@lehnihon/bit-form 2.2.15 → 2.2.16

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 (95) hide show
  1. package/dist/angular/index.cjs +1 -1
  2. package/dist/angular/index.cjs.map +1 -1
  3. package/dist/angular/index.d.cts +2 -2
  4. package/dist/angular/index.d.ts +2 -2
  5. package/dist/angular/index.js +1 -1
  6. package/dist/angular/index.js.map +1 -1
  7. package/dist/chunk-FRKHIMXO.cjs +2 -0
  8. package/dist/chunk-FRKHIMXO.cjs.map +1 -0
  9. package/dist/chunk-HHDHVLGP.cjs +2 -0
  10. package/dist/chunk-HHDHVLGP.cjs.map +1 -0
  11. package/dist/{chunk-LBISXDNW.js → chunk-HNSQFNCR.js} +2 -2
  12. package/dist/chunk-L7RLUUSB.js +2 -0
  13. package/dist/chunk-L7RLUUSB.js.map +1 -0
  14. package/dist/chunk-PGLND5EZ.js +2 -0
  15. package/dist/chunk-PGLND5EZ.js.map +1 -0
  16. package/dist/chunk-PQYTA2OP.js +2 -0
  17. package/dist/chunk-PQYTA2OP.js.map +1 -0
  18. package/dist/chunk-QCKCONCU.js +2 -0
  19. package/dist/chunk-QCKCONCU.js.map +1 -0
  20. package/dist/{chunk-KGI5PU2P.cjs → chunk-UIBR5FS6.cjs} +2 -2
  21. package/dist/{chunk-KGI5PU2P.cjs.map → chunk-UIBR5FS6.cjs.map} +1 -1
  22. package/dist/chunk-WLOKGOW6.cjs +2 -0
  23. package/dist/chunk-WLOKGOW6.cjs.map +1 -0
  24. package/dist/chunk-WRNR6SXK.cjs +2 -0
  25. package/dist/chunk-WRNR6SXK.cjs.map +1 -0
  26. package/dist/{config-types-D9n-rQLk.d.ts → config-types-BgIAuvzu.d.ts} +1 -2
  27. package/dist/{config-types-5eR82k2V.d.cts → config-types-CewC0AIS.d.cts} +1 -2
  28. package/dist/core/bindings.d.cts +2 -2
  29. package/dist/core/bindings.d.ts +2 -2
  30. package/dist/core/store.cjs +1 -1
  31. package/dist/core/store.cjs.map +1 -1
  32. package/dist/core/store.d.cts +3 -3
  33. package/dist/core/store.d.ts +3 -3
  34. package/dist/core/store.js +1 -1
  35. package/dist/core.cjs +1 -1
  36. package/dist/core.cjs.map +1 -1
  37. package/dist/core.d.cts +2 -2
  38. package/dist/core.d.ts +2 -2
  39. package/dist/core.js +1 -1
  40. package/dist/devtools/bridge.cjs +1 -1
  41. package/dist/devtools/bridge.cjs.map +1 -1
  42. package/dist/devtools/bridge.js +1 -1
  43. package/dist/devtools/index.cjs +2 -2
  44. package/dist/devtools/index.cjs.map +1 -1
  45. package/dist/devtools/index.d.cts +1 -1
  46. package/dist/devtools/index.d.ts +1 -1
  47. package/dist/devtools/index.js +1 -1
  48. package/dist/devtools/index.js.map +1 -1
  49. package/dist/index.cjs +1 -1
  50. package/dist/index.cjs.map +1 -1
  51. package/dist/index.d.cts +2 -2
  52. package/dist/index.d.ts +2 -2
  53. package/dist/index.js +1 -1
  54. package/dist/mask.cjs +1 -1
  55. package/dist/mask.cjs.map +1 -1
  56. package/dist/mask.d.cts +3 -3
  57. package/dist/mask.d.ts +3 -3
  58. package/dist/mask.js +1 -1
  59. package/dist/mask.js.map +1 -1
  60. package/dist/react/index.cjs +1 -1
  61. package/dist/react/index.cjs.map +1 -1
  62. package/dist/react/index.d.cts +4 -5
  63. package/dist/react/index.d.ts +4 -5
  64. package/dist/react/index.js +1 -1
  65. package/dist/react/index.js.map +1 -1
  66. package/dist/react-native/index.cjs +1 -1
  67. package/dist/react-native/index.cjs.map +1 -1
  68. package/dist/react-native/index.d.cts +3 -4
  69. package/dist/react-native/index.d.ts +3 -4
  70. package/dist/react-native/index.js +1 -1
  71. package/dist/react-native/index.js.map +1 -1
  72. package/dist/{store-api-types-DSgYwMS3.d.cts → store-api-types-CVQuHPhm.d.cts} +1 -2
  73. package/dist/{store-api-types-Bozwlwyb.d.ts → store-api-types-Cy-zEhRU.d.ts} +1 -2
  74. package/dist/{use-bit-persist-Bd1H2fge.d.ts → use-bit-persist-BhMBUSzN.d.ts} +13 -5
  75. package/dist/{use-bit-persist-DDxV21AN.d.cts → use-bit-persist-Dt264zYz.d.cts} +13 -5
  76. package/dist/vue/index.cjs +1 -1
  77. package/dist/vue/index.cjs.map +1 -1
  78. package/dist/vue/index.d.cts +2 -2
  79. package/dist/vue/index.d.ts +2 -2
  80. package/dist/vue/index.js +1 -1
  81. package/dist/vue/index.js.map +1 -1
  82. package/package.json +1 -1
  83. package/dist/chunk-4EMYM7JF.cjs +0 -2
  84. package/dist/chunk-4EMYM7JF.cjs.map +0 -1
  85. package/dist/chunk-CIZ6UW2J.cjs +0 -2
  86. package/dist/chunk-CIZ6UW2J.cjs.map +0 -1
  87. package/dist/chunk-IB2BMG4F.cjs +0 -2
  88. package/dist/chunk-IB2BMG4F.cjs.map +0 -1
  89. package/dist/chunk-KMOB6DB6.js +0 -2
  90. package/dist/chunk-KMOB6DB6.js.map +0 -1
  91. package/dist/chunk-NFKYWPEV.js +0 -2
  92. package/dist/chunk-NFKYWPEV.js.map +0 -1
  93. package/dist/chunk-VSNLUHZQ.js +0 -2
  94. package/dist/chunk-VSNLUHZQ.js.map +0 -1
  95. /package/dist/{chunk-LBISXDNW.js.map → chunk-HNSQFNCR.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/vue/context.ts","../../src/vue/use-bit-form.ts","../../src/vue/use-bit-field.ts","../../src/vue/use-bit-array.ts","../../src/vue/use-bit-history.ts","../../src/vue/use-bit-scope.ts","../../src/vue/use-bit-steps.ts","../../src/vue/use-bit-watch.ts","../../src/vue/use-bit-upload.ts","../../src/vue/use-bit-persist.ts"],"sourcesContent":["import { inject, provide, InjectionKey } from \"vue\";\nimport type { BitFrameworkStoreApi, BitStoreApi } from \"../core\";\nimport { createFrameworkStoreAdapter } from \"../core\";\n\n// Chave única para evitar colisões\nexport const BIT_STORE_KEY: InjectionKey<BitFrameworkStoreApi<any>> =\n Symbol(\"BIT_STORE\");\n\nexport function provideBitStore<T extends object>(\n store: BitFrameworkStoreApi<T> | BitStoreApi<T>,\n) {\n provide(BIT_STORE_KEY, createFrameworkStoreAdapter<T>(store));\n}\n\nexport function useBitStore<T extends object>() {\n const store = inject(BIT_STORE_KEY);\n if (!store)\n throw new Error(\n \"BitForm Vue hooks devem ser usados sob um provideBitStore\",\n );\n return store as BitFrameworkStoreApi<T>;\n}\n","import { computed, onUnmounted, shallowRef, ref } from \"vue\";\nimport { useBitStore } from \"./context\";\nimport { createFrameworkFormBinding, observeFormMetaSnapshot } from \"../core\";\nimport type { UseBitFormResult } from \"./types\";\n\nexport function useBitForm<T extends object>(): UseBitFormResult<T> {\n const store = useBitStore<T>();\n const state = shallowRef({\n isValid: true,\n isDirty: false,\n isSubmitting: false,\n });\n const submitError = ref<Error | null>(null);\n const lastResponse = ref<unknown>(null);\n\n const unsubscribe = observeFormMetaSnapshot(store, (nextMeta) => {\n state.value = nextMeta;\n });\n\n onUnmounted(unsubscribe);\n\n const { controller, actions } = createFrameworkFormBinding(store, {\n clearSubmissionState: () => {\n submitError.value = null;\n lastResponse.value = null;\n },\n setSubmissionResult: (result) => {\n lastResponse.value = result;\n },\n setSubmissionError: (error) => {\n submitError.value = error;\n },\n });\n\n const isValid = computed(() => state.value.isValid);\n const isSubmitting = computed(() => state.value.isSubmitting);\n const isDirty = computed(() => state.value.isDirty);\n\n const onSubmit = controller.onSubmit;\n const reset = controller.reset;\n\n const meta = {\n isValid,\n isDirty,\n isSubmitting,\n submitError,\n lastResponse,\n };\n\n return {\n // Metadata (grouped)\n meta,\n // Getters\n getValues: controller.getValues,\n getErrors: controller.getErrors,\n getTouched: controller.getTouched,\n getDirtyValues: controller.getDirtyValues,\n // Main actions (frequent use - flat)\n submit: controller.submit,\n onSubmit,\n reset,\n ...actions,\n };\n}\n","import { computed, onUnmounted, shallowRef } from \"vue\";\nimport { useBitStore } from \"./context\";\nimport type { UseBitFieldVueResult } from \"./types\";\nimport type { BitPath, BitPathValue } from \"../core\";\nimport {\n cleanupRegisteredField,\n createFrameworkMaskedFieldBinding,\n deriveFieldMeta,\n} from \"../core\";\n\nexport function useBitField<\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n>(path: P): UseBitFieldVueResult<BitPathValue<TForm, P>> {\n const store = useBitStore<TForm>();\n\n const { fieldController } = createFrameworkMaskedFieldBinding(store, path);\n\n const state = shallowRef(store.read.getFieldState(path));\n\n const unsubscribe = store.observe.subscribeFieldState(path, (nextState) => {\n state.value = nextState;\n });\n\n onUnmounted(() => {\n unsubscribe();\n cleanupRegisteredField(store, path as string);\n });\n\n const rawValue = computed(() => state.value.value as BitPathValue<TForm, P>);\n\n const displayValue = computed(() =>\n fieldController.displayValue(rawValue.value),\n );\n\n const modelValue = computed({\n get: () => displayValue.value,\n set: (val: string) => {\n fieldController.setValue(val);\n },\n });\n\n const metaState = computed(() => deriveFieldMeta(state.value));\n const error = computed(() => metaState.value.error);\n const touched = computed(() => metaState.value.touched);\n const invalid = computed(() => metaState.value.invalid);\n const isValidating = computed(() => metaState.value.isValidating);\n const isDirty = computed(() => metaState.value.isDirty);\n const isHidden = computed(() => metaState.value.isHidden);\n const isRequired = computed(() => metaState.value.isRequired);\n const hasError = computed(() => metaState.value.hasError);\n\n const setValue = (\n val: BitPathValue<TForm, P> | string | number | null | undefined,\n ) => {\n fieldController.setValue(val);\n };\n\n const setBlur = () => fieldController.setBlur();\n\n const onInput = (\n val: BitPathValue<TForm, P> | string | number | null | undefined,\n ) => {\n setValue(val);\n };\n\n const onBlur = () => {\n setBlur();\n };\n\n return {\n // Main handlers and values (flat)\n value: rawValue,\n displayValue,\n modelValue,\n setValue,\n setBlur,\n onInput,\n onBlur,\n // Metadata (grouped)\n meta: {\n error,\n touched,\n invalid,\n isValidating,\n isDirty,\n isHidden,\n isRequired,\n hasError,\n },\n };\n}\n","import { computed, onUnmounted, shallowRef } from \"vue\";\nimport {\n BitArrayPath,\n cleanupRegisteredPrefix,\n createArrayBinding,\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 = createArrayBinding<TForm, P>(store, path);\n const values = shallowRef(controller.readItems());\n\n const unsubscribe = store.observe.subscribePath(path, () => {\n values.value = controller.readItems();\n });\n\n onUnmounted(() => {\n unsubscribe();\n cleanupRegisteredPrefix(store, `${path as string}.`);\n });\n\n const fields = computed(() => controller.getFields(values.value));\n\n const length = computed(() => values.value.length);\n\n return {\n fields,\n length,\n append: controller.append,\n prepend: controller.prepend,\n insert: controller.insert,\n remove: controller.remove,\n move: controller.move,\n swap: controller.swap,\n replace: controller.replace,\n clear: controller.clear,\n };\n}\n","import { computed, onUnmounted, shallowRef } from \"vue\";\nimport { observeHistoryMetaSnapshot, readHistoryMetaSnapshot } from \"../core\";\nimport { useBitStore } from \"./context\";\nimport type { UseBitHistoryResult } from \"./types\";\n\nexport function useBitHistory<T extends object = any>(): UseBitHistoryResult {\n const store = useBitStore<T>();\n\n const meta = shallowRef(readHistoryMetaSnapshot(store));\n\n const unsubscribe = observeHistoryMetaSnapshot(store, (nextMeta) => {\n meta.value = nextMeta;\n });\n\n onUnmounted(unsubscribe);\n\n const undo = () => store.feature.undo();\n const redo = () => store.feature.redo();\n\n return {\n canUndo: computed(() => meta.value.canUndo),\n canRedo: computed(() => meta.value.canRedo),\n historyIndex: computed(() => meta.value.historyIndex),\n historySize: computed(() => meta.value.historySize),\n undo,\n redo,\n };\n}\n","import { computed, onMounted, onUnmounted, ref } from \"vue\";\nimport type { ScopeStatus, ValidateScopeResult } from \"../core\";\nimport { observeScopeStatusSnapshot } from \"../core\";\nimport { useBitStore } from \"./context\";\n\nexport type { ScopeStatus, ValidateScopeResult };\n\nexport function useBitScope(scopeName: string) {\n const store = useBitStore();\n const status = ref<ScopeStatus>(store.read.getScopeStatus(scopeName));\n let unsubscribe: () => void;\n\n onMounted(() => {\n unsubscribe = observeScopeStatusSnapshot(store, scopeName, (nextStatus) => {\n status.value = nextStatus;\n });\n });\n\n onUnmounted(() => {\n unsubscribe?.();\n });\n\n const validate = async (): Promise<ValidateScopeResult> => {\n const valid = await store.feature.validate({ scope: scopeName });\n const errors = store.read.getScopeErrors(scopeName);\n return { valid, errors };\n };\n\n const getErrors = () => store.read.getScopeErrors(scopeName);\n\n const isValid = computed(() => !status.value.hasErrors);\n const isDirty = computed(() => status.value.isDirty);\n const errors = computed(() => status.value.errors);\n\n return {\n scopeName,\n status,\n errors,\n validate,\n getErrors,\n isValid,\n isDirty,\n };\n}\n","import { computed, onMounted, onUnmounted, ref, watch } from \"vue\";\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 const store = useBitStore();\n const stepIndex = ref(0);\n\n const scope = computed(() => scopeNames[stepIndex.value] ?? \"\");\n const status = ref<ScopeStatus>(store.read.getScopeStatus(scope.value));\n let unsubscribe: (() => void) | undefined;\n\n watch(scope, (newScope) => {\n status.value = store.read.getScopeStatus(newScope);\n unsubscribe?.();\n unsubscribe = store.observe.subscribeScopeStatus(newScope, updateStatus);\n });\n\n const updateStatus = () => {\n const scopeName = scope.value;\n const newStatus = store.read.getScopeStatus(scopeName);\n if (!isScopeStatusEqual(status.value, newStatus)) {\n status.value = newStatus;\n }\n };\n\n onMounted(() => {\n unsubscribe = store.observe.subscribeScopeStatus(scope.value, updateStatus);\n });\n\n onUnmounted(() => {\n unsubscribe?.();\n });\n\n const validate = async (): Promise<ValidateScopeResult> => {\n const scopeName = scope.value;\n const valid = await store.feature.validate({ scope: scopeName });\n const errors = store.read.getScopeErrors(scopeName);\n return { valid, errors };\n };\n\n const getErrors = () => store.read.getScopeErrors(scope.value);\n\n const next = async (): Promise<boolean> => {\n const scopeName = scope.value;\n\n const scopeFields = store.read.getScopeFields(scopeName);\n if (store.feature.hasValidationsInProgress(scopeFields)) {\n return false;\n }\n\n const valid = await store.feature.validate({ scope: scopeName });\n if (valid) {\n stepIndex.value = Math.min(stepIndex.value + 1, scopeNames.length - 1);\n } else {\n const errors = store.read.getScopeErrors(scopeName);\n const pathsWithErrors = Object.keys(errors);\n if (pathsWithErrors.length > 0) {\n store.write.markFieldsTouched(pathsWithErrors);\n }\n }\n return valid;\n };\n\n const prev = () => {\n stepIndex.value = Math.max(stepIndex.value - 1, 0);\n };\n\n const goTo = (targetStep: number) => {\n stepIndex.value = Math.max(\n 0,\n Math.min(targetStep - 1, scopeNames.length - 1),\n );\n };\n\n const step = computed(() => stepIndex.value + 1);\n const isFirst = computed(() => stepIndex.value === 0);\n const isLast = computed(() => stepIndex.value >= scopeNames.length - 1);\n const isValid = computed(() => !status.value.hasErrors);\n const isDirty = computed(() => status.value.isDirty);\n const errors = computed(() => status.value.errors);\n\n return {\n step,\n stepIndex,\n scope,\n next,\n prev,\n goTo,\n isFirst,\n isLast,\n status,\n errors,\n isValid,\n isDirty,\n validate,\n getErrors,\n };\n}\n","import { ref, onUnmounted, readonly } from \"vue\";\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) {\n const store = useBitStore<TForm>();\n const initialValue = getDeepValue(\n store.read.getState().values,\n path as string,\n ) as BitPathValue<TForm, P>;\n const value = ref<BitPathValue<TForm, P>>(initialValue);\n\n const unsubscribe = store.observe.subscribePath(path, (newValue) => {\n if (!valueEqual(value.value, newValue)) {\n value.value = newValue as BitPathValue<TForm, P>;\n }\n });\n\n onUnmounted(unsubscribe);\n\n return readonly(value);\n}\n","/**\n * Vue Composition API for File Upload\n *\n * Minimal upload API integrated with global field validation lifecycle.\n */\n\nimport { computed, ComputedRef, ref } from \"vue\";\nimport type { BitDeleteUploadFn, BitUploadFn } from \"../core\";\nimport { createRemoveHandler, createUploadHandler } from \"../core/adapters\";\nimport { useBitStore } from \"./context\";\nimport type { UseBitUploadResult } from \"./types\";\nimport { useBitField } from \"./use-bit-field\";\n\nexport function useBitUpload<\n TMetadata extends Record<string, unknown> = Record<string, unknown>,\n>(\n fieldPath: string,\n uploadFn: BitUploadFn<TMetadata>,\n deleteFile?: BitDeleteUploadFn,\n): UseBitUploadResult {\n const store = useBitStore<any>();\n const field = useBitField(fieldPath);\n let uploadKey: string | null = null;\n const isUploading = ref(false);\n\n const kernelCallbacks = {\n setLoading: (val: boolean) => {\n isUploading.value = val;\n },\n setError: (path: string, msg: string | undefined) =>\n store.write.setError(path, msg),\n setValue: (val: string | null) => field.setValue(val),\n getUploadKey: () => uploadKey,\n setUploadKey: (key: string | null) => {\n uploadKey = key;\n },\n };\n\n const upload = createUploadHandler(fieldPath, uploadFn, kernelCallbacks);\n const remove = createRemoveHandler(fieldPath, deleteFile, kernelCallbacks);\n\n return {\n value: field.value as ComputedRef<string | File | null>,\n setValue: field.setValue,\n error: computed(() => field.meta.error.value),\n isValidating: computed(\n () => !!field.meta.isValidating.value || isUploading.value,\n ),\n upload,\n remove,\n };\n}\n","import { computed, onUnmounted, ref } from \"vue\";\nimport { useBitStore } from \"./context\";\nimport { observePersistMetaSnapshot } from \"../core\";\nimport type { UseBitPersistResult } from \"./types\";\n\nexport function useBitPersist<T extends object = any>(): UseBitPersistResult {\n const store = useBitStore<T>();\n const meta = ref(store.read.getPersistMetadata());\n\n const unsubscribe = observePersistMetaSnapshot(store, (nextMeta) => {\n meta.value = nextMeta;\n });\n\n onUnmounted(() => unsubscribe());\n\n const restore = async (): Promise<boolean> => {\n return store.feature.restorePersisted();\n };\n\n const save = async (): Promise<void> => {\n await store.feature.forceSave();\n };\n\n const clear = async (): Promise<void> => {\n await store.feature.clearPersisted();\n };\n\n return {\n restore,\n save,\n clear,\n meta: {\n isSaving: computed(() => meta.value.isSaving),\n isRestoring: computed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","useBitStore","inject","computed","onUnmounted","shallowRef","ref","useBitForm","store","useBitStore","state","shallowRef","submitError","ref","lastResponse","unsubscribe","observeFormMetaSnapshot","nextMeta","onUnmounted","controller","actions","createFrameworkFormBinding","result","error","isValid","computed","isSubmitting","isDirty","onSubmit","reset","computed","onUnmounted","shallowRef","useBitField","path","store","useBitStore","fieldController","createFrameworkMaskedFieldBinding","state","shallowRef","unsubscribe","nextState","onUnmounted","cleanupRegisteredField","rawValue","computed","displayValue","modelValue","val","metaState","deriveFieldMeta","error","touched","invalid","isValidating","isDirty","isHidden","isRequired","hasError","setValue","setBlur","computed","onUnmounted","shallowRef","useBitArray","path","store","useBitStore","controller","createArrayBinding","values","shallowRef","unsubscribe","onUnmounted","cleanupRegisteredPrefix","fields","computed","length","computed","onUnmounted","shallowRef","useBitHistory","store","useBitStore","meta","shallowRef","readHistoryMetaSnapshot","unsubscribe","observeHistoryMetaSnapshot","nextMeta","onUnmounted","undo","redo","computed","computed","onMounted","onUnmounted","ref","useBitScope","scopeName","store","useBitStore","status","ref","unsubscribe","onMounted","observeScopeStatusSnapshot","nextStatus","onUnmounted","validate","valid","errors","getErrors","isValid","computed","isDirty","computed","onMounted","onUnmounted","ref","watch","useBitSteps","scopeNames","store","useBitStore","stepIndex","ref","scope","computed","status","unsubscribe","watch","newScope","updateStatus","scopeName","newStatus","isScopeStatusEqual","onMounted","onUnmounted","validate","valid","errors","getErrors","next","scopeFields","pathsWithErrors","prev","goTo","targetStep","step","isFirst","isLast","isValid","isDirty","ref","onUnmounted","readonly","useBitWatch","path","store","useBitStore","initialValue","getDeepValue","value","ref","unsubscribe","newValue","valueEqual","onUnmounted","readonly","computed","ref","useBitUpload","fieldPath","uploadFn","deleteFile","store","useBitStore","field","useBitField","uploadKey","isUploading","ref","kernelCallbacks","val","path","msg","key","upload","createUploadHandler","remove","createRemoveHandler","computed","computed","onUnmounted","ref","useBitPersist","store","useBitStore","meta","ref","unsubscribe","observePersistMetaSnapshot","nextMeta","onUnmounted","computed"]}
1
+ {"version":3,"sources":["../../src/vue/context.ts","../../src/vue/use-bit-form.ts","../../src/vue/use-bit-field.ts","../../src/vue/use-bit-array.ts","../../src/vue/use-bit-history.ts","../../src/vue/use-bit-scope.ts","../../src/vue/use-bit-steps.ts","../../src/vue/use-bit-watch.ts","../../src/vue/use-bit-upload.ts","../../src/vue/use-bit-persist.ts"],"sourcesContent":["import { inject, provide, InjectionKey } from \"vue\";\nimport type { BitFrameworkStoreApi, BitStoreApi } from \"../core\";\nimport { createFrameworkStoreAdapter } from \"../core\";\n\n// Chave única para evitar colisões\nexport const BIT_STORE_KEY: InjectionKey<BitFrameworkStoreApi<any>> =\n Symbol(\"BIT_STORE\");\n\nexport function provideBitStore<T extends object>(\n store: BitFrameworkStoreApi<T> | BitStoreApi<T>,\n) {\n provide(BIT_STORE_KEY, createFrameworkStoreAdapter<T>(store));\n}\n\nexport function useBitStore<T extends object>() {\n const store = inject(BIT_STORE_KEY);\n if (!store)\n throw new Error(\n \"BitForm Vue hooks devem ser usados sob um provideBitStore\",\n );\n return store as BitFrameworkStoreApi<T>;\n}\n","import { computed, onUnmounted, shallowRef, ref } from \"vue\";\nimport { useBitStore } from \"./context\";\nimport { createFrameworkFormBinding, observeFormMetaSnapshot } from \"../core\";\nimport type { UseBitFormResult } from \"./types\";\n\nexport function useBitForm<T extends object>(): UseBitFormResult<T> {\n const store = useBitStore<T>();\n const state = shallowRef({\n isValid: true,\n isDirty: false,\n isSubmitting: false,\n });\n const submitError = ref<Error | null>(null);\n const lastResponse = ref<unknown>(null);\n\n const unsubscribe = observeFormMetaSnapshot(store, (nextMeta) => {\n state.value = nextMeta;\n });\n\n onUnmounted(unsubscribe);\n\n const { controller, actions } = createFrameworkFormBinding(store, {\n clearSubmissionState: () => {\n submitError.value = null;\n lastResponse.value = null;\n },\n setSubmissionResult: (result) => {\n lastResponse.value = result;\n },\n setSubmissionError: (error) => {\n submitError.value = error;\n },\n });\n\n const isValid = computed(() => state.value.isValid);\n const isSubmitting = computed(() => state.value.isSubmitting);\n const isDirty = computed(() => state.value.isDirty);\n\n const onSubmit = controller.onSubmit;\n const reset = controller.reset;\n\n const meta = {\n isValid,\n isDirty,\n isSubmitting,\n submitError,\n lastResponse,\n };\n\n return {\n // Metadata (grouped)\n meta,\n // Getters\n getValues: controller.getValues,\n getErrors: controller.getErrors,\n getTouched: controller.getTouched,\n getDirtyValues: controller.getDirtyValues,\n // Main actions (frequent use - flat)\n submit: controller.submit,\n onSubmit,\n reset,\n ...actions,\n };\n}\n","import { computed, onUnmounted, shallowRef } from \"vue\";\nimport { useBitStore } from \"./context\";\nimport type { UseBitFieldVueResult } from \"./types\";\nimport type { BitPath, BitPathValue } from \"../core\";\nimport {\n cleanupRegisteredField,\n createFrameworkMaskedFieldBinding,\n deriveFieldMeta,\n} from \"../core\";\n\nexport function useBitField<\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n>(path: P): UseBitFieldVueResult<BitPathValue<TForm, P>> {\n const store = useBitStore<TForm>();\n\n const { fieldController } = createFrameworkMaskedFieldBinding(store, path);\n\n const state = shallowRef(store.read.getFieldState(path));\n\n const unsubscribe = store.observe.subscribeFieldState(path, (nextState) => {\n state.value = nextState;\n });\n\n onUnmounted(() => {\n unsubscribe();\n cleanupRegisteredField(store, path as string);\n });\n\n const rawValue = computed(() => state.value.value as BitPathValue<TForm, P>);\n\n const displayValue = computed(() =>\n fieldController.displayValue(rawValue.value),\n );\n\n const modelValue = computed({\n get: () => displayValue.value,\n set: (val: string) => {\n fieldController.setValue(val);\n },\n });\n\n const metaState = computed(() => deriveFieldMeta(state.value));\n const error = computed(() => metaState.value.error);\n const touched = computed(() => metaState.value.touched);\n const invalid = computed(() => metaState.value.invalid);\n const isValidating = computed(() => metaState.value.isValidating);\n const isDirty = computed(() => metaState.value.isDirty);\n const isHidden = computed(() => metaState.value.isHidden);\n const isRequired = computed(() => metaState.value.isRequired);\n const hasError = computed(() => metaState.value.hasError);\n\n const setValue = (\n val: BitPathValue<TForm, P> | string | number | null | undefined,\n ) => {\n fieldController.setValue(val);\n };\n\n const setBlur = () => fieldController.setBlur();\n\n const onInput = (\n val: BitPathValue<TForm, P> | string | number | null | undefined,\n ) => {\n setValue(val);\n };\n\n const onBlur = () => {\n setBlur();\n };\n\n return {\n // Main handlers and values (flat)\n value: rawValue,\n displayValue,\n modelValue,\n setValue,\n setBlur,\n onInput,\n onBlur,\n // Metadata (grouped)\n meta: {\n error,\n touched,\n invalid,\n isValidating,\n isDirty,\n isHidden,\n isRequired,\n hasError,\n },\n };\n}\n","import { computed, onUnmounted, shallowRef } from \"vue\";\nimport {\n BitArrayPath,\n cleanupRegisteredPrefix,\n createArrayBinding,\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 = createArrayBinding<TForm, P>(store, path);\n const values = shallowRef(controller.readItems());\n\n const unsubscribe = store.observe.subscribePath(path, () => {\n values.value = controller.readItems();\n });\n\n onUnmounted(() => {\n unsubscribe();\n cleanupRegisteredPrefix(store, `${path as string}.`);\n });\n\n const fields = computed(() => controller.getFields(values.value));\n\n const length = computed(() => values.value.length);\n\n return {\n fields,\n length,\n append: controller.append,\n prepend: controller.prepend,\n insert: controller.insert,\n remove: controller.remove,\n move: controller.move,\n swap: controller.swap,\n replace: controller.replace,\n clear: controller.clear,\n };\n}\n","import { computed, onUnmounted, shallowRef } from \"vue\";\nimport { observeHistoryMetaSnapshot, readHistoryMetaSnapshot } from \"../core\";\nimport { useBitStore } from \"./context\";\nimport type { UseBitHistoryResult } from \"./types\";\n\nexport function useBitHistory<T extends object = any>(): UseBitHistoryResult {\n const store = useBitStore<T>();\n\n const meta = shallowRef(readHistoryMetaSnapshot(store));\n\n const unsubscribe = observeHistoryMetaSnapshot(store, (nextMeta) => {\n meta.value = nextMeta;\n });\n\n onUnmounted(unsubscribe);\n\n const undo = () => store.feature.undo();\n const redo = () => store.feature.redo();\n\n return {\n canUndo: computed(() => meta.value.canUndo),\n canRedo: computed(() => meta.value.canRedo),\n historyIndex: computed(() => meta.value.historyIndex),\n historySize: computed(() => meta.value.historySize),\n undo,\n redo,\n };\n}\n","import { computed, onMounted, onUnmounted, ref } from \"vue\";\nimport type { ScopeStatus, ValidateScopeResult } from \"../core\";\nimport { observeScopeStatusSnapshot } from \"../core\";\nimport { useBitStore } from \"./context\";\n\nexport type { ScopeStatus, ValidateScopeResult };\n\nexport function useBitScope(scopeName: string) {\n const store = useBitStore();\n const status = ref<ScopeStatus>(store.read.getScopeStatus(scopeName));\n let unsubscribe: () => void;\n\n onMounted(() => {\n unsubscribe = observeScopeStatusSnapshot(store, scopeName, (nextStatus) => {\n status.value = nextStatus;\n });\n });\n\n onUnmounted(() => {\n unsubscribe?.();\n });\n\n const validate = async (): Promise<ValidateScopeResult> => {\n const valid = await store.feature.validate({ scope: scopeName });\n const errors = store.read.getScopeErrors(scopeName);\n return { valid, errors };\n };\n\n const getErrors = () => store.read.getScopeErrors(scopeName);\n\n const isValid = computed(() => !status.value.hasErrors);\n const isDirty = computed(() => status.value.isDirty);\n const errors = computed(() => status.value.errors);\n\n return {\n scopeName,\n status,\n errors,\n validate,\n getErrors,\n isValid,\n isDirty,\n };\n}\n","import { computed, onMounted, onUnmounted, ref, watch } from \"vue\";\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 const store = useBitStore();\n const stepIndex = ref(0);\n\n const scope = computed(() => scopeNames[stepIndex.value] ?? \"\");\n const status = ref<ScopeStatus>(store.read.getScopeStatus(scope.value));\n let unsubscribe: (() => void) | undefined;\n\n watch(scope, (newScope) => {\n status.value = store.read.getScopeStatus(newScope);\n unsubscribe?.();\n unsubscribe = store.observe.subscribeScopeStatus(newScope, updateStatus);\n });\n\n const updateStatus = () => {\n const scopeName = scope.value;\n const newStatus = store.read.getScopeStatus(scopeName);\n if (!isScopeStatusEqual(status.value, newStatus)) {\n status.value = newStatus;\n }\n };\n\n onMounted(() => {\n unsubscribe = store.observe.subscribeScopeStatus(scope.value, updateStatus);\n });\n\n onUnmounted(() => {\n unsubscribe?.();\n });\n\n const validate = async (): Promise<ValidateScopeResult> => {\n const scopeName = scope.value;\n const valid = await store.feature.validate({ scope: scopeName });\n const errors = store.read.getScopeErrors(scopeName);\n return { valid, errors };\n };\n\n const getErrors = () => store.read.getScopeErrors(scope.value);\n\n const next = async (): Promise<boolean> => {\n const scopeName = scope.value;\n\n const scopeFields = store.read.getScopeFields(scopeName);\n if (store.feature.hasValidationsInProgress(scopeFields)) {\n return false;\n }\n\n const valid = await store.feature.validate({ scope: scopeName });\n if (valid) {\n stepIndex.value = Math.min(stepIndex.value + 1, scopeNames.length - 1);\n } else {\n const errors = store.read.getScopeErrors(scopeName);\n const pathsWithErrors = Object.keys(errors);\n if (pathsWithErrors.length > 0) {\n store.write.markFieldsTouched(pathsWithErrors);\n }\n }\n return valid;\n };\n\n const prev = () => {\n stepIndex.value = Math.max(stepIndex.value - 1, 0);\n };\n\n const goTo = (targetStep: number) => {\n stepIndex.value = Math.max(\n 0,\n Math.min(targetStep - 1, scopeNames.length - 1),\n );\n };\n\n const step = computed(() => stepIndex.value + 1);\n const isFirst = computed(() => stepIndex.value === 0);\n const isLast = computed(() => stepIndex.value >= scopeNames.length - 1);\n const isValid = computed(() => !status.value.hasErrors);\n const isDirty = computed(() => status.value.isDirty);\n const errors = computed(() => status.value.errors);\n\n return {\n step,\n stepIndex,\n scope,\n next,\n prev,\n goTo,\n isFirst,\n isLast,\n status,\n errors,\n isValid,\n isDirty,\n validate,\n getErrors,\n };\n}\n","import { ref, onUnmounted, readonly } from \"vue\";\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) {\n const store = useBitStore<TForm>();\n const initialValue = getDeepValue(\n store.read.getState().values,\n path as string,\n ) as BitPathValue<TForm, P>;\n const value = ref<BitPathValue<TForm, P>>(initialValue);\n\n const unsubscribe = store.observe.subscribePath(path, (newValue) => {\n if (!valueEqual(value.value, newValue)) {\n value.value = newValue as BitPathValue<TForm, P>;\n }\n });\n\n onUnmounted(unsubscribe);\n\n return readonly(value);\n}\n","/**\n * Vue Composition API for File Upload\n *\n * Minimal upload API integrated with global field validation lifecycle.\n */\n\nimport { computed, ComputedRef, ref } from \"vue\";\nimport type { BitDeleteUploadFn, BitUploadFn } from \"../core\";\nimport { createRemoveHandler, createUploadHandler } from \"../core/adapters\";\nimport { useBitStore } from \"./context\";\nimport type { UseBitUploadResult } from \"./types\";\nimport { useBitField } from \"./use-bit-field\";\n\nexport function useBitUpload<\n TMetadata extends Record<string, unknown> = Record<string, unknown>,\n>(\n fieldPath: string,\n uploadFn: BitUploadFn<TMetadata>,\n deleteFile?: BitDeleteUploadFn,\n): UseBitUploadResult {\n const store = useBitStore<any>();\n const field = useBitField(fieldPath);\n let uploadKey: string | null = null;\n const isUploading = ref(false);\n\n const kernelCallbacks = {\n setLoading: (val: boolean) => {\n isUploading.value = val;\n },\n setError: (path: string, msg: string | undefined) =>\n store.write.setError(path, msg),\n setValue: (val: string | null) => field.setValue(val),\n getUploadKey: () => uploadKey,\n setUploadKey: (key: string | null) => {\n uploadKey = key;\n },\n };\n\n const upload = createUploadHandler(fieldPath, uploadFn, kernelCallbacks);\n const remove = createRemoveHandler(fieldPath, deleteFile, kernelCallbacks);\n\n return {\n value: field.value as ComputedRef<string | File | null>,\n setValue: field.setValue,\n error: computed(() => field.meta.error.value),\n isValidating: computed(\n () => !!field.meta.isValidating.value || isUploading.value,\n ),\n upload,\n remove,\n };\n}\n","import { computed, onUnmounted, ref } from \"vue\";\nimport { useBitStore } from \"./context\";\nimport { observePersistMetaSnapshot } from \"../core\";\nimport type { UseBitPersistResult } from \"./types\";\n\nexport function useBitPersist<T extends object = any>(): UseBitPersistResult {\n const store = useBitStore<T>();\n const meta = ref(store.read.getPersistMetadata());\n\n const unsubscribe = observePersistMetaSnapshot(store, (nextMeta) => {\n meta.value = nextMeta;\n });\n\n onUnmounted(() => unsubscribe());\n\n const restore = async (): Promise<boolean> => {\n return store.feature.restorePersisted();\n };\n\n const save = async (): Promise<void> => {\n await store.feature.forceSave();\n };\n\n const clear = async (): Promise<void> => {\n await store.feature.clearPersisted();\n };\n\n return {\n restore,\n save,\n clear,\n meta: {\n isSaving: computed(() => meta.value.isSaving),\n isRestoring: computed(() => meta.value.isRestoring),\n error: computed(() => meta.value.error),\n },\n };\n}\n"],"mappings":"ydAAA,OAAS,UAAAA,EAAQ,WAAAC,OAA6B,MAKvC,IAAMC,EACX,OAAO,WAAW,EAEb,SAASC,GACdC,EACA,CACAC,GAAQH,EAAeI,EAA+BF,CAAK,CAAC,CAC9D,CAEO,SAASG,GAAgC,CAC9C,IAAMH,EAAQI,EAAON,CAAa,EAClC,GAAI,CAACE,EACH,MAAM,IAAI,MACR,2DACF,EACF,OAAOA,CACT,CCrBA,OAAS,YAAAK,EAAU,eAAAC,GAAa,cAAAC,GAAY,OAAAC,MAAW,MAKhD,SAASC,IAAoD,CAClE,IAAMC,EAAQC,EAAe,EACvBC,EAAQC,GAAW,CACvB,QAAS,GACT,QAAS,GACT,aAAc,EAChB,CAAC,EACKC,EAAcC,EAAkB,IAAI,EACpCC,EAAeD,EAAa,IAAI,EAEhCE,EAAcC,EAAwBR,EAAQS,GAAa,CAC/DP,EAAM,MAAQO,CAChB,CAAC,EAEDC,GAAYH,CAAW,EAEvB,GAAM,CAAE,WAAAI,EAAY,QAAAC,CAAQ,EAAIC,EAA2Bb,EAAO,CAChE,qBAAsB,IAAM,CAC1BI,EAAY,MAAQ,KACpBE,EAAa,MAAQ,IACvB,EACA,oBAAsBQ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K,MAAQI,CACf,CAAC,EAED,OAAAC,GAAY,IAAMH,EAAY,CAAC,EAcxB,CACL,QAbc,SACPJ,EAAM,QAAQ,iBAAiB,EAatC,KAVW,SAA2B,CACtC,MAAMA,EAAM,QAAQ,UAAU,CAChC,EASE,MAPY,SAA2B,CACvC,MAAMA,EAAM,QAAQ,eAAe,CACrC,EAME,KAAM,CACJ,SAAUQ,EAAS,IAAMN,EAAK,MAAM,QAAQ,EAC5C,YAAaM,EAAS,IAAMN,EAAK,MAAM,WAAW,EAClD,MAAOM,EAAS,IAAMN,EAAK,MAAM,KAAK,CACxC,CACF,CACF","names":["inject","provide","BIT_STORE_KEY","provideBitStore","store","provide","createFrameworkStoreAdapter","useBitStore","inject","computed","onUnmounted","shallowRef","ref","useBitForm","store","useBitStore","state","shallowRef","submitError","ref","lastResponse","unsubscribe","observeFormMetaSnapshot","nextMeta","onUnmounted","controller","actions","createFrameworkFormBinding","result","error","isValid","computed","isSubmitting","isDirty","onSubmit","reset","computed","onUnmounted","shallowRef","useBitField","path","store","useBitStore","fieldController","createFrameworkMaskedFieldBinding","state","shallowRef","unsubscribe","nextState","onUnmounted","cleanupRegisteredField","rawValue","computed","displayValue","modelValue","val","metaState","deriveFieldMeta","error","touched","invalid","isValidating","isDirty","isHidden","isRequired","hasError","setValue","setBlur","computed","onUnmounted","shallowRef","useBitArray","path","store","useBitStore","controller","createArrayBinding","values","shallowRef","unsubscribe","onUnmounted","cleanupRegisteredPrefix","fields","computed","length","computed","onUnmounted","shallowRef","useBitHistory","store","useBitStore","meta","shallowRef","readHistoryMetaSnapshot","unsubscribe","observeHistoryMetaSnapshot","nextMeta","onUnmounted","undo","redo","computed","computed","onMounted","onUnmounted","ref","useBitScope","scopeName","store","useBitStore","status","ref","unsubscribe","onMounted","observeScopeStatusSnapshot","nextStatus","onUnmounted","validate","valid","errors","getErrors","isValid","computed","isDirty","computed","onMounted","onUnmounted","ref","watch","useBitSteps","scopeNames","store","useBitStore","stepIndex","ref","scope","computed","status","unsubscribe","watch","newScope","updateStatus","scopeName","newStatus","isScopeStatusEqual","onMounted","onUnmounted","validate","valid","errors","getErrors","next","scopeFields","pathsWithErrors","prev","goTo","targetStep","step","isFirst","isLast","isValid","isDirty","ref","onUnmounted","readonly","useBitWatch","path","store","useBitStore","initialValue","getDeepValue","value","ref","unsubscribe","newValue","valueEqual","onUnmounted","readonly","computed","ref","useBitUpload","fieldPath","uploadFn","deleteFile","store","useBitStore","field","useBitField","uploadKey","isUploading","ref","kernelCallbacks","val","path","msg","key","upload","createUploadHandler","remove","createRemoveHandler","computed","computed","onUnmounted","ref","useBitPersist","store","useBitStore","meta","ref","unsubscribe","observePersistMetaSnapshot","nextMeta","onUnmounted","computed"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lehnihon/bit-form",
3
- "version": "2.2.15",
3
+ "version": "2.2.16",
4
4
  "description": "Gerenciamento de estado de formulários agnóstico e performático",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});function t(r){try{r()}catch (e2){}}function l(r,o,e){let n=0;return async a=>{if(!a)return;let d=++n;t(()=>e.setLoading(!0)),t(()=>e.setError(r,void 0));try{let i=await o(a);if(d!==n)return;t(()=>e.setValue(i.url)),t(()=>e.setUploadKey(i.key)),t(()=>e.setError(r,void 0))}catch(i){if(d!==n)return;let s=i instanceof Error?i.message:"Upload failed";t(()=>e.setError(r,s))}finally{d===n&&t(()=>e.setLoading(!1))}}}function u(r,o,e){return async()=>{let n=e.getUploadKey();if(n&&o)try{await o(n)}catch(a){let d=a instanceof Error?a.message:"Delete failed";e.setError(r,d);return}e.setValue(null),e.setUploadKey(null),e.setError(r,void 0)}}exports.a = l; exports.b = u;
2
- //# sourceMappingURL=chunk-4EMYM7JF.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/adapters/upload-kernel.ts"],"names":["safeCallbackExecution","fn","createUploadHandler","fieldPath","uploadFn","callbacks","currentGeneration","file","myGeneration","result","error","message","createRemoveHandler","deleteFile","uploadKey"],"mappings":"AAqCA,kFAASA,CAAAA,CAAsBC,CAAAA,CAAsB,CACnD,GAAI,CACFA,CAAAA,CAAG,CACL,CAAA,UAAgB,CAEhB,CACF,CAEO,SAASC,CAAAA,CAGdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACkD,CAClD,IAAIC,CAAAA,CAAoB,CAAA,CACxB,OAAO,MAAOC,CAAAA,EAAS,CACrB,EAAA,CAAI,CAACA,CAAAA,CAAM,MAAA,CAEX,IAAMC,CAAAA,CAAe,EAAEF,CAAAA,CACvBN,CAAAA,CAAsB,CAAA,CAAA,EAAMK,CAAAA,CAAU,UAAA,CAAW,CAAA,CAAI,CAAC,CAAA,CACtDL,CAAAA,CAAsB,CAAA,CAAA,EAAMK,CAAAA,CAAU,QAAA,CAASF,CAAAA,CAAW,KAAA,CAAS,CAAC,CAAA,CAEpE,GAAI,CACF,IAAMM,CAAAA,CAAS,MAAML,CAAAA,CAASG,CAAI,CAAA,CAElC,EAAA,CAAIC,CAAAA,GAAiBF,CAAAA,CAAmB,MAAA,CACxCN,CAAAA,CAAsB,CAAA,CAAA,EAAMK,CAAAA,CAAU,QAAA,CAASI,CAAAA,CAAO,GAAG,CAAC,CAAA,CAC1DT,CAAAA,CAAsB,CAAA,CAAA,EAAMK,CAAAA,CAAU,YAAA,CAAaI,CAAAA,CAAO,GAAG,CAAC,CAAA,CAC9DT,CAAAA,CAAsB,CAAA,CAAA,EAAMK,CAAAA,CAAU,QAAA,CAASF,CAAAA,CAAW,KAAA,CAAS,CAAC,CACtE,CAAA,KAAA,CAASO,CAAAA,CAAO,CACd,EAAA,CAAIF,CAAAA,GAAiBF,CAAAA,CAAmB,MAAA,CACxC,IAAMK,CAAAA,CAAUD,EAAAA,WAAiB,KAAA,CAAQA,CAAAA,CAAM,OAAA,CAAU,eAAA,CACzDV,CAAAA,CAAsB,CAAA,CAAA,EAAMK,CAAAA,CAAU,QAAA,CAASF,CAAAA,CAAWQ,CAAO,CAAC,CACpE,CAAA,OAAE,CACIH,CAAAA,GAAiBF,CAAAA,EACnBN,CAAAA,CAAsB,CAAA,CAAA,EAAMK,CAAAA,CAAU,UAAA,CAAW,CAAA,CAAK,CAAC,CAE3D,CACF,CACF,CAKO,SAASO,CAAAA,CACdT,CAAAA,CACAU,CAAAA,CACAR,CAAAA,CACqB,CACrB,OAAO,KAAA,CAAA,CAAA,EAAY,CACjB,IAAMS,CAAAA,CAAYT,CAAAA,CAAU,YAAA,CAAa,CAAA,CAEzC,EAAA,CAAIS,CAAAA,EAAaD,CAAAA,CACf,GAAI,CACF,MAAMA,CAAAA,CAAWC,CAAS,CAC5B,CAAA,KAAA,CAASJ,CAAAA,CAAO,CACd,IAAMC,CAAAA,CACJD,EAAAA,WAAiB,KAAA,CAAQA,CAAAA,CAAM,OAAA,CAAU,eAAA,CAC3CL,CAAAA,CAAU,QAAA,CAASF,CAAAA,CAAWQ,CAAO,CAAA,CACrC,MACF,CAGFN,CAAAA,CAAU,QAAA,CAAS,IAAI,CAAA,CACvBA,CAAAA,CAAU,YAAA,CAAa,IAAI,CAAA,CAC3BA,CAAAA,CAAU,QAAA,CAASF,CAAAA,CAAW,KAAA,CAAS,CACzC,CACF,CAAA,6BAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-4EMYM7JF.cjs","sourcesContent":["/**\n * Framework-agnostic upload kernel.\n *\n * Encapsulates the side-effect logic for uploading/removing files so that\n * React, Vue, and Angular adapters share a single implementation and only\n * differ in how they wire reactive state.\n */\n\nimport type { BitDeleteUploadFn, BitUploadFn } from \"../types/upload\";\n\nexport interface UploadKernelCallbacks {\n /** Called with `true` when upload starts and `false` when it finishes. */\n setLoading: (loading: boolean) => void;\n /** Set or clear a field-level error message. */\n setError: (path: string, message: string | undefined) => void;\n /** Set the stored file URL after a successful upload (or `null` on remove). */\n setValue: (value: string | null) => void;\n /** Return the key of the last uploaded file (used when deleting). */\n getUploadKey: () => string | null;\n /** Persist the upload key returned by the upload function. */\n setUploadKey: (key: string | null) => void;\n}\n\n/**\n * Creates a type-safe `upload` handler for a field.\n *\n * @example\n * ```ts\n * const upload = createUploadHandler(\"avatar\", myUploadFn, {\n * setLoading: (v) => (isUploading.value = v),\n * setError: (p, m) => store.setError(p, m),\n * setValue: (v) => field.setValue(v),\n * getUploadKey: () => uploadKey,\n * setUploadKey: (k) => (uploadKey = k),\n * });\n * ```\n */\nfunction safeCallbackExecution(fn: () => void): void {\n try {\n fn();\n } catch (error) {\n // Silently swallow callback errors to maintain upload state consistency\n }\n}\n\nexport function createUploadHandler<\n TMetadata extends Record<string, unknown> = Record<string, unknown>,\n>(\n fieldPath: string,\n uploadFn: BitUploadFn<TMetadata>,\n callbacks: UploadKernelCallbacks,\n): (file: File | null | undefined) => Promise<void> {\n let currentGeneration = 0;\n return async (file) => {\n if (!file) return;\n\n const myGeneration = ++currentGeneration;\n safeCallbackExecution(() => callbacks.setLoading(true));\n safeCallbackExecution(() => callbacks.setError(fieldPath, undefined));\n\n try {\n const result = await uploadFn(file);\n\n if (myGeneration !== currentGeneration) return;\n safeCallbackExecution(() => callbacks.setValue(result.url));\n safeCallbackExecution(() => callbacks.setUploadKey(result.key));\n safeCallbackExecution(() => callbacks.setError(fieldPath, undefined));\n } catch (error) {\n if (myGeneration !== currentGeneration) return;\n const message = error instanceof Error ? error.message : \"Upload failed\";\n safeCallbackExecution(() => callbacks.setError(fieldPath, message));\n } finally {\n if (myGeneration === currentGeneration) {\n safeCallbackExecution(() => callbacks.setLoading(false));\n }\n }\n };\n}\n\n/**\n * Creates a type-safe `remove` handler for a field.\n */\nexport function createRemoveHandler(\n fieldPath: string,\n deleteFile: BitDeleteUploadFn | undefined,\n callbacks: UploadKernelCallbacks,\n): () => Promise<void> {\n return async () => {\n const uploadKey = callbacks.getUploadKey();\n\n if (uploadKey && deleteFile) {\n try {\n await deleteFile(uploadKey);\n } catch (error) {\n const message =\n error instanceof Error ? error.message : \"Delete failed\";\n callbacks.setError(fieldPath, message);\n return;\n }\n }\n\n callbacks.setValue(null);\n callbacks.setUploadKey(null);\n callbacks.setError(fieldPath, undefined);\n };\n}\n"]}
@@ -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 _chunkRHMJPKNVcjs = require('./chunk-RHMJPKNV.cjs');var _chunkGKNGJOB3cjs = require('./chunk-GKNGJOB3.cjs');var _chunkFTXV2NZOcjs = require('./chunk-FTXV2NZO.cjs');function Kt(s){let{path:t,getFieldConfig:e,masks:i}=s,r=_optionalChain([e, 'call', _2 => _2(t), 'optionalAccess', _3 => _3.mask]);if(r)return typeof r=="string"?_optionalChain([i, 'optionalAccess', _4 => _4[r]]):r}function $t(s){let{state:t,path:e,value:i,isHidden:r,isRequired:n,isDirty:o,isValidating:a}=s,l=e;return{value:i,error:t.errors[l],touched:!!t.touched[l],isHidden:r,isRequired:n,isDirty:o,isValidating:a}}var D=Symbol.for("bit-form.framework-store-api");var M=Symbol.for("bit-form.hooks-api");var U=class{constructor(t){this.baselineValues=_chunkFTXV2NZOcjs.a.call(void 0, t)}getValues(){return this.baselineSnapshot||(this.baselineSnapshot=Object.freeze(_chunkFTXV2NZOcjs.a.call(void 0, this.baselineValues))),this.baselineSnapshot}setValues(t){this.baselineValues=_chunkFTXV2NZOcjs.a.call(void 0, t),this.baselineSnapshot=void 0}};var z= (_class =class{constructor(t,e){;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);this.getComputedEntries=t;this.onError=e}__init() {this.equalityCache=new Map}__init2() {this.reverseDepsCache=null}__init3() {this.childDepsIndex=null}__init4() {this.validatedEntriesSignature=null}__init5() {this.validatedEntriesRef=null}__init6() {this.orderedAllEntriesCache=null}__init7() {this.orderedIndexByPathCache=null}isCacheableScalar(t){return t===null||typeof t!="object"&&typeof t!="function"}invalidateReverseDeps(){this.reverseDepsCache=null,this.childDepsIndex=null,this.orderedAllEntriesCache=null,this.validatedEntriesSignature=null,this.validatedEntriesRef=null,this.orderedIndexByPathCache=null,this.equalityCache.clear()}apply(t,e){let i=this.getComputedEntries();if(i.length===0)return t;this.ensureEntriesAreValid(i);let r=this.resolveEntriesToRun(i,e);if(r.length===0)return t;let n=t,o=new Set;for(let a of r){if(a.dependsOn.some(h=>o.has(h))){o.add(a.path);continue}let l;try{l=a.compute(n)}catch(h){_optionalChain([this, 'access', _5 => _5.onError, 'optionalCall', _6 => _6(h,a.path)]),o.add(a.path);continue}let d=_chunkFTXV2NZOcjs.f.call(void 0, n,a.path),p=this.equalityCache.get(a.path),c,u=this.isCacheableScalar(d)&&this.isCacheableScalar(l);u&&p&&p.current===d&&p.next===l?c=p.equal:(c=_chunkFTXV2NZOcjs.d.call(void 0, d,l),u?this.equalityCache.set(a.path,{current:d,next:l,equal:c}):this.equalityCache.delete(a.path)),c||(n=_chunkFTXV2NZOcjs.g.call(void 0, n,a.path,l))}return n}getReverseDependencies(t){if(this.reverseDepsCache)return this.reverseDepsCache;let e=new Map;for(let r of t)for(let n of r.dependsOn){let o=e.get(n);o||(o=new Set,e.set(n,o)),o.add(r.path)}let i=new Map;for(let r of e.keys()){let n=r.split(".");for(let o=1;o<n.length;o++){let a=n.slice(0,o).join("."),l=i.get(a);l||(l=new Set,i.set(a,l)),l.add(r)}}return this.reverseDepsCache=e,this.childDepsIndex=i,e}resolveEntriesToRun(t,e){if(!e||e.length===0||e.includes("*"))return this.getOrderedAllEntries(t);let i=this.getReverseDependencies(t),r=new Set,n=[...e],o=0;for(;o<n.length;){let p=n[o++],c=this.getDependentsForPath(i,p);if(c)for(let u of c)r.has(u)||(r.add(u),n.push(u))}if(r.size===0)return[];let a=this.getOrderedAllEntries(t),l=this.getOrderedIndexByPath(t,a),d=[];return r.forEach(p=>{let c=l.get(p);if(c===void 0)return;let u=a[c];u&&d.push({index:c,entry:u})}),d.sort((p,c)=>p.index-c.index),d.map(p=>p.entry)}orderEntries(t){if(t.length<=1)return t;let e=new Map(t.map(a=>[a.path,a])),i=new Map,r=new Map;t.forEach(a=>i.set(a.path,0)),t.forEach(a=>{a.dependsOn.forEach(l=>{if(!e.has(l))return;let d=_nullishCoalesce(r.get(l), () => (new Set));d.has(a.path)||(d.add(a.path),r.set(l,d),i.set(a.path,(_nullishCoalesce(i.get(a.path), () => (0)))+1))})});let n=t.filter(a=>(_nullishCoalesce(i.get(a.path), () => (0)))===0).map(a=>a.path),o=[];for(;n.length>0;){let a=n.shift();o.push(a);let l=r.get(a);l&&l.forEach(d=>{let p=(_nullishCoalesce(i.get(d), () => (0)))-1;i.set(d,p),p===0&&n.push(d)})}if(o.length!==t.length)throw new Error("BitStore: cyclic computed dependencies detected. Check computedDependsOn definitions.");return o.map(a=>e.get(a))}getOrderedAllEntries(t){let e=this.createEntriesSignature(t);if(this.orderedAllEntriesCache&&this.orderedAllEntriesCache.signature===e)return this.orderedAllEntriesCache.ordered;let i=this.orderEntries(t);return this.orderedAllEntriesCache={signature:e,ordered:i},i}getOrderedIndexByPath(t,e){let i=this.createEntriesSignature(t);if(this.orderedIndexByPathCache&&this.orderedIndexByPathCache.signature===i)return this.orderedIndexByPathCache.indexByPath;let r=new Map;return e.forEach((n,o)=>{r.set(n.path,o)}),this.orderedIndexByPathCache={signature:i,indexByPath:r},r}ensureEntriesAreValid(t){if(this.validatedEntriesRef===t)return;let e=this.createEntriesSignature(t);if(this.validatedEntriesSignature===e){this.validatedEntriesRef=t;return}t.forEach(i=>this.assertDependencies(i)),this.invalidateReverseDeps(),this.validatedEntriesSignature=e,this.validatedEntriesRef=t}createEntriesSignature(t){return t.map(e=>`${e.path}:${e.dependsOn.join(",")}`).join("|")}getDependentsForPath(t,e){let i=new Set,r=a=>{let l=t.get(a);l&&l.forEach(d=>i.add(d))};r(e);let n=e.split(".");for(;n.length>1;)n.pop(),r(n.join("."));let o=_optionalChain([this, 'access', _7 => _7.childDepsIndex, 'optionalAccess', _8 => _8.get, 'call', _9 => _9(e)]);if(o)for(let a of o)r(a);return i}assertDependencies(t){if(t.dependsOn.length===0)throw new Error(`BitStore: computed field \`${t.path}\` requires explicit computedDependsOn in v4.`);if(t.dependsOn.includes(t.path))throw new Error(`BitStore: computed field \`${t.path}\` cannot depend on itself.`)}}, _class);var q= (_class2 =class{constructor() { _class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this); }__init8() {this.dirtyPaths=new Set}__init9() {this.dirtyPathIndex=new Set}__init10() {this.dirtyPrefixRefCount=new Map}__init11() {this.childrenByPrefix=new Map}updateForPath(t,e,i){this.removeDirtyChildren(t);let r=_chunkFTXV2NZOcjs.f.call(void 0, e,t),n=_chunkFTXV2NZOcjs.f.call(void 0, i,t);return _chunkFTXV2NZOcjs.c.call(void 0, r,n)?this.removeDirtyPath(t):this.addDirtyPath(t),this.dirtyPaths.size>0}rebuild(t,e){return this.dirtyPaths=_chunkFTXV2NZOcjs.e.call(void 0, t,e),this.dirtyPrefixRefCount.clear(),this.rebuildIndex(),this.dirtyPaths.size>0}clear(){this.dirtyPaths.clear(),this.dirtyPathIndex.clear(),this.dirtyPrefixRefCount.clear(),this.childrenByPrefix.clear()}get isDirty(){return this.dirtyPaths.size>0}getDirtyPaths(){return this.dirtyPaths}isPathDirty(t){if(this.dirtyPathIndex.has(t))return!0;let e=t.lastIndexOf(".");for(;e>-1;){let i=t.slice(0,e);if((_nullishCoalesce(this.dirtyPrefixRefCount.get(i), () => (0)))>0)return!0;e=t.lastIndexOf(".",e-1)}return!1}buildDirtyValues(t){if(this.dirtyPaths.size===0)return{};let e=[],i=[...this.dirtyPaths].sort(),r=new Set,n=new Set,o=a=>{let 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 d=l[1];if(r.has(d))continue;r.add(d);let p=_chunkFTXV2NZOcjs.f.call(void 0, t,d);e.push([d,p]),n.add(d)}else{let d=_chunkFTXV2NZOcjs.f.call(void 0, t,a);e.push([a,d]),n.add(a)}}return e.length===0?{}:_chunkFTXV2NZOcjs.h.call(void 0, {},e)}rebuildIndex(){let t=new Set,e=new Map,i=new Map;for(let r of this.dirtyPaths)this.forEachPathPrefix(r,n=>{t.add(n),e.set(n,(_nullishCoalesce(e.get(n), () => (0)))+1)}),this.forEachAncestorPrefix(r,n=>{let o=i.get(n);o?o.add(r):i.set(n,new Set([r]))});this.dirtyPathIndex=t,this.dirtyPrefixRefCount=e,this.childrenByPrefix=i}removeDirtyChildren(t){let e=this.childrenByPrefix.get(t);if(!(!e||e.size===0))for(let i of[...e])this.removeDirtyPath(i)}addDirtyPath(t){this.dirtyPaths.has(t)||(this.dirtyPaths.add(t),this.forEachPathPrefix(t,e=>{this.dirtyPathIndex.add(e),this.dirtyPrefixRefCount.set(e,(_nullishCoalesce(this.dirtyPrefixRefCount.get(e), () => (0)))+1)}),this.forEachAncestorPrefix(t,e=>{let i=this.childrenByPrefix.get(e);i?i.add(t):this.childrenByPrefix.set(e,new Set([t]))}))}removeDirtyPath(t){this.dirtyPaths.has(t)&&(this.dirtyPaths.delete(t),this.forEachPathPrefix(t,e=>{let i=(_nullishCoalesce(this.dirtyPrefixRefCount.get(e), () => (0)))-1;if(i<=0){this.dirtyPrefixRefCount.delete(e),this.dirtyPathIndex.delete(e);return}this.dirtyPrefixRefCount.set(e,i)}),this.forEachAncestorPrefix(t,e=>{_optionalChain([this, 'access', _10 => _10.childrenByPrefix, 'access', _11 => _11.get, 'call', _12 => _12(e), 'optionalAccess', _13 => _13.delete, 'call', _14 => _14(t)])}))}forEachPathPrefix(t,e){let i=t.split("."),r="";for(let n of i)r=r?`${r}.${n}`:n,e(r)}forEachAncestorPrefix(t,e){let i=t.split("."),r="";for(let n=0;n<i.length-1;n++)r=r?`${r}.${i[n]}`:i[n],e(r)}}, _class2);var L= (_class3 =class{constructor() { _class3.prototype.__init12.call(this); }__init12() {this.masks=new Map}registerMask(t,e){this.masks.set(t,e)}unregisterMask(t){this.masks.has(t)&&this.masks.delete(t)}resolveMask(t){return this.masks.get(t)}getAllMasks(){return Object.fromEntries(this.masks.entries())}clear(){this.masks.clear()}}, _class3);function ai(s){return s.replace(/\.+$/g,"")}function w(s){return ai(s.trim())}function x(s,t){let e=w(t);return e.length===0?!1:s===e||s.startsWith(`${e}.`)}function C(s,t){return w(t===void 0?s:`${s}.${t}`)}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); }__init13() {this.fieldConfigs=new Map}__init14() {this.scopeFieldsIndex=null}__init15() {this.computedEntriesCache=null}__init16() {this.normalizerEntriesCache=null}__init17() {this.transformEntriesCache=null}get(t){return this.fieldConfigs.get(t)}set(t,e){this.fieldConfigs.set(t,e),this.registerCachedIndexes(t,e)}delete(t){let e=this.fieldConfigs.get(t);return this.fieldConfigs.delete(t),this.unregisterCachedIndexes(t,e),e}has(t){return this.fieldConfigs.has(t)}forEach(t){this.fieldConfigs.forEach((e,i)=>t(e,i))}entries(){return Array.from(this.fieldConfigs.entries())}getScopeFields(t){if(!this.scopeFieldsIndex){let e=new Map;this.forEach((i,r)=>{if(!i.scope)return;let n=_nullishCoalesce(e.get(i.scope), () => (new Set));n.add(r),e.set(i.scope,n)}),this.scopeFieldsIndex=e}return Array.from(_nullishCoalesce(this.scopeFieldsIndex.get(t), () => ([])))}getComputedEntries(){if(!this.computedEntriesCache){let t=[];this.forEach((e,i)=>{e.computed&&t.push({path:i,compute:e.computed,dependsOn:e.computedDependsOn})}),this.computedEntriesCache=t}return this.computedEntriesCache}getTransformEntries(){if(!this.transformEntriesCache){let t=[];this.forEach((e,i)=>{e.transform&&t.push([i,e.transform])}),this.transformEntriesCache=t}return this.transformEntriesCache}getNormalizerEntries(){if(!this.normalizerEntriesCache){let t=[];this.forEach((e,i)=>{e.normalize&&t.push({path:i,normalize:e.normalize,dependsOn:_optionalChain([e, 'access', _15 => _15.normalizeDependsOn, 'optionalAccess', _16 => _16.length])?e.normalizeDependsOn:[i]})}),this.normalizerEntriesCache=t}return this.normalizerEntriesCache}invalidateIndexes(){this.scopeFieldsIndex=null,this.computedEntriesCache=null,this.normalizerEntriesCache=null,this.transformEntriesCache=null}registerCachedIndexes(t,e){if(this.scopeFieldsIndex&&e.scope){let i=_nullishCoalesce(this.scopeFieldsIndex.get(e.scope), () => (new Set));i.add(t),this.scopeFieldsIndex.set(e.scope,i)}this.computedEntriesCache&&e.computed&&this.computedEntriesCache.push({path:t,compute:e.computed,dependsOn:e.computedDependsOn}),this.normalizerEntriesCache&&e.normalize&&this.normalizerEntriesCache.push({path:t,normalize:e.normalize,dependsOn:_optionalChain([e, 'access', _17 => _17.normalizeDependsOn, 'optionalAccess', _18 => _18.length])?e.normalizeDependsOn:[t]}),this.transformEntriesCache&&e.transform&&this.transformEntriesCache.push([t,e.transform])}unregisterCachedIndexes(t,e){if(!e){this.invalidateIndexes();return}if(this.scopeFieldsIndex&&e.scope){let i=this.scopeFieldsIndex.get(e.scope);i&&(i.delete(t),i.size>0?this.scopeFieldsIndex.set(e.scope,i):this.scopeFieldsIndex.delete(e.scope))}this.computedEntriesCache&&e.computed&&(this.computedEntriesCache=this.computedEntriesCache.filter(i=>i.path!==t)),this.normalizerEntriesCache&&e.normalize&&(this.normalizerEntriesCache=this.normalizerEntriesCache.filter(i=>i.path!==t)),this.transformEntriesCache&&e.transform&&(this.transformEntriesCache=this.transformEntriesCache.filter(([i])=>i!==t))}}, _class4);var W= (_class5 =class{constructor(t,e){;_class5.prototype.__init18.call(this);_class5.prototype.__init19.call(this);_class5.prototype.__init20.call(this);_class5.prototype.__init21.call(this);_class5.prototype.__init22.call(this);_class5.prototype.__init23.call(this);_class5.prototype.__init24.call(this);this.getFieldConfig=t;this.onConditionError=e}__init18() {this.dependencies=new Map}__init19() {this.hiddenFields=new Set}__init20() {this.conditionalVisibilityPaths=new Set}__init21() {this.requiredPathsByDependency=new Map}__init22() {this.requiredConditionalPaths=new Set}__init23() {this.requiredEvaluationVersion=0}__init24() {this.requiredEvaluationCache=new Map}getHiddenFields(){return this.hiddenFields}onRegister(t,e,i){let r=!!_optionalChain([e, 'access', _19 => _19.conditional, 'optionalAccess', _20 => _20.showIf]),n=_optionalChain([e, 'access', _21 => _21.conditional, 'optionalAccess', _22 => _22.dependsOn]);if(n){if(this.wouldCreateCycle(t,n)){let o=new Error(`Circular dependency detected: "${t}" \u2192 [${n.join(", ")}]`);return _optionalChain([this, 'access', _23 => _23.onConditionError, 'optionalCall', _24 => _24({path:t,kind:"showIf",error:o})]),r&&this.hiddenFields.add(t),this.conditionalVisibilityPaths.delete(t),this.requiredConditionalPaths.delete(t),!1}n.forEach(o=>{this.dependencies.has(o)||this.dependencies.set(o,new Set),this.dependencies.get(o).add(t)})}return r&&this.conditionalVisibilityPaths.add(t),n&&_optionalChain([e, 'access', _25 => _25.conditional, 'optionalAccess', _26 => _26.requiredIf])&&(this.requiredConditionalPaths.add(t),n.forEach(o=>{this.requiredPathsByDependency.has(o)||this.requiredPathsByDependency.set(o,new Set),this.requiredPathsByDependency.get(o).add(t)})),this.requiredEvaluationVersion+=1,this.requiredEvaluationCache.clear(),this.evaluateFieldCondition(t,i),!0}onUnregister(t,e,i){this.hiddenFields.delete(t),this.conditionalVisibilityPaths.delete(t),_optionalChain([i, 'optionalAccess', _27 => _27.preserveIncomingDependents])||this.dependencies.delete(t),this.requiredEvaluationVersion+=1,this.requiredEvaluationCache.clear(),this.requiredConditionalPaths.delete(t),_optionalChain([e, 'optionalAccess', _28 => _28.conditional, 'optionalAccess', _29 => _29.dependsOn, 'optionalAccess', _30 => _30.forEach, 'call', _31 => _31(r=>{let n=this.requiredPathsByDependency.get(r);n&&(n.delete(t),n.size===0&&this.requiredPathsByDependency.delete(r))})]),this.dependencies.forEach(r=>{r.delete(t)})}isHidden(t){return this.hiddenFields.has(t)}hasDependents(t){return(_nullishCoalesce(_optionalChain([this, 'access', _32 => _32.dependencies, 'access', _33 => _33.get, 'call', _34 => _34(t), 'optionalAccess', _35 => _35.size]), () => (0)))>0}isRequired(t,e){let i=this.getFieldConfig(t);if(!i||this.isHidden(t)||!_optionalChain([i, 'access', _36 => _36.conditional, 'optionalAccess', _37 => _37.requiredIf]))return!1;let r=this.requiredEvaluationCache.get(t);if(r&&r.version===this.requiredEvaluationVersion&&r.valuesRef===e)return r.result;let n=!1;try{n=!!i.conditional.requiredIf(e)}catch(o){_optionalChain([this, 'access', _38 => _38.onConditionError, 'optionalCall', _39 => _39({path:t,kind:"requiredIf",error:o})])}return this.requiredEvaluationCache.set(t,{version:this.requiredEvaluationVersion,valuesRef:e,result:n}),n}getRequiredErrors(t){let e={};return this.requiredConditionalPaths.forEach(i=>{let r=this.getFieldConfig(i);if(r&&!this.isHidden(i)&&this.isRequired(i,t)){let n=_chunkFTXV2NZOcjs.f.call(void 0, t,i);this.isEmpty(n)&&(e[i]=_nullishCoalesce(_optionalChain([r, 'access', _40 => _40.conditional, 'optionalAccess', _41 => _41.requiredMessage]), () => ("required field")))}}),e}evaluateAll(t){this.conditionalVisibilityPaths.forEach(e=>{this.evaluateFieldCondition(e,t)})}updateDependencies(t,e,i){let r=new Set,n=new Set,o=new Set,a=[t],l=new Set;for(;a.length>0;){let d=a.shift();if(l.has(d))continue;l.add(d);let p=this.dependencies.get(d);p&&p.forEach(c=>{r.add(c);let u=this.isHidden(c),h=this.isRequired(c,e);this.evaluateFieldCondition(c,i);let f=this.isHidden(c),B=this.isRequired(c,i);u!==f&&n.add(c),h!==B&&o.add(c),a.push(c)})}return{affectedFields:Array.from(r),visibilityChanged:Array.from(n),requiredChanged:Array.from(o)}}evaluateFieldCondition(t,e){let r=_optionalChain([this, 'access', _42 => _42.getFieldConfig, 'call', _43 => _43(t), 'optionalAccess', _44 => _44.conditional, 'optionalAccess', _45 => _45.showIf]);if(r)try{r(e)?this.hiddenFields.delete(t):this.hiddenFields.add(t)}catch(n){_optionalChain([this, 'access', _46 => _46.onConditionError, 'optionalCall', _47 => _47({path:t,kind:"showIf",error:n})])}}wouldCreateCycle(t,e){for(let i of e){let r=[t],n=new Set;for(;r.length>0;){let o=r.shift();if(o===i)return!0;if(n.has(o))continue;n.add(o);let a=this.dependencies.get(o);a&&r.push(...a)}}return!1}isEmpty(t){return t==null||typeof t=="string"&&t.trim()===""||Array.isArray(t)&&t.length===0}}, _class5);var N= (_class6 =class{__init25() {this.catalog=new _}constructor(t){;_class6.prototype.__init25.call(this);this.conditions=new W(e=>this.catalog.get(e),t)}getFieldConfig(t){return this.catalog.get(t)}forEachFieldConfig(t){this.catalog.forEach((e,i)=>t(e,i))}hasFieldConfig(t){return this.catalog.has(t)}getHiddenFields(){return this.conditions.getHiddenFields()}register(t,e,i){let r=this.catalog.get(t);r&&this.conditions.onUnregister(t,r,{preserveIncomingDependents:!0}),this.catalog.set(t,e),!(this.conditions.onRegister(t,e,i)||!r)&&(this.catalog.set(t,r),this.conditions.onRegister(t,r,i))}unregister(t){let e=this.catalog.delete(t);this.conditions.onUnregister(t,e)}unregisterPrefix(t){let e=[],i=w(t);return i.length===0||(this.catalog.forEach((r,n)=>{x(n,i)&&e.push([n,r])}),e.forEach(([r,n])=>{this.catalog.delete(r),this.conditions.onUnregister(r,n)})),e}isHidden(t){return this.conditions.isHidden(t)}hasDependents(t){return this.conditions.hasDependents(t)}isRequired(t,e){return this.conditions.isRequired(t,e)}getRequiredErrors(t){return this.conditions.getRequiredErrors(t)}evaluateAll(t){this.conditions.evaluateAll(t)}updateDependencies(t,e,i){return this.conditions.updateDependencies(t,e,i)}getScopeFields(t){return this.catalog.getScopeFields(t)}getComputedEntries(){return this.catalog.getComputedEntries()}getTransformEntries(){return this.catalog.getTransformEntries()}getNormalizerEntries(){return this.catalog.getNormalizerEntries()}invalidateIndexes(){this.catalog.invalidateIndexes()}}, _class6);function li(){return`bit-form-${Math.random().toString(36).slice(2,9)}`}function ci(s){typeof console<"u"&&typeof console.error=="function"&&console.error(s)}function Jt(s={}){let t=_nullishCoalesce(s.initialValues, () => ({})),e=s.validation,i=s.history,r=s.name?`bit-form:${s.name}:draft`:"bit-form:draft",n=_nullishCoalesce(s.onUnhandledError, () => (ci)),o=_optionalChain([s, 'access', _48 => _48.persist, 'optionalAccess', _49 => _49.onError]),a={enabled:_nullishCoalesce(_optionalChain([s, 'access', _50 => _50.persist, 'optionalAccess', _51 => _51.enabled]), () => (!1)),key:_nullishCoalesce(_optionalChain([s, 'access', _52 => _52.persist, 'optionalAccess', _53 => _53.key]), () => (r)),storage:_optionalChain([s, 'access', _54 => _54.persist, 'optionalAccess', _55 => _55.storage]),autoSave:_nullishCoalesce(_optionalChain([s, 'access', _56 => _56.persist, 'optionalAccess', _57 => _57.autoSave]), () => (!0)),debounceMs:_nullishCoalesce(_optionalChain([s, 'access', _58 => _58.persist, 'optionalAccess', _59 => _59.debounceMs]), () => (300)),mode:_nullishCoalesce(_optionalChain([s, 'access', _60 => _60.persist, 'optionalAccess', _61 => _61.mode]), () => ("values")),serialize:_nullishCoalesce(_optionalChain([s, 'access', _62 => _62.persist, 'optionalAccess', _63 => _63.serialize]), () => (JSON.stringify)),deserialize:_nullishCoalesce(_optionalChain([s, 'access', _64 => _64.persist, 'optionalAccess', _65 => _65.deserialize]), () => ((l=>JSON.parse(l)))),onError:l=>{if(o){o(l);return}n(l,"persist")}};return{name:s.name,initialValues:_chunkFTXV2NZOcjs.a.call(void 0, t),resolver:_optionalChain([e, 'optionalAccess', _66 => _66.resolver]),validationDelay:_nullishCoalesce(_optionalChain([e, 'optionalAccess', _67 => _67.delay]), () => (300)),history:{enabled:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _68 => _68.enabled]), () => (!1)),limit:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _69 => _69.limit]), () => (50))},masks:s.masks,fields:s.fields,devTools:s.devTools,persist:a,idFactory:_nullishCoalesce(s.idFactory, () => (li)),plugins:_nullishCoalesce(s.plugins, () => ([])),scheduler:s.scheduler,subscriptionCacheSize:s.subscriptionCacheSize,trackedSubscriptions:_nullishCoalesce(s.trackedSubscriptions, () => (!1)),bus:s.bus,onUnhandledError:n}}function K(s,t){if((!s||s.length===0)&&(!t||t.length===0))return;let e=new Set(_nullishCoalesce(s, () => ([])));return _optionalChain([t, 'optionalAccess', _70 => _70.forEach, 'call', _71 => _71(i=>e.add(i))]),Array.from(e)}function di(s){let t=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _72 => _72.includes, 'call', _73 => _73("*")]), () => (!1)),e=new Set(_nullishCoalesce(s, () => ([]))),i=new Set;for(let r of e){i.add(r);let n=r.lastIndexOf(".");for(;n>-1;)i.add(r.slice(0,n)),n=r.lastIndexOf(".",n-1)}return r=>{if(!s||s.length===0||t||e.has(r)||i.has(r))return!0;let n=r.lastIndexOf(".");for(;n>-1;){if(e.has(r.slice(0,n)))return!0;n=r.lastIndexOf(".",n-1)}return!1}}function ui(s,t){if(!t||t.length===0||t.includes("*"))return s;let e=di(t);return s.filter(i=>i.dependsOn.some(r=>e(r)))}function pi(s){if(s.length<=1)return{orderedEntries:[...s],cyclePaths:[]};let t=new Map(s.map(a=>[a.path,a])),e=new Map,i=new Map,r=new Map(s.map((a,l)=>[a.path,l]));s.forEach(a=>e.set(a.path,0)),s.forEach(a=>{a.dependsOn.forEach(l=>{if(l===a.path||!t.has(l))return;let d=_nullishCoalesce(i.get(l), () => (new Set));d.has(a.path)||(d.add(a.path),i.set(l,d),e.set(a.path,(_nullishCoalesce(e.get(a.path), () => (0)))+1))})});let n=s.filter(a=>(_nullishCoalesce(e.get(a.path), () => (0)))===0).map(a=>a.path),o=[];for(;n.length>0;){n.sort((d,p)=>(_nullishCoalesce(r.get(d), () => (0)))-(_nullishCoalesce(r.get(p), () => (0))));let a=n.shift();o.push(a);let l=i.get(a);l&&l.forEach(d=>{let p=(_nullishCoalesce(e.get(d), () => (0)))-1;e.set(d,p),p===0&&n.push(d)})}if(o.length!==s.length){let a=s.filter(l=>(_nullishCoalesce(e.get(l.path), () => (0)))>0).map(l=>l.path);return{orderedEntries:o.map(l=>t.get(l)),cyclePaths:a}}return{orderedEntries:o.map(a=>t.get(a)),cyclePaths:[]}}function $(s){let{values:t,changedPaths:e,normalizerEntries:i,applyComputed:r,onError:n}=s,o=pi(ui(i,e)),{orderedEntries:a,cyclePaths:l}=o;if(l.length>0&&_optionalChain([n, 'optionalCall', _74 => _74(new Error(`BitStore: cyclic normalizer dependencies detected. Check normalizeDependsOn definitions for: ${l.join(", ")}.`),_nullishCoalesce(l[0], () => ("*")))]),a.length===0)return r(t,e);let d=[],p=t;for(let u of a){let h=_chunkFTXV2NZOcjs.f.call(void 0, p,u.path),f;try{f=u.normalize(h,p)}catch(B){_optionalChain([n, 'optionalCall', _75 => _75(B,u.path)]);continue}_chunkFTXV2NZOcjs.c.call(void 0, h,f)||(d.push([u.path,f]),p=_chunkFTXV2NZOcjs.g.call(void 0, p,u.path,f))}let c=K(e,d.map(([u])=>u));return r(p,c)}function Yt(s){let{values:t,sourceValues:e,transformEntries:i,onError:r}=s;if(i.length===0)return t;let n=t,o=e;for(let[a,l]of i){let d=_chunkFTXV2NZOcjs.f.call(void 0, n,a),p;try{p=l(d,o)}catch(c){_optionalChain([r, 'optionalCall', _76 => _76(c,a)]);continue}_chunkFTXV2NZOcjs.c.call(void 0, d,p)||(n=_chunkFTXV2NZOcjs.g.call(void 0, n,a,p),o=_chunkFTXV2NZOcjs.g.call(void 0, o,a,p))}return n}var J=class{constructor(t){this.effects=t.getAll()}attachStorePort(t){this.effects.forEach(e=>_optionalChain([e, 'access', _77 => _77.attachStorePort, 'optionalCall', _78 => _78(t)]))}initialize(){this.effects.forEach(t=>_optionalChain([t, 'access', _79 => _79.initialize, 'optionalCall', _80 => _80()]))}onStateUpdated(t,e){this.effects.forEach(i=>_optionalChain([i, 'access', _81 => _81.onStateUpdated, 'optionalCall', _82 => _82(t,e)]))}async restorePersisted(){let t=!1;for(let e of this.effects)e.restorePersisted&&(t=await e.restorePersisted()||t);return t}async savePersistedNow(){for(let t of this.effects)t.savePersistedNow&&await t.savePersistedNow()}async clearPersisted(){for(let t of this.effects)t.clearPersisted&&await t.clearPersisted()}async beforeValidate(t){for(let e of this.effects)if(e.beforeValidate)try{await e.beforeValidate(t)}catch(i){this.logEffectHookError(e.name,"beforeValidate",i)}}async afterValidate(t){for(let e of this.effects)if(e.afterValidate)try{await e.afterValidate(t)}catch(i){this.logEffectHookError(e.name,"afterValidate",i)}}async beforeSubmit(t){for(let e of this.effects)if(e.beforeSubmit)try{await e.beforeSubmit(t)}catch(i){this.logEffectHookError(e.name,"beforeSubmit",i)}}async afterSubmit(t){for(let e of this.effects)if(e.afterSubmit)try{await e.afterSubmit(t)}catch(i){this.logEffectHookError(e.name,"afterSubmit",i)}}onFieldChange(t){this.effects.forEach(e=>{try{_optionalChain([e, 'access', _83 => _83.onFieldChange, 'optionalCall', _84 => _84(t)])}catch(i){this.logEffectHookError(e.name,"onFieldChange",i)}})}async reportOperationalError(t){for(let e of this.effects)if(e.reportOperationalError)try{await e.reportOperationalError(t)}catch(i){this.logEffectHookError(e.name,"reportOperationalError",i)}}logEffectHookError(t,e,i){console.error(`BitStoreEffectEngine: effect "${t}" failed in hook "${e}"`,i)}destroy(){for(let t=this.effects.length-1;t>=0;t-=1)_optionalChain([this, 'access', _85 => _85.effects, 'access', _86 => _86[t], 'access', _87 => _87.destroy, 'optionalCall', _88 => _88()])}};var Y=class{constructor(t,e,i=!0,r){this.storeId=t;this.bus=e;this.enableBusDispatch=i;this.storeBusPort=r}attachStorePort(t){this.storeBusPort=t,this.enableBusDispatch&&(this.bus.stores[this.storeId]=t)}initialize(){!this.enableBusDispatch||!this.storeBusPort||(this.bus.stores[this.storeId]=this.storeBusPort)}onStateUpdated(t){this.enableBusDispatch&&this.bus.dispatch(this.storeId,t)}destroy(){this.enableBusDispatch&&delete this.bus.stores[this.storeId]}};var G= (_class7 =class{constructor() { _class7.prototype.__init26.call(this); }__init26() {this.effects=new Map}register(t){this.effects.set(t.name,t)}getAll(){return Array.from(this.effects.values())}}, _class7);var X=class{constructor(t){this.persistManager=t}onStateUpdated(t,e){e&&this.persistManager.queueSave()}restorePersisted(){return this.persistManager.restore()}savePersistedNow(){return this.persistManager.saveNow()}clearPersisted(){return this.persistManager.clear()}destroy(){this.persistManager.destroy()}};var Q=class{constructor(t){this.pluginManager=t}initialize(){this.pluginManager.setupAll()}beforeValidate(t){return this.pluginManager.beforeValidate(t)}afterValidate(t){return this.pluginManager.afterValidate(t)}beforeSubmit(t){return this.pluginManager.beforeSubmit(t)}afterSubmit(t){return this.pluginManager.afterSubmit(t)}onFieldChange(t){this.pluginManager.onFieldChange(t)}reportOperationalError(t){return this.pluginManager.reportError(t.source,t.error,t.payload)}destroy(){this.pluginManager.destroy()}};function hi(){if(typeof globalThis>"u")return;let s;try{s=_nullishCoalesce(globalThis.localStorage, () => (void 0))}catch (e2){return}if(s)return{getItem:t=>s.getItem(t),setItem:(t,e)=>s.setItem(t,e),removeItem:t=>s.removeItem(t)}}var Z= (_class8 =class{constructor(t,e,i,r,n={}){;_class8.prototype.__init27.call(this);_class8.prototype.__init28.call(this);this.config=t;this.getValues=e;this.getDirtyValues=i;this.applyRestoredValues=r;this.callbacks=n}__init27() {this.writeQueue=Promise.resolve()}__init28() {this.activeWrites=0}getStorage(){return this.config.storage||hi()}canPersist(){return!!(this.config.enabled&&this.config.key&&this.getStorage())}handleError(t){_optionalChain([this, 'access', _89 => _89.callbacks, 'access', _90 => _90.onError, 'optionalCall', _91 => _91(t)]),_optionalChain([this, 'access', _92 => _92.config, 'access', _93 => _93.onError, 'optionalCall', _94 => _94(t)])}enqueueWriteOperation(t){this.activeWrites+=1,this.activeWrites===1&&_optionalChain([this, 'access', _95 => _95.callbacks, 'access', _96 => _96.onWriteStart, 'optionalCall', _97 => _97()]);let e=this.writeQueue.then(t,t);return this.writeQueue=e.then(()=>{},()=>{}),e.then(()=>({ok:!0,error:void 0}),r=>({ok:!1,error:r})).then(r=>{if(this.activeWrites=Math.max(0,this.activeWrites-1),r.ok){this.activeWrites===0&&_optionalChain([this, 'access', _98 => _98.callbacks, 'access', _99 => _99.onWriteSuccess, 'optionalCall', _100 => _100()]);return}throw _optionalChain([this, 'access', _101 => _101.callbacks, 'access', _102 => _102.onWriteError, 'optionalCall', _103 => _103(r.error)]),this.activeWrites===0&&_optionalChain([this, 'access', _104 => _104.callbacks, 'access', _105 => _105.onWriteSettled, 'optionalCall', _106 => _106()]),r.error})}async persistPayload(){let t=this.getStorage();if(!t)return;let e=this.config.mode==="dirtyValues"?this.getDirtyValues():this.getValues(),i=this.config.serialize(e);await t.setItem(this.config.key,i)}async saveNow(){this.canPersist()&&await this.enqueueWriteOperation(async()=>{try{await this.persistPayload()}catch(t){throw this.handleError(t),t}})}queueSave(){!this.canPersist()||!this.config.autoSave||(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.saveNow().catch(()=>{})},this.config.debounceMs))}async restore(){if(!this.canPersist())return!1;let t=this.getStorage();if(!t)return!1;try{let e=await t.getItem(this.config.key);if(!e)return!1;let i=this.config.deserialize(e);return!i||typeof i!="object"?!1:(this.applyRestoredValues(i),!0)}catch(e){throw this.handleError(e),e}}async clear(){if(!this.canPersist())return;let t=this.getStorage();t&&await this.enqueueWriteOperation(async()=>{try{await t.removeItem(this.config.key)}catch(e){throw this.handleError(e),e}})}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=void 0)}}, _class8);var tt= (_class9 =class{constructor(t,e){;_class9.prototype.__init29.call(this);_class9.prototype.__init30.call(this);_class9.prototype.__init31.call(this);_class9.prototype.__init32.call(this);this.plugins=t;this.contextFactory=e}__init29() {this.teardownFns=[]}__init30() {this.notifyingError=!1}__init31() {this.pendingErrorQueue=[]}__init32() {this.cachedContext=null}setupAll(){let t=this.getContext();this.plugins.forEach(e=>{if(e.setup)try{let i=e.setup(t);typeof i=="function"&&this.teardownFns.push(i)}catch(i){this.reportError("setup",i,void 0,e.name)}})}async beforeValidate(t){await this.emitHook("beforeValidate",t)}async afterValidate(t){await this.emitHook("afterValidate",t)}async beforeSubmit(t){await this.emitHook("beforeSubmit",t)}async afterSubmit(t){await this.emitHook("afterSubmit",t)}onFieldChange(t){let e=this.getContext();this.plugins.forEach(i=>{let r=_optionalChain([i, 'access', _107 => _107.hooks, 'optionalAccess', _108 => _108.onFieldChange]);if(r)try{let n=r(t,e);Promise.resolve(n).catch(o=>{this.reportError("onFieldChange",o,t,i.name)})}catch(n){this.reportError("onFieldChange",n,t,i.name)}})}async reportError(t,e,i,r){let o=this.getContext().getState();if(this.pendingErrorQueue.push({source:t,pluginName:r,error:e,event:i,values:o.values,state:o}),!this.notifyingError){this.notifyingError=!0;try{for(;this.pendingErrorQueue.length>0;){let a=this.pendingErrorQueue.shift();if(!a)break;for(let l of this.plugins){let d=_optionalChain([l, 'access', _109 => _109.hooks, 'optionalAccess', _110 => _110.onError]);if(d)try{await d(a,this.contextFactory())}catch (e3){}}}}finally{this.notifyingError=!1}}}destroy(){for(let t=this.teardownFns.length-1;t>=0;t-=1){let e=this.teardownFns[t];try{e()}catch(i){this.reportError("teardown",i)}}this.teardownFns=[],this.cachedContext=null}async emitHook(t,e){let i=this.getContext();for(let r of this.plugins){let n=_optionalChain([r, 'access', _111 => _111.hooks, 'optionalAccess', _112 => _112[t]]);if(n)try{await n(e,i)}catch(o){await this.reportError(t,o,e,r.name)}}}getContext(){return this.cachedContext||(this.cachedContext=this.contextFactory()),this.cachedContext}}, _class9);var Ft=typeof globalThis<"u"?globalThis:typeof global<"u"?global:window;Ft.__BIT_FORM__||(Ft.__BIT_FORM__={stores:{},listeners:new Set,dispatch(s,t){this.listeners.forEach(e=>{try{e(s,t)}catch (e4){}})},subscribe(s){return this.listeners.add(s),()=>{this.listeners.delete(s)}}});var wt=Ft.__BIT_FORM__,fi={stores:{},listeners:new Set,dispatch:()=>{},subscribe:()=>()=>{}};function At(){return fi}function gi(){let s=new Set;return{stores:{},listeners:s,dispatch(t,e){s.forEach(i=>{try{i(t,e)}catch (e5){}})},subscribe(t){return s.add(t),()=>s.delete(t)}}}function mi(s){return s.bus?!0:typeof s.devTools=="boolean"?s.devTools:s.devTools&&typeof s.devTools=="object"?s.devTools.enabled!==!1:!1}function Gt(s){let{storeId:t,storeBusPort:e,config:i,getState:r,getConfig:n,getValues:o,getDirtyValues:a,applyPersistedValues:l,setPersistMetadata:d}=s,p=new Z(i.persist,o,a,l,{onWriteStart:()=>_optionalChain([d, 'optionalCall', _113 => _113({isSaving:!0,error:null})]),onWriteSuccess:()=>_optionalChain([d, 'optionalCall', _114 => _114({isSaving:!1,error:null})]),onWriteError:v=>_optionalChain([d, 'optionalCall', _115 => _115({error:v instanceof Error?v:new Error(String(v))})]),onWriteSettled:()=>_optionalChain([d, 'optionalCall', _116 => _116({isSaving:!1})]),onError:v=>i.onUnhandledError(v,"persist")}),c=new tt([...i.plugins],()=>({storeId:t,getState:()=>_chunkFTXV2NZOcjs.a.call(void 0, r()),getConfig:()=>_chunkFTXV2NZOcjs.a.call(void 0, n())})),u=mi(i),h=typeof process<"u"&&typeof process.env<"u"&&process.env.VITEST==="true",f=u?_nullishCoalesce(i.bus, () => ((h?At():wt))):At(),B=new G,g=new X(p);B.register({name:"persist",onStateUpdated:(v,R)=>g.onStateUpdated(v,R),restorePersisted:()=>g.restorePersisted(),savePersistedNow:()=>g.savePersistedNow(),clearPersisted:()=>g.clearPersisted(),destroy:()=>g.destroy()});let m=new Q(c);B.register({name:"plugins",initialize:()=>m.initialize(),beforeValidate:v=>m.beforeValidate(v),afterValidate:v=>m.afterValidate(v),beforeSubmit:v=>m.beforeSubmit(v),afterSubmit:v=>m.afterSubmit(v),onFieldChange:v=>m.onFieldChange(v),reportOperationalError:v=>m.reportOperationalError(v),destroy:()=>m.destroy()});let T=new Y(t,f,u,e);B.register({name:"bus",attachStorePort:v=>T.attachStorePort(v),initialize:()=>T.initialize(),onStateUpdated:v=>T.onStateUpdated(v),destroy:()=>T.destroy()});let P=new J(B);return P.initialize(),P}function b(s,t,e){return{kind:"state.patch",partialState:s,changedPaths:t,skipComputed:_optionalChain([e, 'optionalAccess', _117 => _117.skipComputed])}}function It(s){return{kind:"field.touchMany",paths:s}}function et(s){return{kind:"form.persistMeta",patch:s}}function it(s,t){return{kind:"validation.commit",errors:s,isValid:t}}var Xt=new WeakMap,Qt=new WeakMap;function yi(s){let{dispatch:t}=s,e=Xt,i=Qt,r=_nullishCoalesce(e.get(t), () => (0));e.set(t,r+1),r===0&&(i.set(t,null),t(et({isRestoring:!0,error:null})))}function Si(s){let{dispatch:t,error:e}=s,i=Xt,r=Qt,n=_nullishCoalesce(i.get(t), () => (0));if(n<=0)return;let o=n-1;if(e&&r.set(t,e),o>0){i.set(t,o);let l=_nullishCoalesce(r.get(t), () => (null));l&&t(et({error:l}));return}i.delete(t),e||r.set(t,null);let a=_nullishCoalesce(r.get(t), () => (null));r.delete(t),t(et({isRestoring:!1,error:a}))}async function Zt(s){let{dispatch:t,effects:e}=s;yi({dispatch:t,type:"restoring"});let i=null;try{return await e.restorePersisted()}catch(r){return i=r instanceof Error?r:new Error(String(r)),!1}finally{Si({dispatch:t,type:"restoring",error:i})}}async function te(s){let{effects:t}=s;try{await t.savePersistedNow()}catch (e6){}}async function ee(s){let{effects:t}=s;try{await t.clearPersisted()}catch (e7){}}function ie(s){let{values:t,state:e,initialValues:i,validation:r,fieldRegistry:n,dirtyManager:o,dispatch:a,saveHistorySnapshot:l}=s,d=_chunkFTXV2NZOcjs.a.call(void 0, _chunkFTXV2NZOcjs.b.call(void 0, i,t));r.cancelAll(),n.evaluateAll(d);let p=o.rebuild(d,i);a(b({values:d,errors:{},touched:{},isValidating:{},persist:{...e.persist,error:null},isValid:!1,isDirty:p})),l(),r.validate()}function re(s){let{state:t,path:e}=s,i=`${e}.`,r={...t.errors},n={...t.touched},o=!1;for(let a of Object.keys(r))(a===e||a.startsWith(i))&&(delete r[a],o=!0);for(let a of Object.keys(n))(a===e||a.startsWith(i))&&(delete n[a],o=!0);return o?{errors:r,touched:n}:null}function rt(s){let t=[],e=new Map,i=new Set(s.map(a=>a.path));for(let a of s)if(e.has(a.path)||e.set(a.path,new Set),a.dependsOn)for(let l of a.dependsOn)i.has(l)&&e.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 d=e.get(a)||new Set;for(let p of d)if(r.has(p)){if(n.has(p)){let c=l.indexOf(p),u=[...l.slice(c),p];return{cycle:u,paths:Array.from(e.keys()).filter(h=>u.includes(h)),message:`Circular dependency detected: ${u.join(" \u2192 ")}. Check your computed field definitions.`}}}else{let c=o(p,[...l]);if(c)return c}return n.delete(a),null};for(let a of e.keys())if(!r.has(a)){let l=o(a,[]);l&&!t.some(d=>d.message===l.message)&&t.push(l)}return t}function se(s){return!!(_optionalChain([s, 'optionalAccess', _118 => _118.computed])||_optionalChain([s, 'optionalAccess', _119 => _119.normalize]))}function ne(s){let{path:t,config:e,state:i,fieldRegistry:r,subscriptions:n,validationCleanupField:o,stateReader:a,invalidateFieldIndexes:l,dispatch:d,getState:p,onUnhandledError:c}=s,u=r.getFieldConfig(t),h=_optionalChain([u, 'optionalAccess', _120 => _120.validation, 'optionalAccess', _121 => _121.asyncValidate]),f=_optionalChain([e, 'access', _122 => _122.validation, 'optionalAccess', _123 => _123.asyncValidate]),B=_nullishCoalesce(_optionalChain([u, 'optionalAccess', _124 => _124.validation, 'optionalAccess', _125 => _125.asyncValidateOn]), () => ("blur")),g=_nullishCoalesce(_optionalChain([e, 'access', _126 => _126.validation, 'optionalAccess', _127 => _127.asyncValidateOn]), () => ("blur"));u&&h&&(f!==h||g!==B)&&o(t);let T=!!(_optionalChain([u, 'optionalAccess', _128 => _128.computed])||e.computed),P=se(u)||se(e);if(r.register(t,e,i.values),l(),T){let R=rt(r.getComputedEntries());if(R.length>0){u?r.register(t,u,i.values):r.unregister(t),l(),n.invalidatePathExpansionCache(t),a.invalidatePath(t),c(new Error(R[0].message),"computed");return}}n.invalidatePathExpansionCache(t),a.invalidatePath(t),P&&d(b({values:i.values},["*"]));let v=p();e.scope&&n.notify(v,[_chunkRHMJPKNVcjs.d.call(void 0, e.scope)]),r.isHidden(t)&&n.notify(v,[t])}function oe(s){let{path:t,state:e,hasStaticConfig:i,fieldRegistry:r,subscriptions:n,validationCleanupField:o,invalidateFieldIndexes:a,dispatch:l}=s;if(i)return;let d=r.getFieldConfig(t);o(t),r.unregister(t),a(),n.invalidatePathExpansionCache(t),_optionalChain([d, 'optionalAccess', _129 => _129.scope])&&n.notify(e,[_chunkRHMJPKNVcjs.d.call(void 0, d.scope)]);let p=re({state:e,path:t});p&&l(b({errors:p.errors,touched:p.touched}))}function st(s){let{prefix:t,state:e,fieldRegistry:i,subscriptions:r,validationCleanupPrefix:n,invalidateFieldIndexes:o,dispatch:a}=s;n(t);let l=i.unregisterPrefix(t);o(),r.invalidatePathExpansionCache(t),new Set(l.map(([,h])=>h.scope).filter(h=>!!h)).forEach(h=>{r.notify(e,[_chunkRHMJPKNVcjs.d.call(void 0, h)])});let p={...e.errors},c={...e.touched},u=!1;for(let[h]of l)p[h]&&(delete p[h],u=!0),c[h]&&(delete c[h],u=!0);u&&a(b({errors:p,touched:c}))}var bi="subscription",nt= (_class10 =class{constructor(t,e,i=500){;_class10.prototype.__init33.call(this);_class10.prototype.__init34.call(this);_class10.prototype.__init35.call(this);_class10.prototype.__init36.call(this);_class10.prototype.__init37.call(this);_class10.prototype.__init38.call(this);_class10.prototype.__init39.call(this);_class10.prototype.__init40.call(this);_class10.prototype.__init41.call(this);this.getState=t;if(typeof e=="function"){this.onError=e,this.MAX_PATH_EXPANSION_CACHE_SIZE=i;return}this.MAX_PATH_EXPANSION_CACHE_SIZE=_nullishCoalesce(e, () => (i))}__init33() {this.listeners=new Set}__init34() {this.pathScopedSubscriptions=new Map}__init35() {this.pathSelectorIndex=new Map}__init36() {this.pathExpansionCache=new Map}__init37() {this.subscriptionSeenVersion=new Map}__init38() {this.notifyVersion=0}__init39() {this.cacheHits=0}__init40() {this.cacheMisses=0}__init41() {this.cacheEvictions=0}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}subscribeSelector(t,e,i,r){let n=t(this.getState()),o={notify:l=>{try{let d=t(l);if(r(n,d))return;n=d,e(d)}catch(d){this.reportError(d)}}},a=this.normalizeSubscriptionPaths(i.paths);if(this.pathScopedSubscriptions.set(o,a),a.forEach(l=>{this.forEachIndexPath(l,d=>{let p=_nullishCoalesce(this.pathSelectorIndex.get(d), () => (new Set));p.add(o),this.pathSelectorIndex.set(d,p)})}),i.emitImmediately)try{e(n)}catch(l){this.reportError(l)}return()=>{this.subscriptionSeenVersion.delete(o);let l=this.pathScopedSubscriptions.get(o);l&&(l.forEach(d=>{this.forEachIndexPath(d,p=>{let c=this.pathSelectorIndex.get(p);c&&(c.delete(o),c.size===0&&this.pathSelectorIndex.delete(p))})}),this.pathScopedSubscriptions.delete(o))}}notify(t,e){if(this.listeners.forEach(n=>{try{n()}catch(o){this.reportError(o)}}),this.pathScopedSubscriptions.size===0)return;let i=this.normalizeChangedPathIterable(e);if(i.length===0||i.includes("*")){this.notifyScopedSubscribers(this.pathScopedSubscriptions.keys(),t);return}if(i.length===1&&this.isSimplePath(i[0])){let n=this.collectSubscribersForSingleChangedPath(i[0]);this.notifyScopedSubscribers(n,t);return}let r=this.collectSubscribersForChangedPaths(i);this.notifyScopedSubscribers(r,t)}notifyScopedSubscribers(t,e){for(let i of t)try{i.notify(e)}catch(r){this.reportError(r)}}reportError(t){if(this.onError){this.onError(t,bi);return}console.error("Subscription listener error:",t)}destroy(){this.listeners.clear(),this.pathScopedSubscriptions.clear(),this.pathSelectorIndex.clear(),this.pathExpansionCache.clear(),this.subscriptionSeenVersion.clear()}getPathExpansionCacheStats(){return{cacheSize:this.pathExpansionCache.size,cacheLimit:this.MAX_PATH_EXPANSION_CACHE_SIZE,cacheHits:this.cacheHits,cacheMisses:this.cacheMisses,cacheEvictions:this.cacheEvictions}}getActiveSubscribersCount(){return this.pathScopedSubscriptions.size}invalidatePathExpansionCache(t){if(!t){this.pathExpansionCache.clear();return}let e=w(t);if(e.length===0){this.pathExpansionCache.clear();return}for(let i of this.pathExpansionCache.keys())(x(i,e)||x(e,i))&&this.pathExpansionCache.delete(i)}normalizeSubscriptionPaths(t){if(!t||t.length===0)return[];let e=new Set,i=[];for(let r of t){let n=r.trim();n.length===0||e.has(n)||(e.add(n),i.push(n))}return i}normalizeChangedPathIterable(t){if(!t)return[];let e=new Set,i=[];for(let r of t){let n=r.trim();n.length===0||e.has(n)||(e.add(n),i.push(n))}return i}collectSubscribersForChangedPaths(t){let e=[],i=++this.notifyVersion,r=n=>{let o=this.pathSelectorIndex.get(n);o&&o.forEach(a=>{(_nullishCoalesce(this.subscriptionSeenVersion.get(a), () => (0)))>=i||(this.subscriptionSeenVersion.set(a,i),e.push(a))})};return t.forEach(n=>{this.forEachLookupPath(n,r)}),e}collectSubscribersForSingleChangedPath(t){let e=[],i=++this.notifyVersion,r=n=>{let o=this.pathSelectorIndex.get(n);o&&o.forEach(a=>{(_nullishCoalesce(this.subscriptionSeenVersion.get(a), () => (0)))>=i||(this.subscriptionSeenVersion.set(a,i),e.push(a))})};return this.forEachLookupPath(t,r),e}expandChangedPathForLookup(t){return this.expandPathGeneric(t)}expandPathForIndexing(t){return this.expandPathGeneric(t)}forEachIndexPath(t,e){if(!this.isSimplePath(t)){this.expandPathForIndexing(t).forEach(e);return}let i=t.split("."),r="";for(let n=0;n<i.length;n+=1)r=r?`${r}.${i[n]}`:i[n],e(r)}forEachLookupPath(t,e){if(!this.isSimplePath(t)){this.expandChangedPathForLookup(t).forEach(e);return}e(t);let i=t.lastIndexOf(".");for(;i>-1;)e(t.slice(0,i)),i=t.lastIndexOf(".",i-1)}isSimplePath(t){return!t.includes("*")&&!t.includes("[")&&!t.includes("]")}expandPathGeneric(t){let e=this.pathExpansionCache.get(t);if(e)return this.cacheHits+=1,e;this.cacheMisses+=1;let i=t.split("."),r=[];for(let n=1;n<=i.length;n++)r.push(i.slice(0,n).join("."));return this.setBoundedCacheEntry(this.pathExpansionCache,t,r,this.MAX_PATH_EXPANSION_CACHE_SIZE),r}setBoundedCacheEntry(t,e,i,r){if(t.size>=r){let n=t.keys().next().value;n!==void 0&&(t.delete(n),this.cacheEvictions+=1)}t.set(e,i)}}, _class10);var ot= (_class11 =class{constructor(t){;_class11.prototype.__init42.call(this);this.store=t}__init42() {this.pathIds=new Map}getItemIds(t,e){let i=typeof e=="number"?Math.max(0,e):this.getCurrentArrayLength(t);return[...this.ensureIds(t,i)]}pushItem(t,e){this.withPathIds(t,i=>(i.push(this.store.createArrayItemId(t,i.length)),i)),this.mutateArrayWithSetField(t,i=>[...i,e],{origin:"array",operation:"push"})}prependItem(t,e){this.withPathIds(t,r=>(r.unshift(this.store.createArrayItemId(t,0)),r)),_optionalChain([this, 'access', _130 => _130.store, 'access', _131 => _131.unregisterPrefix, 'optionalCall', _132 => _132(C(t))]);let i=_nullishCoalesce(_chunkFTXV2NZOcjs.f.call(void 0, this.store.getState().values,t), () => ([]));this.commitArrayMutationWithFieldPipeline({path:t,nextArray:[e,...i],meta:{origin:"array",operation:"prepend"},reindex:r=>r+1})}insertItem(t,e,i){let r=this.getCurrentArrayLength(t),n=Math.max(0,Math.min(e,r));if(this.withPathIds(t,l=>{let d=[...l];return d.splice(n,0,this.store.createArrayItemId(t,n)),d}),this.store.unregisterPrefix)for(let l=n;l<r;l++)this.store.unregisterPrefix(C(t,l));let a=[..._nullishCoalesce(_chunkFTXV2NZOcjs.f.call(void 0, this.store.getState().values,t), () => ([]))];a.splice(n,0,i),this.commitArrayMutationWithFieldPipeline({path:t,nextArray:a,meta:{origin:"array",operation:"insert",index:n},reindex:l=>l<n?l:l+1})}removeItem(t,e){let i=this.store.getState(),r=_chunkFTXV2NZOcjs.f.call(void 0, i.values,t);if(!Array.isArray(r)||e<0||e>=r.length)return;this.withPathIds(t,o=>{let a=[...o];return a.splice(e,1),a}),this.store.unregisterPrefix&&this.store.unregisterPrefix(C(t,e));let n=r.filter((o,a)=>a!==e);this.commitArrayMutationWithFieldPipeline({path:t,nextArray:n,meta:{origin:"array",operation:"remove",index:e},reindex:o=>o===e?null:o>e?o-1:o})}swapItems(t,e,i){let r=this.store.getState(),n=_chunkFTXV2NZOcjs.f.call(void 0, r.values,t);if(!Array.isArray(n)||e<0||e>=n.length||i<0||i>=n.length)return;this.withPathIds(t,a=>{let l=[...a];return[l[e],l[i]]=[l[i],l[e]],l});let o=[...n];[o[e],o[i]]=[o[i],o[e]],this.store.unregisterPrefix&&(this.store.unregisterPrefix(C(t,e)),this.store.unregisterPrefix(C(t,i))),this.commitArrayMutationWithFieldPipeline({path:t,nextArray:o,meta:{origin:"array",operation:"swap",from:e,to:i},reindex:a=>a===e?i:a===i?e:a})}moveItem(t,e,i){let r=this.store.getState(),n=_chunkFTXV2NZOcjs.f.call(void 0, r.values,t);if(!Array.isArray(n)||e<0||e>=n.length||i<0||i>=n.length)return;this.withPathIds(t,l=>{let d=[...l],[p]=d.splice(e,1);return d.splice(i,0,p),d});let o=[...n],[a]=o.splice(e,1);if(o.splice(i,0,a),this.store.unregisterPrefix){let l=Math.min(e,i),d=Math.max(e,i);for(let p=l;p<=d;p+=1)this.store.unregisterPrefix(C(t,p))}this.commitArrayMutationWithFieldPipeline({path:t,nextArray:o,meta:{origin:"array",operation:"move",from:e,to:i},reindex:l=>l===e?i:e<i&&l>e&&l<=i?l-1:e>i&&l>=i&&l<e?l+1:l})}replaceItems(t,e){_optionalChain([this, 'access', _133 => _133.store, 'access', _134 => _134.unregisterPrefix, 'optionalCall', _135 => _135(C(t))]),e.length===0?this.pathIds.delete(t):this.pathIds.set(t,e.map((i,r)=>this.store.createArrayItemId(t,r))),this.commitArrayMutationWithFieldPipeline({path:t,nextArray:e,meta:{origin:"array",operation:"replace"},reindex:i=>i<e.length?i:null})}clearItems(t){this.pathIds.delete(t),this.store.unregisterPrefix&&this.store.unregisterPrefix(C(t)),this.commitArrayMutationWithFieldPipeline({path:t,nextArray:[],meta:{origin:"array",operation:"clear"},reindex:()=>null})}mutateArrayWithSetField(t,e,i){let r=_chunkFTXV2NZOcjs.f.call(void 0, this.store.getState().values,t)||[];this.store.setFieldWithMeta(t,e(r),i),this.store.internalSaveSnapshot()}withPathIds(t,e){let i=this.getCurrentArrayLength(t),r=this.ensureIds(t,i),n=e(r);n.length===0?this.pathIds.delete(t):this.pathIds.set(t,n)}ensureIds(t,e){let i=_nullishCoalesce(this.pathIds.get(t), () => ([]));if(i.length===e)return i;if(i.length<e){let n=[...i];for(let o=i.length;o<e;o+=1)n.push(this.store.createArrayItemId(t,o));return this.pathIds.set(t,n),n}let r=i.slice(0,e);return r.length===0?this.pathIds.delete(t):this.pathIds.set(t,r),r}getCurrentArrayLength(t){let e=_chunkFTXV2NZOcjs.f.call(void 0, this.store.getState().values,t);return Array.isArray(e)?e.length:0}commitArrayMutationWithFieldPipeline(t){let{path:e,nextArray:i,meta:r,reindex:n}=t,o=this.store.getState();this.store.setFieldWithMeta(e,i,r);let a=_chunkFTXV2NZOcjs.k.call(void 0, o,e,n);_optionalChain([this, 'access', _136 => _136.store, 'access', _137 => _137.remapValidationPaths, 'optionalCall', _138 => _138(e,n)]),this.store.dispatch(b({errors:a.errors,touched:a.touched,isValidating:a.isValidating},[e])),this.store.internalSaveSnapshot()}}, _class11);var at=class{constructor(t,e,i){this.getState=t;this.dispatch=e;this.reportError=i}reportInvalidInput(t,e){_optionalChain([this, 'access', _139 => _139.reportError, 'optionalCall', _140 => _140(new Error(e===void 0?t:`${t}: ${String(e)}`))])}setError(t,e){if(!t||typeof t!="string"){this.reportInvalidInput("setError received an invalid path",t);return}if(e!==void 0&&typeof e!="string"){this.reportInvalidInput("setError received an invalid message",e);return}let i={...this.getState().errors,[t]:e};e===void 0&&delete i[t],this.dispatch(b({errors:i}))}setErrors(t){if(!t||typeof t!="object"){this.reportInvalidInput("setErrors received an invalid payload");return}let e={};Object.entries(t).forEach(([i,r])=>{if(!i){this.reportInvalidInput("setErrors ignored an empty path");return}if(r!==void 0&&typeof r!="string"){this.reportInvalidInput("setErrors ignored a non-string message",i);return}e[i]=r}),this.dispatch(b({errors:{...this.getState().errors,...e}}))}setServerErrors(t,e){let i=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _141 => _141.arrayStrategy]), () => ("first")),r=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _142 => _142.joinSeparator]), () => ("; ")),n={};for(let[o,a]of Object.entries(t)){if(!o){this.reportInvalidInput("setServerErrors ignored an empty path");continue}if(Array.isArray(a)){let l=a.filter(d=>typeof d=="string"&&d.length>0);if(l.length===0)continue;n[o]=i==="join"?l.join(r):l[0];continue}n[o]=a}this.setErrors(n)}};var lt= (_class12 =class{constructor(t,e,i){;_class12.prototype.__init43.call(this);this.fieldMetadataProvider=t;this.getState=e;this.isPathDirty=i}__init43() {this.requiredValuesRef=null}isHidden(t){return this.fieldMetadataProvider.isHidden(t)}isRequired(t){let e=this.getState().values;return this.requiredValuesRef!==e&&(this.requiredValuesRef=e),this.fieldMetadataProvider.isRequired(t,e)}isFieldDirty(t){return this.isPathDirty(t)}isFieldValidating(t){return!!this.getState().isValidating[t]}isTouched(t){return!!this.getState().touched[t]}}, _class12);function ae(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp)}function le(s,t){let e=[],i=new Map,r=(n,o,a,l,d)=>{if(!(l&&d&&_chunkFTXV2NZOcjs.d.call(void 0, n,o))){if(n!==null&&typeof n=="object"&&o!==null&&typeof o=="object"){let p=i.get(n);if(_optionalChain([p, 'optionalAccess', _143 => _143.has, 'call', _144 => _144(o)]))return;p?p.add(o):i.set(n,new Set([o]))}try{if(ae(n)&&ae(o)&&l&&d){let p=new Set([...Object.keys(n),...Object.keys(o)]);for(let c of p){let u=a?`${a}.${c}`:c,h=Object.prototype.hasOwnProperty.call(n,c),f=Object.prototype.hasOwnProperty.call(o,c);r(n[c],o[c],u,h,f)}return}e.push({path:a,previousValue:_chunkFTXV2NZOcjs.a.call(void 0, n),nextValue:_chunkFTXV2NZOcjs.a.call(void 0, o),hadPreviousValue:l,hasNextValue:d})}finally{if(n!==null&&typeof n=="object"&&o!==null&&typeof o=="object"){let p=i.get(n);_optionalChain([p, 'optionalAccess', _145 => _145.delete, 'call', _146 => _146(o)]),p&&p.size===0&&i.delete(n)}}}};return r(s,t,"",!0,!0),{operations:e}}function ct(s,t,e){let i=s,r=[],n=[];for(let o of t.operations){let a=e==="undo"?o.hadPreviousValue:o.hasNextValue,l=e==="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=_chunkFTXV2NZOcjs.h.call(void 0, i,r)),n.length>0&&(i=_chunkFTXV2NZOcjs.i.call(void 0, i,n)),i}var dt= (_class13 =class{constructor(t,e){;_class13.prototype.__init44.call(this);_class13.prototype.__init45.call(this);_class13.prototype.__init46.call(this);_class13.prototype.__init47.call(this);_class13.prototype.__init48.call(this);this.enableHistory=t;this.maxHistory=e}__init44() {this.baseSnapshot=null}__init45() {this.currentSnapshot=null}__init46() {this.patches=[]}__init47() {this.historyIndex=-1}__init48() {this.historySize=0}saveSnapshot(t){if(!this.enableHistory)return;if(!this.currentSnapshot||this.baseSnapshot===null){this.reset(t);return}let e=le(this.currentSnapshot,t);if(e.operations.length!==0)for(this.historyIndex<this.historySize-1&&(this.patches.splice(this.historyIndex),this.historySize=this.historyIndex+1),this.patches.push(e),this.currentSnapshot=t,this.historyIndex+=1,this.historySize=this.historyIndex+1;this.historySize>this.getCapacity();)this.compactOldestSnapshot()}get canUndo(){return this.enableHistory?this.historyIndex>0:!1}get canRedo(){return this.enableHistory?this.historyIndex<this.historySize-1:!1}undo(){if(!this.canUndo||!this.currentSnapshot)return null;let t=this.patches[this.historyIndex-1],e=ct(this.currentSnapshot,t,"undo");return this.currentSnapshot=e,this.historyIndex-=1,e}redo(){if(!this.canRedo||!this.currentSnapshot)return null;let t=this.patches[this.historyIndex],e=ct(this.currentSnapshot,t,"redo");return this.currentSnapshot=e,this.historyIndex+=1,e}reset(t){if(!this.enableHistory){this.baseSnapshot=null,this.currentSnapshot=null,this.patches=[],this.historyIndex=-1,this.historySize=0;return}this.baseSnapshot=_chunkFTXV2NZOcjs.a.call(void 0, t),this.currentSnapshot=this.baseSnapshot,this.patches=[],this.historyIndex=0,this.historySize=1}getMetadata(){return{enabled:this.enableHistory,canUndo:this.canUndo,canRedo:this.canRedo,historyIndex:this.historyIndex,historySize:this.historySize}}compactOldestSnapshot(){let t=this.patches.shift();!t||this.baseSnapshot===null||(this.baseSnapshot=ct(this.baseSnapshot,t,"redo"),this.historySize=Math.max(1,this.historySize-1),this.historyIndex=Math.max(0,this.historyIndex-1))}getCapacity(){return Math.max(1,this.maxHistory)}}, _class13);function kt(s,t,e){if(!Object.prototype.hasOwnProperty.call(s,t))return[s,e];let r=s,n=e;return n||(r={...s},n=!0),delete r[t],[r,n]}var I=class{constructor(t){this.steps=t}async run(t){for(let e of this.steps){if(t.halted)break;await e.run(t)}}},ut=class{constructor(t){this.steps=t}run(t){for(let e of this.steps){if(t.halted)break;let i=e.run(t);if(i!=null&&typeof i.then=="function")throw new Error(`BitSyncPipelineRunner: step "${e.name}" returned a Promise. Use BitPipelineRunner for async steps.`)}}};var pt=class{constructor(t){this.store=t;this.fieldUpdatePipeline=new ut([{name:"field:clear-current-error",run:e=>this.clearCurrentError(e)},{name:"field:update-dependencies",run:e=>this.updateDependencies(e)},{name:"field:update-dirty",run:e=>this.updateDirtyState(e)},{name:"field:commit-state",run:e=>this.commitFieldState(e)},{name:"field:emit-change",run:e=>this.emitFieldChange(e)},{name:"field:trigger-validate",run:e=>this.triggerResolverValidation(e)},{name:"field:trigger-async-validate",run:e=>this.triggerAsyncValidation(e)}])}updateField(t,e,i={origin:"setField"}){let r=this.store.getState(),n=_chunkFTXV2NZOcjs.f.call(void 0, r.values,t),o={path:t,value:e,meta:i,previousValue:n,nextValues:_chunkFTXV2NZOcjs.g.call(void 0, r.values,t,e),nextErrors:r.errors,hasMutatedErrors:!1,dependencyDiff:{affectedFields:[],visibilityChanged:[],requiredChanged:[]},isDirty:!1};this.fieldUpdatePipeline.run(o)}clearCurrentError(t){[t.nextErrors,t.hasMutatedErrors]=kt(t.nextErrors,t.path,t.hasMutatedErrors),this.store.clearFieldValidation(t.path)}updateDependencies(t){if(typeof this.store.hasDependentFields=="function"&&!this.store.hasDependentFields(t.path)){t.dependencyDiff.affectedFields.length=0,t.dependencyDiff.visibilityChanged.length=0,t.dependencyDiff.requiredChanged.length=0;return}t.dependencyDiff=this.store.updateDependencies(t.path,this.store.getState().values,t.nextValues),new Set([...t.dependencyDiff.visibilityChanged,...t.dependencyDiff.requiredChanged]).forEach(i=>{[t.nextErrors,t.hasMutatedErrors]=kt(t.nextErrors,i,t.hasMutatedErrors),this.store.clearFieldValidation(i)})}updateDirtyState(t){t.isDirty=this.store.updateDirtyForPath(t.path,t.nextValues,this.store.getBaselineValues())}commitFieldState(t){let e=Array.from(new Set([t.path,...t.dependencyDiff.visibilityChanged,...t.dependencyDiff.requiredChanged]));this.store.dispatch(b({values:t.nextValues,errors:t.nextErrors,isDirty:t.isDirty},e))}emitFieldChange(t){this.store.emitFieldChange({path:t.path,previousValue:t.previousValue,nextValue:t.value,values:this.store.getState().values,state:this.store.getState(),meta:t.meta})}triggerResolverValidation(t){let e=Array.from(new Set([t.path,...t.dependencyDiff.visibilityChanged,...t.dependencyDiff.requiredChanged]));(this.store.config.resolver||t.dependencyDiff.visibilityChanged.length>0||t.dependencyDiff.requiredChanged.length>0)&&this.store.triggerValidation(e)}triggerAsyncValidation(t){this.store.isFieldHidden(t.path)||(typeof this.store.getFieldConfig=="function"?_optionalChain([this, 'access', _147 => _147.store, 'access', _148 => _148.getFieldConfig, 'call', _149 => _149(t.path), 'optionalAccess', _150 => _150.validation, 'optionalAccess', _151 => _151.asyncValidateOn]):void 0)!=="change"||this.store.handleFieldAsyncValidation(t.path,t.value)}};var ht= (_class14 =class{constructor() { _class14.prototype.__init49.call(this); }__init49() {this.executors=new Map}register(t,e){let i=_nullishCoalesce(this.executors.get(t), () => ([]));i.push(e),this.executors.set(t,i)}async execute(t){let e=this.getOrderedExecutors(t.kind);for(let i of e)await i.execute(t)}executeSync(t){let e=this.getOrderedExecutors(t.kind);for(let i of e){let r=i.execute(t);if(r&&typeof r.then=="function")throw new Error(`BitLifecycleOrchestrator: executor async em modo sync para kind "${t.kind}".`)}}getOrderedExecutors(t){return[..._nullishCoalesce(this.executors.get(t), () => ([]))].sort((i,r)=>i.phase-r.phase)}}, _class14);var ft=class{constructor(t){this.store=t;this.submitPipeline=new I([{name:"submit:start",run:async e=>this.startSubmit(e)},{name:"submit:invalid",run:async e=>this.handleInvalidSubmit(e)},{name:"submit:prepare",run:e=>this.prepareSubmitValues(e)},{name:"submit:before-hooks",run:async e=>this.runBeforeSubmitHooks(e)},{name:"submit:user-handler",run:async e=>this.runSubmitHandler(e)},{name:"submit:after-hooks",run:async e=>this.runAfterSubmitHooks(e)}])}async submit(t){if(this.store.getState().isSubmitting)return{status:"blocked",reason:"isSubmitting"};if(this.store.hasValidationsInProgress())return{status:"blocked",reason:"validating"};this.store.cancelAllValidations();let i={onSuccess:t,isValid:!1,valuesToSubmit:_chunkFTXV2NZOcjs.a.call(void 0, this.store.getState().values),dirtyValues:{}};try{return await this.submitPipeline.run(i),i.invalid?{status:"invalid"}:{status:"submitted"}}catch(r){return i.error=r,await this.store.emitOperationalError({source:"submit",error:r}),await this.store.emitAfterSubmit({values:i.valuesToSubmit,dirtyValues:i.dirtyValues,state:this.store.getState(),success:!1,error:r}),this.store.config.onUnhandledError(r,"submit"),{status:"failed",error:r}}finally{this.store.dispatch(b({isSubmitting:!1}))}}async startSubmit(t){this.store.dispatch(b({isSubmitting:!0})),t.isValid=await this.store.validateNow()}async handleInvalidSubmit(t){if(t.isValid)return;let e=this.store.getState().errors,i={...this.store.getState().touched};Object.keys(e).forEach(r=>{i[r]=!0}),this.store.batchStateUpdates(()=>{this.store.dispatch(b({touched:i}))}),t.dirtyValues=this.store.buildDirtyValues(this.store.getState().values),t.invalid=!0,await this.store.emitAfterSubmit({values:this.store.getState().values,dirtyValues:t.dirtyValues,state:this.store.getState(),success:!1,invalid:!0}),t.halted=!0}prepareSubmitValues(t){let e=[],i=this.store.getHiddenFields();i.forEach(r=>{e.push([r,void 0])}),e.length>0&&(t.valuesToSubmit=_chunkFTXV2NZOcjs.h.call(void 0, t.valuesToSubmit,e)),t.valuesToSubmit=Yt({values:t.valuesToSubmit,sourceValues:t.valuesToSubmit,transformEntries:this.store.getTransformEntries().filter(([r])=>!i.has(r)),onError:r=>{throw r}}),t.dirtyValues=this.store.buildDirtyValues(t.valuesToSubmit)}async runBeforeSubmitHooks(t){await this.store.emitBeforeSubmit({values:t.valuesToSubmit,dirtyValues:t.dirtyValues,state:this.store.getState()})}async runSubmitHandler(t){try{await t.onSuccess(t.valuesToSubmit,t.dirtyValues)}catch(e){if(_chunkFTXV2NZOcjs.m.call(void 0, e)){this.store.setServerErrors(_chunkFTXV2NZOcjs.n.call(void 0, e)),await this.store.emitAfterSubmit({values:t.valuesToSubmit,dirtyValues:t.dirtyValues,state:this.store.getState(),success:!1,invalid:!0}),t.invalid=!0,t.halted=!0;return}throw e}}async runAfterSubmitHooks(t){await this.store.emitAfterSubmit({values:t.valuesToSubmit,dirtyValues:t.dirtyValues,state:this.store.getState(),success:!0})}};var gt=class{constructor(t){this.store=t}collectChangedUpdates(t,e="",i=[],r=new WeakSet){if(t&&typeof t=="object"){if(r.has(t))return i;r.add(t)}try{Object.entries(t).forEach(([n,o])=>{let a=e?`${e}.${n}`:n;if(o&&typeof o=="object"&&!Array.isArray(o)&&Object.keys(o).length>0){if(r.has(o))return;this.collectChangedUpdates(o,a,i,r);return}i.push([a,o])})}finally{t&&typeof t=="object"&&r.delete(t)}return i}setValues(t,e){if(_optionalChain([e, 'optionalAccess', _152 => _152.rebase])){this.rebaseValues(t);return}if(_optionalChain([e, 'optionalAccess', _153 => _153.partial])){this.hydrateValues(t);return}this.replaceValuesInternal(t,"replaceValues")}hydrateValues(t){let e=this.collectChangedUpdates(t),i=e.map(([n])=>n),r=e.length>0?_chunkFTXV2NZOcjs.h.call(void 0, this.store.getState().values,e):this.store.getState().values;this.replaceValuesInternal(r,"hydrate",i.length>0?i:["*"])}rebaseValues(t){let e=this.store.getState().values,i=_chunkFTXV2NZOcjs.a.call(void 0, t);this.store.setBaselineValues(t),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', _154 => _154.store, 'access', _155 => _155.config, 'optionalAccess', _156 => _156.onUnhandledError, 'call', _157 => _157(r,"rebaseValues")])}),this.store.emitFieldChange({path:"*",previousValue:e,nextValue:i,values:this.store.getState().values,state:this.store.getState(),meta:{origin:"rebase"}})}applyHistoryState(t){this.store.cancelAllValidations();let e=this.store.rebuildDirtyState(t,this.store.getBaselineValues());this.store.dispatch(b({values:t,errors:{},isValid:!1,isDirty:e},["*"])),this.store.validateNow().catch(i=>{_optionalChain([this, 'access', _158 => _158.store, 'access', _159 => _159.config, 'optionalAccess', _160 => _160.onUnhandledError, 'call', _161 => _161(i,"applyHistoryState")])})}reset(){this.store.cancelAllValidations();let t=_chunkFTXV2NZOcjs.a.call(void 0, this.store.getBaselineValues());this.store.evaluateAllDependencies(t),this.store.clearDirtyState(),this.store.dispatch(b({values:t,errors:{},touched:{},isValidating:{},isValid:!0,isDirty:!1},["*"])),this.store.resetHistory(t)}replaceValuesInternal(t,e="replaceValues",i=["*"]){let r=this.store.getState().values,n=_chunkFTXV2NZOcjs.a.call(void 0, t);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', _162 => _162.store, 'access', _163 => _163.config, 'optionalAccess', _164 => _164.onUnhandledError, 'call', _165 => _165(a,"replaceValuesInternal")])}),this.store.emitFieldChange({path:"*",previousValue:r,nextValue:n,values:this.store.getState().values,state:this.store.getState(),meta:{origin:e}})}};var mt= (_class15 =class{constructor(t){;_class15.prototype.__init50.call(this);this.ports=t;this.fieldUpdate=new pt(t.fieldUpdate),this.values=new gt(t.values),this.submitFlow=new ft(t.submit),this.orchestrator.register("updateField",{phase:1,execute:e=>this.fieldUpdate.updateField(e.path,e.value,_nullishCoalesce(e.meta, () => ({origin:"setField"})))}),this.orchestrator.register("setValues",{phase:2,execute:e=>this.values.setValues(e.newValues,e.options)}),this.orchestrator.register("hydrateValues",{phase:2,execute:e=>this.values.hydrateValues(e.newValues)}),this.orchestrator.register("rebaseValues",{phase:2,execute:e=>this.values.rebaseValues(e.newValues)}),this.orchestrator.register("applyHistoryState",{phase:2,execute:e=>this.values.applyHistoryState(e.snapshot)}),this.orchestrator.register("submit",{phase:3,execute:async e=>{e.submitResult=await this.submitFlow.submit(e.onSuccess)}}),this.orchestrator.register("reset",{phase:4,execute:()=>this.values.reset()})}__init50() {this.orchestrator=new ht}updateField(t,e,i={origin:"setField"}){this.orchestrator.executeSync({kind:"updateField",path:t,value:e,meta:i})}setValues(t,e){this.orchestrator.executeSync({kind:"setValues",newValues:t,options:e})}hydrateValues(t){this.orchestrator.executeSync({kind:"hydrateValues",newValues:t})}rebaseValues(t){this.orchestrator.executeSync({kind:"rebaseValues",newValues:t})}applyHistoryState(t){this.orchestrator.executeSync({kind:"applyHistoryState",snapshot:t})}async submit(t){let e={kind:"submit",onSuccess:t};return await this.orchestrator.execute(e),e.submitResult}reset(){this.orchestrator.executeSync({kind:"reset"})}}, _class15);var yt=class{constructor(t,e,i,r){this.getState=t;this.getInitialValues=e;this.getScopeFields=i;this.isPathDirty=r}getScopeStatus(t){let e=this.getScopeFields(t),i=this.getState(),r=e.some(a=>!!i.errors[a]),n=e.some(a=>this.isPathDirty(a)),o=this.getScopeErrors(t);return{hasErrors:r,isDirty:n,errors:o}}getScopeErrors(t){let e=this.getScopeFields(t),i=this.getState(),r={};for(let n of e){let o=i.errors[n];o&&(r[n]=o)}return r}};var ce=Symbol("bit.async.validation.timeout"),St= (_class16 =class{constructor(t){;_class16.prototype.__init51.call(this);_class16.prototype.__init52.call(this);this.port=t}__init51() {this.abortControllers=new Map}__init52() {this.pendingJobs=new Map}handle(t,e,i,r,n){if(!i){this.cancel(t),this.port.setFieldValidating(t,!1);return}this.cancel(t),this.port.clearAsyncError(t),this.port.setFieldValidating(t,!0);let o=new AbortController;this.abortControllers.set(t,o),this.pendingJobs.set(t,{value:e,dueAt:Date.now()+r,validate:i,controller:o,timeoutMs:n}),this.schedulePendingJobs()}cancel(t){this.cancelInternal(t,!0)}cancelInternal(t,e){this.pendingJobs.has(t)&&(this.pendingJobs.delete(t),e&&this.schedulePendingJobs());let i=this.abortControllers.get(t);i&&(i.abort(),this.abortControllers.delete(t))}cleanupPrefix(t){let e=!1,i=new Set([...this.pendingJobs.keys(),...this.abortControllers.keys()]);for(let r of i)x(r,t)&&(this.cancelInternal(r,!1),e=!0,this.port.clearAsyncError(r),this.port.setFieldValidating(r,!1));e&&this.schedulePendingJobs()}remapPaths(t){let e=!1,i=new Map;for(let[n,o]of this.pendingJobs.entries()){let a=t(n);if(!a){o.controller.abort(),e=!0;continue}a!==n&&(e=!0),i.set(a,o)}let r=new Map;for(let[n,o]of this.abortControllers.entries()){let a=t(n);if(!a){o.abort();continue}r.set(a,o)}this.pendingJobs.clear(),i.forEach((n,o)=>{this.pendingJobs.set(o,n)}),this.abortControllers.clear(),r.forEach((n,o)=>{this.abortControllers.set(o,n)}),e&&this.schedulePendingJobs()}cancelAll(){if(this.cancelSchedulerTimeout)try{this.cancelSchedulerTimeout()}catch (e8){}finally{this.cancelSchedulerTimeout=void 0}this.abortControllers.forEach(t=>{try{t.abort()}catch (e9){}}),this.pendingJobs.clear(),this.abortControllers.clear()}schedulePendingJobs(){this.cancelSchedulerTimeout&&(this.cancelSchedulerTimeout(),this.cancelSchedulerTimeout=void 0);let t=Number.POSITIVE_INFINITY;for(let e of this.pendingJobs.values())e.dueAt<t&&(t=e.dueAt);Number.isFinite(t)&&(this.cancelSchedulerTimeout=this.port.schedule(()=>{this.cancelSchedulerTimeout=void 0,this.flushPendingJobs().catch(e=>{this.port.onError(e)})},Math.max(0,t-Date.now())))}async flushPendingJobs(){this.cancelSchedulerTimeout=void 0;let t=Date.now(),e=[];for(let[r,n]of this.pendingJobs.entries())n.dueAt<=t&&e.push([r,n]);if(e.length===0){this.schedulePendingJobs();return}e.forEach(([r])=>{this.pendingJobs.delete(r)});let i=await Promise.allSettled(e.map(([r,n])=>this.runJob(r,n)));for(let r of i)r.status==="rejected"&&this.port.onError(r.reason);this.schedulePendingJobs()}async runJob(t,e){if(!e.controller.signal.aborted)try{let i=e.validate(e.value,this.port.getValues());if(typeof e.timeoutMs=="number"&&e.timeoutMs>0){let o;i=Promise.race([i,new Promise(a=>{o=setTimeout(()=>a(ce),e.timeoutMs)})]).finally(()=>{o&&clearTimeout(o)})}let r=await i;if(e.controller.signal.aborted)return;let n=_chunkFTXV2NZOcjs.f.call(void 0, this.port.getValues(),t);if(!_chunkFTXV2NZOcjs.c.call(void 0, n,e.value)||r===ce)return;r!=null?this.port.setAsyncError(t,r):(this.port.clearAsyncError(t),await this.port.onValidationPassed(t))}finally{let i=_nullishCoalesce(this.findControllerPath(e.controller), () => (t));e.controller.signal.aborted||this.port.setFieldValidating(i,!1),this.abortControllers.get(i)===e.controller&&this.abortControllers.delete(i)}}findControllerPath(t){for(let[e,i]of this.abortControllers.entries())if(i===t)return e}}, _class16);function k(s){for(let t in s)if(s[t]!==void 0)return!0;return!1}async function Dt(s){let{scopeFields:t,store:e,asyncErrors:i}=s,r=e.getState(),n=new Set(e.getHiddenFields()),o=e.config.resolver?await e.config.resolver(r.values,{scopeFields:t}):{},a=e.getState(),l=t.some(f=>r.values[f]!==a.values[f]),d=e.getHiddenFields(),p=t.some(f=>n.has(f)!==d.has(f));if(l||p)return;let c=e.getRequiredErrors(a.values),u={...o,...c};d.forEach(f=>{delete u[f],i.delete(f)});let h={...a.errors};t.forEach(f=>{u[f]?h[f]=u[f]:i.has(f)?h[f]=i.get(f):delete h[f]}),e.dispatch(it(h,!k(h)))}var bt= (_class17 =class{constructor() { _class17.prototype.__init53.call(this);_class17.prototype.__init54.call(this); }__init53() {this.currentValidationId=0}__init54() {this.immediateAbortControllers=new Map}beginValidation(){return this.currentValidationId+=1,this.currentValidationId}getCurrentValidationId(){return this.currentValidationId}isValidationCurrent(t){return t===this.currentValidationId}setImmediateController(t,e){this.immediateAbortControllers.set(t,e)}clearImmediateController(t,e){return this.immediateAbortControllers.get(t)===e?(this.immediateAbortControllers.delete(t),!0):!1}cancelImmediate(t){let e=this.immediateAbortControllers.get(t);e&&(e.abort(),this.immediateAbortControllers.delete(t))}cancelImmediatePrefix(t,e){for(let i of this.immediateAbortControllers.keys())x(i,t)&&(this.cancelImmediate(i),e(i))}remapImmediateControllers(t){let e=new Map;for(let[i,r]of this.immediateAbortControllers.entries()){let n=t(i);if(!n){r.abort();continue}e.set(n,r)}this.immediateAbortControllers.clear(),e.forEach((i,r)=>{this.immediateAbortControllers.set(r,i)})}cancelAllImmediate(){this.immediateAbortControllers.forEach(t=>{t.abort()}),this.immediateAbortControllers.clear()}}, _class17);var Bt= (_class18 =class{constructor(t){;_class18.prototype.__init55.call(this);this.port=t}__init55() {this.pendingScopeFields=null}trigger(t,e){this.cancelTimeout&&(this.cancelTimeout(),this.cancelTimeout=void 0);let i=_nullishCoalesce(this.port.validationDelay, () => (300)),r=_optionalChain([e, 'optionalAccess', _166 => _166.forceDebounce])?Math.max(1,i):i;if(r>0){if(t&&t.length>0)if(!this.pendingScopeFields)this.pendingScopeFields=new Set(t);else for(let o of t)this.pendingScopeFields.add(o);else this.pendingScopeFields=null;let n=this.pendingScopeFields?Array.from(this.pendingScopeFields):void 0;this.cancelTimeout=this.port.schedule(()=>{this.pendingScopeFields=null,this.cancelTimeout=void 0,this.validateWithOptionalScopeFields(n)},r)}else this.pendingScopeFields=null,this.validateWithOptionalScopeFields(t)}validateWithOptionalScopeFields(t){return t&&t.length>0?this.port.validate({scopeFields:t}):this.port.validate()}cancelPending(){this.cancelTimeout&&(this.cancelTimeout(),this.cancelTimeout=void 0),this.pendingScopeFields=null}}, _class18);var de=Symbol("bit.async.validation.timeout");function ue(s){let{targetFields:t,currentErrors:e,allErrors:i,asyncErrors:r}=s;if(t&&t.length>0){let o=e,a=!1,l=()=>(a||(o={...e},a=!0),o);t.forEach(p=>{let c=p,u=e[c];if(i[p]!==void 0)u!==i[p]&&(l()[c]=i[p]);else if(r.has(p)){let h=r.get(p);u!==h&&(l()[c]=h)}else u!==void 0&&delete l()[c]});let d=t.every(p=>i[p]===void 0&&!r.has(p));return{committedErrors:a?o:e,result:d,mode:"scoped"}}let n={};return r.forEach((o,a)=>{n[a]=o}),Object.entries(i).forEach(([o,a])=>{a!==void 0&&(n[o]=a)}),{committedErrors:n,result:void 0,mode:"global"}}function pe(s){let{targetFields:t,hiddenFields:e,getFieldConfig:i,forEachFieldConfig:r}=s,n=[];if(t&&t.length>0){for(let o of t){if(e.has(o))continue;_optionalChain([i, 'call', _167 => _167(o), 'optionalAccess', _168 => _168.validation, 'optionalAccess', _169 => _169.asyncValidate])&&n.push(o)}return n}return r&&r((o,a)=>{!_optionalChain([o, 'access', _170 => _170.validation, 'optionalAccess', _171 => _171.asyncValidate])||e.has(a)||n.push(a)}),n}async function he(s){let{path:t,values:e,validationId:i,getCurrentValidationId:r,getFieldConfig:n,cancelFieldAsync:o,createAbortController:a,setAbortController:l,clearAbortController:d,setFieldValidating:p,setAsyncError:c,clearAsyncError:u}=s,h=_optionalChain([n, 'call', _172 => _172(t), 'optionalAccess', _173 => _173.validation, 'optionalAccess', _174 => _174.asyncValidate]);if(!h){u(t);return}o(t),u(t);let f=a();l(t,f),p(t,!0);try{let B=_optionalChain([n, 'call', _175 => _175(t), 'optionalAccess', _176 => _176.validation, 'optionalAccess', _177 => _177.asyncValidateTimeout]),g=h(_chunkFTXV2NZOcjs.f.call(void 0, e,t),e);if(typeof B=="number"&&B>0){let T;g=Promise.race([g,new Promise(P=>{T=setTimeout(()=>P(de),B)})]).finally(()=>{T&&clearTimeout(T)})}let m=await g;if(f.signal.aborted||i!==r())return;m===de||(m!=null?c(t,m):u(t))}finally{d(t,f)&&p(t,!1)}}function fe(s){let{ctx:t,deps:e}=s,i=t.options;if(_optionalChain([i, 'optionalAccess', _178 => _178.scope])&&_optionalChain([i, 'access', _179 => _179.scopeFields, 'optionalAccess', _180 => _180.length])){e.store.config.onUnhandledError(new Error("validate received both 'scope' and 'scopeFields'. 'scopeFields' takes precedence."),"validation");return}if(!_optionalChain([t, 'access', _181 => _181.options, 'optionalAccess', _182 => _182.scopeFields, 'optionalAccess', _183 => _183.length])&&_optionalChain([t, 'access', _184 => _184.options, 'optionalAccess', _185 => _185.scope])){let r=e.store.getScopeFields(t.options.scope);r.length>0&&(t.targetFields=r)}}async function ge(s){let{ctx:t,deps:e}=s;await e.store.emitBeforeValidate({values:t.currentState.values,state:t.currentState,scope:_optionalChain([t, 'access', _186 => _186.options, 'optionalAccess', _187 => _187.scope]),scopeFields:t.targetFields})}async function me(s){let{ctx:t,deps:e}=s,i=e.store.config.resolver?await e.store.config.resolver(t.currentState.values,{scopeFields:t.targetFields}):{},r=e.store.getRequiredErrors(t.currentState.values);t.allErrors={...i,...r},e.store.getHiddenFields().forEach(n=>{delete t.allErrors[n],e.asyncErrors.delete(n)})}async function ye(s){let{ctx:t,deps:e}=s,i=pe({targetFields:t.targetFields,hiddenFields:e.store.getHiddenFields(),getFieldConfig:n=>e.store.getFieldConfig(n),forEachFieldConfig:e.store.forEachFieldConfig});if(i.length===0)return;let r=await Promise.allSettled(i.map(n=>e.runImmediateAsyncValidation(n,t.currentState.values,t.validationId)));for(let n of r)n.status==="rejected"&&e.store.config.onUnhandledError(n.reason,"validation")}function Se(s){let{ctx:t,deps:e}=s,i=ue({targetFields:t.targetFields,currentErrors:t.currentState.errors,allErrors:t.allErrors,asyncErrors:e.asyncErrors});t.committedErrors=i.committedErrors,t.isValid=!k(i.committedErrors),t.result=i.mode==="scoped"?i.result:t.isValid}async function Mt(s){let{ctx:t,deps:e}=s;t.validationId!==e.getCurrentValidationId()&&(t.aborted=!0,t.result=e.store.getState().isValid,t.halted=!0)}async function be(s){let{ctx:t,deps:e}=s;e.store.dispatch(it(t.committedErrors,t.isValid)),await e.store.emitAfterValidate({values:e.store.getState().values,state:e.store.getState(),scope:_optionalChain([t, 'access', _188 => _188.options, 'optionalAccess', _189 => _189.scope]),scopeFields:t.targetFields,errors:t.committedErrors,result:t.result}),t.halted=!0}var vt=class{constructor(t){this.deps=t;this.runner=new I([{name:"validate:resolve-target-fields",run:e=>fe({ctx:e,deps:this.deps})},{name:"validate:before-hooks",run:async e=>ge({ctx:e,deps:this.deps})},{name:"validate:sync-track",run:async e=>me({ctx:e,deps:this.deps})},{name:"validate:abort-check-pre-async",run:async e=>Mt({ctx:e,deps:this.deps})},{name:"validate:async-track",run:async e=>ye({ctx:e,deps:this.deps})},{name:"validate:abort-check",run:async e=>Mt({ctx:e,deps:this.deps})},{name:"validate:async-track-merge",run:e=>Se({ctx:e,deps:this.deps})},{name:"validate:commit",run:async e=>be({ctx:e,deps:this.deps})}])}async run(t){await this.runner.run(t)}};var Tt= (_class19 =class{constructor(t){;_class19.prototype.__init56.call(this);_class19.prototype.__init57.call(this);_class19.prototype.__init58.call(this);this.store=t;this.schedule=_nullishCoalesce(_optionalChain([t, 'access', _190 => _190.config, 'access', _191 => _191.scheduler, 'optionalAccess', _192 => _192.schedule]), () => (((i,r)=>{let n=setTimeout(i,r);return()=>clearTimeout(n)}))),this.debouncer=new Bt({schedule:(i,r)=>this.schedule(i,r),validate:i=>this.validate(i),validationDelay:_nullishCoalesce(t.config.validationDelay, () => (300))}),this.pipelineStore={getState:()=>this.store.getState(),dispatch:i=>this.store.dispatch(i),config:this.store.config,getFieldConfig:i=>this.store.getFieldConfig(i),forEachFieldConfig:i=>this.store.forEachFieldConfig(i),getScopeFields:i=>this.store.getScopeFields(i),getRequiredErrors:i=>this.store.getRequiredErrors(i),getHiddenFields:()=>this.store.getHiddenFields(),emitBeforeValidate:i=>this.store.emitBeforeValidate(i),emitAfterValidate:i=>this.store.emitAfterValidate(i)},this.asyncScheduler=new St({schedule:(i,r)=>this.schedule(i,r),getValues:()=>this.store.getState().values,setFieldValidating:(i,r)=>this.updateFieldValidating(i,r),setAsyncError:(i,r)=>{this.asyncErrors.set(i,r),this.store.setError(i,r)},clearAsyncError:i=>{let r=this.asyncErrors.get(i);this.asyncErrors.delete(i),r&&!this.store.config.resolver&&this.store.getState().errors[i]===r&&this.store.setError(i,void 0),Dt({scopeFields:[i],store:this.pipelineStore,asyncErrors:this.asyncErrors}).catch(n=>{this.store.config.onUnhandledError(n,"validation")})},onValidationPassed:async i=>{await Dt({scopeFields:[i],store:this.pipelineStore,asyncErrors:this.asyncErrors})},onError:i=>{this.store.config.onUnhandledError(i,"validation")}});let e={store:this.pipelineStore,asyncErrors:this.asyncErrors,getCurrentValidationId:()=>this.coordinator.getCurrentValidationId(),runImmediateAsyncValidation:(i,r,n)=>this.runImmediateAsyncValidation(i,r,n)};this.validationPipeline=new vt(e)}__init56() {this.validatingCount=0}__init57() {this.asyncErrors=new Map}__init58() {this.coordinator=new bt}updateFieldValidating(t,e){let i=this.store.getState();if(!!i.isValidating[t]===e)return;let n={...i.isValidating};e?(n[t]=!0,this.validatingCount+=1):(delete n[t],this.validatingCount=Math.max(0,this.validatingCount-1)),this.store.dispatch(b({isValidating:n}))}cancelFieldAsync(t){this.asyncScheduler.cancel(t),this.coordinator.cancelImmediate(t)}cleanupField(t){this.cancelFieldAsync(t),this.asyncErrors.delete(t),this.updateFieldValidating(t,!1)}cleanupPrefix(t){this.asyncScheduler.cleanupPrefix(t),this.coordinator.cancelImmediatePrefix(t,e=>{this.asyncErrors.delete(e),this.updateFieldValidating(e,!1)})}remapArrayPaths(t,e){let i=`${t}.`;this.asyncScheduler.remapPaths(n=>_chunkFTXV2NZOcjs.l.call(void 0, n,i,e)),this.coordinator.remapImmediateControllers(n=>_chunkFTXV2NZOcjs.l.call(void 0, n,i,e));let r=new Map;this.asyncErrors.forEach((n,o)=>{let a=_chunkFTXV2NZOcjs.l.call(void 0, o,i,e);a!==null&&r.set(a,n)}),this.asyncErrors.clear(),r.forEach((n,o)=>{this.asyncErrors.set(o,n)})}beginExternalValidation(t){this.cancelFieldAsync(t),this.updateFieldValidating(t,!0)}endExternalValidation(t){this.updateFieldValidating(t,!1)}async setExternalError(t,e){if(e){this.asyncErrors.set(t,e),this.store.setError(t,e);return}this.cancelFieldAsync(t),this.asyncErrors.delete(t),this.store.setError(t,void 0),await this.validate({scopeFields:[t]})}handleAsync(t,e){let i=this.store.getFieldConfig(t),r=_optionalChain([i, 'optionalAccess', _193 => _193.validation, 'optionalAccess', _194 => _194.asyncValidate]),n=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _195 => _195.validation, 'optionalAccess', _196 => _196.asyncValidateOn]), () => ("blur"));if(!r||n!=="change"){this.cancelFieldAsync(t),this.updateFieldValidating(t,!1);return}let o=_nullishCoalesce(_optionalChain([i, 'access', _197 => _197.validation, 'optionalAccess', _198 => _198.asyncValidateDelay]), () => (500)),a=_optionalChain([i, 'access', _199 => _199.validation, 'optionalAccess', _200 => _200.asyncValidateTimeout]);this.asyncScheduler.handle(t,e,r,o,a)}hasValidationsInProgress(t){let e=this.store.getState();return t&&t.length>0?t.some(i=>!!e.isValidating[i]):Object.keys(e.isValidating).length>0}trigger(t,e){this.debouncer.trigger(t,e)}async validate(t){try{_optionalChain([t, 'optionalAccess', _201 => _201.scopeFields, 'optionalAccess', _202 => _202.length])&&t.scopeFields.forEach(i=>{this.cancelFieldAsync(i),this.updateFieldValidating(i,!1)});let e={options:t,validationId:this.coordinator.beginValidation(),currentState:this.store.getState(),targetFields:_optionalChain([t, 'optionalAccess', _203 => _203.scopeFields]),allErrors:{},committedErrors:{},isValid:!0,result:!0,aborted:!1};if(await this.validationPipeline.run(e),e.aborted){let i=this.store.getState();await this.store.emitAfterValidate({values:i.values,state:i,scope:_optionalChain([e, 'access', _204 => _204.options, 'optionalAccess', _205 => _205.scope]),scopeFields:e.targetFields,errors:i.errors,result:i.isValid,aborted:!0})}return e.result}catch(e){return this.store.config.onUnhandledError(e,"validation"),!1}}clear(t){this.cancelFieldAsync(t),this.updateFieldValidating(t,!1),this.asyncErrors.delete(t)}cancelAll(){this.validatingCount=0,this.debouncer.cancelPending(),this.asyncScheduler.cancelAll(),this.asyncErrors.clear(),this.coordinator.cancelAllImmediate(),this.store.dispatch(b({isValidating:{}}))}async runImmediateAsyncValidation(t,e,i){await he({path:t,values:e,validationId:i,getCurrentValidationId:()=>this.coordinator.getCurrentValidationId(),getFieldConfig:r=>this.store.getFieldConfig(r),cancelFieldAsync:r=>this.cancelFieldAsync(r),createAbortController:()=>new AbortController,setAbortController:(r,n)=>{this.coordinator.setImmediateController(r,n)},clearAbortController:(r,n)=>this.coordinator.clearImmediateController(r,n),setFieldValidating:(r,n)=>this.updateFieldValidating(r,n),setAsyncError:(r,n)=>{this.asyncErrors.set(r,n)},clearAsyncError:r=>{this.asyncErrors.delete(r)}})}}, _class19);var Rt= (_class20 =class{constructor() { _class20.prototype.__init59.call(this); }__init59() {this.entries=new Map}register(t,e){this.entries.set(t,e)}resolve(t){let e=this.entries.get(t);if(!e)throw new Error(`BitStore capability "${String(t)}" n\xE3o foi registrada.`);return e}toCapabilities(){return{validation:this.resolve("validation"),lifecycle:this.resolve("lifecycle"),history:this.resolve("history"),arrays:this.resolve("arrays"),scope:this.resolve("scope"),query:this.resolve("query"),error:this.resolve("error")}}}, _class20);function Be(){return new Rt}function Bi(s){let{registry:t,ports:e,fieldRegistry:i}=s;t.register("validation",new Tt(e.validationPort)),t.register("lifecycle",new mt(e.lifecyclePorts)),t.register("history",new dt(!!e.config.history.enabled,_nullishCoalesce(e.config.history.limit, () => (50)))),t.register("arrays",new ot(e.arrayPort)),t.register("scope",new yt(()=>e.getState(),()=>e.getBaselineValues(),r=>e.getScopeFields(r),r=>e.isPathDirty(r))),t.register("query",new lt(i,()=>e.getState(),r=>e.isPathDirty(r))),t.register("error",new at(()=>e.getState(),r=>e.dispatch(r),r=>e.config.onUnhandledError(r,"errors")))}function ve(s){let{ports:t,fieldRegistry:e}=s,i=Be();return Bi({registry:i,ports:t,fieldRegistry:e}),{registry:i,capabilities:i.toCapabilities()}}function Te(s){let{config:t,fieldRegistry:e,computedManager:i}=s,r=_chunkFTXV2NZOcjs.a.call(void 0, t.initialValues);t.fields&&Object.entries(t.fields).forEach(([a,l])=>{e.register(a,l,r)});let n=rt(e.getComputedEntries());if(n.length>0)throw new Error(n[0].message);return{values:$({values:r,normalizerEntries:e.getNormalizerEntries(),applyComputed:(a,l)=>i.apply(a,l),onError:(a,l)=>{t.onUnhandledError(a,"derivation")}}),errors:{},touched:{},isValidating:{},persist:{isSaving:!1,isRestoring:!1,error:null},isValid:!0,isSubmitting:!1,isDirty:!1}}function Pe(s){return{getState:s.getState,dispatch:s.dispatch,setError:s.setError,getFieldConfig:s.getFieldConfig,forEachFieldConfig:t=>s.fieldRegistry.forEachFieldConfig((e,i)=>t(e,i)),getScopeFields:s.getScopeFields,config:s.config,getRequiredErrors:t=>s.fieldRegistry.getRequiredErrors(t),getHiddenFields:()=>s.fieldRegistry.getHiddenFields(),emitBeforeValidate:t=>s.getEffects().beforeValidate(t),emitAfterValidate:t=>s.getEffects().afterValidate(t)}}function Ee(s){let t={getState:s.getState,dispatch:s.dispatch,config:s.config,getFieldConfig:r=>s.fieldRegistry.getFieldConfig(r),updateDependencies:(r,n,o)=>s.fieldRegistry.updateDependencies(r,n,o),hasDependentFields:r=>s.fieldRegistry.hasDependents(r),isFieldHidden:r=>s.fieldRegistry.isHidden(r),clearFieldValidation:r=>s.getValidation().clear(r),triggerValidation:(r,n)=>s.getValidation().trigger(r,n),handleFieldAsyncValidation:(r,n)=>s.getValidation().handleAsync(r,n),updateDirtyForPath:(r,n,o)=>s.dirtyManager.updateForPath(r,n,o),getBaselineValues:s.getBaselineValues,emitFieldChange:r=>s.getEffects().onFieldChange(r)},e={getState:s.getState,dispatch:s.dispatch,config:s.config,internalSaveSnapshot:s.saveHistorySnapshot,evaluateAllDependencies:r=>s.fieldRegistry.evaluateAll(r),cancelAllValidations:()=>s.getValidation().cancelAll(),validateNow:r=>s.getValidation().validate(r),rebuildDirtyState:(r,n)=>s.dirtyManager.rebuild(r,n),clearDirtyState:s.dirtyManager.clear.bind(s.dirtyManager),getBaselineValues:s.getBaselineValues,setBaselineValues:s.setBaselineValues,resetHistory:r=>s.getHistory().reset(r),emitFieldChange:r=>s.getEffects().onFieldChange(r),triggerValidation:(r,n)=>s.getValidation().trigger(r,n)},i={getState:s.getState,dispatch:s.dispatch,batchStateUpdates:s.runStateBatch,config:s.config,getTransformEntries:s.getTransformEntries,getHiddenFields:()=>s.fieldRegistry.getHiddenFields(),cancelAllValidations:()=>s.getValidation().cancelAll(),validateNow:r=>s.getValidation().validate(r),hasValidationsInProgress:r=>s.getValidation().hasValidationsInProgress(r),buildDirtyValues:r=>s.dirtyManager.buildDirtyValues(r),setServerErrors:(r,n)=>s.setServerErrors(r,n),emitBeforeSubmit:r=>s.getEffects().beforeSubmit(r),emitAfterSubmit:r=>s.getEffects().afterSubmit(r),emitOperationalError:r=>s.getEffects().reportOperationalError(r)};return{fieldUpdate:t,values:e,submit:i}}function xe(s){return{getState:s.getState,setFieldWithMeta:s.setFieldWithMeta,dispatch:s.dispatch,internalSaveSnapshot:s.saveHistorySnapshot,unregisterPrefix:s.unregisterPrefix,remapValidationPaths:s.remapValidationPaths,createArrayItemId:s.createArrayItemId}}function Ce(s){let{config:t,fieldRegistry:e,dirtyManager:i,baselineManager:r,runtimeContext:n}=s,{stateAccess:o,fieldAccess:a,featureAccess:l,actions:d}=n,p=Pe({config:t,fieldRegistry:e,getState:o.getState,dispatch:o.dispatch,setError:d.setError,getFieldConfig:a.getFieldConfig,getScopeFields:a.getScopeFields,getEffects:l.getEffects}),c=Ee({config:t,fieldRegistry:e,dirtyManager:i,getState:o.getState,dispatch:o.dispatch,setServerErrors:d.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}),u=xe({getState:o.getState,dispatch:o.dispatch,setFieldWithMeta:(h,f,B)=>d.setFieldWithMeta(h,f,B),unregisterPrefix:d.unregisterPrefix,remapValidationPaths:(h,f)=>l.getValidation().remapArrayPaths(h,f),saveHistorySnapshot:o.saveHistorySnapshot,createArrayItemId:(h,f)=>t.idFactory({scope:"array",path:h,index:f})});return ve({ports:{validationPort:p,lifecyclePorts:c,arrayPort:u,config:t,getScopeFields:a.getScopeFields,getState:o.getState,dispatch:o.dispatch,getBaselineValues:()=>r.getValues(),isPathDirty:h=>i.isPathDirty(h)},fieldRegistry:e})}function Ve(s){let{config:t,fieldRegistry:e,dirtyManager:i,computedManager:r,rawConfig:n,baselineManager:o,runtimeContext:a}=s,{stateAccess:l,fieldAccess:d,featureAccess:p,actions:c}=a,u=Ce({config:t,fieldRegistry:e,dirtyManager:i,baselineManager:o,runtimeContext:{stateAccess:l,fieldAccess:d,featureAccess:p,actions:c}}),h=Te({config:t,fieldRegistry:e,computedManager:r}),f=new nt(l.getState,(g,m)=>t.onUnhandledError(g,m),t.subscriptionCacheSize),B=n.storeId||t.name||t.idFactory({scope:"store",storeName:t.name});return{state:h,subscriptions:f,capabilityRegistry:u.registry,storeId:B}}function Fe(){return{depth:0,pendingState:null,changedPathSet:null,changedPathList:null,valuesChanged:!1,pendingHistorySnapshot:!1}}function we(s){s.depth+=1}function Ae(s){return s.depth-=1,s.depth===0}function Pt(s,t){return _nullishCoalesce(t.pendingState, () => (s))}function Ie(s,t){if(s.pendingState=t.nextState,s.valuesChanged||=t.valuesChanged,t.valuesChanged&&(s.pendingHistorySnapshot=!0),t.changedPaths&&t.changedPaths.length>0){let e=_nullishCoalesce(s.changedPathSet, () => (new Set)),i=_nullishCoalesce(s.changedPathList, () => ([]));t.changedPaths.forEach(r=>{if(e.has("*")||e.has(r))return;if(r==="*"){e.clear(),i.length=0,e.add("*"),i.push("*");return}if(!i.some(o=>o!=="*"&&r.startsWith(`${o}.`))){for(let o=i.length-1;o>=0;o-=1){let a=i[o];a==="*"||!a.startsWith(`${r}.`)||(e.delete(a),i.splice(o,1))}e.add(r),i.push(r)}}),s.changedPathSet=e,s.changedPathList=i}}function ke(s){let{currentState:t,batchState:e,applyValueDerivations:i}=s;if(!e.pendingState)return e.pendingHistorySnapshot=!1,null;let r=e.pendingState,n=_nullishCoalesce(e.changedPathList, () => (void 0)),o=e.valuesChanged;return o&&(r={...r,values:i(r.values,n)}),e.pendingState=null,e.changedPathSet=null,e.changedPathList=null,e.valuesChanged=!1,{nextState:_nullishCoalesce(r, () => (t)),changedPaths:n,valuesChanged:o}}function vi(s){let t=!1;for(let i of Object.values(s))if(i===void 0){t=!0;break}if(!t)return s;let e={};return Object.entries(s).forEach(([i,r])=>{let n=r;n!==void 0&&(e[i]=n)}),e}function Ot(s){let{currentState:t,partialState:e,changedPaths:i,applyValueDerivations:r,applyComputedValues:n}=s,o=_nullishCoalesce(r, () => ((u=>n?n(u):u))),a={...t,...e},l=!!e.values;if(e.values&&(a.values=o(e.values,i)),e.errors){a.errors=vi(e.errors);let u=!k(a.errors);a.isValid="isValid"in e?!!e.isValid:u}let d=i&&i.length>0?i:void 0,p=Ti(e),c=K(d,p);return{nextState:a,changedPaths:c,valuesChanged:l}}function Ti(s){let t=new Set,e=[s.errors,s.touched,s.isValidating];for(let i of e)if(i)for(let r in i)t.add(r);return s.persist&&t.add("persist"),"isValid"in s&&t.add("isValid"),"isDirty"in s&&t.add("isDirty"),"isSubmitting"in s&&t.add("isSubmitting"),t.size>0?Array.from(t):void 0}function Pi(s){throw new Error(`BitStore: unsupported operation kind: ${String(s.kind)}`)}function Ei(s,t){switch(t.kind){case"state.patch":return t;case"field.touchMany":{if(t.paths.length===0)return null;let e={...s.touched};for(let i of t.paths)e[i]=!0;return b({touched:e},t.paths)}case"form.persistMeta":return b({persist:{...s.persist,...t.patch}});case"history.apply":return b({values:t.values,isDirty:t.isDirty},["*"]);case"validation.commit":return b({errors:t.errors,isValid:t.isValid});default:return Pi(t)}}function xi(s){let{currentState:t,operation:e,applyValueDerivations:i,onOperationError:r}=s,n=Object.prototype.hasOwnProperty.call(e.partialState,"values"),o=_nullishCoalesce(e.changedPaths, () => ((n?["*"]:void 0))),a;try{a=Ot({currentState:t,partialState:e.partialState,changedPaths:o,applyValueDerivations:i})}catch(l){_optionalChain([r, 'optionalCall', _206 => _206(l)]),a=Ot({currentState:t,partialState:e.partialState,changedPaths:o,applyValueDerivations:d=>d})}return a}function De(s){let{currentState:t,operation:e,applyValueDerivations:i,onOperationError:r}=s,n=Ei(t,e);return n?xi({currentState:t,operation:n,applyValueDerivations:(o,a)=>n.skipComputed?o:i(o,a),onOperationError:r}):null}function Me(s){let{state:t,batchState:e,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o}=s,a=Pt(t,e);if(e.depth>0){let d=De({currentState:a,operation:i,applyValueDerivations:p=>p,onOperationError:n});return d&&Ie(e,d),t}let l=De({currentState:t,operation:i,applyValueDerivations:r,onOperationError:n});return l?(o({nextState:l.nextState,changedPaths:l.changedPaths,valuesChanged:l.valuesChanged}),l.nextState):t}function Re(s){let{state:t,batchState:e,applyValueDerivations:i,onStateCommitted:r}=s,n=ke({currentState:t,batchState:e,applyValueDerivations:i});return n?(r({nextState:n.nextState,changedPaths:n.changedPaths,valuesChanged:n.valuesChanged}),n.nextState):t}function Oe(s){let{batchState:t,callback:e,flushBatchedStateUpdates:i}=s;we(t);try{return e()}finally{Ae(t)&&i()}}function je(s){let{payload:t,setState:e,notifySubscriptions:i,notifyEffects:r}=s;e(t.nextState),i(t.nextState,t.changedPaths),r(t.nextState,t.valuesChanged)}function He(s){let{state:t,batchState:e,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o}=s;return Me({state:t,batchState:e,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o})}function Ue(s){let{batchState:t,values:e,saveHistory:i}=s;if(t.depth>0){t.pendingHistorySnapshot=!0;return}i(e)}function ze(s){let{state:t,batchState:e,applyValueDerivations:i,onStateCommitted:r,saveHistory:n}=s,o=Re({state:t,batchState:e,applyValueDerivations:i,onStateCommitted:r});return e.pendingHistorySnapshot&&(e.pendingHistorySnapshot=!1,n(o.values)),o}var Et= (_class21 =class{constructor(t){;_class21.prototype.__init60.call(this);this.args=t;this.state=t.state,this.subscriptions=t.subscriptions,this.effects=t.effects,this.capabilityRegistry=t.capabilityRegistry,this.capabilities=t.capabilityRegistry.toCapabilities()}__init60() {this.batchState=Fe()}getCapability(t){return this.capabilityRegistry.resolve(t)}getState(){return Pt(this.state,this.batchState)}runBatch(t){return Oe({batchState:this.batchState,callback:t,flushBatchedStateUpdates:()=>this.flushBatchedStateUpdates()})}dispatch(t){this.state=He({state:this.state,batchState:this.batchState,operation:t,applyValueDerivations:(e,i)=>this.applyValueDerivations(e,i),onOperationError:e=>_optionalChain([this, 'access', _207 => _207.args, 'access', _208 => _208.onUnhandledError, 'optionalCall', _209 => _209(e,"derivation")]),onStateCommitted:e=>this.onStateCommitted(e)})}saveHistorySnapshot(){let t=this.capabilities.history.getMetadata();Ue({batchState:this.batchState,values:this.state.values,saveHistory:i=>this.capabilities.history.saveSnapshot(i)});let e=this.capabilities.history.getMetadata();this.notifyIfHistoryChanged(t,e)}cleanup(){this.subscriptions.destroy(),this.capabilities.validation.cancelAll(),this.effects.destroy()}onStateCommitted(t){je({payload:t,setState:e=>{this.state=e},notifySubscriptions:(e,i)=>this.subscriptions.notify(e,i),notifyEffects:(e,i)=>this.effects.onStateUpdated(e,i)})}flushBatchedStateUpdates(){let t=this.capabilities.history.getMetadata();this.state=ze({state:this.state,batchState:this.batchState,applyValueDerivations:(i,r)=>this.applyValueDerivations(i,r),onStateCommitted:i=>this.onStateCommitted(i),saveHistory:i=>this.capabilities.history.saveSnapshot(i)});let e=this.capabilities.history.getMetadata();this.notifyIfHistoryChanged(t,e)}applyValueDerivations(t,e){return this.args.applyValueDerivations?this.args.applyValueDerivations(t,e):t}notifyIfHistoryChanged(t,e){t.canUndo===e.canUndo&&t.canRedo===e.canRedo&&t.historyIndex===e.historyIndex&&t.historySize===e.historySize||this.subscriptions.notify(this.getState(),[_chunkRHMJPKNVcjs.h.call(void 0, )])}}, _class21);function qe(s){let{rawConfig:t,overrides:e}=s,i=Jt(t),r=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _210 => _210.baselineManager]), () => (new U(i.initialValues))),n=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _211 => _211.fieldRegistry]), () => (new N(({error:g})=>{i.onUnhandledError(g,"validation")}))),o=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _212 => _212.computedManager]), () => (new z(()=>n.getComputedEntries(),g=>i.onUnhandledError(g,"computed")))),a=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _213 => _213.dirtyManager]), () => (new q)),l=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _214 => _214.maskManager]), () => (new L));i.masks&&Object.entries(i.masks).forEach(([g,m])=>{l.registerMask(g,m)});let d=()=>{n.invalidateIndexes(),o.invalidateReverseDeps()},p,c=()=>{if(!p)throw new Error("BitStore runtime kernel is not initialized yet.");return p},u=Ve({rawConfig:t,config:i,fieldRegistry:n,computedManager:o,dirtyManager:a,baselineManager:r,runtimeContext:{stateAccess:{getState:()=>c().getState(),dispatch:g=>c().dispatch(g),saveHistorySnapshot:()=>c().saveHistorySnapshot(),runStateBatch:g=>c().runBatch(g)},fieldAccess:{getFieldConfig:g=>n.getFieldConfig(g),getScopeFields:g=>n.getScopeFields(g),getNormalizerEntries:()=>n.getNormalizerEntries(),getTransformEntries:()=>n.getTransformEntries()},featureAccess:{getEffects:()=>c().effects,getHistory:()=>c().getCapability("history"),getValidation:()=>c().getCapability("validation")},actions:{setError:(g,m)=>{c().getCapability("error").setError(g,m)},setServerErrors:(g,m)=>{c().getCapability("error").setServerErrors(g,m)},validate:g=>c().getCapability("validation").validate(g),setFieldWithMeta:(g,m,T={origin:"setField"})=>{c().runBatch(()=>{c().getCapability("lifecycle").updateField(g,m,T)})},unregisterPrefix:g=>{st({prefix:g,state:c().getState(),fieldRegistry:n,subscriptions:c().subscriptions,validationCleanupPrefix:m=>c().getCapability("validation").cleanupPrefix(m),invalidateFieldIndexes:d,dispatch:m=>c().dispatch(m)})},triggerValidation:(g,m)=>{c().getCapability("validation").trigger(g,m)}}}}),h=()=>{let g=c().getState();return a.buildDirtyValues(g.values)},f=g=>{ie({values:g,state:c().getState(),initialValues:r.getValues(),validation:c().getCapability("validation"),fieldRegistry:n,dirtyManager:a,dispatch:m=>c().dispatch(m),saveHistorySnapshot:()=>c().saveHistorySnapshot()})},B=Gt({storeId:u.storeId,config:i,getState:()=>c().getState(),getConfig:()=>i,getValues:()=>c().getState().values,getDirtyValues:h,applyPersistedValues:f,setPersistMetadata:g=>c().dispatch({kind:"form.persistMeta",patch:g})});return p=new Et({state:u.state,subscriptions:u.subscriptions,effects:B,capabilityRegistry:u.capabilityRegistry,onUnhandledError:(g,m)=>i.onUnhandledError(g,m),applyValueDerivations:(g,m)=>{try{return $({values:g,changedPaths:m,normalizerEntries:n.getNormalizerEntries(),applyComputed:(T,P)=>o.apply(T,P),onError:(T,P)=>{i.onUnhandledError(T,"derivation")}})}catch(T){return i.onUnhandledError(T,"derivation"),g}}}),p.saveHistorySnapshot(),{config:i,storeId:u.storeId,runtime:p,fieldRegistry:n,computedManager:o,dirtyManager:a,maskManager:l,baselineManager:r}}function Le(s){let{dispatch:t,effects:e}=s;return Zt({dispatch:t,effects:e})}function _e(s){let{dispatch:t,effects:e}=s;return te({dispatch:t,effects:e})}function We(s){let{dispatch:t,effects:e}=s;return ee({dispatch:t,effects:e})}function Ne(s){let{history:t,applyHistoryState:e}=s,i=t.undo();i&&e(i)}function Ke(s){let{history:t,applyHistoryState:e}=s,i=t.redo();i&&e(i)}function $e(s){return s.history.getMetadata()}function Je(s,t){let e=new Set,i=(o,a)=>o===null||typeof o!="object"?o:new Proxy(o,{get:(l,d,p)=>{if(typeof d=="symbol")return Reflect.get(l,d,p);let c=String(d),u=a?`${a}.${c}`:c;e.add(u);let h=Reflect.get(l,d,p);return i(h,u)}}),r=i(s,"");t(r);let n=new Set;return e.forEach(o=>{let a=Ci(o);a&&n.add(a)}),Array.from(n)}function Ci(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 Vi(s,t){if(s.length!==t.length)return!1;let e=new Set(t);for(let i of s)if(!e.has(i))return!1;return!0}function Fi(s,t){return s.length===0?{emitImmediately:_optionalChain([t, 'optionalAccess', _215 => _215.emitImmediately]),equalityFn:_optionalChain([t, 'optionalAccess', _216 => _216.equalityFn]),mode:"scoped",paths:["*"]}:{emitImmediately:_optionalChain([t, 'optionalAccess', _217 => _217.emitImmediately]),equalityFn:_optionalChain([t, 'optionalAccess', _218 => _218.equalityFn]),mode:"scoped",paths:s}}function Ye(s){let{getState:t,subscribeSelector:e,selector:i,listener:r,options:n}=s,o=null,a=Je(t(),i),l=!1,d=!1,p=c=>{let u=o;o=e(i,h=>{r(h);let f=Je(t(),i);Vi(a,f)||(a=f,!(d||l)&&(d=!0,queueMicrotask(()=>{d=!1,!l&&(_optionalChain([o, 'optionalCall', _219 => _219()]),p(a))})))},Fi(c,n)),_optionalChain([u, 'optionalCall', _220 => _220()])};return p(a),()=>{l=!0,_optionalChain([o, 'optionalCall', _221 => _221()]),o=null}}function Ge(s){let{getState:t,subscriptions:e,selector:i,listener:r,options:n,trackedSubscriptionsEnabled:o}=s,a=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _222 => _222.equalityFn]), () => (_chunkFTXV2NZOcjs.c));if(_optionalChain([n, 'optionalAccess', _223 => _223.mode])==="tracked"){if(!o)throw new Error('BitForm: subscribeSelector com mode="tracked" est\xE1 desabilitado por padr\xE3o. Ative config.trackedSubscriptions=true para habilitar o modo avan\xE7ado.');return Ye({getState:t,subscribeSelector:(l,d,p)=>e.subscribeSelector(l,d,p,a),selector:i,listener:r,options:n})}return e.subscribeSelector(i,r,n,a)}function Xe(s){let{path:t,listener:e,options:i,subscribeSelector:r}=s,n=[..._nullishCoalesce(_optionalChain([i, 'optionalAccess', _224 => _224.paths]), () => ([])),t];return r(o=>_chunkFTXV2NZOcjs.f.call(void 0, o.values,t),e,{...i,paths:n})}function Qe(s){let{path:t,listener:e,getFieldState:i,subscribeSelector:r}=s;return r(()=>i(t),e,{paths:[t],equalityFn:_chunkGKNGJOB3cjs.c})}function Ze(s){let{listener:t,subscribeSelector:e}=s;return e(i=>({isValid:i.isValid,isDirty:i.isDirty,isSubmitting:i.isSubmitting}),t,{paths:["isValid","isDirty","isSubmitting"],equalityFn:(i,r)=>i.isValid===r.isValid&&i.isDirty===r.isDirty&&i.isSubmitting===r.isSubmitting})}function ti(s){let{listener:t,subscribeSelector:e}=s;return e(i=>i.persist,t,{paths:["persist"],equalityFn:(i,r)=>i.isSaving===r.isSaving&&i.isRestoring===r.isRestoring&&i.error===r.error})}function ei(s){let{readHistoryMeta:t,subscribeSelector:e,listener:i}=s;return e(()=>t(),i,{paths:[_chunkRHMJPKNVcjs.h.call(void 0, )],equalityFn:(r,n)=>_chunkRHMJPKNVcjs.e.call(void 0, r,n)})}function ii(s){let{scopeName:t,getScopeFields:e,readScopeStatus:i,subscribeSelector:r,listener:n}=s,o=_chunkRHMJPKNVcjs.d.call(void 0, t),a=i(t),l=()=>{},d=()=>{l();let c=_chunkRHMJPKNVcjs.c.call(void 0, e(t));l=r(()=>i(t),u=>{_chunkRHMJPKNVcjs.b.call(void 0, a,u)||(a=u,n(u))},{paths:[...c,o]})};d();let p=r(()=>e(t).length,()=>{d();let c=i(t);_chunkRHMJPKNVcjs.b.call(void 0, a,c)||(a=c,n(c))},{paths:[o]});return()=>{l(),p()}}function ri(s){let{runtime:t,config:e,fieldRegistry:i,dirtyManager:r,stateReader:n}=s,o={getState:()=>_chunkFTXV2NZOcjs.a.call(void 0, n.getState()),getFieldState:c=>_chunkFTXV2NZOcjs.a.call(void 0, n.getFieldState(c)),getIsValid:()=>n.getFlag("isValid"),getIsSubmitting:()=>n.getFlag("isSubmitting"),getIsDirty:()=>n.getFlag("isDirty"),isHidden:c=>t.capabilities.query.isHidden(c),isRequired:c=>t.capabilities.query.isRequired(c),isFieldDirty:c=>t.capabilities.query.isFieldDirty(c),isFieldValidating:c=>t.capabilities.query.isFieldValidating(c),getDirtyValues:()=>r.buildDirtyValues(n.getState().values),getPersistMetadata:()=>n.getPersistMetadata(),getHistoryMetadata:()=>$e({history:t.capabilities.history}),getScopeStatus:c=>t.capabilities.scope.getScopeStatus(c),getScopeErrors:c=>t.capabilities.scope.getScopeErrors(c),getCanUndo:()=>t.capabilities.history.canUndo,getCanRedo:()=>t.capabilities.history.canRedo,getScopeFields:c=>i.getScopeFields(c)},a={subscribe:c=>t.subscriptions.subscribe(c),subscribePersistMeta:c=>ti({listener:c,subscribeSelector:(u,h,f)=>a.subscribeSelector(u,h,f)}),subscribeHistoryMeta:c=>ei({readHistoryMeta:()=>o.getHistoryMetadata(),subscribeSelector:(u,h,f)=>a.subscribeSelector(u,h,f),listener:c}),subscribeScopeStatus:(c,u)=>ii({scopeName:c,getScopeFields:h=>o.getScopeFields(h),readScopeStatus:h=>o.getScopeStatus(h),subscribeSelector:(h,f,B)=>a.subscribeSelector(h,f,B),listener:u}),subscribeSelector:(c,u,h)=>Ge({getState:()=>o.getState(),subscriptions:t.subscriptions,selector:c,listener:u,options:h,trackedSubscriptionsEnabled:!!e.trackedSubscriptions}),subscribePath:(c,u,h)=>Xe({path:c,listener:u,options:h,subscribeSelector:(f,B,g)=>a.subscribeSelector(f,B,g)}),subscribeFieldState:(c,u)=>Qe({path:c,listener:u,getFieldState:h=>o.getFieldState(h),subscribeSelector:(h,f,B)=>a.subscribeSelector(h,f,B)}),subscribeFormMeta:c=>Ze({listener:c,subscribeSelector:(u,h,f)=>a.subscribeSelector(u,h,f)})},l={registerField:(c,u)=>{ne({path:c,config:u,state:t.getState(),fieldRegistry:i,subscriptions:t.subscriptions,validationCleanupField:h=>t.capabilities.validation.cleanupField(h),stateReader:n,invalidateFieldIndexes:()=>{i.invalidateIndexes()},dispatch:h=>t.dispatch(h),getState:()=>t.getState(),onUnhandledError:(h,f)=>e.onUnhandledError(h,f)})},unregisterField:c=>{oe({path:c,state:t.getState(),hasStaticConfig:!!_optionalChain([e, 'access', _225 => _225.fields, 'optionalAccess', _226 => _226[c]]),fieldRegistry:i,subscriptions:t.subscriptions,validationCleanupField:u=>t.capabilities.validation.cleanupField(u),invalidateFieldIndexes:()=>{i.invalidateIndexes()},dispatch:u=>t.dispatch(u)})},unregisterPrefix:c=>{st({prefix:c,state:t.getState(),fieldRegistry:i,subscriptions:t.subscriptions,validationCleanupPrefix:u=>t.capabilities.validation.cleanupPrefix(u),invalidateFieldIndexes:()=>{i.invalidateIndexes()},dispatch:u=>t.dispatch(u)})},setField:(c,u)=>{t.runBatch(()=>{t.capabilities.lifecycle.updateField(c,u,{origin:"setField"})})},blurField:c=>{t.capabilities.query.isTouched(c)||t.runBatch(()=>{t.dispatch(It([c]))}),t.capabilities.validation.trigger([c])},markFieldsTouched:c=>{c.length!==0&&t.dispatch(It(c))},setValues:(c,u)=>{t.capabilities.lifecycle.setValues(c,u)},setError:(c,u)=>{t.capabilities.error.setError(c,u)},setErrors:c=>{t.capabilities.error.setErrors(c)},setServerErrors:(c,u)=>{t.capabilities.error.setServerErrors(c,u)},reset:()=>{t.runBatch(()=>{t.capabilities.lifecycle.reset()})},transaction:c=>t.runBatch(c),submit:c=>t.capabilities.lifecycle.submit(c),pushItem:(c,u)=>t.capabilities.arrays.pushItem(c,u),prependItem:(c,u)=>t.capabilities.arrays.prependItem(c,u),insertItem:(c,u,h)=>t.capabilities.arrays.insertItem(c,u,h),removeItem:(c,u)=>t.capabilities.arrays.removeItem(c,u),swapItems:(c,u,h)=>t.capabilities.arrays.swapItems(c,u,h),moveItem:(c,u,h)=>t.capabilities.arrays.moveItem(c,u,h),replaceItems:(c,u)=>t.capabilities.arrays.replaceItems(c,u),clearItems:c=>t.capabilities.arrays.clearItems(c)},d=c=>t.dispatch(c);return{read:o,observe:a,write:l,feature:{undo:()=>{Ne({history:t.capabilities.history,applyHistoryState:c=>t.capabilities.lifecycle.applyHistoryState(c)})},redo:()=>{Ke({history:t.capabilities.history,applyHistoryState:c=>t.capabilities.lifecycle.applyHistoryState(c)})},validate:c=>t.capabilities.validation.validate(c),hasValidationsInProgress:c=>t.capabilities.validation.hasValidationsInProgress(c),triggerValidation:(c,u)=>t.capabilities.validation.trigger(c,u),restorePersisted:()=>Le({dispatch:d,effects:t.effects}),forceSave:()=>_e({dispatch:d,effects:t.effects}),clearPersisted:()=>We({dispatch:d,effects:t.effects}),getArrayItemIds:(c,u)=>t.capabilities.arrays.getItemIds(c,u),cleanup:()=>t.cleanup()}}}function si(s){let t=()=>s.read.getState();return{read:{get storeId(){return s.identity.storeId},get config(){return _chunkFTXV2NZOcjs.a.call(void 0, s.identity.config)},get isValid(){return s.read.getIsValid()},get isSubmitting(){return s.read.getIsSubmitting()},get isDirty(){return s.read.getIsDirty()},getState:t,getFieldConfig:o=>{let a=s.getFieldConfig(o);return a?_chunkFTXV2NZOcjs.a.call(void 0, 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:t,subscribe:o=>s.observe.subscribe(o),subscribePersistMeta:o=>s.observe.subscribePersistMeta(o),subscribeHistoryMeta:o=>s.observe.subscribeHistoryMeta(o),subscribeScopeStatus:(o,a)=>s.observe.subscribeScopeStatus(o,a),subscribeFormMeta:o=>s.observe.subscribeFormMeta(o),subscribeSelector:(o,a,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 xt= (_class22 =class{constructor(t){;_class22.prototype.__init61.call(this);this.deps=t}__init61() {this.fieldStateCache=new Map}getState(){return this.deps.getState()}getUserLayer(){let t=this.deps.getState();return{values:t.values,touched:t.touched}}getValidationLayer(){let t=this.deps.getState();return{errors:t.errors,isValidating:t.isValidating,isValid:t.isValid}}getDerivedLayer(){return{isDirty:this.deps.getState().isDirty}}getFeatureLayer(){let t=this.deps.getState();return{persist:t.persist,isSubmitting:t.isSubmitting}}getFlag(t){return this.deps.getState()[t]}getPersistMetadata(){let t=this.deps.getState(),e=t.persist,i=this.persistMetaCache;if(i&&i.state===t&&i.snapshot.isSaving===e.isSaving&&i.snapshot.isRestoring===e.isRestoring&&i.snapshot.error===e.error)return i.snapshot;let r={isSaving:e.isSaving,isRestoring:e.isRestoring,error:e.error};return this.persistMetaCache={state:t,snapshot:r},r}getFieldState(t){let e=t,i=this.deps.getState(),r=this.fieldStateCache.get(e),n=_chunkFTXV2NZOcjs.f.call(void 0, i.values,e),o=i.errors[e],a=!!i.touched[e],l=this.deps.isHidden(e),d=this.deps.isRequired(e),p=this.deps.isFieldDirty(e),c=this.deps.isFieldValidating(e);if(r){let h=r.snapshot;if(h.value===n&&h.error===o&&h.touched===a&&h.isHidden===l&&h.isRequired===d&&h.isDirty===p&&h.isValidating===c)return h}let u=$t({state:i,path:t,value:n,isHidden:l,isRequired:d,isDirty:p,isValidating:c});return this.fieldStateCache.set(e,{state:i,snapshot:u}),u}invalidatePath(t){this.fieldStateCache.delete(t)}}, _class22);var Ct= (_class23 =class{__init62() {this[M]=!0}__init63() {this[D]=!0}constructor(t={}){;_class23.prototype.__init62.call(this);_class23.prototype.__init63.call(this);let e=qe({rawConfig:t});this._config=e.config,this.storeId=e.storeId;let i=new xt({getState:()=>e.runtime.getState(),isHidden:o=>e.runtime.capabilities.query.isHidden(o),isRequired:o=>e.runtime.capabilities.query.isRequired(o),isFieldDirty:o=>e.runtime.capabilities.query.isFieldDirty(o),isFieldValidating:o=>e.runtime.capabilities.query.isFieldValidating(o)}),r=ri({runtime:e.runtime,config:this._config,fieldRegistry:e.fieldRegistry,dirtyManager:e.dirtyManager,stateReader:i}),n=si({identity:{storeId:this.storeId,config:this._config},read:r.read,observe:r.observe,write:r.write,feature:r.feature,getFieldConfig:o=>e.fieldRegistry.getFieldConfig(o),resolveMask:o=>Kt({path:o,getFieldConfig:a=>e.fieldRegistry.getFieldConfig(a),masks:e.maskManager.getAllMasks()}),createArrayItemId:(o,a)=>this._config.idFactory({scope:"array",path:o,index:a})});this.read=n.read,this.observe=n.observe,this.write=n.write,this.feature=n.feature,e.runtime.effects.attachStorePort({getState:()=>this.read.getState(),getHistoryMetadata:()=>this.read.getHistoryMetadata(),undo:()=>this.feature.undo(),redo:()=>this.feature.redo(),reset:()=>this.write.reset()})}}, _class23);function ni(s={}){return new Ct(s)}function oi(s){if(!s||typeof s!="object")return!1;let t=s;return t[M]===!0&&!!t.read&&!!t.observe&&!!t.write&&!!t.feature}function wi(s){if(oi(s))return s;throw new Error("BitForm: o store informado n\xE3o exp\xF5e a API necess\xE1ria para hooks/framework bindings.")}function Ai(s){return!s||typeof s!="object"?!1:s[D]===!0}function Ii(s){if(!oi(s))throw new Error("BitForm: o store informado n\xE3o possui branding de hooks (BIT_HOOKS_API_SYMBOL).");if(!Ai(s))throw new Error("BitForm: o store informado n\xE3o possui branding de framework (BIT_FRAMEWORK_STORE_SYMBOL).");return s}function ki(s){return Object.defineProperty(s,M,{value:!0,enumerable:!1,configurable:!1,writable:!1}),Object.defineProperty(s,D,{value:!0,enumerable:!1,configurable:!1,writable:!1}),s}function Di(s={}){let t=ni(s),e={read:t.read,observe:t.observe,write:t.write,feature:t.feature};return ki(e)}function Mi(s){return s.read}function Ri(s){return s.observe}function Oi(s){return s.write}function ji(s){return s.feature}function Hi(s,t){let e={};for(let i of t)e[i]=s[i];return e}exports.a = wt; exports.b = gi; exports.c = wi; exports.d = Ii; exports.e = Di; exports.f = Mi; exports.g = Ri; exports.h = Oi; exports.i = ji; exports.j = Hi;
2
- //# sourceMappingURL=chunk-CIZ6UW2J.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-CIZ6UW2J.cjs","../src/core/store/engines/store-field-query-engine.ts","../src/core/store/orchestration/framework-store-brand.ts","../src/core/store/orchestration/hook-brand.ts","../src/core/store/managers/core/baseline-manager.ts","../src/core/store/managers/core/computed-manager.ts"],"names":["resolveFieldMask","args","path","getFieldConfig","masks","maskOption","createFieldStateSnapshot","state","value","isHidden","isRequired","isDirty","isValidating","pathKey","BIT_FRAMEWORK_STORE_SYMBOL","BIT_HOOKS_API_SYMBOL","BitBaselineManager","baselineValues","deepClone","values","BitComputedManager","getComputedEntries","onError","changedPaths","computedEntries","entriesToRun","nextValues","failedPaths","entry","dep","newValue","error","currentValue","getDeepValue","cached","valuesEqual","canUseScalarCache","deepEqual","setDeepValue","entries","map","dependents","childIdx","segments","len","prefix","children","reverseDependencies","affectedPaths","queue","queueIndex","currentPath","dependentPath","orderedAllEntries","indexByPath","affectedEntries","entryIndex","left","right","item","entryByPath","inDegree","dependencyPath","nextDependents","orderedPaths","nextDegree","signature","ordered","orderedEntries","index"],"mappings":"AAAA,iiCAAuE,wDAA0C,wDAAmI,SCUpOA,EAAAA,CAAmCC,CAAAA,CAI3B,CACtB,GAAM,CAAE,IAAA,CAAAC,CAAAA,CAAM,cAAA,CAAAC,CAAAA,CAAgB,KAAA,CAAAC,CAAM,CAAA,CAAIH,CAAAA,CAClCI,CAAAA,iBAAaF,CAAAA,mBAAeD,CAAI,CAAA,6BAAG,MAAA,CAEzC,EAAA,CAAKG,CAAAA,CAIL,OAAI,OAAOA,CAAAA,EAAe,QAAA,iBACjBD,CAAAA,4BAAAA,CAAQC,CAAgC,GAAA,CAG1CA,CACT,CAEO,SAASC,EAAAA,CAGdL,CAAAA,CAQ+C,CAC/C,GAAM,CAAE,KAAA,CAAAM,CAAAA,CAAO,IAAA,CAAAL,CAAAA,CAAM,KAAA,CAAAM,CAAAA,CAAO,QAAA,CAAAC,CAAAA,CAAU,UAAA,CAAAC,CAAAA,CAAY,OAAA,CAAAC,CAAAA,CAAS,YAAA,CAAAC,CAAa,CAAA,CACtEX,CAAAA,CACIY,CAAAA,CAAUX,CAAAA,CAEhB,MAAO,CACL,KAAA,CAAAM,CAAAA,CACA,KAAA,CAAOD,CAAAA,CAAM,MAAA,C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ACjC,IAAA,CAAK,mBAAA,CAAsB3B,CAC7B,CAEQ,sBAAA,CAAuBA,CAAAA,CAAwC,CACrE,OAAOA,CAAAA,CACJ,GAAA,CAAKX,CAAAA,EAAU,CAAA,EAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-CIZ6UW2J.cjs","sourcesContent":[null,"import type { BitMask, BitMaskName } from \"../../mask/types\";\nimport type {\n BitErrors,\n BitFieldDefinition,\n BitFieldState,\n BitPath,\n BitPathValue,\n BitState,\n} from \"../contracts/types\";\n\nexport function resolveFieldMask<T extends object>(args: {\n path: string;\n getFieldConfig: (path: string) => BitFieldDefinition<T> | undefined;\n masks: Record<BitMaskName, BitMask> | undefined;\n}): BitMask | undefined {\n const { path, getFieldConfig, masks } = args;\n const maskOption = getFieldConfig(path)?.mask;\n\n if (!maskOption) {\n return undefined;\n }\n\n if (typeof maskOption === \"string\") {\n return masks?.[maskOption as keyof typeof masks];\n }\n\n return maskOption;\n}\n\nexport function createFieldStateSnapshot<\n TForm extends object,\n P extends BitPath<TForm>,\n>(args: {\n state: Readonly<BitState<TForm>>;\n path: P;\n value: BitPathValue<TForm, P>;\n isHidden: boolean;\n isRequired: boolean;\n isDirty: boolean;\n isValidating: boolean;\n}): BitFieldState<TForm, BitPathValue<TForm, P>> {\n const { state, path, value, isHidden, isRequired, isDirty, isValidating } =\n args;\n const pathKey = path as string;\n\n return {\n value,\n error: state.errors[pathKey as keyof BitErrors<TForm>],\n touched: !!state.touched[pathKey as keyof typeof state.touched],\n isHidden,\n isRequired,\n isDirty,\n isValidating,\n };\n}\n","export const BIT_FRAMEWORK_STORE_SYMBOL = Symbol.for(\n \"bit-form.framework-store-api\",\n);\n","export const BIT_HOOKS_API_SYMBOL = Symbol.for(\"bit-form.hooks-api\");\n","import { deepClone } from \"../../../utils\";\n\nexport class BitBaselineManager<T extends object> {\n constructor(baselineValues: T) {\n this.baselineValues = deepClone(baselineValues);\n }\n\n private baselineValues: T;\n private baselineSnapshot?: Readonly<T>;\n\n getValues(): T {\n if (!this.baselineSnapshot) {\n this.baselineSnapshot = Object.freeze(deepClone(this.baselineValues));\n }\n\n return this.baselineSnapshot as T;\n }\n\n setValues(values: T): void {\n this.baselineValues = deepClone(values);\n this.baselineSnapshot = undefined;\n }\n}\n","import { deepEqual, getDeepValue, setDeepValue } from \"../../../utils\";\nimport type { BitComputedFn } from \"../../contracts/types\";\n\nexport interface BitComputedEntry<T extends object> {\n path: string;\n compute: BitComputedFn<T>;\n dependsOn: readonly string[];\n}\n\nexport class BitComputedManager<T extends object> {\n private equalityCache = new Map<\n string,\n { current: unknown; next: unknown; equal: boolean }\n >();\n private reverseDepsCache: Map<string, Set<string>> | null = null;\n private childDepsIndex: Map<string, Set<string>> | null = null;\n private validatedEntriesSignature: string | null = null;\n private validatedEntriesRef: BitComputedEntry<T>[] | null = null;\n private orderedAllEntriesCache: {\n signature: string;\n ordered: BitComputedEntry<T>[];\n } | null = null;\n private orderedIndexByPathCache: {\n signature: string;\n indexByPath: Map<string, number>;\n } | null = null;\n\n constructor(\n private getComputedEntries: () => BitComputedEntry<T>[],\n private onError?: (error: unknown, path: string) => void,\n ) {}\n\n private isCacheableScalar(value: unknown): boolean {\n return (\n value === null ||\n (typeof value !== \"object\" && typeof value !== \"function\")\n );\n }\n\n invalidateReverseDeps(): void {\n this.reverseDepsCache = null;\n this.childDepsIndex = null;\n this.orderedAllEntriesCache = null;\n this.validatedEntriesSignature = null;\n this.validatedEntriesRef = null;\n this.orderedIndexByPathCache = null;\n this.equalityCache.clear();\n }\n\n apply(values: T, changedPaths?: readonly string[]): T {\n const computedEntries = this.getComputedEntries();\n if (computedEntries.length === 0) return values;\n\n this.ensureEntriesAreValid(computedEntries);\n\n const entriesToRun = this.resolveEntriesToRun(\n computedEntries,\n changedPaths,\n );\n\n if (entriesToRun.length === 0) {\n return values;\n }\n\n let nextValues = values;\n const failedPaths = new Set<string>();\n\n for (const entry of entriesToRun) {\n // Skip this entry if any of its declared dependencies failed in this run.\n if (entry.dependsOn.some((dep) => failedPaths.has(dep))) {\n failedPaths.add(entry.path);\n continue;\n }\n\n let newValue: unknown;\n try {\n newValue = entry.compute(nextValues);\n } catch (error) {\n this.onError?.(error, entry.path);\n failedPaths.add(entry.path);\n continue;\n }\n const currentValue = getDeepValue(nextValues, entry.path);\n\n const cached = this.equalityCache.get(entry.path);\n let valuesEqual: boolean;\n const canUseScalarCache =\n this.isCacheableScalar(currentValue) &&\n this.isCacheableScalar(newValue);\n\n if (\n canUseScalarCache &&\n cached &&\n cached.current === currentValue &&\n cached.next === newValue\n ) {\n valuesEqual = cached.equal;\n } else {\n valuesEqual = deepEqual(currentValue, newValue);\n\n if (canUseScalarCache) {\n this.equalityCache.set(entry.path, {\n current: currentValue,\n next: newValue,\n equal: valuesEqual,\n });\n } else {\n this.equalityCache.delete(entry.path);\n }\n }\n\n if (!valuesEqual) {\n nextValues = setDeepValue(nextValues, entry.path, newValue);\n }\n }\n return nextValues;\n }\n\n private getReverseDependencies(\n entries: BitComputedEntry<T>[],\n ): Map<string, Set<string>> {\n if (this.reverseDepsCache) return this.reverseDepsCache;\n\n const map = new Map<string, Set<string>>();\n\n for (const entry of entries) {\n for (const dep of entry.dependsOn) {\n let dependents = map.get(dep);\n if (!dependents) {\n dependents = new Set();\n map.set(dep, dependents);\n }\n dependents.add(entry.path);\n }\n }\n\n const childIdx = new Map<string, Set<string>>();\n\n for (const dep of map.keys()) {\n const segments = dep.split(\".\");\n for (let len = 1; len < segments.length; len++) {\n const prefix = segments.slice(0, len).join(\".\");\n let children = childIdx.get(prefix);\n if (!children) {\n children = new Set();\n childIdx.set(prefix, children);\n }\n children.add(dep);\n }\n }\n\n this.reverseDepsCache = map;\n this.childDepsIndex = childIdx;\n return map;\n }\n\n private resolveEntriesToRun(\n entries: BitComputedEntry<T>[],\n changedPaths?: readonly string[],\n ): BitComputedEntry<T>[] {\n if (\n !changedPaths ||\n changedPaths.length === 0 ||\n changedPaths.includes(\"*\")\n ) {\n return this.getOrderedAllEntries(entries);\n }\n\n const reverseDependencies = this.getReverseDependencies(entries);\n const affectedPaths = new Set<string>();\n const queue = [...changedPaths];\n let queueIndex = 0;\n\n while (queueIndex < queue.length) {\n const currentPath = queue[queueIndex++]!;\n const dependents = this.getDependentsForPath(\n reverseDependencies,\n currentPath,\n );\n\n if (!dependents) {\n continue;\n }\n\n for (const dependentPath of dependents) {\n if (affectedPaths.has(dependentPath)) {\n continue;\n }\n\n affectedPaths.add(dependentPath);\n queue.push(dependentPath);\n }\n }\n\n if (affectedPaths.size === 0) {\n return [];\n }\n\n const orderedAllEntries = this.getOrderedAllEntries(entries);\n const indexByPath = this.getOrderedIndexByPath(entries, orderedAllEntries);\n const affectedEntries: Array<{\n index: number;\n entry: BitComputedEntry<T>;\n }> = [];\n\n affectedPaths.forEach((path) => {\n const entryIndex = indexByPath.get(path);\n if (entryIndex === undefined) {\n return;\n }\n\n const entry = orderedAllEntries[entryIndex];\n if (!entry) {\n return;\n }\n\n affectedEntries.push({ index: entryIndex, entry });\n });\n\n affectedEntries.sort((left, right) => left.index - right.index);\n return affectedEntries.map((item) => item.entry);\n }\n\n private orderEntries(entries: BitComputedEntry<T>[]) {\n if (entries.length <= 1) {\n return entries;\n }\n\n const entryByPath = new Map(entries.map((entry) => [entry.path, entry]));\n const inDegree = new Map<string, number>();\n const dependents = new Map<string, Set<string>>();\n\n entries.forEach((entry) => inDegree.set(entry.path, 0));\n\n entries.forEach((entry) => {\n entry.dependsOn.forEach((dependencyPath) => {\n if (!entryByPath.has(dependencyPath)) {\n return;\n }\n\n const nextDependents = dependents.get(dependencyPath) ?? new Set();\n if (!nextDependents.has(entry.path)) {\n nextDependents.add(entry.path);\n dependents.set(dependencyPath, nextDependents);\n inDegree.set(entry.path, (inDegree.get(entry.path) ?? 0) + 1);\n }\n });\n });\n\n const queue = entries\n .filter((entry) => (inDegree.get(entry.path) ?? 0) === 0)\n .map((entry) => entry.path);\n const orderedPaths: string[] = [];\n\n while (queue.length > 0) {\n const currentPath = queue.shift()!;\n orderedPaths.push(currentPath);\n\n const nextDependents = dependents.get(currentPath);\n if (!nextDependents) {\n continue;\n }\n\n nextDependents.forEach((dependentPath) => {\n const nextDegree = (inDegree.get(dependentPath) ?? 0) - 1;\n inDegree.set(dependentPath, nextDegree);\n\n if (nextDegree === 0) {\n queue.push(dependentPath);\n }\n });\n }\n\n if (orderedPaths.length !== entries.length) {\n throw new Error(\n \"BitStore: cyclic computed dependencies detected. Check computedDependsOn definitions.\",\n );\n }\n\n return orderedPaths.map((path) => entryByPath.get(path)!);\n }\n\n private getOrderedAllEntries(entries: BitComputedEntry<T>[]) {\n const signature = this.createEntriesSignature(entries);\n if (\n this.orderedAllEntriesCache &&\n this.orderedAllEntriesCache.signature === signature\n ) {\n return this.orderedAllEntriesCache.ordered;\n }\n\n const ordered = this.orderEntries(entries);\n this.orderedAllEntriesCache = { signature, ordered };\n return ordered;\n }\n\n private getOrderedIndexByPath(\n entries: BitComputedEntry<T>[],\n orderedEntries: BitComputedEntry<T>[],\n ): Map<string, number> {\n const signature = this.createEntriesSignature(entries);\n if (\n this.orderedIndexByPathCache &&\n this.orderedIndexByPathCache.signature === signature\n ) {\n return this.orderedIndexByPathCache.indexByPath;\n }\n\n const indexByPath = new Map<string, number>();\n orderedEntries.forEach((entry, index) => {\n indexByPath.set(entry.path, index);\n });\n\n this.orderedIndexByPathCache = { signature, indexByPath };\n return indexByPath;\n }\n\n private ensureEntriesAreValid(entries: BitComputedEntry<T>[]) {\n if (this.validatedEntriesRef === entries) {\n return;\n }\n\n const signature = this.createEntriesSignature(entries);\n if (this.validatedEntriesSignature === signature) {\n this.validatedEntriesRef = entries;\n return;\n }\n\n entries.forEach((entry) => this.assertDependencies(entry));\n this.invalidateReverseDeps();\n this.validatedEntriesSignature = signature;\n this.validatedEntriesRef = entries;\n }\n\n private createEntriesSignature(entries: BitComputedEntry<T>[]): string {\n return entries\n .map((entry) => `${entry.path}:${entry.dependsOn.join(\",\")}`)\n .join(\"|\");\n }\n\n private getDependentsForPath(\n reverseDependencies: Map<string, Set<string>>,\n changedPath: string,\n ) {\n const dependents = new Set<string>();\n\n const collect = (dependencyPath: string) => {\n const listeners = reverseDependencies.get(dependencyPath);\n if (!listeners) {\n return;\n }\n\n listeners.forEach((path) => dependents.add(path));\n };\n\n collect(changedPath);\n\n const parentSegments = changedPath.split(\".\");\n while (parentSegments.length > 1) {\n parentSegments.pop();\n collect(parentSegments.join(\".\"));\n }\n\n const childKeys = this.childDepsIndex?.get(changedPath);\n if (childKeys) {\n for (const childDep of childKeys) {\n collect(childDep);\n }\n }\n\n return dependents;\n }\n\n private assertDependencies(entry: BitComputedEntry<T>) {\n if (entry.dependsOn.length === 0) {\n throw new Error(\n `BitStore: computed field \\`${entry.path}\\` requires explicit computedDependsOn in v4.`,\n );\n }\n\n if (entry.dependsOn.includes(entry.path)) {\n throw new Error(\n `BitStore: computed field \\`${entry.path}\\` cannot depend on itself.`,\n );\n }\n }\n}\n"]}
@@ -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(); } }var _chunkCIZ6UW2Jcjs = require('./chunk-CIZ6UW2J.cjs');var _chunkAVUK52JWcjs = require('./chunk-AVUK52JW.cjs');var _chunkRHMJPKNVcjs = require('./chunk-RHMJPKNV.cjs');var _chunkGKNGJOB3cjs = require('./chunk-GKNGJOB3.cjs');var _chunkFTXV2NZOcjs = require('./chunk-FTXV2NZO.cjs');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var L=_react.createContext.call(void 0, null),ft= exports.a =({store:t,children:e})=>_jsxruntime.jsx.call(void 0, L.Provider,{value:_chunkCIZ6UW2Jcjs.d.call(void 0, t),children:e}),l= exports.b =()=>{let t=_react.useContext.call(void 0, L);if(!t)throw new Error("BitForm hooks devem ser usados dentro de um BitFormProvider");return t};function Pt(){let t=l(),[e,r]=_react.useState.call(void 0, null),[i,s]=_react.useState.call(void 0, null),o=_react.useRef.call(void 0, null),c=_react.useCallback.call(void 0, S=>_chunkAVUK52JWcjs.b.call(void 0, t,S),[t]),m=_react.useCallback.call(void 0, ()=>{let S=_chunkAVUK52JWcjs.a.call(void 0, t);return o.current&&o.current.isValid===S.isValid&&o.current.isDirty===S.isDirty&&o.current.isSubmitting===S.isSubmitting?o.current:(o.current=S,S)},[t]),n=_react.useSyncExternalStore.call(void 0, c,m,m),d=_react.useMemo.call(void 0, ()=>_chunkAVUK52JWcjs.i.call(void 0, t,{clearSubmissionState:()=>{r(null),s(null)},setSubmissionResult:S=>{s(S)},setSubmissionError:S=>{r(S)}}),[t]),{controller:a,actions:x}=d,v=_react.useCallback.call(void 0, a.submit,[a]),T=_react.useCallback.call(void 0, a.onSubmit,[a]),E=_react.useCallback.call(void 0, a.reset,[a]),u=_react.useCallback.call(void 0, a.getValues,[a]),b=_react.useCallback.call(void 0, a.getErrors,[a]),B=_react.useCallback.call(void 0, a.getTouched,[a]),g=_react.useCallback.call(void 0, a.getDirtyValues,[a]);return{meta:_react.useMemo.call(void 0, ()=>({...n,submitError:e,lastResponse:i}),[n,e,i]),getValues:u,getErrors:b,getTouched:B,getDirtyValues:g,submit:v,onSubmit:T,reset:E,...x}}function Rt(t){let e=l(),r=_react.useMemo.call(void 0, ()=>_chunkAVUK52JWcjs.g.call(void 0, e,t),[e,t]),i=_react.useRef.call(void 0, null),s=_react.useCallback.call(void 0, ()=>{let n=r.readItems();return i.current&&_chunkFTXV2NZOcjs.c.call(void 0, i.current,n)?i.current:(i.current=n,n)},[r]),o=_react.useCallback.call(void 0, n=>e.observe.subscribePath(t,()=>n()),[e,t]),c=_react.useSyncExternalStore.call(void 0, o,s,s),m=_react.useMemo.call(void 0, ()=>r.getFields(c),[r,c]);return _react.useEffect.call(void 0, ()=>()=>{_chunkAVUK52JWcjs.k.call(void 0, e,`${t}.`)},[e,t]),{fields:m,length:c.length,append:r.append,prepend:r.prepend,insert:r.insert,remove:r.remove,move:r.move,swap:r.swap,replace:r.replace,clear:r.clear}}function At(t){let e=l(),r=_react.useRef.call(void 0, null),i=_react.useCallback.call(void 0, ()=>{let n=e.read.getScopeStatus(t);return r.current&&_chunkRHMJPKNVcjs.b.call(void 0, r.current,n)?r.current:(r.current=n,n)},[e,t]),s=_react.useCallback.call(void 0, n=>e.observe.subscribeScopeStatus(t,()=>n()),[e,t]),o=_react.useSyncExternalStore.call(void 0, s,i,i),c=_react.useCallback.call(void 0, async()=>{let n=await e.feature.validate({scope:t}),d=e.read.getScopeErrors(t);return{valid:n,errors:d}},[e,t]),m=_react.useCallback.call(void 0, ()=>e.read.getScopeErrors(t),[e,t]);return{scopeName:t,status:o,errors:o.errors,validate:c,getErrors:m,isValid:!o.hasErrors,isDirty:o.isDirty}}function It(t){let e=l(),[r,i]=_react.useState.call(void 0, 0),s=_nullishCoalesce(t[r], () => ("")),o=_react.useRef.call(void 0, null),c=_react.useCallback.call(void 0, ()=>{let u=e.read.getScopeStatus(s);return o.current&&_chunkRHMJPKNVcjs.b.call(void 0, o.current,u)?o.current:(o.current=u,u)},[e,s]),m=_react.useSyncExternalStore.call(void 0, _react.useCallback.call(void 0, u=>e.observe.subscribeScopeStatus(s,()=>u()),[e,s]),c,c),n=_react.useCallback.call(void 0, async()=>{let u=await e.feature.validate({scope:s}),b=e.read.getScopeErrors(s);return{valid:u,errors:b}},[e,s]),d=_react.useCallback.call(void 0, ()=>e.read.getScopeErrors(s),[e,s]),a=_react.useCallback.call(void 0, async()=>{let u=e.read.getScopeFields(s);if(e.feature.hasValidationsInProgress(u))return!1;let b=await e.feature.validate({scope:s});if(b)i(B=>Math.min(B+1,t.length-1));else{let B=e.read.getScopeErrors(s),g=Object.keys(B);g.length>0&&e.write.markFieldsTouched(g)}return b},[e,s,t.length]),x=_react.useCallback.call(void 0, ()=>{i(u=>Math.max(u-1,0))},[]),v=_react.useCallback.call(void 0, u=>{i(Math.max(0,Math.min(u-1,t.length-1)))},[t.length]),T=r===0,E=r>=t.length-1;return{step:r+1,stepIndex:r,scope:s,next:a,prev:x,goTo:v,isFirst:T,isLast:E,status:m,errors:m.errors,isValid:!m.hasErrors,isDirty:m.isDirty,validate:n,getErrors:d}}function zt(t){let e=l(),r=_react.useRef.call(void 0, null),i=_react.useCallback.call(void 0, ()=>{let o=_chunkFTXV2NZOcjs.f.call(void 0, e.read.getState().values,t);return r.current!==null&&_chunkFTXV2NZOcjs.c.call(void 0, r.current,o)?r.current:(r.current=o,o)},[e,t]),s=_react.useCallback.call(void 0, o=>e.observe.subscribePath(t,()=>o()),[e,t]);return _react.useSyncExternalStore.call(void 0, s,i,i)}function Qt(){let t=l(),e=_react.useSyncExternalStore.call(void 0, c=>_chunkAVUK52JWcjs.e.call(void 0, t,c),()=>_chunkAVUK52JWcjs.d.call(void 0, t),()=>_chunkAVUK52JWcjs.d.call(void 0, t)),r=_react.useCallback.call(void 0, async()=>t.feature.restorePersisted(),[t]),i=_react.useCallback.call(void 0, async()=>{await t.feature.forceSave()},[t]),s=_react.useCallback.call(void 0, async()=>{await t.feature.clearPersisted()},[t]),o=_react.useMemo.call(void 0, ()=>({isSaving:e.isSaving,isRestoring:e.isRestoring,error:e.error}),[e]);return{restore:r,save:i,clear:s,meta:o}}function se(t){let e=l(),r=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>()=>_chunkAVUK52JWcjs.j.call(void 0, e,t),[e,t]);let i=_react.useCallback.call(void 0, ()=>{let n=e.read.getFieldState(t),d=_chunkGKNGJOB3cjs.a.call(void 0, n,r.current);return r.current=d,d},[e,t]),s=_react.useCallback.call(void 0, n=>e.observe.subscribeFieldState(t,()=>n()),[e,t]),o=_react.useSyncExternalStore.call(void 0, s,i,i),c=_react.useCallback.call(void 0, n=>e.write.setField(t,n),[e,t]),m=_react.useCallback.call(void 0, ()=>e.write.blurField(t),[e,t]);return{fieldState:o,setValue:c,setBlur:m,store:e}}exports.a = ft; exports.b = l; exports.c = Pt; exports.d = se; exports.e = Rt; exports.f = At; exports.g = It; exports.h = zt; exports.i = Qt;
2
- //# sourceMappingURL=chunk-IB2BMG4F.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-IB2BMG4F.cjs","../src/react/context.tsx","../src/react/use-bit-form.ts","../src/react/use-bit-array.ts"],"names":["BitContext","createContext","BitFormProvider","store","children","jsx","createFrameworkStoreAdapter","useBitStore","useContext","useBitForm","submitError","setSubmitError","useState","lastResponse","setLastResponse","lastMeta","useRef","subscribeMeta","useCallback","cb","subscribeFormMetaSnapshot","getMetaSnapshot","nextMeta","readFormMetaSnapshot","metaState","useSyncExternalStore","binding","useMemo","createFrameworkFormBinding","result","error","controller","actions","submit","onSubmit","reset","getValues","getErrors","getTouched","getDirtyValues","useBitArray","path","createArrayBinding","lastSnapshotRef","getSnapshot","next","valueEqual","subscribeArray","data","fields","useEffect","cleanupRegisteredPrefix"],"mappings":"AAAA,qOAAwC,wDAA0F,wDAAyC,wDAAyC,wDAAgD,8BCAnN,+CAa/C,IATIA,CAAAA,CAAaC,kCAAAA,IAAoD,CAAA,CAE1DC,EAAAA,aAAkB,CAAC,CAC9B,KAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CACF,CAAA,CAAA,EAIEC,6BAAAA,CAACL,CAAW,QAAA,CAAX,CAAoB,KAAA,CAAOM,iCAAAA,CAAiC,CAAA,CAC1D,QAAA,CAAAF,CAAAA,CACH,CAAA,CAGWG,CAAAA,aAAc,CAAA,CAAA,EAAwB,CACjD,IAAMJ,CAAAA,CAAQK,+BAAAA,CAAqB,CAAA,CACnC,EAAA,CAAI,CAACL,CAAAA,CACH,MAAM,IAAI,KAAA,CACR,6DACF,CAAA,CACF,OAAOA,CACT,CAAA,CCzBA,SAegBM,EAAAA,CAAAA,CAAoD,CAClE,IAAMN,CAAAA,CAAQI,CAAAA,CAAe,CAAA,CAEvB,CAACG,CAAAA,CAAaC,CAAc,CAAA,CAAIC,6BAAAA,IAA2B,CAAA,CAC3D,C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AAAA,CAAc1B,gCAAAA,CAAY,CAAA,EAAM,CACpC,IAAM2B,CAAAA,CAAOd,CAAAA,CAAW,SAAA,CAAU,CAAA,CAElC,OAAIY,CAAAA,CAAgB,OAAA,EAAWG,iCAAAA,CAAWH,CAAgB,OAAA,CAASE,CAAI,CAAA,CAC9DF,CAAAA,CAAgB,OAAA,CAAA,CAGzBA,CAAAA,CAAgB,OAAA,CAAUE,CAAAA,CACnBA,CAAAA,CACT,CAAA,CAAG,CAACd,CAAU,CAAC,CAAA,CAETgB,CAAAA,CAAiB7B,gCAAAA,CACpBC,EAAmBhB,CAAAA,CAAM,OAAA,CAAQ,aAAA,CAAcsC,CAAAA,CAAM,CAAA,CAAA,EAAMtB,CAAAA,CAAG,CAAC,CAAA,CAChE,CAAChB,CAAAA,CAAOsC,CAAI,CACd,CAAA,CAEMO,CAAAA,CAAOvB,yCAAAA,CAAqBsB,CAAgBH,CAAAA,CAAaA,CAAW,CAAA,CAEpEK,CAAAA,CAAStB,4BAAAA,CAAQ,CAAA,EAAMI,CAAAA,CAAW,SAAA,CAAUiB,CAAI,CAAA,CAAG,CAACjB,CAAAA,CAAYiB,CAAI,CAAC,CAAA,CAE3E,OAAAE,8BAAAA,CAAU,CAAA,EACD,CAAA,CAAA,EAAM,CACXC,iCAAAA,CAAwBhD,CAAO,CAAA,EAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-IB2BMG4F.cjs","sourcesContent":[null,"import React, { createContext, useContext } from \"react\";\nimport type { BitFrameworkStoreApi, BitStoreApi } from \"../core\";\nimport { createFrameworkStoreAdapter } from \"../core\";\n\nconst BitContext = createContext<BitFrameworkStoreApi<any> | null>(null);\n\nexport const BitFormProvider = ({\n store,\n children,\n}: {\n store: BitFrameworkStoreApi<any> | BitStoreApi<any>;\n children: React.ReactNode;\n}) => (\n <BitContext.Provider value={createFrameworkStoreAdapter(store)}>\n {children}\n </BitContext.Provider>\n);\n\nexport const useBitStore = <T extends object>() => {\n const store = useContext(BitContext);\n if (!store)\n throw new Error(\n \"BitForm hooks devem ser usados dentro de um BitFormProvider\",\n );\n return store as BitFrameworkStoreApi<T>;\n};\n","import {\n useCallback,\n useSyncExternalStore,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useBitStore } from \"./context\";\nimport {\n createFrameworkFormBinding,\n readFormMetaSnapshot,\n subscribeFormMetaSnapshot,\n} from \"../core\";\nimport type { UseBitFormResult } from \"./types\";\n\nexport function useBitForm<T extends object>(): UseBitFormResult<T> {\n const store = useBitStore<T>();\n\n const [submitError, setSubmitError] = useState<Error | null>(null);\n const [lastResponse, setLastResponse] = useState<unknown>(null);\n const lastMeta = useRef<ReturnType<typeof readFormMetaSnapshot<T>> | null>(\n null,\n );\n\n const subscribeMeta = useCallback(\n (cb: () => void) => subscribeFormMetaSnapshot(store, cb),\n [store],\n );\n const getMetaSnapshot = useCallback(() => {\n const nextMeta = readFormMetaSnapshot(store);\n\n if (\n lastMeta.current &&\n lastMeta.current.isValid === nextMeta.isValid &&\n lastMeta.current.isDirty === nextMeta.isDirty &&\n lastMeta.current.isSubmitting === nextMeta.isSubmitting\n ) {\n return lastMeta.current;\n }\n\n lastMeta.current = nextMeta;\n return nextMeta;\n }, [store]);\n\n const metaState = useSyncExternalStore(\n subscribeMeta,\n getMetaSnapshot,\n getMetaSnapshot,\n );\n\n const binding = useMemo(\n () =>\n createFrameworkFormBinding(store, {\n clearSubmissionState: () => {\n setSubmitError(null);\n setLastResponse(null);\n },\n setSubmissionResult: (result) => {\n setLastResponse(result);\n },\n setSubmissionError: (error) => {\n setSubmitError(error);\n },\n }),\n [store],\n );\n\n const { controller, actions } = binding;\n\n const submit = useCallback(controller.submit, [controller]);\n const onSubmit = useCallback(controller.onSubmit, [controller]);\n const reset = useCallback(controller.reset, [controller]);\n\n const getValues = useCallback(controller.getValues, [controller]);\n const getErrors = useCallback(controller.getErrors, [controller]);\n const getTouched = useCallback(controller.getTouched, [controller]);\n const getDirtyValues = useCallback(controller.getDirtyValues, [controller]);\n\n const meta = useMemo(\n () => ({\n ...metaState,\n submitError,\n lastResponse,\n }),\n [metaState, submitError, lastResponse],\n );\n\n return {\n // Metadata (grouped)\n meta,\n // Getters\n getValues,\n getErrors,\n getTouched,\n getDirtyValues,\n // Main actions (frequent use - flat)\n submit,\n onSubmit,\n reset,\n ...actions,\n };\n}\n","import {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useSyncExternalStore,\n} from \"react\";\nimport {\n BitArrayPath,\n cleanupRegisteredPrefix,\n createArrayBinding,\n valueEqual,\n} from \"../core\";\nimport { useBitStore } from \"./context\";\n\nexport function useBitArray<\n TForm extends object = any,\n P extends BitArrayPath<TForm> = BitArrayPath<TForm>,\n>(path: P) {\n const store = useBitStore<TForm>();\n const controller = useMemo(\n () => createArrayBinding<TForm, P>(store, path),\n [store, path],\n );\n type ArraySnapshot = ReturnType<typeof controller.readItems>;\n const lastSnapshotRef = useRef<ArraySnapshot | null>(null);\n\n const getSnapshot = useCallback(() => {\n const next = controller.readItems();\n\n if (lastSnapshotRef.current && valueEqual(lastSnapshotRef.current, next)) {\n return lastSnapshotRef.current;\n }\n\n lastSnapshotRef.current = next;\n return next;\n }, [controller]);\n\n const subscribeArray = useCallback(\n (cb: () => void) => store.observe.subscribePath(path, () => cb()),\n [store, path],\n );\n\n const data = useSyncExternalStore(subscribeArray, getSnapshot, getSnapshot);\n\n const fields = useMemo(() => controller.getFields(data), [controller, data]);\n\n useEffect(() => {\n return () => {\n cleanupRegisteredPrefix(store, `${path as string}.`);\n };\n }, [store, path]);\n\n return {\n fields,\n length: data.length,\n append: controller.append,\n prepend: controller.prepend,\n insert: controller.insert,\n remove: controller.remove,\n move: controller.move,\n swap: controller.swap,\n replace: controller.replace,\n clear: controller.clear,\n };\n}\n"]}