@lehnihon/bit-form 2.2.27 → 2.2.29

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 (46) hide show
  1. package/dist/angular/index.cjs +1 -1
  2. package/dist/angular/index.cjs.map +1 -1
  3. package/dist/angular/index.js +1 -1
  4. package/dist/angular/index.js.map +1 -1
  5. package/dist/{chunk-WYYVVM2C.js → chunk-4U32VQD5.js} +2 -2
  6. package/dist/chunk-FF6WALLN.js +2 -0
  7. package/dist/chunk-FF6WALLN.js.map +1 -0
  8. package/dist/chunk-K3QLAMDG.cjs +2 -0
  9. package/dist/{chunk-U6UFULNS.cjs.map → chunk-K3QLAMDG.cjs.map} +1 -1
  10. package/dist/chunk-KEINCG6A.js +2 -0
  11. package/dist/chunk-KEINCG6A.js.map +1 -0
  12. package/dist/{chunk-GBHOCY7E.cjs → chunk-LBWJK3IC.cjs} +2 -2
  13. package/dist/{chunk-GBHOCY7E.cjs.map → chunk-LBWJK3IC.cjs.map} +1 -1
  14. package/dist/chunk-UNBTMNY3.cjs +2 -0
  15. package/dist/chunk-UNBTMNY3.cjs.map +1 -0
  16. package/dist/core/store.cjs +1 -1
  17. package/dist/core/store.js +1 -1
  18. package/dist/core.cjs +1 -1
  19. package/dist/core.js +1 -1
  20. package/dist/devtools/bridge.cjs +1 -1
  21. package/dist/devtools/bridge.js +1 -1
  22. package/dist/devtools/index.cjs +49 -24
  23. package/dist/devtools/index.cjs.map +1 -1
  24. package/dist/devtools/index.d.cts +2 -0
  25. package/dist/devtools/index.d.ts +2 -0
  26. package/dist/devtools/index.js +49 -24
  27. package/dist/devtools/index.js.map +1 -1
  28. package/dist/index.cjs +1 -1
  29. package/dist/index.js +1 -1
  30. package/dist/react/index.cjs +1 -1
  31. package/dist/react/index.js +1 -1
  32. package/dist/react-native/index.cjs +1 -1
  33. package/dist/react-native/index.js +1 -1
  34. package/dist/vue/index.cjs +1 -1
  35. package/dist/vue/index.cjs.map +1 -1
  36. package/dist/vue/index.js +1 -1
  37. package/dist/vue/index.js.map +1 -1
  38. package/package.json +1 -1
  39. package/dist/chunk-7T7L2TZX.js +0 -2
  40. package/dist/chunk-7T7L2TZX.js.map +0 -1
  41. package/dist/chunk-EYCJKAK3.js +0 -2
  42. package/dist/chunk-EYCJKAK3.js.map +0 -1
  43. package/dist/chunk-U6UFULNS.cjs +0 -2
  44. package/dist/chunk-WKLCAC74.cjs +0 -2
  45. package/dist/chunk-WKLCAC74.cjs.map +0 -1
  46. /package/dist/{chunk-WYYVVM2C.js.map → chunk-4U32VQD5.js.map} +0 -0
@@ -1,2 +0,0 @@
1
- import{d as I}from"./chunk-7T7L2TZX.js";import{a as U,b as q,d as L,e as W,g as O,i as _,j as $,k as z}from"./chunk-L42NQRVD.js";import{b as T}from"./chunk-UIKO6GGW.js";import{a as j}from"./chunk-Y7TQTZY7.js";import{c as x,f as D}from"./chunk-UBVVBVLS.js";import{createContext as X,useContext as Y,useEffect as Z,useMemo as N,useRef as tt}from"react";import{jsx as et}from"react/jsx-runtime";var G=X(null),vt=({store:t,children:e})=>{let r=N(()=>I(t),[t]),n=tt(!1);return Z(()=>(n.current=!1,()=>{n.current=!0,queueMicrotask(()=>{n.current&&(n.current=!1,r.feature?.cleanup?.())})}),[r]),et(G.Provider,{value:r,children:e})},S=()=>{let t=Y(G);if(!t)throw new Error("BitForm hooks devem ser usados dentro de um BitFormProvider");return t};import{useCallback as d,useMemo as w,useRef as rt,useState as H,useSyncExternalStore as st}from"react";function Mt(){let t=S(),[e,r]=H(null),[n,s]=H(null),o=rt(null),c=d(p=>q(t,p),[t]),l=d(()=>{let p=U(t);return o.current&&o.current.isValid===p.isValid&&o.current.isDirty===p.isDirty&&o.current.isSubmitting===p.isSubmitting?o.current:(o.current=p,p)},[t]),i=st(c,l,l),a=w(()=>_(t,{clearSubmissionState:()=>{r(null),s(null)},setSubmissionResult:p=>{s(p)},setSubmissionError:p=>{r(p)}}),[t]),{controller:m,actions:P}=a,b=d(m.submit,[m]),g=d(m.onSubmit,[m]),y=d(m.reset,[m]),F=d(m.getValues,[m]),h=d(m.getErrors,[m]),u=d(m.getTouched,[m]),B=d(m.getDirtyValues,[m]),R=w(()=>({...i,submitError:e,lastResponse:n}),[i,e,n]);return w(()=>({meta:R,getValues:F,getErrors:h,getTouched:u,getDirtyValues:B,submit:b,onSubmit:g,reset:y,...P}),[R,F,h,u,B,b,g,y,P])}import{useCallback as J,useEffect as ot,useMemo as k,useRef as nt,useSyncExternalStore as it}from"react";function jt(t){let e=S(),r=k(()=>O(e,t),[e,t]),n=nt(null),s=J(()=>{let i=r.readItems();return n.current&&x(n.current,i)?n.current:(n.current=i,i)},[r]),o=J(i=>e.observe.subscribePath(t,()=>i()),[e,t]),c=it(o,s,s),l=k(()=>r.getFields(c),[r,c]);return ot(()=>()=>{z(e,`${t}.`)},[e,t]),k(()=>({fields:l,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}),[l,c.length,r])}import{useCallback as E,useMemo as at,useRef as ut,useSyncExternalStore as ct}from"react";function Wt(t){let e=S(),r=ut(null),n=E(()=>{let i=e.read.getScopeStatus(t);return r.current&&T(r.current,i)?r.current:(r.current=i,i)},[e,t]),s=E(i=>e.observe.subscribeScopeStatus(t,()=>i()),[e,t]),o=ct(s,n,n),c=E(async()=>{let i=await e.feature.validate({scope:t}),a=e.read.getScopeErrors(t);return{valid:i,errors:a}},[e,t]),l=E(()=>e.read.getScopeErrors(t),[e,t]);return at(()=>({scopeName:t,status:o,errors:o.errors,validate:c,getErrors:l,isValid:!o.hasErrors,isDirty:o.isDirty}),[t,o,c,l])}import{useCallback as f,useMemo as lt,useRef as A,useState as mt,useSyncExternalStore as pt}from"react";function Gt(t){if(t.length===0)throw new Error("useBitSteps: scopeNames must not be empty");let e=S(),[r,n]=mt(0),s=t[r]??"",o=A(null),c=A(s);c.current=s;let l=A(r);l.current=r;let i=f(()=>{let u=e.read.getScopeStatus(s);return o.current&&T(o.current,u)?o.current:(o.current=u,u)},[e,s]),a=pt(f(u=>e.observe.subscribeScopeStatus(s,()=>u()),[e,s]),i,i),m=f(async()=>{let u=await e.feature.validate({scope:s}),B=e.read.getScopeErrors(s);return{valid:u,errors:B}},[e,s]),P=f(()=>e.read.getScopeErrors(s),[e,s]),b=f(async()=>{let u=c.current,B=l.current,R=e.read.getScopeFields(u);if(e.feature.hasValidationsInProgress(R))return!1;let p=await e.feature.validate({scope:u});if(B!==l.current)return!1;if(p)n(M=>Math.min(M+1,t.length-1));else{let M=e.read.getScopeErrors(u),C=Object.keys(M);C.length>0&&e.write.markFieldsTouched(C)}return p},[e,t.length]),g=f(()=>{n(u=>Math.max(u-1,0))},[]),y=f(u=>{n(Math.max(0,Math.min(u-1,t.length-1)))},[t.length]),F=r===0,h=r>=t.length-1;return lt(()=>({step:r+1,stepIndex:r,scope:s,next:b,prev:g,goTo:y,isFirst:F,isLast:h,status:a,errors:a.errors,isValid:!a.hasErrors,isDirty:a.isDirty,validate:m,getErrors:P}),[r,s,b,g,y,F,h,a,m,P])}import{useCallback as K,useSyncExternalStore as St,useRef as dt}from"react";function Zt(t){let e=S(),r=dt(null),n=K(()=>{let o=D(e.read.getState().values,t);return r.current!==null&&x(r.current,o)?r.current:(r.current=o,o)},[e,t]),s=K(o=>e.observe.subscribePath(t,()=>o()),[e,t]);return St(s,n,n)}import{useCallback as v,useMemo as Q,useSyncExternalStore as ft,useRef as Bt}from"react";function se(){let t=S(),e=v(a=>W(t,a),[t]),r=Bt(null),n=v(()=>{let a=L(t);return r.current&&r.current.isSaving===a.isSaving&&r.current.isRestoring===a.isRestoring&&r.current.error===a.error?r.current:(r.current=a,a)},[t]),s=ft(e,n,n),o=v(async()=>t.feature.restorePersisted(),[t]),c=v(async()=>{await t.feature.forceSave()},[t]),l=v(async()=>{await t.feature.clearPersisted()},[t]),i=Q(()=>({isSaving:s.isSaving,isRestoring:s.isRestoring,error:s.error}),[s]);return Q(()=>({restore:o,save:c,clear:l,meta:i}),[o,c,l,i])}import{useCallback as V,useEffect as Pt,useRef as bt,useSyncExternalStore as gt}from"react";function me(t){let e=S(),r=bt(null);Pt(()=>()=>$(e,t),[e,t]);let n=V(()=>{let i=e.read.getFieldState(t),a=j(i,r.current);return r.current=a,a},[e,t]),s=V(i=>e.observe.subscribeFieldState(t,()=>i()),[e,t]),o=gt(s,n,n),c=V(i=>e.write.setField(t,i),[e,t]),l=V(()=>e.write.blurField(t),[e,t]);return{fieldState:o,setValue:c,setBlur:l,store:e}}export{vt as a,S as b,Mt as c,me as d,jt as e,Wt as f,Gt as g,Zt as h,se as i};
2
- //# sourceMappingURL=chunk-EYCJKAK3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/react/context.tsx","../src/react/use-bit-form.ts","../src/react/use-bit-array.ts","../src/react/use-bit-scope.ts","../src/react/use-bit-steps.ts","../src/react/use-bit-watch.ts","../src/react/use-bit-persist.ts","../src/react/use-bit-field-base.ts"],"sourcesContent":["import React, { createContext, useContext, useEffect, useMemo, useRef } from \"react\";\nimport type { BitFrameworkStoreApi, BitStoreApi } from \"../core\";\nimport { createFrameworkStoreAdapter } from \"../core\";\n\nconst BitContext = createContext<BitFrameworkStoreApi<any> | null>(null);\n\ninterface BitFormProviderProps<T extends object> {\n store: BitFrameworkStoreApi<T> | BitStoreApi<T>;\n children: React.ReactNode;\n}\n\ninterface BitFormProviderRuntimeProps {\n store: unknown;\n children: React.ReactNode;\n}\n\ntype BitFormProviderComponent = {\n <T extends object>(props: BitFormProviderProps<T>): React.ReactElement;\n (props: BitFormProviderRuntimeProps): React.ReactElement;\n};\n\nexport const BitFormProvider: BitFormProviderComponent = ({\n store,\n children,\n}: BitFormProviderRuntimeProps) => {\n const adapted = useMemo(() => createFrameworkStoreAdapter(store), [store]);\n const cleanupPendingRef = useRef(false);\n\n useEffect(() => {\n // On mount (including Strict Mode remount), cancel any pending cleanup.\n cleanupPendingRef.current = false;\n\n return () => {\n // On unmount, flag that cleanup is pending and defer to microtask.\n // React Strict Mode double-mounts (mount → unmount → mount)\n // synchronously. The remount resets cleanupPendingRef before the\n // microtask fires, so Strict Mode cycles are safely ignored.\n cleanupPendingRef.current = true;\n queueMicrotask(() => {\n if (cleanupPendingRef.current) {\n cleanupPendingRef.current = false;\n (adapted as any).feature?.cleanup?.();\n }\n });\n };\n }, [adapted]);\n\n return (\n <BitContext.Provider value={adapted}>\n {children}\n </BitContext.Provider>\n );\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 useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport {\n createFrameworkFormBinding,\n readFormMetaSnapshot,\n subscribeFormMetaSnapshot,\n} from \"../core\";\nimport { useBitStore } from \"./context\";\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 useMemo(\n () => ({\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 meta,\n getValues,\n getErrors,\n getTouched,\n getDirtyValues,\n submit,\n onSubmit,\n reset,\n actions,\n ],\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 useMemo(\n () => ({\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 [fields, data.length, controller],\n );\n}\n","import { useCallback, useMemo, useRef, useSyncExternalStore } from \"react\";\nimport type { ScopeStatus, ValidateScopeResult } from \"../core\";\nimport { isScopeStatusEqual } from \"../core\";\nimport { useBitStore } from \"./context\";\n\nexport type { ScopeStatus, ValidateScopeResult };\n\nexport function useBitScope(scopeName: string) {\n const store = useBitStore();\n\n const lastStatus = useRef<ScopeStatus | null>(null);\n\n const getStatusSnapshot = useCallback(() => {\n const nextStatus = store.read.getScopeStatus(scopeName);\n\n if (\n lastStatus.current &&\n isScopeStatusEqual(lastStatus.current, nextStatus)\n ) {\n return lastStatus.current;\n }\n\n lastStatus.current = nextStatus;\n return nextStatus;\n }, [store, scopeName]);\n\n // Assina apenas os slices de estado relevantes para o escopo (errors e\n // isDirty), evitando execuções desnecessárias do getStatusSnapshot em\n // mudanças não relacionadas (isSubmitting, isValidating de outros campos…)\n const subscribe = useCallback(\n (cb: () => void) =>\n store.observe.subscribeScopeStatus(scopeName, () => cb()),\n [store, scopeName],\n );\n\n const status = useSyncExternalStore(\n subscribe,\n getStatusSnapshot,\n getStatusSnapshot,\n );\n\n const validate = useCallback(async (): Promise<ValidateScopeResult> => {\n const valid = await store.feature.validate({ scope: scopeName });\n const errors = store.read.getScopeErrors(scopeName);\n return { valid, errors };\n }, [store, scopeName]);\n\n const getErrors = useCallback(() => {\n return store.read.getScopeErrors(scopeName);\n }, [store, scopeName]);\n\n return useMemo(\n () => ({\n scopeName,\n status,\n errors: status.errors,\n validate,\n getErrors,\n isValid: !status.hasErrors,\n isDirty: status.isDirty,\n }),\n [scopeName, status, validate, getErrors],\n );\n}\n","import {\n useCallback,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport type { ScopeStatus, ValidateScopeResult } from \"../core\";\nimport { isScopeStatusEqual } from \"../core\";\nimport { useBitStore } from \"./context\";\nimport type { UseBitStepsResult } from \"./types\";\n\nexport function useBitSteps(scopeNames: string[]): UseBitStepsResult {\n if (scopeNames.length === 0) {\n throw new Error(\"useBitSteps: scopeNames must not be empty\");\n }\n const store = useBitStore();\n const [stepIndex, setStepIndex] = useState(0);\n\n const scope = scopeNames[stepIndex] ?? \"\";\n const lastStatus = useRef<ScopeStatus | null>(null);\n const scopeRef = useRef(scope);\n scopeRef.current = scope;\n const stepIndexRef = useRef(stepIndex);\n stepIndexRef.current = stepIndex;\n\n const getStatusSnapshot = useCallback(() => {\n const nextStatus = store.read.getScopeStatus(scope);\n\n if (\n lastStatus.current &&\n isScopeStatusEqual(lastStatus.current, nextStatus)\n ) {\n return lastStatus.current;\n }\n\n lastStatus.current = nextStatus;\n return nextStatus;\n }, [store, scope]);\n\n const status = useSyncExternalStore(\n useCallback(\n (cb: () => void) => store.observe.subscribeScopeStatus(scope, () => cb()),\n [store, scope],\n ),\n getStatusSnapshot,\n getStatusSnapshot,\n );\n\n const validate = useCallback(async (): Promise<ValidateScopeResult> => {\n const valid = await store.feature.validate({ scope });\n const errors = store.read.getScopeErrors(scope);\n return { valid, errors };\n }, [store, scope]);\n\n const getErrors = useCallback(() => {\n return store.read.getScopeErrors(scope);\n }, [store, scope]);\n\n const next = useCallback(async (): Promise<boolean> => {\n const capturedScope = scopeRef.current;\n const capturedStepIndex = stepIndexRef.current;\n const scopeFields = store.read.getScopeFields(capturedScope);\n\n if (store.feature.hasValidationsInProgress(scopeFields)) {\n return false;\n }\n\n const valid = await store.feature.validate({ scope: capturedScope });\n\n if (capturedStepIndex !== stepIndexRef.current) return false;\n\n if (valid) {\n setStepIndex((s) => Math.min(s + 1, scopeNames.length - 1));\n } else {\n const errors = store.read.getScopeErrors(capturedScope);\n const pathsWithErrors = Object.keys(errors);\n if (pathsWithErrors.length > 0) {\n store.write.markFieldsTouched(pathsWithErrors);\n }\n }\n return valid;\n }, [store, scopeNames.length]);\n\n const prev = useCallback(() => {\n setStepIndex((s) => Math.max(s - 1, 0));\n }, []);\n\n const goTo = useCallback(\n (stepNumber: number) => {\n setStepIndex(\n Math.max(0, Math.min(stepNumber - 1, scopeNames.length - 1)),\n );\n },\n [scopeNames.length],\n );\n\n const isFirst = stepIndex === 0;\n const isLast = stepIndex >= scopeNames.length - 1;\n\n return useMemo(\n () => ({\n step: stepIndex + 1,\n stepIndex,\n scope,\n next,\n prev,\n goTo,\n isFirst,\n isLast,\n status,\n errors: status.errors,\n isValid: !status.hasErrors,\n isDirty: status.isDirty,\n validate,\n getErrors,\n }),\n [\n stepIndex,\n scope,\n next,\n prev,\n goTo,\n isFirst,\n isLast,\n status,\n validate,\n getErrors,\n ],\n );\n}\n","import { useCallback, useSyncExternalStore, useRef } from \"react\";\nimport { useBitStore } from \"./context\";\nimport { getDeepValue, valueEqual, BitPath, BitPathValue } from \"../core\";\n\nexport function useBitWatch<\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n>(path: P): BitPathValue<TForm, P> {\n const store = useBitStore<TForm>();\n const lastValue = useRef<BitPathValue<TForm, P> | null>(null);\n\n const getSnapshot = useCallback(() => {\n const value = getDeepValue(\n store.read.getState().values,\n path as string,\n ) as BitPathValue<TForm, P>;\n\n if (lastValue.current !== null && valueEqual(lastValue.current, value)) {\n return lastValue.current;\n }\n\n lastValue.current = value;\n return value;\n }, [store, path]);\n\n // Assina apenas o path monitorado → evita executar getSnapshot em toda\n // mudança de estado do store (blur, validation, outros campos, etc.)\n const subscribe = useCallback(\n (cb: () => void) => store.observe.subscribePath(path, () => cb()),\n [store, path],\n );\n\n return useSyncExternalStore(\n subscribe,\n getSnapshot,\n getSnapshot,\n ) as BitPathValue<TForm, P>;\n}\n","import { useCallback, useMemo, useSyncExternalStore, useRef } from \"react\";\nimport { readPersistMetaSnapshot, subscribePersistMetaSnapshot } from \"../core\";\nimport { useBitStore } from \"./context\";\nimport type { UseBitPersistResult } from \"./types\";\n\nexport function useBitPersist(): UseBitPersistResult {\n const store = useBitStore<any>();\n\n const subscribePersistMeta = useCallback(\n (cb: () => void) => subscribePersistMetaSnapshot(store, cb),\n [store],\n );\n\n const lastMeta = useRef<ReturnType<typeof readPersistMetaSnapshot> | null>(null);\n\n const getSnapshot = useCallback(() => {\n const nextMeta = readPersistMetaSnapshot(store);\n\n if (\n lastMeta.current &&\n lastMeta.current.isSaving === nextMeta.isSaving &&\n lastMeta.current.isRestoring === nextMeta.isRestoring &&\n lastMeta.current.error === nextMeta.error\n ) {\n return lastMeta.current;\n }\n\n lastMeta.current = nextMeta;\n return nextMeta;\n }, [store]);\n\n const persistMeta = useSyncExternalStore(\n subscribePersistMeta,\n getSnapshot,\n getSnapshot,\n );\n\n const restore = useCallback(async () => {\n return store.feature.restorePersisted();\n }, [store]);\n\n const save = useCallback(async () => {\n await store.feature.forceSave();\n }, [store]);\n\n const clear = useCallback(async () => {\n await store.feature.clearPersisted();\n }, [store]);\n\n const meta = useMemo(\n () => ({\n isSaving: persistMeta.isSaving,\n isRestoring: persistMeta.isRestoring,\n error: persistMeta.error,\n }),\n [persistMeta],\n );\n\n return useMemo(\n () => ({\n restore,\n save,\n clear,\n meta,\n }),\n [restore, save, clear, meta],\n );\n}\n","import { useCallback, useEffect, useRef, useSyncExternalStore } from \"react\";\nimport {\n BitFieldSnapshot,\n BitPath,\n BitPathValue,\n cleanupRegisteredField,\n createFieldStateSnapshot,\n} from \"../core\";\nimport { useBitStore } from \"./context\";\n\nexport function useBitFieldBase<\n _TValue = any,\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n>(path: P) {\n const store = useBitStore<TForm>();\n const lastSnapshot = useRef<BitFieldSnapshot<BitPathValue<TForm, P>> | null>(\n null,\n );\n\n useEffect(() => {\n return () => cleanupRegisteredField(store, path as string);\n }, [store, path]);\n\n const getSnapshot = useCallback(() => {\n const nextState = store.read.getFieldState(path);\n const snapshot = createFieldStateSnapshot(nextState, lastSnapshot.current);\n lastSnapshot.current = snapshot;\n return snapshot;\n }, [store, path]);\n\n const subscribe = useCallback(\n (cb: () => void) => store.observe.subscribeFieldState(path, () => cb()),\n [store, path],\n );\n\n const fieldState = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\n const setValue = useCallback(\n (val: BitPathValue<TForm, P>) => store.write.setField(path, val),\n [store, path],\n );\n\n const setBlur = useCallback(() => store.write.blurField(path), [store, path]);\n\n return { fieldState, setValue, setBlur, store };\n}\n"],"mappings":"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","names":["createContext","useContext","useEffect","useMemo","useRef","jsx","BitContext","createContext","BitFormProvider","store","children","adapted","useMemo","createFrameworkStoreAdapter","cleanupPendingRef","useRef","useEffect","useBitStore","useContext","useCallback","useMemo","useRef","useState","useSyncExternalStore","useBitForm","store","useBitStore","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","meta","useCallback","useEffect","useMemo","useRef","useSyncExternalStore","useBitArray","path","store","useBitStore","controller","useMemo","createArrayBinding","lastSnapshotRef","useRef","getSnapshot","useCallback","next","valueEqual","subscribeArray","cb","data","useSyncExternalStore","fields","useEffect","cleanupRegisteredPrefix","useCallback","useMemo","useRef","useSyncExternalStore","useBitScope","scopeName","store","useBitStore","lastStatus","useRef","getStatusSnapshot","useCallback","nextStatus","isScopeStatusEqual","subscribe","cb","status","useSyncExternalStore","validate","valid","errors","getErrors","useMemo","useCallback","useMemo","useRef","useState","useSyncExternalStore","useBitSteps","scopeNames","store","useBitStore","stepIndex","setStepIndex","useState","scope","lastStatus","useRef","scopeRef","stepIndexRef","getStatusSnapshot","useCallback","nextStatus","isScopeStatusEqual","status","useSyncExternalStore","cb","validate","valid","errors","getErrors","next","capturedScope","capturedStepIndex","scopeFields","s","pathsWithErrors","prev","goTo","stepNumber","isFirst","isLast","useMemo","useCallback","useSyncExternalStore","useRef","useBitWatch","path","store","useBitStore","lastValue","useRef","getSnapshot","useCallback","value","getDeepValue","valueEqual","subscribe","cb","useSyncExternalStore","useCallback","useMemo","useSyncExternalStore","useRef","useBitPersist","store","useBitStore","subscribePersistMeta","useCallback","cb","subscribePersistMetaSnapshot","lastMeta","useRef","getSnapshot","nextMeta","readPersistMetaSnapshot","persistMeta","useSyncExternalStore","restore","save","clear","meta","useMemo","useCallback","useEffect","useRef","useSyncExternalStore","useBitFieldBase","path","store","useBitStore","lastSnapshot","useRef","useEffect","cleanupRegisteredField","getSnapshot","useCallback","nextState","snapshot","createFieldStateSnapshot","subscribe","cb","fieldState","useSyncExternalStore","setValue","val","setBlur"]}
@@ -1,2 +0,0 @@
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 _class23; var _class24; var _class25;var _chunkRHMJPKNVcjs = require('./chunk-RHMJPKNV.cjs');var _chunkAV7YYSFIcjs = require('./chunk-AV7YYSFI.cjs');var _chunkOWDDAM6Ccjs = require('./chunk-OWDDAM6C.cjs');var _chunkX3DGA5UCcjs = require('./chunk-X3DGA5UC.cjs');function Xe(s){let{path:e,getFieldConfig:t,masks:i}=s,r=_optionalChain([t, 'call', _2 => _2(e), 'optionalAccess', _3 => _3.mask]);if(r)return typeof r=="string"?_optionalChain([i, 'optionalAccess', _4 => _4[r]]):r}function Ze(s){let{state:e,path:t,value:i,isHidden:r,isRequired:n,isDirty:o,isValidating:a}=s,l=t;return{value:i,error:e.errors[l],touched:!!e.touched[l],isHidden:r,isRequired:n,isDirty:o,isValidating:a}}var j=Symbol.for("bit-form.framework-store-api");var H=Symbol.for("bit-form.hooks-api");var _=class{constructor(e){this.baselineValues=_chunkOWDDAM6Ccjs.a.call(void 0, e)}getValues(){return this.baselineSnapshot||(this.baselineSnapshot=Object.freeze(_chunkOWDDAM6Ccjs.a.call(void 0, this.baselineValues))),this.baselineSnapshot}setValues(e){this.baselineValues=_chunkOWDDAM6Ccjs.a.call(void 0, e),this.baselineSnapshot=void 0}};var L= (_class =class{constructor(e,t){;_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=e;this.onError=t}__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(e){return e===null||typeof e!="object"&&typeof e!="function"}invalidateReverseDeps(){this.reverseDepsCache=null,this.childDepsIndex=null,this.orderedAllEntriesCache=null,this.validatedEntriesSignature=null,this.validatedEntriesRef=null,this.orderedIndexByPathCache=null,this.equalityCache.clear()}apply(e,t){let i=this.getComputedEntries(e);if(i.length===0)return{values:e,changedComputedPaths:[]};this.ensureEntriesAreValid(i);let r=this.resolveEntriesToRun(i,t);if(r.length===0)return{values:e,changedComputedPaths:[]};let n=e,o=new Set,a=new Set;for(let l of r){if(l.dependsOn.some(f=>{if(o.has(f))return!0;let S=f+".";for(let g of o)if(g.startsWith(S))return!0;return!1})){o.add(l.path);continue}let c;try{c=l.compute(n)}catch(f){_optionalChain([this, 'access', _5 => _5.onError, 'optionalCall', _6 => _6(f,l.path)]),o.add(l.path);continue}let u;try{u=_chunkOWDDAM6Ccjs.f.call(void 0, n,l.path)}catch(f){_optionalChain([this, 'access', _7 => _7.onError, 'optionalCall', _8 => _8(f,l.path)]),o.add(l.path);continue}let d=this.equalityCache.get(l.path),p,h=this.isCacheableScalar(u)&&this.isCacheableScalar(c);try{h&&d&&d.current===u&&d.next===c?p=d.equal:p=_chunkOWDDAM6Ccjs.d.call(void 0, u,c)}catch(f){_optionalChain([this, 'access', _9 => _9.onError, 'optionalCall', _10 => _10(f,l.path)]),o.add(l.path);continue}if(h?(this.equalityCache.size>1e3&&this.equalityCache.clear(),this.equalityCache.set(l.path,{current:u,next:c,equal:p})):this.equalityCache.delete(l.path),!p)try{n=_chunkOWDDAM6Ccjs.g.call(void 0, n,l.path,c),a.add(l.path)}catch(f){_optionalChain([this, 'access', _11 => _11.onError, 'optionalCall', _12 => _12(f,l.path)]),o.add(l.path);continue}}return{values:n,changedComputedPaths:[...a]}}getReverseDependencies(e){if(this.reverseDepsCache)return this.reverseDepsCache;let t=new Map;for(let r of e)for(let n of r.dependsOn){let o=t.get(n);o||(o=new Set,t.set(n,o)),o.add(r.path)}let i=new Map;for(let r of t.keys()){let n=r.split(".");for(let o=1;o<n.length;o++){let a=n.slice(0,o).join("."),l=i.get(a);l||(l=new Set,i.set(a,l)),l.add(r)}}return this.reverseDepsCache=t,this.childDepsIndex=i,t}resolveEntriesToRun(e,t){if(!t||t.length===0||t.includes("*"))return this.getOrderedAllEntries(e);let i=this.getReverseDependencies(e),r=new Set,n=[...t],o=0;for(;o<n.length;){let u=n[o++],d=this.getDependentsForPath(i,u);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(e),l=this.getOrderedIndexByPath(e,a),c=[];return r.forEach(u=>{let d=l.get(u);if(d===void 0)return;let p=a[d];p&&c.push({index:d,entry:p})}),c.sort((u,d)=>u.index-d.index),c.map(u=>u.entry)}orderEntries(e){if(e.length<=1)return e;let t=new Map(e.map(l=>[l.path,l])),i=new Map,r=new Map;e.forEach(l=>i.set(l.path,0)),e.forEach(l=>{l.dependsOn.forEach(c=>{if(!t.has(c))return;let u=_nullishCoalesce(r.get(c), () => (new Set));u.has(l.path)||(u.add(l.path),r.set(c,u),i.set(l.path,(_nullishCoalesce(i.get(l.path), () => (0)))+1))})});let n=e.filter(l=>(_nullishCoalesce(i.get(l.path), () => (0)))===0).map(l=>l.path),o=[],a=0;for(;a<n.length;){let l=n[a++];o.push(l);let c=r.get(l);c&&c.forEach(u=>{let d=(_nullishCoalesce(i.get(u), () => (0)))-1;i.set(u,d),d===0&&n.push(u)})}if(o.length!==e.length)throw new Error("BitStore: cyclic computed dependencies detected. Check computedDependsOn definitions.");return o.map(l=>t.get(l))}getOrderedAllEntries(e){let t=this.createEntriesSignature(e);if(this.orderedAllEntriesCache&&this.orderedAllEntriesCache.signature===t)return this.orderedAllEntriesCache.ordered;let i=this.orderEntries(e);return this.orderedAllEntriesCache={signature:t,ordered:i},i}getOrderedIndexByPath(e,t){let i=this.createEntriesSignature(e);if(this.orderedIndexByPathCache&&this.orderedIndexByPathCache.signature===i)return this.orderedIndexByPathCache.indexByPath;let r=new Map;return t.forEach((n,o)=>{r.set(n.path,o)}),this.orderedIndexByPathCache={signature:i,indexByPath:r},r}ensureEntriesAreValid(e){if(this.validatedEntriesRef===e)return;let t=this.createEntriesSignature(e);if(this.validatedEntriesSignature===t){this.validatedEntriesRef=e;return}e.forEach(i=>this.assertDependencies(i)),this.invalidateReverseDeps(),this.validatedEntriesSignature=t,this.validatedEntriesRef=e}createEntriesSignature(e){return e.map(t=>`${t.path}:${t.dependsOn.join(",")}`).join("|")}getDependentsForPath(e,t){let i=new Set,r=a=>{let l=e.get(a);l&&l.forEach(c=>i.add(c))};r(t);let n=t.split(".");for(;n.length>1;)n.pop(),r(n.join("."));let o=_optionalChain([this, 'access', _13 => _13.childDepsIndex, 'optionalAccess', _14 => _14.get, 'call', _15 => _15(t)]);if(o)for(let a of o)r(a);return i}assertDependencies(e){if(e.dependsOn.length===0)throw new Error(`BitStore: computed field \`${e.path}\` requires explicit computedDependsOn in v4.`);if(e.dependsOn.includes(e.path))throw new Error(`BitStore: computed field \`${e.path}\` cannot depend on itself.`)}}, _class);var W= (_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(e,t,i){this.removeDirtyChildren(e);let r=_chunkOWDDAM6Ccjs.f.call(void 0, t,e),n=_chunkOWDDAM6Ccjs.f.call(void 0, i,e);return _chunkOWDDAM6Ccjs.c.call(void 0, r,n)?this.removeDirtyPath(e):this.addDirtyPath(e),this.dirtyPaths.size>0}rebuild(e,t){return this.dirtyPaths=_chunkOWDDAM6Ccjs.e.call(void 0, e,t),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(e){if(this.dirtyPathIndex.has(e))return!0;let t=e.lastIndexOf(".");for(;t>-1;){let i=e.slice(0,t);if((_nullishCoalesce(this.dirtyPrefixRefCount.get(i), () => (0)))>0)return!0;t=e.lastIndexOf(".",t-1)}return!1}buildDirtyValues(e){if(this.dirtyPaths.size===0)return{};let t=[],i=[...this.dirtyPaths].sort(),r=new Set,n=new Set,o=a=>{let l=a.lastIndexOf(".");for(;l>-1;){if(n.has(a.slice(0,l)))return!0;l=a.lastIndexOf(".",l-1)}return!1};for(let a of i){if(o(a))continue;let l=a.match(/^(.+)\.\d+/);if(l){let c=l[1];if(r.has(c))continue;r.add(c);let u=_chunkOWDDAM6Ccjs.f.call(void 0, e,c);t.push([c,u]),n.add(c)}else{let c=_chunkOWDDAM6Ccjs.f.call(void 0, e,a);t.push([a,c]),n.add(a)}}return t.length===0?{}:_chunkOWDDAM6Ccjs.h.call(void 0, {},t)}rebuildIndex(){let e=new Set,t=new Map,i=new Map;for(let r of this.dirtyPaths)this.forEachPathPrefix(r,n=>{e.add(n),t.set(n,(_nullishCoalesce(t.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=e,this.dirtyPrefixRefCount=t,this.childrenByPrefix=i}removeDirtyChildren(e){let t=this.childrenByPrefix.get(e);if(!(!t||t.size===0))for(let i of[...t])this.removeDirtyPath(i)}addDirtyPath(e){this.dirtyPaths.has(e)||(this.dirtyPaths.add(e),this.forEachPathPrefix(e,t=>{this.dirtyPathIndex.add(t),this.dirtyPrefixRefCount.set(t,(_nullishCoalesce(this.dirtyPrefixRefCount.get(t), () => (0)))+1)}),this.forEachAncestorPrefix(e,t=>{let i=this.childrenByPrefix.get(t);i?i.add(e):this.childrenByPrefix.set(t,new Set([e]))}))}removeDirtyPath(e){this.dirtyPaths.has(e)&&(this.dirtyPaths.delete(e),this.forEachPathPrefix(e,t=>{let i=(_nullishCoalesce(this.dirtyPrefixRefCount.get(t), () => (0)))-1;if(i<=0){this.dirtyPrefixRefCount.delete(t),this.dirtyPathIndex.delete(t);return}this.dirtyPrefixRefCount.set(t,i)}),this.forEachAncestorPrefix(e,t=>{_optionalChain([this, 'access', _16 => _16.childrenByPrefix, 'access', _17 => _17.get, 'call', _18 => _18(t), 'optionalAccess', _19 => _19.delete, 'call', _20 => _20(e)])}))}forEachPathPrefix(e,t){let i=e.split("."),r="";for(let n of i)r=r?`${r}.${n}`:n,t(r)}forEachAncestorPrefix(e,t){let i=e.split("."),r="";for(let n=0;n<i.length-1;n++)r=r?`${r}.${i[n]}`:i[n],t(r)}}, _class2);var N= (_class3 =class{__init12() {this.masks=new Map}constructor(){;_class3.prototype.__init12.call(this);Object.entries(_chunkX3DGA5UCcjs.L).forEach(([e,t])=>{this.masks.set(e,t)})}registerMask(e,t){this.masks.set(e,t)}unregisterMask(e){this.masks.has(e)&&this.masks.delete(e)}resolveMask(e){return this.masks.get(e)}getAllMasks(){return Object.fromEntries(this.masks.entries())}clear(){this.masks.clear()}}, _class3);function Si(s){return s==null?"":s.replace(/\.+$/g,"")}function F(s){return s==null?"":Si(s.trim())}function x(s,e){if(s==null||e==null)return!1;let t=F(e);return t.length===0?!1:s===t||s.startsWith(`${t}.`)}function C(s,e){return s==null?"":F(e===void 0?s:`${s}.${e}`)}function V(s){return s.includes(".*.")||s.endsWith(".*")}function et(s){let t=s.replace(/\./g,"\\.").replace(/\*/g,"\\d+");return new RegExp(`^${t}$`)}function U(s,e){if(!V(s))return[s];let t=s.split("."),i=[""];for(let r=0;r<t.length;r++){let n=t[r],o=[];for(let a of i)if(n==="*"){let l=a.replace(/\.$/,""),c=l?_chunkOWDDAM6Ccjs.f.call(void 0, e,l):e;if(Array.isArray(c)&&c.length>0)for(let u=0;u<c.length;u++)o.push(`${a}${u}.`)}else o.push(`${a}${n}.`);i=o}return i.map(r=>r.replace(/\.$/,""))}function Ie(s,e,t){if(!V(s)||!V(t))return s;let i=t.replace(/\./g,"\\.").replace(/\*/g,"(\\d+)"),r=new RegExp(`^${i}$`),n=e.match(r);if(!n)return s;let o=n.slice(1),a=0,l=s.split("*"),c=l[0];for(let u=1;u<l.length;u++){let d=a<o.length?o[a++]:"*";c+=d+l[u]}return c}var $= (_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);_class4.prototype.__init18.call(this);_class4.prototype.__init19.call(this); }__init13() {this.fieldConfigs=new Map}__init14() {this.wildcardConfigs=new Map}__init15() {this.wildcardRegexes=new Map}__init16() {this.scopeFieldsIndex=null}__init17() {this.computedEntriesCache=null}__init18() {this.normalizerEntriesCache=null}__init19() {this.transformEntriesCache=null}get(e){let t=this.fieldConfigs.get(e);if(t)return t;for(let[i,r]of this.wildcardConfigs.entries()){let n=this.wildcardRegexes.get(i);if(n&&n.test(e))return r}}set(e,t){V(e)?(this.wildcardConfigs.set(e,t),this.wildcardRegexes.set(e,et(e))):this.fieldConfigs.set(e,t),this.registerCachedIndexes(e,t)}delete(e){let t;return V(e)?(t=this.wildcardConfigs.get(e),this.wildcardConfigs.delete(e),this.wildcardRegexes.delete(e)):(t=this.fieldConfigs.get(e),this.fieldConfigs.delete(e)),this.unregisterCachedIndexes(e,t),t}has(e){if(this.fieldConfigs.has(e)||this.wildcardConfigs.has(e))return!0;for(let t of this.wildcardRegexes.values())if(t.test(e))return!0;return!1}forEach(e){this.fieldConfigs.forEach((t,i)=>e(t,i)),this.wildcardConfigs.forEach((t,i)=>e(t,i))}entries(){return[...Array.from(this.fieldConfigs.entries()),...Array.from(this.wildcardConfigs.entries())]}getScopeFields(e,t){if(!this.scopeFieldsIndex){let n=new Map;this.forEach((o,a)=>{if(!o.scope)return;let l=_nullishCoalesce(n.get(o.scope), () => (new Set));l.add(a),n.set(o.scope,l)}),this.scopeFieldsIndex=n}let i=Array.from(_nullishCoalesce(this.scopeFieldsIndex.get(e), () => ([])));if(i.length===0)return[];let r=new Set;for(let n of i)V(n)?U(n,t).forEach(a=>r.add(a)):r.add(n);return Array.from(r)}getComputedEntries(e){if(!this.computedEntriesCache){let i=[];this.forEach((r,n)=>{r.computed&&i.push({path:n,compute:r.computed,dependsOn:r.computedDependsOn})}),this.computedEntriesCache=i}let t=[];for(let i of this.computedEntriesCache)if(V(i.path)){let r=U(i.path,e);for(let n of r)t.push({path:n,compute:o=>i.compute(o,n),dependsOn:i.dependsOn.map(o=>Ie(o,n,i.path))})}else t.push({path:i.path,compute:r=>i.compute(r,i.path),dependsOn:i.dependsOn});return t}getTransformEntries(e){if(!this.transformEntriesCache){let i=[];this.forEach((r,n)=>{r.transform&&i.push([n,r.transform])}),this.transformEntriesCache=i}let t=[];for(let[i,r]of this.transformEntriesCache)if(V(i)){let n=U(i,e);for(let o of n)t.push([o,(a,l)=>r(a,l,o)])}else t.push([i,(n,o)=>r(n,o,i)]);return t}getNormalizerEntries(e){if(!this.normalizerEntriesCache){let i=[];this.forEach((r,n)=>{r.normalize&&i.push({path:n,normalize:r.normalize,dependsOn:_optionalChain([r, 'access', _21 => _21.normalizeDependsOn, 'optionalAccess', _22 => _22.length])?r.normalizeDependsOn:[n]})}),this.normalizerEntriesCache=i}let t=[];for(let i of this.normalizerEntriesCache)if(V(i.path)){let r=U(i.path,e);for(let n of r)t.push({path:n,normalize:(o,a)=>i.normalize(o,a,n),dependsOn:i.dependsOn.map(o=>Ie(o,n,i.path))})}else t.push({path:i.path,normalize:(r,n)=>i.normalize(r,n,i.path),dependsOn:i.dependsOn});return t}invalidateIndexes(){this.scopeFieldsIndex=null,this.computedEntriesCache=null,this.normalizerEntriesCache=null,this.transformEntriesCache=null}registerCachedIndexes(e,t){if(this.scopeFieldsIndex&&t.scope){let i=_nullishCoalesce(this.scopeFieldsIndex.get(t.scope), () => (new Set));i.add(e),this.scopeFieldsIndex.set(t.scope,i)}if(this.computedEntriesCache&&t.computed){let i=this.computedEntriesCache.findIndex(r=>r.path===e);i>=0&&this.computedEntriesCache.splice(i,1),this.computedEntriesCache.push({path:e,compute:t.computed,dependsOn:t.computedDependsOn})}this.normalizerEntriesCache&&t.normalize&&this.normalizerEntriesCache.push({path:e,normalize:t.normalize,dependsOn:_optionalChain([t, 'access', _23 => _23.normalizeDependsOn, 'optionalAccess', _24 => _24.length])?t.normalizeDependsOn:[e]}),this.transformEntriesCache&&t.transform&&this.transformEntriesCache.push([e,t.transform])}unregisterCachedIndexes(e,t){if(!t){this.invalidateIndexes();return}if(this.scopeFieldsIndex&&t.scope){let i=this.scopeFieldsIndex.get(t.scope);i&&(i.delete(e),i.size>0?this.scopeFieldsIndex.set(t.scope,i):this.scopeFieldsIndex.delete(t.scope))}this.computedEntriesCache&&t.computed&&(this.computedEntriesCache=this.computedEntriesCache.filter(i=>i.path!==e)),this.normalizerEntriesCache&&t.normalize&&(this.normalizerEntriesCache=this.normalizerEntriesCache.filter(i=>i.path!==e)),this.transformEntriesCache&&t.transform&&(this.transformEntriesCache=this.transformEntriesCache.filter(([i])=>i!==e))}}, _class4);var K= (_class5 =class{constructor(e,t){;_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);_class5.prototype.__init25.call(this);_class5.prototype.__init26.call(this);this.getFieldConfig=e;this.onConditionError=t}__init20() {this.dependencies=new Map}__init21() {this.hiddenFields=new Set}__init22() {this.conditionalVisibilityPaths=new Set}__init23() {this.requiredPathsByDependency=new Map}__init24() {this.requiredConditionalPaths=new Set}__init25() {this.requiredEvaluationVersion=0}__init26() {this.requiredEvaluationCache=new Map}getHiddenFields(){return this.hiddenFields}onRegister(e,t,i){let r=!!_optionalChain([t, 'access', _25 => _25.conditional, 'optionalAccess', _26 => _26.showIf]),n=_optionalChain([t, 'access', _27 => _27.conditional, 'optionalAccess', _28 => _28.dependsOn]);if(n){if(this.wouldCreateCycle(e,n)){let o=new Error(`Circular dependency detected: "${e}" \u2192 [${n.join(", ")}]`);return _optionalChain([this, 'access', _29 => _29.onConditionError, 'optionalCall', _30 => _30({path:e,kind:"showIf",error:o})]),r&&this.hiddenFields.add(e),this.conditionalVisibilityPaths.delete(e),this.requiredConditionalPaths.delete(e),!1}n.forEach(o=>{this.dependencies.has(o)||this.dependencies.set(o,new Set),this.dependencies.get(o).add(e)})}return r&&this.conditionalVisibilityPaths.add(e),n&&_optionalChain([t, 'access', _31 => _31.conditional, 'optionalAccess', _32 => _32.requiredIf])&&(this.requiredConditionalPaths.add(e),n.forEach(o=>{this.requiredPathsByDependency.has(o)||this.requiredPathsByDependency.set(o,new Set),this.requiredPathsByDependency.get(o).add(e)})),this.requiredEvaluationVersion+=1,this.requiredEvaluationCache.clear(),this.evaluateFieldCondition(e,i),!0}onUnregister(e,t,i){this.hiddenFields.delete(e),this.conditionalVisibilityPaths.delete(e),_optionalChain([i, 'optionalAccess', _33 => _33.preserveIncomingDependents])||this.dependencies.delete(e),this.requiredEvaluationVersion+=1,this.requiredEvaluationCache.clear(),this.requiredConditionalPaths.delete(e),_optionalChain([t, 'optionalAccess', _34 => _34.conditional, 'optionalAccess', _35 => _35.dependsOn, 'optionalAccess', _36 => _36.forEach, 'call', _37 => _37(r=>{let n=this.requiredPathsByDependency.get(r);n&&(n.delete(e),n.size===0&&this.requiredPathsByDependency.delete(r))})]),this.dependencies.forEach(r=>{r.delete(e)});for(let[r,n]of this.dependencies)n.size===0&&this.dependencies.delete(r)}isHidden(e){return this.hiddenFields.has(e)}hasDependents(e){return(_nullishCoalesce(_optionalChain([this, 'access', _38 => _38.dependencies, 'access', _39 => _39.get, 'call', _40 => _40(e), 'optionalAccess', _41 => _41.size]), () => (0)))>0}isRequired(e,t){let i=this.getFieldConfig(e);if(!i||this.isHidden(e)||!_optionalChain([i, 'access', _42 => _42.conditional, 'optionalAccess', _43 => _43.requiredIf]))return!1;let r=this.requiredEvaluationCache.get(e);if(r&&r.version===this.requiredEvaluationVersion&&_chunkOWDDAM6Ccjs.d.call(void 0, r.valuesRef,t))return r.result;let n=!1;try{n=!!i.conditional.requiredIf(t)}catch(o){_optionalChain([this, 'access', _44 => _44.onConditionError, 'optionalCall', _45 => _45({path:e,kind:"requiredIf",error:o})])}return this.requiredEvaluationCache.set(e,{version:this.requiredEvaluationVersion,valuesRef:t,result:n}),n}getRequiredErrors(e){let t={};return this.requiredConditionalPaths.forEach(i=>{let r=this.getFieldConfig(i);if(r&&!this.isHidden(i)&&this.isRequired(i,e)){let n=_chunkOWDDAM6Ccjs.f.call(void 0, e,i);this.isEmpty(n)&&(t[i]=_nullishCoalesce(_optionalChain([r, 'access', _46 => _46.conditional, 'optionalAccess', _47 => _47.requiredMessage]), () => ("required field")))}}),t}evaluateAll(e){this.conditionalVisibilityPaths.forEach(t=>{this.evaluateFieldCondition(t,e)})}updateDependencies(e,t,i){let r=new Set,n=new Set,o=new Set,a=[e],l=new Set;for(;a.length>0;){let c=a.shift();if(l.has(c))continue;l.add(c);let u=this.dependencies.get(c);u&&u.forEach(d=>{r.add(d);let p=this.isHidden(d),h=this.isRequired(d,t);this.evaluateFieldCondition(d,i);let f=this.isHidden(d),S=this.isRequired(d,i);p!==f&&n.add(d),h!==S&&o.add(d),a.push(d)})}return{affectedFields:Array.from(r),visibilityChanged:Array.from(n),requiredChanged:Array.from(o)}}evaluateFieldCondition(e,t){let r=_optionalChain([this, 'access', _48 => _48.getFieldConfig, 'call', _49 => _49(e), 'optionalAccess', _50 => _50.conditional, 'optionalAccess', _51 => _51.showIf]);if(r)try{r(t)?this.hiddenFields.delete(e):this.hiddenFields.add(e)}catch(n){_optionalChain([this, 'access', _52 => _52.onConditionError, 'optionalCall', _53 => _53({path:e,kind:"showIf",error:n})])}}wouldCreateCycle(e,t){for(let i of t){let r=[e],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(e){return e==null||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.length===0}}, _class5);var J= (_class6 =class{__init27() {this.catalog=new $}constructor(e){;_class6.prototype.__init27.call(this);this.conditions=new K(t=>this.catalog.get(t),e)}getFieldConfig(e){return this.catalog.get(e)}forEachFieldConfig(e){this.catalog.forEach((t,i)=>e(t,i))}hasFieldConfig(e){return this.catalog.has(e)}getHiddenFields(){return this.conditions.getHiddenFields()}register(e,t,i){let r=this.catalog.get(e);r&&this.conditions.onUnregister(e,r,{preserveIncomingDependents:!0}),this.catalog.set(e,t),!(this.conditions.onRegister(e,t,i)||!r)&&(this.catalog.set(e,r),this.conditions.onRegister(e,r,i))}unregister(e){let t=this.catalog.delete(e);this.conditions.onUnregister(e,t)}unregisterPrefix(e){let t=[],i=F(e);return i.length===0||(this.catalog.forEach((r,n)=>{x(n,i)&&t.push([n,r])}),t.forEach(([r,n])=>{this.catalog.delete(r),this.conditions.onUnregister(r,n)})),t}isHidden(e){return this.conditions.isHidden(e)}hasDependents(e){return this.conditions.hasDependents(e)}isRequired(e,t){return this.conditions.isRequired(e,t)}getRequiredErrors(e){return this.conditions.getRequiredErrors(e)}evaluateAll(e){this.conditions.evaluateAll(e)}updateDependencies(e,t,i){return this.conditions.updateDependencies(e,t,i)}getScopeFields(e,t){return this.catalog.getScopeFields(e,t)}getComputedEntries(e){return this.catalog.getComputedEntries(e)}getTransformEntries(e){return this.catalog.getTransformEntries(e)}getNormalizerEntries(e){return this.catalog.getNormalizerEntries(e)}invalidateIndexes(){this.catalog.invalidateIndexes()}}, _class6);function bi(s){let e=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _54 => _54.path]), () => ("")),t=_optionalChain([s, 'optionalAccess', _55 => _55.index]),i=t!==void 0?`${e}:${t}`:`${e}:${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`;return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`bit-form-${i}-${crypto.randomUUID().slice(0,8)}`:`bit-form-${i}`}function De(s){typeof console<"u"&&typeof console.error=="function"&&console.error(s)}function tt(s={}){let e=_nullishCoalesce(s.initialValues, () => ({})),t=s.validation,i=s.history,r=_optionalChain([s, 'access', _56 => _56.persist, 'optionalAccess', _57 => _57.enabled])===!0,n=s.persist!==void 0,o=s.name?`bit-form:${s.name}:draft`:"bit-form:draft",a=_nullishCoalesce(s.onUnhandledError, () => (De)),l=(d,p)=>{try{a(d,p)}catch(h){De(d),De(h)}},c=_optionalChain([s, 'access', _58 => _58.persist, 'optionalAccess', _59 => _59.onError]),u={enabled:_nullishCoalesce(_optionalChain([s, 'access', _60 => _60.persist, 'optionalAccess', _61 => _61.enabled]), () => (!1)),key:_nullishCoalesce(_optionalChain([s, 'access', _62 => _62.persist, 'optionalAccess', _63 => _63.key]), () => (o)),storage:_optionalChain([s, 'access', _64 => _64.persist, 'optionalAccess', _65 => _65.storage]),autoSave:n||r?_nullishCoalesce(_optionalChain([s, 'access', _66 => _66.persist, 'optionalAccess', _67 => _67.autoSave]), () => (!0)):!1,debounceMs:_nullishCoalesce(_optionalChain([s, 'access', _68 => _68.persist, 'optionalAccess', _69 => _69.debounceMs]), () => (300)),mode:_nullishCoalesce(_optionalChain([s, 'access', _70 => _70.persist, 'optionalAccess', _71 => _71.mode]), () => ("values")),serialize:_nullishCoalesce(_optionalChain([s, 'access', _72 => _72.persist, 'optionalAccess', _73 => _73.serialize]), () => (JSON.stringify)),deserialize:_nullishCoalesce(_optionalChain([s, 'access', _74 => _74.persist, 'optionalAccess', _75 => _75.deserialize]), () => ((d=>JSON.parse(d)))),onError:d=>{if(c){c(d);return}l(d,"persist")}};return{name:s.name,initialValues:_chunkOWDDAM6Ccjs.a.call(void 0, e),resolver:_optionalChain([t, 'optionalAccess', _76 => _76.resolver]),validationDelay:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _77 => _77.delay]), () => (300)),history:{enabled:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _78 => _78.enabled]), () => (!1)),limit:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _79 => _79.limit]), () => (50)),debounceMs:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _80 => _80.debounceMs]), () => (300))},fields:s.fields,devTools:s.devTools,persist:u,idFactory:_nullishCoalesce(s.idFactory, () => (bi)),plugins:_nullishCoalesce(s.plugins, () => ([])),scheduler:s.scheduler,subscriptionCacheSize:s.subscriptionCacheSize,trackedSubscriptions:_nullishCoalesce(s.trackedSubscriptions, () => (!1)),bus:s.bus,onUnhandledError:l}}function z(s,e){if((!s||s.length===0)&&(!e||e.length===0))return;let t=new Set(_nullishCoalesce(s, () => ([])));return _optionalChain([e, 'optionalAccess', _81 => _81.forEach, 'call', _82 => _82(i=>t.add(i))]),Array.from(t)}function vi(s){let e=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _83 => _83.includes, 'call', _84 => _84("*")]), () => (!1)),t=new Set(_nullishCoalesce(s, () => ([]))),i=new Set;for(let r of t){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||e||t.has(r)||i.has(r))return!0;let n=r.lastIndexOf(".");for(;n>-1;){if(t.has(r.slice(0,n)))return!0;n=r.lastIndexOf(".",n-1)}return!1}}function Bi(s,e){if(!e||e.length===0||e.includes("*"))return s;let t=vi(e);return s.filter(i=>i.dependsOn.some(r=>t(r)))}function Ti(s,e){if(s.length<=1)return{orderedEntries:[...s],cyclePaths:[]};let t=new Map(s.map(l=>[l.path,l])),i=new Map,r=new Map,n=new Map(s.map((l,c)=>[l.path,c]));s.forEach(l=>i.set(l.path,0)),s.forEach(l=>{l.dependsOn.forEach(c=>{if(c===l.path)return;if(!t.has(c)){typeof console<"u"&&console.warn&&console.warn(`BitStore: normalizer "${l.path}" depends on "${c}" which is not a registered normalizer. It will receive pre-computed values.`),_optionalChain([e, 'optionalCall', _85 => _85(new Error(`BitStore: normalizer "${l.path}" depends on "${c}" which is not a registered normalizer.`),l.path)]);return}let u=_nullishCoalesce(r.get(c), () => (new Set));u.has(l.path)||(u.add(l.path),r.set(c,u),i.set(l.path,(_nullishCoalesce(i.get(l.path), () => (0)))+1))})});let o=s.filter(l=>(_nullishCoalesce(i.get(l.path), () => (0)))===0).map(l=>l.path),a=[];for(;o.length>0;){o.sort((u,d)=>(_nullishCoalesce(n.get(u), () => (0)))-(_nullishCoalesce(n.get(d), () => (0))));let l=o.shift();a.push(l);let c=r.get(l);c&&c.forEach(u=>{let d=(_nullishCoalesce(i.get(u), () => (0)))-1;i.set(u,d),d===0&&o.push(u)})}if(a.length!==s.length){let l=s.filter(c=>(_nullishCoalesce(i.get(c.path), () => (0)))>0).map(c=>c.path);return{orderedEntries:a.map(c=>t.get(c)),cyclePaths:l}}return{orderedEntries:a.map(l=>t.get(l)),cyclePaths:[]}}function G(s){let{values:e,changedPaths:t,normalizerEntries:i,applyComputed:r,onError:n}=s,o=Ti(Bi(i,t),n),{orderedEntries:a,cyclePaths:l}=o;if(l.length>0&&_optionalChain([n, 'optionalCall', _86 => _86(new Error(`BitStore: cyclic normalizer dependencies detected. Check normalizeDependsOn definitions for: ${l.join(", ")}.`),_nullishCoalesce(l[0], () => ("*")))]),a.length===0)return r(e,t);let c=[],u=e;for(let p of a){let h=_chunkOWDDAM6Ccjs.f.call(void 0, u,p.path),f;try{f=p.normalize(h,u)}catch(S){n?n(S,p.path):typeof console<"u"&&console.error&&console.error(`BitStore: normalizer error at "${p.path}"`,S);continue}_chunkOWDDAM6Ccjs.c.call(void 0, h,f)||(c.push([p.path,f]),u=_chunkOWDDAM6Ccjs.g.call(void 0, u,p.path,f))}let d=z(t,c.map(([p])=>p));return r(u,d)}function it(s){let{values:e,sourceValues:t,transformEntries:i,onError:r}=s;if(i.length===0)return e;let n=e,o=t;for(let[a,l]of i){let c=_chunkOWDDAM6Ccjs.f.call(void 0, n,a),u;try{u=l(c,o)}catch(d){r?r(d,a):typeof console<"u"&&console.error&&console.error(`BitStore: transform error at "${a}"`,d);continue}_chunkOWDDAM6Ccjs.c.call(void 0, c,u)||(n=_chunkOWDDAM6Ccjs.g.call(void 0, n,a,u),o=_chunkOWDDAM6Ccjs.g.call(void 0, o,a,u))}return n}var Y=class{constructor(e){this.effects=e.getAll()}attachStorePort(e){this.effects.forEach(t=>_optionalChain([t, 'access', _87 => _87.attachStorePort, 'optionalCall', _88 => _88(e)]))}initialize(){this.effects.forEach(e=>_optionalChain([e, 'access', _89 => _89.initialize, 'optionalCall', _90 => _90()]))}onStateUpdated(e,t){this.effects.forEach(i=>{try{_optionalChain([i, 'access', _91 => _91.onStateUpdated, 'optionalCall', _92 => _92(e,t)])}catch(r){this.logEffectHookError(i.name,"onStateUpdated",r)}})}async restorePersisted(){let e=!1,t=null;for(let i of this.effects)if(i.restorePersisted)try{e=await i.restorePersisted()||e}catch(r){this.logEffectHookError(i.name,"restorePersisted",r),t??=r}if(t&&!e)throw t;return e}async savePersistedNow(){let e=null;for(let t of this.effects)if(t.savePersistedNow)try{await t.savePersistedNow()}catch(i){this.logEffectHookError(t.name,"savePersistedNow",i),e??=i}if(e)throw e}async clearPersisted(){let e=null;for(let t of this.effects)if(t.clearPersisted)try{await t.clearPersisted()}catch(i){this.logEffectHookError(t.name,"clearPersisted",i),e??=i}if(e)throw e}async beforeValidate(e){for(let t of this.effects)if(t.beforeValidate)try{await t.beforeValidate(e)}catch(i){this.logEffectHookError(t.name,"beforeValidate",i)}}async afterValidate(e){for(let t of this.effects)if(t.afterValidate)try{await t.afterValidate(e)}catch(i){this.logEffectHookError(t.name,"afterValidate",i)}}async beforeSubmit(e){for(let t of this.effects)if(t.beforeSubmit)try{await t.beforeSubmit(e)}catch(i){this.logEffectHookError(t.name,"beforeSubmit",i)}}async afterSubmit(e){for(let t of this.effects)if(t.afterSubmit)try{await t.afterSubmit(e)}catch(i){this.logEffectHookError(t.name,"afterSubmit",i)}}onFieldChange(e){this.effects.forEach(t=>{try{_optionalChain([t, 'access', _93 => _93.onFieldChange, 'optionalCall', _94 => _94(e)])}catch(i){this.logEffectHookError(t.name,"onFieldChange",i)}})}async reportOperationalError(e){for(let t of this.effects)if(t.reportOperationalError)try{await t.reportOperationalError(e)}catch(i){this.logEffectHookError(t.name,"reportOperationalError",i)}}logEffectHookError(e,t,i){console.error(`BitStoreEffectEngine: effect "${e}" failed in hook "${t}"`,i)}destroy(){for(let e=this.effects.length-1;e>=0;e-=1)try{_optionalChain([this, 'access', _95 => _95.effects, 'access', _96 => _96[e], 'access', _97 => _97.destroy, 'optionalCall', _98 => _98()])}catch(t){this.logEffectHookError(this.effects[e].name,"destroy",t)}}};var Q=class{constructor(e,t,i=!0,r){this.storeId=e;this.bus=t;this.enableBusDispatch=i;this.storeBusPort=r}attachStorePort(e){this.storeBusPort=e,this.enableBusDispatch&&(this.bus.stores[this.storeId]=e)}initialize(){!this.enableBusDispatch||!this.storeBusPort||(this.bus.stores[this.storeId]=this.storeBusPort)}onStateUpdated(e){this.enableBusDispatch&&this.bus.dispatch(this.storeId,e)}destroy(){this.enableBusDispatch&&(delete this.bus.stores[this.storeId],this.storeBusPort=void 0)}};var X= (_class7 =class{constructor() { _class7.prototype.__init28.call(this); }__init28() {this.effects=new Map}register(e){this.effects.set(e.name,e)}getAll(){return Array.from(this.effects.values())}}, _class7);var Z= (_class8 =class{constructor(e){;_class8.prototype.__init29.call(this);this.persistManager=e}__init29() {this.beforeUnloadHandler=null}initialize(){typeof window<"u"&&(this.beforeUnloadHandler=()=>{this.persistManager.saveNow().catch(()=>{})},window.addEventListener("beforeunload",this.beforeUnloadHandler))}onStateUpdated(e,t){t&&this.persistManager.queueSave()}restorePersisted(){return this.persistManager.restore()}savePersistedNow(){return this.persistManager.saveNow()}clearPersisted(){return this.persistManager.clear()}destroy(){this.beforeUnloadHandler&&(window.removeEventListener("beforeunload",this.beforeUnloadHandler),this.beforeUnloadHandler=null),this.persistManager.destroy()}}, _class8);var ee=class{constructor(e){this.pluginManager=e}initialize(){this.pluginManager.setupAll()}beforeValidate(e){return this.pluginManager.beforeValidate(e)}afterValidate(e){return this.pluginManager.afterValidate(e)}beforeSubmit(e){return this.pluginManager.beforeSubmit(e)}afterSubmit(e){return this.pluginManager.afterSubmit(e)}onFieldChange(e){this.pluginManager.onFieldChange(e)}reportOperationalError(e){return this.pluginManager.reportError(e.source,e.error,e.payload)}destroy(){this.pluginManager.destroy()}};function Pi(){if(typeof globalThis>"u")return;let s;try{s=_nullishCoalesce(globalThis.localStorage, () => (void 0))}catch (e2){return}if(s){try{let e="__bit_form_storage_test__";s.setItem(e,"1"),s.removeItem(e)}catch (e3){return}return{getItem:e=>{try{return s.getItem(e)}catch (e4){return null}},setItem:(e,t)=>{try{s.setItem(e,t)}catch (e5){throw new Error("BitStore: storage quota exceeded or unavailable")}},removeItem:e=>{try{s.removeItem(e)}catch (e6){}}}}}function Ei(s){let e=new WeakSet;return JSON.stringify(s,(t,i)=>{if(typeof i=="object"&&i!==null){if(e.has(i))return"[Circular]";e.add(i)}return i})}var te= (_class9 =class{constructor(e,t,i,r,n={}){;_class9.prototype.__init30.call(this);_class9.prototype.__init31.call(this);_class9.prototype.__init32.call(this);_class9.prototype.__init33.call(this);this.config=e;this.getValues=t;this.getDirtyValues=i;this.applyRestoredValues=r;this.callbacks=n}__init30() {this.writeQueue=Promise.resolve()}__init31() {this.activeWrites=0}__init32() {this.isDestroyed=!1}__init33() {this.lastWriteError=null}getStorage(){return this.config.storage||Pi()}canPersist(){return!!(this.config.enabled&&this.config.key&&this.getStorage())}handleError(e){_optionalChain([this, 'access', _99 => _99.callbacks, 'access', _100 => _100.onError, 'optionalCall', _101 => _101(e)]),_optionalChain([this, 'access', _102 => _102.config, 'access', _103 => _103.onError, 'optionalCall', _104 => _104(e)])}enqueueWriteOperation(e){this.activeWrites+=1;try{this.activeWrites===1&&_optionalChain([this, 'access', _105 => _105.callbacks, 'access', _106 => _106.onWriteStart, 'optionalCall', _107 => _107()])}catch(r){throw this.activeWrites=Math.max(0,this.activeWrites-1),r}let t=this.writeQueue.then(e,e);return this.writeQueue=t.then(()=>{},()=>{}),t.then(()=>({ok:!0,error:void 0}),r=>({ok:!1,error:r})).then(r=>{if(this.activeWrites=Math.max(0,this.activeWrites-1),r.ok){if(this.lastWriteError=null,this.activeWrites===0)try{_optionalChain([this, 'access', _108 => _108.callbacks, 'access', _109 => _109.onWriteSuccess, 'optionalCall', _110 => _110()])}finally{_optionalChain([this, 'access', _111 => _111.callbacks, 'access', _112 => _112.onWriteSettled, 'optionalCall', _113 => _113()])}return}this.lastWriteError=r.error;try{_optionalChain([this, 'access', _114 => _114.callbacks, 'access', _115 => _115.onWriteError, 'optionalCall', _116 => _116(r.error)])}finally{this.activeWrites===0&&_optionalChain([this, 'access', _117 => _117.callbacks, 'access', _118 => _118.onWriteSettled, 'optionalCall', _119 => _119()])}throw r.error})}serialize(e){let t=this.config.serialize;return t===JSON.stringify||!t?Ei(e):t(e)}async persistPayload(){let e=this.getStorage();if(!e)return;let t=this.config.mode==="dirtyValues"?this.getDirtyValues():this.getValues(),i=this.serialize(t);await e.setItem(this.config.key,i)}async saveNow(){this.canPersist()&&await this.enqueueWriteOperation(async()=>{try{await this.persistPayload()}catch(e){throw this.handleError(e),e}})}queueSave(){!this.canPersist()||!this.config.autoSave||(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,!this.isDestroyed&&this.saveNow().catch(()=>{})},this.config.debounceMs))}async restore(){if(this.isDestroyed||!this.canPersist())return!1;let e=this.getStorage();if(!e)return!1;try{let t=await e.getItem(this.config.key);if(this.isDestroyed||!t)return!1;let i=this.config.deserialize(t);return this.isDestroyed||!i||typeof i!="object"||Array.isArray(i)||this.isDestroyed?!1:(this.applyRestoredValues(i),!0)}catch(t){try{let i=this.getStorage();i&&await i.removeItem(this.config.key)}catch (e7){}throw this.handleError(t),t}}async clear(){if(!this.canPersist())return;this.timer&&(clearTimeout(this.timer),this.timer=void 0);let e=this.getStorage();e&&await this.enqueueWriteOperation(async()=>{try{await e.removeItem(this.config.key)}catch(t){throw this.handleError(t),t}})}destroy(){this.isDestroyed=!0,this.timer&&(clearTimeout(this.timer),this.timer=void 0)}}, _class9);var ie= (_class10 =class{constructor(e,t){;_class10.prototype.__init34.call(this);_class10.prototype.__init35.call(this);_class10.prototype.__init36.call(this);_class10.prototype.__init37.call(this);this.plugins=e;this.contextFactory=t}__init34() {this.teardownFns=[]}__init35() {this.notifyingError=!1}__init36() {this.pendingErrorQueue=[]}__init37() {this.cachedContext=null}setupAll(){let e=this.getContext();this.plugins.forEach(t=>{if(t.setup)try{let i=t.setup(e);typeof i=="function"&&this.teardownFns.push(i)}catch(i){this.reportError("setup",i,void 0,t.name)}})}async beforeValidate(e){await this.emitHook("beforeValidate",e)}async afterValidate(e){await this.emitHook("afterValidate",e)}async beforeSubmit(e){await this.emitHook("beforeSubmit",e)}async afterSubmit(e){await this.emitHook("afterSubmit",e)}onFieldChange(e){let t=this.getContext();this.plugins.forEach(i=>{let r=_optionalChain([i, 'access', _120 => _120.hooks, 'optionalAccess', _121 => _121.onFieldChange]);if(r)try{let n=r(e,t);Promise.resolve(n).catch(o=>{this.reportError("onFieldChange",o,e,i.name)})}catch(n){this.reportError("onFieldChange",n,e,i.name)}})}async reportError(e,t,i,r){if(this.pendingErrorQueue.push({source:e,pluginName:r,error:t,event:i}),!this.notifyingError){this.notifyingError=!0;try{for(;this.pendingErrorQueue.length>0;){let n=this.pendingErrorQueue.shift();if(!n)break;let o=this.contextFactory().getState(),a={source:n.source,pluginName:n.pluginName,error:n.error,event:n.event,values:o.values,state:o},l=!1;for(let c of this.plugins){let u=_optionalChain([c, 'access', _122 => _122.hooks, 'optionalAccess', _123 => _123.onError]);if(u){l=!0;try{await u(a,this.contextFactory())}catch (e8){}}}!l&&typeof console<"u"&&console.error&&console.error("BitForm: plugin error without onError handler",a.source,a.error)}}finally{this.notifyingError=!1}if(this.pendingErrorQueue.length>0){this.notifyingError=!0;try{for(;this.pendingErrorQueue.length>0;){let n=this.pendingErrorQueue.shift();if(!n)break;let o=this.contextFactory().getState(),a={source:n.source,pluginName:n.pluginName,error:n.error,event:n.event,values:o.values,state:o};for(let l of this.plugins){let c=_optionalChain([l, 'access', _124 => _124.hooks, 'optionalAccess', _125 => _125.onError]);if(c)try{await c(a,this.contextFactory())}catch (e9){}}}}finally{this.notifyingError=!1}}}}destroy(){for(let e=this.teardownFns.length-1;e>=0;e-=1){let t=this.teardownFns[e];try{t()}catch(i){this.reportError("teardown",i)}}this.teardownFns=[],this.cachedContext=null}async emitHook(e,t){let i=this.getContext();for(let r of this.plugins){let n=_optionalChain([r, 'access', _126 => _126.hooks, 'optionalAccess', _127 => _127[e]]);if(n)try{await n(t,i)}catch(o){await this.reportError(e,o,t,r.name)}}}getContext(){return this.cachedContext||(this.cachedContext=this.contextFactory()),this.cachedContext}}, _class10);var Me=typeof globalThis<"u"?globalThis:typeof global<"u"?global:window,rt=typeof window>"u"&&typeof process<"u"&&typeof process.env<"u";!rt&&!Me.__BIT_FORM__&&(Me.__BIT_FORM__={stores:{},listeners:new Set,dispatch(s,e){this.listeners.forEach(t=>{try{t(s,e)}catch(i){typeof console<"u"&&console.warn&&console.warn("[bit-form] Bus listener error:",i)}})},subscribe(s){return this.listeners.add(s),()=>{this.listeners.delete(s)}}});var Re=rt?st():Me.__BIT_FORM__,xi={stores:{},listeners:new Set,dispatch:()=>{},subscribe:()=>()=>{}};function Oe(){return xi}function st(){let s=new Set;return{stores:{},listeners:s,dispatch(e,t){s.forEach(i=>{try{i(e,t)}catch (e10){}})},subscribe(e){return s.add(e),()=>s.delete(e)}}}function Ci(s){return s.bus?!0:typeof s.devTools=="boolean"?s.devTools:s.devTools&&typeof s.devTools=="object"?s.devTools.enabled!==!1:!1}function nt(s){let{storeId:e,storeBusPort:t,config:i,getState:r,getConfig:n,getValues:o,getDirtyValues:a,applyPersistedValues:l,setPersistMetadata:c}=s,u=new te(i.persist,o,a,l,{onWriteStart:()=>_optionalChain([c, 'optionalCall', _128 => _128({isSaving:!0,error:null})]),onWriteSuccess:()=>_optionalChain([c, 'optionalCall', _129 => _129({isSaving:!1,error:null})]),onWriteError:T=>_optionalChain([c, 'optionalCall', _130 => _130({error:T instanceof Error?T:new Error(String(T))})]),onWriteSettled:()=>_optionalChain([c, 'optionalCall', _131 => _131({isSaving:!1})]),onError:T=>i.onUnhandledError(T,"persist")}),d=Ci(i),p=typeof process<"u"&&typeof process.env<"u"&&process.env.VITEST==="true",h=d?_nullishCoalesce(i.bus, () => ((p?Oe():Re))):Oe(),f=new ie([...i.plugins],()=>({storeId:e,getState:()=>_chunkOWDDAM6Ccjs.a.call(void 0, r()),getConfig:()=>_chunkOWDDAM6Ccjs.a.call(void 0, n()),bus:h})),S=new X,g=!1,y=new Z(u);S.register({name:"persist",onStateUpdated:(T,mi)=>y.onStateUpdated(T,mi),initialize:()=>y.initialize(),restorePersisted:async()=>{if(g)return!1;let T=await y.restorePersisted();return g?!1:T},savePersistedNow:()=>y.savePersistedNow(),clearPersisted:()=>y.clearPersisted(),destroy:()=>{g=!0,y.destroy()}});let b=new ee(f);S.register({name:"plugins",initialize:()=>b.initialize(),beforeValidate:T=>b.beforeValidate(T),afterValidate:T=>b.afterValidate(T),beforeSubmit:T=>b.beforeSubmit(T),afterSubmit:T=>b.afterSubmit(T),onFieldChange:T=>b.onFieldChange(T),reportOperationalError:T=>b.reportOperationalError(T),destroy:()=>b.destroy()});let E=new Q(e,h,d,t);S.register({name:"bus",attachStorePort:T=>E.attachStorePort(T),initialize:()=>E.initialize(),onStateUpdated:T=>E.onStateUpdated(T),destroy:()=>E.destroy()});let R=new Y(S);try{R.initialize()}catch(T){console.error("BitStoreEffects: initialize() failed \u2014 store will operate without initialized effects",T)}return R}function B(s,e,t){return{kind:"state.patch",partialState:s,changedPaths:e,skipComputed:_optionalChain([t, 'optionalAccess', _132 => _132.skipComputed])}}function je(s){return{kind:"field.touchMany",paths:s}}function re(s){return{kind:"form.persistMeta",patch:s}}function se(s,e){return{kind:"validation.commit",errors:s,isValid:e}}var ot=new WeakMap,at=new WeakMap;function Vi(s){let{dispatch:e}=s,t=ot,i=at,r=_nullishCoalesce(t.get(e), () => (0));t.set(e,r+1),r===0&&(i.set(e,null),e(re({isRestoring:!0,error:null})))}function Fi(s){let{dispatch:e,error:t}=s,i=ot,r=at,n=_nullishCoalesce(i.get(e), () => (0));if(n<=0)return;let o=n-1;if(t&&r.set(e,t),o>0){i.set(e,o);let l=_nullishCoalesce(r.get(e), () => (null));l&&e(re({error:l}));return}i.delete(e),t||r.set(e,null);let a=_nullishCoalesce(r.get(e), () => (null));r.delete(e),e(re({isRestoring:!1,error:a}))}async function lt(s){let{dispatch:e,effects:t,onUnhandledError:i}=s;Vi({dispatch:e,type:"restoring"});let r=null;try{return await t.restorePersisted()}catch(n){return r=n instanceof Error?n:new Error(String(n)),_optionalChain([i, 'optionalCall', _133 => _133(r,"persist")]),!1}finally{Fi({dispatch:e,type:"restoring",error:r})}}async function dt(s){let{effects:e,onUnhandledError:t}=s;try{await e.savePersistedNow()}catch(i){throw _optionalChain([t, 'optionalCall', _134 => _134(i,"persist")]),i}}async function ct(s){let{effects:e,onUnhandledError:t}=s;try{await e.clearPersisted()}catch(i){throw _optionalChain([t, 'optionalCall', _135 => _135(i,"persist")]),i}}function ut(s){let{values:e,state:t,initialValues:i,validation:r,fieldRegistry:n,dirtyManager:o,dispatch:a,saveHistorySnapshot:l}=s,c=_chunkOWDDAM6Ccjs.a.call(void 0, _chunkOWDDAM6Ccjs.b.call(void 0, _chunkOWDDAM6Ccjs.a.call(void 0, t.values),e));r.cancelAll(),n.evaluateAll(c);let u=o.rebuild(c,i);a(B({values:c,errors:{},touched:{},isValidating:{},persist:{...t.persist,error:null},isValid:!1,isDirty:u})),l(),r.validate().catch(d=>{console.error("BitStore: post-persist validation failed \u2014 form values persisted but validation error may be stale",d)})}function pt(s){let{state:e,path:t}=s,i=`${t}.`,r={...e.errors},n={...e.touched},o=!1;for(let a of Object.keys(r))(a===t||a.startsWith(i))&&(delete r[a],o=!0);for(let a of Object.keys(n))(a===t||a.startsWith(i))&&(delete n[a],o=!0);return o?{errors:r,touched:n}:null}function ne(s){let e=[],t=new Map,i=new Set(s.map(a=>a.path));for(let a of s)if(t.has(a.path)||t.set(a.path,new Set),a.dependsOn)for(let l of a.dependsOn)i.has(l)&&t.get(a.path).add(l);let r=new Set,n=new Set,o=(a,l)=>{r.add(a),n.add(a),l.push(a);let c=t.get(a)||new Set;for(let u of c)if(r.has(u)){if(n.has(u)){let d=l.indexOf(u),p=[...l.slice(d),u];return n.delete(a),{cycle:p,paths:Array.from(t.keys()).filter(h=>p.includes(h)),message:`Circular dependency detected: ${p.join(" \u2192 ")}. Check your computed field definitions.`}}}else{let d=o(u,l);if(d)return n.delete(a),d}return n.delete(a),l.pop(),null};for(let a of t.keys())if(!r.has(a)){let l=o(a,[]);l&&!e.some(c=>c.message===l.message)&&e.push(l)}return e}function ht(s){return!!(_optionalChain([s, 'optionalAccess', _136 => _136.computed])||_optionalChain([s, 'optionalAccess', _137 => _137.normalize]))}function ft(s){let{path:e,config:t,state:i,fieldRegistry:r,subscriptions:n,validationCleanupField:o,stateReader:a,invalidateFieldIndexes:l,dispatch:c,getState:u,onUnhandledError:d}=s,p=r.getFieldConfig(e),h=_optionalChain([p, 'optionalAccess', _138 => _138.validation, 'optionalAccess', _139 => _139.asyncValidate]),f=_optionalChain([t, 'access', _140 => _140.validation, 'optionalAccess', _141 => _141.asyncValidate]),S=_nullishCoalesce(_optionalChain([p, 'optionalAccess', _142 => _142.validation, 'optionalAccess', _143 => _143.asyncValidateOn]), () => ("blur")),g=_nullishCoalesce(_optionalChain([t, 'access', _144 => _144.validation, 'optionalAccess', _145 => _145.asyncValidateOn]), () => ("blur"));p&&h&&(f!==h||g!==S)&&o(e);let b=!!(_optionalChain([p, 'optionalAccess', _146 => _146.computed])||t.computed),E=ht(p)||ht(t);if(r.register(e,t,i.values),l(),b){let T=ne(r.getComputedEntries(i.values));if(T.length>0){p?r.register(e,p,i.values):r.unregister(e),l(),n.invalidatePathExpansionCache(e),a.invalidatePath(e),d(new Error(T[0].message),"computed");return}}n.invalidatePathExpansionCache(e),a.invalidatePath(e),E&&c(B({values:i.values},["*"]));let R=u();t.scope&&n.notify(R,[_chunkRHMJPKNVcjs.d.call(void 0, t.scope)]),r.isHidden(e)&&n.notify(R,[e])}function gt(s){let{path:e,state:t,hasStaticConfig:i,fieldRegistry:r,subscriptions:n,validationCleanupField:o,invalidateFieldIndexes:a,dispatch:l}=s;if(i)return;let c=r.getFieldConfig(e);o(e),r.unregister(e),a(),n.invalidatePathExpansionCache(e),_optionalChain([c, 'optionalAccess', _147 => _147.scope])&&n.notify(t,[_chunkRHMJPKNVcjs.d.call(void 0, c.scope)]);let u=pt({state:t,path:e});u&&l(B({errors:u.errors,touched:u.touched}))}function oe(s){let{prefix:e,state:t,fieldRegistry:i,subscriptions:r,validationCleanupPrefix:n,invalidateFieldIndexes:o,dispatch:a,hasStaticConfigPath:l}=s;n(e);let c=F(e),u=_nullishCoalesce(l, () => ((()=>!1))),d=[];i.forEachFieldConfig((y,b)=>{x(b,c)&&(u(b)||d.push(b))});let p=[];d.forEach(y=>{let b=i.getFieldConfig(y);b&&(i.unregister(y),p.push([y,b]))}),o(),r.invalidatePathExpansionCache(e),new Set(p.map(([,y])=>y.scope).filter(y=>!!y)).forEach(y=>{r.notify(t,[_chunkRHMJPKNVcjs.d.call(void 0, y)])});let f={...t.errors},S={...t.touched},g=!1;for(let[y]of p)f[y]&&(delete f[y],g=!0),S[y]&&(delete S[y],g=!0);g&&a(B({errors:f,touched:S}))}var wi="subscription",ae= (_class11 =class{constructor(e,t,i=500){;_class11.prototype.__init38.call(this);_class11.prototype.__init39.call(this);_class11.prototype.__init40.call(this);_class11.prototype.__init41.call(this);_class11.prototype.__init42.call(this);_class11.prototype.__init43.call(this);_class11.prototype.__init44.call(this);_class11.prototype.__init45.call(this);_class11.prototype.__init46.call(this);_class11.prototype.__init47.call(this);this.getState=e;if(typeof t=="function"){this.onError=t,this.MAX_PATH_EXPANSION_CACHE_SIZE=i;return}this.MAX_PATH_EXPANSION_CACHE_SIZE=_nullishCoalesce(t, () => (i))}__init38() {this.listeners=new Set}__init39() {this.pathScopedSubscriptions=new Map}__init40() {this.pathSelectorIndex=new Map}__init41() {this.pathExpansionCache=new Map}__init42() {this.subscriptionSeenVersion=new Map}__init43() {this.notifyVersion=0}__init44() {this.cacheHits=0}__init45() {this.cacheMisses=0}__init46() {this.cacheEvictions=0}subscribe(e){return this.isDestroyed?()=>{}:(this.listeners.add(e),()=>{this.listeners.delete(e)})}subscribeSelector(e,t,i,r){if(this.isDestroyed)return()=>{};let n=e(this.getState()),o={notify:l=>{try{let c=e(l);if(r(n,c))return;n=c,t(c)}catch(c){this.reportError(c)}}},a=this.normalizeSubscriptionPaths(i.paths);if(this.pathScopedSubscriptions.set(o,a),a.forEach(l=>{this.forEachIndexPath(l,c=>{let u=_nullishCoalesce(this.pathSelectorIndex.get(c), () => (new Set));u.add(o),this.pathSelectorIndex.set(c,u)})}),i.emitImmediately)try{t(n)}catch(l){this.reportError(l)}return()=>{this.subscriptionSeenVersion.delete(o);let l=this.pathScopedSubscriptions.get(o);l&&(l.forEach(c=>{this.forEachIndexPath(c,u=>{let d=this.pathSelectorIndex.get(u);d&&(d.delete(o),d.size===0&&this.pathSelectorIndex.delete(u))})}),this.pathScopedSubscriptions.delete(o))}}notify(e,t){for(let n of Array.from(this.listeners))try{n()}catch(o){this.reportError(o)}if(this.pathScopedSubscriptions.size===0)return;let i=this.normalizeChangedPathIterable(t);if(i.length===0||i.includes("*")){this.notifyScopedSubscribers(Array.from(this.pathScopedSubscriptions.keys()),e);return}if(i.length===1&&this.isSimplePath(i[0])){let n=this.collectSubscribersForSingleChangedPath(i[0]);this.notifyScopedSubscribers(n,e);return}let r=this.collectSubscribersForChangedPaths(i);this.notifyScopedSubscribers(r,e)}notifyScopedSubscribers(e,t){for(let i of e)try{i.notify(t)}catch(r){this.reportError(r)}}reportError(e){try{if(this.onError){this.onError(e,wi);return}console.error("Subscription listener error:",e)}catch (e11){}}__init47() {this.isDestroyed=!1}destroy(){this.isDestroyed=!0,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(e){if(!e){this.pathExpansionCache.clear();return}let t=F(e);if(t.length===0){this.pathExpansionCache.clear();return}for(let i of this.pathExpansionCache.keys())(x(i,t)||x(t,i))&&this.pathExpansionCache.delete(i)}normalizeSubscriptionPaths(e){if(!e||e.length===0)return["*"];let t=new Set,i=[];for(let r of e){if(r==null)continue;let n=r.trim();n.length===0||t.has(n)||(t.add(n),i.push(n))}return i}normalizeChangedPathIterable(e){if(!e)return[];let t=new Set,i=[];for(let r of e){if(r==null)continue;let n=r.trim();n.length===0||t.has(n)||(t.add(n),i.push(n))}return i}collectSubscribersForChangedPaths(e){let t=[];this.notifyVersion=this.notifyVersion+1|0;let i=this.notifyVersion,r=n=>{let o=this.pathSelectorIndex.get(n);o&&o.forEach(a=>{(_nullishCoalesce(this.subscriptionSeenVersion.get(a), () => (Number.NaN)))!==i&&(this.subscriptionSeenVersion.set(a,i),t.push(a))})};return e.forEach(n=>{this.forEachLookupPath(n,r)}),t}collectSubscribersForSingleChangedPath(e){let t=[];this.notifyVersion=this.notifyVersion+1|0;let i=this.notifyVersion,r=n=>{let o=this.pathSelectorIndex.get(n);o&&o.forEach(a=>{(_nullishCoalesce(this.subscriptionSeenVersion.get(a), () => (Number.NaN)))!==i&&(this.subscriptionSeenVersion.set(a,i),t.push(a))})};return this.forEachLookupPath(e,r),t}expandChangedPathForLookup(e){return this.expandPathGeneric(e)}expandPathForIndexing(e){return this.expandPathGeneric(e)}forEachIndexPath(e,t){if(!this.isSimplePath(e)){this.expandPathForIndexing(e).forEach(t);return}let i=e.split("."),r="";for(let n=0;n<i.length;n+=1)r=r?`${r}.${i[n]}`:i[n],t(r)}forEachLookupPath(e,t){if(!this.isSimplePath(e)){this.expandChangedPathForLookup(e).forEach(t);return}t(e);let i=e.lastIndexOf(".");for(;i>-1;)t(e.slice(0,i)),i=e.lastIndexOf(".",i-1)}isSimplePath(e){return!e.includes("*")&&!e.includes("[")&&!e.includes("]")}expandPathGeneric(e){let t=this.pathExpansionCache.get(e);if(t)return this.cacheHits+=1,t;this.cacheMisses+=1;let i=e.split("."),r=[];for(let n=1;n<=i.length;n++)r.push(i.slice(0,n).join("."));return this.setBoundedCacheEntry(this.pathExpansionCache,e,r,this.MAX_PATH_EXPANSION_CACHE_SIZE),r}setBoundedCacheEntry(e,t,i,r){if(e.size>=r){let n=e.keys().next().value;n!==void 0&&(e.delete(n),this.cacheEvictions+=1)}e.set(t,i)}}, _class11);var le= (_class12 =class{constructor(e){;_class12.prototype.__init48.call(this);this.store=e}__init48() {this.pathIds=new Map}getItemIds(e,t){let i=typeof t=="number"&&Number.isFinite(t)?Math.max(0,t):this.getCurrentArrayLength(e);return[...this.ensureIds(e,i)]}pushItem(e,t){this.withPathIds(e,o=>(o.push(this.store.createArrayItemId(e,o.length)),o));let i=this.getCurrentArrayLength(e);_optionalChain([this, 'access', _148 => _148.store, 'access', _149 => _149.unregisterPrefix, 'optionalCall', _150 => _150(C(e,i))]);let r=_chunkOWDDAM6Ccjs.f.call(void 0, this.store.getState().values,e),n=Array.isArray(r)?[...r]:[];n.push(t),this.commitArrayMutationWithFieldPipeline({path:e,nextArray:n,meta:{origin:"array",operation:"push"},reindex:o=>o})}prependItem(e,t){this.withPathIds(e,n=>(n.unshift(this.store.createArrayItemId(e,0)),n)),_optionalChain([this, 'access', _151 => _151.store, 'access', _152 => _152.unregisterPrefix, 'optionalCall', _153 => _153(C(e))]);let i=_chunkOWDDAM6Ccjs.f.call(void 0, this.store.getState().values,e),r=Array.isArray(i)?[...i]:[];r.unshift(t),this.commitArrayMutationWithFieldPipeline({path:e,nextArray:r,meta:{origin:"array",operation:"prepend"},reindex:n=>n+1})}insertItem(e,t,i){let r=this.getCurrentArrayLength(e),n=Math.max(0,Math.min(t,r));if(this.withPathIds(e,l=>{let c=[...l];return c.splice(n,0,this.store.createArrayItemId(e,n)),c}),this.store.unregisterPrefix)for(let l=n;l<r;l++)this.store.unregisterPrefix(C(e,l));let o=_chunkOWDDAM6Ccjs.f.call(void 0, this.store.getState().values,e),a=Array.isArray(o)?[...o]:[];a.splice(n,0,i),this.commitArrayMutationWithFieldPipeline({path:e,nextArray:a,meta:{origin:"array",operation:"insert",index:n},reindex:l=>l<n?l:l+1})}removeItem(e,t){let i=this.store.getState(),r=_chunkOWDDAM6Ccjs.f.call(void 0, i.values,e);if(!Array.isArray(r)||t<0||t>=r.length)return;this.withPathIds(e,o=>{let a=[...o];return a.splice(t,1),a}),this.store.unregisterPrefix&&this.store.unregisterPrefix(C(e,t));let n=r.filter((o,a)=>a!==t);this.commitArrayMutationWithFieldPipeline({path:e,nextArray:n,meta:{origin:"array",operation:"remove",index:t},reindex:o=>o===t?null:o>t?o-1:o})}swapItems(e,t,i){let r=this.store.getState(),n=_chunkOWDDAM6Ccjs.f.call(void 0, r.values,e);if(!Array.isArray(n)||t<0||t>=n.length||i<0||i>=n.length)return;this.withPathIds(e,a=>{let l=[...a];return[l[t],l[i]]=[l[i],l[t]],l});let o=[...n];[o[t],o[i]]=[o[i],o[t]],this.store.unregisterPrefix&&(this.store.unregisterPrefix(C(e,t)),this.store.unregisterPrefix(C(e,i))),this.commitArrayMutationWithFieldPipeline({path:e,nextArray:o,meta:{origin:"array",operation:"swap",from:t,to:i},reindex:a=>a===t?i:a===i?t:a})}moveItem(e,t,i){let r=this.store.getState(),n=_chunkOWDDAM6Ccjs.f.call(void 0, r.values,e);if(!Array.isArray(n)||t<0||t>=n.length||i<0||i>=n.length)return;this.withPathIds(e,l=>{let c=[...l],[u]=c.splice(t,1);return c.splice(i,0,u),c});let o=[...n],[a]=o.splice(t,1);if(o.splice(i,0,a),this.store.unregisterPrefix){let l=Math.min(t,i),c=Math.max(t,i);for(let u=l;u<=c;u+=1)this.store.unregisterPrefix(C(e,u))}this.commitArrayMutationWithFieldPipeline({path:e,nextArray:o,meta:{origin:"array",operation:"move",from:t,to:i},reindex:l=>l===t?i:t<i&&l>t&&l<=i?l-1:t>i&&l>=i&&l<t?l+1:l})}replaceItems(e,t){Array.isArray(t)&&(_optionalChain([this, 'access', _154 => _154.store, 'access', _155 => _155.unregisterPrefix, 'optionalCall', _156 => _156(C(e))]),t.length===0?this.pathIds.delete(e):this.pathIds.set(e,t.map((i,r)=>this.store.createArrayItemId(e,r))),this.commitArrayMutationWithFieldPipeline({path:e,nextArray:t,meta:{origin:"array",operation:"replace"},reindex:i=>i<t.length?i:null}))}clearItems(e){this.pathIds.delete(e),this.store.unregisterPrefix&&this.store.unregisterPrefix(C(e)),this.commitArrayMutationWithFieldPipeline({path:e,nextArray:[],meta:{origin:"array",operation:"clear"},reindex:()=>null})}mutateArrayWithSetField(e,t,i){let r=_chunkOWDDAM6Ccjs.f.call(void 0, this.store.getState().values,e)||[];this.store.setFieldWithMeta(e,t(r),i),this.store.internalSaveSnapshot()}withPathIds(e,t){let i=this.getCurrentArrayLength(e),r=this.ensureIds(e,i),n=t(r);n.length===0?this.pathIds.delete(e):this.pathIds.set(e,n)}ensureIds(e,t){let i=_nullishCoalesce(this.pathIds.get(e), () => ([]));if(i.length===t)return i;if(i.length<t){let n=[...i];for(let o=i.length;o<t;o+=1)n.push(this.store.createArrayItemId(e,o));return this.pathIds.set(e,n),n}let r=i.slice(0,t);return r.length===0?this.pathIds.delete(e):this.pathIds.set(e,r),r}getCurrentArrayLength(e){let t=_chunkOWDDAM6Ccjs.f.call(void 0, this.store.getState().values,e);return Array.isArray(t)?t.length:0}commitArrayMutationWithFieldPipeline(e){let{path:t,nextArray:i,meta:r,reindex:n}=e,o=this.store.getState();this.store.setFieldWithMeta(t,i,r);let a=_chunkOWDDAM6Ccjs.k.call(void 0, o,t,n);_optionalChain([this, 'access', _157 => _157.store, 'access', _158 => _158.remapValidationPaths, 'optionalCall', _159 => _159(t,n)]),this.store.dispatch(B({errors:a.errors,touched:a.touched,isValidating:a.isValidating},[t])),this.store.internalSaveSnapshot()}}, _class12);var de=class{constructor(e,t,i){this.getState=e;this.dispatch=t;this.reportError=i}reportInvalidInput(e,t){_optionalChain([this, 'access', _160 => _160.reportError, 'optionalCall', _161 => _161(new Error(t===void 0?e:`${e}: ${String(t)}`))])}setError(e,t){if(!e||typeof e!="string"){this.reportInvalidInput("setError received an invalid path",e);return}if(t!==void 0&&typeof t!="string"){this.reportInvalidInput("setError received an invalid message",t);return}let i={...this.getState().errors,[e]:t};t===void 0&&delete i[e],this.dispatch(B({errors:i}))}setErrors(e){if(!e||typeof e!="object"){this.reportInvalidInput("setErrors received an invalid payload");return}let t={};Object.entries(e).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}t[i]=r}),this.dispatch(B({errors:{...this.getState().errors,...t}}))}setServerErrors(e,t){if(!e)return;let i=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _162 => _162.arrayStrategy]), () => ("first")),r=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _163 => _163.joinSeparator]), () => ("; ")),n={};for(let[o,a]of Object.entries(e)){if(!o){this.reportInvalidInput("setServerErrors ignored an empty path");continue}if(Array.isArray(a)){let l=a.filter(c=>typeof c=="string"&&c.length>0);if(l.length===0)continue;n[o]=i==="join"?l.join(r):l[0];continue}n[o]=a!==void 0?a:void 0}this.setErrors(n)}};var ce= (_class13 =class{constructor(e,t,i){;_class13.prototype.__init49.call(this);this.fieldMetadataProvider=e;this.getState=t;this.isPathDirty=i}__init49() {this.requiredValuesRef=null}isHidden(e){return this.fieldMetadataProvider.isHidden(e)}isRequired(e){let t=this.getState().values;return this.requiredValuesRef!==t&&(this.requiredValuesRef=t),this.fieldMetadataProvider.isRequired(e,t)}isFieldDirty(e){return this.isPathDirty(e)}isFieldValidating(e){return!!this.getState().isValidating[e]}isTouched(e){return!!this.getState().touched[e]}}, _class13);function yt(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp)}function mt(s,e){let t=[],i=new Map,r=(n,o,a,l,c)=>{if(!(l&&c&&_chunkOWDDAM6Ccjs.d.call(void 0, n,o))){if(n!==null&&typeof n=="object"&&o!==null&&typeof o=="object"){let u=i.get(n);if(_optionalChain([u, 'optionalAccess', _164 => _164.has, 'call', _165 => _165(o)]))return;u?u.add(o):i.set(n,new Set([o]))}try{if(yt(n)&&yt(o)&&l&&c){let u=new Set([...Object.keys(n),...Object.keys(o)]);for(let d of u){let p=a?`${a}.${d}`:d,h=Object.prototype.hasOwnProperty.call(n,d),f=Object.prototype.hasOwnProperty.call(o,d);r(n[d],o[d],p,h,f)}return}t.push({path:a,previousValue:_chunkOWDDAM6Ccjs.a.call(void 0, n),nextValue:_chunkOWDDAM6Ccjs.a.call(void 0, o),hadPreviousValue:l,hasNextValue:c})}finally{if(n!==null&&typeof n=="object"&&o!==null&&typeof o=="object"){let u=i.get(n);_optionalChain([u, 'optionalAccess', _166 => _166.delete, 'call', _167 => _167(o)]),u&&u.size===0&&i.delete(n)}}}};return r(s,e,"",!0,!0),{operations:t}}function ue(s,e,t){let i=s,r=[],n=[];for(let o of e.operations){let a=t==="undo"?o.hadPreviousValue:o.hasNextValue,l=t==="undo"?o.previousValue:o.nextValue;if(!o.path){i=a?l:{},r.length=0,n.length=0;continue}if(a){r.push([o.path,l]);continue}n.push(o.path)}return r.length>0&&(i=_chunkOWDDAM6Ccjs.h.call(void 0, i,r)),n.length>0&&(i=_chunkOWDDAM6Ccjs.i.call(void 0, i,n)),i}var pe= (_class14 =class{constructor(e,t){;_class14.prototype.__init50.call(this);_class14.prototype.__init51.call(this);_class14.prototype.__init52.call(this);_class14.prototype.__init53.call(this);_class14.prototype.__init54.call(this);_class14.prototype.__init55.call(this);_class14.prototype.__init56.call(this);this.enableHistory=e;this.maxHistory=t}__init50() {this.baseSnapshot=null}__init51() {this.currentSnapshot=null}__init52() {this.patches=[]}__init53() {this.historyIndex=-1}__init54() {this.historySize=0}__init55() {this.pendingUndo=null}__init56() {this.pendingRedo=null}saveSnapshot(e){if(!this.enableHistory)return;if(!this.currentSnapshot||this.baseSnapshot===null){this.reset(e);return}let t=mt(this.currentSnapshot,e);if(t.operations.length!==0)for(this.historyIndex<this.historySize-1&&(this.patches.splice(this.historyIndex),this.historySize=this.historyIndex+1),this.patches.push(t),this.currentSnapshot=e,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 e=this.historyIndex-1;if(e>=this.patches.length)return null;let t=this.patches[e],i=ue(_chunkOWDDAM6Ccjs.a.call(void 0, this.currentSnapshot),t,"undo");return this.pendingUndo=i,i}commitUndo(){this.pendingUndo!==null&&(this.currentSnapshot=this.pendingUndo,this.historyIndex-=1,this.pendingUndo=null)}rollbackUndo(){this.pendingUndo=null}redo(){if(!this.canRedo||!this.currentSnapshot)return null;let e=this.historyIndex;if(e>=this.patches.length)return null;let t=this.patches[e],i=ue(_chunkOWDDAM6Ccjs.a.call(void 0, this.currentSnapshot),t,"redo");return this.pendingRedo=i,i}commitRedo(){this.pendingRedo!==null&&(this.currentSnapshot=this.pendingRedo,this.historyIndex+=1,this.pendingRedo=null)}rollbackRedo(){this.pendingRedo=null}reset(e){if(!this.enableHistory){this.baseSnapshot=null,this.currentSnapshot=null,this.patches=[],this.historyIndex=-1,this.historySize=0;return}this.baseSnapshot=_chunkOWDDAM6Ccjs.a.call(void 0, e),this.currentSnapshot=_chunkOWDDAM6Ccjs.a.call(void 0, e),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(){if(this.patches.length===0||this.baseSnapshot===null)return;let e=this.patches[0];e&&(this.baseSnapshot=ue(this.baseSnapshot,e,"redo"),this.patches.shift(),this.historySize=Math.max(1,this.historySize-1),this.historyIndex=Math.max(0,this.historyIndex-1))}getCapacity(){return Math.max(2,this.maxHistory)}}, _class14);function He(s,e,t){if(!Object.prototype.hasOwnProperty.call(s,e))return[s,t];let r=s,n=t;return n||(r={...s},n=!0),delete r[e],[r,n]}var M=class{constructor(e){this.steps=e}async run(e){for(let t of this.steps){if(e.halted)break;await t.run(e)}}},he=class{constructor(e){this.steps=e}run(e){for(let t of this.steps){if(e.halted)break;let i=t.run(e);if(i!=null&&typeof i.then=="function")throw new Error(`BitSyncPipelineRunner: step "${t.name}" returned a Promise. Use BitPipelineRunner for async steps.`)}}};var fe=class{constructor(e){this.store=e;this.fieldUpdatePipeline=new he([{name:"field:clear-current-error",run:t=>this.clearCurrentError(t)},{name:"field:update-dependencies",run:t=>this.updateDependencies(t)},{name:"field:update-dirty",run:t=>this.updateDirtyState(t)},{name:"field:commit-state",run:t=>this.commitFieldState(t)},{name:"field:emit-change",run:t=>this.emitFieldChange(t)},{name:"field:trigger-validate",run:t=>this.triggerResolverValidation(t)},{name:"field:trigger-async-validate",run:t=>this.triggerAsyncValidation(t)}])}updateField(e,t,i={origin:"setField"}){let r=this.store.getState(),n=_chunkOWDDAM6Ccjs.f.call(void 0, r.values,e),o={path:e,value:t,meta:i,previousValue:n,nextValues:_chunkOWDDAM6Ccjs.g.call(void 0, r.values,e,t),nextErrors:r.errors,hasMutatedErrors:!1,dependencyDiff:{affectedFields:[],visibilityChanged:[],requiredChanged:[]},isDirty:!1};this.fieldUpdatePipeline.run(o)}clearCurrentError(e){[e.nextErrors,e.hasMutatedErrors]=He(e.nextErrors,e.path,e.hasMutatedErrors),this.store.clearFieldValidation(e.path)}updateDependencies(e){if(typeof this.store.hasDependentFields=="function"&&!this.store.hasDependentFields(e.path)){e.dependencyDiff.affectedFields.length=0,e.dependencyDiff.visibilityChanged.length=0,e.dependencyDiff.requiredChanged.length=0;return}e.dependencyDiff=this.store.updateDependencies(e.path,this.store.getState().values,e.nextValues),new Set([...e.dependencyDiff.visibilityChanged,...e.dependencyDiff.requiredChanged]).forEach(i=>{[e.nextErrors,e.hasMutatedErrors]=He(e.nextErrors,i,e.hasMutatedErrors),this.store.clearFieldValidation(i)})}updateDirtyState(e){e.isDirty=this.store.updateDirtyForPath(e.path,e.nextValues,this.store.getBaselineValues())}commitFieldState(e){let t=Array.from(new Set([e.path,...e.dependencyDiff.visibilityChanged,...e.dependencyDiff.requiredChanged]));this.store.dispatch(B({values:e.nextValues,errors:e.nextErrors,isDirty:e.isDirty},t))}emitFieldChange(e){this.store.emitFieldChange({path:e.path,previousValue:e.previousValue,nextValue:e.value,values:this.store.getState().values,state:this.store.getState(),meta:e.meta})}triggerResolverValidation(e){let t=Array.from(new Set([e.path,...e.dependencyDiff.visibilityChanged,...e.dependencyDiff.requiredChanged]));(this.store.config.resolver||e.dependencyDiff.visibilityChanged.length>0||e.dependencyDiff.requiredChanged.length>0)&&this.store.triggerValidation(t)}triggerAsyncValidation(e){this.store.isFieldHidden(e.path)||(typeof this.store.getFieldConfig=="function"?_optionalChain([this, 'access', _168 => _168.store, 'access', _169 => _169.getFieldConfig, 'call', _170 => _170(e.path), 'optionalAccess', _171 => _171.validation, 'optionalAccess', _172 => _172.asyncValidateOn]):void 0)!=="change"||this.store.handleFieldAsyncValidation(e.path,e.value)}};var ge= (_class15 =class{constructor() { _class15.prototype.__init57.call(this); }__init57() {this.executors=new Map}register(e,t){let i=_nullishCoalesce(this.executors.get(e), () => ([]));i.push(t),this.executors.set(e,i)}async execute(e){let t=this.getOrderedExecutors(e.kind);for(let i of t)await i.execute(e)}executeSync(e){let t=this.getOrderedExecutors(e.kind);for(let i of t){let r=i.execute(e);if(r&&typeof r.then=="function")throw new Error(`BitLifecycleOrchestrator: executor async em modo sync para kind "${e.kind}".`)}}getOrderedExecutors(e){return[..._nullishCoalesce(this.executors.get(e), () => ([]))].sort((i,r)=>i.phase-r.phase)}}, _class15);var ye=class{constructor(e){this.store=e;this.submitPipeline=new M([{name:"submit:start",run:async t=>this.startSubmit(t)},{name:"submit:invalid",run:async t=>this.handleInvalidSubmit(t)},{name:"submit:prepare",run:t=>this.prepareSubmitValues(t)},{name:"submit:before-hooks",run:async t=>this.runBeforeSubmitHooks(t)},{name:"submit:user-handler",run:async t=>this.runSubmitHandler(t)},{name:"submit:after-hooks",run:async t=>this.runAfterSubmitHooks(t)}])}async submit(e){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:e,isValid:!1,valuesToSubmit:_chunkOWDDAM6Ccjs.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}),_optionalChain([this, 'access', _173 => _173.store, 'access', _174 => _174.config, 'access', _175 => _175.onUnhandledError, 'optionalCall', _176 => _176(r,"submit")]),{status:"failed",error:r}}finally{this.store.dispatch(B({isSubmitting:!1}))}}async startSubmit(e){this.store.dispatch(B({isSubmitting:!0})),e.isValid=await this.store.validateNow()}async handleInvalidSubmit(e){if(e.isValid)return;let t=this.store.getState().errors,i={...this.store.getState().touched};Object.keys(t).forEach(r=>{i[r]=!0}),this.store.batchStateUpdates(()=>{this.store.dispatch(B({touched:i}))}),e.dirtyValues=this.store.buildDirtyValues(this.store.getState().values),e.invalid=!0,await this.store.emitAfterSubmit({values:this.store.getState().values,dirtyValues:e.dirtyValues,state:this.store.getState(),success:!1,invalid:!0}),e.halted=!0}prepareSubmitValues(e){let t=e.valuesToSubmit,i=this.store.getHiddenFields();if(i.size>0){let r=[];i.forEach(n=>{r.push([n,void 0])}),t=_chunkOWDDAM6Ccjs.h.call(void 0, t,r)}t=it({values:t,sourceValues:t,transformEntries:this.store.getTransformEntries().filter(([r])=>!i.has(r)),onError:r=>{throw r}}),e.valuesToSubmit=t,e.dirtyValues=this.store.buildDirtyValues(t)}async runBeforeSubmitHooks(e){await this.store.emitBeforeSubmit({values:e.valuesToSubmit,dirtyValues:e.dirtyValues,state:this.store.getState()})}async runSubmitHandler(e){try{await e.onSuccess(e.valuesToSubmit,e.dirtyValues)}catch(t){if(_chunkOWDDAM6Ccjs.m.call(void 0, t)){this.store.setServerErrors(_chunkOWDDAM6Ccjs.n.call(void 0, t)),await this.store.emitAfterSubmit({values:e.valuesToSubmit,dirtyValues:e.dirtyValues,state:this.store.getState(),success:!1,invalid:!0}),e.invalid=!0,e.halted=!0;return}throw t}}async runAfterSubmitHooks(e){await this.store.emitAfterSubmit({values:e.valuesToSubmit,dirtyValues:e.dirtyValues,state:this.store.getState(),success:!0})}};var me=class{constructor(e){this.store=e}collectChangedUpdates(e,t="",i=[],r=new WeakSet){if(e&&typeof e=="object"){if(r.has(e))return i;r.add(e)}try{Object.entries(e).forEach(([n,o])=>{let a=t?`${t}.${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{e&&typeof e=="object"&&r.delete(e)}return i}setValues(e,t){if(_optionalChain([t, 'optionalAccess', _177 => _177.rebase])){this.rebaseValues(e);return}if(_optionalChain([t, 'optionalAccess', _178 => _178.partial])){this.hydrateValues(e);return}this.replaceValuesInternal(e,"replaceValues")}hydrateValues(e){let t=this.collectChangedUpdates(e),i=t.map(([n])=>n),r=t.length>0?_chunkOWDDAM6Ccjs.h.call(void 0, this.store.getState().values,t):this.store.getState().values;this.replaceValuesInternal(r,"hydrate",i.length>0?i:["*"])}rebaseValues(e){let t=this.store.getState().values,i=_chunkOWDDAM6Ccjs.a.call(void 0, e);this.store.setBaselineValues(i),this.store.cancelAllValidations(),this.store.evaluateAllDependencies(i),this.store.clearDirtyState(),this.store.dispatch(B({values:i,errors:{},touched:{},isValidating:{},isValid:!1,isDirty:!1},["*"])),this.store.resetHistory(i),this.store.validateNow().catch(r=>{_optionalChain([this, 'access', _179 => _179.store, 'access', _180 => _180.config, 'optionalAccess', _181 => _181.onUnhandledError, 'optionalCall', _182 => _182(r,"rebaseValues")])}),this.store.emitFieldChange({path:"*",previousValue:t,nextValue:i,values:this.store.getState().values,state:this.store.getState(),meta:{origin:"rebase"}})}applyHistoryState(e){this.store.cancelAllValidations();let t=this.store.rebuildDirtyState(e,this.store.getBaselineValues());this.store.dispatch(B({values:e,errors:{},isValid:!1,isDirty:t},["*"])),this.store.validateNow().catch(i=>{_optionalChain([this, 'access', _183 => _183.store, 'access', _184 => _184.config, 'optionalAccess', _185 => _185.onUnhandledError, 'call', _186 => _186(i,"applyHistoryState")])})}reset(){this.store.cancelAllValidations();let e=_chunkOWDDAM6Ccjs.a.call(void 0, this.store.getBaselineValues());this.store.evaluateAllDependencies(e),this.store.clearDirtyState(),this.store.dispatch(B({values:e,errors:{},touched:{},isValidating:{},isValid:!1,isDirty:!1},["*"])),this.store.resetHistory(e)}replaceValuesInternal(e,t="replaceValues",i=["*"]){let r=this.store.getState().values,n=_chunkOWDDAM6Ccjs.a.call(void 0, e);this.store.cancelAllValidations(),this.store.evaluateAllDependencies(n);let o=this.store.rebuildDirtyState(n,this.store.getBaselineValues());this.store.dispatch(B({values:n,errors:{},isValidating:{},isValid:!1,isDirty:o},i)),this.store.internalSaveSnapshot(),this.store.validateNow().catch(a=>{_optionalChain([this, 'access', _187 => _187.store, 'access', _188 => _188.config, 'optionalAccess', _189 => _189.onUnhandledError, 'call', _190 => _190(a,"replaceValuesInternal")])}),this.store.emitFieldChange({path:"*",previousValue:r,nextValue:n,values:this.store.getState().values,state:this.store.getState(),meta:{origin:t}})}};var Se= (_class16 =class{constructor(e){;_class16.prototype.__init58.call(this);this.ports=e;this.fieldUpdate=new fe(e.fieldUpdate),this.values=new me(e.values),this.submitFlow=new ye(e.submit),this.orchestrator.register("updateField",{phase:1,execute:t=>this.fieldUpdate.updateField(t.path,t.value,_nullishCoalesce(t.meta, () => ({origin:"setField"})))}),this.orchestrator.register("setValues",{phase:2,execute:t=>this.values.setValues(t.newValues,t.options)}),this.orchestrator.register("hydrateValues",{phase:2,execute:t=>this.values.hydrateValues(t.newValues)}),this.orchestrator.register("rebaseValues",{phase:2,execute:t=>this.values.rebaseValues(t.newValues)}),this.orchestrator.register("applyHistoryState",{phase:2,execute:t=>this.values.applyHistoryState(t.snapshot)}),this.orchestrator.register("submit",{phase:3,execute:async t=>{t.submitResult=await this.submitFlow.submit(t.onSuccess)}}),this.orchestrator.register("reset",{phase:4,execute:()=>this.values.reset()})}__init58() {this.orchestrator=new ge}updateField(e,t,i={origin:"setField"}){this.orchestrator.executeSync({kind:"updateField",path:e,value:t,meta:i})}setValues(e,t){this.orchestrator.executeSync({kind:"setValues",newValues:e,options:t})}hydrateValues(e){this.orchestrator.executeSync({kind:"hydrateValues",newValues:e})}rebaseValues(e){this.orchestrator.executeSync({kind:"rebaseValues",newValues:e})}applyHistoryState(e){this.orchestrator.executeSync({kind:"applyHistoryState",snapshot:e})}async submit(e){let t={kind:"submit",onSuccess:e};return await this.orchestrator.execute(t),t.submitResult}reset(){this.orchestrator.executeSync({kind:"reset"})}}, _class16);var be=class{constructor(e,t,i,r){this.getState=e;this.getInitialValues=t;this.getScopeFields=i;this.isPathDirty=r}getScopeStatus(e){if(!e)return{hasErrors:!1,isDirty:!1,errors:{}};let t=this.getScopeFields(e);if(t.length===0)return{hasErrors:!1,isDirty:!1,errors:{}};let i=this.getState(),r=t.some(a=>!!i.errors[a]),n=t.some(a=>this.isPathDirty(a)),o=this.getScopeErrors(e);return{hasErrors:r,isDirty:n,errors:o}}getScopeErrors(e){let t=this.getScopeFields(e),i=this.getState(),r={};for(let n of t){let o=i.errors[n];o&&(r[n]=o)}return r}};var St=Symbol("bit.async.validation.timeout"),ve= (_class17 =class{constructor(e){;_class17.prototype.__init59.call(this);_class17.prototype.__init60.call(this);_class17.prototype.__init61.call(this);this.port=e}__init59() {this._cancellingAll=!1}__init60() {this.abortControllers=new Map}__init61() {this.pendingJobs=new Map}handle(e,t,i,r,n){if(!i){this.cancel(e),this.port.setFieldValidating(e,!1);return}this.cancel(e),this.port.clearAsyncError(e),this.port.setFieldValidating(e,!0);let o=new AbortController;this.abortControllers.set(e,o),this.pendingJobs.set(e,{value:t,dueAt:Date.now()+r,validate:i,controller:o,timeoutMs:n}),this.schedulePendingJobs()}cancel(e){let t=this.pendingJobs.has(e)||this.abortControllers.has(e);this.cancelInternal(e,!0),t&&this.port.setFieldValidating(e,!1)}cancelInternal(e,t){this.pendingJobs.has(e)&&(this.pendingJobs.delete(e),t&&this.schedulePendingJobs());let i=this.abortControllers.get(e);i&&(i.abort(),this.abortControllers.delete(e))}cleanupPrefix(e){let t=!1,i=new Set([...this.pendingJobs.keys(),...this.abortControllers.keys()]);for(let r of i)x(r,e)&&(this.cancelInternal(r,!1),t=!0,this.port.clearAsyncError(r),this.port.setFieldValidating(r,!1));t&&this.schedulePendingJobs()}remapPaths(e){let t=!1,i=new Map;for(let[n,o]of this.pendingJobs.entries()){let a=e(n);if(!a){o.controller.abort(),t=!0;continue}a!==n&&(t=!0),i.set(a,o)}let r=new Map;for(let[n,o]of this.abortControllers.entries()){let a=e(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)}),t&&this.schedulePendingJobs()}cancelAll(){this._cancellingAll=!0;try{if(this.cancelSchedulerTimeout)try{this.cancelSchedulerTimeout()}catch (e12){}finally{this.cancelSchedulerTimeout=void 0}let e=Array.from(this.abortControllers.keys());for(let t of e){let i=this.abortControllers.get(t);if(i){try{i.abort()}catch (e13){}this.port.setFieldValidating(t,!1)}}this.pendingJobs.forEach((t,i)=>{this.port.setFieldValidating(i,!1)}),this.pendingJobs.clear(),this.abortControllers.clear()}finally{this._cancellingAll=!1}}schedulePendingJobs(){this.cancelSchedulerTimeout&&(this.cancelSchedulerTimeout(),this.cancelSchedulerTimeout=void 0);let e=Number.POSITIVE_INFINITY;for(let t of this.pendingJobs.values())t.dueAt<e&&(e=t.dueAt);Number.isFinite(e)&&(this.cancelSchedulerTimeout=this.port.schedule(()=>{this.cancelSchedulerTimeout=void 0,this.flushPendingJobs().catch(t=>{this.port.onError(t)})},Math.max(0,e-Date.now())))}async flushPendingJobs(){this.cancelSchedulerTimeout=void 0;let e=Date.now(),t=[];for(let[r,n]of this.pendingJobs.entries())n.dueAt<=e&&t.push([r,n]);if(t.length===0){this.schedulePendingJobs();return}t.forEach(([r])=>{this.pendingJobs.delete(r)});let i=await Promise.allSettled(t.map(([r,n])=>this.runJob(r,n)));for(let r of i)r.status==="rejected"&&this.port.onError(r.reason);this.schedulePendingJobs()}async runJob(e,t){if(!t.controller.signal.aborted)try{let i=t.validate(t.value,this.port.getValues());if(typeof t.timeoutMs=="number"&&t.timeoutMs>0){let o;i=Promise.race([i,new Promise(a=>{o=setTimeout(()=>a(St),t.timeoutMs)})]).finally(()=>{o&&clearTimeout(o)})}let r=await i;if(t.controller.signal.aborted)return;let n=_chunkOWDDAM6Ccjs.f.call(void 0, this.port.getValues(),e);if(!_chunkOWDDAM6Ccjs.c.call(void 0, n,t.value)){let o=this.findControllerPath(t.controller);if(!o||o===e)return;let a=_chunkOWDDAM6Ccjs.f.call(void 0, this.port.getValues(),o);if(!_chunkOWDDAM6Ccjs.c.call(void 0, a,t.value))return;e=o}if(r===St)return;r!=null?this.port.setAsyncError(e,r):(this.port.clearAsyncError(e),await this.port.onValidationPassed(e))}finally{let i=_nullishCoalesce(this.findControllerPath(t.controller), () => (e));!this._cancellingAll&&this.abortControllers.get(i)===t.controller&&this.port.setFieldValidating(i,!1),this.abortControllers.get(i)===t.controller&&this.abortControllers.delete(i)}}findControllerPath(e){for(let[t,i]of this.abortControllers.entries())if(i===e)return t}}, _class17);function k(s){for(let e of Object.keys(s))if(s[e]!==void 0)return!0;return!1}async function Ue(s){let{scopeFields:e,store:t,asyncErrors:i}=s,r=t.getState(),n=new Set(t.getHiddenFields()),o=t.config.resolver?await t.config.resolver(r.values,{scopeFields:e}):{},a=t.getState(),l=e.some(f=>!_chunkOWDDAM6Ccjs.c.call(void 0, _chunkOWDDAM6Ccjs.f.call(void 0, r.values,f),_chunkOWDDAM6Ccjs.f.call(void 0, a.values,f))),c=t.getHiddenFields(),u=e.some(f=>n.has(f)!==c.has(f));if(l||u)return;let d=t.getRequiredErrors(a.values),p={...o,...d};c.forEach(f=>{delete p[f]});let h={...a.errors};e.forEach(f=>{p[f]?h[f]=p[f]:i.has(f)?h[f]=i.get(f):delete h[f]}),t.dispatch(se(h,!k(h)&&!k(a.errors)))}var Be= (_class18 =class{constructor() { _class18.prototype.__init62.call(this);_class18.prototype.__init63.call(this); }__init62() {this.currentValidationId=0}__init63() {this.immediateAbortControllers=new Map}beginValidation(){return this.currentValidationId+=1,this.currentValidationId}getCurrentValidationId(){return this.currentValidationId}isValidationCurrent(e){return e===this.currentValidationId}setImmediateController(e,t){this.immediateAbortControllers.set(e,t)}clearImmediateController(e,t){return this.immediateAbortControllers.get(e)===t?(this.immediateAbortControllers.delete(e),!0):!1}cancelImmediate(e){let t=this.immediateAbortControllers.get(e);t&&(t.abort(),this.immediateAbortControllers.delete(e))}cancelImmediatePrefix(e,t){for(let i of this.immediateAbortControllers.keys())x(i,e)&&(this.cancelImmediate(i),t(i))}remapImmediateControllers(e){let t=new Map;for(let[i,r]of this.immediateAbortControllers.entries()){let n=e(i);if(!n){r.abort();continue}t.set(n,r)}this.immediateAbortControllers.clear(),t.forEach((i,r)=>{this.immediateAbortControllers.set(r,i)})}cancelAllImmediate(){this.immediateAbortControllers.forEach(e=>{e.abort()}),this.immediateAbortControllers.clear()}}, _class18);var Te= (_class19 =class{constructor(e){;_class19.prototype.__init64.call(this);_class19.prototype.__init65.call(this);this.port=e}__init64() {this.pendingScopeFields=null}__init65() {this.isGlobalPending=!1}trigger(e,t){this.cancelTimeout&&(this.cancelTimeout(),this.cancelTimeout=void 0,this.isGlobalPending=!1);let i=_nullishCoalesce(this.port.validationDelay, () => (300)),r=_optionalChain([t, 'optionalAccess', _191 => _191.forceDebounce])?Math.max(1,i):i;if(r>0){if(!e||e.length===0)this.pendingScopeFields=null,this.isGlobalPending=!0;else if(!this.isGlobalPending)if(!this.pendingScopeFields)this.pendingScopeFields=new Set(e);else for(let n of e)this.pendingScopeFields.add(n);this.cancelTimeout=this.port.schedule(()=>{let n=this.pendingScopeFields?Array.from(this.pendingScopeFields):void 0;this.pendingScopeFields=null,this.isGlobalPending=!1,this.cancelTimeout=void 0,this.validateWithOptionalScopeFields(n)},r)}else{let n=e;if(this.isGlobalPending)n=void 0;else if(this.pendingScopeFields){if(e)for(let o of e)this.pendingScopeFields.add(o);n=Array.from(this.pendingScopeFields)}this.pendingScopeFields=null,this.isGlobalPending=!1,this.validateWithOptionalScopeFields(n)}}validateWithOptionalScopeFields(e){return e&&e.length>0?this.port.validate({scopeFields:e}):this.port.validate()}cancelPending(){this.cancelTimeout&&(this.cancelTimeout(),this.cancelTimeout=void 0),this.pendingScopeFields=null,this.isGlobalPending=!1}}, _class19);var bt=Symbol("bit.async.validation.timeout");function vt(s){let{targetFields:e,currentErrors:t,allErrors:i,asyncErrors:r,hiddenFields:n}=s;if(e&&e.length>0){let a=t,l=!1,c=()=>(l||(a={...t},l=!0),a);e.forEach(d=>{let p=d,h=t[p];if(_optionalChain([n, 'optionalAccess', _192 => _192.has, 'call', _193 => _193(d)])){h!==void 0&&delete c()[p];return}if(i[d]!==void 0)h!==i[d]&&(c()[p]=i[d]);else if(r.has(d)){let f=r.get(d);h!==f&&(c()[p]=f)}else h!==void 0&&delete c()[p]});let u=e.every(d=>_optionalChain([n, 'optionalAccess', _194 => _194.has, 'call', _195 => _195(d)])||i[d]===void 0&&!r.has(d));return{committedErrors:l?a:t,result:u,mode:"scoped"}}let o={};return r.forEach((a,l)=>{_optionalChain([n, 'optionalAccess', _196 => _196.has, 'call', _197 => _197(l)])||(o[l]=a)}),Object.entries(i).forEach(([a,l])=>{l!==void 0&&(o[a]=l)}),{committedErrors:o,result:void 0,mode:"global"}}function Bt(s){let{targetFields:e,hiddenFields:t,getFieldConfig:i,forEachFieldConfig:r}=s,n=[];if(e&&e.length>0){for(let o of e){if(t.has(o))continue;_optionalChain([i, 'call', _198 => _198(o), 'optionalAccess', _199 => _199.validation, 'optionalAccess', _200 => _200.asyncValidate])&&n.push(o)}return n}return r&&r((o,a)=>{!_optionalChain([o, 'access', _201 => _201.validation, 'optionalAccess', _202 => _202.asyncValidate])||t.has(a)||n.push(a)}),n}async function Tt(s){let{path:e,values:t,validationId:i,getCurrentValidationId:r,getFieldConfig:n,cancelFieldAsync:o,createAbortController:a,setAbortController:l,clearAbortController:c,setFieldValidating:u,setAsyncError:d,clearAsyncError:p}=s,h=_optionalChain([n, 'call', _203 => _203(e), 'optionalAccess', _204 => _204.validation, 'optionalAccess', _205 => _205.asyncValidate]);if(!h){p(e);return}o(e),p(e);let f=a();l(e,f),u(e,!0);try{let S=_optionalChain([n, 'call', _206 => _206(e), 'optionalAccess', _207 => _207.validation, 'optionalAccess', _208 => _208.asyncValidateTimeout]),g=h(_chunkOWDDAM6Ccjs.f.call(void 0, t,e),t);if(typeof S=="number"&&S>0){let b;g=Promise.race([g,new Promise(E=>{b=setTimeout(()=>E(bt),S)})]).finally(()=>{b&&clearTimeout(b)})}let y=await g.catch(b=>b instanceof Error?b.message:String(_nullishCoalesce(b, () => (""))));if(f.signal.aborted||i!==r())return;y===bt||(y!=null?d(e,y):p(e))}finally{c(e,f)&&u(e,!1)}}function Pt(s){let{ctx:e,deps:t}=s,i=e.options;if(_optionalChain([i, 'optionalAccess', _209 => _209.scope])&&_optionalChain([i, 'access', _210 => _210.scopeFields, 'optionalAccess', _211 => _211.length])){t.store.config.onUnhandledError(new Error("validate received both 'scope' and 'scopeFields'. 'scopeFields' takes precedence."),"validation");return}if(!_optionalChain([e, 'access', _212 => _212.options, 'optionalAccess', _213 => _213.scopeFields, 'optionalAccess', _214 => _214.length])&&_optionalChain([e, 'access', _215 => _215.options, 'optionalAccess', _216 => _216.scope])){let r=t.store.getScopeFields(e.options.scope);r.length>0&&(e.targetFields=r)}}async function Et(s){let{ctx:e,deps:t}=s;await t.store.emitBeforeValidate({values:e.currentState.values,state:e.currentState,scope:_optionalChain([e, 'access', _217 => _217.options, 'optionalAccess', _218 => _218.scope]),scopeFields:e.targetFields})}async function xt(s){let{ctx:e,deps:t}=s,i=t.store.config.resolver?await t.store.config.resolver(e.currentState.values,{scopeFields:e.targetFields}):{},r=t.store.getRequiredErrors(e.currentState.values);e.allErrors={...i,...r},t.store.getHiddenFields().forEach(n=>{delete e.allErrors[n]})}async function Ct(s){let{ctx:e,deps:t}=s,i=Bt({targetFields:e.targetFields,hiddenFields:t.store.getHiddenFields(),getFieldConfig:n=>t.store.getFieldConfig(n),forEachFieldConfig:t.store.forEachFieldConfig});if(i.length===0)return;let r=await Promise.allSettled(i.map(n=>t.runImmediateAsyncValidation(n,e.currentState.values,e.validationId)));for(let n of r)n.status==="rejected"&&t.store.config.onUnhandledError(n.reason,"validation")}function Vt(s){let{ctx:e,deps:t}=s,i=vt({targetFields:e.targetFields,currentErrors:e.currentState.errors,allErrors:e.allErrors,asyncErrors:t.asyncErrors,hiddenFields:t.store.getHiddenFields()});e.committedErrors=i.committedErrors,e.isValid=!k(i.committedErrors),e.result=i.mode==="scoped"?i.result:e.isValid}async function ze(s){let{ctx:e,deps:t}=s;e.validationId!==t.getCurrentValidationId()&&(e.aborted=!0,e.result=t.store.getState().isValid,e.halted=!0)}async function Ft(s){let{ctx:e,deps:t}=s;t.store.dispatch(se(e.committedErrors,e.isValid)),await t.store.emitAfterValidate({values:t.store.getState().values,state:t.store.getState(),scope:_optionalChain([e, 'access', _219 => _219.options, 'optionalAccess', _220 => _220.scope]),scopeFields:e.targetFields,errors:e.committedErrors,result:e.result}),e.halted=!0}var Pe=class{constructor(e){this.deps=e;this.runner=new M([{name:"validate:resolve-target-fields",run:t=>Pt({ctx:t,deps:this.deps})},{name:"validate:before-hooks",run:async t=>Et({ctx:t,deps:this.deps})},{name:"validate:sync-track",run:async t=>xt({ctx:t,deps:this.deps})},{name:"validate:abort-check-pre-async",run:async t=>ze({ctx:t,deps:this.deps})},{name:"validate:async-track",run:async t=>Ct({ctx:t,deps:this.deps})},{name:"validate:abort-check",run:async t=>ze({ctx:t,deps:this.deps})},{name:"validate:async-track-merge",run:t=>Vt({ctx:t,deps:this.deps})},{name:"validate:commit",run:async t=>Ft({ctx:t,deps:this.deps})}])}async run(e){await this.runner.run(e)}};var Ee= (_class20 =class{constructor(e){;_class20.prototype.__init66.call(this);_class20.prototype.__init67.call(this);_class20.prototype.__init68.call(this);this.store=e;this.schedule=_nullishCoalesce(_optionalChain([e, 'access', _221 => _221.config, 'access', _222 => _222.scheduler, 'optionalAccess', _223 => _223.schedule]), () => (((i,r)=>{let n=setTimeout(i,r);return()=>clearTimeout(n)}))),this.debouncer=new Te({schedule:(i,r)=>this.schedule(i,r),validate:i=>this.validate(i),validationDelay:_nullishCoalesce(e.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 ve({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),Ue({scopeFields:[i],store:this.pipelineStore,asyncErrors:this.asyncErrors}).catch(n=>{this.store.config.onUnhandledError(n,"validation")})},onValidationPassed:async i=>{await Ue({scopeFields:[i],store:this.pipelineStore,asyncErrors:this.asyncErrors})},onError:i=>{this.store.config.onUnhandledError(i,"validation")}});let t={store:this.pipelineStore,asyncErrors:this.asyncErrors,getCurrentValidationId:()=>this.coordinator.getCurrentValidationId(),runImmediateAsyncValidation:(i,r,n)=>this.runImmediateAsyncValidation(i,r,n)};this.validationPipeline=new Pe(t)}__init66() {this.validatingCount=0}__init67() {this.asyncErrors=new Map}__init68() {this.coordinator=new Be}updateFieldValidating(e,t){let i=this.store.getState();if(!!i.isValidating[e]===t)return;let n={...i.isValidating};t?(n[e]=!0,this.validatingCount+=1):(delete n[e],this.validatingCount=Math.max(0,this.validatingCount-1)),this.store.dispatch(B({isValidating:n}))}cancelFieldAsync(e){this.asyncScheduler.cancel(e),this.coordinator.cancelImmediate(e)}cleanupField(e){this.cancelFieldAsync(e),this.asyncErrors.delete(e),this.updateFieldValidating(e,!1)}cleanupPrefix(e){this.asyncScheduler.cleanupPrefix(e),this.coordinator.cancelImmediatePrefix(e,t=>{this.asyncErrors.delete(t),this.updateFieldValidating(t,!1)})}remapArrayPaths(e,t){let i=`${e}.`;this.asyncScheduler.remapPaths(c=>_chunkOWDDAM6Ccjs.l.call(void 0, c,i,t)),this.coordinator.remapImmediateControllers(c=>_chunkOWDDAM6Ccjs.l.call(void 0, c,i,t));let r=new Map;this.asyncErrors.forEach((c,u)=>{let d=_chunkOWDDAM6Ccjs.l.call(void 0, u,i,t);d!==null&&r.set(d,c)}),this.asyncErrors.clear(),r.forEach((c,u)=>{this.asyncErrors.set(u,c)});let o=this.store.getState().isValidating,a={},l=!1;for(let[c]of Object.entries(o))if(c.startsWith(i)){let u=_chunkOWDDAM6Ccjs.l.call(void 0, c,i,t);u!==null?(a[u]=!0,u!==c&&(l=!0)):l=!0}else a[c]=!0;l&&this.store.dispatch(B({isValidating:a}))}beginExternalValidation(e){this.cancelFieldAsync(e),this.updateFieldValidating(e,!0)}endExternalValidation(e){this.updateFieldValidating(e,!1)}async setExternalError(e,t){if(t){this.asyncErrors.set(e,t),this.store.setError(e,t);return}this.cancelFieldAsync(e),this.asyncErrors.delete(e),this.store.setError(e,void 0),await this.validate({scopeFields:[e]})}handleAsync(e,t){let i=this.store.getFieldConfig(e),r=_optionalChain([i, 'optionalAccess', _224 => _224.validation, 'optionalAccess', _225 => _225.asyncValidate]),n=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _226 => _226.validation, 'optionalAccess', _227 => _227.asyncValidateOn]), () => ("blur"));if(!r||n!=="change"){this.cancelFieldAsync(e),this.updateFieldValidating(e,!1);return}let o=_nullishCoalesce(_optionalChain([i, 'access', _228 => _228.validation, 'optionalAccess', _229 => _229.asyncValidateDelay]), () => (500)),a=_optionalChain([i, 'access', _230 => _230.validation, 'optionalAccess', _231 => _231.asyncValidateTimeout]);this.asyncScheduler.handle(e,t,r,o,a)}hasValidationsInProgress(e){let t=this.store.getState();return e&&e.length>0?e.some(i=>!!t.isValidating[i]):Object.keys(t.isValidating).length>0}trigger(e,t){this.debouncer.trigger(e,t)}async validate(e){try{_optionalChain([e, 'optionalAccess', _232 => _232.scopeFields, 'optionalAccess', _233 => _233.length])&&e.scopeFields.forEach(i=>{this.cancelFieldAsync(i),this.updateFieldValidating(i,!1)});let t={options:e,validationId:this.coordinator.beginValidation(),currentState:this.store.getState(),targetFields:_optionalChain([e, 'optionalAccess', _234 => _234.scopeFields]),allErrors:{},committedErrors:{},isValid:!0,result:!0,aborted:!1};if(await this.validationPipeline.run(t),t.aborted){let i=this.store.getState();await this.store.emitAfterValidate({values:i.values,state:i,scope:_optionalChain([t, 'access', _235 => _235.options, 'optionalAccess', _236 => _236.scope]),scopeFields:t.targetFields,errors:i.errors,result:i.isValid,aborted:!0})}return t.result}catch(t){return this.store.config.onUnhandledError(t,"validation"),!1}}clear(e){this.cancelFieldAsync(e),this.updateFieldValidating(e,!1),this.asyncErrors.delete(e)}cancelAll(){this.validatingCount=0,this.debouncer.cancelPending(),this.asyncScheduler.cancelAll(),this.asyncErrors.clear(),this.coordinator.cancelAllImmediate(),this.store.dispatch(B({isValidating:{}}))}async runImmediateAsyncValidation(e,t,i){await Tt({path:e,values:t,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)}})}}, _class20);var qe= (_class21 =class{constructor() { _class21.prototype.__init69.call(this); }__init69() {this.entries=new Map}register(e,t){this.entries.set(e,t)}resolve(e){let t=this.entries.get(e);if(!t)throw new Error(`BitStore capability "${String(e)}" n\xE3o foi registrada.`);return t}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")}}}, _class21);function wt(){return new qe}function Ai(s){let{registry:e,ports:t,fieldRegistry:i}=s;e.register("validation",new Ee(t.validationPort)),e.register("lifecycle",new Se(t.lifecyclePorts)),e.register("history",new pe(!!t.config.history.enabled,_nullishCoalesce(t.config.history.limit, () => (50)))),e.register("arrays",new le(t.arrayPort)),e.register("scope",new be(()=>t.getState(),()=>t.getBaselineValues(),r=>t.getScopeFields(r),r=>t.isPathDirty(r))),e.register("query",new ce(i,()=>t.getState(),r=>t.isPathDirty(r))),e.register("error",new de(()=>t.getState(),r=>t.dispatch(r),r=>t.config.onUnhandledError(r,"errors")))}function At(s){let{ports:e,fieldRegistry:t}=s,i=wt();return Ai({registry:i,ports:e,fieldRegistry:t}),{registry:i,capabilities:i.toCapabilities()}}function kt(s){let{config:e,fieldRegistry:t,computedManager:i}=s,r=_chunkOWDDAM6Ccjs.a.call(void 0, e.initialValues);e.fields&&Object.entries(e.fields).forEach(([a,l])=>{t.register(a,l,r)});let n=ne(t.getComputedEntries(r));if(n.length>0)throw new Error(n[0].message);return{values:G({values:r,normalizerEntries:t.getNormalizerEntries(r),applyComputed:(a,l)=>i.apply(a,l),onError:(a,l)=>{e.onUnhandledError(a,"derivation")}}).values,errors:{},touched:{},isValidating:{},persist:{isSaving:!1,isRestoring:!1,error:null},isValid:!0,isSubmitting:!1,isDirty:!1}}function It(s){return{getState:s.getState,dispatch:s.dispatch,setError:s.setError,getFieldConfig:s.getFieldConfig,forEachFieldConfig:e=>s.fieldRegistry.forEachFieldConfig((t,i)=>e(t,i)),getScopeFields:s.getScopeFields,config:s.config,getRequiredErrors:e=>s.fieldRegistry.getRequiredErrors(e),getHiddenFields:()=>s.fieldRegistry.getHiddenFields(),emitBeforeValidate:e=>s.getEffects().beforeValidate(e),emitAfterValidate:e=>s.getEffects().afterValidate(e)}}function Dt(s){let e={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)},t={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:e,values:t,submit:i}}function Mt(s){return{getState:s.getState,setFieldWithMeta:s.setFieldWithMeta,dispatch:s.dispatch,internalSaveSnapshot:s.saveHistorySnapshot,unregisterPrefix:s.unregisterPrefix,remapValidationPaths:s.remapValidationPaths,createArrayItemId:s.createArrayItemId}}function Rt(s){let{config:e,fieldRegistry:t,dirtyManager:i,baselineManager:r,runtimeContext:n}=s,{stateAccess:o,fieldAccess:a,featureAccess:l,actions:c}=n,u=It({config:e,fieldRegistry:t,getState:o.getState,dispatch:o.dispatch,setError:c.setError,getFieldConfig:a.getFieldConfig,getScopeFields:a.getScopeFields,getEffects:l.getEffects}),d=Dt({config:e,fieldRegistry:t,dirtyManager:i,getState:o.getState,dispatch:o.dispatch,setServerErrors:c.setServerErrors,saveHistorySnapshot:o.saveHistorySnapshot,runStateBatch:o.runStateBatch,getTransformEntries:a.getTransformEntries,getBaselineValues:()=>r.getValues(),setBaselineValues:h=>r.setValues(h),getValidation:l.getValidation,getHistory:l.getHistory,getEffects:l.getEffects}),p=Mt({getState:o.getState,dispatch:o.dispatch,setFieldWithMeta:(h,f,S)=>c.setFieldWithMeta(h,f,S),unregisterPrefix:c.unregisterPrefix,remapValidationPaths:(h,f)=>l.getValidation().remapArrayPaths(h,f),saveHistorySnapshot:o.saveHistorySnapshot,createArrayItemId:(h,f)=>e.idFactory({scope:"array",path:h,index:f})});return At({ports:{validationPort:u,lifecyclePorts:d,arrayPort:p,config:e,getScopeFields:a.getScopeFields,getState:o.getState,dispatch:o.dispatch,getBaselineValues:()=>r.getValues(),isPathDirty:h=>i.isPathDirty(h)},fieldRegistry:t})}function Ot(s){let{config:e,fieldRegistry:t,dirtyManager:i,computedManager:r,rawConfig:n,baselineManager:o,runtimeContext:a}=s,{stateAccess:l,fieldAccess:c,featureAccess:u,actions:d}=a,p=Rt({config:e,fieldRegistry:t,dirtyManager:i,baselineManager:o,runtimeContext:{stateAccess:l,fieldAccess:c,featureAccess:u,actions:d}}),h=kt({config:e,fieldRegistry:t,computedManager:r}),f=new ae(l.getState,(g,y)=>e.onUnhandledError(g,y),e.subscriptionCacheSize),S=n.storeId||e.name||e.idFactory({scope:"store",storeName:e.name});return{state:h,subscriptions:f,capabilityRegistry:p.registry,storeId:S}}function jt(){return{depth:0,pendingState:null,changedPathSet:null,changedPathList:null,valuesChanged:!1,pendingHistorySnapshot:!1}}function Ht(s){s.depth+=1}function Ut(s){return s.depth-=1,s.depth===0}function xe(s,e){return _nullishCoalesce(e.pendingState, () => (s))}function zt(s,e){if(s.pendingState=e.nextState,s.valuesChanged||=e.valuesChanged,e.valuesChanged&&(s.pendingHistorySnapshot=!0),e.changedPaths&&e.changedPaths.length>0){let t=_nullishCoalesce(s.changedPathSet, () => (new Set)),i=_nullishCoalesce(s.changedPathList, () => ([]));e.changedPaths.forEach(r=>{if(t.has("*")||t.has(r))return;if(r==="*"){t.clear(),i.length=0,t.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}.`)||(t.delete(a),i.splice(o,1))}t.add(r),i.push(r)}}),s.changedPathSet=t,s.changedPathList=i}}function qt(s){let{currentState:e,batchState:t,applyValueDerivations:i,onDerivationError:r}=s;if(!t.pendingState)return null;let n={...t.pendingState},o=_nullishCoalesce(t.changedPathList, () => (void 0)),a=t.valuesChanged;try{if(a)try{let l=i(n.values,o);n={...n,values:l.values},l.changedComputedPaths.length>0&&(o=o?[...new Set([...o,...l.changedComputedPaths])]:[...l.changedComputedPaths])}catch(l){try{_optionalChain([r, 'optionalCall', _237 => _237(l)])}catch (e14){}}}finally{t.pendingState=null,t.changedPathSet=null,t.changedPathList=null,t.valuesChanged=!1}return{nextState:_nullishCoalesce(n, () => (e)),changedPaths:o,valuesChanged:a}}var Ce= (_class22 =class{constructor(e){;_class22.prototype.__init70.call(this);this.args=e;this.debounceMs=Math.max(0,_nullishCoalesce(e.debounceMs, () => (300)))}__init70() {this.pendingValues=null}queueSnapshot(e){if(this.debounceMs<=0){this.recordSnapshot(e);return}this.pendingValues=e,this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.flushPendingSnapshot()},this.debounceMs)}flushPendingSnapshot(){if(this.timer&&(clearTimeout(this.timer),this.timer=void 0),!this.pendingValues)return;let e=this.pendingValues;this.pendingValues=null,this.recordSnapshot(e)}dispose(){this.timer&&(clearTimeout(this.timer),this.timer=void 0),this.pendingValues=null}recordSnapshot(e){let t=this.readMetadata();try{this.args.history.saveSnapshot(e)}catch(r){typeof console<"u"&&console.error&&console.error("[BitStoreHistoryOrchestrator] Failed to record history snapshot:",r);return}let i=this.readMetadata();t.canUndo===i.canUndo&&t.canRedo===i.canRedo&&t.historyIndex===i.historyIndex&&t.historySize===i.historySize||this.args.notifyHistoryChanged()}readMetadata(){let e=this.args.history.getMetadata();return{canUndo:e.canUndo,canRedo:e.canRedo,historyIndex:e.historyIndex,historySize:e.historySize}}}, _class22);function ki(s){let e=!1;for(let i of Object.values(s))if(i===void 0){e=!0;break}if(!e)return s;let t={};return Object.entries(s).forEach(([i,r])=>{let n=r;n!==void 0&&(t[i]=n)}),t}function Ve(s){let{currentState:e,partialState:t,changedPaths:i,applyValueDerivations:r,applyComputedValues:n}=s,o=_nullishCoalesce(r, () => ((h=>({values:n?n(h):h,changedComputedPaths:[]})))),a={...e,...t},l=Object.prototype.hasOwnProperty.call(t,"values"),c;if(t.values){let h=o(t.values,i);a.values=h.values,h.changedComputedPaths.length>0&&(c=h.changedComputedPaths)}if(t.errors){a.errors=ki(t.errors);let h=!k(a.errors);a.isValid="isValid"in t?!!t.isValid:h}let u=i&&i.length>0?i:void 0,d=Ii(t),p=z(z(u,d),c);return{nextState:a,changedPaths:p,valuesChanged:l}}function Ii(s){let e=new Set,t=[s.errors,s.touched,s.isValidating];for(let i of t)if(i)for(let r of Object.keys(i))e.add(r);return s.persist&&e.add("persist"),"isValid"in s&&e.add("isValid"),"isDirty"in s&&e.add("isDirty"),"isSubmitting"in s&&e.add("isSubmitting"),e.size>0?Array.from(e):void 0}function Di(s){throw new Error(`BitStore: unsupported operation kind: ${String(s.kind)}`)}function Mi(s,e){switch(e.kind){case"state.patch":return e;case"field.touchMany":{if(e.paths.length===0)return null;let t={...s.touched};for(let i of e.paths)t[i]=!0;return B({touched:t},e.paths)}case"form.persistMeta":return B({persist:{...s.persist,...e.patch}});case"history.apply":return B({values:e.values,isDirty:e.isDirty},["*"]);case"validation.commit":return B({errors:e.errors,isValid:e.isValid});default:return Di(e)}}function Ri(s){let{currentState:e,operation:t,applyValueDerivations:i,onOperationError:r}=s,n=Object.prototype.hasOwnProperty.call(t.partialState,"values"),o=_nullishCoalesce(t.changedPaths, () => ((n?["*"]:void 0))),a=c=>({values:c,changedComputedPaths:[]}),l;try{l=Ve({currentState:e,partialState:t.partialState,changedPaths:o,applyValueDerivations:i})}catch(c){try{_optionalChain([r, 'optionalCall', _238 => _238(c)])}catch (e15){}try{l=Ve({currentState:e,partialState:t.partialState,changedPaths:o,applyValueDerivations:a})}catch (e16){try{let{values:u,...d}=t.partialState;Object.keys(d).length>0&&(l=Ve({currentState:e,partialState:d,changedPaths:o,applyValueDerivations:a}))}catch (e17){let u=new Error("BitStore: all commit fallback strategies failed \u2014 operation lost");try{_optionalChain([r, 'optionalCall', _239 => _239(u)])}catch (e18){}l=void 0}}}return l}function _t(s){let{currentState:e,operation:t,applyValueDerivations:i,onOperationError:r}=s,n=Mi(e,t);if(!n)return null;let o=a=>({values:a,changedComputedPaths:[]});return Ri({currentState:e,operation:n,applyValueDerivations:(a,l)=>n.skipComputed?o(a):i(a,l),onOperationError:r})}function Lt(s){let{state:e,batchState:t,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o}=s,a=xe(e,t),l=u=>({values:u,changedComputedPaths:[]});if(t.depth>0){let u=_t({currentState:a,operation:i,applyValueDerivations:l,onOperationError:n});return u&&zt(t,u),e}let c=_t({currentState:e,operation:i,applyValueDerivations:r,onOperationError:n});return c?(o({nextState:c.nextState,changedPaths:c.changedPaths,valuesChanged:c.valuesChanged}),c.nextState):e}function Wt(s){let{state:e,batchState:t,applyValueDerivations:i,onDerivationError:r,onStateCommitted:n}=s,o=qt({currentState:e,batchState:t,applyValueDerivations:i,onDerivationError:r});return o?(n({nextState:o.nextState,changedPaths:o.changedPaths,valuesChanged:o.valuesChanged}),o.nextState):(n({nextState:e,changedPaths:void 0,valuesChanged:!1}),e)}function Nt(s){let{batchState:e,callback:t,flushBatchedStateUpdates:i}=s;Ht(e);try{return t()}catch(r){throw e.pendingState=null,e.pendingHistorySnapshot=!1,e.changedPathSet=null,e.changedPathList=null,e.valuesChanged=!1,r}finally{Ut(e)&&i()}}function $t(s){let{payload:e,setState:t,notifySubscriptions:i,notifyEffects:r}=s;t(e.nextState),i(e.nextState,e.changedPaths),r(e.nextState,e.valuesChanged)}function Kt(s){let{state:e,batchState:t,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o}=s;return Lt({state:e,batchState:t,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o})}function Jt(s){let{batchState:e,values:t,saveHistory:i}=s;if(e.depth>0){e.pendingHistorySnapshot=!0;return}i(t)}function Gt(s){let{state:e,batchState:t,applyValueDerivations:i,onDerivationError:r,onStateCommitted:n,saveHistory:o}=s,a=Wt({state:e,batchState:t,applyValueDerivations:i,onDerivationError:r,onStateCommitted:n});return t.pendingHistorySnapshot&&(t.pendingHistorySnapshot=!1,a!==e&&o(a.values)),a}var Fe= (_class23 =class{constructor(e){;_class23.prototype.__init71.call(this);_class23.prototype.__init72.call(this);this.args=e;this.state=e.state,this.subscriptions=e.subscriptions,this.effects=e.effects,this.capabilityRegistry=e.capabilityRegistry,this.capabilities=e.capabilityRegistry.toCapabilities(),this.historyOrchestrator=new Ce({debounceMs:e.historyDebounceMs,history:this.capabilities.history,notifyHistoryChanged:()=>{this.subscriptions.notify(this.getState(),[_chunkRHMJPKNVcjs.h.call(void 0, )])}})}__init71() {this.batchState=jt()}__init72() {this.destroyed=!1}getCapability(e){return this.capabilityRegistry.resolve(e)}getState(){return xe(this.state,this.batchState)}runBatch(e){return Nt({batchState:this.batchState,callback:e,flushBatchedStateUpdates:()=>this.flushBatchedStateUpdates()})}dispatch(e){this.state=Kt({state:this.state,batchState:this.batchState,operation:e,applyValueDerivations:(t,i)=>this.applyValueDerivations(t,i),onOperationError:t=>_optionalChain([this, 'access', _240 => _240.args, 'access', _241 => _241.onUnhandledError, 'optionalCall', _242 => _242(t,"derivation")]),onStateCommitted:t=>this.onStateCommitted(t)})}saveHistorySnapshot(){Jt({batchState:this.batchState,values:this.state.values,saveHistory:e=>this.historyOrchestrator.queueSnapshot(e)})}flushPendingHistorySnapshot(){this.historyOrchestrator.flushPendingSnapshot()}cancelPendingHistorySnapshot(){this.batchState.pendingHistorySnapshot=!1}cleanup(){this.destroyed||(this.destroyed=!0,this.flushPendingHistorySnapshot(),this.historyOrchestrator.dispose(),this.subscriptions.destroy(),this.capabilities.validation.cancelAll(),this.effects.destroy())}onStateCommitted(e){$t({payload:e,setState:t=>{this.state=t},notifySubscriptions:(t,i)=>this.subscriptions.notify(t,i),notifyEffects:(t,i)=>this.effects.onStateUpdated(t,i)})}flushBatchedStateUpdates(){this.state=Gt({state:this.state,batchState:this.batchState,applyValueDerivations:(e,t)=>this.applyValueDerivations(e,t),onDerivationError:e=>_optionalChain([this, 'access', _243 => _243.args, 'access', _244 => _244.onUnhandledError, 'optionalCall', _245 => _245(e,"derivation")]),onStateCommitted:e=>this.onStateCommitted(e),saveHistory:e=>this.historyOrchestrator.queueSnapshot(e)})}applyValueDerivations(e,t){return this.args.applyValueDerivations?this.args.applyValueDerivations(e,t):{values:e,changedComputedPaths:[]}}}, _class23);function Yt(s){let{rawConfig:e,overrides:t}=s,i=tt(e),r=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _246 => _246.baselineManager]), () => (new _(i.initialValues))),n=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _247 => _247.fieldRegistry]), () => (new J(({error:g})=>{i.onUnhandledError(g,"validation")}))),o=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _248 => _248.computedManager]), () => (new L(g=>n.getComputedEntries(g),g=>i.onUnhandledError(g,"computed")))),a=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _249 => _249.dirtyManager]), () => (new W)),l=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _250 => _250.maskManager]), () => (new N)),c=()=>{n.invalidateIndexes(),o.invalidateReverseDeps()},u,d=()=>{if(!u)throw new Error("BitStore runtime kernel is not initialized yet.");return u},p=Ot({rawConfig:e,config:i,fieldRegistry:n,computedManager:o,dirtyManager:a,baselineManager:r,runtimeContext:{stateAccess:{getState:()=>d().getState(),dispatch:g=>d().dispatch(g),saveHistorySnapshot:()=>d().saveHistorySnapshot(),runStateBatch:g=>d().runBatch(g)},fieldAccess:{getFieldConfig:g=>n.getFieldConfig(g),getScopeFields:g=>n.getScopeFields(g,d().getState().values),getNormalizerEntries:()=>n.getNormalizerEntries(d().getState().values),getTransformEntries:()=>n.getTransformEntries(d().getState().values)},featureAccess:{getEffects:()=>d().effects,getHistory:()=>d().getCapability("history"),getValidation:()=>d().getCapability("validation")},actions:{setError:(g,y)=>{d().getCapability("error").setError(g,y)},setServerErrors:(g,y)=>{d().getCapability("error").setServerErrors(g,y)},validate:g=>d().getCapability("validation").validate(g),setFieldWithMeta:(g,y,b={origin:"setField"})=>{d().runBatch(()=>{d().getCapability("lifecycle").updateField(g,y,b)})},unregisterPrefix:g=>{oe({prefix:g,state:d().getState(),fieldRegistry:n,subscriptions:d().subscriptions,validationCleanupPrefix:y=>d().getCapability("validation").cleanupPrefix(y),invalidateFieldIndexes:c,hasStaticConfigPath:y=>!!_optionalChain([i, 'access', _251 => _251.fields, 'optionalAccess', _252 => _252[y]]),dispatch:y=>d().dispatch(y)})},triggerValidation:(g,y)=>{d().getCapability("validation").trigger(g,y)}}}}),h=()=>{let g=d().getState();return a.buildDirtyValues(g.values)},f=g=>{d().flushPendingHistorySnapshot(),ut({values:g,state:d().getState(),initialValues:r.getValues(),validation:d().getCapability("validation"),fieldRegistry:n,dirtyManager:a,dispatch:y=>d().dispatch(y),saveHistorySnapshot:()=>d().saveHistorySnapshot()})},S=nt({storeId:p.storeId,config:i,getState:()=>d().getState(),getConfig:()=>i,getValues:()=>d().getState().values,getDirtyValues:h,applyPersistedValues:f,setPersistMetadata:g=>d().dispatch({kind:"form.persistMeta",patch:g})});return u=new Fe({state:p.state,subscriptions:p.subscriptions,effects:S,capabilityRegistry:p.capabilityRegistry,historyDebounceMs:i.history.debounceMs,onUnhandledError:(g,y)=>i.onUnhandledError(g,y),applyValueDerivations:(g,y)=>{try{return G({values:g,changedPaths:y,normalizerEntries:n.getNormalizerEntries(g),applyComputed:(b,E)=>o.apply(b,E),onError:(b,E)=>{i.onUnhandledError(b,"derivation")}})}catch(b){return i.onUnhandledError(b,"derivation"),{values:g,changedComputedPaths:[]}}}}),u.saveHistorySnapshot(),u.flushPendingHistorySnapshot(),{config:i,storeId:p.storeId,runtime:u,fieldRegistry:n,computedManager:o,dirtyManager:a,maskManager:l,baselineManager:r}}function Qt(s){let{dispatch:e,effects:t,onUnhandledError:i}=s;return lt({dispatch:e,effects:t,onUnhandledError:i})}function Xt(s){let{dispatch:e,effects:t,onUnhandledError:i}=s;return dt({dispatch:e,effects:t,onUnhandledError:i})}function Zt(s){let{dispatch:e,effects:t,onUnhandledError:i}=s;return ct({dispatch:e,effects:t,onUnhandledError:i})}function ei(s){let{history:e,applyHistoryState:t}=s,i=e.undo();if(i){e.commitUndo();try{t(i)}catch(r){try{e.redo()!==null&&e.commitRedo()}catch (e19){}throw r}}}function ti(s){let{history:e,applyHistoryState:t}=s,i=e.redo();if(i){e.commitRedo();try{t(i)}catch(r){try{e.undo()!==null&&e.commitUndo()}catch (e20){}throw r}}}function ii(s){return s.history.getMetadata()}function ri(s,e){let t=new Set,i=(o,a,l=new WeakSet)=>o===null||typeof o!="object"||l.has(o)?o:(l.add(o),new Proxy(o,{get:(c,u,d)=>{if(typeof u=="symbol")return Reflect.get(c,u,d);let p=String(u),h=a?`${a}.${p}`:p;t.add(h);let f=Reflect.get(c,u,d);return i(f,h)}})),r=i(s,"");e(r);let n=new Set;return t.forEach(o=>{let a=Oi(o);a&&n.add(a)}),Array.from(n)}function Oi(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 ji(s,e){if(s.length!==e.length)return!1;let t=new Set(e);for(let i of s)if(!t.has(i))return!1;return!0}function Hi(s,e){return s.length===0?{emitImmediately:_optionalChain([e, 'optionalAccess', _253 => _253.emitImmediately]),equalityFn:_optionalChain([e, 'optionalAccess', _254 => _254.equalityFn]),mode:"scoped",paths:["*"]}:{emitImmediately:_optionalChain([e, 'optionalAccess', _255 => _255.emitImmediately]),equalityFn:_optionalChain([e, 'optionalAccess', _256 => _256.equalityFn]),mode:"scoped",paths:s}}function si(s){let{getState:e,subscribeSelector:t,selector:i,listener:r,options:n}=s,o=null,a=ri(e(),i),l=!1,c=!1,u=d=>{let p=o;o=t(i,h=>{r(h);let f=ri(e(),i);ji(a,f)||(a=f,!(c||l)&&(c=!0,queueMicrotask(()=>{c=!1,!l&&(_optionalChain([o, 'optionalCall', _257 => _257()]),u(a))})))},Hi(d,n)),_optionalChain([p, 'optionalCall', _258 => _258()])};return u(a),()=>{l=!0,_optionalChain([o, 'optionalCall', _259 => _259()]),o=null}}function ni(s){let{getState:e,subscriptions:t,selector:i,listener:r,options:n,trackedSubscriptionsEnabled:o,onUnhandledError:a}=s,l=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _260 => _260.equalityFn]), () => (_chunkOWDDAM6Ccjs.c));return _optionalChain([n, 'optionalAccess', _261 => _261.mode])==="tracked"?o?si({getState:e,subscribeSelector:(c,u,d)=>t.subscribeSelector(c,u,d,l),selector:i,listener:r,options:n}):(_optionalChain([a, 'optionalCall', _262 => _262(new Error('BitForm: subscribeSelector com mode="tracked" est\xE1 desabilitado por padr\xE3o. Ative config.trackedSubscriptions=true para habilitar o modo avan\xE7ado.'),"subscription")]),()=>{}):t.subscribeSelector(i,r,n,l)}function oi(s){let{path:e,listener:t,options:i,subscribeSelector:r}=s,n=[..._nullishCoalesce(_optionalChain([i, 'optionalAccess', _263 => _263.paths]), () => ([])),e];return r(o=>_chunkOWDDAM6Ccjs.f.call(void 0, o.values,e),t,{...i,paths:n})}function ai(s){let{path:e,listener:t,getFieldState:i,subscribeSelector:r}=s;return r(()=>i(e),t,{paths:[e],equalityFn:_chunkAV7YYSFIcjs.c})}function li(s){let{listener:e,subscribeSelector:t}=s;return t(i=>({isValid:i.isValid,isDirty:i.isDirty,isSubmitting:i.isSubmitting}),e,{paths:["isValid","isDirty","isSubmitting"],equalityFn:(i,r)=>i.isValid===r.isValid&&i.isDirty===r.isDirty&&i.isSubmitting===r.isSubmitting})}function di(s){let{listener:e,subscribeSelector:t}=s;return t(i=>i.persist,e,{paths:["persist"],equalityFn:(i,r)=>i.isSaving===r.isSaving&&i.isRestoring===r.isRestoring&&i.error===r.error})}function ci(s){let{readHistoryMeta:e,subscribeSelector:t,listener:i}=s;return t(()=>e(),i,{paths:[_chunkRHMJPKNVcjs.h.call(void 0, )],equalityFn:(r,n)=>_chunkRHMJPKNVcjs.e.call(void 0, r,n)})}function ui(s){let{scopeName:e,getScopeFields:t,readScopeStatus:i,subscribeSelector:r,listener:n}=s,o=_chunkRHMJPKNVcjs.d.call(void 0, e),a=i(e),l=()=>{},c=()=>{l();let h=_chunkRHMJPKNVcjs.c.call(void 0, t(e));l=r(()=>i(e),f=>{_chunkRHMJPKNVcjs.b.call(void 0, a,f)||(a=f,n(f))},{paths:[...h,o]})};c();let u=!1,d=!1,p=r(()=>t(e).length,()=>{u||(u=!0,queueMicrotask(()=>{if(u=!1,d){l();return}c();let h=i(e);_chunkRHMJPKNVcjs.b.call(void 0, a,h)||(a=h,n(h))}))},{paths:[o]});return()=>{d=!0,l(),p()}}function pi(s){let{runtime:e,config:t,fieldRegistry:i,dirtyManager:r,stateReader:n}=s,o={getState:()=>_chunkOWDDAM6Ccjs.a.call(void 0, n.getState()),getFieldState:d=>_chunkOWDDAM6Ccjs.a.call(void 0, n.getFieldState(d)),getIsValid:()=>n.getFlag("isValid"),getIsSubmitting:()=>n.getFlag("isSubmitting"),getIsDirty:()=>n.getFlag("isDirty"),isHidden:d=>e.capabilities.query.isHidden(d),isRequired:d=>e.capabilities.query.isRequired(d),isFieldDirty:d=>e.capabilities.query.isFieldDirty(d),isFieldValidating:d=>e.capabilities.query.isFieldValidating(d),getDirtyValues:()=>r.buildDirtyValues(n.getState().values),getPersistMetadata:()=>n.getPersistMetadata(),getHistoryMetadata:()=>ii({history:e.capabilities.history}),getScopeStatus:d=>e.capabilities.scope.getScopeStatus(d),getScopeErrors:d=>e.capabilities.scope.getScopeErrors(d),getCanUndo:()=>e.capabilities.history.canUndo,getCanRedo:()=>e.capabilities.history.canRedo,getScopeFields:d=>i.getScopeFields(d,n.getState().values)},a={subscribe:d=>e.subscriptions.subscribe(d),subscribePersistMeta:d=>di({listener:d,subscribeSelector:(p,h,f)=>a.subscribeSelector(p,h,f)}),subscribeHistoryMeta:d=>ci({readHistoryMeta:()=>o.getHistoryMetadata(),subscribeSelector:(p,h,f)=>a.subscribeSelector(p,h,f),listener:d}),subscribeScopeStatus:(d,p)=>ui({scopeName:d,getScopeFields:h=>o.getScopeFields(h),readScopeStatus:h=>o.getScopeStatus(h),subscribeSelector:(h,f,S)=>a.subscribeSelector(h,f,S),listener:p}),subscribeSelector:(d,p,h)=>ni({getState:()=>o.getState(),subscriptions:e.subscriptions,selector:d,listener:p,options:h,trackedSubscriptionsEnabled:!!t.trackedSubscriptions,onUnhandledError:(f,S)=>t.onUnhandledError(f,S)}),subscribePath:(d,p,h)=>oi({path:d,listener:p,options:h,subscribeSelector:(f,S,g)=>a.subscribeSelector(f,S,g)}),subscribeFieldState:(d,p)=>ai({path:d,listener:p,getFieldState:h=>o.getFieldState(h),subscribeSelector:(h,f,S)=>a.subscribeSelector(h,f,S)}),subscribeFormMeta:d=>li({listener:d,subscribeSelector:(p,h,f)=>a.subscribeSelector(p,h,f)})},l={registerField:(d,p)=>{ft({path:d,config:p,state:e.getState(),fieldRegistry:i,subscriptions:e.subscriptions,validationCleanupField:h=>e.capabilities.validation.cleanupField(h),stateReader:n,invalidateFieldIndexes:()=>{i.invalidateIndexes()},dispatch:h=>e.dispatch(h),getState:()=>e.getState(),onUnhandledError:(h,f)=>t.onUnhandledError(h,f)})},unregisterField:d=>{gt({path:d,state:e.getState(),hasStaticConfig:!!_optionalChain([t, 'access', _264 => _264.fields, 'optionalAccess', _265 => _265[d]]),fieldRegistry:i,subscriptions:e.subscriptions,validationCleanupField:p=>e.capabilities.validation.cleanupField(p),invalidateFieldIndexes:()=>{i.invalidateIndexes()},dispatch:p=>e.dispatch(p)})},unregisterPrefix:d=>{oe({prefix:d,state:e.getState(),fieldRegistry:i,subscriptions:e.subscriptions,validationCleanupPrefix:p=>e.capabilities.validation.cleanupPrefix(p),invalidateFieldIndexes:()=>{i.invalidateIndexes()},hasStaticConfigPath:p=>!!_optionalChain([t, 'access', _266 => _266.fields, 'optionalAccess', _267 => _267[p]]),dispatch:p=>e.dispatch(p)})},setField:(d,p)=>{e.runBatch(()=>{e.capabilities.lifecycle.updateField(d,p,{origin:"setField"})})},blurField:d=>{e.capabilities.query.isTouched(d)||e.runBatch(()=>{e.dispatch(je([d]))}),e.flushPendingHistorySnapshot(),e.capabilities.validation.trigger([d])},markFieldsTouched:d=>{d.length!==0&&e.dispatch(je(d))},setValues:(d,p)=>{_optionalChain([p, 'optionalAccess', _268 => _268.rebase])&&e.flushPendingHistorySnapshot(),e.capabilities.lifecycle.setValues(d,p)},setError:(d,p)=>{e.capabilities.error.setError(d,p)},setErrors:d=>{e.capabilities.error.setErrors(d)},setServerErrors:(d,p)=>{e.capabilities.error.setServerErrors(d,p)},reset:()=>{e.flushPendingHistorySnapshot(),e.runBatch(()=>{e.capabilities.lifecycle.reset(),e.cancelPendingHistorySnapshot()})},transaction:d=>e.runBatch(d),submit:d=>(e.flushPendingHistorySnapshot(),e.capabilities.lifecycle.submit(d)),pushItem:(d,p)=>e.capabilities.arrays.pushItem(d,p),prependItem:(d,p)=>e.capabilities.arrays.prependItem(d,p),insertItem:(d,p,h)=>e.capabilities.arrays.insertItem(d,p,h),removeItem:(d,p)=>e.capabilities.arrays.removeItem(d,p),swapItems:(d,p,h)=>e.capabilities.arrays.swapItems(d,p,h),moveItem:(d,p,h)=>e.capabilities.arrays.moveItem(d,p,h),replaceItems:(d,p)=>e.capabilities.arrays.replaceItems(d,p),clearItems:d=>e.capabilities.arrays.clearItems(d)},c=d=>e.dispatch(d);return{read:o,observe:a,write:l,feature:{undo:()=>{e.flushPendingHistorySnapshot(),ei({history:e.capabilities.history,applyHistoryState:d=>e.capabilities.lifecycle.applyHistoryState(d)})},redo:()=>{e.flushPendingHistorySnapshot(),ti({history:e.capabilities.history,applyHistoryState:d=>e.capabilities.lifecycle.applyHistoryState(d)})},validate:d=>e.capabilities.validation.validate(d),hasValidationsInProgress:d=>e.capabilities.validation.hasValidationsInProgress(d),triggerValidation:(d,p)=>e.capabilities.validation.trigger(d,p),restorePersisted:()=>Qt({dispatch:c,effects:e.effects,onUnhandledError:(d,p)=>t.onUnhandledError(d,p)}),forceSave:()=>Xt({dispatch:c,effects:e.effects,onUnhandledError:(d,p)=>t.onUnhandledError(d,p)}),clearPersisted:()=>Zt({dispatch:c,effects:e.effects,onUnhandledError:(d,p)=>t.onUnhandledError(d,p)}),getArrayItemIds:(d,p)=>e.capabilities.arrays.getItemIds(d,p),cleanup:()=>e.cleanup()}}}var hi=s=>Object.freeze(_chunkOWDDAM6Ccjs.a.call(void 0, s));function fi(s){let e=()=>s.read.getState();return{read:{get storeId(){return s.identity.storeId},get config(){return hi(s.identity.config)},get isValid(){return s.read.getIsValid()},get isSubmitting(){return s.read.getIsSubmitting()},get isDirty(){return s.read.getIsDirty()},getState:e,getFieldConfig:o=>{let a=s.getFieldConfig(o);return a?hi(a):void 0},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:e,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,l)=>s.observe.subscribeSelector(o,a,l),subscribePath:(o,a,l)=>s.observe.subscribePath(o,a,l),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,l)=>s.write.insertItem(o,a,l),removeItem:(o,a)=>s.write.removeItem(o,a),moveItem:(o,a,l)=>s.write.moveItem(o,a,l),swapItems:(o,a,l)=>s.write.swapItems(o,a,l),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 we= (_class24 =class{constructor(e){;_class24.prototype.__init73.call(this);this.deps=e}__init73() {this.fieldStateCache=new Map}getState(){return this.deps.getState()}getUserLayer(){let e=this.deps.getState();return{values:e.values,touched:e.touched}}getValidationLayer(){let e=this.deps.getState();return{errors:e.errors,isValidating:e.isValidating,isValid:e.isValid}}getDerivedLayer(){return{isDirty:this.deps.getState().isDirty}}getFeatureLayer(){let e=this.deps.getState();return{persist:e.persist,isSubmitting:e.isSubmitting}}getFlag(e){return this.deps.getState()[e]}getPersistMetadata(){let e=this.deps.getState(),t=e.persist,i=this.persistMetaCache;if(i&&i.state===e&&i.snapshot.isSaving===t.isSaving&&i.snapshot.isRestoring===t.isRestoring&&i.snapshot.error===t.error)return i.snapshot;let r={isSaving:t.isSaving,isRestoring:t.isRestoring,error:t.error};return this.persistMetaCache={state:e,snapshot:r},r}getFieldState(e){let t=e,i=this.deps.getState(),r=this.fieldStateCache.get(t),n=_chunkOWDDAM6Ccjs.f.call(void 0, i.values,t),o=i.errors[t],a=!!i.touched[t],l=this.deps.isHidden(t),c=this.deps.isRequired(t),u=this.deps.isFieldDirty(t),d=this.deps.isFieldValidating(t);if(r){let h=r.snapshot;if(h.value===n&&h.error===o&&h.touched===a&&h.isHidden===l&&h.isRequired===c&&h.isDirty===u&&h.isValidating===d)return h}let p=Ze({state:i,path:e,value:n,isHidden:l,isRequired:c,isDirty:u,isValidating:d});return this.fieldStateCache.set(t,{state:i,snapshot:p}),p}invalidatePath(e){this.fieldStateCache.delete(e)}invalidatePathTree(e){let t=`${e}.`;for(let i of this.fieldStateCache.keys())(i===e||i.startsWith(t))&&this.fieldStateCache.delete(i)}}, _class24);var Ae= (_class25 =class{__init74() {this[H]=!0}__init75() {this[j]=!0}constructor(e={}){;_class25.prototype.__init74.call(this);_class25.prototype.__init75.call(this);let t=Yt({rawConfig:e});this._config=t.config,this.storeId=t.storeId;let i=new we({getState:()=>t.runtime.getState(),isHidden:o=>t.runtime.capabilities.query.isHidden(o),isRequired:o=>t.runtime.capabilities.query.isRequired(o),isFieldDirty:o=>t.runtime.capabilities.query.isFieldDirty(o),isFieldValidating:o=>t.runtime.capabilities.query.isFieldValidating(o)}),r=pi({runtime:t.runtime,config:this._config,fieldRegistry:t.fieldRegistry,dirtyManager:t.dirtyManager,stateReader:i}),n=fi({identity:{storeId:this.storeId,config:this._config},read:r.read,observe:r.observe,write:r.write,feature:r.feature,getFieldConfig:o=>t.fieldRegistry.getFieldConfig(o),resolveMask:o=>Xe({path:o,getFieldConfig:a=>t.fieldRegistry.getFieldConfig(a),masks:t.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,t.runtime.effects.attachStorePort({getState:()=>this.read.getState(),getHistoryMetadata:()=>this.read.getHistoryMetadata(),undo:()=>this.feature.undo(),redo:()=>this.feature.redo(),reset:()=>this.write.reset()})}}, _class25);function gi(s={}){return new Ae(s)}function yi(s){if(!s||typeof s!="object")return!1;let e=s;return e[H]===!0&&!!e.read&&!!e.observe&&!!e.write&&!!e.feature}function Ui(s){if(yi(s))return s;throw new Error("BitForm: o store informado n\xE3o exp\xF5e a API necess\xE1ria para hooks/framework bindings.")}function zi(s){if(!s||typeof s!="object")return!1;let e=s;return e[j]===!0&&typeof e.read=="object"&&typeof e.feature=="object"}function qi(s){if(!yi(s))throw new Error("BitForm: o store informado n\xE3o possui branding de hooks (BIT_HOOKS_API_SYMBOL).");if(!zi(s))throw new Error("BitForm: o store informado n\xE3o possui branding de framework (BIT_FRAMEWORK_STORE_SYMBOL).");return s}function _i(s){return Object.defineProperty(s,H,{value:!0,enumerable:!1,configurable:!1,writable:!1}),Object.defineProperty(s,j,{value:!0,enumerable:!1,configurable:!1,writable:!1}),s}function Li(s={}){let e=gi(s),t={read:e.read,observe:e.observe,write:e.write,feature:e.feature};return _i(t)}function Wi(s){return s.read}function Ni(s){return s.observe}function $i(s){return s.write}function Ki(s){return s.feature}function Ji(s,e){let t={};for(let i of e)t[i]=s[i];return t}exports.a = Re; exports.b = st; exports.c = Ui; exports.d = qi; exports.e = Li; exports.f = Wi; exports.g = Ni; exports.h = $i; exports.i = Ki; exports.j = Ji;
2
- //# sourceMappingURL=chunk-U6UFULNS.cjs.map
@@ -1,2 +0,0 @@
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 _chunkU6UFULNScjs = require('./chunk-U6UFULNS.cjs');var _chunkH27ROY4Fcjs = require('./chunk-H27ROY4F.cjs');var _chunkRHMJPKNVcjs = require('./chunk-RHMJPKNV.cjs');var _chunkAV7YYSFIcjs = require('./chunk-AV7YYSFI.cjs');var _chunkOWDDAM6Ccjs = require('./chunk-OWDDAM6C.cjs');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var G=_react.createContext.call(void 0, null),vt= exports.a =({store:t,children:e})=>{let r=_react.useMemo.call(void 0, ()=>_chunkU6UFULNScjs.d.call(void 0, t),[t]),n=_react.useRef.call(void 0, !1);return _react.useEffect.call(void 0, ()=>(n.current=!1,()=>{n.current=!0,queueMicrotask(()=>{n.current&&(n.current=!1,_optionalChain([r, 'access', _2 => _2.feature, 'optionalAccess', _3 => _3.cleanup, 'optionalCall', _4 => _4()]))})}),[r]),_jsxruntime.jsx.call(void 0, G.Provider,{value:r,children:e})},S= exports.b =()=>{let t=_react.useContext.call(void 0, G);if(!t)throw new Error("BitForm hooks devem ser usados dentro de um BitFormProvider");return t};function Mt(){let t=S(),[e,r]=_react.useState.call(void 0, null),[n,s]=_react.useState.call(void 0, null),o=_react.useRef.call(void 0, null),c=_react.useCallback.call(void 0, p=>_chunkH27ROY4Fcjs.b.call(void 0, t,p),[t]),l=_react.useCallback.call(void 0, ()=>{let p=_chunkH27ROY4Fcjs.a.call(void 0, t);return o.current&&o.current.isValid===p.isValid&&o.current.isDirty===p.isDirty&&o.current.isSubmitting===p.isSubmitting?o.current:(o.current=p,p)},[t]),i=_react.useSyncExternalStore.call(void 0, c,l,l),a=_react.useMemo.call(void 0, ()=>_chunkH27ROY4Fcjs.i.call(void 0, t,{clearSubmissionState:()=>{r(null),s(null)},setSubmissionResult:p=>{s(p)},setSubmissionError:p=>{r(p)}}),[t]),{controller:m,actions:P}=a,b=_react.useCallback.call(void 0, m.submit,[m]),g=_react.useCallback.call(void 0, m.onSubmit,[m]),y=_react.useCallback.call(void 0, m.reset,[m]),F=_react.useCallback.call(void 0, m.getValues,[m]),h=_react.useCallback.call(void 0, m.getErrors,[m]),u=_react.useCallback.call(void 0, m.getTouched,[m]),B=_react.useCallback.call(void 0, m.getDirtyValues,[m]),R=_react.useMemo.call(void 0, ()=>({...i,submitError:e,lastResponse:n}),[i,e,n]);return _react.useMemo.call(void 0, ()=>({meta:R,getValues:F,getErrors:h,getTouched:u,getDirtyValues:B,submit:b,onSubmit:g,reset:y,...P}),[R,F,h,u,B,b,g,y,P])}function jt(t){let e=S(),r=_react.useMemo.call(void 0, ()=>_chunkH27ROY4Fcjs.g.call(void 0, e,t),[e,t]),n=_react.useRef.call(void 0, null),s=_react.useCallback.call(void 0, ()=>{let i=r.readItems();return n.current&&_chunkOWDDAM6Ccjs.c.call(void 0, n.current,i)?n.current:(n.current=i,i)},[r]),o=_react.useCallback.call(void 0, i=>e.observe.subscribePath(t,()=>i()),[e,t]),c=_react.useSyncExternalStore.call(void 0, o,s,s),l=_react.useMemo.call(void 0, ()=>r.getFields(c),[r,c]);return _react.useEffect.call(void 0, ()=>()=>{_chunkH27ROY4Fcjs.k.call(void 0, e,`${t}.`)},[e,t]),_react.useMemo.call(void 0, ()=>({fields:l,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}),[l,c.length,r])}function Wt(t){let e=S(),r=_react.useRef.call(void 0, null),n=_react.useCallback.call(void 0, ()=>{let i=e.read.getScopeStatus(t);return r.current&&_chunkRHMJPKNVcjs.b.call(void 0, r.current,i)?r.current:(r.current=i,i)},[e,t]),s=_react.useCallback.call(void 0, i=>e.observe.subscribeScopeStatus(t,()=>i()),[e,t]),o=_react.useSyncExternalStore.call(void 0, s,n,n),c=_react.useCallback.call(void 0, async()=>{let i=await e.feature.validate({scope:t}),a=e.read.getScopeErrors(t);return{valid:i,errors:a}},[e,t]),l=_react.useCallback.call(void 0, ()=>e.read.getScopeErrors(t),[e,t]);return _react.useMemo.call(void 0, ()=>({scopeName:t,status:o,errors:o.errors,validate:c,getErrors:l,isValid:!o.hasErrors,isDirty:o.isDirty}),[t,o,c,l])}function Gt(t){if(t.length===0)throw new Error("useBitSteps: scopeNames must not be empty");let e=S(),[r,n]=_react.useState.call(void 0, 0),s=_nullishCoalesce(t[r], () => ("")),o=_react.useRef.call(void 0, null),c=_react.useRef.call(void 0, s);c.current=s;let l=_react.useRef.call(void 0, r);l.current=r;let i=_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]),a=_react.useSyncExternalStore.call(void 0, _react.useCallback.call(void 0, u=>e.observe.subscribeScopeStatus(s,()=>u()),[e,s]),i,i),m=_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]),P=_react.useCallback.call(void 0, ()=>e.read.getScopeErrors(s),[e,s]),b=_react.useCallback.call(void 0, async()=>{let u=c.current,B=l.current,R=e.read.getScopeFields(u);if(e.feature.hasValidationsInProgress(R))return!1;let p=await e.feature.validate({scope:u});if(B!==l.current)return!1;if(p)n(M=>Math.min(M+1,t.length-1));else{let M=e.read.getScopeErrors(u),C=Object.keys(M);C.length>0&&e.write.markFieldsTouched(C)}return p},[e,t.length]),g=_react.useCallback.call(void 0, ()=>{n(u=>Math.max(u-1,0))},[]),y=_react.useCallback.call(void 0, u=>{n(Math.max(0,Math.min(u-1,t.length-1)))},[t.length]),F=r===0,h=r>=t.length-1;return _react.useMemo.call(void 0, ()=>({step:r+1,stepIndex:r,scope:s,next:b,prev:g,goTo:y,isFirst:F,isLast:h,status:a,errors:a.errors,isValid:!a.hasErrors,isDirty:a.isDirty,validate:m,getErrors:P}),[r,s,b,g,y,F,h,a,m,P])}function Zt(t){let e=S(),r=_react.useRef.call(void 0, null),n=_react.useCallback.call(void 0, ()=>{let o=_chunkOWDDAM6Ccjs.f.call(void 0, e.read.getState().values,t);return r.current!==null&&_chunkOWDDAM6Ccjs.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,n,n)}function se(){let t=S(),e=_react.useCallback.call(void 0, a=>_chunkH27ROY4Fcjs.e.call(void 0, t,a),[t]),r=_react.useRef.call(void 0, null),n=_react.useCallback.call(void 0, ()=>{let a=_chunkH27ROY4Fcjs.d.call(void 0, t);return r.current&&r.current.isSaving===a.isSaving&&r.current.isRestoring===a.isRestoring&&r.current.error===a.error?r.current:(r.current=a,a)},[t]),s=_react.useSyncExternalStore.call(void 0, e,n,n),o=_react.useCallback.call(void 0, async()=>t.feature.restorePersisted(),[t]),c=_react.useCallback.call(void 0, async()=>{await t.feature.forceSave()},[t]),l=_react.useCallback.call(void 0, async()=>{await t.feature.clearPersisted()},[t]),i=_react.useMemo.call(void 0, ()=>({isSaving:s.isSaving,isRestoring:s.isRestoring,error:s.error}),[s]);return _react.useMemo.call(void 0, ()=>({restore:o,save:c,clear:l,meta:i}),[o,c,l,i])}function me(t){let e=S(),r=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>()=>_chunkH27ROY4Fcjs.j.call(void 0, e,t),[e,t]);let n=_react.useCallback.call(void 0, ()=>{let i=e.read.getFieldState(t),a=_chunkAV7YYSFIcjs.a.call(void 0, i,r.current);return r.current=a,a},[e,t]),s=_react.useCallback.call(void 0, i=>e.observe.subscribeFieldState(t,()=>i()),[e,t]),o=_react.useSyncExternalStore.call(void 0, s,n,n),c=_react.useCallback.call(void 0, i=>e.write.setField(t,i),[e,t]),l=_react.useCallback.call(void 0, ()=>e.write.blurField(t),[e,t]);return{fieldState:o,setValue:c,setBlur:l,store:e}}exports.a = vt; exports.b = S; exports.c = Mt; exports.d = me; exports.e = jt; exports.f = Wt; exports.g = Gt; exports.h = Zt; exports.i = se;
2
- //# sourceMappingURL=chunk-WKLCAC74.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/builds/kenji.ccp-group/bit-form/dist/chunk-WKLCAC74.cjs","../src/react/context.tsx","../src/react/use-bit-form.ts","../src/react/use-bit-array.ts"],"names":["BitContext","createContext","BitFormProvider","store","children","adapted","useMemo","createFrameworkStoreAdapter","cleanupPendingRef","useRef","useEffect","jsx","useBitStore","useContext","useBitForm","submitError","setSubmitError","useState","lastResponse","setLastResponse","lastMeta","subscribeMeta","useCallback","cb","subscribeFormMetaSnapshot","getMetaSnapshot","nextMeta","readFormMetaSnapshot","metaState","useSyncExternalStore","binding","createFrameworkFormBinding","result","error","controller","actions","submit","onSubmit","reset","getValues","getErrors","getTouched","getDirtyValues","meta","useBitArray","path","createArrayBinding","lastSnapshotRef","getSnapshot","next","valueEqual","subscribeArray","data","fields","cleanupRegisteredPrefix"],"mappings":"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","file":"/builds/kenji.ccp-group/bit-form/dist/chunk-WKLCAC74.cjs","sourcesContent":[null,"import React, { createContext, useContext, useEffect, useMemo, useRef } from \"react\";\nimport type { BitFrameworkStoreApi, BitStoreApi } from \"../core\";\nimport { createFrameworkStoreAdapter } from \"../core\";\n\nconst BitContext = createContext<BitFrameworkStoreApi<any> | null>(null);\n\ninterface BitFormProviderProps<T extends object> {\n store: BitFrameworkStoreApi<T> | BitStoreApi<T>;\n children: React.ReactNode;\n}\n\ninterface BitFormProviderRuntimeProps {\n store: unknown;\n children: React.ReactNode;\n}\n\ntype BitFormProviderComponent = {\n <T extends object>(props: BitFormProviderProps<T>): React.ReactElement;\n (props: BitFormProviderRuntimeProps): React.ReactElement;\n};\n\nexport const BitFormProvider: BitFormProviderComponent = ({\n store,\n children,\n}: BitFormProviderRuntimeProps) => {\n const adapted = useMemo(() => createFrameworkStoreAdapter(store), [store]);\n const cleanupPendingRef = useRef(false);\n\n useEffect(() => {\n // On mount (including Strict Mode remount), cancel any pending cleanup.\n cleanupPendingRef.current = false;\n\n return () => {\n // On unmount, flag that cleanup is pending and defer to microtask.\n // React Strict Mode double-mounts (mount → unmount → mount)\n // synchronously. The remount resets cleanupPendingRef before the\n // microtask fires, so Strict Mode cycles are safely ignored.\n cleanupPendingRef.current = true;\n queueMicrotask(() => {\n if (cleanupPendingRef.current) {\n cleanupPendingRef.current = false;\n (adapted as any).feature?.cleanup?.();\n }\n });\n };\n }, [adapted]);\n\n return (\n <BitContext.Provider value={adapted}>\n {children}\n </BitContext.Provider>\n );\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 useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport {\n createFrameworkFormBinding,\n readFormMetaSnapshot,\n subscribeFormMetaSnapshot,\n} from \"../core\";\nimport { useBitStore } from \"./context\";\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 useMemo(\n () => ({\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 meta,\n getValues,\n getErrors,\n getTouched,\n getDirtyValues,\n submit,\n onSubmit,\n reset,\n actions,\n ],\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 useMemo(\n () => ({\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 [fields, data.length, controller],\n );\n}\n"]}