@lehnihon/bit-form 2.2.12 → 2.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/angular/index.cjs +1 -1
  2. package/dist/angular/index.js +1 -1
  3. package/dist/{chunk-IDJIIPCS.js → chunk-4NQOD2BA.js} +2 -2
  4. package/dist/{chunk-ZWWXPYEL.js → chunk-7OZR7KWL.js} +2 -2
  5. package/dist/{chunk-QZBJ4WRU.cjs → chunk-ALIYU2RT.cjs} +2 -2
  6. package/dist/{chunk-QZBJ4WRU.cjs.map → chunk-ALIYU2RT.cjs.map} +1 -1
  7. package/dist/{chunk-LZTWNUKZ.js → chunk-EY44ZBGC.js} +2 -2
  8. package/dist/chunk-G4HK5QTU.js +2 -0
  9. package/dist/chunk-G4HK5QTU.js.map +1 -0
  10. package/dist/chunk-IMMFFTXE.js +2 -0
  11. package/dist/chunk-IMMFFTXE.js.map +1 -0
  12. package/dist/{chunk-JPOZKCPR.cjs → chunk-IXZ52RPZ.cjs} +2 -2
  13. package/dist/{chunk-JPOZKCPR.cjs.map → chunk-IXZ52RPZ.cjs.map} +1 -1
  14. package/dist/{chunk-S3DJPXMV.js → chunk-JKYECJH5.js} +2 -2
  15. package/dist/{chunk-MZNHMPTF.cjs → chunk-LM34BK4Q.cjs} +2 -2
  16. package/dist/{chunk-MZNHMPTF.cjs.map → chunk-LM34BK4Q.cjs.map} +1 -1
  17. package/dist/chunk-MAKFWOL5.cjs +2 -0
  18. package/dist/{chunk-OR5AGYQT.cjs.map → chunk-MAKFWOL5.cjs.map} +1 -1
  19. package/dist/chunk-MJ4AOJRT.cjs +2 -0
  20. package/dist/chunk-MJ4AOJRT.cjs.map +1 -0
  21. package/dist/{chunk-C2GGB5NF.cjs → chunk-OSQWKXFI.cjs} +2 -2
  22. package/dist/{chunk-C2GGB5NF.cjs.map → chunk-OSQWKXFI.cjs.map} +1 -1
  23. package/dist/chunk-VOA3SKFY.cjs +2 -0
  24. package/dist/chunk-VOA3SKFY.cjs.map +1 -0
  25. package/dist/chunk-W2FPKUNM.js +2 -0
  26. package/dist/chunk-W2FPKUNM.js.map +1 -0
  27. package/dist/core/bindings.cjs +1 -1
  28. package/dist/core/bindings.js +1 -1
  29. package/dist/core/store.cjs +1 -1
  30. package/dist/core/store.js +1 -1
  31. package/dist/core/utils.cjs +1 -1
  32. package/dist/core/utils.js +1 -1
  33. package/dist/core.cjs +1 -1
  34. package/dist/core.js +1 -1
  35. package/dist/devtools/bridge.cjs +1 -1
  36. package/dist/devtools/bridge.js +1 -1
  37. package/dist/devtools/index.cjs +2 -2
  38. package/dist/devtools/index.js +1 -1
  39. package/dist/index.cjs +1 -1
  40. package/dist/index.js +1 -1
  41. package/dist/react/index.cjs +1 -1
  42. package/dist/react/index.js +1 -1
  43. package/dist/react-native/index.cjs +1 -1
  44. package/dist/react-native/index.js +1 -1
  45. package/dist/utils.cjs +1 -1
  46. package/dist/utils.js +1 -1
  47. package/dist/vue/index.cjs +1 -1
  48. package/dist/vue/index.js +1 -1
  49. package/package.json +1 -1
  50. package/dist/chunk-6NH6MUXA.js +0 -2
  51. package/dist/chunk-6NH6MUXA.js.map +0 -1
  52. package/dist/chunk-CGJRZJ62.js +0 -2
  53. package/dist/chunk-CGJRZJ62.js.map +0 -1
  54. package/dist/chunk-OR5AGYQT.cjs +0 -2
  55. package/dist/chunk-PA43XYOW.cjs +0 -2
  56. package/dist/chunk-PA43XYOW.cjs.map +0 -1
  57. package/dist/chunk-PG7ZH32Z.js +0 -2
  58. package/dist/chunk-PG7ZH32Z.js.map +0 -1
  59. package/dist/chunk-RGMUXQ2K.cjs +0 -2
  60. package/dist/chunk-RGMUXQ2K.cjs.map +0 -1
  61. /package/dist/{chunk-IDJIIPCS.js.map → chunk-4NQOD2BA.js.map} +0 -0
  62. /package/dist/{chunk-ZWWXPYEL.js.map → chunk-7OZR7KWL.js.map} +0 -0
  63. /package/dist/{chunk-LZTWNUKZ.js.map → chunk-EY44ZBGC.js.map} +0 -0
  64. /package/dist/{chunk-S3DJPXMV.js.map → chunk-JKYECJH5.js.map} +0 -0
@@ -0,0 +1,2 @@
1
+ function l(e,n=new WeakMap){if(e===null||typeof e!="object")return e;if(typeof structuredClone=="function")try{return structuredClone(e)}catch{}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(n.has(e))return n.get(e);if(e instanceof Map){let s=new Map;return n.set(e,s),e.forEach((t,o)=>{s.set(l(o,n),l(t,n))}),s}if(e instanceof Set){let s=new Set;return n.set(e,s),e.forEach(t=>{s.add(l(t,n))}),s}if(Array.isArray(e)){let s=[];n.set(e,s);for(let t of e)s.push(l(t,n));return s}let r=Object.getPrototypeOf(e);if(!(r===Object.prototype||r===null)){let s=Object.create(r);n.set(e,s);for(let t of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,t);o&&("value"in o&&(o.value=l(o.value,n)),Object.defineProperty(s,t,o))}return s}let c={};n.set(e,c);for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&(c[s]=l(e[s],n));return c}function p(e){return l(e)}function w(e,n,r=new WeakMap){if(n===void 0)return p(e);if(n===null||typeof n!="object"||n instanceof Date||n instanceof RegExp||Array.isArray(n))return p(n);let a=n;if(r.has(a))return r.get(a);let c=e&&typeof e=="object"&&!Array.isArray(e)?p(e):{};r.set(a,c);try{for(let s of Object.keys(n)){let t=n[s],o=c[s];if(t!==null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof Date)&&!(t instanceof RegExp)){c[s]=w(o,t,r);continue}c[s]=p(t)}}finally{r.delete(a)}return c}function h(e,n){return e===n?!0:e===null||typeof e!="object"||n===null||typeof n!="object"?!1:x(e,n)}function x(e,n){return b(e,n,new WeakMap)}function b(e,n,r){if(e===n)return!0;if(e===null||typeof e!="object"||n===null||typeof n!="object")return!1;let a=r.get(e);if(a?.has(n))return!0;if(a?a.add(n):r.set(e,new WeakSet([n])),Array.isArray(e)!==Array.isArray(n))return!1;if(e instanceof Date&&n instanceof Date)return e.getTime()===n.getTime();if(e instanceof RegExp&&n instanceof RegExp)return e.toString()===n.toString();let c=Object.keys(e),s=Object.keys(n);if(c.length!==s.length)return!1;for(let t of c)if(!Object.prototype.hasOwnProperty.call(n,t)||!b(e[t],n[t],r))return!1;return!0}function R(e,n,r="",a=new Set,c=new Map){if(h(e,n))return a;if(e===null||typeof e!="object"||n===null||typeof n!="object")return r&&a.add(r),a;let s=c.get(e);if(s?.has(n))return a;s?s.add(n):c.set(e,new Set([n]));try{if(Array.isArray(e)||Array.isArray(n))return!h(e,n)&&r&&a.add(r),a;let t=new Set;for(let o of Object.keys(e||{}))t.add(o);for(let o of Object.keys(n||{}))t.add(o);for(let o of t){let i=r?`${r}.${o}`:o;R(e?.[o],n?.[o],i,a,c)}return a}finally{let t=c.get(e);t?.delete(n),t&&t.size===0&&c.delete(e)}}var d=new Map;function T(e,n){if(d.has(e))d.delete(e);else if(d.size>=5e3){let r=d.keys().next().value;r!==void 0&&d.delete(r)}d.set(e,n)}function k(e){let n=d.get(e);if(n)return n;let r=e.split(".");return T(e,r),r}function V(e,n){if(!n)return e;let r=k(n),a=e;for(let c of r){if(a==null)return;a=a[c]}return a}function K(e,n,r){if(!n)return r;let a=k(n),c=Array.isArray(e)?[...e]:{...e},s=c;for(let t=0;t<a.length-1;t++){let o=a[t],i=a[t+1],u=Number(i),f=Number.isInteger(u)&&String(u)===i,y=s[o];y==null?s[o]=f?[]:{}:s[o]=Array.isArray(y)?[...y]:{...y},s=s[o]}return s[a[a.length-1]]=r,c}function E(e,n){if(n.length===0)return e;let r=Array.isArray(e)?[...e]:{...e},a=new WeakSet;r&&typeof r=="object"&&a.add(r);for(let[c,s]of n){let t=k(c),o=r;for(let i=0;i<t.length-1;i++){let u=t[i],f=t[i+1],y=Number(f),m=Number.isInteger(y)&&String(y)===f,g=o[u];g==null?(o[u]=m?[]:{},a.add(o[u])):typeof g=="object"?a.has(g)||(o[u]=Array.isArray(g)?[...g]:{...g},a.add(o[u])):(o[u]=m?[]:{},a.add(o[u])),o=o[u]}o[t[t.length-1]]=s}return r}function D(e,n){if(n.length===0)return e;let r=Array.isArray(e)?[...e]:{...e},a=new WeakSet;r&&typeof r=="object"&&a.add(r);for(let c of n){if(!c)return Array.isArray(e)?[]:{};let s=k(c),t=r;for(let i=0;i<s.length-1;i++){let u=s[i],f=t?.[u];if(f==null){t=void 0;break}if(typeof f=="object")a.has(f)||(t[u]=Array.isArray(f)?[...f]:{...f},a.add(t[u]));else{t=void 0;break}t=t[u]}if(!t)continue;let o=s[s.length-1];if(Array.isArray(t)){let i=Number(o);Number.isInteger(i)&&i>=0&&t.splice(i,1)}else t&&typeof t=="object"&&delete t[o]}return r}function N(e,n){let r={},a=`${n}.`;for(let c in e)c!==n&&!c.startsWith(a)&&(r[c]=e[c]);return r}function S(e,n,r){let a={},c={},s={},t=`${n}.`;for(let o of Object.keys(e.errors)){let i=A(o,t,r);i&&(a[i]=e.errors[o])}for(let o of Object.keys(e.touched)){let i=A(o,t,r);i&&(c[i]=e.touched[o])}for(let o of Object.keys(e.isValidating)){let i=A(o,t,r);i&&(s[i]=e.isValidating[o])}return{errors:a,touched:c,isValidating:s}}function A(e,n,r){if(!e.startsWith(n))return e;let c=e.substring(n.length).split("."),s=Number(c[0]);if(!Number.isInteger(s)||s<0)return e;let t=r(s);if(t===null)return null;let o=c.slice(1).join(".");return o?`${n}${t}.${o}`:`${n}${t}`}function O(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let n=e.errors??e;if(typeof n!="object"||n===null||Array.isArray(n))return!1;let r=Object.entries(n);return r.length===0?!1:r.every(([a,c])=>a.length>0&&(typeof c=="string"||Array.isArray(c)&&c.every(s=>typeof s=="string")))}function j(e){return O(e)?e.errors??e:{}}export{p as a,w as b,h as c,x as d,R as e,V as f,K as g,E as h,D as i,N as j,S as k,A as l,O as m,j as n};
2
+ //# sourceMappingURL=chunk-IMMFFTXE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/utils/clone.ts","../src/core/utils/structural.ts","../src/core/utils/path-value.ts","../src/core/utils/array-meta.ts","../src/core/utils/server-errors.ts"],"sourcesContent":["export function cloneValue<T>(\n obj: T,\n visited: WeakMap<object, unknown> = new WeakMap(),\n): T {\n if (obj === null || typeof obj !== \"object\") {\n return obj;\n }\n\n if (typeof structuredClone === \"function\") {\n try {\n return structuredClone(obj);\n } catch {\n // Alguns runtimes lançam para payloads não suportados (ex.: funções).\n // Nesses casos, seguimos para o clone recursivo para manter fail-open.\n }\n }\n\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as any as T;\n }\n\n if (obj instanceof RegExp) {\n return new RegExp(obj.source, obj.flags) as any as T;\n }\n\n if (visited.has(obj as object)) {\n return visited.get(obj as object) as T;\n }\n\n if (obj instanceof Map) {\n const clone = new Map<unknown, unknown>();\n visited.set(obj as object, clone);\n\n obj.forEach((value, key) => {\n clone.set(cloneValue(key, visited), cloneValue(value, visited));\n });\n\n return clone as T;\n }\n\n if (obj instanceof Set) {\n const clone = new Set<unknown>();\n visited.set(obj as object, clone);\n\n obj.forEach((value) => {\n clone.add(cloneValue(value, visited));\n });\n\n return clone as T;\n }\n\n if (Array.isArray(obj)) {\n const clone: unknown[] = [];\n visited.set(obj as object, clone);\n\n for (const item of obj) {\n clone.push(cloneValue(item, visited));\n }\n\n return clone as T;\n }\n\n const prototype = Object.getPrototypeOf(obj);\n const isPlainObject = prototype === Object.prototype || prototype === null;\n\n if (!isPlainObject) {\n const clone = Object.create(prototype) as Record<PropertyKey, unknown>;\n visited.set(obj as object, clone);\n\n for (const key of Reflect.ownKeys(obj as object)) {\n const descriptor = Object.getOwnPropertyDescriptor(obj as object, key);\n if (!descriptor) {\n continue;\n }\n\n if (\"value\" in descriptor) {\n descriptor.value = cloneValue(descriptor.value, visited);\n }\n\n Object.defineProperty(clone, key, descriptor);\n }\n\n return clone as T;\n }\n\n const clone: any = {};\n visited.set(obj as object, clone);\n\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n clone[key] = cloneValue((obj as any)[key], visited);\n }\n }\n\n return clone as T;\n}\n","import { cloneValue } from \"./clone\";\n\nexport function deepClone<T>(obj: T): T {\n return cloneValue(obj);\n}\n\nexport function deepMerge<T>(\n target: T,\n source: any,\n activeMerges: WeakMap<object, unknown> = new WeakMap(),\n): T {\n if (source === undefined) {\n return deepClone(target);\n }\n\n if (\n source === null ||\n typeof source !== \"object\" ||\n source instanceof Date ||\n source instanceof RegExp ||\n Array.isArray(source)\n ) {\n return deepClone(source as T);\n }\n\n const sourceObject = source as object;\n if (activeMerges.has(sourceObject)) {\n return activeMerges.get(sourceObject) as T;\n }\n\n const base =\n target && typeof target === \"object\" && !Array.isArray(target)\n ? deepClone(target as any)\n : ({} as Record<string, unknown>);\n\n activeMerges.set(sourceObject, base);\n\n try {\n for (const key of Object.keys(source)) {\n const sourceValue = source[key];\n const baseValue = (base as Record<string, unknown>)[key];\n\n if (\n sourceValue !== null &&\n typeof sourceValue === \"object\" &&\n !Array.isArray(sourceValue) &&\n !(sourceValue instanceof Date) &&\n !(sourceValue instanceof RegExp)\n ) {\n (base as Record<string, unknown>)[key] = deepMerge(\n baseValue,\n sourceValue,\n activeMerges,\n );\n continue;\n }\n\n (base as Record<string, unknown>)[key] = deepClone(sourceValue);\n }\n } finally {\n activeMerges.delete(sourceObject);\n }\n\n return base as T;\n}\n\nexport function valueEqual(a: any, b: any): boolean {\n if (a === b) return true;\n if (\n a === null ||\n typeof a !== \"object\" ||\n b === null ||\n typeof b !== \"object\"\n ) {\n return false;\n }\n return deepEqual(a, b);\n}\n\nexport function deepEqual(a: any, b: any): boolean {\n return deepEqualInner(a, b, new WeakMap());\n}\n\nfunction deepEqualInner(\n a: any,\n b: any,\n visitedPairs: WeakMap<object, WeakSet<object>>,\n): boolean {\n if (a === b) return true;\n if (\n a === null ||\n typeof a !== \"object\" ||\n b === null ||\n typeof b !== \"object\"\n ) {\n return false;\n }\n\n const visitedTargets = visitedPairs.get(a);\n if (visitedTargets?.has(b)) return true;\n\n if (visitedTargets) {\n visitedTargets.add(b);\n } else {\n visitedPairs.set(a, new WeakSet([b]));\n }\n\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n\n if (a instanceof Date && b instanceof Date)\n return a.getTime() === b.getTime();\n if (a instanceof RegExp && b instanceof RegExp)\n return a.toString() === b.toString();\n\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (\n !Object.prototype.hasOwnProperty.call(b, key) ||\n !deepEqualInner(a[key], b[key], visitedPairs)\n ) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function collectDirtyPaths(\n obj: any,\n initial: any,\n prefix = \"\",\n result: Set<string> = new Set(),\n activePairs: Map<object, Set<object>> = new Map(),\n): Set<string> {\n if (valueEqual(obj, initial)) return result;\n if (\n obj === null ||\n typeof obj !== \"object\" ||\n initial === null ||\n typeof initial !== \"object\"\n ) {\n if (prefix) result.add(prefix);\n return result;\n }\n\n const activeInitials = activePairs.get(obj as object);\n if (activeInitials?.has(initial as object)) {\n return result;\n }\n\n if (activeInitials) {\n activeInitials.add(initial as object);\n } else {\n activePairs.set(obj as object, new Set([initial as object]));\n }\n\n try {\n if (Array.isArray(obj) || Array.isArray(initial)) {\n if (!valueEqual(obj, initial) && prefix) result.add(prefix);\n return result;\n }\n const allKeys = new Set<string>();\n for (const key of Object.keys(obj || {})) {\n allKeys.add(key);\n }\n for (const key of Object.keys(initial || {})) {\n allKeys.add(key);\n }\n for (const k of allKeys) {\n const p = prefix ? `${prefix}.${k}` : k;\n collectDirtyPaths(\n (obj as any)?.[k],\n (initial as any)?.[k],\n p,\n result,\n activePairs,\n );\n }\n return result;\n } finally {\n const nextActiveInitials = activePairs.get(obj as object);\n nextActiveInitials?.delete(initial as object);\n\n if (nextActiveInitials && nextActiveInitials.size === 0) {\n activePairs.delete(obj as object);\n }\n }\n}\n","const PATH_CACHE_MAX = 5000;\nconst pathCache = new Map<string, string[]>();\n\nfunction setPathCacheEntry(path: string, keys: string[]) {\n if (pathCache.has(path)) {\n pathCache.delete(path);\n } else if (pathCache.size >= PATH_CACHE_MAX) {\n const oldestKey = pathCache.keys().next().value;\n if (oldestKey !== undefined) {\n pathCache.delete(oldestKey);\n }\n }\n\n pathCache.set(path, keys);\n}\n\nfunction getPathKeys(path: string): string[] {\n const cached = pathCache.get(path);\n if (cached) {\n return cached;\n }\n\n const keys = path.split(\".\");\n setPathCacheEntry(path, keys);\n return keys;\n}\n\nexport function getDeepValue(obj: any, path: string): any {\n if (!path) return obj;\n\n const keys = getPathKeys(path);\n\n let current = obj;\n for (const key of keys) {\n if (current === null || current === undefined) return undefined;\n current = current[key];\n }\n return current;\n}\n\nexport function setDeepValue(obj: any, path: string, value: any): any {\n if (!path) return value;\n\n const keys = getPathKeys(path);\n\n const result = Array.isArray(obj) ? [...obj] : { ...obj };\n let current = result;\n\n for (let i = 0; i < keys.length - 1; i++) {\n const key = keys[i];\n const nextKey = keys[i + 1];\n\n const nextAsNumber = Number(nextKey);\n const isNextNumeric =\n Number.isInteger(nextAsNumber) && String(nextAsNumber) === nextKey;\n const currentValue = current[key];\n\n if (currentValue === null || currentValue === undefined) {\n current[key] = isNextNumeric ? [] : {};\n } else {\n current[key] = Array.isArray(currentValue)\n ? [...currentValue]\n : { ...currentValue };\n }\n\n current = current[key];\n }\n\n current[keys[keys.length - 1]] = value;\n\n return result;\n}\n\nexport function setDeepValues(\n obj: any,\n updates: ReadonlyArray<readonly [path: string, value: any]>,\n): any {\n if (updates.length === 0) {\n return obj;\n }\n\n const root = Array.isArray(obj) ? [...obj] : { ...obj };\n const clonedNodes = new WeakSet<object>();\n if (root && typeof root === \"object\") {\n clonedNodes.add(root);\n }\n\n for (const [path, value] of updates) {\n const keys = getPathKeys(path);\n let current: any = root;\n\n for (let i = 0; i < keys.length - 1; i++) {\n const key = keys[i];\n const nextKey = keys[i + 1];\n\n const nextAsNumber = Number(nextKey);\n const isNextNumeric =\n Number.isInteger(nextAsNumber) && String(nextAsNumber) === nextKey;\n\n const currentValue = current[key];\n\n if (currentValue === null || currentValue === undefined) {\n current[key] = isNextNumeric ? [] : {};\n clonedNodes.add(current[key]);\n } else if (typeof currentValue === \"object\") {\n if (!clonedNodes.has(currentValue)) {\n current[key] = Array.isArray(currentValue)\n ? [...currentValue]\n : { ...currentValue };\n clonedNodes.add(current[key]);\n }\n } else {\n current[key] = isNextNumeric ? [] : {};\n clonedNodes.add(current[key]);\n }\n\n current = current[key];\n }\n\n current[keys[keys.length - 1]] = value;\n }\n\n return root;\n}\n\nexport function unsetDeepValue(obj: any, path: string): any {\n if (!path) {\n return Array.isArray(obj) ? [] : {};\n }\n\n const keys = getPathKeys(path);\n const root = Array.isArray(obj) ? [...obj] : { ...obj };\n let current: any = root;\n\n for (let i = 0; i < keys.length - 1; i++) {\n const key = keys[i];\n const currentValue = current?.[key];\n\n if (currentValue === null || currentValue === undefined) {\n return root;\n }\n\n current[key] = Array.isArray(currentValue)\n ? [...currentValue]\n : { ...currentValue };\n\n current = current[key];\n }\n\n const leafKey = keys[keys.length - 1];\n\n if (Array.isArray(current)) {\n const arrayIndex = Number(leafKey);\n // Only splice if leafKey is a valid array index (integer >= 0)\n if (Number.isInteger(arrayIndex) && arrayIndex >= 0) {\n current.splice(arrayIndex, 1);\n }\n } else if (current && typeof current === \"object\") {\n delete current[leafKey];\n }\n\n return root;\n}\n\nexport function unsetDeepValues(obj: any, paths: ReadonlyArray<string>): any {\n if (paths.length === 0) {\n return obj;\n }\n\n const root = Array.isArray(obj) ? [...obj] : { ...obj };\n const clonedNodes = new WeakSet<object>();\n if (root && typeof root === \"object\") {\n clonedNodes.add(root);\n }\n\n for (const path of paths) {\n if (!path) {\n return Array.isArray(obj) ? [] : {};\n }\n\n const keys = getPathKeys(path);\n let current: any = root;\n\n for (let i = 0; i < keys.length - 1; i++) {\n const key = keys[i];\n const currentValue = current?.[key];\n\n if (currentValue === null || currentValue === undefined) {\n current = undefined;\n break;\n }\n\n if (typeof currentValue === \"object\") {\n if (!clonedNodes.has(currentValue)) {\n current[key] = Array.isArray(currentValue)\n ? [...currentValue]\n : { ...currentValue };\n clonedNodes.add(current[key]);\n }\n } else {\n current = undefined;\n break;\n }\n\n current = current[key];\n }\n\n if (!current) {\n continue;\n }\n\n const leafKey = keys[keys.length - 1];\n\n if (Array.isArray(current)) {\n const arrayIndex = Number(leafKey);\n // Only splice if leafKey is a valid array index (integer >= 0)\n if (Number.isInteger(arrayIndex) && arrayIndex >= 0) {\n current.splice(arrayIndex, 1);\n }\n } else if (current && typeof current === \"object\") {\n delete current[leafKey];\n }\n }\n\n return root;\n}\n","export function cleanPrefixedKeys(\n obj: Record<string, any>,\n prefix: string,\n): Record<string, any> {\n const newObj: Record<string, any> = {};\n const prefixWithDot = `${prefix}.`;\n\n for (const key in obj) {\n if (key !== prefix && !key.startsWith(prefixWithDot)) {\n newObj[key] = obj[key];\n }\n }\n return newObj;\n}\n\nexport const shiftKeys = (\n obj: Record<string, any>,\n path: string,\n removedIndex: number,\n) => {\n return reindexObjectKeys(obj, path, (currentIdx) => {\n if (currentIdx === removedIndex) {\n return null;\n }\n\n return currentIdx > removedIndex ? currentIdx - 1 : currentIdx;\n });\n};\n\nexport const swapKeys = (\n obj: Record<string, any>,\n path: string,\n indexA: number,\n indexB: number,\n) => {\n return reindexObjectKeys(obj, path, (currentIdx) => {\n if (currentIdx === indexA) {\n return indexB;\n }\n\n if (currentIdx === indexB) {\n return indexA;\n }\n\n return currentIdx;\n });\n};\n\nexport const moveKeys = (\n obj: Record<string, any>,\n path: string,\n from: number,\n to: number,\n) => {\n return reindexObjectKeys(obj, path, (currentIdx) => {\n if (currentIdx === from) {\n return to;\n }\n\n if (from < to && currentIdx > from && currentIdx <= to) {\n return currentIdx - 1;\n }\n\n if (from > to && currentIdx >= to && currentIdx < from) {\n return currentIdx + 1;\n }\n\n return currentIdx;\n });\n};\n\nexport function reindexFieldArrayMeta(\n state: {\n errors: Record<string, any>;\n touched: Record<string, any>;\n isValidating: Record<string, any>;\n },\n path: string,\n remapIndex: (index: number) => number | null,\n) {\n const nextErrors: Record<string, any> = {};\n const nextTouched: Record<string, any> = {};\n const nextIsValidating: Record<string, any> = {};\n\n const prefix = `${path}.`;\n\n for (const key of Object.keys(state.errors)) {\n const nextKey = remapIndexedPath(key, prefix, remapIndex);\n if (nextKey) nextErrors[nextKey] = state.errors[key];\n }\n\n for (const key of Object.keys(state.touched)) {\n const nextKey = remapIndexedPath(key, prefix, remapIndex);\n if (nextKey) nextTouched[nextKey] = state.touched[key];\n }\n\n for (const key of Object.keys(state.isValidating)) {\n const nextKey = remapIndexedPath(key, prefix, remapIndex);\n if (nextKey) nextIsValidating[nextKey] = state.isValidating[key];\n }\n\n return {\n errors: nextErrors,\n touched: nextTouched,\n isValidating: nextIsValidating,\n };\n}\n\nexport function remapIndexedPath(\n key: string,\n prefix: string,\n remapIndex: (index: number) => number | null,\n): string | null {\n if (!key.startsWith(prefix)) {\n return key;\n }\n\n const remaining = key.substring(prefix.length);\n const parts = remaining.split(\".\");\n const currentIdx = Number(parts[0]);\n if (!Number.isInteger(currentIdx) || currentIdx < 0) {\n return key;\n }\n const nextIdx = remapIndex(currentIdx);\n\n if (nextIdx === null) {\n return null;\n }\n\n const rest = parts.slice(1).join(\".\");\n return rest ? `${prefix}${nextIdx}.${rest}` : `${prefix}${nextIdx}`;\n}\n\nfunction reindexObjectKeys(\n obj: Record<string, any>,\n path: string,\n remapIndex: (index: number) => number | null,\n) {\n const nextObject: Record<string, any> = {};\n const prefix = `${path}.`;\n\n for (const key of Object.keys(obj)) {\n if (!key.startsWith(prefix)) {\n nextObject[key] = obj[key];\n continue;\n }\n\n const remaining = key.substring(prefix.length);\n const parts = remaining.split(\".\");\n const currentIdx = Number(parts[0]);\n if (!Number.isInteger(currentIdx) || currentIdx < 0) {\n nextObject[key] = obj[key];\n continue;\n }\n const nextIdx = remapIndex(currentIdx);\n\n if (nextIdx === null) {\n continue;\n }\n\n const rest = parts.slice(1).join(\".\");\n const nextKey = rest\n ? `${prefix}${nextIdx}.${rest}`\n : `${prefix}${nextIdx}`;\n nextObject[nextKey] = obj[key];\n }\n\n return nextObject;\n}\n","export function isValidationErrorShape(\n x: unknown,\n): x is Record<string, string | string[]> {\n if (typeof x !== \"object\" || x === null || Array.isArray(x)) return false;\n\n const obj = (x as Record<string, unknown>).errors ?? x;\n if (typeof obj !== \"object\" || obj === null || Array.isArray(obj)) {\n return false;\n }\n\n const entries = Object.entries(obj as Record<string, unknown>);\n if (entries.length === 0) {\n return false;\n }\n\n return entries.every(\n ([key, v]) =>\n key.length > 0 &&\n (typeof v === \"string\" ||\n (Array.isArray(v) && v.every((i) => typeof i === \"string\"))),\n );\n}\n\nexport function extractServerErrors(\n x: unknown,\n): Record<string, string | string[]> {\n if (!isValidationErrorShape(x)) return {};\n\n const obj = (x as Record<string, unknown>).errors ?? x;\n return obj as Record<string, string | string[]>;\n}\n"],"mappings":"AAAO,SAASA,EACdC,EACAC,EAAoC,IAAI,QACrC,CACH,GAAID,IAAQ,MAAQ,OAAOA,GAAQ,SACjC,OAAOA,EAGT,GAAI,OAAO,iBAAoB,WAC7B,GAAI,CACF,OAAO,gBAAgBA,CAAG,CAC5B,MAAQ,CAGR,CAGF,GAAIA,aAAe,KACjB,OAAO,IAAI,KAAKA,EAAI,QAAQ,CAAC,EAG/B,GAAIA,aAAe,OACjB,OAAO,IAAI,OAAOA,EAAI,OAAQA,EAAI,KAAK,EAGzC,GAAIC,EAAQ,IAAID,CAAa,EAC3B,OAAOC,EAAQ,IAAID,CAAa,EAGlC,GAAIA,aAAe,IAAK,CACtB,IAAME,EAAQ,IAAI,IAClB,OAAAD,EAAQ,IAAID,EAAeE,CAAK,EAEhCF,EAAI,QAAQ,CAACG,EAAOC,IAAQ,CAC1BF,EAAM,IAAIH,EAAWK,EAAKH,CAAO,EAAGF,EAAWI,EAAOF,CAAO,CA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D,EACAJ,EACe,CACf,GAAI,CAACK,EAAI,WAAWD,CAAM,EACxB,OAAOC,EAIT,IAAMG,EADYH,EAAI,UAAUD,EAAO,MAAM,EACrB,MAAM,GAAG,EAC3BK,EAAa,OAAOD,EAAM,CAAC,CAAC,EAClC,GAAI,CAAC,OAAO,UAAUC,CAAU,GAAKA,EAAa,EAChD,OAAOJ,EAET,IAAMK,EAAUV,EAAWS,CAAU,EAErC,GAAIC,IAAY,KACd,OAAO,KAGT,IAAMC,EAAOH,EAAM,MAAM,CAAC,EAAE,KAAK,GAAG,EACpC,OAAOG,EAAO,GAAGP,CAAM,GAAGM,CAAO,IAAIC,CAAI,GAAK,GAAGP,CAAM,GAAGM,CAAO,EACnE,CCnIO,SAASE,EACdC,EACwC,CACxC,GAAI,OAAOA,GAAM,UAAYA,IAAM,MAAQ,MAAM,QAAQA,CAAC,EAAG,MAAO,GAEpE,IAAMC,EAAOD,EAA8B,QAAUA,EACrD,GAAI,OAAOC,GAAQ,UAAYA,IAAQ,MAAQ,MAAM,QAAQA,CAAG,EAC9D,MAAO,GAGT,IAAMC,EAAU,OAAO,QAAQD,CAA8B,EAC7D,OAAIC,EAAQ,SAAW,EACd,GAGFA,EAAQ,MACb,CAAC,CAACC,EAAKC,CAAC,IACND,EAAI,OAAS,IACZ,OAAOC,GAAM,UACX,MAAM,QAAQA,CAAC,GAAKA,EAAE,MAAOC,GAAM,OAAOA,GAAM,QAAQ,EAC/D,CACF,CAEO,SAASC,EACdN,EACmC,CACnC,OAAKD,EAAuBC,CAAC,EAEhBA,EAA8B,QAAUA,EAFd,CAAC,CAI1C","names":["cloneValue","obj","visited","clone","value","key","item","prototype","descriptor","deepClone","obj","cloneValue","deepMerge","target","source","activeMerges","sourceObject","base","key","sourceValue","baseValue","valueEqual","a","b","deepEqual","deepEqualInner","visitedPairs","visitedTargets","keysA","keysB","collectDirtyPaths","initial","prefix","result","activePairs","activeInitials","allKeys","k","p","nextActiveInitials","pathCache","setPathCacheEntry","path","keys","oldestKey","getPathKeys","cached","getDeepValue","obj","current","key","setDeepValue","value","result","i","nextKey","nextAsNumber","isNextNumeric","currentValue","setDeepValues","updates","root","clonedNodes","unsetDeepValues","obj","paths","root","clonedNodes","path","keys","getPathKeys","current","key","currentValue","leafKey","arrayIndex","cleanPrefixedKeys","obj","prefix","newObj","prefixWithDot","key","reindexFieldArrayMeta","state","path","remapIndex","nextErrors","nextTouched","nextIsValidating","prefix","key","nextKey","remapIndexedPath","parts","currentIdx","nextIdx","rest","isValidationErrorShape","x","obj","entries","key","v","i","extractServerErrors"]}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunkOR5AGYQTcjs = require('./chunk-OR5AGYQT.cjs');var _chunkQZBJ4WRUcjs = require('./chunk-QZBJ4WRU.cjs');var _chunkRHMJPKNVcjs = require('./chunk-RHMJPKNV.cjs');var _chunkC2GGB5NFcjs = require('./chunk-C2GGB5NF.cjs');var _chunkRGMUXQ2Kcjs = require('./chunk-RGMUXQ2K.cjs');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var L=_react.createContext.call(void 0, null),ft= exports.a =({store:t,children:e})=>_jsxruntime.jsx.call(void 0, L.Provider,{value:_chunkOR5AGYQTcjs.d.call(void 0, t),children:e}),l= exports.b =()=>{let t=_react.useContext.call(void 0, L);if(!t)throw new Error("BitForm hooks devem ser usados dentro de um BitFormProvider");return t};function Pt(){let t=l(),[e,r]=_react.useState.call(void 0, null),[i,s]=_react.useState.call(void 0, null),o=_react.useRef.call(void 0, null),c=_react.useCallback.call(void 0, S=>_chunkQZBJ4WRUcjs.b.call(void 0, t,S),[t]),m=_react.useCallback.call(void 0, ()=>{let S=_chunkQZBJ4WRUcjs.a.call(void 0, t);return o.current&&o.current.isValid===S.isValid&&o.current.isDirty===S.isDirty&&o.current.isSubmitting===S.isSubmitting?o.current:(o.current=S,S)},[t]),n=_react.useSyncExternalStore.call(void 0, c,m,m),d=_react.useMemo.call(void 0, ()=>_chunkQZBJ4WRUcjs.i.call(void 0, t,{clearSubmissionState:()=>{r(null),s(null)},setSubmissionResult:S=>{s(S)},setSubmissionError:S=>{r(S)}}),[t]),{controller:a,actions:x}=d,v=_react.useCallback.call(void 0, a.submit,[a]),T=_react.useCallback.call(void 0, a.onSubmit,[a]),E=_react.useCallback.call(void 0, a.reset,[a]),u=_react.useCallback.call(void 0, a.getValues,[a]),b=_react.useCallback.call(void 0, a.getErrors,[a]),B=_react.useCallback.call(void 0, a.getTouched,[a]),g=_react.useCallback.call(void 0, a.getDirtyValues,[a]);return{meta:_react.useMemo.call(void 0, ()=>({...n,submitError:e,lastResponse:i}),[n,e,i]),getValues:u,getErrors:b,getTouched:B,getDirtyValues:g,submit:v,onSubmit:T,reset:E,...x}}function Rt(t){let e=l(),r=_react.useMemo.call(void 0, ()=>_chunkQZBJ4WRUcjs.g.call(void 0, e,t),[e,t]),i=_react.useRef.call(void 0, null),s=_react.useCallback.call(void 0, ()=>{let n=r.readItems();return i.current&&_chunkRGMUXQ2Kcjs.c.call(void 0, i.current,n)?i.current:(i.current=n,n)},[r]),o=_react.useCallback.call(void 0, n=>e.observe.subscribePath(t,()=>n()),[e,t]),c=_react.useSyncExternalStore.call(void 0, o,s,s),m=_react.useMemo.call(void 0, ()=>r.getFields(c),[r,c]);return _react.useEffect.call(void 0, ()=>()=>{_chunkQZBJ4WRUcjs.k.call(void 0, e,`${t}.`)},[e,t]),{fields:m,length:c.length,append:r.append,prepend:r.prepend,insert:r.insert,remove:r.remove,move:r.move,swap:r.swap,replace:r.replace,clear:r.clear}}function At(t){let e=l(),r=_react.useRef.call(void 0, null),i=_react.useCallback.call(void 0, ()=>{let n=e.read.getScopeStatus(t);return r.current&&_chunkRHMJPKNVcjs.b.call(void 0, r.current,n)?r.current:(r.current=n,n)},[e,t]),s=_react.useCallback.call(void 0, n=>e.observe.subscribeScopeStatus(t,()=>n()),[e,t]),o=_react.useSyncExternalStore.call(void 0, s,i,i),c=_react.useCallback.call(void 0, async()=>{let n=await e.feature.validate({scope:t}),d=e.read.getScopeErrors(t);return{valid:n,errors:d}},[e,t]),m=_react.useCallback.call(void 0, ()=>e.read.getScopeErrors(t),[e,t]);return{scopeName:t,status:o,errors:o.errors,validate:c,getErrors:m,isValid:!o.hasErrors,isDirty:o.isDirty}}function It(t){let e=l(),[r,i]=_react.useState.call(void 0, 0),s=_nullishCoalesce(t[r], () => ("")),o=_react.useRef.call(void 0, null),c=_react.useCallback.call(void 0, ()=>{let u=e.read.getScopeStatus(s);return o.current&&_chunkRHMJPKNVcjs.b.call(void 0, o.current,u)?o.current:(o.current=u,u)},[e,s]),m=_react.useSyncExternalStore.call(void 0, _react.useCallback.call(void 0, u=>e.observe.subscribeScopeStatus(s,()=>u()),[e,s]),c,c),n=_react.useCallback.call(void 0, async()=>{let u=await e.feature.validate({scope:s}),b=e.read.getScopeErrors(s);return{valid:u,errors:b}},[e,s]),d=_react.useCallback.call(void 0, ()=>e.read.getScopeErrors(s),[e,s]),a=_react.useCallback.call(void 0, async()=>{let u=e.read.getScopeFields(s);if(e.feature.hasValidationsInProgress(u))return!1;let b=await e.feature.validate({scope:s});if(b)i(B=>Math.min(B+1,t.length-1));else{let B=e.read.getScopeErrors(s),g=Object.keys(B);g.length>0&&e.write.markFieldsTouched(g)}return b},[e,s,t.length]),x=_react.useCallback.call(void 0, ()=>{i(u=>Math.max(u-1,0))},[]),v=_react.useCallback.call(void 0, u=>{i(Math.max(0,Math.min(u-1,t.length-1)))},[t.length]),T=r===0,E=r>=t.length-1;return{step:r+1,stepIndex:r,scope:s,next:a,prev:x,goTo:v,isFirst:T,isLast:E,status:m,errors:m.errors,isValid:!m.hasErrors,isDirty:m.isDirty,validate:n,getErrors:d}}function zt(t){let e=l(),r=_react.useRef.call(void 0, null),i=_react.useCallback.call(void 0, ()=>{let o=_chunkRGMUXQ2Kcjs.f.call(void 0, e.read.getState().values,t);return r.current!==null&&_chunkRGMUXQ2Kcjs.c.call(void 0, r.current,o)?r.current:(r.current=o,o)},[e,t]),s=_react.useCallback.call(void 0, o=>e.observe.subscribePath(t,()=>o()),[e,t]);return _react.useSyncExternalStore.call(void 0, s,i,i)}function Qt(){let t=l(),e=_react.useSyncExternalStore.call(void 0, c=>_chunkQZBJ4WRUcjs.e.call(void 0, t,c),()=>_chunkQZBJ4WRUcjs.d.call(void 0, t),()=>_chunkQZBJ4WRUcjs.d.call(void 0, t)),r=_react.useCallback.call(void 0, async()=>t.feature.restorePersisted(),[t]),i=_react.useCallback.call(void 0, async()=>{await t.feature.forceSave()},[t]),s=_react.useCallback.call(void 0, async()=>{await t.feature.clearPersisted()},[t]),o=_react.useMemo.call(void 0, ()=>({isSaving:e.isSaving,isRestoring:e.isRestoring,error:e.error}),[e]);return{restore:r,save:i,clear:s,meta:o}}function se(t){let e=l(),r=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>()=>_chunkQZBJ4WRUcjs.j.call(void 0, e,t),[e,t]);let i=_react.useCallback.call(void 0, ()=>{let n=e.read.getFieldState(t),d=_chunkC2GGB5NFcjs.a.call(void 0, n,r.current);return r.current=d,d},[e,t]),s=_react.useCallback.call(void 0, n=>e.observe.subscribeFieldState(t,()=>n()),[e,t]),o=_react.useSyncExternalStore.call(void 0, s,i,i),c=_react.useCallback.call(void 0, n=>e.write.setField(t,n),[e,t]),m=_react.useCallback.call(void 0, ()=>e.write.blurField(t),[e,t]);return{fieldState:o,setValue:c,setBlur:m,store:e}}exports.a = ft; exports.b = l; exports.c = Pt; exports.d = se; exports.e = Rt; exports.f = At; exports.g = It; exports.h = zt; exports.i = Qt;
2
- //# sourceMappingURL=chunk-JPOZKCPR.cjs.map
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunkMAKFWOL5cjs = require('./chunk-MAKFWOL5.cjs');var _chunkALIYU2RTcjs = require('./chunk-ALIYU2RT.cjs');var _chunkRHMJPKNVcjs = require('./chunk-RHMJPKNV.cjs');var _chunkOSQWKXFIcjs = require('./chunk-OSQWKXFI.cjs');var _chunkVOA3SKFYcjs = require('./chunk-VOA3SKFY.cjs');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var L=_react.createContext.call(void 0, null),ft= exports.a =({store:t,children:e})=>_jsxruntime.jsx.call(void 0, L.Provider,{value:_chunkMAKFWOL5cjs.d.call(void 0, t),children:e}),l= exports.b =()=>{let t=_react.useContext.call(void 0, L);if(!t)throw new Error("BitForm hooks devem ser usados dentro de um BitFormProvider");return t};function Pt(){let t=l(),[e,r]=_react.useState.call(void 0, null),[i,s]=_react.useState.call(void 0, null),o=_react.useRef.call(void 0, null),c=_react.useCallback.call(void 0, S=>_chunkALIYU2RTcjs.b.call(void 0, t,S),[t]),m=_react.useCallback.call(void 0, ()=>{let S=_chunkALIYU2RTcjs.a.call(void 0, t);return o.current&&o.current.isValid===S.isValid&&o.current.isDirty===S.isDirty&&o.current.isSubmitting===S.isSubmitting?o.current:(o.current=S,S)},[t]),n=_react.useSyncExternalStore.call(void 0, c,m,m),d=_react.useMemo.call(void 0, ()=>_chunkALIYU2RTcjs.i.call(void 0, t,{clearSubmissionState:()=>{r(null),s(null)},setSubmissionResult:S=>{s(S)},setSubmissionError:S=>{r(S)}}),[t]),{controller:a,actions:x}=d,v=_react.useCallback.call(void 0, a.submit,[a]),T=_react.useCallback.call(void 0, a.onSubmit,[a]),E=_react.useCallback.call(void 0, a.reset,[a]),u=_react.useCallback.call(void 0, a.getValues,[a]),b=_react.useCallback.call(void 0, a.getErrors,[a]),B=_react.useCallback.call(void 0, a.getTouched,[a]),g=_react.useCallback.call(void 0, a.getDirtyValues,[a]);return{meta:_react.useMemo.call(void 0, ()=>({...n,submitError:e,lastResponse:i}),[n,e,i]),getValues:u,getErrors:b,getTouched:B,getDirtyValues:g,submit:v,onSubmit:T,reset:E,...x}}function Rt(t){let e=l(),r=_react.useMemo.call(void 0, ()=>_chunkALIYU2RTcjs.g.call(void 0, e,t),[e,t]),i=_react.useRef.call(void 0, null),s=_react.useCallback.call(void 0, ()=>{let n=r.readItems();return i.current&&_chunkVOA3SKFYcjs.c.call(void 0, i.current,n)?i.current:(i.current=n,n)},[r]),o=_react.useCallback.call(void 0, n=>e.observe.subscribePath(t,()=>n()),[e,t]),c=_react.useSyncExternalStore.call(void 0, o,s,s),m=_react.useMemo.call(void 0, ()=>r.getFields(c),[r,c]);return _react.useEffect.call(void 0, ()=>()=>{_chunkALIYU2RTcjs.k.call(void 0, e,`${t}.`)},[e,t]),{fields:m,length:c.length,append:r.append,prepend:r.prepend,insert:r.insert,remove:r.remove,move:r.move,swap:r.swap,replace:r.replace,clear:r.clear}}function At(t){let e=l(),r=_react.useRef.call(void 0, null),i=_react.useCallback.call(void 0, ()=>{let n=e.read.getScopeStatus(t);return r.current&&_chunkRHMJPKNVcjs.b.call(void 0, r.current,n)?r.current:(r.current=n,n)},[e,t]),s=_react.useCallback.call(void 0, n=>e.observe.subscribeScopeStatus(t,()=>n()),[e,t]),o=_react.useSyncExternalStore.call(void 0, s,i,i),c=_react.useCallback.call(void 0, async()=>{let n=await e.feature.validate({scope:t}),d=e.read.getScopeErrors(t);return{valid:n,errors:d}},[e,t]),m=_react.useCallback.call(void 0, ()=>e.read.getScopeErrors(t),[e,t]);return{scopeName:t,status:o,errors:o.errors,validate:c,getErrors:m,isValid:!o.hasErrors,isDirty:o.isDirty}}function It(t){let e=l(),[r,i]=_react.useState.call(void 0, 0),s=_nullishCoalesce(t[r], () => ("")),o=_react.useRef.call(void 0, null),c=_react.useCallback.call(void 0, ()=>{let u=e.read.getScopeStatus(s);return o.current&&_chunkRHMJPKNVcjs.b.call(void 0, o.current,u)?o.current:(o.current=u,u)},[e,s]),m=_react.useSyncExternalStore.call(void 0, _react.useCallback.call(void 0, u=>e.observe.subscribeScopeStatus(s,()=>u()),[e,s]),c,c),n=_react.useCallback.call(void 0, async()=>{let u=await e.feature.validate({scope:s}),b=e.read.getScopeErrors(s);return{valid:u,errors:b}},[e,s]),d=_react.useCallback.call(void 0, ()=>e.read.getScopeErrors(s),[e,s]),a=_react.useCallback.call(void 0, async()=>{let u=e.read.getScopeFields(s);if(e.feature.hasValidationsInProgress(u))return!1;let b=await e.feature.validate({scope:s});if(b)i(B=>Math.min(B+1,t.length-1));else{let B=e.read.getScopeErrors(s),g=Object.keys(B);g.length>0&&e.write.markFieldsTouched(g)}return b},[e,s,t.length]),x=_react.useCallback.call(void 0, ()=>{i(u=>Math.max(u-1,0))},[]),v=_react.useCallback.call(void 0, u=>{i(Math.max(0,Math.min(u-1,t.length-1)))},[t.length]),T=r===0,E=r>=t.length-1;return{step:r+1,stepIndex:r,scope:s,next:a,prev:x,goTo:v,isFirst:T,isLast:E,status:m,errors:m.errors,isValid:!m.hasErrors,isDirty:m.isDirty,validate:n,getErrors:d}}function zt(t){let e=l(),r=_react.useRef.call(void 0, null),i=_react.useCallback.call(void 0, ()=>{let o=_chunkVOA3SKFYcjs.f.call(void 0, e.read.getState().values,t);return r.current!==null&&_chunkVOA3SKFYcjs.c.call(void 0, r.current,o)?r.current:(r.current=o,o)},[e,t]),s=_react.useCallback.call(void 0, o=>e.observe.subscribePath(t,()=>o()),[e,t]);return _react.useSyncExternalStore.call(void 0, s,i,i)}function Qt(){let t=l(),e=_react.useSyncExternalStore.call(void 0, c=>_chunkALIYU2RTcjs.e.call(void 0, t,c),()=>_chunkALIYU2RTcjs.d.call(void 0, t),()=>_chunkALIYU2RTcjs.d.call(void 0, t)),r=_react.useCallback.call(void 0, async()=>t.feature.restorePersisted(),[t]),i=_react.useCallback.call(void 0, async()=>{await t.feature.forceSave()},[t]),s=_react.useCallback.call(void 0, async()=>{await t.feature.clearPersisted()},[t]),o=_react.useMemo.call(void 0, ()=>({isSaving:e.isSaving,isRestoring:e.isRestoring,error:e.error}),[e]);return{restore:r,save:i,clear:s,meta:o}}function se(t){let e=l(),r=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>()=>_chunkALIYU2RTcjs.j.call(void 0, e,t),[e,t]);let i=_react.useCallback.call(void 0, ()=>{let n=e.read.getFieldState(t),d=_chunkOSQWKXFIcjs.a.call(void 0, n,r.current);return r.current=d,d},[e,t]),s=_react.useCallback.call(void 0, n=>e.observe.subscribeFieldState(t,()=>n()),[e,t]),o=_react.useSyncExternalStore.call(void 0, s,i,i),c=_react.useCallback.call(void 0, n=>e.write.setField(t,n),[e,t]),m=_react.useCallback.call(void 0, ()=>e.write.blurField(t),[e,t]);return{fieldState:o,setValue:c,setBlur:m,store:e}}exports.a = ft; exports.b = l; exports.c = Pt; exports.d = se; exports.e = Rt; exports.f = At; exports.g = It; exports.h = zt; exports.i = Qt;
2
+ //# sourceMappingURL=chunk-IXZ52RPZ.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-JPOZKCPR.cjs","../src/react/context.tsx","../src/react/use-bit-form.ts","../src/react/use-bit-array.ts"],"names":["BitContext","createContext","BitFormProvider","store","children","jsx","createFrameworkStoreAdapter","useBitStore","useContext","useBitForm","submitError","setSubmitError","useState","lastResponse","setLastResponse","lastMeta","useRef","subscribeMeta","useCallback","cb","subscribeFormMetaSnapshot","getMetaSnapshot","nextMeta","readFormMetaSnapshot","metaState","useSyncExternalStore","binding","useMemo","createFrameworkFormBinding","result","error","controller","actions","submit","onSubmit","reset","getValues","getErrors","getTouched","getDirtyValues","useBitArray","path","createArrayBinding","lastSnapshotRef","getSnapshot","next","valueEqual","subscribeArray","data","fields","useEffect","cleanupRegisteredPrefix"],"mappings":"AAAA,qOAAwC,wDAA0F,wDAAyC,wDAAyC,wDAAgD,8BCAnN,+CAa/C,IATIA,CAAAA,CAAaC,kCAAAA,IAAoD,CAAA,CAE1DC,EAAAA,aAAkB,CAAC,CAC9B,KAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CACF,CAAA,CAAA,EAIEC,6B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CAAA,EAAM,CACXC,iCAAAA,CAAwBhD,CAAO,CAAA,EAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-JPOZKCPR.cjs","sourcesContent":[null,"import React, { createContext, useContext } from \"react\";\nimport type { BitFrameworkStoreApi, BitStoreApi } from \"../core\";\nimport { createFrameworkStoreAdapter } from \"../core\";\n\nconst BitContext = createContext<BitFrameworkStoreApi<any> | null>(null);\n\nexport const BitFormProvider = ({\n store,\n children,\n}: {\n store: BitFrameworkStoreApi<any> | BitStoreApi<any>;\n children: React.ReactNode;\n}) => (\n <BitContext.Provider value={createFrameworkStoreAdapter(store)}>\n {children}\n </BitContext.Provider>\n);\n\nexport const useBitStore = <T extends object>() => {\n const store = useContext(BitContext);\n if (!store)\n throw new Error(\n \"BitForm hooks devem ser usados dentro de um BitFormProvider\",\n );\n return store as BitFrameworkStoreApi<T>;\n};\n","import {\n useCallback,\n useSyncExternalStore,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useBitStore } from \"./context\";\nimport {\n createFrameworkFormBinding,\n readFormMetaSnapshot,\n subscribeFormMetaSnapshot,\n} from \"../core\";\nimport type { UseBitFormResult } from \"./types\";\n\nexport function useBitForm<T extends object>(): UseBitFormResult<T> {\n const store = useBitStore<T>();\n\n const [submitError, setSubmitError] = useState<Error | null>(null);\n const [lastResponse, setLastResponse] = useState<unknown>(null);\n const lastMeta = useRef<ReturnType<typeof readFormMetaSnapshot<T>> | null>(\n null,\n );\n\n const subscribeMeta = useCallback(\n (cb: () => void) => subscribeFormMetaSnapshot(store, cb),\n [store],\n );\n const getMetaSnapshot = useCallback(() => {\n const nextMeta = readFormMetaSnapshot(store);\n\n if (\n lastMeta.current &&\n lastMeta.current.isValid === nextMeta.isValid &&\n lastMeta.current.isDirty === nextMeta.isDirty &&\n lastMeta.current.isSubmitting === nextMeta.isSubmitting\n ) {\n return lastMeta.current;\n }\n\n lastMeta.current = nextMeta;\n return nextMeta;\n }, [store]);\n\n const metaState = useSyncExternalStore(\n subscribeMeta,\n getMetaSnapshot,\n getMetaSnapshot,\n );\n\n const binding = useMemo(\n () =>\n createFrameworkFormBinding(store, {\n clearSubmissionState: () => {\n setSubmitError(null);\n setLastResponse(null);\n },\n setSubmissionResult: (result) => {\n setLastResponse(result);\n },\n setSubmissionError: (error) => {\n setSubmitError(error);\n },\n }),\n [store],\n );\n\n const { controller, actions } = binding;\n\n const submit = useCallback(controller.submit, [controller]);\n const onSubmit = useCallback(controller.onSubmit, [controller]);\n const reset = useCallback(controller.reset, [controller]);\n\n const getValues = useCallback(controller.getValues, [controller]);\n const getErrors = useCallback(controller.getErrors, [controller]);\n const getTouched = useCallback(controller.getTouched, [controller]);\n const getDirtyValues = useCallback(controller.getDirtyValues, [controller]);\n\n const meta = useMemo(\n () => ({\n ...metaState,\n submitError,\n lastResponse,\n }),\n [metaState, submitError, lastResponse],\n );\n\n return {\n // Metadata (grouped)\n meta,\n // Getters\n getValues,\n getErrors,\n getTouched,\n getDirtyValues,\n // Main actions (frequent use - flat)\n submit,\n onSubmit,\n reset,\n ...actions,\n };\n}\n","import {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useSyncExternalStore,\n} from \"react\";\nimport {\n BitArrayPath,\n cleanupRegisteredPrefix,\n createArrayBinding,\n valueEqual,\n} from \"../core\";\nimport { useBitStore } from \"./context\";\n\nexport function useBitArray<\n TForm extends object = any,\n P extends BitArrayPath<TForm> = BitArrayPath<TForm>,\n>(path: P) {\n const store = useBitStore<TForm>();\n const controller = useMemo(\n () => createArrayBinding<TForm, P>(store, path),\n [store, path],\n );\n type ArraySnapshot = ReturnType<typeof controller.readItems>;\n const lastSnapshotRef = useRef<ArraySnapshot | null>(null);\n\n const getSnapshot = useCallback(() => {\n const next = controller.readItems();\n\n if (lastSnapshotRef.current && valueEqual(lastSnapshotRef.current, next)) {\n return lastSnapshotRef.current;\n }\n\n lastSnapshotRef.current = next;\n return next;\n }, [controller]);\n\n const subscribeArray = useCallback(\n (cb: () => void) => store.observe.subscribePath(path, () => cb()),\n [store, path],\n );\n\n const data = useSyncExternalStore(subscribeArray, getSnapshot, getSnapshot);\n\n const fields = useMemo(() => controller.getFields(data), [controller, data]);\n\n useEffect(() => {\n return () => {\n cleanupRegisteredPrefix(store, `${path as string}.`);\n };\n }, [store, path]);\n\n return {\n fields,\n length: data.length,\n append: controller.append,\n prepend: controller.prepend,\n insert: controller.insert,\n remove: controller.remove,\n move: controller.move,\n swap: controller.swap,\n replace: controller.replace,\n clear: controller.clear,\n };\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-IXZ52RPZ.cjs","../src/react/context.tsx","../src/react/use-bit-form.ts","../src/react/use-bit-array.ts"],"names":["BitContext","createContext","BitFormProvider","store","children","jsx","createFrameworkStoreAdapter","useBitStore","useContext","useBitForm","submitError","setSubmitError","useState","lastResponse","setLastResponse","lastMeta","useRef","subscribeMeta","useCallback","cb","subscribeFormMetaSnapshot","getMetaSnapshot","nextMeta","readFormMetaSnapshot","metaState","useSyncExternalStore","binding","useMemo","createFrameworkFormBinding","result","error","controller","actions","submit","onSubmit","reset","getValues","getErrors","getTouched","getDirtyValues","useBitArray","path","createArrayBinding","lastSnapshotRef","getSnapshot","next","valueEqual","subscribeArray","data","fields","useEffect","cleanupRegisteredPrefix"],"mappings":"AAAA,qOAAwC,wDAA0F,wDAAyC,wDAAyC,wDAAgD,8BCAnN,+CAa/C,IATIA,CAAAA,CAAaC,kCAAAA,IAAoD,CAAA,CAE1DC,EAAAA,aAAkB,CAAC,CAC9B,KAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CACF,CAAA,CAAA,EAIEC,6BAAAA,CAACL,CAAW,QAAA,CAAX,CAAoB,KAAA,CAAOM,iCAAAA,CAAiC,CAAA,CAC1D,QAAA,CAAAF,CAAAA,CACH,CAAA,CAGWG,CAAAA,aAAc,CAAA,CAAA,EAAwB,CACjD,IAAMJ,CAAAA,CAAQK,+BAAAA,CAAqB,CAAA,CACnC,EAAA,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CACT,IAAMtC,CAAAA,CAAQI,CAAAA,CAAmB,CAAA,CAC3BwB,CAAAA,CAAaJ,4BAAAA,CACjB,CAAA,EAAMe,iCAAAA,CAA6BvC,CAAOsC,CAAI,CAAA,CAC9C,CAACtC,CAAAA,CAAOsC,CAAI,CACd,CAAA,CAEME,CAAAA,CAAkB3B,2BAAAA,IAAiC,CAAA,CAEnD4B,CAAAA,CAAc1B,gCAAAA,CAAY,CAAA,EAAM,CACpC,IAAM2B,CAAAA,CAAOd,CAAAA,CAAW,SAAA,CAAU,CAAA,CAElC,OAAIY,CAAAA,CAAgB,OAAA,EAAWG,iCAAAA,CAAWH,CAAgB,OAAA,CAASE,CAAI,CAAA,CAC9DF,CAAAA,CAAgB,OAAA,CAAA,CAGzBA,CAAAA,CAAgB,OAAA,CAAUE,CAAAA,CACnBA,CAAAA,CACT,CAAA,CAAG,CAACd,CAAU,CAAC,CAAA,CAETgB,CAAAA,CAAiB7B,gCAAAA,CACpBC,EAAmBhB,CAAAA,CAAM,OAAA,CAAQ,aAAA,CAAcsC,CAAAA,CAAM,CAAA,CAAA,EAAMtB,CAAAA,CAAG,CAAC,CAAA,CAChE,CAAChB,CAAAA,CAAOsC,CAAI,CACd,CAAA,CAEMO,CAAAA,CAAOvB,yCAAAA,CAAqBsB,CAAgBH,CAAAA,CAAaA,CAAW,CAAA,CAEpEK,CAAAA,CAAStB,4BAAAA,CAAQ,CAAA,EAAMI,CAAAA,CAAW,SAAA,CAAUiB,CAAI,CAAA,CAAG,CAACjB,CAAAA,CAAYiB,CAAI,CAAC,CAAA,CAE3E,OAAAE,8BAAAA,CAAU,CAAA,EACD,CAAA,CAAA,EAAM,CACXC,iCAAAA,CAAwBhD,CAAO,CAAA,EAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-IXZ52RPZ.cjs","sourcesContent":[null,"import React, { createContext, useContext } from \"react\";\nimport type { BitFrameworkStoreApi, BitStoreApi } from \"../core\";\nimport { createFrameworkStoreAdapter } from \"../core\";\n\nconst BitContext = createContext<BitFrameworkStoreApi<any> | null>(null);\n\nexport const BitFormProvider = ({\n store,\n children,\n}: {\n store: BitFrameworkStoreApi<any> | BitStoreApi<any>;\n children: React.ReactNode;\n}) => (\n <BitContext.Provider value={createFrameworkStoreAdapter(store)}>\n {children}\n </BitContext.Provider>\n);\n\nexport const useBitStore = <T extends object>() => {\n const store = useContext(BitContext);\n if (!store)\n throw new Error(\n \"BitForm hooks devem ser usados dentro de um BitFormProvider\",\n );\n return store as BitFrameworkStoreApi<T>;\n};\n","import {\n useCallback,\n useSyncExternalStore,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useBitStore } from \"./context\";\nimport {\n createFrameworkFormBinding,\n readFormMetaSnapshot,\n subscribeFormMetaSnapshot,\n} from \"../core\";\nimport type { UseBitFormResult } from \"./types\";\n\nexport function useBitForm<T extends object>(): UseBitFormResult<T> {\n const store = useBitStore<T>();\n\n const [submitError, setSubmitError] = useState<Error | null>(null);\n const [lastResponse, setLastResponse] = useState<unknown>(null);\n const lastMeta = useRef<ReturnType<typeof readFormMetaSnapshot<T>> | null>(\n null,\n );\n\n const subscribeMeta = useCallback(\n (cb: () => void) => subscribeFormMetaSnapshot(store, cb),\n [store],\n );\n const getMetaSnapshot = useCallback(() => {\n const nextMeta = readFormMetaSnapshot(store);\n\n if (\n lastMeta.current &&\n lastMeta.current.isValid === nextMeta.isValid &&\n lastMeta.current.isDirty === nextMeta.isDirty &&\n lastMeta.current.isSubmitting === nextMeta.isSubmitting\n ) {\n return lastMeta.current;\n }\n\n lastMeta.current = nextMeta;\n return nextMeta;\n }, [store]);\n\n const metaState = useSyncExternalStore(\n subscribeMeta,\n getMetaSnapshot,\n getMetaSnapshot,\n );\n\n const binding = useMemo(\n () =>\n createFrameworkFormBinding(store, {\n clearSubmissionState: () => {\n setSubmitError(null);\n setLastResponse(null);\n },\n setSubmissionResult: (result) => {\n setLastResponse(result);\n },\n setSubmissionError: (error) => {\n setSubmitError(error);\n },\n }),\n [store],\n );\n\n const { controller, actions } = binding;\n\n const submit = useCallback(controller.submit, [controller]);\n const onSubmit = useCallback(controller.onSubmit, [controller]);\n const reset = useCallback(controller.reset, [controller]);\n\n const getValues = useCallback(controller.getValues, [controller]);\n const getErrors = useCallback(controller.getErrors, [controller]);\n const getTouched = useCallback(controller.getTouched, [controller]);\n const getDirtyValues = useCallback(controller.getDirtyValues, [controller]);\n\n const meta = useMemo(\n () => ({\n ...metaState,\n submitError,\n lastResponse,\n }),\n [metaState, submitError, lastResponse],\n );\n\n return {\n // Metadata (grouped)\n meta,\n // Getters\n getValues,\n getErrors,\n getTouched,\n getDirtyValues,\n // Main actions (frequent use - flat)\n submit,\n onSubmit,\n reset,\n ...actions,\n };\n}\n","import {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useSyncExternalStore,\n} from \"react\";\nimport {\n BitArrayPath,\n cleanupRegisteredPrefix,\n createArrayBinding,\n valueEqual,\n} from \"../core\";\nimport { useBitStore } from \"./context\";\n\nexport function useBitArray<\n TForm extends object = any,\n P extends BitArrayPath<TForm> = BitArrayPath<TForm>,\n>(path: P) {\n const store = useBitStore<TForm>();\n const controller = useMemo(\n () => createArrayBinding<TForm, P>(store, path),\n [store, path],\n );\n type ArraySnapshot = ReturnType<typeof controller.readItems>;\n const lastSnapshotRef = useRef<ArraySnapshot | null>(null);\n\n const getSnapshot = useCallback(() => {\n const next = controller.readItems();\n\n if (lastSnapshotRef.current && valueEqual(lastSnapshotRef.current, next)) {\n return lastSnapshotRef.current;\n }\n\n lastSnapshotRef.current = next;\n return next;\n }, [controller]);\n\n const subscribeArray = useCallback(\n (cb: () => void) => store.observe.subscribePath(path, () => cb()),\n [store, path],\n );\n\n const data = useSyncExternalStore(subscribeArray, getSnapshot, getSnapshot);\n\n const fields = useMemo(() => controller.getFields(data), [controller, data]);\n\n useEffect(() => {\n return () => {\n cleanupRegisteredPrefix(store, `${path as string}.`);\n };\n }, [store, path]);\n\n return {\n fields,\n length: data.length,\n append: controller.append,\n prepend: controller.prepend,\n insert: controller.insert,\n remove: controller.remove,\n move: controller.move,\n swap: controller.swap,\n replace: controller.replace,\n clear: controller.clear,\n };\n}\n"]}
@@ -1,2 +1,2 @@
1
- import{d as r}from"./chunk-6NH6MUXA.js";function o(i,e){return e&&e.value===i.value&&e.error===i.error&&e.touched===i.touched&&e.isHidden===i.isHidden&&e.isRequired===i.isRequired&&e.isDirty===i.isDirty&&e.isValidating===i.isValidating?e:{value:i.value,error:i.error,touched:i.touched,isHidden:i.isHidden,isRequired:i.isRequired,isDirty:i.isDirty,isValidating:i.isValidating}}function d(i,e){return i===e?!0:!i||!e?!1:r(i.value,e.value)&&i.error===e.error&&i.touched===e.touched&&i.isHidden===e.isHidden&&i.isRequired===e.isRequired&&i.isDirty===e.isDirty&&i.isValidating===e.isValidating}var n=d;export{o as a,d as b,n as c};
2
- //# sourceMappingURL=chunk-S3DJPXMV.js.map
1
+ import{d as r}from"./chunk-IMMFFTXE.js";function o(i,e){return e&&e.value===i.value&&e.error===i.error&&e.touched===i.touched&&e.isHidden===i.isHidden&&e.isRequired===i.isRequired&&e.isDirty===i.isDirty&&e.isValidating===i.isValidating?e:{value:i.value,error:i.error,touched:i.touched,isHidden:i.isHidden,isRequired:i.isRequired,isDirty:i.isDirty,isValidating:i.isValidating}}function d(i,e){return i===e?!0:!i||!e?!1:r(i.value,e.value)&&i.error===e.error&&i.touched===e.touched&&i.isHidden===e.isHidden&&i.isRequired===e.isRequired&&i.isDirty===e.isDirty&&i.isValidating===e.isValidating}var n=d;export{o as a,d as b,n as c};
2
+ //# sourceMappingURL=chunk-JKYECJH5.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkQKGTVKBUcjs = require('./chunk-QKGTVKBU.cjs');var _chunkOR5AGYQTcjs = require('./chunk-OR5AGYQT.cjs');function R(e){return{values:e.values,errors:e.errors,touched:e.touched,isValid:e.isValid,isDirty:e.isDirty,isSubmitting:e.isSubmitting,isValidating:e.isValidating,persist:e.persist}}function k(e){let o=e.getHistoryMetadata();return{...R(e.getState()),_meta:{canUndo:o.canUndo,canRedo:o.canRedo,totalSteps:o.historySize,currentIndex:o.historyIndex}}}function b(e){let o={};for(let[t,i]of Object.entries(e))o[t]=k(i);return o}function w(e){if(!e||typeof e!="object")return!1;let o=e;return typeof o.getState=="function"&&typeof o.getHistoryMetadata=="function"}function I(e){if(!w(e))return!1;let o=e;return typeof o.undo=="function"&&typeof o.redo=="function"&&typeof o.reset=="function"}function B(e,o){let t=e[o];return I(t)?t:null}var S=null,O=50;function N(e,o=_chunkOR5AGYQTcjs.a){S&&(console.warn("[bit-form] Reiniciando ponte do DevTools (Fast Refresh detectado)."),S());let t=null,i=null,f,n=null,a=new Set,T=!1,u=r=>{_optionalChain([t, 'optionalAccess', _ => _.readyState])===WebSocket.OPEN&&t.send(JSON.stringify(r))},h=()=>{if(a.size===0)return;let r=b(Array.from(a).reduce((s,l)=>{let d=o.stores[l];return d&&(s[l]=d),s},{}));a.clear(),n=null,Object.keys(r).length>0&&u({type:"STATE_UPDATE",protocolVersion:1,payload:r})},D=()=>{n||(n=setTimeout(()=>{h()},O))},y=()=>{T=!1,t=new WebSocket(e),t.onopen=()=>{console.log("[bit-form] \u{1F50C} Conectado ao CLI DevTools via WebSocket."),u({type:"HELLO",protocolVersion:1,payload:{role:"server",protocolVersion:1}});let r=b(o.stores);Object.keys(r).length>0&&u({type:"STATE_UPDATE",protocolVersion:1,payload:r}),i=o.subscribe((s,l)=>{a.add(s),D()}),f=setInterval(()=>{u({type:"PING",protocolVersion:1})},3e4)},t.onmessage=r=>{try{let s=JSON.parse(r.data);if(_chunkQKGTVKBUcjs.c.call(void 0, s)){let{storeId:l,action:d}=s.payload,p=B(o.stores,l);if(!p)return;switch(d){case"undo":p.undo();break;case"redo":p.redo();break;case"reset":p.reset();break}}}catch(s){console.warn("[bit-form] Erro ao processar comando do CLI:",s)}},t.onclose=()=>{i&&i(),clearInterval(f),n&&(clearTimeout(n),n=null),a.clear(),T?console.log("[bit-form] Ponte antiga encerrada com sucesso."):(console.log("[bit-form] Conex\xE3o perdida. Reconectando em 3s..."),setTimeout(y,3e3))}};y();let m=()=>{T=!0,i&&i(),clearInterval(f),n&&(clearTimeout(n),n=null),a.clear(),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),S=null};return S=m,m}exports.a = b; exports.b = B; exports.c = N;
2
- //# sourceMappingURL=chunk-MZNHMPTF.cjs.map
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkQKGTVKBUcjs = require('./chunk-QKGTVKBU.cjs');var _chunkMAKFWOL5cjs = require('./chunk-MAKFWOL5.cjs');function R(e){return{values:e.values,errors:e.errors,touched:e.touched,isValid:e.isValid,isDirty:e.isDirty,isSubmitting:e.isSubmitting,isValidating:e.isValidating,persist:e.persist}}function k(e){let o=e.getHistoryMetadata();return{...R(e.getState()),_meta:{canUndo:o.canUndo,canRedo:o.canRedo,totalSteps:o.historySize,currentIndex:o.historyIndex}}}function b(e){let o={};for(let[t,i]of Object.entries(e))o[t]=k(i);return o}function w(e){if(!e||typeof e!="object")return!1;let o=e;return typeof o.getState=="function"&&typeof o.getHistoryMetadata=="function"}function I(e){if(!w(e))return!1;let o=e;return typeof o.undo=="function"&&typeof o.redo=="function"&&typeof o.reset=="function"}function B(e,o){let t=e[o];return I(t)?t:null}var S=null,O=50;function N(e,o=_chunkMAKFWOL5cjs.a){S&&(console.warn("[bit-form] Reiniciando ponte do DevTools (Fast Refresh detectado)."),S());let t=null,i=null,f,n=null,a=new Set,T=!1,u=r=>{_optionalChain([t, 'optionalAccess', _ => _.readyState])===WebSocket.OPEN&&t.send(JSON.stringify(r))},h=()=>{if(a.size===0)return;let r=b(Array.from(a).reduce((s,l)=>{let d=o.stores[l];return d&&(s[l]=d),s},{}));a.clear(),n=null,Object.keys(r).length>0&&u({type:"STATE_UPDATE",protocolVersion:1,payload:r})},D=()=>{n||(n=setTimeout(()=>{h()},O))},y=()=>{T=!1,t=new WebSocket(e),t.onopen=()=>{console.log("[bit-form] \u{1F50C} Conectado ao CLI DevTools via WebSocket."),u({type:"HELLO",protocolVersion:1,payload:{role:"server",protocolVersion:1}});let r=b(o.stores);Object.keys(r).length>0&&u({type:"STATE_UPDATE",protocolVersion:1,payload:r}),i=o.subscribe((s,l)=>{a.add(s),D()}),f=setInterval(()=>{u({type:"PING",protocolVersion:1})},3e4)},t.onmessage=r=>{try{let s=JSON.parse(r.data);if(_chunkQKGTVKBUcjs.c.call(void 0, s)){let{storeId:l,action:d}=s.payload,p=B(o.stores,l);if(!p)return;switch(d){case"undo":p.undo();break;case"redo":p.redo();break;case"reset":p.reset();break}}}catch(s){console.warn("[bit-form] Erro ao processar comando do CLI:",s)}},t.onclose=()=>{i&&i(),clearInterval(f),n&&(clearTimeout(n),n=null),a.clear(),T?console.log("[bit-form] Ponte antiga encerrada com sucesso."):(console.log("[bit-form] Conex\xE3o perdida. Reconectando em 3s..."),setTimeout(y,3e3))}};y();let m=()=>{T=!0,i&&i(),clearInterval(f),n&&(clearTimeout(n),n=null),a.clear(),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),S=null};return S=m,m}exports.a = b; exports.b = B; exports.c = N;
2
+ //# sourceMappingURL=chunk-LM34BK4Q.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-MZNHMPTF.cjs","../src/devtools/store-snapshot.ts","../src/devtools/store-port.ts","../src/devtools/bridge.ts"],"names":["normalizeStoreState","state","createDevToolsStoreSnapshot","store","historyMeta","createDevToolsSnapshotMap","stores","snapshots","storeId","instance","isDevToolsReadableStore","value","candidate","isDevToolsActionableStore","getDevToolsActionableStore","activeBridgeCleanup","STATE_BATCH_INTERVAL_MS","setupRemoteBridge","url","bus","bitBus","socket","unsubscribeBus","heartbeatInterval","batchFlushTimeout","pendingStoreIds","isIntentionalDisconnect","sendWhenOpen","message","flushPendingStoreUpdates","payload","acc","storeInstance","scheduleStoreFlush","connect","initialState","_newState","event","isDevToolsActionMessage","action","e","cleanup"],"mappings":"AAAA,qoBAA+C,wDAAyC,SCG/EA,CAAAA,CACPC,CAAAA,CACsC,CACtC,MAAO,CACL,MAAA,CAAQA,CAAAA,CAAM,MAAA,CACd,MAAA,CAAQA,CAAAA,CAAM,MAAA,CACd,OAAA,CAASA,CAAAA,CAAM,OAAA,CACf,OAAA,CAASA,CAAAA,CAAM,OAAA,CACf,OAAA,CAASA,CAAAA,CAAM,OAAA,CACf,YAAA,CAAcA,CAAAA,CAAM,YAAA,CACpB,YAAA,CAAcA,CAAAA,CAAM,YAAA,CACpB,OAAA,CAASA,CAAAA,CAAM,OACjB,CACF,CAEO,SAASC,CAAAA,CAA8CC,CAAAA,CAQpC,CACxB,IAAMC,CAAAA,CAAcD,CAAAA,CAAM,kBAAA,CAAmB,CAAA,CAE7C,MAAO,CACL,GAAGH,CAAAA,CAAoBG,CAAAA,CAAM,QAAA,CAAS,CAAC,CAAA,CACvC,KAAA,CAAO,CACL,OAAA,CAASC,CAAAA,CAA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AAA,EAAAA,CACF,YAAA,CAAaA,CAAiB,CAAA,CAC9BA,CAAAA,CAAoB,IAAA,CAAA,CAEtBC,CAAAA,CAAgB,KAAA,CAAM,CAAA,CAEpBJ,CAAAA,EAAAA,CACCA,CAAAA,CAAO,UAAA,GAAe,SAAA,CAAU,IAAA,EAC/BA,CAAAA,CAAO,UAAA,GAAe,SAAA,CAAU,UAAA,CAAA,EAElCA,CAAAA,CAAO,KAAA,CAAM,CAAA,CAEfN,CAAAA,CAAsB,IACxB,CAAA,CAEA,OAAAA,CAAAA,CAAsB0B,CAAAA,CAEfA,CACT,CAAA,4CAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-MZNHMPTF.cjs","sourcesContent":[null,"import type { BitBusStorePort, BitState } from \"../core\";\nimport type { DevToolsStoreSnapshot, DevToolsStoreSnapshots } from \"./protocol\";\n\nfunction normalizeStoreState<T extends object>(\n state: Readonly<BitState<T>>,\n): Omit<DevToolsStoreSnapshot, \"_meta\"> {\n return {\n values: state.values,\n errors: state.errors as Record<string, unknown>,\n touched: state.touched as Record<string, unknown>,\n isValid: state.isValid,\n isDirty: state.isDirty,\n isSubmitting: state.isSubmitting,\n isValidating: state.isValidating as Record<string, unknown>,\n persist: state.persist,\n };\n}\n\nexport function createDevToolsStoreSnapshot<T extends object>(store: {\n getState: () => Readonly<BitState<T>>;\n getHistoryMetadata: () => {\n canUndo: boolean;\n canRedo: boolean;\n historySize: number;\n historyIndex: number;\n };\n}): DevToolsStoreSnapshot {\n const historyMeta = store.getHistoryMetadata();\n\n return {\n ...normalizeStoreState(store.getState()),\n _meta: {\n canUndo: historyMeta.canUndo,\n canRedo: historyMeta.canRedo,\n totalSteps: historyMeta.historySize,\n currentIndex: historyMeta.historyIndex,\n },\n };\n}\n\nexport function createDevToolsSnapshotMap(\n stores: Record<string, BitBusStorePort<object>>,\n): DevToolsStoreSnapshots {\n const snapshots: DevToolsStoreSnapshots = {};\n\n for (const [storeId, instance] of Object.entries(stores)) {\n snapshots[storeId] = createDevToolsStoreSnapshot(instance);\n }\n\n return snapshots;\n}\n","import type { BitBusStorePort } from \"../core\";\n\nexport type BitDevToolsReadableStore<T extends object = object> =\n BitBusStorePort<T>;\n\nexport type BitDevToolsActionableStore<T extends object = object> =\n BitBusStorePort<T>;\n\nexport function isDevToolsReadableStore(\n value: unknown,\n): value is BitDevToolsReadableStore<object> {\n if (!value || typeof value !== \"object\") {\n return false;\n }\n\n const candidate = value as unknown as Record<string, unknown>;\n\n return (\n typeof candidate.getState === \"function\" &&\n typeof candidate.getHistoryMetadata === \"function\"\n );\n}\n\nexport function isDevToolsActionableStore(\n value: unknown,\n): value is BitDevToolsActionableStore<object> {\n if (!isDevToolsReadableStore(value)) {\n return false;\n }\n\n const candidate = value as unknown as Record<string, unknown>;\n\n return (\n typeof candidate.undo === \"function\" &&\n typeof candidate.redo === \"function\" &&\n typeof candidate.reset === \"function\"\n );\n}\n\nexport function getDevToolsActionableStore(\n stores: Record<string, unknown>,\n storeId: string,\n): BitDevToolsActionableStore<object> | null {\n const candidate = stores[storeId];\n return isDevToolsActionableStore(candidate) ? candidate : null;\n}\n","import { bitBus } from \"../core\";\nimport type { BitBus } from \"../core\";\nimport type { BitBusStorePort } from \"../core\";\nimport { DEVTOOLS_PROTOCOL_VERSION, isDevToolsActionMessage } from \"./protocol\";\nimport { createDevToolsSnapshotMap } from \"./store-snapshot\";\nimport { getDevToolsActionableStore } from \"./store-port\";\n\nlet activeBridgeCleanup: (() => void) | null = null;\nconst STATE_BATCH_INTERVAL_MS = 50;\n\nexport function setupRemoteBridge(url: string, bus: BitBus = bitBus) {\n if (activeBridgeCleanup) {\n console.warn(\n \"[bit-form] Reiniciando ponte do DevTools (Fast Refresh detectado).\",\n );\n activeBridgeCleanup();\n }\n\n let socket: WebSocket | null = null;\n let unsubscribeBus: (() => void) | null = null;\n let heartbeatInterval: ReturnType<typeof setInterval>;\n let batchFlushTimeout: ReturnType<typeof setTimeout> | null = null;\n const pendingStoreIds = new Set<string>();\n let isIntentionalDisconnect = false;\n\n const sendWhenOpen = (message: Record<string, unknown>) => {\n if (socket?.readyState !== WebSocket.OPEN) {\n return;\n }\n\n socket.send(JSON.stringify(message));\n };\n\n const flushPendingStoreUpdates = () => {\n if (pendingStoreIds.size === 0) {\n return;\n }\n\n const payload = createDevToolsSnapshotMap(\n Array.from(pendingStoreIds).reduce<\n Record<string, BitBusStorePort<object>>\n >((acc, storeId) => {\n const storeInstance = bus.stores[storeId];\n if (storeInstance) {\n acc[storeId] = storeInstance;\n }\n return acc;\n }, {}),\n );\n\n pendingStoreIds.clear();\n batchFlushTimeout = null;\n\n if (Object.keys(payload).length > 0) {\n sendWhenOpen({\n type: \"STATE_UPDATE\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n payload,\n });\n }\n };\n\n const scheduleStoreFlush = () => {\n if (batchFlushTimeout) {\n return;\n }\n\n batchFlushTimeout = setTimeout(() => {\n flushPendingStoreUpdates();\n }, STATE_BATCH_INTERVAL_MS);\n };\n\n const connect = () => {\n isIntentionalDisconnect = false;\n socket = new WebSocket(url);\n\n socket.onopen = () => {\n console.log(\"[bit-form] 🔌 Conectado ao CLI DevTools via WebSocket.\");\n\n sendWhenOpen({\n type: \"HELLO\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n payload: { role: \"server\", protocolVersion: DEVTOOLS_PROTOCOL_VERSION },\n });\n\n const initialState = createDevToolsSnapshotMap(bus.stores);\n if (Object.keys(initialState).length > 0) {\n sendWhenOpen({\n type: \"STATE_UPDATE\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n payload: initialState,\n });\n }\n\n unsubscribeBus = bus.subscribe((storeId, _newState) => {\n pendingStoreIds.add(storeId);\n scheduleStoreFlush();\n });\n\n heartbeatInterval = setInterval(() => {\n sendWhenOpen({\n type: \"PING\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n });\n }, 30000);\n };\n\n socket.onmessage = (event) => {\n try {\n const message = JSON.parse(event.data) as unknown;\n\n if (isDevToolsActionMessage(message)) {\n const { storeId, action } = message.payload;\n const store = getDevToolsActionableStore(bus.stores, storeId);\n\n if (!store) {\n return;\n }\n\n switch (action) {\n case \"undo\":\n store.undo();\n break;\n case \"redo\":\n store.redo();\n break;\n case \"reset\":\n store.reset();\n break;\n }\n }\n } catch (e) {\n console.warn(\"[bit-form] Erro ao processar comando do CLI:\", e);\n }\n };\n\n socket.onclose = () => {\n if (unsubscribeBus) unsubscribeBus();\n clearInterval(heartbeatInterval);\n if (batchFlushTimeout) {\n clearTimeout(batchFlushTimeout);\n batchFlushTimeout = null;\n }\n pendingStoreIds.clear();\n\n if (!isIntentionalDisconnect) {\n console.log(\"[bit-form] Conexão perdida. Reconectando em 3s...\");\n setTimeout(connect, 3000);\n } else {\n console.log(\"[bit-form] Ponte antiga encerrada com sucesso.\");\n }\n };\n };\n\n connect();\n\n const cleanup = () => {\n isIntentionalDisconnect = true;\n\n if (unsubscribeBus) unsubscribeBus();\n clearInterval(heartbeatInterval);\n if (batchFlushTimeout) {\n clearTimeout(batchFlushTimeout);\n batchFlushTimeout = null;\n }\n pendingStoreIds.clear();\n if (\n socket &&\n (socket.readyState === WebSocket.OPEN ||\n socket.readyState === WebSocket.CONNECTING)\n ) {\n socket.close();\n }\n activeBridgeCleanup = null;\n };\n\n activeBridgeCleanup = cleanup;\n\n return cleanup;\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-LM34BK4Q.cjs","../src/devtools/store-snapshot.ts","../src/devtools/store-port.ts","../src/devtools/bridge.ts"],"names":["normalizeStoreState","state","createDevToolsStoreSnapshot","store","historyMeta","createDevToolsSnapshotMap","stores","snapshots","storeId","instance","isDevToolsReadableStore","value","candidate","isDevToolsActionableStore","getDevToolsActionableStore","activeBridgeCleanup","STATE_BATCH_INTERVAL_MS","setupRemoteBridge","url","bus","bitBus","socket","unsubscribeBus","heartbeatInterval","batchFlushTimeout","pendingStoreIds","isIntentionalDisconnect","sendWhenOpen","message","flushPendingStoreUpdates","payload","acc","storeInstance","scheduleStoreFlush","connect","initialState","_newState","event","isDevToolsActionMessage","action","e","cleanup"],"mappings":"AAAA,qoBAA+C,wDAAyC,SCG/EA,CAAAA,CACPC,CAAAA,CACsC,CACtC,MAAO,CACL,MAAA,CAAQA,CAAAA,CAAM,MAAA,CACd,MAAA,CAAQA,CAAAA,CAAM,MAAA,CACd,OAAA,CAASA,CAAAA,CAAM,OAAA,CACf,OAAA,CAASA,CAAAA,CAAM,OAAA,CACf,OAAA,CAASA,CAAAA,CAAM,OAAA,CACf,YAAA,CAAcA,CAAAA,CAAM,YAAA,CACpB,YAAA,CAAcA,CAAAA,CAAM,YAAA,CACpB,OAAA,CAASA,CAAAA,CAAM,OACjB,CACF,CAEO,SAASC,CAAAA,CAA8CC,CAAAA,CAQpC,CACxB,IAAMC,CAAAA,CAAcD,CAAAA,CAAM,kBAAA,CAAmB,CAAA,CAE7C,MAAO,CACL,GAAGH,CAAAA,CAAoBG,CAAAA,CAAM,QAAA,CAAS,CAAC,CAAA,CACvC,KAAA,CAAO,CACL,OAAA,CAASC,CAAAA,CAAY,OAAA,CACrB,OAAA,CAASA,CAAAA,CAAY,OAAA,CACrB,UAAA,CAAYA,CAAAA,CAAY,WAAA,CACxB,YAAA,CAAcA,CAAAA,CAAY,YAC5B,CACF,CACF,CAEO,SAASC,CAAAA,CACdC,CAAAA,CACwB,CACxB,IAAMC,CAAAA,CAAoC,CAAC,CAAA,CAE3C,GAAA,CAAA,GAAW,CAACC,CAAAA,CAASC,CAAQ,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQH,CAAM,CAAA,CACrDC,CAAAA,CAAUC,CAAO,CAAA,CAAIN,CAAAA,CAA4BO,CAAQ,CAAA,CAG3D,OAAOF,CACT,CC1CO,SAASG,CAAAA,CACdC,CAAAA,CAC2C,CAC3C,EAAA,CAAI,CAACA,CAAAA,EAAS,OAAOA,CAAAA,EAAU,QAAA,CAC7B,MAAO,CAAA,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A,CAAG,CACV,OAAA,CAAQ,IAAA,CAAK,8CAAA,CAAgDA,CAAC,CAChE,CACF,CAAA,CAEAnB,CAAAA,CAAO,OAAA,CAAU,CAAA,CAAA,EAAM,CACjBC,CAAAA,EAAgBA,CAAAA,CAAe,CAAA,CACnC,aAAA,CAAcC,CAAiB,CAAA,CAC3BC,CAAAA,EAAAA,CACF,YAAA,CAAaA,CAAiB,CAAA,CAC9BA,CAAAA,CAAoB,IAAA,CAAA,CAEtBC,CAAAA,CAAgB,KAAA,CAAM,CAAA,CAEjBC,CAAAA,CAIH,OAAA,CAAQ,GAAA,CAAI,gDAAgD,CAAA,CAAA,CAH5D,OAAA,CAAQ,GAAA,CAAI,sDAAmD,CAAA,CAC/D,UAAA,CAAWQ,CAAAA,CAAS,GAAI,CAAA,CAI5B,CACF,CAAA,CAEAA,CAAAA,CAAQ,CAAA,CAER,IAAMO,CAAAA,CAAU,CAAA,CAAA,EAAM,CACpBf,CAAAA,CAA0B,CAAA,CAAA,CAEtBJ,CAAAA,EAAgBA,CAAAA,CAAe,CAAA,CACnC,aAAA,CAAcC,CAAiB,CAAA,CAC3BC,CAAAA,EAAAA,CACF,YAAA,CAAaA,CAAiB,CAAA,CAC9BA,CAAAA,CAAoB,IAAA,CAAA,CAEtBC,CAAAA,CAAgB,KAAA,CAAM,CAAA,CAEpBJ,CAAAA,EAAAA,CACCA,CAAAA,CAAO,UAAA,GAAe,SAAA,CAAU,IAAA,EAC/BA,CAAAA,CAAO,UAAA,GAAe,SAAA,CAAU,UAAA,CAAA,EAElCA,CAAAA,CAAO,KAAA,CAAM,CAAA,CAEfN,CAAAA,CAAsB,IACxB,CAAA,CAEA,OAAAA,CAAAA,CAAsB0B,CAAAA,CAEfA,CACT,CAAA,4CAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-LM34BK4Q.cjs","sourcesContent":[null,"import type { BitBusStorePort, BitState } from \"../core\";\nimport type { DevToolsStoreSnapshot, DevToolsStoreSnapshots } from \"./protocol\";\n\nfunction normalizeStoreState<T extends object>(\n state: Readonly<BitState<T>>,\n): Omit<DevToolsStoreSnapshot, \"_meta\"> {\n return {\n values: state.values,\n errors: state.errors as Record<string, unknown>,\n touched: state.touched as Record<string, unknown>,\n isValid: state.isValid,\n isDirty: state.isDirty,\n isSubmitting: state.isSubmitting,\n isValidating: state.isValidating as Record<string, unknown>,\n persist: state.persist,\n };\n}\n\nexport function createDevToolsStoreSnapshot<T extends object>(store: {\n getState: () => Readonly<BitState<T>>;\n getHistoryMetadata: () => {\n canUndo: boolean;\n canRedo: boolean;\n historySize: number;\n historyIndex: number;\n };\n}): DevToolsStoreSnapshot {\n const historyMeta = store.getHistoryMetadata();\n\n return {\n ...normalizeStoreState(store.getState()),\n _meta: {\n canUndo: historyMeta.canUndo,\n canRedo: historyMeta.canRedo,\n totalSteps: historyMeta.historySize,\n currentIndex: historyMeta.historyIndex,\n },\n };\n}\n\nexport function createDevToolsSnapshotMap(\n stores: Record<string, BitBusStorePort<object>>,\n): DevToolsStoreSnapshots {\n const snapshots: DevToolsStoreSnapshots = {};\n\n for (const [storeId, instance] of Object.entries(stores)) {\n snapshots[storeId] = createDevToolsStoreSnapshot(instance);\n }\n\n return snapshots;\n}\n","import type { BitBusStorePort } from \"../core\";\n\nexport type BitDevToolsReadableStore<T extends object = object> =\n BitBusStorePort<T>;\n\nexport type BitDevToolsActionableStore<T extends object = object> =\n BitBusStorePort<T>;\n\nexport function isDevToolsReadableStore(\n value: unknown,\n): value is BitDevToolsReadableStore<object> {\n if (!value || typeof value !== \"object\") {\n return false;\n }\n\n const candidate = value as unknown as Record<string, unknown>;\n\n return (\n typeof candidate.getState === \"function\" &&\n typeof candidate.getHistoryMetadata === \"function\"\n );\n}\n\nexport function isDevToolsActionableStore(\n value: unknown,\n): value is BitDevToolsActionableStore<object> {\n if (!isDevToolsReadableStore(value)) {\n return false;\n }\n\n const candidate = value as unknown as Record<string, unknown>;\n\n return (\n typeof candidate.undo === \"function\" &&\n typeof candidate.redo === \"function\" &&\n typeof candidate.reset === \"function\"\n );\n}\n\nexport function getDevToolsActionableStore(\n stores: Record<string, unknown>,\n storeId: string,\n): BitDevToolsActionableStore<object> | null {\n const candidate = stores[storeId];\n return isDevToolsActionableStore(candidate) ? candidate : null;\n}\n","import { bitBus } from \"../core\";\nimport type { BitBus } from \"../core\";\nimport type { BitBusStorePort } from \"../core\";\nimport { DEVTOOLS_PROTOCOL_VERSION, isDevToolsActionMessage } from \"./protocol\";\nimport { createDevToolsSnapshotMap } from \"./store-snapshot\";\nimport { getDevToolsActionableStore } from \"./store-port\";\n\nlet activeBridgeCleanup: (() => void) | null = null;\nconst STATE_BATCH_INTERVAL_MS = 50;\n\nexport function setupRemoteBridge(url: string, bus: BitBus = bitBus) {\n if (activeBridgeCleanup) {\n console.warn(\n \"[bit-form] Reiniciando ponte do DevTools (Fast Refresh detectado).\",\n );\n activeBridgeCleanup();\n }\n\n let socket: WebSocket | null = null;\n let unsubscribeBus: (() => void) | null = null;\n let heartbeatInterval: ReturnType<typeof setInterval>;\n let batchFlushTimeout: ReturnType<typeof setTimeout> | null = null;\n const pendingStoreIds = new Set<string>();\n let isIntentionalDisconnect = false;\n\n const sendWhenOpen = (message: Record<string, unknown>) => {\n if (socket?.readyState !== WebSocket.OPEN) {\n return;\n }\n\n socket.send(JSON.stringify(message));\n };\n\n const flushPendingStoreUpdates = () => {\n if (pendingStoreIds.size === 0) {\n return;\n }\n\n const payload = createDevToolsSnapshotMap(\n Array.from(pendingStoreIds).reduce<\n Record<string, BitBusStorePort<object>>\n >((acc, storeId) => {\n const storeInstance = bus.stores[storeId];\n if (storeInstance) {\n acc[storeId] = storeInstance;\n }\n return acc;\n }, {}),\n );\n\n pendingStoreIds.clear();\n batchFlushTimeout = null;\n\n if (Object.keys(payload).length > 0) {\n sendWhenOpen({\n type: \"STATE_UPDATE\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n payload,\n });\n }\n };\n\n const scheduleStoreFlush = () => {\n if (batchFlushTimeout) {\n return;\n }\n\n batchFlushTimeout = setTimeout(() => {\n flushPendingStoreUpdates();\n }, STATE_BATCH_INTERVAL_MS);\n };\n\n const connect = () => {\n isIntentionalDisconnect = false;\n socket = new WebSocket(url);\n\n socket.onopen = () => {\n console.log(\"[bit-form] 🔌 Conectado ao CLI DevTools via WebSocket.\");\n\n sendWhenOpen({\n type: \"HELLO\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n payload: { role: \"server\", protocolVersion: DEVTOOLS_PROTOCOL_VERSION },\n });\n\n const initialState = createDevToolsSnapshotMap(bus.stores);\n if (Object.keys(initialState).length > 0) {\n sendWhenOpen({\n type: \"STATE_UPDATE\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n payload: initialState,\n });\n }\n\n unsubscribeBus = bus.subscribe((storeId, _newState) => {\n pendingStoreIds.add(storeId);\n scheduleStoreFlush();\n });\n\n heartbeatInterval = setInterval(() => {\n sendWhenOpen({\n type: \"PING\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n });\n }, 30000);\n };\n\n socket.onmessage = (event) => {\n try {\n const message = JSON.parse(event.data) as unknown;\n\n if (isDevToolsActionMessage(message)) {\n const { storeId, action } = message.payload;\n const store = getDevToolsActionableStore(bus.stores, storeId);\n\n if (!store) {\n return;\n }\n\n switch (action) {\n case \"undo\":\n store.undo();\n break;\n case \"redo\":\n store.redo();\n break;\n case \"reset\":\n store.reset();\n break;\n }\n }\n } catch (e) {\n console.warn(\"[bit-form] Erro ao processar comando do CLI:\", e);\n }\n };\n\n socket.onclose = () => {\n if (unsubscribeBus) unsubscribeBus();\n clearInterval(heartbeatInterval);\n if (batchFlushTimeout) {\n clearTimeout(batchFlushTimeout);\n batchFlushTimeout = null;\n }\n pendingStoreIds.clear();\n\n if (!isIntentionalDisconnect) {\n console.log(\"[bit-form] Conexão perdida. Reconectando em 3s...\");\n setTimeout(connect, 3000);\n } else {\n console.log(\"[bit-form] Ponte antiga encerrada com sucesso.\");\n }\n };\n };\n\n connect();\n\n const cleanup = () => {\n isIntentionalDisconnect = true;\n\n if (unsubscribeBus) unsubscribeBus();\n clearInterval(heartbeatInterval);\n if (batchFlushTimeout) {\n clearTimeout(batchFlushTimeout);\n batchFlushTimeout = null;\n }\n pendingStoreIds.clear();\n if (\n socket &&\n (socket.readyState === WebSocket.OPEN ||\n socket.readyState === WebSocket.CONNECTING)\n ) {\n socket.close();\n }\n activeBridgeCleanup = null;\n };\n\n activeBridgeCleanup = cleanup;\n\n return cleanup;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17; var _class18; var _class19; var _class20; var _class21; var _class22;var _chunkRHMJPKNVcjs = require('./chunk-RHMJPKNV.cjs');var _chunkOSQWKXFIcjs = require('./chunk-OSQWKXFI.cjs');var _chunkVOA3SKFYcjs = require('./chunk-VOA3SKFY.cjs');function Kt(s){let{path:t,getFieldConfig:e,masks:i}=s,r=_optionalChain([e, 'call', _2 => _2(t), 'optionalAccess', _3 => _3.mask]);if(r)return typeof r=="string"?_optionalChain([i, 'optionalAccess', _4 => _4[r]]):r}function $t(s){let{state:t,path:e,value:i,isHidden:r,isRequired:n,isDirty:o,isValidating:a}=s,c=e;return{value:i,error:t.errors[c],touched:!!t.touched[c],isHidden:r,isRequired:n,isDirty:o,isValidating:a}}var M=Symbol.for("bit-form.framework-store-api");var R=Symbol.for("bit-form.hooks-api");var z=class{constructor(t){this.baselineValues=_chunkVOA3SKFYcjs.a.call(void 0, t)}getValues(){return this.baselineSnapshot||(this.baselineSnapshot=Object.freeze(_chunkVOA3SKFYcjs.a.call(void 0, this.baselineValues))),this.baselineSnapshot}setValues(t){this.baselineValues=_chunkVOA3SKFYcjs.a.call(void 0, t),this.baselineSnapshot=void 0}};var q= (_class =class{constructor(t,e){;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);this.getComputedEntries=t;this.onError=e}__init() {this.equalityCache=new Map}__init2() {this.reverseDepsCache=null}__init3() {this.childDepsIndex=null}__init4() {this.validatedEntriesSignature=null}__init5() {this.validatedEntriesRef=null}__init6() {this.orderedAllEntriesCache=null}__init7() {this.orderedIndexByPathCache=null}isCacheableScalar(t){return t===null||typeof t!="object"&&typeof t!="function"}invalidateReverseDeps(){this.reverseDepsCache=null,this.childDepsIndex=null,this.orderedAllEntriesCache=null,this.validatedEntriesSignature=null,this.validatedEntriesRef=null,this.orderedIndexByPathCache=null,this.equalityCache.clear()}apply(t,e){let i=this.getComputedEntries();if(i.length===0)return t;this.ensureEntriesAreValid(i);let r=this.resolveEntriesToRun(i,e);if(r.length===0)return t;let n=t,o=new Set;for(let a of r){if(a.dependsOn.some(h=>o.has(h))){o.add(a.path);continue}let c;try{c=a.compute(n)}catch(h){_optionalChain([this, 'access', _5 => _5.onError, 'optionalCall', _6 => _6(h,a.path)]),o.add(a.path);continue}let u=_chunkVOA3SKFYcjs.f.call(void 0, n,a.path),l=this.equalityCache.get(a.path),d,p=this.isCacheableScalar(u)&&this.isCacheableScalar(c);p&&l&&l.current===u&&l.next===c?d=l.equal:(d=_chunkVOA3SKFYcjs.d.call(void 0, u,c),p?this.equalityCache.set(a.path,{current:u,next:c,equal:d}):this.equalityCache.delete(a.path)),d||(n=_chunkVOA3SKFYcjs.g.call(void 0, n,a.path,c))}return n}getReverseDependencies(t){if(this.reverseDepsCache)return this.reverseDepsCache;let e=new Map;for(let r of t)for(let n of r.dependsOn){let o=e.get(n);o||(o=new Set,e.set(n,o)),o.add(r.path)}let i=new Map;for(let r of e.keys()){let n=r.split(".");for(let o=1;o<n.length;o++){let a=n.slice(0,o).join("."),c=i.get(a);c||(c=new Set,i.set(a,c)),c.add(r)}}return this.reverseDepsCache=e,this.childDepsIndex=i,e}resolveEntriesToRun(t,e){if(!e||e.length===0||e.includes("*"))return this.getOrderedAllEntries(t);let i=this.getReverseDependencies(t),r=new Set,n=[...e],o=0;for(;o<n.length;){let l=n[o++],d=this.getDependentsForPath(i,l);if(d)for(let p of d)r.has(p)||(r.add(p),n.push(p))}if(r.size===0)return[];let a=this.getOrderedAllEntries(t),c=this.getOrderedIndexByPath(t,a),u=[];return r.forEach(l=>{let d=c.get(l);if(d===void 0)return;let p=a[d];p&&u.push({index:d,entry:p})}),u.sort((l,d)=>l.index-d.index),u.map(l=>l.entry)}orderEntries(t){if(t.length<=1)return t;let e=new Map(t.map(a=>[a.path,a])),i=new Map,r=new Map;t.forEach(a=>i.set(a.path,0)),t.forEach(a=>{a.dependsOn.forEach(c=>{if(!e.has(c))return;let u=_nullishCoalesce(r.get(c), () => (new Set));u.has(a.path)||(u.add(a.path),r.set(c,u),i.set(a.path,(_nullishCoalesce(i.get(a.path), () => (0)))+1))})});let n=t.filter(a=>(_nullishCoalesce(i.get(a.path), () => (0)))===0).map(a=>a.path),o=[];for(;n.length>0;){let a=n.shift();o.push(a);let c=r.get(a);c&&c.forEach(u=>{let l=(_nullishCoalesce(i.get(u), () => (0)))-1;i.set(u,l),l===0&&n.push(u)})}if(o.length!==t.length)throw new Error("BitStore: cyclic computed dependencies detected. Check computedDependsOn definitions.");return o.map(a=>e.get(a))}getOrderedAllEntries(t){let e=this.createEntriesSignature(t);if(this.orderedAllEntriesCache&&this.orderedAllEntriesCache.signature===e)return this.orderedAllEntriesCache.ordered;let i=this.orderEntries(t);return this.orderedAllEntriesCache={signature:e,ordered:i},i}getOrderedIndexByPath(t,e){let i=this.createEntriesSignature(t);if(this.orderedIndexByPathCache&&this.orderedIndexByPathCache.signature===i)return this.orderedIndexByPathCache.indexByPath;let r=new Map;return e.forEach((n,o)=>{r.set(n.path,o)}),this.orderedIndexByPathCache={signature:i,indexByPath:r},r}ensureEntriesAreValid(t){if(this.validatedEntriesRef===t)return;let e=this.createEntriesSignature(t);if(this.validatedEntriesSignature===e){this.validatedEntriesRef=t;return}t.forEach(i=>this.assertDependencies(i)),this.invalidateReverseDeps(),this.validatedEntriesSignature=e,this.validatedEntriesRef=t}createEntriesSignature(t){return t.map(e=>`${e.path}:${e.dependsOn.join(",")}`).join("|")}getDependentsForPath(t,e){let i=new Set,r=a=>{let c=t.get(a);c&&c.forEach(u=>i.add(u))};r(e);let n=e.split(".");for(;n.length>1;)n.pop(),r(n.join("."));let o=_optionalChain([this, 'access', _7 => _7.childDepsIndex, 'optionalAccess', _8 => _8.get, 'call', _9 => _9(e)]);if(o)for(let a of o)r(a);return i}assertDependencies(t){if(t.dependsOn.length===0)throw new Error(`BitStore: computed field \`${t.path}\` requires explicit computedDependsOn in v4.`);if(t.dependsOn.includes(t.path))throw new Error(`BitStore: computed field \`${t.path}\` cannot depend on itself.`)}}, _class);var L= (_class2 =class{constructor() { _class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this); }__init8() {this.dirtyPaths=new Set}__init9() {this.dirtyPathIndex=new Set}__init10() {this.dirtyPrefixRefCount=new Map}__init11() {this.childrenByPrefix=new Map}updateForPath(t,e,i){this.removeDirtyChildren(t);let r=_chunkVOA3SKFYcjs.f.call(void 0, e,t),n=_chunkVOA3SKFYcjs.f.call(void 0, i,t);return _chunkVOA3SKFYcjs.c.call(void 0, r,n)?this.removeDirtyPath(t):this.addDirtyPath(t),this.dirtyPaths.size>0}rebuild(t,e){return this.dirtyPaths=_chunkVOA3SKFYcjs.e.call(void 0, t,e),this.dirtyPrefixRefCount.clear(),this.rebuildIndex(),this.dirtyPaths.size>0}clear(){this.dirtyPaths.clear(),this.dirtyPathIndex.clear(),this.dirtyPrefixRefCount.clear(),this.childrenByPrefix.clear()}get isDirty(){return this.dirtyPaths.size>0}getDirtyPaths(){return this.dirtyPaths}isPathDirty(t){if(this.dirtyPathIndex.has(t))return!0;let e=t.lastIndexOf(".");for(;e>-1;){let i=t.slice(0,e);if((_nullishCoalesce(this.dirtyPrefixRefCount.get(i), () => (0)))>0)return!0;e=t.lastIndexOf(".",e-1)}return!1}buildDirtyValues(t){if(this.dirtyPaths.size===0)return{};let e=[],i=[...this.dirtyPaths].sort(),r=new Set,n=new Set,o=a=>{let c=a.lastIndexOf(".");for(;c>-1;){if(n.has(a.slice(0,c)))return!0;c=a.lastIndexOf(".",c-1)}return!1};for(let a of i){if(o(a))continue;let c=a.match(/^(.+)\.\d+/);if(c){let u=c[1];if(r.has(u))continue;r.add(u);let l=_chunkVOA3SKFYcjs.f.call(void 0, t,u);e.push([u,l]),n.add(u)}else{let u=_chunkVOA3SKFYcjs.f.call(void 0, t,a);e.push([a,u]),n.add(a)}}return e.length===0?{}:_chunkVOA3SKFYcjs.h.call(void 0, {},e)}rebuildIndex(){let t=new Set,e=new Map,i=new Map;for(let r of this.dirtyPaths)this.forEachPathPrefix(r,n=>{t.add(n),e.set(n,(_nullishCoalesce(e.get(n), () => (0)))+1)}),this.forEachAncestorPrefix(r,n=>{let o=i.get(n);o?o.add(r):i.set(n,new Set([r]))});this.dirtyPathIndex=t,this.dirtyPrefixRefCount=e,this.childrenByPrefix=i}removeDirtyChildren(t){let e=this.childrenByPrefix.get(t);if(!(!e||e.size===0))for(let i of[...e])this.removeDirtyPath(i)}addDirtyPath(t){this.dirtyPaths.has(t)||(this.dirtyPaths.add(t),this.forEachPathPrefix(t,e=>{this.dirtyPathIndex.add(e),this.dirtyPrefixRefCount.set(e,(_nullishCoalesce(this.dirtyPrefixRefCount.get(e), () => (0)))+1)}),this.forEachAncestorPrefix(t,e=>{let i=this.childrenByPrefix.get(e);i?i.add(t):this.childrenByPrefix.set(e,new Set([t]))}))}removeDirtyPath(t){this.dirtyPaths.has(t)&&(this.dirtyPaths.delete(t),this.forEachPathPrefix(t,e=>{let i=(_nullishCoalesce(this.dirtyPrefixRefCount.get(e), () => (0)))-1;if(i<=0){this.dirtyPrefixRefCount.delete(e),this.dirtyPathIndex.delete(e);return}this.dirtyPrefixRefCount.set(e,i)}),this.forEachAncestorPrefix(t,e=>{_optionalChain([this, 'access', _10 => _10.childrenByPrefix, 'access', _11 => _11.get, 'call', _12 => _12(e), 'optionalAccess', _13 => _13.delete, 'call', _14 => _14(t)])}))}forEachPathPrefix(t,e){let i=t.split("."),r="";for(let n of i)r=r?`${r}.${n}`:n,e(r)}forEachAncestorPrefix(t,e){let i=t.split("."),r="";for(let n=0;n<i.length-1;n++)r=r?`${r}.${i[n]}`:i[n],e(r)}}, _class2);var _= (_class3 =class{constructor() { _class3.prototype.__init12.call(this); }__init12() {this.masks=new Map}registerMask(t,e){this.masks.set(t,e)}unregisterMask(t){this.masks.has(t)&&this.masks.delete(t)}resolveMask(t){return this.masks.get(t)}getAllMasks(){return Object.fromEntries(this.masks.entries())}clear(){this.masks.clear()}}, _class3);function ni(s){return s.replace(/\.+$/g,"")}function A(s){return ni(s.trim())}function x(s,t){let e=A(t);return e.length===0?!1:s===e||s.startsWith(`${e}.`)}function C(s,t){return A(t===void 0?s:`${s}.${t}`)}var N= (_class4 =class{constructor() { _class4.prototype.__init13.call(this);_class4.prototype.__init14.call(this);_class4.prototype.__init15.call(this);_class4.prototype.__init16.call(this);_class4.prototype.__init17.call(this); }__init13() {this.fieldConfigs=new Map}__init14() {this.scopeFieldsIndex=null}__init15() {this.computedEntriesCache=null}__init16() {this.normalizerEntriesCache=null}__init17() {this.transformEntriesCache=null}get(t){return this.fieldConfigs.get(t)}set(t,e){this.fieldConfigs.set(t,e),this.registerCachedIndexes(t,e)}delete(t){let e=this.fieldConfigs.get(t);return this.fieldConfigs.delete(t),this.unregisterCachedIndexes(t,e),e}has(t){return this.fieldConfigs.has(t)}forEach(t){this.fieldConfigs.forEach((e,i)=>t(e,i))}entries(){return Array.from(this.fieldConfigs.entries())}getScopeFields(t){if(!this.scopeFieldsIndex){let e=new Map;this.forEach((i,r)=>{if(!i.scope)return;let n=_nullishCoalesce(e.get(i.scope), () => (new Set));n.add(r),e.set(i.scope,n)}),this.scopeFieldsIndex=e}return Array.from(_nullishCoalesce(this.scopeFieldsIndex.get(t), () => ([])))}getComputedEntries(){if(!this.computedEntriesCache){let t=[];this.forEach((e,i)=>{e.computed&&t.push({path:i,compute:e.computed,dependsOn:e.computedDependsOn})}),this.computedEntriesCache=t}return this.computedEntriesCache}getTransformEntries(){if(!this.transformEntriesCache){let t=[];this.forEach((e,i)=>{e.transform&&t.push([i,e.transform])}),this.transformEntriesCache=t}return this.transformEntriesCache}getNormalizerEntries(){if(!this.normalizerEntriesCache){let t=[];this.forEach((e,i)=>{e.normalize&&t.push({path:i,normalize:e.normalize,dependsOn:_optionalChain([e, 'access', _15 => _15.normalizeDependsOn, 'optionalAccess', _16 => _16.length])?e.normalizeDependsOn:[i]})}),this.normalizerEntriesCache=t}return this.normalizerEntriesCache}invalidateIndexes(){this.scopeFieldsIndex=null,this.computedEntriesCache=null,this.normalizerEntriesCache=null,this.transformEntriesCache=null}registerCachedIndexes(t,e){if(this.scopeFieldsIndex&&e.scope){let i=_nullishCoalesce(this.scopeFieldsIndex.get(e.scope), () => (new Set));i.add(t),this.scopeFieldsIndex.set(e.scope,i)}this.computedEntriesCache&&e.computed&&this.computedEntriesCache.push({path:t,compute:e.computed,dependsOn:e.computedDependsOn}),this.normalizerEntriesCache&&e.normalize&&this.normalizerEntriesCache.push({path:t,normalize:e.normalize,dependsOn:_optionalChain([e, 'access', _17 => _17.normalizeDependsOn, 'optionalAccess', _18 => _18.length])?e.normalizeDependsOn:[t]}),this.transformEntriesCache&&e.transform&&this.transformEntriesCache.push([t,e.transform])}unregisterCachedIndexes(t,e){if(!e){this.invalidateIndexes();return}if(this.scopeFieldsIndex&&e.scope){let i=this.scopeFieldsIndex.get(e.scope);i&&(i.delete(t),i.size>0?this.scopeFieldsIndex.set(e.scope,i):this.scopeFieldsIndex.delete(e.scope))}this.computedEntriesCache&&e.computed&&(this.computedEntriesCache=this.computedEntriesCache.filter(i=>i.path!==t)),this.normalizerEntriesCache&&e.normalize&&(this.normalizerEntriesCache=this.normalizerEntriesCache.filter(i=>i.path!==t)),this.transformEntriesCache&&e.transform&&(this.transformEntriesCache=this.transformEntriesCache.filter(([i])=>i!==t))}}, _class4);var W= (_class5 =class{constructor(t,e){;_class5.prototype.__init18.call(this);_class5.prototype.__init19.call(this);_class5.prototype.__init20.call(this);_class5.prototype.__init21.call(this);_class5.prototype.__init22.call(this);_class5.prototype.__init23.call(this);_class5.prototype.__init24.call(this);this.getFieldConfig=t;this.onConditionError=e}__init18() {this.dependencies=new Map}__init19() {this.hiddenFields=new Set}__init20() {this.conditionalVisibilityPaths=new Set}__init21() {this.requiredPathsByDependency=new Map}__init22() {this.requiredConditionalPaths=new Set}__init23() {this.requiredEvaluationVersion=0}__init24() {this.requiredEvaluationCache=new Map}getHiddenFields(){return this.hiddenFields}onRegister(t,e,i){let r=!!_optionalChain([e, 'access', _19 => _19.conditional, 'optionalAccess', _20 => _20.showIf]),n=_optionalChain([e, 'access', _21 => _21.conditional, 'optionalAccess', _22 => _22.dependsOn]);if(n){if(this.wouldCreateCycle(t,n)){let o=new Error(`Circular dependency detected: "${t}" \u2192 [${n.join(", ")}]`);return _optionalChain([this, 'access', _23 => _23.onConditionError, 'optionalCall', _24 => _24({path:t,kind:"showIf",error:o})]),r&&this.hiddenFields.add(t),this.conditionalVisibilityPaths.delete(t),this.requiredConditionalPaths.delete(t),!1}n.forEach(o=>{this.dependencies.has(o)||this.dependencies.set(o,new Set),this.dependencies.get(o).add(t)})}return r&&this.conditionalVisibilityPaths.add(t),n&&_optionalChain([e, 'access', _25 => _25.conditional, 'optionalAccess', _26 => _26.requiredIf])&&(this.requiredConditionalPaths.add(t),n.forEach(o=>{this.requiredPathsByDependency.has(o)||this.requiredPathsByDependency.set(o,new Set),this.requiredPathsByDependency.get(o).add(t)})),this.requiredEvaluationVersion+=1,this.requiredEvaluationCache.clear(),this.evaluateFieldCondition(t,i),!0}onUnregister(t,e,i){this.hiddenFields.delete(t),this.conditionalVisibilityPaths.delete(t),_optionalChain([i, 'optionalAccess', _27 => _27.preserveIncomingDependents])||this.dependencies.delete(t),this.requiredEvaluationVersion+=1,this.requiredEvaluationCache.clear(),this.requiredConditionalPaths.delete(t),_optionalChain([e, 'optionalAccess', _28 => _28.conditional, 'optionalAccess', _29 => _29.dependsOn, 'optionalAccess', _30 => _30.forEach, 'call', _31 => _31(r=>{let n=this.requiredPathsByDependency.get(r);n&&(n.delete(t),n.size===0&&this.requiredPathsByDependency.delete(r))})]),this.dependencies.forEach(r=>{r.delete(t)})}isHidden(t){return this.hiddenFields.has(t)}hasDependents(t){return(_nullishCoalesce(_optionalChain([this, 'access', _32 => _32.dependencies, 'access', _33 => _33.get, 'call', _34 => _34(t), 'optionalAccess', _35 => _35.size]), () => (0)))>0}isRequired(t,e){let i=this.getFieldConfig(t);if(!i||this.isHidden(t)||!_optionalChain([i, 'access', _36 => _36.conditional, 'optionalAccess', _37 => _37.requiredIf]))return!1;let r=this.requiredEvaluationCache.get(t);if(r&&r.version===this.requiredEvaluationVersion&&r.valuesRef===e)return r.result;let n=!1;try{n=!!i.conditional.requiredIf(e)}catch(o){_optionalChain([this, 'access', _38 => _38.onConditionError, 'optionalCall', _39 => _39({path:t,kind:"requiredIf",error:o})])}return this.requiredEvaluationCache.set(t,{version:this.requiredEvaluationVersion,valuesRef:e,result:n}),n}getRequiredErrors(t){let e={};return this.requiredConditionalPaths.forEach(i=>{let r=this.getFieldConfig(i);if(r&&!this.isHidden(i)&&this.isRequired(i,t)){let n=_chunkVOA3SKFYcjs.f.call(void 0, t,i);this.isEmpty(n)&&(e[i]=_nullishCoalesce(_optionalChain([r, 'access', _40 => _40.conditional, 'optionalAccess', _41 => _41.requiredMessage]), () => ("required field")))}}),e}evaluateAll(t){this.conditionalVisibilityPaths.forEach(e=>{this.evaluateFieldCondition(e,t)})}updateDependencies(t,e,i){let r=new Set,n=new Set,o=new Set,a=[t],c=new Set;for(;a.length>0;){let u=a.shift();if(c.has(u))continue;c.add(u);let l=this.dependencies.get(u);l&&l.forEach(d=>{r.add(d);let p=this.isHidden(d),h=this.isRequired(d,e);this.evaluateFieldCondition(d,i);let g=this.isHidden(d),v=this.isRequired(d,i);p!==g&&n.add(d),h!==v&&o.add(d),a.push(d)})}return{affectedFields:Array.from(r),visibilityChanged:Array.from(n),requiredChanged:Array.from(o)}}evaluateFieldCondition(t,e){let r=_optionalChain([this, 'access', _42 => _42.getFieldConfig, 'call', _43 => _43(t), 'optionalAccess', _44 => _44.conditional, 'optionalAccess', _45 => _45.showIf]);if(r)try{r(e)?this.hiddenFields.delete(t):this.hiddenFields.add(t)}catch(n){_optionalChain([this, 'access', _46 => _46.onConditionError, 'optionalCall', _47 => _47({path:t,kind:"showIf",error:n})])}}wouldCreateCycle(t,e){for(let i of e){let r=[t],n=new Set;for(;r.length>0;){let o=r.shift();if(o===i)return!0;if(n.has(o))continue;n.add(o);let a=this.dependencies.get(o);a&&r.push(...a)}}return!1}isEmpty(t){return t==null||typeof t=="string"&&t.trim()===""||Array.isArray(t)&&t.length===0}}, _class5);var K= (_class6 =class{__init25() {this.catalog=new N}constructor(t){;_class6.prototype.__init25.call(this);this.conditions=new W(e=>this.catalog.get(e),t)}getFieldConfig(t){return this.catalog.get(t)}forEachFieldConfig(t){this.catalog.forEach((e,i)=>t(e,i))}hasFieldConfig(t){return this.catalog.has(t)}getHiddenFields(){return this.conditions.getHiddenFields()}register(t,e,i){let r=this.catalog.get(t);r&&this.conditions.onUnregister(t,r,{preserveIncomingDependents:!0}),this.catalog.set(t,e),!(this.conditions.onRegister(t,e,i)||!r)&&(this.catalog.set(t,r),this.conditions.onRegister(t,r,i))}unregister(t){let e=this.catalog.delete(t);this.conditions.onUnregister(t,e)}unregisterPrefix(t){let e=[],i=A(t);return i.length===0||(this.catalog.forEach((r,n)=>{x(n,i)&&e.push([n,r])}),e.forEach(([r,n])=>{this.catalog.delete(r),this.conditions.onUnregister(r,n)})),e}isHidden(t){return this.conditions.isHidden(t)}hasDependents(t){return this.conditions.hasDependents(t)}isRequired(t,e){return this.conditions.isRequired(t,e)}getRequiredErrors(t){return this.conditions.getRequiredErrors(t)}evaluateAll(t){this.conditions.evaluateAll(t)}updateDependencies(t,e,i){return this.conditions.updateDependencies(t,e,i)}getScopeFields(t){return this.catalog.getScopeFields(t)}getComputedEntries(){return this.catalog.getComputedEntries()}getTransformEntries(){return this.catalog.getTransformEntries()}getNormalizerEntries(){return this.catalog.getNormalizerEntries()}invalidateIndexes(){this.catalog.invalidateIndexes()}}, _class6);function oi(){return`bit-form-${Math.random().toString(36).slice(2,9)}`}function ai(s){typeof console<"u"&&typeof console.error=="function"&&console.error(s)}function Jt(s={}){let t=_nullishCoalesce(s.initialValues, () => ({})),e=s.validation,i=s.history,r=s.name?`bit-form:${s.name}:draft`:"bit-form:draft",n=_nullishCoalesce(s.onUnhandledError, () => (ai)),o=_optionalChain([s, 'access', _48 => _48.persist, 'optionalAccess', _49 => _49.onError]),a={enabled:_nullishCoalesce(_optionalChain([s, 'access', _50 => _50.persist, 'optionalAccess', _51 => _51.enabled]), () => (!1)),key:_nullishCoalesce(_optionalChain([s, 'access', _52 => _52.persist, 'optionalAccess', _53 => _53.key]), () => (r)),storage:_optionalChain([s, 'access', _54 => _54.persist, 'optionalAccess', _55 => _55.storage]),autoSave:_nullishCoalesce(_optionalChain([s, 'access', _56 => _56.persist, 'optionalAccess', _57 => _57.autoSave]), () => (!0)),debounceMs:_nullishCoalesce(_optionalChain([s, 'access', _58 => _58.persist, 'optionalAccess', _59 => _59.debounceMs]), () => (300)),mode:_nullishCoalesce(_optionalChain([s, 'access', _60 => _60.persist, 'optionalAccess', _61 => _61.mode]), () => ("values")),serialize:_nullishCoalesce(_optionalChain([s, 'access', _62 => _62.persist, 'optionalAccess', _63 => _63.serialize]), () => (JSON.stringify)),deserialize:_nullishCoalesce(_optionalChain([s, 'access', _64 => _64.persist, 'optionalAccess', _65 => _65.deserialize]), () => ((c=>JSON.parse(c)))),onError:c=>{if(o){o(c);return}n(c,"persist")}};return{name:s.name,initialValues:_chunkVOA3SKFYcjs.a.call(void 0, t),resolver:_optionalChain([e, 'optionalAccess', _66 => _66.resolver]),validationDelay:_nullishCoalesce(_optionalChain([e, 'optionalAccess', _67 => _67.delay]), () => (300)),history:{enabled:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _68 => _68.enabled]), () => (!1)),limit:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _69 => _69.limit]), () => (50))},masks:s.masks,fields:s.fields,devTools:s.devTools,persist:a,idFactory:_nullishCoalesce(s.idFactory, () => (oi)),plugins:_nullishCoalesce(s.plugins, () => ([])),scheduler:s.scheduler,subscriptionCacheSize:s.subscriptionCacheSize,trackedSubscriptions:_nullishCoalesce(s.trackedSubscriptions, () => (!1)),bus:s.bus,onUnhandledError:n}}function $(s,t){if((!s||s.length===0)&&(!t||t.length===0))return;let e=new Set(_nullishCoalesce(s, () => ([])));return _optionalChain([t, 'optionalAccess', _70 => _70.forEach, 'call', _71 => _71(i=>e.add(i))]),Array.from(e)}function li(s){let t=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _72 => _72.includes, 'call', _73 => _73("*")]), () => (!1)),e=new Set(_nullishCoalesce(s, () => ([]))),i=new Set;for(let r of e){i.add(r);let n=r.lastIndexOf(".");for(;n>-1;)i.add(r.slice(0,n)),n=r.lastIndexOf(".",n-1)}return r=>{if(!s||s.length===0||t||e.has(r)||i.has(r))return!0;let n=r.lastIndexOf(".");for(;n>-1;){if(e.has(r.slice(0,n)))return!0;n=r.lastIndexOf(".",n-1)}return!1}}function ci(s,t){if(!t||t.length===0||t.includes("*"))return s;let e=li(t);return s.filter(i=>i.dependsOn.some(r=>e(r)))}function di(s){if(s.length<=1)return{orderedEntries:[...s],cyclePaths:[]};let t=new Map(s.map(a=>[a.path,a])),e=new Map,i=new Map,r=new Map(s.map((a,c)=>[a.path,c]));s.forEach(a=>e.set(a.path,0)),s.forEach(a=>{a.dependsOn.forEach(c=>{if(c===a.path||!t.has(c))return;let u=_nullishCoalesce(i.get(c), () => (new Set));u.has(a.path)||(u.add(a.path),i.set(c,u),e.set(a.path,(_nullishCoalesce(e.get(a.path), () => (0)))+1))})});let n=s.filter(a=>(_nullishCoalesce(e.get(a.path), () => (0)))===0).map(a=>a.path),o=[];for(;n.length>0;){n.sort((u,l)=>(_nullishCoalesce(r.get(u), () => (0)))-(_nullishCoalesce(r.get(l), () => (0))));let a=n.shift();o.push(a);let c=i.get(a);c&&c.forEach(u=>{let l=(_nullishCoalesce(e.get(u), () => (0)))-1;e.set(u,l),l===0&&n.push(u)})}if(o.length!==s.length){let a=s.filter(c=>(_nullishCoalesce(e.get(c.path), () => (0)))>0).map(c=>c.path);return{orderedEntries:o.map(c=>t.get(c)),cyclePaths:a}}return{orderedEntries:o.map(a=>t.get(a)),cyclePaths:[]}}function J(s){let{values:t,changedPaths:e,normalizerEntries:i,applyComputed:r,onError:n}=s,o=di(ci(i,e)),{orderedEntries:a,cyclePaths:c}=o;if(c.length>0&&_optionalChain([n, 'optionalCall', _74 => _74(new Error(`BitStore: cyclic normalizer dependencies detected. Check normalizeDependsOn definitions for: ${c.join(", ")}.`),_nullishCoalesce(c[0], () => ("*")))]),a.length===0)return r(t,e);let u=[],l=t;for(let p of a){let h=_chunkVOA3SKFYcjs.f.call(void 0, l,p.path),g;try{g=p.normalize(h,l)}catch(v){_optionalChain([n, 'optionalCall', _75 => _75(v,p.path)]);continue}_chunkVOA3SKFYcjs.c.call(void 0, h,g)||(u.push([p.path,g]),l=_chunkVOA3SKFYcjs.g.call(void 0, l,p.path,g))}let d=$(e,u.map(([p])=>p));return r(l,d)}function Yt(s){let{values:t,sourceValues:e,transformEntries:i,onError:r}=s;if(i.length===0)return t;let n=t,o=e;for(let[a,c]of i){let u=_chunkVOA3SKFYcjs.f.call(void 0, n,a),l;try{l=c(u,o)}catch(d){_optionalChain([r, 'optionalCall', _76 => _76(d,a)]);continue}_chunkVOA3SKFYcjs.c.call(void 0, u,l)||(n=_chunkVOA3SKFYcjs.g.call(void 0, n,a,l),o=_chunkVOA3SKFYcjs.g.call(void 0, o,a,l))}return n}var Y=class{constructor(t){this.effects=t.getAll()}attachStorePort(t){this.effects.forEach(e=>_optionalChain([e, 'access', _77 => _77.attachStorePort, 'optionalCall', _78 => _78(t)]))}initialize(){this.effects.forEach(t=>_optionalChain([t, 'access', _79 => _79.initialize, 'optionalCall', _80 => _80()]))}onStateUpdated(t,e){this.effects.forEach(i=>_optionalChain([i, 'access', _81 => _81.onStateUpdated, 'optionalCall', _82 => _82(t,e)]))}async restorePersisted(){let t=!1;for(let e of this.effects)e.restorePersisted&&(t=await e.restorePersisted()||t);return t}async savePersistedNow(){for(let t of this.effects)t.savePersistedNow&&await t.savePersistedNow()}async clearPersisted(){for(let t of this.effects)t.clearPersisted&&await t.clearPersisted()}async beforeValidate(t){for(let e of this.effects)if(e.beforeValidate)try{await e.beforeValidate(t)}catch(i){this.logEffectHookError(e.name,"beforeValidate",i)}}async afterValidate(t){for(let e of this.effects)if(e.afterValidate)try{await e.afterValidate(t)}catch(i){this.logEffectHookError(e.name,"afterValidate",i)}}async beforeSubmit(t){for(let e of this.effects)if(e.beforeSubmit)try{await e.beforeSubmit(t)}catch(i){this.logEffectHookError(e.name,"beforeSubmit",i)}}async afterSubmit(t){for(let e of this.effects)if(e.afterSubmit)try{await e.afterSubmit(t)}catch(i){this.logEffectHookError(e.name,"afterSubmit",i)}}onFieldChange(t){this.effects.forEach(e=>{try{_optionalChain([e, 'access', _83 => _83.onFieldChange, 'optionalCall', _84 => _84(t)])}catch(i){this.logEffectHookError(e.name,"onFieldChange",i)}})}async reportOperationalError(t){for(let e of this.effects)if(e.reportOperationalError)try{await e.reportOperationalError(t)}catch(i){this.logEffectHookError(e.name,"reportOperationalError",i)}}logEffectHookError(t,e,i){console.error(`BitStoreEffectEngine: effect "${t}" failed in hook "${e}"`,i)}destroy(){for(let t=this.effects.length-1;t>=0;t-=1)_optionalChain([this, 'access', _85 => _85.effects, 'access', _86 => _86[t], 'access', _87 => _87.destroy, 'optionalCall', _88 => _88()])}};var G=class{constructor(t,e,i=!0,r){this.storeId=t;this.bus=e;this.enableBusDispatch=i;this.storeBusPort=r}attachStorePort(t){this.storeBusPort=t,this.enableBusDispatch&&(this.bus.stores[this.storeId]=t)}initialize(){!this.enableBusDispatch||!this.storeBusPort||(this.bus.stores[this.storeId]=this.storeBusPort)}onStateUpdated(t){this.enableBusDispatch&&this.bus.dispatch(this.storeId,t)}destroy(){this.enableBusDispatch&&delete this.bus.stores[this.storeId]}};var X= (_class7 =class{constructor() { _class7.prototype.__init26.call(this); }__init26() {this.effects=new Map}register(t){this.effects.set(t.name,t)}getAll(){return Array.from(this.effects.values())}}, _class7);var Q=class{constructor(t){this.persistManager=t}onStateUpdated(t,e){e&&this.persistManager.queueSave()}restorePersisted(){return this.persistManager.restore()}savePersistedNow(){return this.persistManager.saveNow()}clearPersisted(){return this.persistManager.clear()}destroy(){this.persistManager.destroy()}};var Z=class{constructor(t){this.pluginManager=t}initialize(){this.pluginManager.setupAll()}beforeValidate(t){return this.pluginManager.beforeValidate(t)}afterValidate(t){return this.pluginManager.afterValidate(t)}beforeSubmit(t){return this.pluginManager.beforeSubmit(t)}afterSubmit(t){return this.pluginManager.afterSubmit(t)}onFieldChange(t){this.pluginManager.onFieldChange(t)}reportOperationalError(t){return this.pluginManager.reportError(t.source,t.error,t.payload)}destroy(){this.pluginManager.destroy()}};function ui(){if(typeof globalThis>"u")return;let s;try{s=_nullishCoalesce(globalThis.localStorage, () => (void 0))}catch (e2){return}if(s)return{getItem:t=>s.getItem(t),setItem:(t,e)=>s.setItem(t,e),removeItem:t=>s.removeItem(t)}}var tt=class{constructor(t,e,i,r,n={}){this.config=t;this.getValues=e;this.getDirtyValues=i;this.applyRestoredValues=r;this.callbacks=n}getStorage(){return this.config.storage||ui()}canPersist(){return!!(this.config.enabled&&this.config.key&&this.getStorage())}handleError(t){_optionalChain([this, 'access', _89 => _89.callbacks, 'access', _90 => _90.onError, 'optionalCall', _91 => _91(t)]),_optionalChain([this, 'access', _92 => _92.config, 'access', _93 => _93.onError, 'optionalCall', _94 => _94(t)])}async persistPayload(){let t=this.getStorage();if(!t)return;let e=this.config.mode==="dirtyValues"?this.getDirtyValues():this.getValues(),i=this.config.serialize(e);await t.setItem(this.config.key,i)}async saveNow(){if(this.canPersist())try{await this.persistPayload()}catch(t){throw this.handleError(t),t}}queueSave(){!this.canPersist()||!this.config.autoSave||(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,_optionalChain([this, 'access', _95 => _95.callbacks, 'access', _96 => _96.onAutoSaveStart, 'optionalCall', _97 => _97()]),this.saveNow().then(()=>{_optionalChain([this, 'access', _98 => _98.callbacks, 'access', _99 => _99.onAutoSaveSuccess, 'optionalCall', _100 => _100()])}).catch(t=>{_optionalChain([this, 'access', _101 => _101.callbacks, 'access', _102 => _102.onAutoSaveError, 'optionalCall', _103 => _103(t)])})},this.config.debounceMs))}async restore(){if(!this.canPersist())return!1;let t=this.getStorage();if(!t)return!1;try{let e=await t.getItem(this.config.key);if(!e)return!1;let i=this.config.deserialize(e);return!i||typeof i!="object"?!1:(this.applyRestoredValues(i),!0)}catch(e){return this.handleError(e),!1}}async clear(){if(!this.canPersist())return;let t=this.getStorage();if(t)try{await t.removeItem(this.config.key)}catch(e){this.handleError(e)}}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=void 0)}};var et= (_class8 =class{constructor(t,e){;_class8.prototype.__init27.call(this);_class8.prototype.__init28.call(this);_class8.prototype.__init29.call(this);_class8.prototype.__init30.call(this);this.plugins=t;this.contextFactory=e}__init27() {this.teardownFns=[]}__init28() {this.notifyingError=!1}__init29() {this.pendingErrorQueue=[]}__init30() {this.cachedContext=null}setupAll(){let t=this.getContext();this.plugins.forEach(e=>{if(e.setup)try{let i=e.setup(t);typeof i=="function"&&this.teardownFns.push(i)}catch(i){this.reportError("setup",i,void 0,e.name)}})}async beforeValidate(t){await this.emitHook("beforeValidate",t)}async afterValidate(t){await this.emitHook("afterValidate",t)}async beforeSubmit(t){await this.emitHook("beforeSubmit",t)}async afterSubmit(t){await this.emitHook("afterSubmit",t)}onFieldChange(t){let e=this.getContext();this.plugins.forEach(i=>{let r=_optionalChain([i, 'access', _104 => _104.hooks, 'optionalAccess', _105 => _105.onFieldChange]);if(r)try{let n=r(t,e);Promise.resolve(n).catch(o=>{this.reportError("onFieldChange",o,t,i.name)})}catch(n){this.reportError("onFieldChange",n,t,i.name)}})}async reportError(t,e,i,r){let n=this.getContext();if(this.pendingErrorQueue.push({source:t,pluginName:r,error:e,event:i,values:n.getState().values,state:n.getState()}),!this.notifyingError){this.notifyingError=!0;try{for(;this.pendingErrorQueue.length>0;){let o=this.pendingErrorQueue.shift();if(!o)break;for(let a of this.plugins){let c=_optionalChain([a, 'access', _106 => _106.hooks, 'optionalAccess', _107 => _107.onError]);if(c)try{await c(o,n)}catch (e3){}}}}finally{this.notifyingError=!1}}}destroy(){for(let t=this.teardownFns.length-1;t>=0;t-=1){let e=this.teardownFns[t];try{e()}catch(i){this.reportError("teardown",i)}}this.teardownFns=[],this.cachedContext=null}async emitHook(t,e){let i=this.getContext();for(let r of this.plugins){let n=_optionalChain([r, 'access', _108 => _108.hooks, 'optionalAccess', _109 => _109[t]]);if(n)try{await n(e,i)}catch(o){await this.reportError(t,o,e,r.name)}}}getContext(){return this.cachedContext||(this.cachedContext=this.contextFactory()),this.cachedContext}}, _class8);var Ft=typeof globalThis<"u"?globalThis:typeof global<"u"?global:window;Ft.__BIT_FORM__||(Ft.__BIT_FORM__={stores:{},listeners:new Set,dispatch(s,t){this.listeners.forEach(e=>e(s,t))},subscribe(s){return this.listeners.add(s),()=>{this.listeners.delete(s)}}});var wt=Ft.__BIT_FORM__,pi={stores:{},listeners:new Set,dispatch:()=>{},subscribe:()=>()=>{}};function At(){return pi}function hi(){let s=new Set;return{stores:{},listeners:s,dispatch(t,e){s.forEach(i=>i(t,e))},subscribe(t){return s.add(t),()=>s.delete(t)}}}function fi(s){return s.bus?!0:typeof s.devTools=="boolean"?s.devTools:s.devTools&&typeof s.devTools=="object"?s.devTools.enabled!==!1:!1}function Gt(s){let{storeId:t,storeBusPort:e,config:i,getState:r,getConfig:n,getValues:o,getDirtyValues:a,applyPersistedValues:c,setPersistMetadata:u}=s,l=new tt(i.persist,o,a,c,{onAutoSaveStart:()=>_optionalChain([u, 'optionalCall', _110 => _110({isSaving:!0,error:null})]),onAutoSaveSuccess:()=>_optionalChain([u, 'optionalCall', _111 => _111({isSaving:!1,error:null})]),onAutoSaveError:b=>_optionalChain([u, 'optionalCall', _112 => _112({isSaving:!1,error:b instanceof Error?b:new Error(String(b))})]),onError:b=>i.onUnhandledError(b,"persist")}),d=new et([...i.plugins],()=>({storeId:t,getState:()=>r(),getConfig:()=>n()})),p=fi(i),h=typeof process<"u"&&typeof process.env<"u"&&process.env.VITEST==="true",g=p?_nullishCoalesce(i.bus, () => ((h?At():wt))):At(),v=new X,f=new Q(l);v.register({name:"persist",onStateUpdated:(b,O)=>f.onStateUpdated(b,O),restorePersisted:()=>f.restorePersisted(),savePersistedNow:()=>f.savePersistedNow(),clearPersisted:()=>f.clearPersisted(),destroy:()=>f.destroy()});let m=new Z(d);v.register({name:"plugins",initialize:()=>m.initialize(),beforeValidate:b=>m.beforeValidate(b),afterValidate:b=>m.afterValidate(b),beforeSubmit:b=>m.beforeSubmit(b),afterSubmit:b=>m.afterSubmit(b),onFieldChange:b=>m.onFieldChange(b),reportOperationalError:b=>m.reportOperationalError(b),destroy:()=>m.destroy()});let T=new G(t,g,p,e);v.register({name:"bus",attachStorePort:b=>T.attachStorePort(b),initialize:()=>T.initialize(),onStateUpdated:b=>T.onStateUpdated(b),destroy:()=>T.destroy()});let P=new Y(v);return P.initialize(),P}function S(s,t,e){return{kind:"state.patch",partialState:s,changedPaths:t,skipComputed:_optionalChain([e, 'optionalAccess', _113 => _113.skipComputed])}}function It(s){return{kind:"field.touchMany",paths:s}}function w(s){return{kind:"form.persistMeta",patch:s}}function it(s,t){return{kind:"validation.commit",errors:s,isValid:t}}async function Xt(s){let{dispatch:t,effects:e}=s;t(w({isRestoring:!0,error:null}));try{return await e.restorePersisted()}catch(i){return t(w({isRestoring:!1,error:i instanceof Error?i:new Error(String(i))})),!1}finally{t(w({isRestoring:!1}))}}async function Qt(s){let{dispatch:t,effects:e}=s,i=null;t(w({isSaving:!0,error:null}));try{await e.savePersistedNow()}catch(r){i=r instanceof Error?r:new Error(String(r))}finally{t(w({isSaving:!1,error:i}))}}async function Zt(s){let{dispatch:t,effects:e}=s,i=null;t(w({isSaving:!0,error:null}));try{await e.clearPersisted()}catch(r){i=r instanceof Error?r:new Error(String(r))}finally{t(w({isSaving:!1,error:i}))}}function te(s){let{values:t,state:e,initialValues:i,validation:r,fieldRegistry:n,dirtyManager:o,dispatch:a,saveHistorySnapshot:c}=s,u=_chunkVOA3SKFYcjs.a.call(void 0, _chunkVOA3SKFYcjs.b.call(void 0, i,t));r.cancelAll(),n.evaluateAll(u);let l=o.rebuild(u,i);a(S({values:u,errors:{},touched:{},isValidating:{},persist:{...e.persist,error:null},isValid:!1,isDirty:l})),c(),r.validate()}function ee(s){let{state:t,path:e}=s,i=`${e}.`,r={...t.errors},n={...t.touched},o=!1;for(let a of Object.keys(r))(a===e||a.startsWith(i))&&(delete r[a],o=!0);for(let a of Object.keys(n))(a===e||a.startsWith(i))&&(delete n[a],o=!0);return o?{errors:r,touched:n}:null}function rt(s){let t=[],e=new Map,i=new Set(s.map(a=>a.path));for(let a of s)if(e.has(a.path)||e.set(a.path,new Set),a.dependsOn)for(let c of a.dependsOn)i.has(c)&&e.get(a.path).add(c);let r=new Set,n=new Set,o=(a,c)=>{r.add(a),n.add(a),c.push(a);let u=e.get(a)||new Set;for(let l of u)if(r.has(l)){if(n.has(l)){let d=c.indexOf(l),p=[...c.slice(d),l];return{cycle:p,paths:Array.from(e.keys()).filter(h=>p.includes(h)),message:`Circular dependency detected: ${p.join(" \u2192 ")}. Check your computed field definitions.`}}}else{let d=o(l,[...c]);if(d)return d}return n.delete(a),null};for(let a of e.keys())if(!r.has(a)){let c=o(a,[]);c&&!t.some(u=>u.message===c.message)&&t.push(c)}return t}function ie(s){return!!(_optionalChain([s, 'optionalAccess', _114 => _114.computed])||_optionalChain([s, 'optionalAccess', _115 => _115.normalize]))}function re(s){let{path:t,config:e,state:i,fieldRegistry:r,subscriptions:n,validationCleanupField:o,stateReader:a,invalidateFieldIndexes:c,dispatch:u,getState:l,onUnhandledError:d}=s,p=r.getFieldConfig(t),h=_optionalChain([p, 'optionalAccess', _116 => _116.validation, 'optionalAccess', _117 => _117.asyncValidate]),g=_optionalChain([e, 'access', _118 => _118.validation, 'optionalAccess', _119 => _119.asyncValidate]),v=_nullishCoalesce(_optionalChain([p, 'optionalAccess', _120 => _120.validation, 'optionalAccess', _121 => _121.asyncValidateOn]), () => ("blur")),f=_nullishCoalesce(_optionalChain([e, 'access', _122 => _122.validation, 'optionalAccess', _123 => _123.asyncValidateOn]), () => ("blur"));p&&h&&(g!==h||f!==v)&&o(t);let T=!!(_optionalChain([p, 'optionalAccess', _124 => _124.computed])||e.computed),P=ie(p)||ie(e);if(r.register(t,e,i.values),c(),T){let O=rt(r.getComputedEntries());if(O.length>0){p?r.register(t,p,i.values):r.unregister(t),c(),n.invalidatePathExpansionCache(t),a.invalidatePath(t),d(new Error(O[0].message),"computed");return}}n.invalidatePathExpansionCache(t),a.invalidatePath(t),P&&u(S({values:i.values},["*"]));let b=l();e.scope&&n.notify(b,[_chunkRHMJPKNVcjs.d.call(void 0, e.scope)]),r.isHidden(t)&&n.notify(b,[t])}function se(s){let{path:t,state:e,hasStaticConfig:i,fieldRegistry:r,subscriptions:n,validationCleanupField:o,invalidateFieldIndexes:a,dispatch:c}=s;if(i)return;let u=r.getFieldConfig(t);o(t),r.unregister(t),a(),n.invalidatePathExpansionCache(t),_optionalChain([u, 'optionalAccess', _125 => _125.scope])&&n.notify(e,[_chunkRHMJPKNVcjs.d.call(void 0, u.scope)]);let l=ee({state:e,path:t});l&&c(S({errors:l.errors,touched:l.touched}))}function st(s){let{prefix:t,state:e,fieldRegistry:i,subscriptions:r,validationCleanupPrefix:n,invalidateFieldIndexes:o,dispatch:a}=s;n(t);let c=i.unregisterPrefix(t);o(),r.invalidatePathExpansionCache(t),new Set(c.map(([,h])=>h.scope).filter(h=>!!h)).forEach(h=>{r.notify(e,[_chunkRHMJPKNVcjs.d.call(void 0, h)])});let l={...e.errors},d={...e.touched},p=!1;for(let[h]of c)l[h]&&(delete l[h],p=!0),d[h]&&(delete d[h],p=!0);p&&a(S({errors:l,touched:d}))}var nt= (_class9 =class{constructor(t,e=500){;_class9.prototype.__init31.call(this);_class9.prototype.__init32.call(this);_class9.prototype.__init33.call(this);_class9.prototype.__init34.call(this);_class9.prototype.__init35.call(this);_class9.prototype.__init36.call(this);_class9.prototype.__init37.call(this);_class9.prototype.__init38.call(this);_class9.prototype.__init39.call(this);this.getState=t;this.MAX_PATH_EXPANSION_CACHE_SIZE=e}__init31() {this.listeners=new Set}__init32() {this.pathScopedSubscriptions=new Map}__init33() {this.pathSelectorIndex=new Map}__init34() {this.pathExpansionCache=new Map}__init35() {this.subscriptionSeenVersion=new Map}__init36() {this.notifyVersion=0}__init37() {this.cacheHits=0}__init38() {this.cacheMisses=0}__init39() {this.cacheEvictions=0}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}subscribeSelector(t,e,i,r){let n=t(this.getState()),o={notify:c=>{let u=t(c);r(n,u)||(n=u,e(u))}},a=this.normalizeSubscriptionPaths(i.paths);return this.pathScopedSubscriptions.set(o,a),a.forEach(c=>{this.forEachIndexPath(c,u=>{let l=_nullishCoalesce(this.pathSelectorIndex.get(u), () => (new Set));l.add(o),this.pathSelectorIndex.set(u,l)})}),i.emitImmediately&&e(n),()=>{this.subscriptionSeenVersion.delete(o);let c=this.pathScopedSubscriptions.get(o);c&&(c.forEach(u=>{this.forEachIndexPath(u,l=>{let d=this.pathSelectorIndex.get(l);d&&(d.delete(o),d.size===0&&this.pathSelectorIndex.delete(l))})}),this.pathScopedSubscriptions.delete(o))}}notify(t,e){if(this.listeners.forEach(n=>{try{n()}catch(o){console.error("Subscription listener error:",o)}}),this.pathScopedSubscriptions.size===0)return;let i=this.normalizeChangedPathIterable(e);if(i.length===0||i.includes("*")){this.pathScopedSubscriptions.forEach((n,o)=>{try{o.notify(t)}catch(a){console.error("Path subscription notify error:",a)}});return}if(i.length===1&&this.isSimplePath(i[0])){this.collectSubscribersForSingleChangedPath(i[0]).forEach(o=>{try{o.notify(t)}catch(a){console.error("Path subscription notify error:",a)}});return}this.collectSubscribersForChangedPaths(i).forEach(n=>{try{n.notify(t)}catch(o){console.error("Path subscription notify error:",o)}})}destroy(){this.listeners.clear(),this.pathScopedSubscriptions.clear(),this.pathSelectorIndex.clear(),this.pathExpansionCache.clear(),this.subscriptionSeenVersion.clear()}getPathExpansionCacheStats(){return{cacheSize:this.pathExpansionCache.size,cacheLimit:this.MAX_PATH_EXPANSION_CACHE_SIZE,cacheHits:this.cacheHits,cacheMisses:this.cacheMisses,cacheEvictions:this.cacheEvictions}}getActiveSubscribersCount(){return this.pathScopedSubscriptions.size}invalidatePathExpansionCache(t){if(!t){this.pathExpansionCache.clear();return}let e=A(t);if(e.length===0){this.pathExpansionCache.clear();return}for(let i of this.pathExpansionCache.keys())(x(i,e)||x(e,i))&&this.pathExpansionCache.delete(i)}normalizeSubscriptionPaths(t){if(!t||t.length===0)return[];let e=new Set,i=[];for(let r of t){let n=r.trim();n.length===0||e.has(n)||(e.add(n),i.push(n))}return i}normalizeChangedPathIterable(t){if(!t)return[];let e=new Set,i=[];for(let r of t){let n=r.trim();n.length===0||e.has(n)||(e.add(n),i.push(n))}return i}collectSubscribersForChangedPaths(t){let e=[],i=++this.notifyVersion,r=n=>{let o=this.pathSelectorIndex.get(n);o&&o.forEach(a=>{(_nullishCoalesce(this.subscriptionSeenVersion.get(a), () => (0)))>=i||(this.subscriptionSeenVersion.set(a,i),e.push(a))})};return t.forEach(n=>{this.forEachLookupPath(n,r)}),e}collectSubscribersForSingleChangedPath(t){let e=[],i=++this.notifyVersion,r=n=>{let o=this.pathSelectorIndex.get(n);o&&o.forEach(a=>{(_nullishCoalesce(this.subscriptionSeenVersion.get(a), () => (0)))>=i||(this.subscriptionSeenVersion.set(a,i),e.push(a))})};return this.forEachLookupPath(t,r),e}expandChangedPathForLookup(t){return this.expandPathGeneric(t)}expandPathForIndexing(t){return this.expandPathGeneric(t)}forEachIndexPath(t,e){if(!this.isSimplePath(t)){this.expandPathForIndexing(t).forEach(e);return}let i=t.split("."),r="";for(let n=0;n<i.length;n+=1)r=r?`${r}.${i[n]}`:i[n],e(r)}forEachLookupPath(t,e){if(!this.isSimplePath(t)){this.expandChangedPathForLookup(t).forEach(e);return}e(t);let i=t.lastIndexOf(".");for(;i>-1;)e(t.slice(0,i)),i=t.lastIndexOf(".",i-1)}isSimplePath(t){return!t.includes("*")&&!t.includes("[")&&!t.includes("]")}expandPathGeneric(t){let e=this.pathExpansionCache.get(t);if(e)return this.cacheHits+=1,e;this.cacheMisses+=1;let i=t.split("."),r=[];for(let n=1;n<=i.length;n++)r.push(i.slice(0,n).join("."));return this.setBoundedCacheEntry(this.pathExpansionCache,t,r,this.MAX_PATH_EXPANSION_CACHE_SIZE),r}setBoundedCacheEntry(t,e,i,r){if(t.size>=r){let n=t.keys().next().value;n!==void 0&&(t.delete(n),this.cacheEvictions+=1)}t.set(e,i)}}, _class9);var ot= (_class10 =class{constructor(t){;_class10.prototype.__init40.call(this);this.store=t}__init40() {this.pathIds=new Map}getItemIds(t,e){let i=typeof e=="number"?Math.max(0,e):this.getCurrentArrayLength(t);return[...this.ensureIds(t,i)]}pushItem(t,e){this.withPathIds(t,i=>(i.push(this.store.createArrayItemId(t,i.length)),i)),this.mutateArrayWithSetField(t,i=>[...i,e],{origin:"array",operation:"push"})}prependItem(t,e){this.withPathIds(t,r=>(r.unshift(this.store.createArrayItemId(t,0)),r)),_optionalChain([this, 'access', _126 => _126.store, 'access', _127 => _127.unregisterPrefix, 'optionalCall', _128 => _128(C(t))]);let i=_nullishCoalesce(_chunkVOA3SKFYcjs.f.call(void 0, this.store.getState().values,t), () => ([]));this.commitArrayMutationWithFieldPipeline({path:t,nextArray:[e,...i],meta:{origin:"array",operation:"prepend"},reindex:r=>r+1})}insertItem(t,e,i){let r=this.getCurrentArrayLength(t),n=Math.max(0,Math.min(e,r));if(this.withPathIds(t,c=>{let u=[...c];return u.splice(n,0,this.store.createArrayItemId(t,n)),u}),this.store.unregisterPrefix)for(let c=n;c<r;c++)this.store.unregisterPrefix(C(t,c));let a=[..._nullishCoalesce(_chunkVOA3SKFYcjs.f.call(void 0, this.store.getState().values,t), () => ([]))];a.splice(n,0,i),this.commitArrayMutationWithFieldPipeline({path:t,nextArray:a,meta:{origin:"array",operation:"insert",index:n},reindex:c=>c<n?c:c+1})}removeItem(t,e){let i=this.store.getState(),r=_chunkVOA3SKFYcjs.f.call(void 0, i.values,t);if(!Array.isArray(r)||e<0||e>=r.length)return;this.withPathIds(t,o=>{let a=[...o];return a.splice(e,1),a}),this.store.unregisterPrefix&&this.store.unregisterPrefix(C(t,e));let n=r.filter((o,a)=>a!==e);this.commitArrayMutationWithFieldPipeline({path:t,nextArray:n,meta:{origin:"array",operation:"remove",index:e},reindex:o=>o===e?null:o>e?o-1:o})}swapItems(t,e,i){let r=this.store.getState(),n=_chunkVOA3SKFYcjs.f.call(void 0, r.values,t);if(!Array.isArray(n)||e<0||e>=n.length||i<0||i>=n.length)return;this.withPathIds(t,a=>{let c=[...a];return[c[e],c[i]]=[c[i],c[e]],c});let o=[...n];[o[e],o[i]]=[o[i],o[e]],this.store.unregisterPrefix&&(this.store.unregisterPrefix(C(t,e)),this.store.unregisterPrefix(C(t,i))),this.commitArrayMutationWithFieldPipeline({path:t,nextArray:o,meta:{origin:"array",operation:"swap",from:e,to:i},reindex:a=>a===e?i:a===i?e:a})}moveItem(t,e,i){let r=this.store.getState(),n=_chunkVOA3SKFYcjs.f.call(void 0, r.values,t);if(!Array.isArray(n)||e<0||e>=n.length||i<0||i>=n.length)return;this.withPathIds(t,c=>{let u=[...c],[l]=u.splice(e,1);return u.splice(i,0,l),u});let o=[...n],[a]=o.splice(e,1);if(o.splice(i,0,a),this.store.unregisterPrefix){let c=Math.min(e,i),u=Math.max(e,i);for(let l=c;l<=u;l+=1)this.store.unregisterPrefix(C(t,l))}this.commitArrayMutationWithFieldPipeline({path:t,nextArray:o,meta:{origin:"array",operation:"move",from:e,to:i},reindex:c=>c===e?i:e<i&&c>e&&c<=i?c-1:e>i&&c>=i&&c<e?c+1:c})}replaceItems(t,e){_optionalChain([this, 'access', _129 => _129.store, 'access', _130 => _130.unregisterPrefix, 'optionalCall', _131 => _131(C(t))]),this.pathIds.set(t,e.map((i,r)=>this.store.createArrayItemId(t,r))),this.commitArrayMutationWithFieldPipeline({path:t,nextArray:e,meta:{origin:"array",operation:"replace"},reindex:i=>i<e.length?i:null})}clearItems(t){this.pathIds.set(t,[]),this.store.unregisterPrefix&&this.store.unregisterPrefix(C(t)),this.commitArrayMutationWithFieldPipeline({path:t,nextArray:[],meta:{origin:"array",operation:"clear"},reindex:()=>null})}mutateArrayWithSetField(t,e,i){let r=_chunkVOA3SKFYcjs.f.call(void 0, this.store.getState().values,t)||[];this.store.setFieldWithMeta(t,e(r),i),this.store.internalSaveSnapshot()}withPathIds(t,e){let i=this.getCurrentArrayLength(t),r=this.ensureIds(t,i);this.pathIds.set(t,e(r))}ensureIds(t,e){let i=_nullishCoalesce(this.pathIds.get(t), () => ([]));if(i.length===e)return i;if(i.length<e){let n=[...i];for(let o=i.length;o<e;o+=1)n.push(this.store.createArrayItemId(t,o));return this.pathIds.set(t,n),n}let r=i.slice(0,e);return this.pathIds.set(t,r),r}getCurrentArrayLength(t){let e=_chunkVOA3SKFYcjs.f.call(void 0, this.store.getState().values,t);return Array.isArray(e)?e.length:0}commitArrayMutationWithFieldPipeline(t){let{path:e,nextArray:i,meta:r,reindex:n}=t,o=this.store.getState();this.store.setFieldWithMeta(e,i,r);let a=_chunkVOA3SKFYcjs.k.call(void 0, o,e,n);_optionalChain([this, 'access', _132 => _132.store, 'access', _133 => _133.remapValidationPaths, 'optionalCall', _134 => _134(e,n)]),this.store.dispatch(S({errors:a.errors,touched:a.touched,isValidating:a.isValidating},[e])),this.store.internalSaveSnapshot()}}, _class10);var at=class{constructor(t,e,i){this.getState=t;this.dispatch=e;this.reportError=i}reportInvalidInput(t,e){_optionalChain([this, 'access', _135 => _135.reportError, 'optionalCall', _136 => _136(new Error(e===void 0?t:`${t}: ${String(e)}`))])}setError(t,e){if(!t||typeof t!="string"){this.reportInvalidInput("setError received an invalid path",t);return}if(e!==void 0&&typeof e!="string"){this.reportInvalidInput("setError received an invalid message",e);return}let i={...this.getState().errors,[t]:e};e===void 0&&delete i[t],this.dispatch(S({errors:i}))}setErrors(t){if(!t||typeof t!="object"){this.reportInvalidInput("setErrors received an invalid payload");return}let e={};Object.entries(t).forEach(([i,r])=>{if(!i){this.reportInvalidInput("setErrors ignored an empty path");return}if(r!==void 0&&typeof r!="string"){this.reportInvalidInput("setErrors ignored a non-string message",i);return}e[i]=r}),this.dispatch(S({errors:{...this.getState().errors,...e}}))}setServerErrors(t,e){let i=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _137 => _137.arrayStrategy]), () => ("first")),r=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _138 => _138.joinSeparator]), () => ("; ")),n={};for(let[o,a]of Object.entries(t)){if(!o){this.reportInvalidInput("setServerErrors ignored an empty path");continue}if(Array.isArray(a)){let c=a.filter(u=>typeof u=="string"&&u.length>0);if(c.length===0)continue;n[o]=i==="join"?c.join(r):c[0];continue}n[o]=a}this.setErrors(n)}};var lt= (_class11 =class{constructor(t,e,i){;_class11.prototype.__init41.call(this);this.fieldMetadataProvider=t;this.getState=e;this.isPathDirty=i}__init41() {this.requiredValuesRef=null}isHidden(t){return this.fieldMetadataProvider.isHidden(t)}isRequired(t){let e=this.getState().values;return this.requiredValuesRef!==e&&(this.requiredValuesRef=e),this.fieldMetadataProvider.isRequired(t,e)}isFieldDirty(t){return this.isPathDirty(t)}isFieldValidating(t){return!!this.getState().isValidating[t]}isTouched(t){return!!this.getState().touched[t]}}, _class11);function ne(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp)}function oe(s,t){let e=[],i=new Map,r=(n,o,a,c,u)=>{if(!(c&&u&&_chunkVOA3SKFYcjs.d.call(void 0, n,o))){if(n!==null&&typeof n=="object"&&o!==null&&typeof o=="object"){let l=i.get(n);if(_optionalChain([l, 'optionalAccess', _139 => _139.has, 'call', _140 => _140(o)]))return;l?l.add(o):i.set(n,new Set([o]))}try{if(ne(n)&&ne(o)&&c&&u){let l=new Set([...Object.keys(n),...Object.keys(o)]);for(let d of l){let p=a?`${a}.${d}`:d,h=Object.prototype.hasOwnProperty.call(n,d),g=Object.prototype.hasOwnProperty.call(o,d);r(n[d],o[d],p,h,g)}return}e.push({path:a,previousValue:_chunkVOA3SKFYcjs.a.call(void 0, n),nextValue:_chunkVOA3SKFYcjs.a.call(void 0, o),hadPreviousValue:c,hasNextValue:u})}finally{if(n!==null&&typeof n=="object"&&o!==null&&typeof o=="object"){let l=i.get(n);_optionalChain([l, 'optionalAccess', _141 => _141.delete, 'call', _142 => _142(o)]),l&&l.size===0&&i.delete(n)}}}};return r(s,t,"",!0,!0),{operations:e}}function ct(s,t,e){let i=s,r=[],n=[];for(let o of t.operations){let a=e==="undo"?o.hadPreviousValue:o.hasNextValue,c=e==="undo"?o.previousValue:o.nextValue;if(!o.path){i=a?c:{},r.length=0,n.length=0;continue}if(a){r.push([o.path,c]);continue}n.push(o.path)}return r.length>0&&(i=_chunkVOA3SKFYcjs.h.call(void 0, i,r)),n.length>0&&(i=_chunkVOA3SKFYcjs.i.call(void 0, i,n)),i}var dt= (_class12 =class{constructor(t,e){;_class12.prototype.__init42.call(this);_class12.prototype.__init43.call(this);_class12.prototype.__init44.call(this);_class12.prototype.__init45.call(this);_class12.prototype.__init46.call(this);this.enableHistory=t;this.maxHistory=e}__init42() {this.baseSnapshot=null}__init43() {this.currentSnapshot=null}__init44() {this.patches=[]}__init45() {this.historyIndex=-1}__init46() {this.historySize=0}saveSnapshot(t){if(!this.enableHistory)return;if(!this.currentSnapshot||this.baseSnapshot===null){this.reset(t);return}let e=oe(this.currentSnapshot,t);if(e.operations.length!==0)for(this.historyIndex<this.historySize-1&&(this.patches.splice(this.historyIndex),this.historySize=this.historyIndex+1),this.patches.push(e),this.currentSnapshot=t,this.historyIndex+=1,this.historySize=this.historyIndex+1;this.historySize>this.getCapacity();)this.compactOldestSnapshot()}get canUndo(){return this.enableHistory?this.historyIndex>0:!1}get canRedo(){return this.enableHistory?this.historyIndex<this.historySize-1:!1}undo(){if(!this.canUndo||!this.currentSnapshot)return null;let t=this.patches[this.historyIndex-1],e=ct(this.currentSnapshot,t,"undo");return this.currentSnapshot=e,this.historyIndex-=1,e}redo(){if(!this.canRedo||!this.currentSnapshot)return null;let t=this.patches[this.historyIndex],e=ct(this.currentSnapshot,t,"redo");return this.currentSnapshot=e,this.historyIndex+=1,e}reset(t){if(!this.enableHistory){this.baseSnapshot=null,this.currentSnapshot=null,this.patches=[],this.historyIndex=-1,this.historySize=0;return}this.baseSnapshot=_chunkVOA3SKFYcjs.a.call(void 0, t),this.currentSnapshot=this.baseSnapshot,this.patches=[],this.historyIndex=0,this.historySize=1}getMetadata(){return{enabled:this.enableHistory,canUndo:this.canUndo,canRedo:this.canRedo,historyIndex:this.historyIndex,historySize:this.historySize}}compactOldestSnapshot(){let t=this.patches.shift();!t||this.baseSnapshot===null||(this.baseSnapshot=ct(this.baseSnapshot,t,"redo"),this.historySize=Math.max(1,this.historySize-1),this.historyIndex=Math.max(0,this.historyIndex-1))}getCapacity(){return Math.max(1,this.maxHistory)}}, _class12);function Dt(s,t,e){if(!Object.prototype.hasOwnProperty.call(s,t))return[s,e];let r=s,n=e;return n||(r={...s},n=!0),delete r[t],[r,n]}var D=class{constructor(t){this.steps=t}async run(t){for(let e of this.steps){if(t.halted)break;await e.run(t)}}},ut=class{constructor(t){this.steps=t}run(t){for(let e of this.steps){if(t.halted)break;let i=e.run(t);if(i!=null&&typeof i.then=="function")throw new Error(`BitSyncPipelineRunner: step "${e.name}" returned a Promise. Use BitPipelineRunner for async steps.`)}}};var pt=class{constructor(t){this.store=t;this.fieldUpdatePipeline=new ut([{name:"field:clear-current-error",run:e=>this.clearCurrentError(e)},{name:"field:update-dependencies",run:e=>this.updateDependencies(e)},{name:"field:update-dirty",run:e=>this.updateDirtyState(e)},{name:"field:commit-state",run:e=>this.commitFieldState(e)},{name:"field:emit-change",run:e=>this.emitFieldChange(e)},{name:"field:trigger-validate",run:e=>this.triggerResolverValidation(e)},{name:"field:trigger-async-validate",run:e=>this.triggerAsyncValidation(e)}])}updateField(t,e,i={origin:"setField"}){let r=this.store.getState(),n=_chunkVOA3SKFYcjs.f.call(void 0, r.values,t),o={path:t,value:e,meta:i,previousValue:n,nextValues:_chunkVOA3SKFYcjs.g.call(void 0, r.values,t,e),nextErrors:r.errors,hasMutatedErrors:!1,dependencyDiff:{affectedFields:[],visibilityChanged:[],requiredChanged:[]},isDirty:!1};this.fieldUpdatePipeline.run(o)}clearCurrentError(t){[t.nextErrors,t.hasMutatedErrors]=Dt(t.nextErrors,t.path,t.hasMutatedErrors),this.store.clearFieldValidation(t.path)}updateDependencies(t){if(typeof this.store.hasDependentFields=="function"&&!this.store.hasDependentFields(t.path)){t.dependencyDiff.affectedFields.length=0,t.dependencyDiff.visibilityChanged.length=0,t.dependencyDiff.requiredChanged.length=0;return}t.dependencyDiff=this.store.updateDependencies(t.path,this.store.getState().values,t.nextValues),new Set([...t.dependencyDiff.visibilityChanged,...t.dependencyDiff.requiredChanged]).forEach(i=>{[t.nextErrors,t.hasMutatedErrors]=Dt(t.nextErrors,i,t.hasMutatedErrors),this.store.clearFieldValidation(i)})}updateDirtyState(t){t.isDirty=this.store.updateDirtyForPath(t.path,t.nextValues,this.store.getBaselineValues())}commitFieldState(t){let e=Array.from(new Set([t.path,...t.dependencyDiff.visibilityChanged,...t.dependencyDiff.requiredChanged]));this.store.dispatch(S({values:t.nextValues,errors:t.nextErrors,isDirty:t.isDirty},e))}emitFieldChange(t){this.store.emitFieldChange({path:t.path,previousValue:t.previousValue,nextValue:t.value,values:this.store.getState().values,state:this.store.getState(),meta:t.meta})}triggerResolverValidation(t){let e=Array.from(new Set([t.path,...t.dependencyDiff.visibilityChanged,...t.dependencyDiff.requiredChanged]));(this.store.config.resolver||t.dependencyDiff.visibilityChanged.length>0||t.dependencyDiff.requiredChanged.length>0)&&this.store.triggerValidation(e)}triggerAsyncValidation(t){this.store.isFieldHidden(t.path)||(typeof this.store.getFieldConfig=="function"?_optionalChain([this, 'access', _143 => _143.store, 'access', _144 => _144.getFieldConfig, 'call', _145 => _145(t.path), 'optionalAccess', _146 => _146.validation, 'optionalAccess', _147 => _147.asyncValidateOn]):void 0)!=="change"||this.store.handleFieldAsyncValidation(t.path,t.value)}};var ht= (_class13 =class{constructor() { _class13.prototype.__init47.call(this); }__init47() {this.executors=new Map}register(t,e){let i=_nullishCoalesce(this.executors.get(t), () => ([]));i.push(e),this.executors.set(t,i)}async execute(t){let e=this.getOrderedExecutors(t.kind);for(let i of e)await i.execute(t)}executeSync(t){let e=this.getOrderedExecutors(t.kind);for(let i of e){let r=i.execute(t);if(r&&typeof r.then=="function")throw new Error(`BitLifecycleOrchestrator: executor async em modo sync para kind "${t.kind}".`)}}getOrderedExecutors(t){return[..._nullishCoalesce(this.executors.get(t), () => ([]))].sort((i,r)=>i.phase-r.phase)}}, _class13);var ft=class{constructor(t){this.store=t;this.submitPipeline=new D([{name:"submit:start",run:async e=>this.startSubmit(e)},{name:"submit:invalid",run:async e=>this.handleInvalidSubmit(e)},{name:"submit:prepare",run:e=>this.prepareSubmitValues(e)},{name:"submit:before-hooks",run:async e=>this.runBeforeSubmitHooks(e)},{name:"submit:user-handler",run:async e=>this.runSubmitHandler(e)},{name:"submit:after-hooks",run:async e=>this.runAfterSubmitHooks(e)}])}async submit(t){if(this.store.getState().isSubmitting)return{status:"blocked",reason:"isSubmitting"};if(this.store.hasValidationsInProgress())return{status:"blocked",reason:"validating"};this.store.cancelAllValidations();let i={onSuccess:t,isValid:!1,valuesToSubmit:_chunkVOA3SKFYcjs.a.call(void 0, this.store.getState().values),dirtyValues:{}};try{return await this.submitPipeline.run(i),i.invalid?{status:"invalid"}:{status:"submitted"}}catch(r){return i.error=r,await this.store.emitOperationalError({source:"submit",error:r}),await this.store.emitAfterSubmit({values:i.valuesToSubmit,dirtyValues:i.dirtyValues,state:this.store.getState(),success:!1,error:r}),this.store.config.onUnhandledError(r,"submit"),{status:"failed",error:r}}finally{this.store.dispatch(S({isSubmitting:!1}))}}async startSubmit(t){this.store.dispatch(S({isSubmitting:!0})),t.isValid=await this.store.validateNow()}async handleInvalidSubmit(t){if(t.isValid)return;let e=this.store.getState().errors,i={...this.store.getState().touched};Object.keys(e).forEach(r=>{i[r]=!0}),this.store.batchStateUpdates(()=>{this.store.dispatch(S({touched:i}))}),t.dirtyValues=this.store.buildDirtyValues(this.store.getState().values),t.invalid=!0,await this.store.emitAfterSubmit({values:this.store.getState().values,dirtyValues:t.dirtyValues,state:this.store.getState(),success:!1,invalid:!0}),t.halted=!0}prepareSubmitValues(t){let e=[],i=this.store.getHiddenFields();i.forEach(r=>{e.push([r,void 0])}),e.length>0&&(t.valuesToSubmit=_chunkVOA3SKFYcjs.h.call(void 0, t.valuesToSubmit,e)),t.valuesToSubmit=Yt({values:t.valuesToSubmit,sourceValues:t.valuesToSubmit,transformEntries:this.store.getTransformEntries().filter(([r])=>!i.has(r)),onError:r=>{throw r}}),t.dirtyValues=this.store.buildDirtyValues(t.valuesToSubmit)}async runBeforeSubmitHooks(t){await this.store.emitBeforeSubmit({values:t.valuesToSubmit,dirtyValues:t.dirtyValues,state:this.store.getState()})}async runSubmitHandler(t){try{await t.onSuccess(t.valuesToSubmit,t.dirtyValues)}catch(e){if(_chunkVOA3SKFYcjs.m.call(void 0, e)){this.store.setServerErrors(_chunkVOA3SKFYcjs.n.call(void 0, e)),await this.store.emitAfterSubmit({values:t.valuesToSubmit,dirtyValues:t.dirtyValues,state:this.store.getState(),success:!1,invalid:!0}),t.invalid=!0,t.halted=!0;return}throw e}}async runAfterSubmitHooks(t){await this.store.emitAfterSubmit({values:t.valuesToSubmit,dirtyValues:t.dirtyValues,state:this.store.getState(),success:!0})}};var gt=class{constructor(t){this.store=t}collectChangedUpdates(t,e="",i=[],r=new WeakSet){if(t&&typeof t=="object"){if(r.has(t))return i;r.add(t)}try{Object.entries(t).forEach(([n,o])=>{let a=e?`${e}.${n}`:n;if(o&&typeof o=="object"&&!Array.isArray(o)&&Object.keys(o).length>0){if(r.has(o))return;this.collectChangedUpdates(o,a,i,r);return}i.push([a,o])})}finally{t&&typeof t=="object"&&r.delete(t)}return i}setValues(t,e){if(_optionalChain([e, 'optionalAccess', _148 => _148.rebase])){this.rebaseValues(t);return}if(_optionalChain([e, 'optionalAccess', _149 => _149.partial])){this.hydrateValues(t);return}this.replaceValuesInternal(t,"replaceValues")}hydrateValues(t){let e=this.collectChangedUpdates(t),i=e.map(([n])=>n),r=e.length>0?_chunkVOA3SKFYcjs.h.call(void 0, this.store.getState().values,e):this.store.getState().values;this.replaceValuesInternal(r,"hydrate",i.length>0?i:["*"])}rebaseValues(t){let e=this.store.getState().values,i=_chunkVOA3SKFYcjs.a.call(void 0, t);this.store.setBaselineValues(t),this.store.cancelAllValidations(),this.store.evaluateAllDependencies(i),this.store.clearDirtyState(),this.store.dispatch(S({values:i,errors:{},touched:{},isValidating:{},isValid:!1,isDirty:!1},["*"])),this.store.resetHistory(i),this.store.validateNow().catch(r=>{_optionalChain([this, 'access', _150 => _150.store, 'access', _151 => _151.config, 'optionalAccess', _152 => _152.onUnhandledError, 'call', _153 => _153(r,"rebaseValues")])}),this.store.emitFieldChange({path:"*",previousValue:e,nextValue:i,values:this.store.getState().values,state:this.store.getState(),meta:{origin:"rebase"}})}applyHistoryState(t){this.store.cancelAllValidations();let e=this.store.rebuildDirtyState(t,this.store.getBaselineValues());this.store.dispatch(S({values:t,errors:{},isValid:!1,isDirty:e},["*"])),this.store.validateNow().catch(i=>{_optionalChain([this, 'access', _154 => _154.store, 'access', _155 => _155.config, 'optionalAccess', _156 => _156.onUnhandledError, 'call', _157 => _157(i,"applyHistoryState")])})}reset(){this.store.cancelAllValidations();let t=_chunkVOA3SKFYcjs.a.call(void 0, this.store.getBaselineValues());this.store.evaluateAllDependencies(t),this.store.clearDirtyState(),this.store.dispatch(S({values:t,errors:{},touched:{},isValidating:{},isValid:!0,isDirty:!1},["*"])),this.store.resetHistory(t)}replaceValuesInternal(t,e="replaceValues",i=["*"]){let r=this.store.getState().values,n=_chunkVOA3SKFYcjs.a.call(void 0, t);this.store.cancelAllValidations(),this.store.evaluateAllDependencies(n);let o=this.store.rebuildDirtyState(n,this.store.getBaselineValues());this.store.dispatch(S({values:n,errors:{},isValidating:{},isValid:!1,isDirty:o},i)),this.store.internalSaveSnapshot(),this.store.validateNow().catch(a=>{_optionalChain([this, 'access', _158 => _158.store, 'access', _159 => _159.config, 'optionalAccess', _160 => _160.onUnhandledError, 'call', _161 => _161(a,"replaceValuesInternal")])}),this.store.emitFieldChange({path:"*",previousValue:r,nextValue:n,values:this.store.getState().values,state:this.store.getState(),meta:{origin:e}})}};var mt= (_class14 =class{constructor(t){;_class14.prototype.__init48.call(this);this.ports=t;this.fieldUpdate=new pt(t.fieldUpdate),this.values=new gt(t.values),this.submitFlow=new ft(t.submit),this.orchestrator.register("updateField",{phase:1,execute:e=>this.fieldUpdate.updateField(e.path,e.value,_nullishCoalesce(e.meta, () => ({origin:"setField"})))}),this.orchestrator.register("setValues",{phase:2,execute:e=>this.values.setValues(e.newValues,e.options)}),this.orchestrator.register("hydrateValues",{phase:2,execute:e=>this.values.hydrateValues(e.newValues)}),this.orchestrator.register("rebaseValues",{phase:2,execute:e=>this.values.rebaseValues(e.newValues)}),this.orchestrator.register("applyHistoryState",{phase:2,execute:e=>this.values.applyHistoryState(e.snapshot)}),this.orchestrator.register("submit",{phase:3,execute:async e=>{e.submitResult=await this.submitFlow.submit(e.onSuccess)}}),this.orchestrator.register("reset",{phase:4,execute:()=>this.values.reset()})}__init48() {this.orchestrator=new ht}updateField(t,e,i={origin:"setField"}){this.orchestrator.executeSync({kind:"updateField",path:t,value:e,meta:i})}setValues(t,e){this.orchestrator.executeSync({kind:"setValues",newValues:t,options:e})}hydrateValues(t){this.orchestrator.executeSync({kind:"hydrateValues",newValues:t})}rebaseValues(t){this.orchestrator.executeSync({kind:"rebaseValues",newValues:t})}applyHistoryState(t){this.orchestrator.executeSync({kind:"applyHistoryState",snapshot:t})}async submit(t){let e={kind:"submit",onSuccess:t};return await this.orchestrator.execute(e),e.submitResult}reset(){this.orchestrator.executeSync({kind:"reset"})}}, _class14);var yt=class{constructor(t,e,i,r){this.getState=t;this.getInitialValues=e;this.getScopeFields=i;this.isPathDirty=r}getScopeStatus(t){let e=this.getScopeFields(t),i=this.getState(),r=e.some(a=>!!i.errors[a]),n=e.some(a=>this.isPathDirty(a)),o=this.getScopeErrors(t);return{hasErrors:r,isDirty:n,errors:o}}getScopeErrors(t){let e=this.getScopeFields(t),i=this.getState(),r={};for(let n of e){let o=i.errors[n];o&&(r[n]=o)}return r}};var ae=Symbol("bit.async.validation.timeout"),St= (_class15 =class{constructor(t){;_class15.prototype.__init49.call(this);_class15.prototype.__init50.call(this);this.port=t}__init49() {this.abortControllers=new Map}__init50() {this.pendingJobs=new Map}handle(t,e,i,r,n){if(!i){this.cancel(t),this.port.setFieldValidating(t,!1);return}this.cancel(t),this.port.clearAsyncError(t),this.port.setFieldValidating(t,!0);let o=new AbortController;this.abortControllers.set(t,o),this.pendingJobs.set(t,{value:e,dueAt:Date.now()+r,validate:i,controller:o,timeoutMs:n}),this.schedulePendingJobs()}cancel(t){this.cancelInternal(t,!0)}cancelInternal(t,e){this.pendingJobs.has(t)&&(this.pendingJobs.delete(t),e&&this.schedulePendingJobs());let i=this.abortControllers.get(t);i&&(i.abort(),this.abortControllers.delete(t))}cleanupPrefix(t){let e=!1,i=new Set([...this.pendingJobs.keys(),...this.abortControllers.keys()]);for(let r of i)x(r,t)&&(this.cancelInternal(r,!1),e=!0,this.port.clearAsyncError(r),this.port.setFieldValidating(r,!1));e&&this.schedulePendingJobs()}remapPaths(t){let e=!1,i=new Map;for(let[n,o]of this.pendingJobs.entries()){let a=t(n);if(!a){o.controller.abort(),e=!0;continue}a!==n&&(e=!0),i.set(a,o)}let r=new Map;for(let[n,o]of this.abortControllers.entries()){let a=t(n);if(!a){o.abort();continue}r.set(a,o)}this.pendingJobs.clear(),i.forEach((n,o)=>{this.pendingJobs.set(o,n)}),this.abortControllers.clear(),r.forEach((n,o)=>{this.abortControllers.set(o,n)}),e&&this.schedulePendingJobs()}cancelAll(){if(this.cancelSchedulerTimeout)try{this.cancelSchedulerTimeout()}catch (e4){}finally{this.cancelSchedulerTimeout=void 0}this.abortControllers.forEach(t=>{try{t.abort()}catch (e5){}}),this.pendingJobs.clear(),this.abortControllers.clear()}schedulePendingJobs(){this.cancelSchedulerTimeout&&(this.cancelSchedulerTimeout(),this.cancelSchedulerTimeout=void 0);let t=Number.POSITIVE_INFINITY;for(let e of this.pendingJobs.values())e.dueAt<t&&(t=e.dueAt);Number.isFinite(t)&&(this.cancelSchedulerTimeout=this.port.schedule(()=>{this.cancelSchedulerTimeout=void 0,this.flushPendingJobs().catch(e=>{this.port.onError(e)})},Math.max(0,t-Date.now())))}async flushPendingJobs(){this.cancelSchedulerTimeout=void 0;let t=Date.now(),e=[];for(let[r,n]of this.pendingJobs.entries())n.dueAt<=t&&e.push([r,n]);if(e.length===0){this.schedulePendingJobs();return}e.forEach(([r])=>{this.pendingJobs.delete(r)});let i=await Promise.allSettled(e.map(([r,n])=>this.runJob(r,n)));for(let r of i)r.status==="rejected"&&this.port.onError(r.reason);this.schedulePendingJobs()}async runJob(t,e){if(!e.controller.signal.aborted)try{let i=e.validate(e.value,this.port.getValues());if(typeof e.timeoutMs=="number"&&e.timeoutMs>0){let o;i=Promise.race([i,new Promise(a=>{o=setTimeout(()=>a(ae),e.timeoutMs)})]).finally(()=>{o&&clearTimeout(o)})}let r=await i;if(e.controller.signal.aborted)return;let n=_chunkVOA3SKFYcjs.f.call(void 0, this.port.getValues(),t);if(!_chunkVOA3SKFYcjs.c.call(void 0, n,e.value)||r===ae)return;r!=null?this.port.setAsyncError(t,r):(this.port.clearAsyncError(t),await this.port.onValidationPassed(t))}finally{let i=_nullishCoalesce(this.findControllerPath(e.controller), () => (t));e.controller.signal.aborted||this.port.setFieldValidating(i,!1),this.abortControllers.get(i)===e.controller&&this.abortControllers.delete(i)}}findControllerPath(t){for(let[e,i]of this.abortControllers.entries())if(i===t)return e}}, _class15);function k(s){for(let t in s)if(s[t]!==void 0)return!0;return!1}async function kt(s){let{scopeFields:t,store:e,asyncErrors:i}=s,r=e.getState(),n=e.config.resolver?await e.config.resolver(r.values,{scopeFields:t}):{},o=e.getState();if(t.some(d=>r.values[d]!==o.values[d]))return;let c=e.getRequiredErrors(o.values),u={...n,...c};e.getHiddenFields().forEach(d=>{delete u[d],i.delete(d)});let l={...o.errors};t.forEach(d=>{u[d]?l[d]=u[d]:i.has(d)?l[d]=i.get(d):delete l[d]}),e.dispatch(it(l,!k(l)))}var bt= (_class16 =class{constructor() { _class16.prototype.__init51.call(this);_class16.prototype.__init52.call(this); }__init51() {this.currentValidationId=0}__init52() {this.immediateAbortControllers=new Map}beginValidation(){return this.currentValidationId+=1,this.currentValidationId}getCurrentValidationId(){return this.currentValidationId}isValidationCurrent(t){return t===this.currentValidationId}setImmediateController(t,e){this.immediateAbortControllers.set(t,e)}clearImmediateController(t,e){return this.immediateAbortControllers.get(t)===e?(this.immediateAbortControllers.delete(t),!0):!1}cancelImmediate(t){let e=this.immediateAbortControllers.get(t);e&&(e.abort(),this.immediateAbortControllers.delete(t))}cancelImmediatePrefix(t,e){for(let i of this.immediateAbortControllers.keys())x(i,t)&&(this.cancelImmediate(i),e(i))}remapImmediateControllers(t){let e=new Map;for(let[i,r]of this.immediateAbortControllers.entries()){let n=t(i);if(!n){r.abort();continue}e.set(n,r)}this.immediateAbortControllers.clear(),e.forEach((i,r)=>{this.immediateAbortControllers.set(r,i)})}cancelAllImmediate(){this.immediateAbortControllers.forEach(t=>{t.abort()}),this.immediateAbortControllers.clear()}}, _class16);var Bt= (_class17 =class{constructor(t){;_class17.prototype.__init53.call(this);this.port=t}__init53() {this.pendingScopeFields=null}trigger(t,e){this.cancelTimeout&&(this.cancelTimeout(),this.cancelTimeout=void 0);let i=_nullishCoalesce(this.port.validationDelay, () => (300)),r=_optionalChain([e, 'optionalAccess', _162 => _162.forceDebounce])?Math.max(1,i):i;if(r>0){if(t&&t.length>0)if(!this.pendingScopeFields)this.pendingScopeFields=new Set(t);else for(let o of t)this.pendingScopeFields.add(o);else this.pendingScopeFields=null;let n=this.pendingScopeFields?Array.from(this.pendingScopeFields):void 0;this.cancelTimeout=this.port.schedule(()=>{this.pendingScopeFields=null,this.cancelTimeout=void 0,this.validateWithOptionalScopeFields(n)},r)}else this.pendingScopeFields=null,this.validateWithOptionalScopeFields(t)}validateWithOptionalScopeFields(t){return t&&t.length>0?this.port.validate({scopeFields:t}):this.port.validate()}cancelPending(){this.cancelTimeout&&(this.cancelTimeout(),this.cancelTimeout=void 0),this.pendingScopeFields=null}}, _class17);var le=Symbol("bit.async.validation.timeout");function ce(s){let{targetFields:t,currentErrors:e,allErrors:i,asyncErrors:r}=s;if(t&&t.length>0){let o=e,a=!1,c=()=>(a||(o={...e},a=!0),o);t.forEach(l=>{let d=l,p=e[d];if(i[l]!==void 0)p!==i[l]&&(c()[d]=i[l]);else if(r.has(l)){let h=r.get(l);p!==h&&(c()[d]=h)}else p!==void 0&&delete c()[d]});let u=t.every(l=>i[l]===void 0&&!r.has(l));return{committedErrors:a?o:e,result:u,mode:"scoped"}}let n={};return r.forEach((o,a)=>{n[a]=o}),Object.entries(i).forEach(([o,a])=>{a!==void 0&&(n[o]=a)}),{committedErrors:n,result:void 0,mode:"global"}}function de(s){let{targetFields:t,hiddenFields:e,getFieldConfig:i,forEachFieldConfig:r}=s,n=[];if(t&&t.length>0){for(let o of t){if(e.has(o))continue;_optionalChain([i, 'call', _163 => _163(o), 'optionalAccess', _164 => _164.validation, 'optionalAccess', _165 => _165.asyncValidate])&&n.push(o)}return n}return r&&r((o,a)=>{!_optionalChain([o, 'access', _166 => _166.validation, 'optionalAccess', _167 => _167.asyncValidate])||e.has(a)||n.push(a)}),n}async function ue(s){let{path:t,values:e,validationId:i,getCurrentValidationId:r,getFieldConfig:n,cancelFieldAsync:o,createAbortController:a,setAbortController:c,clearAbortController:u,setFieldValidating:l,setAsyncError:d,clearAsyncError:p}=s,h=_optionalChain([n, 'call', _168 => _168(t), 'optionalAccess', _169 => _169.validation, 'optionalAccess', _170 => _170.asyncValidate]);if(!h){p(t);return}o(t),p(t);let g=a();c(t,g),l(t,!0);try{let v=_optionalChain([n, 'call', _171 => _171(t), 'optionalAccess', _172 => _172.validation, 'optionalAccess', _173 => _173.asyncValidateTimeout]),f=h(_chunkVOA3SKFYcjs.f.call(void 0, e,t),e);if(typeof v=="number"&&v>0){let T;f=Promise.race([f,new Promise(P=>{T=setTimeout(()=>P(le),v)})]).finally(()=>{T&&clearTimeout(T)})}let m=await f;if(g.signal.aborted||i!==r())return;m===le||(m!=null?d(t,m):p(t))}finally{u(t,g)&&l(t,!1)}}function pe(s){let{ctx:t,deps:e}=s,i=t.options;if(_optionalChain([i, 'optionalAccess', _174 => _174.scope])&&_optionalChain([i, 'access', _175 => _175.scopeFields, 'optionalAccess', _176 => _176.length])){e.store.config.onUnhandledError(new Error("validate received both 'scope' and 'scopeFields'. 'scopeFields' takes precedence."),"validation");return}if(!_optionalChain([t, 'access', _177 => _177.options, 'optionalAccess', _178 => _178.scopeFields, 'optionalAccess', _179 => _179.length])&&_optionalChain([t, 'access', _180 => _180.options, 'optionalAccess', _181 => _181.scope])){let r=e.store.getScopeFields(t.options.scope);r.length>0&&(t.targetFields=r)}}async function he(s){let{ctx:t,deps:e}=s;await e.store.emitBeforeValidate({values:t.currentState.values,state:t.currentState,scope:_optionalChain([t, 'access', _182 => _182.options, 'optionalAccess', _183 => _183.scope]),scopeFields:t.targetFields})}async function fe(s){let{ctx:t,deps:e}=s,i=e.store.config.resolver?await e.store.config.resolver(t.currentState.values,{scopeFields:t.targetFields}):{},r=e.store.getRequiredErrors(t.currentState.values);t.allErrors={...i,...r},e.store.getHiddenFields().forEach(n=>{delete t.allErrors[n],e.asyncErrors.delete(n)})}async function ge(s){let{ctx:t,deps:e}=s,i=de({targetFields:t.targetFields,hiddenFields:e.store.getHiddenFields(),getFieldConfig:n=>e.store.getFieldConfig(n),forEachFieldConfig:e.store.forEachFieldConfig});if(i.length===0)return;let r=await Promise.allSettled(i.map(n=>e.runImmediateAsyncValidation(n,t.currentState.values,t.validationId)));for(let n of r)n.status==="rejected"&&e.store.config.onUnhandledError(n.reason,"validation")}function me(s){let{ctx:t,deps:e}=s,i=ce({targetFields:t.targetFields,currentErrors:t.currentState.errors,allErrors:t.allErrors,asyncErrors:e.asyncErrors});t.committedErrors=i.committedErrors,t.isValid=!k(i.committedErrors),t.result=i.mode==="scoped"?i.result:t.isValid}async function Mt(s){let{ctx:t,deps:e}=s;t.validationId!==e.getCurrentValidationId()&&(t.aborted=!0,t.result=e.store.getState().isValid,t.halted=!0)}async function ye(s){let{ctx:t,deps:e}=s;e.store.dispatch(it(t.committedErrors,t.isValid)),await e.store.emitAfterValidate({values:e.store.getState().values,state:e.store.getState(),scope:_optionalChain([t, 'access', _184 => _184.options, 'optionalAccess', _185 => _185.scope]),scopeFields:t.targetFields,errors:t.committedErrors,result:t.result}),t.halted=!0}var vt=class{constructor(t){this.deps=t;this.runner=new D([{name:"validate:resolve-target-fields",run:e=>pe({ctx:e,deps:this.deps})},{name:"validate:before-hooks",run:async e=>he({ctx:e,deps:this.deps})},{name:"validate:sync-track",run:async e=>fe({ctx:e,deps:this.deps})},{name:"validate:abort-check-pre-async",run:async e=>Mt({ctx:e,deps:this.deps})},{name:"validate:async-track",run:async e=>ge({ctx:e,deps:this.deps})},{name:"validate:abort-check",run:async e=>Mt({ctx:e,deps:this.deps})},{name:"validate:async-track-merge",run:e=>me({ctx:e,deps:this.deps})},{name:"validate:commit",run:async e=>ye({ctx:e,deps:this.deps})}])}async run(t){await this.runner.run(t)}};var Tt= (_class18 =class{constructor(t){;_class18.prototype.__init54.call(this);_class18.prototype.__init55.call(this);_class18.prototype.__init56.call(this);this.store=t;this.schedule=_nullishCoalesce(_optionalChain([t, 'access', _186 => _186.config, 'access', _187 => _187.scheduler, 'optionalAccess', _188 => _188.schedule]), () => (((i,r)=>{let n=setTimeout(i,r);return()=>clearTimeout(n)}))),this.debouncer=new Bt({schedule:(i,r)=>this.schedule(i,r),validate:i=>this.validate(i),validationDelay:_nullishCoalesce(t.config.validationDelay, () => (300))}),this.pipelineStore={getState:()=>this.store.getState(),dispatch:i=>this.store.dispatch(i),config:this.store.config,getFieldConfig:i=>this.store.getFieldConfig(i),forEachFieldConfig:i=>this.store.forEachFieldConfig(i),getScopeFields:i=>this.store.getScopeFields(i),getRequiredErrors:i=>this.store.getRequiredErrors(i),getHiddenFields:()=>this.store.getHiddenFields(),emitBeforeValidate:i=>this.store.emitBeforeValidate(i),emitAfterValidate:i=>this.store.emitAfterValidate(i)},this.asyncScheduler=new St({schedule:(i,r)=>this.schedule(i,r),getValues:()=>this.store.getState().values,setFieldValidating:(i,r)=>this.updateFieldValidating(i,r),setAsyncError:(i,r)=>{this.asyncErrors.set(i,r),this.store.setError(i,r)},clearAsyncError:i=>{let r=this.asyncErrors.get(i);this.asyncErrors.delete(i),r&&!this.store.config.resolver&&this.store.getState().errors[i]===r&&this.store.setError(i,void 0),kt({scopeFields:[i],store:this.pipelineStore,asyncErrors:this.asyncErrors}).catch(n=>{this.store.config.onUnhandledError(n,"validation")})},onValidationPassed:async i=>{await kt({scopeFields:[i],store:this.pipelineStore,asyncErrors:this.asyncErrors})},onError:i=>{this.store.config.onUnhandledError(i,"validation")}});let e={store:this.pipelineStore,asyncErrors:this.asyncErrors,getCurrentValidationId:()=>this.coordinator.getCurrentValidationId(),runImmediateAsyncValidation:(i,r,n)=>this.runImmediateAsyncValidation(i,r,n)};this.validationPipeline=new vt(e)}__init54() {this.validatingCount=0}__init55() {this.asyncErrors=new Map}__init56() {this.coordinator=new bt}updateFieldValidating(t,e){let i=this.store.getState();if(!!i.isValidating[t]===e)return;let n={...i.isValidating};e?(n[t]=!0,this.validatingCount+=1):(delete n[t],this.validatingCount=Math.max(0,this.validatingCount-1)),this.store.dispatch(S({isValidating:n}))}cancelFieldAsync(t){this.asyncScheduler.cancel(t),this.coordinator.cancelImmediate(t)}cleanupField(t){this.cancelFieldAsync(t),this.asyncErrors.delete(t),this.updateFieldValidating(t,!1)}cleanupPrefix(t){this.asyncScheduler.cleanupPrefix(t),this.coordinator.cancelImmediatePrefix(t,e=>{this.asyncErrors.delete(e),this.updateFieldValidating(e,!1)})}remapArrayPaths(t,e){let i=`${t}.`;this.asyncScheduler.remapPaths(n=>_chunkVOA3SKFYcjs.l.call(void 0, n,i,e)),this.coordinator.remapImmediateControllers(n=>_chunkVOA3SKFYcjs.l.call(void 0, n,i,e));let r=new Map;this.asyncErrors.forEach((n,o)=>{let a=_chunkVOA3SKFYcjs.l.call(void 0, o,i,e);a!==null&&r.set(a,n)}),this.asyncErrors.clear(),r.forEach((n,o)=>{this.asyncErrors.set(o,n)})}beginExternalValidation(t){this.cancelFieldAsync(t),this.updateFieldValidating(t,!0)}endExternalValidation(t){this.updateFieldValidating(t,!1)}async setExternalError(t,e){if(e){this.asyncErrors.set(t,e),this.store.setError(t,e);return}this.cancelFieldAsync(t),this.asyncErrors.delete(t),this.store.setError(t,void 0),await this.validate({scopeFields:[t]})}handleAsync(t,e){let i=this.store.getFieldConfig(t),r=_optionalChain([i, 'optionalAccess', _189 => _189.validation, 'optionalAccess', _190 => _190.asyncValidate]),n=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _191 => _191.validation, 'optionalAccess', _192 => _192.asyncValidateOn]), () => ("blur"));if(!r||n!=="change"){this.cancelFieldAsync(t),this.updateFieldValidating(t,!1);return}let o=_nullishCoalesce(_optionalChain([i, 'access', _193 => _193.validation, 'optionalAccess', _194 => _194.asyncValidateDelay]), () => (500)),a=_optionalChain([i, 'access', _195 => _195.validation, 'optionalAccess', _196 => _196.asyncValidateTimeout]);this.asyncScheduler.handle(t,e,r,o,a)}hasValidationsInProgress(t){let e=this.store.getState();return t&&t.length>0?t.some(i=>!!e.isValidating[i]):Object.keys(e.isValidating).length>0}trigger(t,e){this.debouncer.trigger(t,e)}async validate(t){try{_optionalChain([t, 'optionalAccess', _197 => _197.scopeFields, 'optionalAccess', _198 => _198.length])&&t.scopeFields.forEach(i=>{this.cancelFieldAsync(i),this.updateFieldValidating(i,!1)});let e={options:t,validationId:this.coordinator.beginValidation(),currentState:this.store.getState(),targetFields:_optionalChain([t, 'optionalAccess', _199 => _199.scopeFields]),allErrors:{},committedErrors:{},isValid:!0,result:!0,aborted:!1};if(await this.validationPipeline.run(e),e.aborted){let i=this.store.getState();await this.store.emitAfterValidate({values:i.values,state:i,scope:_optionalChain([e, 'access', _200 => _200.options, 'optionalAccess', _201 => _201.scope]),scopeFields:e.targetFields,errors:i.errors,result:i.isValid,aborted:!0})}return e.result}catch(e){return this.store.config.onUnhandledError(e,"validation"),!1}}clear(t){this.cancelFieldAsync(t),this.updateFieldValidating(t,!1),this.asyncErrors.delete(t)}cancelAll(){this.validatingCount=0,this.debouncer.cancelPending(),this.asyncScheduler.cancelAll(),this.asyncErrors.clear(),this.coordinator.cancelAllImmediate(),this.store.dispatch(S({isValidating:{}}))}async runImmediateAsyncValidation(t,e,i){await ue({path:t,values:e,validationId:i,getCurrentValidationId:()=>this.coordinator.getCurrentValidationId(),getFieldConfig:r=>this.store.getFieldConfig(r),cancelFieldAsync:r=>this.cancelFieldAsync(r),createAbortController:()=>new AbortController,setAbortController:(r,n)=>{this.coordinator.setImmediateController(r,n)},clearAbortController:(r,n)=>this.coordinator.clearImmediateController(r,n),setFieldValidating:(r,n)=>this.updateFieldValidating(r,n),setAsyncError:(r,n)=>{this.asyncErrors.set(r,n)},clearAsyncError:r=>{this.asyncErrors.delete(r)}})}}, _class18);var Rt= (_class19 =class{constructor() { _class19.prototype.__init57.call(this); }__init57() {this.entries=new Map}register(t,e){this.entries.set(t,e)}resolve(t){let e=this.entries.get(t);if(!e)throw new Error(`BitStore capability "${String(t)}" n\xE3o foi registrada.`);return e}toCapabilities(){return{validation:this.resolve("validation"),lifecycle:this.resolve("lifecycle"),history:this.resolve("history"),arrays:this.resolve("arrays"),scope:this.resolve("scope"),query:this.resolve("query"),error:this.resolve("error")}}}, _class19);function Se(){return new Rt}function gi(s){let{registry:t,ports:e,fieldRegistry:i}=s;t.register("validation",new Tt(e.validationPort)),t.register("lifecycle",new mt(e.lifecyclePorts)),t.register("history",new dt(!!e.config.history.enabled,_nullishCoalesce(e.config.history.limit, () => (50)))),t.register("arrays",new ot(e.arrayPort)),t.register("scope",new yt(()=>e.getState(),()=>e.getBaselineValues(),r=>e.getScopeFields(r),r=>e.isPathDirty(r))),t.register("query",new lt(i,()=>e.getState(),r=>e.isPathDirty(r))),t.register("error",new at(()=>e.getState(),r=>e.dispatch(r),r=>e.config.onUnhandledError(r,"errors")))}function be(s){let{ports:t,fieldRegistry:e}=s,i=Se();return gi({registry:i,ports:t,fieldRegistry:e}),{registry:i,capabilities:i.toCapabilities()}}function Be(s){let{config:t,fieldRegistry:e,computedManager:i}=s,r=_chunkVOA3SKFYcjs.a.call(void 0, t.initialValues);t.fields&&Object.entries(t.fields).forEach(([a,c])=>{e.register(a,c,r)});let n=rt(e.getComputedEntries());if(n.length>0)throw new Error(n[0].message);return{values:J({values:r,normalizerEntries:e.getNormalizerEntries(),applyComputed:(a,c)=>i.apply(a,c),onError:(a,c)=>{t.onUnhandledError(a,"derivation")}}),errors:{},touched:{},isValidating:{},persist:{isSaving:!1,isRestoring:!1,error:null},isValid:!0,isSubmitting:!1,isDirty:!1}}function ve(s){return{getState:s.getState,dispatch:s.dispatch,setError:s.setError,getFieldConfig:s.getFieldConfig,forEachFieldConfig:t=>s.fieldRegistry.forEachFieldConfig((e,i)=>t(e,i)),getScopeFields:s.getScopeFields,config:s.config,getRequiredErrors:t=>s.fieldRegistry.getRequiredErrors(t),getHiddenFields:()=>s.fieldRegistry.getHiddenFields(),emitBeforeValidate:t=>s.getEffects().beforeValidate(t),emitAfterValidate:t=>s.getEffects().afterValidate(t)}}function Te(s){let t={getState:s.getState,dispatch:s.dispatch,config:s.config,getFieldConfig:r=>s.fieldRegistry.getFieldConfig(r),updateDependencies:(r,n,o)=>s.fieldRegistry.updateDependencies(r,n,o),hasDependentFields:r=>s.fieldRegistry.hasDependents(r),isFieldHidden:r=>s.fieldRegistry.isHidden(r),clearFieldValidation:r=>s.getValidation().clear(r),triggerValidation:(r,n)=>s.getValidation().trigger(r,n),handleFieldAsyncValidation:(r,n)=>s.getValidation().handleAsync(r,n),updateDirtyForPath:(r,n,o)=>s.dirtyManager.updateForPath(r,n,o),getBaselineValues:s.getBaselineValues,emitFieldChange:r=>s.getEffects().onFieldChange(r)},e={getState:s.getState,dispatch:s.dispatch,config:s.config,internalSaveSnapshot:s.saveHistorySnapshot,evaluateAllDependencies:r=>s.fieldRegistry.evaluateAll(r),cancelAllValidations:()=>s.getValidation().cancelAll(),validateNow:r=>s.getValidation().validate(r),rebuildDirtyState:(r,n)=>s.dirtyManager.rebuild(r,n),clearDirtyState:s.dirtyManager.clear.bind(s.dirtyManager),getBaselineValues:s.getBaselineValues,setBaselineValues:s.setBaselineValues,resetHistory:r=>s.getHistory().reset(r),emitFieldChange:r=>s.getEffects().onFieldChange(r),triggerValidation:(r,n)=>s.getValidation().trigger(r,n)},i={getState:s.getState,dispatch:s.dispatch,batchStateUpdates:s.runStateBatch,config:s.config,getTransformEntries:s.getTransformEntries,getHiddenFields:()=>s.fieldRegistry.getHiddenFields(),cancelAllValidations:()=>s.getValidation().cancelAll(),validateNow:r=>s.getValidation().validate(r),hasValidationsInProgress:r=>s.getValidation().hasValidationsInProgress(r),buildDirtyValues:r=>s.dirtyManager.buildDirtyValues(r),setServerErrors:(r,n)=>s.setServerErrors(r,n),emitBeforeSubmit:r=>s.getEffects().beforeSubmit(r),emitAfterSubmit:r=>s.getEffects().afterSubmit(r),emitOperationalError:r=>s.getEffects().reportOperationalError(r)};return{fieldUpdate:t,values:e,submit:i}}function Pe(s){return{getState:s.getState,setFieldWithMeta:s.setFieldWithMeta,dispatch:s.dispatch,internalSaveSnapshot:s.saveHistorySnapshot,unregisterPrefix:s.unregisterPrefix,remapValidationPaths:s.remapValidationPaths,createArrayItemId:s.createArrayItemId}}function Ee(s){let{config:t,fieldRegistry:e,dirtyManager:i,baselineManager:r,runtimeContext:n}=s,{stateAccess:o,fieldAccess:a,featureAccess:c,actions:u}=n,l=ve({config:t,fieldRegistry:e,getState:o.getState,dispatch:o.dispatch,setError:u.setError,getFieldConfig:a.getFieldConfig,getScopeFields:a.getScopeFields,getEffects:c.getEffects}),d=Te({config:t,fieldRegistry:e,dirtyManager:i,getState:o.getState,dispatch:o.dispatch,setServerErrors:u.setServerErrors,saveHistorySnapshot:o.saveHistorySnapshot,runStateBatch:o.runStateBatch,getTransformEntries:a.getTransformEntries,getBaselineValues:()=>r.getValues(),setBaselineValues:h=>r.setValues(h),getValidation:c.getValidation,getHistory:c.getHistory,getEffects:c.getEffects}),p=Pe({getState:o.getState,dispatch:o.dispatch,setFieldWithMeta:(h,g,v)=>u.setFieldWithMeta(h,g,v),unregisterPrefix:u.unregisterPrefix,remapValidationPaths:(h,g)=>c.getValidation().remapArrayPaths(h,g),saveHistorySnapshot:o.saveHistorySnapshot,createArrayItemId:(h,g)=>t.idFactory({scope:"array",path:h,index:g})});return be({ports:{validationPort:l,lifecyclePorts:d,arrayPort:p,config:t,getScopeFields:a.getScopeFields,getState:o.getState,dispatch:o.dispatch,getBaselineValues:()=>r.getValues(),isPathDirty:h=>i.isPathDirty(h)},fieldRegistry:e})}function xe(s){let{config:t,fieldRegistry:e,dirtyManager:i,computedManager:r,rawConfig:n,baselineManager:o,runtimeContext:a}=s,{stateAccess:c,fieldAccess:u,featureAccess:l,actions:d}=a,p=Ee({config:t,fieldRegistry:e,dirtyManager:i,baselineManager:o,runtimeContext:{stateAccess:c,fieldAccess:u,featureAccess:l,actions:d}}),h=Be({config:t,fieldRegistry:e,computedManager:r}),g=new nt(c.getState,t.subscriptionCacheSize),v=n.storeId||t.name||t.idFactory({scope:"store",storeName:t.name});return{state:h,subscriptions:g,capabilityRegistry:p.registry,storeId:v}}function Ce(){return{depth:0,pendingState:null,changedPathSet:null,changedPathList:null,valuesChanged:!1,pendingHistorySnapshot:!1}}function Ve(s){s.depth+=1}function Fe(s){return s.depth-=1,s.depth===0}function Pt(s,t){return _nullishCoalesce(t.pendingState, () => (s))}function we(s,t){if(s.pendingState=t.nextState,s.valuesChanged||=t.valuesChanged,t.valuesChanged&&(s.pendingHistorySnapshot=!0),t.changedPaths&&t.changedPaths.length>0){let e=_nullishCoalesce(s.changedPathSet, () => (new Set)),i=_nullishCoalesce(s.changedPathList, () => ([]));t.changedPaths.forEach(r=>{if(e.has("*")||e.has(r))return;if(r==="*"){e.clear(),i.length=0,e.add("*"),i.push("*");return}if(!i.some(o=>o!=="*"&&r.startsWith(`${o}.`))){for(let o=i.length-1;o>=0;o-=1){let a=i[o];a==="*"||!a.startsWith(`${r}.`)||(e.delete(a),i.splice(o,1))}e.add(r),i.push(r)}}),s.changedPathSet=e,s.changedPathList=i}}function Ae(s){let{currentState:t,batchState:e,applyValueDerivations:i}=s;if(!e.pendingState)return e.pendingHistorySnapshot=!1,null;let r=e.pendingState,n=_nullishCoalesce(e.changedPathList, () => (void 0)),o=e.valuesChanged;return o&&(r={...r,values:i(r.values,n)}),e.pendingState=null,e.changedPathSet=null,e.changedPathList=null,e.valuesChanged=!1,{nextState:_nullishCoalesce(r, () => (t)),changedPaths:n,valuesChanged:o}}function mi(s){let t=!1;for(let i of Object.values(s))if(i===void 0){t=!0;break}if(!t)return s;let e={};return Object.entries(s).forEach(([i,r])=>{let n=r;n!==void 0&&(e[i]=n)}),e}function Ot(s){let{currentState:t,partialState:e,changedPaths:i,applyValueDerivations:r,applyComputedValues:n}=s,o=_nullishCoalesce(r, () => ((p=>n?n(p):p))),a={...t,...e},c=!!e.values;if(e.values&&(a.values=o(e.values,i)),e.errors){a.errors=mi(e.errors);let p=!k(a.errors);a.isValid="isValid"in e?!!e.isValid:p}let u=i&&i.length>0?i:void 0,l=yi(e),d=$(u,l);return{nextState:a,changedPaths:d,valuesChanged:c}}function yi(s){let t=new Set,e=[s.errors,s.touched,s.isValidating];for(let i of e)if(i)for(let r in i)t.add(r);return s.persist&&t.add("persist"),"isValid"in s&&t.add("isValid"),"isDirty"in s&&t.add("isDirty"),"isSubmitting"in s&&t.add("isSubmitting"),t.size>0?Array.from(t):void 0}function Si(s){throw new Error(`BitStore: unsupported operation kind: ${String(s.kind)}`)}function bi(s,t){switch(t.kind){case"state.patch":return t;case"field.touchMany":{if(t.paths.length===0)return null;let e={...s.touched};for(let i of t.paths)e[i]=!0;return S({touched:e},t.paths)}case"form.persistMeta":return S({persist:{...s.persist,...t.patch}});case"history.apply":return S({values:t.values,isDirty:t.isDirty},["*"]);case"validation.commit":return S({errors:t.errors,isValid:t.isValid});default:return Si(t)}}function Bi(s){let{currentState:t,operation:e,applyValueDerivations:i,onOperationError:r}=s,n=Object.prototype.hasOwnProperty.call(e.partialState,"values"),o=_nullishCoalesce(e.changedPaths, () => ((n?["*"]:void 0))),a;try{a=Ot({currentState:t,partialState:e.partialState,changedPaths:o,applyValueDerivations:i})}catch(c){_optionalChain([r, 'optionalCall', _202 => _202(c)]),a=Ot({currentState:t,partialState:e.partialState,changedPaths:o,applyValueDerivations:u=>u})}return a}function Ie(s){let{currentState:t,operation:e,applyValueDerivations:i,onOperationError:r}=s,n=bi(t,e);return n?Bi({currentState:t,operation:n,applyValueDerivations:(o,a)=>n.skipComputed?o:i(o,a),onOperationError:r}):null}function De(s){let{state:t,batchState:e,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o}=s,a=Pt(t,e);if(e.depth>0){let u=Ie({currentState:a,operation:i,applyValueDerivations:l=>l,onOperationError:n});return u&&we(e,u),t}let c=Ie({currentState:t,operation:i,applyValueDerivations:r,onOperationError:n});return c?(o({nextState:c.nextState,changedPaths:c.changedPaths,valuesChanged:c.valuesChanged}),c.nextState):t}function ke(s){let{state:t,batchState:e,applyValueDerivations:i,onStateCommitted:r}=s,n=Ae({currentState:t,batchState:e,applyValueDerivations:i});return n?(r({nextState:n.nextState,changedPaths:n.changedPaths,valuesChanged:n.valuesChanged}),n.nextState):t}function Me(s){let{batchState:t,callback:e,flushBatchedStateUpdates:i}=s;Ve(t);try{return e()}finally{Fe(t)&&i()}}function Re(s){let{payload:t,setState:e,notifySubscriptions:i,notifyEffects:r}=s;e(t.nextState),i(t.nextState,t.changedPaths),r(t.nextState,t.valuesChanged)}function Oe(s){let{state:t,batchState:e,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o}=s;return De({state:t,batchState:e,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o})}function je(s){let{batchState:t,values:e,saveHistory:i}=s;if(t.depth>0){t.pendingHistorySnapshot=!0;return}i(e)}function He(s){let{state:t,batchState:e,applyValueDerivations:i,onStateCommitted:r,saveHistory:n}=s,o=ke({state:t,batchState:e,applyValueDerivations:i,onStateCommitted:r});return e.pendingHistorySnapshot&&(e.pendingHistorySnapshot=!1,n(o.values)),o}var Et= (_class20 =class{constructor(t){;_class20.prototype.__init58.call(this);this.args=t;this.state=t.state,this.subscriptions=t.subscriptions,this.effects=t.effects,this.capabilityRegistry=t.capabilityRegistry,this.capabilities=t.capabilityRegistry.toCapabilities()}__init58() {this.batchState=Ce()}getCapability(t){return this.capabilityRegistry.resolve(t)}getState(){return Pt(this.state,this.batchState)}runBatch(t){return Me({batchState:this.batchState,callback:t,flushBatchedStateUpdates:()=>this.flushBatchedStateUpdates()})}dispatch(t){this.state=Oe({state:this.state,batchState:this.batchState,operation:t,applyValueDerivations:(e,i)=>this.applyValueDerivations(e,i),onOperationError:e=>_optionalChain([this, 'access', _203 => _203.args, 'access', _204 => _204.onUnhandledError, 'optionalCall', _205 => _205(e,"derivation")]),onStateCommitted:e=>this.onStateCommitted(e)})}saveHistorySnapshot(){let t=this.capabilities.history.getMetadata();je({batchState:this.batchState,values:this.state.values,saveHistory:i=>this.capabilities.history.saveSnapshot(i)});let e=this.capabilities.history.getMetadata();this.notifyIfHistoryChanged(t,e)}cleanup(){this.subscriptions.destroy(),this.capabilities.validation.cancelAll(),this.effects.destroy()}onStateCommitted(t){Re({payload:t,setState:e=>{this.state=e},notifySubscriptions:(e,i)=>this.subscriptions.notify(e,i),notifyEffects:(e,i)=>this.effects.onStateUpdated(e,i)})}flushBatchedStateUpdates(){let t=this.capabilities.history.getMetadata();this.state=He({state:this.state,batchState:this.batchState,applyValueDerivations:(i,r)=>this.applyValueDerivations(i,r),onStateCommitted:i=>this.onStateCommitted(i),saveHistory:i=>this.capabilities.history.saveSnapshot(i)});let e=this.capabilities.history.getMetadata();this.notifyIfHistoryChanged(t,e)}applyValueDerivations(t,e){return this.args.applyValueDerivations?this.args.applyValueDerivations(t,e):t}notifyIfHistoryChanged(t,e){t.canUndo===e.canUndo&&t.canRedo===e.canRedo&&t.historyIndex===e.historyIndex&&t.historySize===e.historySize||this.subscriptions.notify(this.getState(),[_chunkRHMJPKNVcjs.h.call(void 0, )])}}, _class20);function Ue(s){let{rawConfig:t,overrides:e}=s,i=Jt(t),r=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _206 => _206.baselineManager]), () => (new z(i.initialValues))),n=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _207 => _207.fieldRegistry]), () => (new K(({error:f})=>{i.onUnhandledError(f,"validation")}))),o=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _208 => _208.computedManager]), () => (new q(()=>n.getComputedEntries(),f=>i.onUnhandledError(f,"computed")))),a=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _209 => _209.dirtyManager]), () => (new L)),c=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _210 => _210.maskManager]), () => (new _));i.masks&&Object.entries(i.masks).forEach(([f,m])=>{c.registerMask(f,m)});let u=()=>{n.invalidateIndexes(),o.invalidateReverseDeps()},l,d=()=>{if(!l)throw new Error("BitStore runtime kernel is not initialized yet.");return l},p=xe({rawConfig:t,config:i,fieldRegistry:n,computedManager:o,dirtyManager:a,baselineManager:r,runtimeContext:{stateAccess:{getState:()=>d().getState(),dispatch:f=>d().dispatch(f),saveHistorySnapshot:()=>d().saveHistorySnapshot(),runStateBatch:f=>d().runBatch(f)},fieldAccess:{getFieldConfig:f=>n.getFieldConfig(f),getScopeFields:f=>n.getScopeFields(f),getNormalizerEntries:()=>n.getNormalizerEntries(),getTransformEntries:()=>n.getTransformEntries()},featureAccess:{getEffects:()=>d().effects,getHistory:()=>d().getCapability("history"),getValidation:()=>d().getCapability("validation")},actions:{setError:(f,m)=>{d().getCapability("error").setError(f,m)},setServerErrors:(f,m)=>{d().getCapability("error").setServerErrors(f,m)},validate:f=>d().getCapability("validation").validate(f),setFieldWithMeta:(f,m,T={origin:"setField"})=>{d().runBatch(()=>{d().getCapability("lifecycle").updateField(f,m,T)})},unregisterPrefix:f=>{st({prefix:f,state:d().getState(),fieldRegistry:n,subscriptions:d().subscriptions,validationCleanupPrefix:m=>d().getCapability("validation").cleanupPrefix(m),invalidateFieldIndexes:u,dispatch:m=>d().dispatch(m)})},triggerValidation:(f,m)=>{d().getCapability("validation").trigger(f,m)}}}}),h=()=>{let f=d().getState();return a.buildDirtyValues(f.values)},g=f=>{te({values:f,state:d().getState(),initialValues:r.getValues(),validation:d().getCapability("validation"),fieldRegistry:n,dirtyManager:a,dispatch:m=>d().dispatch(m),saveHistorySnapshot:()=>d().saveHistorySnapshot()})},v=Gt({storeId:p.storeId,config:i,getState:()=>d().getState(),getConfig:()=>i,getValues:()=>d().getState().values,getDirtyValues:h,applyPersistedValues:g,setPersistMetadata:f=>d().dispatch({kind:"form.persistMeta",patch:f})});return l=new Et({state:p.state,subscriptions:p.subscriptions,effects:v,capabilityRegistry:p.capabilityRegistry,onUnhandledError:(f,m)=>i.onUnhandledError(f,m),applyValueDerivations:(f,m)=>{try{return J({values:f,changedPaths:m,normalizerEntries:n.getNormalizerEntries(),applyComputed:(T,P)=>o.apply(T,P),onError:(T,P)=>{i.onUnhandledError(T,"derivation")}})}catch(T){return i.onUnhandledError(T,"derivation"),f}}}),l.saveHistorySnapshot(),{config:i,storeId:p.storeId,runtime:l,fieldRegistry:n,computedManager:o,dirtyManager:a,maskManager:c,baselineManager:r}}function ze(s){let{dispatch:t,effects:e}=s;return Xt({dispatch:t,effects:e})}function qe(s){let{dispatch:t,effects:e}=s;return Qt({dispatch:t,effects:e})}function Le(s){let{dispatch:t,effects:e}=s;return Zt({dispatch:t,effects:e})}function _e(s){let{history:t,applyHistoryState:e}=s,i=t.undo();i&&e(i)}function Ne(s){let{history:t,applyHistoryState:e}=s,i=t.redo();i&&e(i)}function We(s){return s.history.getMetadata()}function Ke(s,t){let e=new Set,i=(o,a)=>o===null||typeof o!="object"?o:new Proxy(o,{get:(c,u,l)=>{if(typeof u=="symbol")return Reflect.get(c,u,l);let d=String(u),p=a?`${a}.${d}`:d;e.add(p);let h=Reflect.get(c,u,l);return i(h,p)}}),r=i(s,"");t(r);let n=new Set;return e.forEach(o=>{let a=vi(o);a&&n.add(a)}),Array.from(n)}function vi(s){if(s)return s==="values"?"*":s.startsWith("values.")?s.slice(7):s==="errors"||s==="touched"||s==="isValidating"?"*":s.startsWith("errors.")?s.slice(7):s.startsWith("touched.")?s.slice(8):s.startsWith("isValidating.")?s.slice(13):s==="persist"||s.startsWith("persist.")?"persist":s}function Ti(s,t){if(s.length!==t.length)return!1;let e=new Set(t);for(let i of s)if(!e.has(i))return!1;return!0}function Pi(s,t){return s.length===0?{emitImmediately:_optionalChain([t, 'optionalAccess', _211 => _211.emitImmediately]),equalityFn:_optionalChain([t, 'optionalAccess', _212 => _212.equalityFn]),mode:"scoped",paths:["*"]}:{emitImmediately:_optionalChain([t, 'optionalAccess', _213 => _213.emitImmediately]),equalityFn:_optionalChain([t, 'optionalAccess', _214 => _214.equalityFn]),mode:"scoped",paths:s}}function $e(s){let{getState:t,subscribeSelector:e,selector:i,listener:r,options:n}=s,o=null,a=Ke(t(),i),c=!1,u=!1,l=d=>{let p=o;o=e(i,h=>{r(h);let g=Ke(t(),i);Ti(a,g)||(a=g,!(u||c)&&(u=!0,queueMicrotask(()=>{u=!1,!c&&(_optionalChain([o, 'optionalCall', _215 => _215()]),l(a))})))},Pi(d,n)),_optionalChain([p, 'optionalCall', _216 => _216()])};return l(a),()=>{c=!0,_optionalChain([o, 'optionalCall', _217 => _217()]),o=null}}function Je(s){let{getState:t,subscriptions:e,selector:i,listener:r,options:n,trackedSubscriptionsEnabled:o}=s,a=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _218 => _218.equalityFn]), () => (_chunkVOA3SKFYcjs.c));if(_optionalChain([n, 'optionalAccess', _219 => _219.mode])==="tracked"){if(!o)throw new Error('BitForm: subscribeSelector com mode="tracked" est\xE1 desabilitado por padr\xE3o. Ative config.trackedSubscriptions=true para habilitar o modo avan\xE7ado.');return $e({getState:t,subscribeSelector:(c,u,l)=>e.subscribeSelector(c,u,l,a),selector:i,listener:r,options:n})}return e.subscribeSelector(i,r,n,a)}function Ye(s){let{path:t,listener:e,options:i,subscribeSelector:r}=s,n=[..._nullishCoalesce(_optionalChain([i, 'optionalAccess', _220 => _220.paths]), () => ([])),t];return r(o=>_chunkVOA3SKFYcjs.f.call(void 0, o.values,t),e,{...i,paths:n})}function Ge(s){let{path:t,listener:e,getFieldState:i,subscribeSelector:r}=s;return r(()=>i(t),e,{paths:[t],equalityFn:_chunkOSQWKXFIcjs.c})}function Xe(s){let{listener:t,subscribeSelector:e}=s;return e(i=>({isValid:i.isValid,isDirty:i.isDirty,isSubmitting:i.isSubmitting}),t,{paths:["isValid","isDirty","isSubmitting"],equalityFn:(i,r)=>i.isValid===r.isValid&&i.isDirty===r.isDirty&&i.isSubmitting===r.isSubmitting})}function Qe(s){let{listener:t,subscribeSelector:e}=s;return e(i=>i.persist,t,{paths:["persist"],equalityFn:(i,r)=>i.isSaving===r.isSaving&&i.isRestoring===r.isRestoring&&i.error===r.error})}function Ze(s){let{readHistoryMeta:t,subscribeSelector:e,listener:i}=s;return e(()=>t(),i,{paths:[_chunkRHMJPKNVcjs.h.call(void 0, )],equalityFn:(r,n)=>_chunkRHMJPKNVcjs.e.call(void 0, r,n)})}function ti(s){let{scopeName:t,getScopeFields:e,readScopeStatus:i,subscribeSelector:r,listener:n}=s,o=_chunkRHMJPKNVcjs.d.call(void 0, t),a=i(t),c=()=>{},u=()=>{c();let d=_chunkRHMJPKNVcjs.c.call(void 0, e(t));c=r(()=>i(t),p=>{_chunkRHMJPKNVcjs.b.call(void 0, a,p)||(a=p,n(p))},{paths:[...d,o]})};u();let l=r(()=>e(t).length,()=>{u();let d=i(t);_chunkRHMJPKNVcjs.b.call(void 0, a,d)||(a=d,n(d))},{paths:[o]});return()=>{c(),l()}}function ei(s){let{runtime:t,config:e,fieldRegistry:i,dirtyManager:r,stateReader:n}=s,o={getState:()=>_chunkVOA3SKFYcjs.a.call(void 0, n.getState()),getFieldState:l=>_chunkVOA3SKFYcjs.a.call(void 0, n.getFieldState(l)),getIsValid:()=>n.getFlag("isValid"),getIsSubmitting:()=>n.getFlag("isSubmitting"),getIsDirty:()=>n.getFlag("isDirty"),isHidden:l=>t.capabilities.query.isHidden(l),isRequired:l=>t.capabilities.query.isRequired(l),isFieldDirty:l=>t.capabilities.query.isFieldDirty(l),isFieldValidating:l=>t.capabilities.query.isFieldValidating(l),getDirtyValues:()=>r.buildDirtyValues(n.getState().values),getPersistMetadata:()=>n.getPersistMetadata(),getHistoryMetadata:()=>We({history:t.capabilities.history}),getScopeStatus:l=>t.capabilities.scope.getScopeStatus(l),getScopeErrors:l=>t.capabilities.scope.getScopeErrors(l),getCanUndo:()=>t.capabilities.history.canUndo,getCanRedo:()=>t.capabilities.history.canRedo,getScopeFields:l=>i.getScopeFields(l)},a={subscribe:l=>t.subscriptions.subscribe(l),subscribePersistMeta:l=>Qe({listener:l,subscribeSelector:(d,p,h)=>a.subscribeSelector(d,p,h)}),subscribeHistoryMeta:l=>Ze({readHistoryMeta:()=>o.getHistoryMetadata(),subscribeSelector:(d,p,h)=>a.subscribeSelector(d,p,h),listener:l}),subscribeScopeStatus:(l,d)=>ti({scopeName:l,getScopeFields:p=>o.getScopeFields(p),readScopeStatus:p=>o.getScopeStatus(p),subscribeSelector:(p,h,g)=>a.subscribeSelector(p,h,g),listener:d}),subscribeSelector:(l,d,p)=>Je({getState:()=>o.getState(),subscriptions:t.subscriptions,selector:l,listener:d,options:p,trackedSubscriptionsEnabled:!!e.trackedSubscriptions}),subscribePath:(l,d,p)=>Ye({path:l,listener:d,options:p,subscribeSelector:(h,g,v)=>a.subscribeSelector(h,g,v)}),subscribeFieldState:(l,d)=>Ge({path:l,listener:d,getFieldState:p=>o.getFieldState(p),subscribeSelector:(p,h,g)=>a.subscribeSelector(p,h,g)}),subscribeFormMeta:l=>Xe({listener:l,subscribeSelector:(d,p,h)=>a.subscribeSelector(d,p,h)})};return{read:o,observe:a,write:{registerField:(l,d)=>{re({path:l,config:d,state:t.getState(),fieldRegistry:i,subscriptions:t.subscriptions,validationCleanupField:p=>t.capabilities.validation.cleanupField(p),stateReader:n,invalidateFieldIndexes:()=>{i.invalidateIndexes()},dispatch:p=>t.dispatch(p),getState:()=>t.getState(),onUnhandledError:(p,h)=>e.onUnhandledError(p,h)})},unregisterField:l=>{se({path:l,state:t.getState(),hasStaticConfig:!!_optionalChain([e, 'access', _221 => _221.fields, 'optionalAccess', _222 => _222[l]]),fieldRegistry:i,subscriptions:t.subscriptions,validationCleanupField:d=>t.capabilities.validation.cleanupField(d),invalidateFieldIndexes:()=>{i.invalidateIndexes()},dispatch:d=>t.dispatch(d)})},unregisterPrefix:l=>{st({prefix:l,state:t.getState(),fieldRegistry:i,subscriptions:t.subscriptions,validationCleanupPrefix:d=>t.capabilities.validation.cleanupPrefix(d),invalidateFieldIndexes:()=>{i.invalidateIndexes()},dispatch:d=>t.dispatch(d)})},setField:(l,d)=>{t.runBatch(()=>{t.capabilities.lifecycle.updateField(l,d,{origin:"setField"})})},blurField:l=>{t.capabilities.query.isTouched(l)||t.runBatch(()=>{t.dispatch(It([l]))}),t.capabilities.validation.trigger([l])},markFieldsTouched:l=>{l.length!==0&&t.dispatch(It(l))},setValues:(l,d)=>{t.capabilities.lifecycle.setValues(l,d)},setError:(l,d)=>{t.capabilities.error.setError(l,d)},setErrors:l=>{t.capabilities.error.setErrors(l)},setServerErrors:(l,d)=>{t.capabilities.error.setServerErrors(l,d)},reset:()=>{t.runBatch(()=>{t.capabilities.lifecycle.reset()})},transaction:l=>t.runBatch(l),submit:l=>t.capabilities.lifecycle.submit(l),pushItem:(l,d)=>t.capabilities.arrays.pushItem(l,d),prependItem:(l,d)=>t.capabilities.arrays.prependItem(l,d),insertItem:(l,d,p)=>t.capabilities.arrays.insertItem(l,d,p),removeItem:(l,d)=>t.capabilities.arrays.removeItem(l,d),swapItems:(l,d,p)=>t.capabilities.arrays.swapItems(l,d,p),moveItem:(l,d,p)=>t.capabilities.arrays.moveItem(l,d,p),replaceItems:(l,d)=>t.capabilities.arrays.replaceItems(l,d),clearItems:l=>t.capabilities.arrays.clearItems(l)},feature:{undo:()=>{_e({history:t.capabilities.history,applyHistoryState:l=>t.capabilities.lifecycle.applyHistoryState(l)})},redo:()=>{Ne({history:t.capabilities.history,applyHistoryState:l=>t.capabilities.lifecycle.applyHistoryState(l)})},validate:l=>t.capabilities.validation.validate(l),hasValidationsInProgress:l=>t.capabilities.validation.hasValidationsInProgress(l),triggerValidation:(l,d)=>t.capabilities.validation.trigger(l,d),restorePersisted:()=>ze({dispatch:l=>t.dispatch(l),effects:t.effects}),forceSave:()=>qe({dispatch:l=>t.dispatch(l),effects:t.effects}),clearPersisted:()=>Le({dispatch:l=>t.dispatch(l),effects:t.effects}),getArrayItemIds:(l,d)=>t.capabilities.arrays.getItemIds(l,d),cleanup:()=>t.cleanup()}}}function ii(s){let t=()=>s.read.getState();return{read:{get storeId(){return s.identity.storeId},get config(){return s.identity.config},get isValid(){return s.read.getIsValid()},get isSubmitting(){return s.read.getIsSubmitting()},get isDirty(){return s.read.getIsDirty()},getState:t,getFieldConfig:o=>s.getFieldConfig(o),getFieldState:o=>s.read.getFieldState(o),isHidden:o=>s.read.isHidden(o),isRequired:o=>s.read.isRequired(o),isFieldDirty:o=>s.read.isFieldDirty(o),isFieldValidating:o=>s.read.isFieldValidating(o),getDirtyValues:()=>s.read.getDirtyValues(),getPersistMetadata:()=>s.read.getPersistMetadata(),getHistoryMetadata:()=>s.read.getHistoryMetadata(),getScopeStatus:o=>s.read.getScopeStatus(o),getScopeErrors:o=>s.read.getScopeErrors(o),getScopeFields:o=>s.read.getScopeFields(o)},observe:{getState:t,subscribe:o=>s.observe.subscribe(o),subscribePersistMeta:o=>s.observe.subscribePersistMeta(o),subscribeHistoryMeta:o=>s.observe.subscribeHistoryMeta(o),subscribeScopeStatus:(o,a)=>s.observe.subscribeScopeStatus(o,a),subscribeFormMeta:o=>s.observe.subscribeFormMeta(o),subscribeSelector:(o,a,c)=>s.observe.subscribeSelector(o,a,c),subscribePath:(o,a,c)=>s.observe.subscribePath(o,a,c),subscribeFieldState:(o,a)=>s.observe.subscribeFieldState(o,a)},write:{setField:(o,a)=>s.write.setField(o,a),blurField:o=>s.write.blurField(o),markFieldsTouched:o=>s.write.markFieldsTouched(o),setValues:(o,a)=>s.write.setValues(o,a),setError:(o,a)=>s.write.setError(o,a),setErrors:o=>s.write.setErrors(o),setServerErrors:(o,a)=>s.write.setServerErrors(o,a),reset:()=>s.write.reset(),transaction:o=>s.write.transaction(o),submit:o=>s.write.submit(o)},feature:{cleanup:()=>s.feature.cleanup(),validate:o=>s.feature.validate(o),triggerValidation:(o,a)=>s.feature.triggerValidation(o,a),restorePersisted:()=>s.feature.restorePersisted(),forceSave:()=>s.feature.forceSave(),clearPersisted:()=>s.feature.clearPersisted(),registerField:(o,a)=>s.write.registerField(o,a),unregisterField:o=>s.write.unregisterField(o),unregisterPrefix:o=>s.write.unregisterPrefix(o),pushItem:(o,a)=>s.write.pushItem(o,a),prependItem:(o,a)=>s.write.prependItem(o,a),insertItem:(o,a,c)=>s.write.insertItem(o,a,c),removeItem:(o,a)=>s.write.removeItem(o,a),moveItem:(o,a,c)=>s.write.moveItem(o,a,c),swapItems:(o,a,c)=>s.write.swapItems(o,a,c),replaceItems:(o,a)=>s.write.replaceItems(o,a),clearItems:o=>s.write.clearItems(o),getArrayItemIds:(o,a)=>s.feature.getArrayItemIds(o,a),get canUndo(){return s.read.getCanUndo()},get canRedo(){return s.read.getCanRedo()},hasValidationsInProgress:o=>s.feature.hasValidationsInProgress(o),resolveMask:o=>s.resolveMask(o),createArrayItemId:(o,a)=>s.createArrayItemId(o,a),undo:()=>s.feature.undo(),redo:()=>s.feature.redo()}}}var xt= (_class21 =class{constructor(t){;_class21.prototype.__init59.call(this);this.deps=t}__init59() {this.fieldStateCache=new Map}getState(){return this.deps.getState()}getUserLayer(){let t=this.deps.getState();return{values:t.values,touched:t.touched}}getValidationLayer(){let t=this.deps.getState();return{errors:t.errors,isValidating:t.isValidating,isValid:t.isValid}}getDerivedLayer(){return{isDirty:this.deps.getState().isDirty}}getFeatureLayer(){let t=this.deps.getState();return{persist:t.persist,isSubmitting:t.isSubmitting}}getFlag(t){return this.deps.getState()[t]}getPersistMetadata(){return this.deps.getState().persist}getFieldState(t){let e=t,i=this.deps.getState(),r=this.fieldStateCache.get(e),n=_chunkVOA3SKFYcjs.f.call(void 0, i.values,e),o=i.errors[e],a=!!i.touched[e],c=this.deps.isHidden(e),u=this.deps.isRequired(e),l=this.deps.isFieldDirty(e),d=this.deps.isFieldValidating(e);if(r){let h=r.snapshot;if(h.value===n&&h.error===o&&h.touched===a&&h.isHidden===c&&h.isRequired===u&&h.isDirty===l&&h.isValidating===d)return h}let p=$t({state:i,path:t,value:n,isHidden:c,isRequired:u,isDirty:l,isValidating:d});return this.fieldStateCache.set(e,{state:i,snapshot:p}),p}invalidatePath(t){this.fieldStateCache.delete(t)}}, _class21);var Ct= (_class22 =class{__init60() {this[R]=!0}__init61() {this[M]=!0}constructor(t={}){;_class22.prototype.__init60.call(this);_class22.prototype.__init61.call(this);let e=Ue({rawConfig:t});this._config=e.config,this.storeId=e.storeId;let i=new xt({getState:()=>e.runtime.getState(),isHidden:o=>e.runtime.capabilities.query.isHidden(o),isRequired:o=>e.runtime.capabilities.query.isRequired(o),isFieldDirty:o=>e.runtime.capabilities.query.isFieldDirty(o),isFieldValidating:o=>e.runtime.capabilities.query.isFieldValidating(o)}),r=ei({runtime:e.runtime,config:this._config,fieldRegistry:e.fieldRegistry,dirtyManager:e.dirtyManager,stateReader:i}),n=ii({identity:{storeId:this.storeId,config:this._config},read:r.read,observe:r.observe,write:r.write,feature:r.feature,getFieldConfig:o=>e.fieldRegistry.getFieldConfig(o),resolveMask:o=>Kt({path:o,getFieldConfig:a=>e.fieldRegistry.getFieldConfig(a),masks:e.maskManager.getAllMasks()}),createArrayItemId:(o,a)=>this._config.idFactory({scope:"array",path:o,index:a})});this.read=n.read,this.observe=n.observe,this.write=n.write,this.feature=n.feature,e.runtime.effects.attachStorePort({getState:()=>this.read.getState(),getHistoryMetadata:()=>this.read.getHistoryMetadata(),undo:()=>this.feature.undo(),redo:()=>this.feature.redo(),reset:()=>this.write.reset()})}}, _class22);function ri(s={}){return new Ct(s)}function si(s){if(!s||typeof s!="object")return!1;let t=s;return t[R]===!0&&!!t.read&&!!t.observe&&!!t.write&&!!t.feature}function Ei(s){if(si(s))return s;throw new Error("BitForm: o store informado n\xE3o exp\xF5e a API necess\xE1ria para hooks/framework bindings.")}function xi(s){return!s||typeof s!="object"?!1:s[M]===!0}function Ci(s){if(!si(s))throw new Error("BitForm: o store informado n\xE3o possui branding de hooks (BIT_HOOKS_API_SYMBOL).");if(!xi(s))throw new Error("BitForm: o store informado n\xE3o possui branding de framework (BIT_FRAMEWORK_STORE_SYMBOL).");return s}function Vi(s){return Object.defineProperty(s,R,{value:!0,enumerable:!1,configurable:!1,writable:!1}),Object.defineProperty(s,M,{value:!0,enumerable:!1,configurable:!1,writable:!1}),s}function Fi(s={}){let t=ri(s),e={read:t.read,observe:t.observe,write:t.write,feature:t.feature};return Vi(e)}function wi(s){return s.read}function Ai(s){return s.observe}function Ii(s){return s.write}function Di(s){return s.feature}function ki(s,t){let e={};for(let i of t)e[i]=s[i];return e}exports.a = wt; exports.b = hi; exports.c = Ei; exports.d = Ci; exports.e = Fi; exports.f = wi; exports.g = Ai; exports.h = Ii; exports.i = Di; exports.j = ki;
2
+ //# sourceMappingURL=chunk-MAKFWOL5.cjs.map