@lehnihon/bit-form 2.2.12 → 2.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/angular/index.cjs +1 -1
  2. package/dist/angular/index.js +1 -1
  3. package/dist/{chunk-IDJIIPCS.js → chunk-4NQOD2BA.js} +2 -2
  4. package/dist/{chunk-ZWWXPYEL.js → chunk-7OZR7KWL.js} +2 -2
  5. package/dist/{chunk-QZBJ4WRU.cjs → chunk-ALIYU2RT.cjs} +2 -2
  6. package/dist/{chunk-QZBJ4WRU.cjs.map → chunk-ALIYU2RT.cjs.map} +1 -1
  7. package/dist/{chunk-LZTWNUKZ.js → chunk-EY44ZBGC.js} +2 -2
  8. package/dist/chunk-G4HK5QTU.js +2 -0
  9. package/dist/chunk-G4HK5QTU.js.map +1 -0
  10. package/dist/chunk-IMMFFTXE.js +2 -0
  11. package/dist/chunk-IMMFFTXE.js.map +1 -0
  12. package/dist/{chunk-JPOZKCPR.cjs → chunk-IXZ52RPZ.cjs} +2 -2
  13. package/dist/{chunk-JPOZKCPR.cjs.map → chunk-IXZ52RPZ.cjs.map} +1 -1
  14. package/dist/{chunk-S3DJPXMV.js → chunk-JKYECJH5.js} +2 -2
  15. package/dist/{chunk-MZNHMPTF.cjs → chunk-LM34BK4Q.cjs} +2 -2
  16. package/dist/{chunk-MZNHMPTF.cjs.map → chunk-LM34BK4Q.cjs.map} +1 -1
  17. package/dist/chunk-MAKFWOL5.cjs +2 -0
  18. package/dist/{chunk-OR5AGYQT.cjs.map → chunk-MAKFWOL5.cjs.map} +1 -1
  19. package/dist/chunk-MJ4AOJRT.cjs +2 -0
  20. package/dist/chunk-MJ4AOJRT.cjs.map +1 -0
  21. package/dist/{chunk-C2GGB5NF.cjs → chunk-OSQWKXFI.cjs} +2 -2
  22. package/dist/{chunk-C2GGB5NF.cjs.map → chunk-OSQWKXFI.cjs.map} +1 -1
  23. package/dist/chunk-VOA3SKFY.cjs +2 -0
  24. package/dist/chunk-VOA3SKFY.cjs.map +1 -0
  25. package/dist/chunk-W2FPKUNM.js +2 -0
  26. package/dist/chunk-W2FPKUNM.js.map +1 -0
  27. package/dist/core/bindings.cjs +1 -1
  28. package/dist/core/bindings.js +1 -1
  29. package/dist/core/store.cjs +1 -1
  30. package/dist/core/store.js +1 -1
  31. package/dist/core/utils.cjs +1 -1
  32. package/dist/core/utils.js +1 -1
  33. package/dist/core.cjs +1 -1
  34. package/dist/core.js +1 -1
  35. package/dist/devtools/bridge.cjs +1 -1
  36. package/dist/devtools/bridge.js +1 -1
  37. package/dist/devtools/index.cjs +2 -2
  38. package/dist/devtools/index.js +1 -1
  39. package/dist/index.cjs +1 -1
  40. package/dist/index.js +1 -1
  41. package/dist/react/index.cjs +1 -1
  42. package/dist/react/index.js +1 -1
  43. package/dist/react-native/index.cjs +1 -1
  44. package/dist/react-native/index.js +1 -1
  45. package/dist/utils.cjs +1 -1
  46. package/dist/utils.js +1 -1
  47. package/dist/vue/index.cjs +1 -1
  48. package/dist/vue/index.js +1 -1
  49. package/package.json +1 -1
  50. package/dist/chunk-6NH6MUXA.js +0 -2
  51. package/dist/chunk-6NH6MUXA.js.map +0 -1
  52. package/dist/chunk-CGJRZJ62.js +0 -2
  53. package/dist/chunk-CGJRZJ62.js.map +0 -1
  54. package/dist/chunk-OR5AGYQT.cjs +0 -2
  55. package/dist/chunk-PA43XYOW.cjs +0 -2
  56. package/dist/chunk-PA43XYOW.cjs.map +0 -1
  57. package/dist/chunk-PG7ZH32Z.js +0 -2
  58. package/dist/chunk-PG7ZH32Z.js.map +0 -1
  59. package/dist/chunk-RGMUXQ2K.cjs +0 -2
  60. package/dist/chunk-RGMUXQ2K.cjs.map +0 -1
  61. /package/dist/{chunk-IDJIIPCS.js.map → chunk-4NQOD2BA.js.map} +0 -0
  62. /package/dist/{chunk-ZWWXPYEL.js.map → chunk-7OZR7KWL.js.map} +0 -0
  63. /package/dist/{chunk-LZTWNUKZ.js.map → chunk-EY44ZBGC.js.map} +0 -0
  64. /package/dist/{chunk-S3DJPXMV.js.map → chunk-JKYECJH5.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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 _chunkPA43XYOWcjs = require('../chunk-PA43XYOW.cjs');require('../chunk-W5CLDRRE.cjs');var _chunkOR5AGYQTcjs = require('../chunk-OR5AGYQT.cjs');var _chunkQZBJ4WRUcjs = require('../chunk-QZBJ4WRU.cjs');var _chunkBSGJ3T5Scjs = require('../chunk-BSGJ3T5S.cjs');var _chunkRHMJPKNVcjs = require('../chunk-RHMJPKNV.cjs');var _chunk3KI3GEU3cjs = require('../chunk-3KI3GEU3.cjs');require('../chunk-C2GGB5NF.cjs');var _chunkRGMUXQ2Kcjs = require('../chunk-RGMUXQ2K.cjs');var _chunkPFPGASVZcjs = require('../chunk-PFPGASVZ.cjs');var _core = require('@angular/core');var B=new (0, _core.InjectionToken)("BIT_STORE");function at(t){return{provide:B,useValue:_chunkOR5AGYQTcjs.d.call(void 0, t)}}function l(){let t=_core.inject.call(void 0, B,{optional:!0});if(!t)throw new Error('BitForm: N\xE3o foi poss\xEDvel encontrar a BitStore. Certifique-se de que voc\xEA adicionou "provideBitStore(store)" nos providers do seu componente.');return t}function lt(){let t=l(),e=_core.inject.call(void 0, _core.DestroyRef),r=_core.signal.call(void 0, {isValid:!0,isDirty:!1,isSubmitting:!1}),o=_core.signal.call(void 0, null),s=_core.signal.call(void 0, null),i=_chunkQZBJ4WRUcjs.c.call(void 0, t,m=>{r.set(m)});e.onDestroy(()=>i());let p=_core.computed.call(void 0, ()=>r().isValid),a=_core.computed.call(void 0, ()=>r().isSubmitting),d=_core.computed.call(void 0, ()=>r().isDirty),{controller:c,actions:n}=_chunkQZBJ4WRUcjs.i.call(void 0, t,{clearSubmissionState:()=>{o.set(null),s.set(null)},setSubmissionResult:m=>{s.set(m)},setSubmissionError:m=>{o.set(m)}},{stopPropagation:!0});return{meta:{isValid:p,isDirty:d,isSubmitting:a,submitError:o.asReadonly(),lastResponse:s.asReadonly()},getValues:c.getValues,getErrors:c.getErrors,getTouched:c.getTouched,getDirtyValues:c.getDirtyValues,submit:c.submit,onSubmit:c.onSubmit,reset:c.reset,...n}}function E(t){let e=_core.inject.call(void 0, B),r=_core.signal.call(void 0, e.read.getFieldState(t)),o=e.observe.subscribeFieldState(t,y=>{r.set(y)});_core.inject.call(void 0, _core.DestroyRef).onDestroy(()=>{o(),_chunkQZBJ4WRUcjs.j.call(void 0, e,t)});let s=_core.computed.call(void 0, ()=>r().value),i=_core.computed.call(void 0, ()=>_chunk3KI3GEU3cjs.a.call(void 0, r())),p=_core.computed.call(void 0, ()=>i().error),a=_core.computed.call(void 0, ()=>i().touched),d=_core.computed.call(void 0, ()=>i().invalid),c=_core.computed.call(void 0, ()=>i().isDirty),n=_core.computed.call(void 0, ()=>i().isValidating),f=_core.computed.call(void 0, ()=>i().isHidden),m=_core.computed.call(void 0, ()=>i().isRequired),{fieldController:j}=_chunkQZBJ4WRUcjs.h.call(void 0, e,t),T=_core.computed.call(void 0, ()=>j.displayValue(s())),v=y=>{j.setValue(y)},h=()=>j.setBlur(),x=_core.computed.call(void 0, ()=>i().hasError);return{value:s,displayValue:T,setValue:v,setBlur:h,update:y=>v(_chunkPFPGASVZcjs.a.call(void 0, y)?_nullishCoalesce(_optionalChain([y, 'access', _2 => _2.target, 'optionalAccess', _3 => _3.value]), () => (null)):y),meta:{error:p,touched:a,invalid:d,isDirty:c,isValidating:n,isHidden:f,isRequired:m,hasError:x}}}function ft(t){let e=_core.inject.call(void 0, B),r=_core.inject.call(void 0, _core.DestroyRef),o=_chunkQZBJ4WRUcjs.g.call(void 0, e,t),s=_core.signal.call(void 0, o.readItems()),i=e.observe.subscribePath(t,()=>{s.set(o.readItems())});return r.onDestroy(()=>{i(),_chunkQZBJ4WRUcjs.k.call(void 0, e,`${t}.`)}),{fields:_core.computed.call(void 0, ()=>o.getFields(s())),length:_core.computed.call(void 0, ()=>s().length),append:o.append,prepend:o.prepend,remove:o.remove,insert:o.insert,swap:o.swap,move:o.move,replace:o.replace,clear:o.clear}}function Rt(){let t=l(),e=_core.inject.call(void 0, _core.DestroyRef),r=_core.signal.call(void 0, _chunkRHMJPKNVcjs.f.call(void 0, t)),o=_chunkRHMJPKNVcjs.g.call(void 0, t,s=>{r.set(s)});return e.onDestroy(()=>o()),{canUndo:_core.computed.call(void 0, ()=>r().canUndo),canRedo:_core.computed.call(void 0, ()=>r().canRedo),historyIndex:_core.computed.call(void 0, ()=>r().historyIndex),historySize:_core.computed.call(void 0, ()=>r().historySize),undo:()=>t.feature.undo(),redo:()=>t.feature.redo()}}function Ft(t){let e=l(),r=e.read.getScopeStatus(t),o=_core.signal.call(void 0, r),s=_chunkBSGJ3T5Scjs.a.call(void 0, e,t,f=>{o.set(f)});_optionalChain([_core.inject.call(void 0, _core.DestroyRef,{optional:!0}), 'optionalAccess', _4 => _4.onDestroy, 'call', _5 => _5(()=>s())]);let p=async()=>{let f=await e.feature.validate({scope:t}),m=e.read.getScopeErrors(t);return{valid:f,errors:m}},a=()=>e.read.getScopeErrors(t),d=_core.computed.call(void 0, ()=>!o().hasErrors),c=_core.computed.call(void 0, ()=>o().isDirty),n=_core.computed.call(void 0, ()=>o().errors);return{scopeName:t,status:o,errors:n,validate:p,getErrors:a,isValid:d,isDirty:c,unsubscribe:s}}function ht(t){let e=l(),r=_core.signal.call(void 0, 0),o=_core.computed.call(void 0, ()=>_nullishCoalesce(t[r()], () => (""))),s=()=>_nullishCoalesce(t[r()], () => ("")),i=_core.signal.call(void 0, e.read.getScopeStatus(s())),p=()=>{let u=s(),g=e.read.getScopeStatus(u),b=i();_chunkRHMJPKNVcjs.b.call(void 0, b,g)||i.set(g)},a=e.observe.subscribeScopeStatus(s(),p),d=()=>{a(),a=e.observe.subscribeScopeStatus(s(),p)};_optionalChain([_core.inject.call(void 0, _core.DestroyRef,{optional:!0}), 'optionalAccess', _6 => _6.onDestroy, 'call', _7 => _7(()=>a())]);let n=async()=>{let u=s(),g=await e.feature.validate({scope:u}),b=e.read.getScopeErrors(u);return{valid:g,errors:b}},f=()=>e.read.getScopeErrors(s()),m=async()=>{let u=s(),g=e.read.getScopeFields(u);if(e.feature.hasValidationsInProgress(g))return!1;let b=await e.feature.validate({scope:u});if(b){let F=Math.min(r()+1,t.length-1);r.set(F),i.set(e.read.getScopeStatus(_nullishCoalesce(t[F], () => ("")))),d()}else{let F=e.read.getScopeErrors(u),U=Object.keys(F);U.length>0&&e.write.markFieldsTouched(U)}return b},j=()=>{let u=Math.max(r()-1,0);r.set(u),i.set(e.read.getScopeStatus(_nullishCoalesce(t[u], () => ("")))),d()},T=u=>{let g=Math.max(0,Math.min(u-1,t.length-1));r.set(g),i.set(e.read.getScopeStatus(_nullishCoalesce(t[g], () => ("")))),d()},v=_core.computed.call(void 0, ()=>r()+1),h=_core.computed.call(void 0, ()=>r()===0),x=_core.computed.call(void 0, ()=>r()>=t.length-1),A=_core.computed.call(void 0, ()=>!i().hasErrors),y=_core.computed.call(void 0, ()=>i().isDirty),st=_core.computed.call(void 0, ()=>i().errors);return{step:v,stepIndex:r,scope:o,next:m,prev:j,goTo:T,isFirst:h,isLast:x,status:i,errors:st,isValid:A,isDirty:y,validate:n,getErrors:f}}function Et(t){let e=l(),r=_core.inject.call(void 0, _core.DestroyRef),o=_core.signal.call(void 0, _chunkRGMUXQ2Kcjs.f.call(void 0, e.read.getState().values,t),{equal:_chunkRGMUXQ2Kcjs.c}),s=e.observe.subscribePath(t,i=>{o.set(i)});return r.onDestroy(s),o.asReadonly()}function kt(t,e,r){let o=_core.inject.call(void 0, B),s=E(t),i=null,p=_core.signal.call(void 0, !1),a={setLoading:n=>p.set(n),setError:(n,f)=>o.write.setError(n,f),setValue:n=>s.setValue(n),getUploadKey:()=>i,setUploadKey:n=>{i=n}},d=_chunkPA43XYOWcjs.a.call(void 0, t,e,a),c=_chunkPA43XYOWcjs.b.call(void 0, t,r,a);return{value:_core.computed.call(void 0, ()=>s.value()),setValue:s.setValue,error:_core.computed.call(void 0, ()=>s.meta.error()),isValidating:_core.computed.call(void 0, ()=>!!s.meta.isValidating()||p()),upload:d,remove:c}}function Ht(){let t=l(),e=_core.signal.call(void 0, t.read.getPersistMetadata()),r=_chunkQZBJ4WRUcjs.f.call(void 0, t,a=>{e.set(a)});return _optionalChain([_core.inject.call(void 0, _core.DestroyRef,{optional:!0}), 'optionalAccess', _8 => _8.onDestroy, 'call', _9 => _9(()=>r())]),{restore:async()=>t.feature.restorePersisted(),save:async()=>{await t.feature.forceSave()},clear:async()=>{await t.feature.clearPersisted()},meta:{isSaving:_core.computed.call(void 0, ()=>e().isSaving),isRestoring:_core.computed.call(void 0, ()=>e().isRestoring),error:_core.computed.call(void 0, ()=>e().error)}}}exports.injectBitArray = ft; exports.injectBitField = E; exports.injectBitForm = lt; exports.injectBitHistory = Rt; exports.injectBitPersist = Ht; exports.injectBitScope = Ft; exports.injectBitSteps = ht; exports.injectBitUpload = kt; exports.injectBitWatch = Et; exports.provideBitStore = at; exports.useBitStore = l;
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 _chunkMJ4AOJRTcjs = require('../chunk-MJ4AOJRT.cjs');require('../chunk-W5CLDRRE.cjs');var _chunkMAKFWOL5cjs = require('../chunk-MAKFWOL5.cjs');var _chunkALIYU2RTcjs = require('../chunk-ALIYU2RT.cjs');var _chunkBSGJ3T5Scjs = require('../chunk-BSGJ3T5S.cjs');var _chunkRHMJPKNVcjs = require('../chunk-RHMJPKNV.cjs');var _chunk3KI3GEU3cjs = require('../chunk-3KI3GEU3.cjs');require('../chunk-OSQWKXFI.cjs');var _chunkVOA3SKFYcjs = require('../chunk-VOA3SKFY.cjs');var _chunkPFPGASVZcjs = require('../chunk-PFPGASVZ.cjs');var _core = require('@angular/core');var B=new (0, _core.InjectionToken)("BIT_STORE");function at(t){return{provide:B,useValue:_chunkMAKFWOL5cjs.d.call(void 0, t)}}function l(){let t=_core.inject.call(void 0, B,{optional:!0});if(!t)throw new Error('BitForm: N\xE3o foi poss\xEDvel encontrar a BitStore. Certifique-se de que voc\xEA adicionou "provideBitStore(store)" nos providers do seu componente.');return t}function lt(){let t=l(),e=_core.inject.call(void 0, _core.DestroyRef),r=_core.signal.call(void 0, {isValid:!0,isDirty:!1,isSubmitting:!1}),o=_core.signal.call(void 0, null),s=_core.signal.call(void 0, null),i=_chunkALIYU2RTcjs.c.call(void 0, t,m=>{r.set(m)});e.onDestroy(()=>i());let p=_core.computed.call(void 0, ()=>r().isValid),a=_core.computed.call(void 0, ()=>r().isSubmitting),d=_core.computed.call(void 0, ()=>r().isDirty),{controller:c,actions:n}=_chunkALIYU2RTcjs.i.call(void 0, t,{clearSubmissionState:()=>{o.set(null),s.set(null)},setSubmissionResult:m=>{s.set(m)},setSubmissionError:m=>{o.set(m)}},{stopPropagation:!0});return{meta:{isValid:p,isDirty:d,isSubmitting:a,submitError:o.asReadonly(),lastResponse:s.asReadonly()},getValues:c.getValues,getErrors:c.getErrors,getTouched:c.getTouched,getDirtyValues:c.getDirtyValues,submit:c.submit,onSubmit:c.onSubmit,reset:c.reset,...n}}function E(t){let e=_core.inject.call(void 0, B),r=_core.signal.call(void 0, e.read.getFieldState(t)),o=e.observe.subscribeFieldState(t,y=>{r.set(y)});_core.inject.call(void 0, _core.DestroyRef).onDestroy(()=>{o(),_chunkALIYU2RTcjs.j.call(void 0, e,t)});let s=_core.computed.call(void 0, ()=>r().value),i=_core.computed.call(void 0, ()=>_chunk3KI3GEU3cjs.a.call(void 0, r())),p=_core.computed.call(void 0, ()=>i().error),a=_core.computed.call(void 0, ()=>i().touched),d=_core.computed.call(void 0, ()=>i().invalid),c=_core.computed.call(void 0, ()=>i().isDirty),n=_core.computed.call(void 0, ()=>i().isValidating),f=_core.computed.call(void 0, ()=>i().isHidden),m=_core.computed.call(void 0, ()=>i().isRequired),{fieldController:j}=_chunkALIYU2RTcjs.h.call(void 0, e,t),T=_core.computed.call(void 0, ()=>j.displayValue(s())),v=y=>{j.setValue(y)},h=()=>j.setBlur(),x=_core.computed.call(void 0, ()=>i().hasError);return{value:s,displayValue:T,setValue:v,setBlur:h,update:y=>v(_chunkPFPGASVZcjs.a.call(void 0, y)?_nullishCoalesce(_optionalChain([y, 'access', _2 => _2.target, 'optionalAccess', _3 => _3.value]), () => (null)):y),meta:{error:p,touched:a,invalid:d,isDirty:c,isValidating:n,isHidden:f,isRequired:m,hasError:x}}}function ft(t){let e=_core.inject.call(void 0, B),r=_core.inject.call(void 0, _core.DestroyRef),o=_chunkALIYU2RTcjs.g.call(void 0, e,t),s=_core.signal.call(void 0, o.readItems()),i=e.observe.subscribePath(t,()=>{s.set(o.readItems())});return r.onDestroy(()=>{i(),_chunkALIYU2RTcjs.k.call(void 0, e,`${t}.`)}),{fields:_core.computed.call(void 0, ()=>o.getFields(s())),length:_core.computed.call(void 0, ()=>s().length),append:o.append,prepend:o.prepend,remove:o.remove,insert:o.insert,swap:o.swap,move:o.move,replace:o.replace,clear:o.clear}}function Rt(){let t=l(),e=_core.inject.call(void 0, _core.DestroyRef),r=_core.signal.call(void 0, _chunkRHMJPKNVcjs.f.call(void 0, t)),o=_chunkRHMJPKNVcjs.g.call(void 0, t,s=>{r.set(s)});return e.onDestroy(()=>o()),{canUndo:_core.computed.call(void 0, ()=>r().canUndo),canRedo:_core.computed.call(void 0, ()=>r().canRedo),historyIndex:_core.computed.call(void 0, ()=>r().historyIndex),historySize:_core.computed.call(void 0, ()=>r().historySize),undo:()=>t.feature.undo(),redo:()=>t.feature.redo()}}function Ft(t){let e=l(),r=e.read.getScopeStatus(t),o=_core.signal.call(void 0, r),s=_chunkBSGJ3T5Scjs.a.call(void 0, e,t,f=>{o.set(f)});_optionalChain([_core.inject.call(void 0, _core.DestroyRef,{optional:!0}), 'optionalAccess', _4 => _4.onDestroy, 'call', _5 => _5(()=>s())]);let p=async()=>{let f=await e.feature.validate({scope:t}),m=e.read.getScopeErrors(t);return{valid:f,errors:m}},a=()=>e.read.getScopeErrors(t),d=_core.computed.call(void 0, ()=>!o().hasErrors),c=_core.computed.call(void 0, ()=>o().isDirty),n=_core.computed.call(void 0, ()=>o().errors);return{scopeName:t,status:o,errors:n,validate:p,getErrors:a,isValid:d,isDirty:c,unsubscribe:s}}function ht(t){let e=l(),r=_core.signal.call(void 0, 0),o=_core.computed.call(void 0, ()=>_nullishCoalesce(t[r()], () => (""))),s=()=>_nullishCoalesce(t[r()], () => ("")),i=_core.signal.call(void 0, e.read.getScopeStatus(s())),p=()=>{let u=s(),g=e.read.getScopeStatus(u),b=i();_chunkRHMJPKNVcjs.b.call(void 0, b,g)||i.set(g)},a=e.observe.subscribeScopeStatus(s(),p),d=()=>{a(),a=e.observe.subscribeScopeStatus(s(),p)};_optionalChain([_core.inject.call(void 0, _core.DestroyRef,{optional:!0}), 'optionalAccess', _6 => _6.onDestroy, 'call', _7 => _7(()=>a())]);let n=async()=>{let u=s(),g=await e.feature.validate({scope:u}),b=e.read.getScopeErrors(u);return{valid:g,errors:b}},f=()=>e.read.getScopeErrors(s()),m=async()=>{let u=s(),g=e.read.getScopeFields(u);if(e.feature.hasValidationsInProgress(g))return!1;let b=await e.feature.validate({scope:u});if(b){let F=Math.min(r()+1,t.length-1);r.set(F),i.set(e.read.getScopeStatus(_nullishCoalesce(t[F], () => ("")))),d()}else{let F=e.read.getScopeErrors(u),U=Object.keys(F);U.length>0&&e.write.markFieldsTouched(U)}return b},j=()=>{let u=Math.max(r()-1,0);r.set(u),i.set(e.read.getScopeStatus(_nullishCoalesce(t[u], () => ("")))),d()},T=u=>{let g=Math.max(0,Math.min(u-1,t.length-1));r.set(g),i.set(e.read.getScopeStatus(_nullishCoalesce(t[g], () => ("")))),d()},v=_core.computed.call(void 0, ()=>r()+1),h=_core.computed.call(void 0, ()=>r()===0),x=_core.computed.call(void 0, ()=>r()>=t.length-1),A=_core.computed.call(void 0, ()=>!i().hasErrors),y=_core.computed.call(void 0, ()=>i().isDirty),st=_core.computed.call(void 0, ()=>i().errors);return{step:v,stepIndex:r,scope:o,next:m,prev:j,goTo:T,isFirst:h,isLast:x,status:i,errors:st,isValid:A,isDirty:y,validate:n,getErrors:f}}function Et(t){let e=l(),r=_core.inject.call(void 0, _core.DestroyRef),o=_core.signal.call(void 0, _chunkVOA3SKFYcjs.f.call(void 0, e.read.getState().values,t),{equal:_chunkVOA3SKFYcjs.c}),s=e.observe.subscribePath(t,i=>{o.set(i)});return r.onDestroy(s),o.asReadonly()}function kt(t,e,r){let o=_core.inject.call(void 0, B),s=E(t),i=null,p=_core.signal.call(void 0, !1),a={setLoading:n=>p.set(n),setError:(n,f)=>o.write.setError(n,f),setValue:n=>s.setValue(n),getUploadKey:()=>i,setUploadKey:n=>{i=n}},d=_chunkMJ4AOJRTcjs.a.call(void 0, t,e,a),c=_chunkMJ4AOJRTcjs.b.call(void 0, t,r,a);return{value:_core.computed.call(void 0, ()=>s.value()),setValue:s.setValue,error:_core.computed.call(void 0, ()=>s.meta.error()),isValidating:_core.computed.call(void 0, ()=>!!s.meta.isValidating()||p()),upload:d,remove:c}}function Ht(){let t=l(),e=_core.signal.call(void 0, t.read.getPersistMetadata()),r=_chunkALIYU2RTcjs.f.call(void 0, t,a=>{e.set(a)});return _optionalChain([_core.inject.call(void 0, _core.DestroyRef,{optional:!0}), 'optionalAccess', _8 => _8.onDestroy, 'call', _9 => _9(()=>r())]),{restore:async()=>t.feature.restorePersisted(),save:async()=>{await t.feature.forceSave()},clear:async()=>{await t.feature.clearPersisted()},meta:{isSaving:_core.computed.call(void 0, ()=>e().isSaving),isRestoring:_core.computed.call(void 0, ()=>e().isRestoring),error:_core.computed.call(void 0, ()=>e().error)}}}exports.injectBitArray = ft; exports.injectBitField = E; exports.injectBitForm = lt; exports.injectBitHistory = Rt; exports.injectBitPersist = Ht; exports.injectBitScope = Ft; exports.injectBitSteps = ht; exports.injectBitUpload = kt; exports.injectBitWatch = Et; exports.provideBitStore = at; exports.useBitStore = l;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,2 +1,2 @@
1
- import{a as Z,b as N}from"../chunk-PG7ZH32Z.js";import"../chunk-5NA2TFPG.js";import{d as K}from"../chunk-CGJRZJ62.js";import{c as C,f as W,g as z,h as $,i as G,j as J,k as Q}from"../chunk-LZTWNUKZ.js";import{a as X}from"../chunk-W2E5UIXT.js";import{b as O,f as _,g as q}from"../chunk-UIKO6GGW.js";import{a as Y}from"../chunk-ICYXODTQ.js";import"../chunk-S3DJPXMV.js";import{c as M,f as H}from"../chunk-6NH6MUXA.js";import{a as L}from"../chunk-3NUJVIAM.js";import{inject as it,InjectionToken as nt}from"@angular/core";var B=new nt("BIT_STORE");function at(t){return{provide:B,useValue:K(t)}}function l(){let t=it(B,{optional:!0});if(!t)throw new Error('BitForm: N\xE3o foi poss\xEDvel encontrar a BitStore. Certifique-se de que voc\xEA adicionou "provideBitStore(store)" nos providers do seu componente.');return t}import{signal as V,computed as I,inject as ct,DestroyRef as ut}from"@angular/core";function lt(){let t=l(),e=ct(ut),r=V({isValid:!0,isDirty:!1,isSubmitting:!1}),o=V(null),s=V(null),i=C(t,m=>{r.set(m)});e.onDestroy(()=>i());let p=I(()=>r().isValid),a=I(()=>r().isSubmitting),d=I(()=>r().isDirty),{controller:c,actions:n}=G(t,{clearSubmissionState:()=>{o.set(null),s.set(null)},setSubmissionResult:m=>{s.set(m)},setSubmissionError:m=>{o.set(m)}},{stopPropagation:!0});return{meta:{isValid:p,isDirty:d,isSubmitting:a,submitError:o.asReadonly(),lastResponse:s.asReadonly()},getValues:c.getValues,getErrors:c.getErrors,getTouched:c.getTouched,getDirtyValues:c.getDirtyValues,submit:c.submit,onSubmit:c.onSubmit,reset:c.reset,...n}}import{DestroyRef as pt,computed as S,inject as tt,signal as dt}from"@angular/core";function E(t){let e=tt(B),r=dt(e.read.getFieldState(t)),o=e.observe.subscribeFieldState(t,y=>{r.set(y)});tt(pt).onDestroy(()=>{o(),J(e,t)});let s=S(()=>r().value),i=S(()=>Y(r())),p=S(()=>i().error),a=S(()=>i().touched),d=S(()=>i().invalid),c=S(()=>i().isDirty),n=S(()=>i().isValidating),f=S(()=>i().isHidden),m=S(()=>i().isRequired),{fieldController:j}=$(e,t),T=S(()=>j.displayValue(s())),v=y=>{j.setValue(y)},h=()=>j.setBlur(),x=S(()=>i().hasError);return{value:s,displayValue:T,setValue:v,setBlur:h,update:y=>v(L(y)?y.target?.value??null:y),meta:{error:p,touched:a,invalid:d,isDirty:c,isValidating:n,isHidden:f,isRequired:m,hasError:x}}}import{computed as et,DestroyRef as mt,inject as rt,signal as St}from"@angular/core";function ft(t){let e=rt(B),r=rt(mt),o=z(e,t),s=St(o.readItems()),i=e.observe.subscribePath(t,()=>{s.set(o.readItems())});return r.onDestroy(()=>{i(),Q(e,`${t}.`)}),{fields:et(()=>o.getFields(s())),length:et(()=>s().length),append:o.append,prepend:o.prepend,remove:o.remove,insert:o.insert,swap:o.swap,move:o.move,replace:o.replace,clear:o.clear}}import{computed as P,DestroyRef as yt,inject as gt,signal as Bt}from"@angular/core";function Rt(){let t=l(),e=gt(yt),r=Bt(_(t)),o=q(t,s=>{r.set(s)});return e.onDestroy(()=>o()),{canUndo:P(()=>r().canUndo),canRedo:P(()=>r().canRedo),historyIndex:P(()=>r().historyIndex),historySize:P(()=>r().historySize),undo:()=>t.feature.undo(),redo:()=>t.feature.redo()}}import{computed as D,DestroyRef as bt,inject as jt,signal as vt}from"@angular/core";function Ft(t){let e=l(),r=e.read.getScopeStatus(t),o=vt(r),s=X(e,t,f=>{o.set(f)});jt(bt,{optional:!0})?.onDestroy(()=>s());let p=async()=>{let f=await e.feature.validate({scope:t}),m=e.read.getScopeErrors(t);return{valid:f,errors:m}},a=()=>e.read.getScopeErrors(t),d=D(()=>!o().hasErrors),c=D(()=>o().isDirty),n=D(()=>o().errors);return{scopeName:t,status:o,errors:n,validate:p,getErrors:a,isValid:d,isDirty:c,unsubscribe:s}}import{computed as R,DestroyRef as Pt,inject as Tt,signal as ot}from"@angular/core";function ht(t){let e=l(),r=ot(0),o=R(()=>t[r()]??""),s=()=>t[r()]??"",i=ot(e.read.getScopeStatus(s())),p=()=>{let u=s(),g=e.read.getScopeStatus(u),b=i();O(b,g)||i.set(g)},a=e.observe.subscribeScopeStatus(s(),p),d=()=>{a(),a=e.observe.subscribeScopeStatus(s(),p)};Tt(Pt,{optional:!0})?.onDestroy(()=>a());let n=async()=>{let u=s(),g=await e.feature.validate({scope:u}),b=e.read.getScopeErrors(u);return{valid:g,errors:b}},f=()=>e.read.getScopeErrors(s()),m=async()=>{let u=s(),g=e.read.getScopeFields(u);if(e.feature.hasValidationsInProgress(g))return!1;let b=await e.feature.validate({scope:u});if(b){let F=Math.min(r()+1,t.length-1);r.set(F),i.set(e.read.getScopeStatus(t[F]??"")),d()}else{let F=e.read.getScopeErrors(u),U=Object.keys(F);U.length>0&&e.write.markFieldsTouched(U)}return b},j=()=>{let u=Math.max(r()-1,0);r.set(u),i.set(e.read.getScopeStatus(t[u]??"")),d()},T=u=>{let g=Math.max(0,Math.min(u-1,t.length-1));r.set(g),i.set(e.read.getScopeStatus(t[g]??"")),d()},v=R(()=>r()+1),h=R(()=>r()===0),x=R(()=>r()>=t.length-1),A=R(()=>!i().hasErrors),y=R(()=>i().isDirty),st=R(()=>i().errors);return{step:v,stepIndex:r,scope:o,next:m,prev:j,goTo:T,isFirst:h,isLast:x,status:i,errors:st,isValid:A,isDirty:y,validate:n,getErrors:f}}import{DestroyRef as xt,signal as Vt,inject as It}from"@angular/core";function Et(t){let e=l(),r=It(xt),o=Vt(H(e.read.getState().values,t),{equal:M}),s=e.observe.subscribePath(t,i=>{o.set(i)});return r.onDestroy(s),o.asReadonly()}import{computed as w,inject as Dt,signal as wt}from"@angular/core";function kt(t,e,r){let o=Dt(B),s=E(t),i=null,p=wt(!1),a={setLoading:n=>p.set(n),setError:(n,f)=>o.write.setError(n,f),setValue:n=>s.setValue(n),getUploadKey:()=>i,setUploadKey:n=>{i=n}},d=Z(t,e,a),c=N(t,r,a);return{value:w(()=>s.value()),setValue:s.setValue,error:w(()=>s.meta.error()),isValidating:w(()=>!!s.meta.isValidating()||p()),upload:d,remove:c}}import{computed as k,DestroyRef as At,inject as Ut,signal as Mt}from"@angular/core";function Ht(){let t=l(),e=Mt(t.read.getPersistMetadata()),r=W(t,a=>{e.set(a)});return Ut(At,{optional:!0})?.onDestroy(()=>r()),{restore:async()=>t.feature.restorePersisted(),save:async()=>{await t.feature.forceSave()},clear:async()=>{await t.feature.clearPersisted()},meta:{isSaving:k(()=>e().isSaving),isRestoring:k(()=>e().isRestoring),error:k(()=>e().error)}}}export{ft as injectBitArray,E as injectBitField,lt as injectBitForm,Rt as injectBitHistory,Ht as injectBitPersist,Ft as injectBitScope,ht as injectBitSteps,kt as injectBitUpload,Et as injectBitWatch,at as provideBitStore,l as useBitStore};
1
+ import{a as Z,b as N}from"../chunk-W2FPKUNM.js";import"../chunk-5NA2TFPG.js";import{d as K}from"../chunk-G4HK5QTU.js";import{c as C,f as W,g as z,h as $,i as G,j as J,k as Q}from"../chunk-EY44ZBGC.js";import{a as X}from"../chunk-W2E5UIXT.js";import{b as O,f as _,g as q}from"../chunk-UIKO6GGW.js";import{a as Y}from"../chunk-ICYXODTQ.js";import"../chunk-JKYECJH5.js";import{c as M,f as H}from"../chunk-IMMFFTXE.js";import{a as L}from"../chunk-3NUJVIAM.js";import{inject as it,InjectionToken as nt}from"@angular/core";var B=new nt("BIT_STORE");function at(t){return{provide:B,useValue:K(t)}}function l(){let t=it(B,{optional:!0});if(!t)throw new Error('BitForm: N\xE3o foi poss\xEDvel encontrar a BitStore. Certifique-se de que voc\xEA adicionou "provideBitStore(store)" nos providers do seu componente.');return t}import{signal as V,computed as I,inject as ct,DestroyRef as ut}from"@angular/core";function lt(){let t=l(),e=ct(ut),r=V({isValid:!0,isDirty:!1,isSubmitting:!1}),o=V(null),s=V(null),i=C(t,m=>{r.set(m)});e.onDestroy(()=>i());let p=I(()=>r().isValid),a=I(()=>r().isSubmitting),d=I(()=>r().isDirty),{controller:c,actions:n}=G(t,{clearSubmissionState:()=>{o.set(null),s.set(null)},setSubmissionResult:m=>{s.set(m)},setSubmissionError:m=>{o.set(m)}},{stopPropagation:!0});return{meta:{isValid:p,isDirty:d,isSubmitting:a,submitError:o.asReadonly(),lastResponse:s.asReadonly()},getValues:c.getValues,getErrors:c.getErrors,getTouched:c.getTouched,getDirtyValues:c.getDirtyValues,submit:c.submit,onSubmit:c.onSubmit,reset:c.reset,...n}}import{DestroyRef as pt,computed as S,inject as tt,signal as dt}from"@angular/core";function E(t){let e=tt(B),r=dt(e.read.getFieldState(t)),o=e.observe.subscribeFieldState(t,y=>{r.set(y)});tt(pt).onDestroy(()=>{o(),J(e,t)});let s=S(()=>r().value),i=S(()=>Y(r())),p=S(()=>i().error),a=S(()=>i().touched),d=S(()=>i().invalid),c=S(()=>i().isDirty),n=S(()=>i().isValidating),f=S(()=>i().isHidden),m=S(()=>i().isRequired),{fieldController:j}=$(e,t),T=S(()=>j.displayValue(s())),v=y=>{j.setValue(y)},h=()=>j.setBlur(),x=S(()=>i().hasError);return{value:s,displayValue:T,setValue:v,setBlur:h,update:y=>v(L(y)?y.target?.value??null:y),meta:{error:p,touched:a,invalid:d,isDirty:c,isValidating:n,isHidden:f,isRequired:m,hasError:x}}}import{computed as et,DestroyRef as mt,inject as rt,signal as St}from"@angular/core";function ft(t){let e=rt(B),r=rt(mt),o=z(e,t),s=St(o.readItems()),i=e.observe.subscribePath(t,()=>{s.set(o.readItems())});return r.onDestroy(()=>{i(),Q(e,`${t}.`)}),{fields:et(()=>o.getFields(s())),length:et(()=>s().length),append:o.append,prepend:o.prepend,remove:o.remove,insert:o.insert,swap:o.swap,move:o.move,replace:o.replace,clear:o.clear}}import{computed as P,DestroyRef as yt,inject as gt,signal as Bt}from"@angular/core";function Rt(){let t=l(),e=gt(yt),r=Bt(_(t)),o=q(t,s=>{r.set(s)});return e.onDestroy(()=>o()),{canUndo:P(()=>r().canUndo),canRedo:P(()=>r().canRedo),historyIndex:P(()=>r().historyIndex),historySize:P(()=>r().historySize),undo:()=>t.feature.undo(),redo:()=>t.feature.redo()}}import{computed as D,DestroyRef as bt,inject as jt,signal as vt}from"@angular/core";function Ft(t){let e=l(),r=e.read.getScopeStatus(t),o=vt(r),s=X(e,t,f=>{o.set(f)});jt(bt,{optional:!0})?.onDestroy(()=>s());let p=async()=>{let f=await e.feature.validate({scope:t}),m=e.read.getScopeErrors(t);return{valid:f,errors:m}},a=()=>e.read.getScopeErrors(t),d=D(()=>!o().hasErrors),c=D(()=>o().isDirty),n=D(()=>o().errors);return{scopeName:t,status:o,errors:n,validate:p,getErrors:a,isValid:d,isDirty:c,unsubscribe:s}}import{computed as R,DestroyRef as Pt,inject as Tt,signal as ot}from"@angular/core";function ht(t){let e=l(),r=ot(0),o=R(()=>t[r()]??""),s=()=>t[r()]??"",i=ot(e.read.getScopeStatus(s())),p=()=>{let u=s(),g=e.read.getScopeStatus(u),b=i();O(b,g)||i.set(g)},a=e.observe.subscribeScopeStatus(s(),p),d=()=>{a(),a=e.observe.subscribeScopeStatus(s(),p)};Tt(Pt,{optional:!0})?.onDestroy(()=>a());let n=async()=>{let u=s(),g=await e.feature.validate({scope:u}),b=e.read.getScopeErrors(u);return{valid:g,errors:b}},f=()=>e.read.getScopeErrors(s()),m=async()=>{let u=s(),g=e.read.getScopeFields(u);if(e.feature.hasValidationsInProgress(g))return!1;let b=await e.feature.validate({scope:u});if(b){let F=Math.min(r()+1,t.length-1);r.set(F),i.set(e.read.getScopeStatus(t[F]??"")),d()}else{let F=e.read.getScopeErrors(u),U=Object.keys(F);U.length>0&&e.write.markFieldsTouched(U)}return b},j=()=>{let u=Math.max(r()-1,0);r.set(u),i.set(e.read.getScopeStatus(t[u]??"")),d()},T=u=>{let g=Math.max(0,Math.min(u-1,t.length-1));r.set(g),i.set(e.read.getScopeStatus(t[g]??"")),d()},v=R(()=>r()+1),h=R(()=>r()===0),x=R(()=>r()>=t.length-1),A=R(()=>!i().hasErrors),y=R(()=>i().isDirty),st=R(()=>i().errors);return{step:v,stepIndex:r,scope:o,next:m,prev:j,goTo:T,isFirst:h,isLast:x,status:i,errors:st,isValid:A,isDirty:y,validate:n,getErrors:f}}import{DestroyRef as xt,signal as Vt,inject as It}from"@angular/core";function Et(t){let e=l(),r=It(xt),o=Vt(H(e.read.getState().values,t),{equal:M}),s=e.observe.subscribePath(t,i=>{o.set(i)});return r.onDestroy(s),o.asReadonly()}import{computed as w,inject as Dt,signal as wt}from"@angular/core";function kt(t,e,r){let o=Dt(B),s=E(t),i=null,p=wt(!1),a={setLoading:n=>p.set(n),setError:(n,f)=>o.write.setError(n,f),setValue:n=>s.setValue(n),getUploadKey:()=>i,setUploadKey:n=>{i=n}},d=Z(t,e,a),c=N(t,r,a);return{value:w(()=>s.value()),setValue:s.setValue,error:w(()=>s.meta.error()),isValidating:w(()=>!!s.meta.isValidating()||p()),upload:d,remove:c}}import{computed as k,DestroyRef as At,inject as Ut,signal as Mt}from"@angular/core";function Ht(){let t=l(),e=Mt(t.read.getPersistMetadata()),r=W(t,a=>{e.set(a)});return Ut(At,{optional:!0})?.onDestroy(()=>r()),{restore:async()=>t.feature.restorePersisted(),save:async()=>{await t.feature.forceSave()},clear:async()=>{await t.feature.clearPersisted()},meta:{isSaving:k(()=>e().isSaving),isRestoring:k(()=>e().isRestoring),error:k(()=>e().error)}}}export{ft as injectBitArray,E as injectBitField,lt as injectBitForm,Rt as injectBitHistory,Ht as injectBitPersist,Ft as injectBitScope,ht as injectBitSteps,kt as injectBitUpload,Et as injectBitWatch,at as provideBitStore,l as useBitStore};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{d as M}from"./chunk-CGJRZJ62.js";import{a as A,b as C,d as R,e as D,g as U,i as j,j as I,k as q}from"./chunk-LZTWNUKZ.js";import{b as F}from"./chunk-UIKO6GGW.js";import{a as k}from"./chunk-S3DJPXMV.js";import{c as y,f as w}from"./chunk-6NH6MUXA.js";import{createContext as G,useContext as H}from"react";import{jsx as J}from"react/jsx-runtime";var L=G(null),ft=({store:t,children:e})=>J(L.Provider,{value:M(t),children:e}),l=()=>{let t=H(L);if(!t)throw new Error("BitForm hooks devem ser usados dentro de um BitFormProvider");return t};import{useCallback as p,useSyncExternalStore as K,useMemo as W,useRef as Q,useState as O}from"react";function Pt(){let t=l(),[e,r]=O(null),[i,s]=O(null),o=Q(null),c=p(S=>C(t,S),[t]),m=p(()=>{let S=A(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=K(c,m,m),d=W(()=>j(t,{clearSubmissionState:()=>{r(null),s(null)},setSubmissionResult:S=>{s(S)},setSubmissionError:S=>{r(S)}}),[t]),{controller:a,actions:x}=d,v=p(a.submit,[a]),T=p(a.onSubmit,[a]),E=p(a.reset,[a]),u=p(a.getValues,[a]),b=p(a.getErrors,[a]),B=p(a.getTouched,[a]),g=p(a.getDirtyValues,[a]);return{meta:W(()=>({...n,submitError:e,lastResponse:i}),[n,e,i]),getValues:u,getErrors:b,getTouched:B,getDirtyValues:g,submit:v,onSubmit:T,reset:E,...x}}import{useCallback as _,useEffect as X,useMemo as $,useRef as Y,useSyncExternalStore as Z}from"react";function Rt(t){let e=l(),r=$(()=>U(e,t),[e,t]),i=Y(null),s=_(()=>{let n=r.readItems();return i.current&&y(i.current,n)?i.current:(i.current=n,n)},[r]),o=_(n=>e.observe.subscribePath(t,()=>n()),[e,t]),c=Z(o,s,s),m=$(()=>r.getFields(c),[r,c]);return X(()=>()=>{q(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}}import{useCallback as P,useRef as N,useSyncExternalStore as tt}from"react";function At(t){let e=l(),r=N(null),i=P(()=>{let n=e.read.getScopeStatus(t);return r.current&&F(r.current,n)?r.current:(r.current=n,n)},[e,t]),s=P(n=>e.observe.subscribeScopeStatus(t,()=>n()),[e,t]),o=tt(s,i,i),c=P(async()=>{let n=await e.feature.validate({scope:t}),d=e.read.getScopeErrors(t);return{valid:n,errors:d}},[e,t]),m=P(()=>e.read.getScopeErrors(t),[e,t]);return{scopeName:t,status:o,errors:o.errors,validate:c,getErrors:m,isValid:!o.hasErrors,isDirty:o.isDirty}}import{useCallback as f,useRef as et,useState as rt,useSyncExternalStore as st}from"react";function It(t){let e=l(),[r,i]=rt(0),s=t[r]??"",o=et(null),c=f(()=>{let u=e.read.getScopeStatus(s);return o.current&&F(o.current,u)?o.current:(o.current=u,u)},[e,s]),m=st(f(u=>e.observe.subscribeScopeStatus(s,()=>u()),[e,s]),c,c),n=f(async()=>{let u=await e.feature.validate({scope:s}),b=e.read.getScopeErrors(s);return{valid:u,errors:b}},[e,s]),d=f(()=>e.read.getScopeErrors(s),[e,s]),a=f(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=f(()=>{i(u=>Math.max(u-1,0))},[]),v=f(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}}import{useCallback as z,useSyncExternalStore as ot,useRef as nt}from"react";function zt(t){let e=l(),r=nt(null),i=z(()=>{let o=w(e.read.getState().values,t);return r.current!==null&&y(r.current,o)?r.current:(r.current=o,o)},[e,t]),s=z(o=>e.observe.subscribePath(t,()=>o()),[e,t]);return ot(s,i,i)}import{useCallback as V,useMemo as it,useSyncExternalStore as at}from"react";function Qt(){let t=l(),e=at(c=>D(t,c),()=>R(t),()=>R(t)),r=V(async()=>t.feature.restorePersisted(),[t]),i=V(async()=>{await t.feature.forceSave()},[t]),s=V(async()=>{await t.feature.clearPersisted()},[t]),o=it(()=>({isSaving:e.isSaving,isRestoring:e.isRestoring,error:e.error}),[e]);return{restore:r,save:i,clear:s,meta:o}}import{useCallback as h,useEffect as ut,useRef as ct,useSyncExternalStore as lt}from"react";function se(t){let e=l(),r=ct(null);ut(()=>()=>I(e,t),[e,t]);let i=h(()=>{let n=e.read.getFieldState(t),d=k(n,r.current);return r.current=d,d},[e,t]),s=h(n=>e.observe.subscribeFieldState(t,()=>n()),[e,t]),o=lt(s,i,i),c=h(n=>e.write.setField(t,n),[e,t]),m=h(()=>e.write.blurField(t),[e,t]);return{fieldState:o,setValue:c,setBlur:m,store:e}}export{ft as a,l as b,Pt as c,se as d,Rt as e,At as f,It as g,zt as h,Qt as i};
2
- //# sourceMappingURL=chunk-IDJIIPCS.js.map
1
+ import{d as M}from"./chunk-G4HK5QTU.js";import{a as A,b as C,d as R,e as D,g as U,i as j,j as I,k as q}from"./chunk-EY44ZBGC.js";import{b as F}from"./chunk-UIKO6GGW.js";import{a as k}from"./chunk-JKYECJH5.js";import{c as y,f as w}from"./chunk-IMMFFTXE.js";import{createContext as G,useContext as H}from"react";import{jsx as J}from"react/jsx-runtime";var L=G(null),ft=({store:t,children:e})=>J(L.Provider,{value:M(t),children:e}),l=()=>{let t=H(L);if(!t)throw new Error("BitForm hooks devem ser usados dentro de um BitFormProvider");return t};import{useCallback as p,useSyncExternalStore as K,useMemo as W,useRef as Q,useState as O}from"react";function Pt(){let t=l(),[e,r]=O(null),[i,s]=O(null),o=Q(null),c=p(S=>C(t,S),[t]),m=p(()=>{let S=A(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=K(c,m,m),d=W(()=>j(t,{clearSubmissionState:()=>{r(null),s(null)},setSubmissionResult:S=>{s(S)},setSubmissionError:S=>{r(S)}}),[t]),{controller:a,actions:x}=d,v=p(a.submit,[a]),T=p(a.onSubmit,[a]),E=p(a.reset,[a]),u=p(a.getValues,[a]),b=p(a.getErrors,[a]),B=p(a.getTouched,[a]),g=p(a.getDirtyValues,[a]);return{meta:W(()=>({...n,submitError:e,lastResponse:i}),[n,e,i]),getValues:u,getErrors:b,getTouched:B,getDirtyValues:g,submit:v,onSubmit:T,reset:E,...x}}import{useCallback as _,useEffect as X,useMemo as $,useRef as Y,useSyncExternalStore as Z}from"react";function Rt(t){let e=l(),r=$(()=>U(e,t),[e,t]),i=Y(null),s=_(()=>{let n=r.readItems();return i.current&&y(i.current,n)?i.current:(i.current=n,n)},[r]),o=_(n=>e.observe.subscribePath(t,()=>n()),[e,t]),c=Z(o,s,s),m=$(()=>r.getFields(c),[r,c]);return X(()=>()=>{q(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}}import{useCallback as P,useRef as N,useSyncExternalStore as tt}from"react";function At(t){let e=l(),r=N(null),i=P(()=>{let n=e.read.getScopeStatus(t);return r.current&&F(r.current,n)?r.current:(r.current=n,n)},[e,t]),s=P(n=>e.observe.subscribeScopeStatus(t,()=>n()),[e,t]),o=tt(s,i,i),c=P(async()=>{let n=await e.feature.validate({scope:t}),d=e.read.getScopeErrors(t);return{valid:n,errors:d}},[e,t]),m=P(()=>e.read.getScopeErrors(t),[e,t]);return{scopeName:t,status:o,errors:o.errors,validate:c,getErrors:m,isValid:!o.hasErrors,isDirty:o.isDirty}}import{useCallback as f,useRef as et,useState as rt,useSyncExternalStore as st}from"react";function It(t){let e=l(),[r,i]=rt(0),s=t[r]??"",o=et(null),c=f(()=>{let u=e.read.getScopeStatus(s);return o.current&&F(o.current,u)?o.current:(o.current=u,u)},[e,s]),m=st(f(u=>e.observe.subscribeScopeStatus(s,()=>u()),[e,s]),c,c),n=f(async()=>{let u=await e.feature.validate({scope:s}),b=e.read.getScopeErrors(s);return{valid:u,errors:b}},[e,s]),d=f(()=>e.read.getScopeErrors(s),[e,s]),a=f(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=f(()=>{i(u=>Math.max(u-1,0))},[]),v=f(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}}import{useCallback as z,useSyncExternalStore as ot,useRef as nt}from"react";function zt(t){let e=l(),r=nt(null),i=z(()=>{let o=w(e.read.getState().values,t);return r.current!==null&&y(r.current,o)?r.current:(r.current=o,o)},[e,t]),s=z(o=>e.observe.subscribePath(t,()=>o()),[e,t]);return ot(s,i,i)}import{useCallback as V,useMemo as it,useSyncExternalStore as at}from"react";function Qt(){let t=l(),e=at(c=>D(t,c),()=>R(t),()=>R(t)),r=V(async()=>t.feature.restorePersisted(),[t]),i=V(async()=>{await t.feature.forceSave()},[t]),s=V(async()=>{await t.feature.clearPersisted()},[t]),o=it(()=>({isSaving:e.isSaving,isRestoring:e.isRestoring,error:e.error}),[e]);return{restore:r,save:i,clear:s,meta:o}}import{useCallback as h,useEffect as ut,useRef as ct,useSyncExternalStore as lt}from"react";function se(t){let e=l(),r=ct(null);ut(()=>()=>I(e,t),[e,t]);let i=h(()=>{let n=e.read.getFieldState(t),d=k(n,r.current);return r.current=d,d},[e,t]),s=h(n=>e.observe.subscribeFieldState(t,()=>n()),[e,t]),o=lt(s,i,i),c=h(n=>e.write.setField(t,n),[e,t]),m=h(()=>e.write.blurField(t),[e,t]);return{fieldState:o,setValue:c,setBlur:m,store:e}}export{ft as a,l as b,Pt as c,se as d,Rt as e,At as f,It as g,zt as h,Qt as i};
2
+ //# sourceMappingURL=chunk-4NQOD2BA.js.map
@@ -1,2 +1,2 @@
1
- import{a as c,c as v}from"./chunk-K5X37E3U.js";import{a as g}from"./chunk-CGJRZJ62.js";function R(e){return{values:e.values,errors:e.errors,touched:e.touched,isValid:e.isValid,isDirty:e.isDirty,isSubmitting:e.isSubmitting,isValidating:e.isValidating,persist:e.persist}}function k(e){let o=e.getHistoryMetadata();return{...R(e.getState()),_meta:{canUndo:o.canUndo,canRedo:o.canRedo,totalSteps:o.historySize,currentIndex:o.historyIndex}}}function b(e){let o={};for(let[t,i]of Object.entries(e))o[t]=k(i);return o}function w(e){if(!e||typeof e!="object")return!1;let o=e;return typeof o.getState=="function"&&typeof o.getHistoryMetadata=="function"}function I(e){if(!w(e))return!1;let o=e;return typeof o.undo=="function"&&typeof o.redo=="function"&&typeof o.reset=="function"}function B(e,o){let t=e[o];return I(t)?t:null}var S=null,O=50;function N(e,o=g){S&&(console.warn("[bit-form] Reiniciando ponte do DevTools (Fast Refresh detectado)."),S());let t=null,i=null,f,n=null,a=new Set,T=!1,u=r=>{t?.readyState===WebSocket.OPEN&&t.send(JSON.stringify(r))},h=()=>{if(a.size===0)return;let r=b(Array.from(a).reduce((s,l)=>{let d=o.stores[l];return d&&(s[l]=d),s},{}));a.clear(),n=null,Object.keys(r).length>0&&u({type:"STATE_UPDATE",protocolVersion:1,payload:r})},D=()=>{n||(n=setTimeout(()=>{h()},O))},y=()=>{T=!1,t=new WebSocket(e),t.onopen=()=>{console.log("[bit-form] \u{1F50C} Conectado ao CLI DevTools via WebSocket."),u({type:"HELLO",protocolVersion:1,payload:{role:"server",protocolVersion:1}});let r=b(o.stores);Object.keys(r).length>0&&u({type:"STATE_UPDATE",protocolVersion:1,payload:r}),i=o.subscribe((s,l)=>{a.add(s),D()}),f=setInterval(()=>{u({type:"PING",protocolVersion:1})},3e4)},t.onmessage=r=>{try{let s=JSON.parse(r.data);if(v(s)){let{storeId:l,action:d}=s.payload,p=B(o.stores,l);if(!p)return;switch(d){case"undo":p.undo();break;case"redo":p.redo();break;case"reset":p.reset();break}}}catch(s){console.warn("[bit-form] Erro ao processar comando do CLI:",s)}},t.onclose=()=>{i&&i(),clearInterval(f),n&&(clearTimeout(n),n=null),a.clear(),T?console.log("[bit-form] Ponte antiga encerrada com sucesso."):(console.log("[bit-form] Conex\xE3o perdida. Reconectando em 3s..."),setTimeout(y,3e3))}};y();let m=()=>{T=!0,i&&i(),clearInterval(f),n&&(clearTimeout(n),n=null),a.clear(),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),S=null};return S=m,m}export{b as a,B as b,N as c};
2
- //# sourceMappingURL=chunk-ZWWXPYEL.js.map
1
+ import{a as c,c as v}from"./chunk-K5X37E3U.js";import{a as g}from"./chunk-G4HK5QTU.js";function R(e){return{values:e.values,errors:e.errors,touched:e.touched,isValid:e.isValid,isDirty:e.isDirty,isSubmitting:e.isSubmitting,isValidating:e.isValidating,persist:e.persist}}function k(e){let o=e.getHistoryMetadata();return{...R(e.getState()),_meta:{canUndo:o.canUndo,canRedo:o.canRedo,totalSteps:o.historySize,currentIndex:o.historyIndex}}}function b(e){let o={};for(let[t,i]of Object.entries(e))o[t]=k(i);return o}function w(e){if(!e||typeof e!="object")return!1;let o=e;return typeof o.getState=="function"&&typeof o.getHistoryMetadata=="function"}function I(e){if(!w(e))return!1;let o=e;return typeof o.undo=="function"&&typeof o.redo=="function"&&typeof o.reset=="function"}function B(e,o){let t=e[o];return I(t)?t:null}var S=null,O=50;function N(e,o=g){S&&(console.warn("[bit-form] Reiniciando ponte do DevTools (Fast Refresh detectado)."),S());let t=null,i=null,f,n=null,a=new Set,T=!1,u=r=>{t?.readyState===WebSocket.OPEN&&t.send(JSON.stringify(r))},h=()=>{if(a.size===0)return;let r=b(Array.from(a).reduce((s,l)=>{let d=o.stores[l];return d&&(s[l]=d),s},{}));a.clear(),n=null,Object.keys(r).length>0&&u({type:"STATE_UPDATE",protocolVersion:1,payload:r})},D=()=>{n||(n=setTimeout(()=>{h()},O))},y=()=>{T=!1,t=new WebSocket(e),t.onopen=()=>{console.log("[bit-form] \u{1F50C} Conectado ao CLI DevTools via WebSocket."),u({type:"HELLO",protocolVersion:1,payload:{role:"server",protocolVersion:1}});let r=b(o.stores);Object.keys(r).length>0&&u({type:"STATE_UPDATE",protocolVersion:1,payload:r}),i=o.subscribe((s,l)=>{a.add(s),D()}),f=setInterval(()=>{u({type:"PING",protocolVersion:1})},3e4)},t.onmessage=r=>{try{let s=JSON.parse(r.data);if(v(s)){let{storeId:l,action:d}=s.payload,p=B(o.stores,l);if(!p)return;switch(d){case"undo":p.undo();break;case"redo":p.redo();break;case"reset":p.reset();break}}}catch(s){console.warn("[bit-form] Erro ao processar comando do CLI:",s)}},t.onclose=()=>{i&&i(),clearInterval(f),n&&(clearTimeout(n),n=null),a.clear(),T?console.log("[bit-form] Ponte antiga encerrada com sucesso."):(console.log("[bit-form] Conex\xE3o perdida. Reconectando em 3s..."),setTimeout(y,3e3))}};y();let m=()=>{T=!0,i&&i(),clearInterval(f),n&&(clearTimeout(n),n=null),a.clear(),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),S=null};return S=m,m}export{b as a,B as b,N as c};
2
+ //# sourceMappingURL=chunk-7OZR7KWL.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkRGMUXQ2Kcjs = require('./chunk-RGMUXQ2K.cjs');var _chunkPFPGASVZcjs = require('./chunk-PFPGASVZ.cjs');function m(e){let t=e.read.getState();return{isValid:t.isValid,isDirty:t.isDirty,isSubmitting:t.isSubmitting}}function f(e,t){return e.observe.subscribeFormMeta(()=>t())}function g(e,t){return t(m(e)),f(e,()=>{t(m(e))})}function B(e){return e.read.getPersistMetadata()}function v(e,t){return e.observe.subscribePersistMeta(()=>t())}function x(e,t){return t(B(e)),e.observe.subscribePersistMeta(o=>{t(o)})}function M(e,t){let o=!1,a=r=>Array.isArray(r)?r:r==null?[]:((!(typeof process<"u")||process.env.NODE_ENV!=="production")&&!o&&(o=!0,console.warn(`[bit-form] createArrayBinding expected an array at path "${String(t)}" but received ${typeof r}. Returning an empty array.`)),[]),p=r=>e.feature.getArrayItemIds(t,r);return{readItems(){let r=_chunkRGMUXQ2Kcjs.f.call(void 0, e.read.getState().values,t);return a(r)},getFields(r){let i=p(r.length);return r.map((s,n)=>({key:i[n]||`temp-${n}`,value:s,index:n}))},append(r){e.feature.pushItem(t,r)},prepend(r){e.feature.prependItem(t,r)},insert(r,i){e.feature.insertItem(t,r,i)},remove(r){e.feature.removeItem(t,r)},move(r,i){e.feature.moveItem(t,r,i)},swap(r,i){e.feature.swapItems(t,r,i)},replace(r){e.feature.replaceItems(t,r)},clear(){e.feature.clearItems(t)}}}function b(e,t,o){return{setValue:i=>{let s=o();e.setField(t,_chunkPFPGASVZcjs.c.call(void 0, i,s))},setBlur:()=>e.blurField(t),displayValue:i=>_chunkPFPGASVZcjs.b.call(void 0, i,o())}}function w(e,t){return{fieldController:b({setField(a,p){e.write.setField(a,p)},blurField(a){e.write.blurField(a)}},t,()=>e.feature.resolveMask(t))}}function F(e,t){_optionalChain([e, 'optionalAccess', _ => _.preventDefault, 'optionalCall', _2 => _2()]),_optionalChain([t, 'optionalAccess', _3 => _3.stopPropagation])&&_optionalChain([e, 'optionalAccess', _4 => _4.stopPropagation, 'optionalCall', _5 => _5()])}function y(e,t,o){return{submit:i=>async s=>{F(s,o),await e.submit(i)},onSubmit:i=>async s=>{F(s,o),t.setSubmissionError(null);let n,l=await e.submit(async(P,S)=>{n=await i(P,S)});if(l.status==="submitted"){t.setSubmissionResult(n),t.setSubmissionError(null);return}l.status==="failed"&&t.setSubmissionError(l.error instanceof Error?l.error:new Error(String(l.error)))},reset:()=>{e.reset(),t.clearSubmissionState()},getValues:()=>e.getState().values,getErrors:()=>e.getState().errors,getTouched:()=>e.getState().touched,getDirtyValues:()=>e.getDirtyValues()}}function T(e,t,o){let a={getState:e.read.getState,getDirtyValues:e.read.getDirtyValues,submit:e.write.submit,reset:e.write.reset,setServerErrors:e.write.setServerErrors};return{controller:y(a,t,o),actions:{setField:e.write.setField.bind(e.write),blurField:e.write.blurField.bind(e.write),setValues:e.write.setValues.bind(e.write),setError:e.write.setError.bind(e.write),setErrors:e.write.setErrors.bind(e.write),setServerErrors:e.write.setServerErrors.bind(e.write),validate:e.feature.validate.bind(e.feature),transaction:e.write.transaction.bind(e.write)}}}function A(e,t){_optionalChain([e, 'access', _6 => _6.feature, 'optionalAccess', _7 => _7.unregisterField, 'optionalCall', _8 => _8(t)])}function k(e,t){_optionalChain([e, 'access', _9 => _9.feature, 'optionalAccess', _10 => _10.unregisterPrefix, 'optionalCall', _11 => _11(t)])}exports.a = m; exports.b = f; exports.c = g; exports.d = B; exports.e = v; exports.f = x; exports.g = M; exports.h = w; exports.i = T; exports.j = A; exports.k = k;
2
- //# sourceMappingURL=chunk-QZBJ4WRU.cjs.map
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkVOA3SKFYcjs = require('./chunk-VOA3SKFY.cjs');var _chunkPFPGASVZcjs = require('./chunk-PFPGASVZ.cjs');function m(e){let t=e.read.getState();return{isValid:t.isValid,isDirty:t.isDirty,isSubmitting:t.isSubmitting}}function f(e,t){return e.observe.subscribeFormMeta(()=>t())}function g(e,t){return t(m(e)),f(e,()=>{t(m(e))})}function B(e){return e.read.getPersistMetadata()}function v(e,t){return e.observe.subscribePersistMeta(()=>t())}function x(e,t){return t(B(e)),e.observe.subscribePersistMeta(o=>{t(o)})}function M(e,t){let o=!1,a=r=>Array.isArray(r)?r:r==null?[]:((!(typeof process<"u")||process.env.NODE_ENV!=="production")&&!o&&(o=!0,console.warn(`[bit-form] createArrayBinding expected an array at path "${String(t)}" but received ${typeof r}. Returning an empty array.`)),[]),p=r=>e.feature.getArrayItemIds(t,r);return{readItems(){let r=_chunkVOA3SKFYcjs.f.call(void 0, e.read.getState().values,t);return a(r)},getFields(r){let i=p(r.length);return r.map((s,n)=>({key:i[n]||`temp-${n}`,value:s,index:n}))},append(r){e.feature.pushItem(t,r)},prepend(r){e.feature.prependItem(t,r)},insert(r,i){e.feature.insertItem(t,r,i)},remove(r){e.feature.removeItem(t,r)},move(r,i){e.feature.moveItem(t,r,i)},swap(r,i){e.feature.swapItems(t,r,i)},replace(r){e.feature.replaceItems(t,r)},clear(){e.feature.clearItems(t)}}}function b(e,t,o){return{setValue:i=>{let s=o();e.setField(t,_chunkPFPGASVZcjs.c.call(void 0, i,s))},setBlur:()=>e.blurField(t),displayValue:i=>_chunkPFPGASVZcjs.b.call(void 0, i,o())}}function w(e,t){return{fieldController:b({setField(a,p){e.write.setField(a,p)},blurField(a){e.write.blurField(a)}},t,()=>e.feature.resolveMask(t))}}function F(e,t){_optionalChain([e, 'optionalAccess', _ => _.preventDefault, 'optionalCall', _2 => _2()]),_optionalChain([t, 'optionalAccess', _3 => _3.stopPropagation])&&_optionalChain([e, 'optionalAccess', _4 => _4.stopPropagation, 'optionalCall', _5 => _5()])}function y(e,t,o){return{submit:i=>async s=>{F(s,o),await e.submit(i)},onSubmit:i=>async s=>{F(s,o),t.setSubmissionError(null);let n,l=await e.submit(async(P,S)=>{n=await i(P,S)});if(l.status==="submitted"){t.setSubmissionResult(n),t.setSubmissionError(null);return}l.status==="failed"&&t.setSubmissionError(l.error instanceof Error?l.error:new Error(String(l.error)))},reset:()=>{e.reset(),t.clearSubmissionState()},getValues:()=>e.getState().values,getErrors:()=>e.getState().errors,getTouched:()=>e.getState().touched,getDirtyValues:()=>e.getDirtyValues()}}function T(e,t,o){let a={getState:e.read.getState,getDirtyValues:e.read.getDirtyValues,submit:e.write.submit,reset:e.write.reset,setServerErrors:e.write.setServerErrors};return{controller:y(a,t,o),actions:{setField:e.write.setField.bind(e.write),blurField:e.write.blurField.bind(e.write),setValues:e.write.setValues.bind(e.write),setError:e.write.setError.bind(e.write),setErrors:e.write.setErrors.bind(e.write),setServerErrors:e.write.setServerErrors.bind(e.write),validate:e.feature.validate.bind(e.feature),transaction:e.write.transaction.bind(e.write)}}}function A(e,t){_optionalChain([e, 'access', _6 => _6.feature, 'optionalAccess', _7 => _7.unregisterField, 'optionalCall', _8 => _8(t)])}function k(e,t){_optionalChain([e, 'access', _9 => _9.feature, 'optionalAccess', _10 => _10.unregisterPrefix, 'optionalCall', _11 => _11(t)])}exports.a = m; exports.b = f; exports.c = g; exports.d = B; exports.e = v; exports.f = x; exports.g = M; exports.h = w; exports.i = T; exports.j = A; exports.k = k;
2
+ //# sourceMappingURL=chunk-ALIYU2RT.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-QZBJ4WRU.cjs","../src/core/bindings/form-meta.ts","../src/core/bindings/persist-meta.ts","../src/core/bindings/array-controller.ts"],"names":["readFormMetaSnapshot","store","state","subscribeFormMetaSnapshot","listener","observeFormMetaSnapshot","readPersistMetaSnapshot","subscribePersistMetaSnapshot","observePersistMetaSnapshot","meta","createArrayBinding","path","warnedTypeMismatch","normalizeItems","value","getIds","length","getDeepValue","items","ids","item","index"],"mappings":"AAAA,qoBAAwC,wDAAgD,SCGxEA,CAAAA,CACdC,CAAAA,CACa,CACb,IAAMC,CAAAA,CAAQD,CAAAA,CAAM,IAAA,CAAK,QAAA,CAAS,CAAA,CAClC,MAAO,CACL,OAAA,CAASC,CAAAA,CAAM,OAAA,CACf,OAAA,CAASA,CAAAA,CAAM,OAAA,CACf,YAAA,CAAcA,CAAAA,CAAM,YACtB,CACF,CAEO,SAASC,CAAAA,CACdF,CAAAA,CACAG,CAAAA,CACY,CACZ,OAAOH,CAAAA,CAAM,OAAA,CAAQ,iBAAA,CAAkB,CAAA,CAAA,EAAMG,CAAAA,CAAS,CAAC,CACzD,CAEO,SAASC,CAAAA,CACdJ,CAAAA,CACAG,CAAAA,CACY,CACZ,OAAAA,CAAAA,CAASJ,CAAAA,CAAqBC,CAAK,CAAC,CAAA,CAE7BE,CAAAA,CAA0BF,CAAAA,CAAO,CAAA,CAAA,EAAM,CAC5CG,CAAAA,CAASJ,CAAAA,CAAqBC,CAAK,CAAC,CACtC,CAAC,CACH,CCjBO,SAASK,CAAAA,CAAwBL,CAAAA,CAIjB,CACrB,OAAOA,CAAAA,CAAM,IAAA,CAAK,kBAAA,CAAmB,CACvC,CAEO,SAASM,CAAAA,CACdN,CAAAA,CACAG,CAAAA,CACY,CACZ,OAAOH,CAAAA,CAAM,OAAA,CAAQ,oBAAA,CAAqB,CAAA,CAAA,EAAMG,CAAAA,CAAS,CAAC,CAC5D,CAEO,SAASI,CAAAA,CACdP,CAAAA,CACAG,CAAAA,CACY,CACZ,OAAAA,CAAAA,CAASE,CAAAA,CAAwBL,CAAK,CAAC,CAAA,CAEhCA,CAAAA,CAAM,OAAA,CAAQ,oBAAA,CAAsBQ,CAAAA,EAAS,CAClDL,CAAAA,CAASK,CAAI,CACf,CAAC,CACH,CC1BO,SAASC,CAAAA,CAGdT,CAAAA,CAA2BU,CAAAA,CAAoC,CAG/D,IAAIC,CAAAA,CAAqB,CAAA,CAAA,CAEnBC,CAAAA,CAAkBC,CAAAA,EAClB,KAAA,CAAM,OAAA,CAAQA,CAAK,CAAA,CACdA,CAAAA,CAGLA,CAAAA,EAAS,IAAA,CACJ,CAAC,CAAA,CAAA,CAAA,CAIR,CAAA,CAAA,OAAO,OAAA,CAAY,GAAA,CAAA,EACf,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,YAAA,CAAA,EAGlB,CAACF,CAAAA,EAAAA,CACZA,CAAAA,CAAqB,CAAA,CAAA,CACrB,OAAA,CAAQ,IAAA,CACN,CAAA,yDAAA,EAA4D,MAAA,CAC1DD,CACF,CAAC,CAAA,eAAA,EAAkB,OAAOG,CAAK,CAAA,2BAAA,CACjC,CAAA,CAAA,CAGK,CAAC,CAAA,CAAA,CAGJC,CAAAA,CAAUC,CAAAA,EACdf,CAAAA,CAAM,OAAA,CAAQ,eAAA,CAAgBU,CAAAA,CAAMK,CAAM,CAAA,CAE5C,MAAO,CACL,SAAA,CAAA,CAAY,CACV,IAAMF,CAAAA,CAAQG,iCAAAA,CACZhB,CAAM,IAAA,CAAK,QAAA,CAAS,CAAA,CAAE,MAAA,CACtBU,CACF,CAAA,CACA,OAAOE,CAAAA,CAAeC,CAAK,CAC7B,CAAA,CAEA,SAAA,CAAUI,CAAAA,CAAO,CACf,IAAMC,CAAAA,CAAMJ,CAAAA,CAAOG,CAAAA,CAAM,MAAM,CAAA,CAC/B,OAAOA,CAAAA,CAAM,GAAA,CAAI,CAACE,CAAAA,CAAMC,CAAAA,CAAAA,EAAAA,CAAW,CACjC,GAAA,CAAKF,CAAAA,CAAIE,CAAK,CAAA,EAAK,CAAA,KAAA,EAAQA,CAAK,CAAA,CAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-QZBJ4WRU.cjs","sourcesContent":[null,"import type { BitFormMeta } from \"../store/contracts/public/meta-types\";\nimport type { BitStoreApi } from \"../store/contracts/public/store-api-types\";\n\nexport function readFormMetaSnapshot<T extends object>(\n store: BitStoreApi<T>,\n): BitFormMeta {\n const state = store.read.getState();\n return {\n isValid: state.isValid,\n isDirty: state.isDirty,\n isSubmitting: state.isSubmitting,\n };\n}\n\nexport function subscribeFormMetaSnapshot<T extends object>(\n store: BitStoreApi<T>,\n listener: () => void,\n): () => void {\n return store.observe.subscribeFormMeta(() => listener());\n}\n\nexport function observeFormMetaSnapshot<T extends object>(\n store: BitStoreApi<T>,\n listener: (meta: BitFormMeta) => void,\n): () => void {\n listener(readFormMetaSnapshot(store));\n\n return subscribeFormMetaSnapshot(store, () => {\n listener(readFormMetaSnapshot(store));\n });\n}\n","import type { BitPersistMetadata } from \"../store/contracts/types\";\n\ntype BitPersistMetaReadableStore = {\n read: {\n getPersistMetadata(): BitPersistMetadata;\n };\n observe: {\n subscribePersistMeta(\n listener: (meta: BitPersistMetadata) => void,\n ): () => void;\n };\n};\n\nexport function readPersistMetaSnapshot(store: {\n read: {\n getPersistMetadata(): BitPersistMetadata;\n };\n}): BitPersistMetadata {\n return store.read.getPersistMetadata();\n}\n\nexport function subscribePersistMetaSnapshot(\n store: BitPersistMetaReadableStore,\n listener: () => void,\n): () => void {\n return store.observe.subscribePersistMeta(() => listener());\n}\n\nexport function observePersistMetaSnapshot(\n store: BitPersistMetaReadableStore,\n listener: (meta: BitPersistMetadata) => void,\n): () => void {\n listener(readPersistMetaSnapshot(store));\n\n return store.observe.subscribePersistMeta((meta) => {\n listener(meta);\n });\n}\n","import type { BitStoreApi } from \"../store/contracts/public/store-api-types\";\nimport type {\n BitArrayItem,\n BitArrayPath,\n BitPathValue,\n} from \"../store/contracts/types\";\nimport type { BitArrayBinding, BitArrayBindingField } from \"../types/bindings\";\nimport { getDeepValue } from \"../utils\";\n\nexport type { BitArrayBinding, BitArrayBindingField };\n\nexport function createArrayBinding<\n TForm extends object,\n P extends BitArrayPath<TForm>,\n>(store: BitStoreApi<TForm>, path: P): BitArrayBinding<TForm, P> {\n type Item = BitArrayItem<BitPathValue<TForm, P>>;\n\n let warnedTypeMismatch = false;\n\n const normalizeItems = (value: unknown): Item[] => {\n if (Array.isArray(value)) {\n return value as Item[];\n }\n\n if (value == null) {\n return [];\n }\n\n const isDev =\n typeof process !== \"undefined\"\n ? process.env.NODE_ENV !== \"production\"\n : true;\n\n if (isDev && !warnedTypeMismatch) {\n warnedTypeMismatch = true;\n console.warn(\n `[bit-form] createArrayBinding expected an array at path \"${String(\n path,\n )}\" but received ${typeof value}. Returning an empty array.`,\n );\n }\n\n return [];\n };\n\n const getIds = (length: number) =>\n store.feature.getArrayItemIds(path, length);\n\n return {\n readItems() {\n const value = getDeepValue(\n store.read.getState().values,\n path as string,\n ) as BitPathValue<TForm, P> | undefined;\n return normalizeItems(value);\n },\n\n getFields(items) {\n const ids = getIds(items.length);\n return items.map((item, index) => ({\n key: ids[index] || `temp-${index}`,\n value: item,\n index,\n }));\n },\n\n append(value) {\n store.feature.pushItem(path, value);\n },\n\n prepend(value) {\n store.feature.prependItem(path, value);\n },\n\n insert(index, value) {\n store.feature.insertItem(path, index, value);\n },\n\n remove(index) {\n store.feature.removeItem(path, index);\n },\n\n move(from, to) {\n store.feature.moveItem(path, from, to);\n },\n\n swap(indexA, indexB) {\n store.feature.swapItems(path, indexA, indexB);\n },\n\n replace(items) {\n store.feature.replaceItems(path, items);\n },\n\n clear() {\n store.feature.clearItems(path);\n },\n };\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-ALIYU2RT.cjs","../src/core/bindings/form-meta.ts","../src/core/bindings/persist-meta.ts","../src/core/bindings/array-controller.ts"],"names":["readFormMetaSnapshot","store","state","subscribeFormMetaSnapshot","listener","observeFormMetaSnapshot","readPersistMetaSnapshot","subscribePersistMetaSnapshot","observePersistMetaSnapshot","meta","createArrayBinding","path","warnedTypeMismatch","normalizeItems","value","getIds","length","getDeepValue","items","ids","item","index"],"mappings":"AAAA,qoBAAwC,wDAAgD,SCGxEA,CAAAA,CACdC,CAAAA,CACa,CACb,IAAMC,CAAAA,CAAQD,CAAAA,CAAM,IAAA,CAAK,QAAA,CAAS,CAAA,CAClC,MAAO,CACL,OAAA,CAASC,CAAAA,CAAM,OAAA,CACf,OAAA,CAASA,CAAAA,CAAM,OAAA,CACf,YAAA,CAAcA,CAAAA,CAAM,YACtB,CACF,CAEO,SAASC,CAAAA,CACdF,CAAAA,CACAG,CAAAA,CACY,CACZ,OAAOH,CAAAA,CAAM,OAAA,CAAQ,iBAAA,CAAkB,CAAA,CAAA,EAAMG,CAAAA,CAAS,CAAC,CACzD,CAEO,SAASC,CAAAA,CACdJ,CAAAA,CACAG,CAAAA,CACY,CACZ,OAAAA,CAAAA,CAASJ,CAAAA,CAAqBC,CAAK,CAAC,CAAA,CAE7BE,CAAAA,CAA0BF,CAAAA,CAAO,CAAA,CAAA,EAAM,CAC5CG,CAAAA,CAASJ,CAAAA,CAAqBC,CAAK,CAAC,CACtC,CAAC,CACH,CCjBO,SAASK,CAAAA,CAAwBL,CAAAA,CAIjB,CACrB,OAAOA,CAAAA,CAAM,IAAA,CAAK,kBAAA,CAAmB,CACvC,CAEO,SAASM,CAAAA,CACdN,CAAAA,CACAG,CAAAA,CACY,CACZ,OAAOH,CAAAA,CAAM,OAAA,CAAQ,oBAAA,CAAqB,CAAA,CAAA,EAAMG,CAAAA,CAAS,CAAC,CAC5D,CAEO,SAASI,CAAAA,CACdP,CAAAA,CACAG,CAAAA,CACY,CACZ,OAAAA,CAAAA,CAASE,CAAAA,CAAwBL,CAAK,CAAC,CAAA,CAEhCA,CAAAA,CAAM,OAAA,CAAQ,oBAAA,CAAsBQ,CAAAA,EAAS,CAClDL,CAAAA,CAASK,CAAI,CACf,CAAC,CACH,CC1BO,SAASC,CAAAA,CAGdT,CAAAA,CAA2BU,CAAAA,CAAoC,CAG/D,IAAIC,CAAAA,CAAqB,CAAA,CAAA,CAEnBC,CAAAA,CAAkBC,CAAAA,EAClB,KAAA,CAAM,OAAA,CAAQA,CAAK,CAAA,CACdA,CAAAA,CAGLA,CAAAA,EAAS,IAAA,CACJ,CAAC,CAAA,CAAA,CAAA,CAIR,CAAA,CAAA,OAAO,OAAA,CAAY,GAAA,CAAA,EACf,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,YAAA,CAAA,EAGlB,CAACF,CAAAA,EAAAA,CACZA,CAAAA,CAAqB,CAAA,CAAA,CACrB,OAAA,CAAQ,IAAA,CACN,CAAA,yDAAA,EAA4D,MAAA,CAC1DD,CACF,CAAC,CAAA,eAAA,EAAkB,OAAOG,CAAK,CAAA,2BAAA,CACjC,CAAA,CAAA,CAGK,CAAC,CAAA,CAAA,CAGJC,CAAAA,CAAUC,CAAAA,EACdf,CAAAA,CAAM,OAAA,CAAQ,eAAA,CAAgBU,CAAAA,CAAMK,CAAM,CAAA,CAE5C,MAAO,CACL,SAAA,CAAA,CAAY,CACV,IAAMF,CAAAA,CAAQG,iCAAAA,CACZhB,CAAM,IAAA,CAAK,QAAA,CAAS,CAAA,CAAE,MAAA,CACtBU,CACF,CAAA,CACA,OAAOE,CAAAA,CAAeC,CAAK,CAC7B,CAAA,CAEA,SAAA,CAAUI,CAAAA,CAAO,CACf,IAAMC,CAAAA,CAAMJ,CAAAA,CAAOG,CAAAA,CAAM,MAAM,CAAA,CAC/B,OAAOA,CAAAA,CAAM,GAAA,CAAI,CAACE,CAAAA,CAAMC,CAAAA,CAAAA,EAAAA,CAAW,CACjC,GAAA,CAAKF,CAAAA,CAAIE,CAAK,CAAA,EAAK,CAAA,KAAA,EAAQA,CAAK,CAAA,CAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-ALIYU2RT.cjs","sourcesContent":[null,"import type { BitFormMeta } from \"../store/contracts/public/meta-types\";\nimport type { BitStoreApi } from \"../store/contracts/public/store-api-types\";\n\nexport function readFormMetaSnapshot<T extends object>(\n store: BitStoreApi<T>,\n): BitFormMeta {\n const state = store.read.getState();\n return {\n isValid: state.isValid,\n isDirty: state.isDirty,\n isSubmitting: state.isSubmitting,\n };\n}\n\nexport function subscribeFormMetaSnapshot<T extends object>(\n store: BitStoreApi<T>,\n listener: () => void,\n): () => void {\n return store.observe.subscribeFormMeta(() => listener());\n}\n\nexport function observeFormMetaSnapshot<T extends object>(\n store: BitStoreApi<T>,\n listener: (meta: BitFormMeta) => void,\n): () => void {\n listener(readFormMetaSnapshot(store));\n\n return subscribeFormMetaSnapshot(store, () => {\n listener(readFormMetaSnapshot(store));\n });\n}\n","import type { BitPersistMetadata } from \"../store/contracts/types\";\n\ntype BitPersistMetaReadableStore = {\n read: {\n getPersistMetadata(): BitPersistMetadata;\n };\n observe: {\n subscribePersistMeta(\n listener: (meta: BitPersistMetadata) => void,\n ): () => void;\n };\n};\n\nexport function readPersistMetaSnapshot(store: {\n read: {\n getPersistMetadata(): BitPersistMetadata;\n };\n}): BitPersistMetadata {\n return store.read.getPersistMetadata();\n}\n\nexport function subscribePersistMetaSnapshot(\n store: BitPersistMetaReadableStore,\n listener: () => void,\n): () => void {\n return store.observe.subscribePersistMeta(() => listener());\n}\n\nexport function observePersistMetaSnapshot(\n store: BitPersistMetaReadableStore,\n listener: (meta: BitPersistMetadata) => void,\n): () => void {\n listener(readPersistMetaSnapshot(store));\n\n return store.observe.subscribePersistMeta((meta) => {\n listener(meta);\n });\n}\n","import type { BitStoreApi } from \"../store/contracts/public/store-api-types\";\nimport type {\n BitArrayItem,\n BitArrayPath,\n BitPathValue,\n} from \"../store/contracts/types\";\nimport type { BitArrayBinding, BitArrayBindingField } from \"../types/bindings\";\nimport { getDeepValue } from \"../utils\";\n\nexport type { BitArrayBinding, BitArrayBindingField };\n\nexport function createArrayBinding<\n TForm extends object,\n P extends BitArrayPath<TForm>,\n>(store: BitStoreApi<TForm>, path: P): BitArrayBinding<TForm, P> {\n type Item = BitArrayItem<BitPathValue<TForm, P>>;\n\n let warnedTypeMismatch = false;\n\n const normalizeItems = (value: unknown): Item[] => {\n if (Array.isArray(value)) {\n return value as Item[];\n }\n\n if (value == null) {\n return [];\n }\n\n const isDev =\n typeof process !== \"undefined\"\n ? process.env.NODE_ENV !== \"production\"\n : true;\n\n if (isDev && !warnedTypeMismatch) {\n warnedTypeMismatch = true;\n console.warn(\n `[bit-form] createArrayBinding expected an array at path \"${String(\n path,\n )}\" but received ${typeof value}. Returning an empty array.`,\n );\n }\n\n return [];\n };\n\n const getIds = (length: number) =>\n store.feature.getArrayItemIds(path, length);\n\n return {\n readItems() {\n const value = getDeepValue(\n store.read.getState().values,\n path as string,\n ) as BitPathValue<TForm, P> | undefined;\n return normalizeItems(value);\n },\n\n getFields(items) {\n const ids = getIds(items.length);\n return items.map((item, index) => ({\n key: ids[index] || `temp-${index}`,\n value: item,\n index,\n }));\n },\n\n append(value) {\n store.feature.pushItem(path, value);\n },\n\n prepend(value) {\n store.feature.prependItem(path, value);\n },\n\n insert(index, value) {\n store.feature.insertItem(path, index, value);\n },\n\n remove(index) {\n store.feature.removeItem(path, index);\n },\n\n move(from, to) {\n store.feature.moveItem(path, from, to);\n },\n\n swap(indexA, indexB) {\n store.feature.swapItems(path, indexA, indexB);\n },\n\n replace(items) {\n store.feature.replaceItems(path, items);\n },\n\n clear() {\n store.feature.clearItems(path);\n },\n };\n}\n"]}
@@ -1,2 +1,2 @@
1
- import{f as c}from"./chunk-6NH6MUXA.js";import{b as u,c as d}from"./chunk-3NUJVIAM.js";function m(e){let t=e.read.getState();return{isValid:t.isValid,isDirty:t.isDirty,isSubmitting:t.isSubmitting}}function f(e,t){return e.observe.subscribeFormMeta(()=>t())}function g(e,t){return t(m(e)),f(e,()=>{t(m(e))})}function B(e){return e.read.getPersistMetadata()}function v(e,t){return e.observe.subscribePersistMeta(()=>t())}function x(e,t){return t(B(e)),e.observe.subscribePersistMeta(o=>{t(o)})}function M(e,t){let o=!1,a=r=>Array.isArray(r)?r:r==null?[]:((!(typeof process<"u")||process.env.NODE_ENV!=="production")&&!o&&(o=!0,console.warn(`[bit-form] createArrayBinding expected an array at path "${String(t)}" but received ${typeof r}. Returning an empty array.`)),[]),p=r=>e.feature.getArrayItemIds(t,r);return{readItems(){let r=c(e.read.getState().values,t);return a(r)},getFields(r){let i=p(r.length);return r.map((s,n)=>({key:i[n]||`temp-${n}`,value:s,index:n}))},append(r){e.feature.pushItem(t,r)},prepend(r){e.feature.prependItem(t,r)},insert(r,i){e.feature.insertItem(t,r,i)},remove(r){e.feature.removeItem(t,r)},move(r,i){e.feature.moveItem(t,r,i)},swap(r,i){e.feature.swapItems(t,r,i)},replace(r){e.feature.replaceItems(t,r)},clear(){e.feature.clearItems(t)}}}function b(e,t,o){return{setValue:i=>{let s=o();e.setField(t,d(i,s))},setBlur:()=>e.blurField(t),displayValue:i=>u(i,o())}}function w(e,t){return{fieldController:b({setField(a,p){e.write.setField(a,p)},blurField(a){e.write.blurField(a)}},t,()=>e.feature.resolveMask(t))}}function F(e,t){e?.preventDefault?.(),t?.stopPropagation&&e?.stopPropagation?.()}function y(e,t,o){return{submit:i=>async s=>{F(s,o),await e.submit(i)},onSubmit:i=>async s=>{F(s,o),t.setSubmissionError(null);let n,l=await e.submit(async(P,S)=>{n=await i(P,S)});if(l.status==="submitted"){t.setSubmissionResult(n),t.setSubmissionError(null);return}l.status==="failed"&&t.setSubmissionError(l.error instanceof Error?l.error:new Error(String(l.error)))},reset:()=>{e.reset(),t.clearSubmissionState()},getValues:()=>e.getState().values,getErrors:()=>e.getState().errors,getTouched:()=>e.getState().touched,getDirtyValues:()=>e.getDirtyValues()}}function T(e,t,o){let a={getState:e.read.getState,getDirtyValues:e.read.getDirtyValues,submit:e.write.submit,reset:e.write.reset,setServerErrors:e.write.setServerErrors};return{controller:y(a,t,o),actions:{setField:e.write.setField.bind(e.write),blurField:e.write.blurField.bind(e.write),setValues:e.write.setValues.bind(e.write),setError:e.write.setError.bind(e.write),setErrors:e.write.setErrors.bind(e.write),setServerErrors:e.write.setServerErrors.bind(e.write),validate:e.feature.validate.bind(e.feature),transaction:e.write.transaction.bind(e.write)}}}function A(e,t){e.feature?.unregisterField?.(t)}function k(e,t){e.feature?.unregisterPrefix?.(t)}export{m as a,f as b,g as c,B as d,v as e,x as f,M as g,w as h,T as i,A as j,k};
2
- //# sourceMappingURL=chunk-LZTWNUKZ.js.map
1
+ import{f as c}from"./chunk-IMMFFTXE.js";import{b as u,c as d}from"./chunk-3NUJVIAM.js";function m(e){let t=e.read.getState();return{isValid:t.isValid,isDirty:t.isDirty,isSubmitting:t.isSubmitting}}function f(e,t){return e.observe.subscribeFormMeta(()=>t())}function g(e,t){return t(m(e)),f(e,()=>{t(m(e))})}function B(e){return e.read.getPersistMetadata()}function v(e,t){return e.observe.subscribePersistMeta(()=>t())}function x(e,t){return t(B(e)),e.observe.subscribePersistMeta(o=>{t(o)})}function M(e,t){let o=!1,a=r=>Array.isArray(r)?r:r==null?[]:((!(typeof process<"u")||process.env.NODE_ENV!=="production")&&!o&&(o=!0,console.warn(`[bit-form] createArrayBinding expected an array at path "${String(t)}" but received ${typeof r}. Returning an empty array.`)),[]),p=r=>e.feature.getArrayItemIds(t,r);return{readItems(){let r=c(e.read.getState().values,t);return a(r)},getFields(r){let i=p(r.length);return r.map((s,n)=>({key:i[n]||`temp-${n}`,value:s,index:n}))},append(r){e.feature.pushItem(t,r)},prepend(r){e.feature.prependItem(t,r)},insert(r,i){e.feature.insertItem(t,r,i)},remove(r){e.feature.removeItem(t,r)},move(r,i){e.feature.moveItem(t,r,i)},swap(r,i){e.feature.swapItems(t,r,i)},replace(r){e.feature.replaceItems(t,r)},clear(){e.feature.clearItems(t)}}}function b(e,t,o){return{setValue:i=>{let s=o();e.setField(t,d(i,s))},setBlur:()=>e.blurField(t),displayValue:i=>u(i,o())}}function w(e,t){return{fieldController:b({setField(a,p){e.write.setField(a,p)},blurField(a){e.write.blurField(a)}},t,()=>e.feature.resolveMask(t))}}function F(e,t){e?.preventDefault?.(),t?.stopPropagation&&e?.stopPropagation?.()}function y(e,t,o){return{submit:i=>async s=>{F(s,o),await e.submit(i)},onSubmit:i=>async s=>{F(s,o),t.setSubmissionError(null);let n,l=await e.submit(async(P,S)=>{n=await i(P,S)});if(l.status==="submitted"){t.setSubmissionResult(n),t.setSubmissionError(null);return}l.status==="failed"&&t.setSubmissionError(l.error instanceof Error?l.error:new Error(String(l.error)))},reset:()=>{e.reset(),t.clearSubmissionState()},getValues:()=>e.getState().values,getErrors:()=>e.getState().errors,getTouched:()=>e.getState().touched,getDirtyValues:()=>e.getDirtyValues()}}function T(e,t,o){let a={getState:e.read.getState,getDirtyValues:e.read.getDirtyValues,submit:e.write.submit,reset:e.write.reset,setServerErrors:e.write.setServerErrors};return{controller:y(a,t,o),actions:{setField:e.write.setField.bind(e.write),blurField:e.write.blurField.bind(e.write),setValues:e.write.setValues.bind(e.write),setError:e.write.setError.bind(e.write),setErrors:e.write.setErrors.bind(e.write),setServerErrors:e.write.setServerErrors.bind(e.write),validate:e.feature.validate.bind(e.feature),transaction:e.write.transaction.bind(e.write)}}}function A(e,t){e.feature?.unregisterField?.(t)}function k(e,t){e.feature?.unregisterPrefix?.(t)}export{m as a,f as b,g as c,B as d,v as e,x as f,M as g,w as h,T as i,A as j,k};
2
+ //# sourceMappingURL=chunk-EY44ZBGC.js.map
@@ -0,0 +1,2 @@
1
+ import{b as Vt,c as _t,d as I,e as Nt,h as U}from"./chunk-UIKO6GGW.js";import{c as Wt}from"./chunk-JKYECJH5.js";import{a as B,b as jt,c as E,d as j,e as Ht,f as y,g as V,h as F,i as Ut,k as zt,l as H,m as qt,n as Lt}from"./chunk-IMMFFTXE.js";function Kt(s){let{path:t,getFieldConfig:e,masks:i}=s,r=e(t)?.mask;if(r)return typeof r=="string"?i?.[r]:r}function $t(s){let{state:t,path:e,value:i,isHidden:r,isRequired:n,isDirty:o,isValidating:a}=s,c=e;return{value:i,error:t.errors[c],touched:!!t.touched[c],isHidden:r,isRequired:n,isDirty:o,isValidating:a}}var M=Symbol.for("bit-form.framework-store-api");var R=Symbol.for("bit-form.hooks-api");var z=class{constructor(t){this.baselineValues=B(t)}baselineValues;baselineSnapshot;getValues(){return this.baselineSnapshot||(this.baselineSnapshot=Object.freeze(B(this.baselineValues))),this.baselineSnapshot}setValues(t){this.baselineValues=B(t),this.baselineSnapshot=void 0}};var q=class{constructor(t,e){this.getComputedEntries=t;this.onError=e}equalityCache=new Map;reverseDepsCache=null;childDepsIndex=null;validatedEntriesSignature=null;validatedEntriesRef=null;orderedAllEntriesCache=null;orderedIndexByPathCache=null;isCacheableScalar(t){return t===null||typeof t!="object"&&typeof t!="function"}invalidateReverseDeps(){this.reverseDepsCache=null,this.childDepsIndex=null,this.orderedAllEntriesCache=null,this.validatedEntriesSignature=null,this.validatedEntriesRef=null,this.orderedIndexByPathCache=null,this.equalityCache.clear()}apply(t,e){let i=this.getComputedEntries();if(i.length===0)return t;this.ensureEntriesAreValid(i);let r=this.resolveEntriesToRun(i,e);if(r.length===0)return t;let n=t,o=new Set;for(let a of r){if(a.dependsOn.some(h=>o.has(h))){o.add(a.path);continue}let c;try{c=a.compute(n)}catch(h){this.onError?.(h,a.path),o.add(a.path);continue}let u=y(n,a.path),l=this.equalityCache.get(a.path),d,p=this.isCacheableScalar(u)&&this.isCacheableScalar(c);p&&l&&l.current===u&&l.next===c?d=l.equal:(d=j(u,c),p?this.equalityCache.set(a.path,{current:u,next:c,equal:d}):this.equalityCache.delete(a.path)),d||(n=V(n,a.path,c))}return n}getReverseDependencies(t){if(this.reverseDepsCache)return this.reverseDepsCache;let e=new Map;for(let r of t)for(let n of r.dependsOn){let o=e.get(n);o||(o=new Set,e.set(n,o)),o.add(r.path)}let i=new Map;for(let r of e.keys()){let n=r.split(".");for(let o=1;o<n.length;o++){let a=n.slice(0,o).join("."),c=i.get(a);c||(c=new Set,i.set(a,c)),c.add(r)}}return this.reverseDepsCache=e,this.childDepsIndex=i,e}resolveEntriesToRun(t,e){if(!e||e.length===0||e.includes("*"))return this.getOrderedAllEntries(t);let i=this.getReverseDependencies(t),r=new Set,n=[...e],o=0;for(;o<n.length;){let l=n[o++],d=this.getDependentsForPath(i,l);if(d)for(let p of d)r.has(p)||(r.add(p),n.push(p))}if(r.size===0)return[];let a=this.getOrderedAllEntries(t),c=this.getOrderedIndexByPath(t,a),u=[];return r.forEach(l=>{let d=c.get(l);if(d===void 0)return;let p=a[d];p&&u.push({index:d,entry:p})}),u.sort((l,d)=>l.index-d.index),u.map(l=>l.entry)}orderEntries(t){if(t.length<=1)return t;let e=new Map(t.map(a=>[a.path,a])),i=new Map,r=new Map;t.forEach(a=>i.set(a.path,0)),t.forEach(a=>{a.dependsOn.forEach(c=>{if(!e.has(c))return;let u=r.get(c)??new Set;u.has(a.path)||(u.add(a.path),r.set(c,u),i.set(a.path,(i.get(a.path)??0)+1))})});let n=t.filter(a=>(i.get(a.path)??0)===0).map(a=>a.path),o=[];for(;n.length>0;){let a=n.shift();o.push(a);let c=r.get(a);c&&c.forEach(u=>{let l=(i.get(u)??0)-1;i.set(u,l),l===0&&n.push(u)})}if(o.length!==t.length)throw new Error("BitStore: cyclic computed dependencies detected. Check computedDependsOn definitions.");return o.map(a=>e.get(a))}getOrderedAllEntries(t){let e=this.createEntriesSignature(t);if(this.orderedAllEntriesCache&&this.orderedAllEntriesCache.signature===e)return this.orderedAllEntriesCache.ordered;let i=this.orderEntries(t);return this.orderedAllEntriesCache={signature:e,ordered:i},i}getOrderedIndexByPath(t,e){let i=this.createEntriesSignature(t);if(this.orderedIndexByPathCache&&this.orderedIndexByPathCache.signature===i)return this.orderedIndexByPathCache.indexByPath;let r=new Map;return e.forEach((n,o)=>{r.set(n.path,o)}),this.orderedIndexByPathCache={signature:i,indexByPath:r},r}ensureEntriesAreValid(t){if(this.validatedEntriesRef===t)return;let e=this.createEntriesSignature(t);if(this.validatedEntriesSignature===e){this.validatedEntriesRef=t;return}t.forEach(i=>this.assertDependencies(i)),this.invalidateReverseDeps(),this.validatedEntriesSignature=e,this.validatedEntriesRef=t}createEntriesSignature(t){return t.map(e=>`${e.path}:${e.dependsOn.join(",")}`).join("|")}getDependentsForPath(t,e){let i=new Set,r=a=>{let c=t.get(a);c&&c.forEach(u=>i.add(u))};r(e);let n=e.split(".");for(;n.length>1;)n.pop(),r(n.join("."));let o=this.childDepsIndex?.get(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.`)}};var L=class{dirtyPaths=new Set;dirtyPathIndex=new Set;dirtyPrefixRefCount=new Map;childrenByPrefix=new Map;updateForPath(t,e,i){this.removeDirtyChildren(t);let r=y(e,t),n=y(i,t);return E(r,n)?this.removeDirtyPath(t):this.addDirtyPath(t),this.dirtyPaths.size>0}rebuild(t,e){return this.dirtyPaths=Ht(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((this.dirtyPrefixRefCount.get(i)??0)>0)return!0;e=t.lastIndexOf(".",e-1)}return!1}buildDirtyValues(t){if(this.dirtyPaths.size===0)return{};let e=[],i=[...this.dirtyPaths].sort(),r=new Set,n=new Set,o=a=>{let c=a.lastIndexOf(".");for(;c>-1;){if(n.has(a.slice(0,c)))return!0;c=a.lastIndexOf(".",c-1)}return!1};for(let a of i){if(o(a))continue;let c=a.match(/^(.+)\.\d+/);if(c){let u=c[1];if(r.has(u))continue;r.add(u);let l=y(t,u);e.push([u,l]),n.add(u)}else{let u=y(t,a);e.push([a,u]),n.add(a)}}return e.length===0?{}:F({},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,(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,(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=(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=>{this.childrenByPrefix.get(e)?.delete(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)}};var _=class{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()}};function ni(s){return s.replace(/\.+$/g,"")}function A(s){return ni(s.trim())}function x(s,t){let e=A(t);return e.length===0?!1:s===e||s.startsWith(`${e}.`)}function C(s,t){return A(t===void 0?s:`${s}.${t}`)}var N=class{fieldConfigs=new Map;scopeFieldsIndex=null;computedEntriesCache=null;normalizerEntriesCache=null;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=e.get(i.scope)??new Set;n.add(r),e.set(i.scope,n)}),this.scopeFieldsIndex=e}return Array.from(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:e.normalizeDependsOn?.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=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:e.normalizeDependsOn?.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))}};var W=class{constructor(t,e){this.getFieldConfig=t;this.onConditionError=e}dependencies=new Map;hiddenFields=new Set;conditionalVisibilityPaths=new Set;requiredPathsByDependency=new Map;requiredConditionalPaths=new Set;requiredEvaluationVersion=0;requiredEvaluationCache=new Map;getHiddenFields(){return this.hiddenFields}onRegister(t,e,i){let r=!!e.conditional?.showIf,n=e.conditional?.dependsOn;if(n){if(this.wouldCreateCycle(t,n)){let o=new Error(`Circular dependency detected: "${t}" \u2192 [${n.join(", ")}]`);return this.onConditionError?.({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&&e.conditional?.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),i?.preserveIncomingDependents||this.dependencies.delete(t),this.requiredEvaluationVersion+=1,this.requiredEvaluationCache.clear(),this.requiredConditionalPaths.delete(t),e?.conditional?.dependsOn?.forEach(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(this.dependencies.get(t)?.size??0)>0}isRequired(t,e){let i=this.getFieldConfig(t);if(!i||this.isHidden(t)||!i.conditional?.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){this.onConditionError?.({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=y(t,i);this.isEmpty(n)&&(e[i]=r.conditional?.requiredMessage??"required field")}}),e}evaluateAll(t){this.conditionalVisibilityPaths.forEach(e=>{this.evaluateFieldCondition(e,t)})}updateDependencies(t,e,i){let r=new Set,n=new Set,o=new Set,a=[t],c=new Set;for(;a.length>0;){let u=a.shift();if(c.has(u))continue;c.add(u);let l=this.dependencies.get(u);l&&l.forEach(d=>{r.add(d);let p=this.isHidden(d),h=this.isRequired(d,e);this.evaluateFieldCondition(d,i);let g=this.isHidden(d),v=this.isRequired(d,i);p!==g&&n.add(d),h!==v&&o.add(d),a.push(d)})}return{affectedFields:Array.from(r),visibilityChanged:Array.from(n),requiredChanged:Array.from(o)}}evaluateFieldCondition(t,e){let r=this.getFieldConfig(t)?.conditional?.showIf;if(r)try{r(e)?this.hiddenFields.delete(t):this.hiddenFields.add(t)}catch(n){this.onConditionError?.({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}};var K=class{catalog=new N;conditions;constructor(t){this.conditions=new W(e=>this.catalog.get(e),t)}getFieldConfig(t){return this.catalog.get(t)}forEachFieldConfig(t){this.catalog.forEach((e,i)=>t(e,i))}hasFieldConfig(t){return this.catalog.has(t)}getHiddenFields(){return this.conditions.getHiddenFields()}register(t,e,i){let r=this.catalog.get(t);r&&this.conditions.onUnregister(t,r,{preserveIncomingDependents:!0}),this.catalog.set(t,e),!(this.conditions.onRegister(t,e,i)||!r)&&(this.catalog.set(t,r),this.conditions.onRegister(t,r,i))}unregister(t){let e=this.catalog.delete(t);this.conditions.onUnregister(t,e)}unregisterPrefix(t){let e=[],i=A(t);return i.length===0||(this.catalog.forEach((r,n)=>{x(n,i)&&e.push([n,r])}),e.forEach(([r,n])=>{this.catalog.delete(r),this.conditions.onUnregister(r,n)})),e}isHidden(t){return this.conditions.isHidden(t)}hasDependents(t){return this.conditions.hasDependents(t)}isRequired(t,e){return this.conditions.isRequired(t,e)}getRequiredErrors(t){return this.conditions.getRequiredErrors(t)}evaluateAll(t){this.conditions.evaluateAll(t)}updateDependencies(t,e,i){return this.conditions.updateDependencies(t,e,i)}getScopeFields(t){return this.catalog.getScopeFields(t)}getComputedEntries(){return this.catalog.getComputedEntries()}getTransformEntries(){return this.catalog.getTransformEntries()}getNormalizerEntries(){return this.catalog.getNormalizerEntries()}invalidateIndexes(){this.catalog.invalidateIndexes()}};function oi(){return`bit-form-${Math.random().toString(36).slice(2,9)}`}function ai(s){typeof console<"u"&&typeof console.error=="function"&&console.error(s)}function Jt(s={}){let t=s.initialValues??{},e=s.validation,i=s.history,r=s.name?`bit-form:${s.name}:draft`:"bit-form:draft",n=s.onUnhandledError??ai,o=s.persist?.onError,a={enabled:s.persist?.enabled??!1,key:s.persist?.key??r,storage:s.persist?.storage,autoSave:s.persist?.autoSave??!0,debounceMs:s.persist?.debounceMs??300,mode:s.persist?.mode??"values",serialize:s.persist?.serialize??JSON.stringify,deserialize:s.persist?.deserialize??(c=>JSON.parse(c)),onError:c=>{if(o){o(c);return}n(c,"persist")}};return{name:s.name,initialValues:B(t),resolver:e?.resolver,validationDelay:e?.delay??300,history:{enabled:i?.enabled??!1,limit:i?.limit??50},masks:s.masks,fields:s.fields,devTools:s.devTools,persist:a,idFactory:s.idFactory??oi,plugins:s.plugins??[],scheduler:s.scheduler,subscriptionCacheSize:s.subscriptionCacheSize,trackedSubscriptions:s.trackedSubscriptions??!1,bus:s.bus,onUnhandledError:n}}function $(s,t){if((!s||s.length===0)&&(!t||t.length===0))return;let e=new Set(s??[]);return t?.forEach(i=>e.add(i)),Array.from(e)}function li(s){let t=s?.includes("*")??!1,e=new Set(s??[]),i=new Set;for(let r of e){i.add(r);let n=r.lastIndexOf(".");for(;n>-1;)i.add(r.slice(0,n)),n=r.lastIndexOf(".",n-1)}return r=>{if(!s||s.length===0||t||e.has(r)||i.has(r))return!0;let n=r.lastIndexOf(".");for(;n>-1;){if(e.has(r.slice(0,n)))return!0;n=r.lastIndexOf(".",n-1)}return!1}}function ci(s,t){if(!t||t.length===0||t.includes("*"))return s;let e=li(t);return s.filter(i=>i.dependsOn.some(r=>e(r)))}function di(s){if(s.length<=1)return{orderedEntries:[...s],cyclePaths:[]};let t=new Map(s.map(a=>[a.path,a])),e=new Map,i=new Map,r=new Map(s.map((a,c)=>[a.path,c]));s.forEach(a=>e.set(a.path,0)),s.forEach(a=>{a.dependsOn.forEach(c=>{if(c===a.path||!t.has(c))return;let u=i.get(c)??new Set;u.has(a.path)||(u.add(a.path),i.set(c,u),e.set(a.path,(e.get(a.path)??0)+1))})});let n=s.filter(a=>(e.get(a.path)??0)===0).map(a=>a.path),o=[];for(;n.length>0;){n.sort((u,l)=>(r.get(u)??0)-(r.get(l)??0));let a=n.shift();o.push(a);let c=i.get(a);c&&c.forEach(u=>{let l=(e.get(u)??0)-1;e.set(u,l),l===0&&n.push(u)})}if(o.length!==s.length){let a=s.filter(c=>(e.get(c.path)??0)>0).map(c=>c.path);return{orderedEntries:o.map(c=>t.get(c)),cyclePaths:a}}return{orderedEntries:o.map(a=>t.get(a)),cyclePaths:[]}}function J(s){let{values:t,changedPaths:e,normalizerEntries:i,applyComputed:r,onError:n}=s,o=di(ci(i,e)),{orderedEntries:a,cyclePaths:c}=o;if(c.length>0&&n?.(new Error(`BitStore: cyclic normalizer dependencies detected. Check normalizeDependsOn definitions for: ${c.join(", ")}.`),c[0]??"*"),a.length===0)return r(t,e);let u=[],l=t;for(let p of a){let h=y(l,p.path),g;try{g=p.normalize(h,l)}catch(v){n?.(v,p.path);continue}E(h,g)||(u.push([p.path,g]),l=V(l,p.path,g))}let d=$(e,u.map(([p])=>p));return r(l,d)}function Yt(s){let{values:t,sourceValues:e,transformEntries:i,onError:r}=s;if(i.length===0)return t;let n=t,o=e;for(let[a,c]of i){let u=y(n,a),l;try{l=c(u,o)}catch(d){r?.(d,a);continue}E(u,l)||(n=V(n,a,l),o=V(o,a,l))}return n}var Y=class{effects;constructor(t){this.effects=t.getAll()}attachStorePort(t){this.effects.forEach(e=>e.attachStorePort?.(t))}initialize(){this.effects.forEach(t=>t.initialize?.())}onStateUpdated(t,e){this.effects.forEach(i=>i.onStateUpdated?.(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{e.onFieldChange?.(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)this.effects[t].destroy?.()}};var G=class{constructor(t,e,i=!0,r){this.storeId=t;this.bus=e;this.enableBusDispatch=i;this.storeBusPort=r}storeBusPort;attachStorePort(t){this.storeBusPort=t,this.enableBusDispatch&&(this.bus.stores[this.storeId]=t)}initialize(){!this.enableBusDispatch||!this.storeBusPort||(this.bus.stores[this.storeId]=this.storeBusPort)}onStateUpdated(t){this.enableBusDispatch&&this.bus.dispatch(this.storeId,t)}destroy(){this.enableBusDispatch&&delete this.bus.stores[this.storeId]}};var X=class{effects=new Map;register(t){this.effects.set(t.name,t)}getAll(){return Array.from(this.effects.values())}};var Q=class{constructor(t){this.persistManager=t}onStateUpdated(t,e){e&&this.persistManager.queueSave()}restorePersisted(){return this.persistManager.restore()}savePersistedNow(){return this.persistManager.saveNow()}clearPersisted(){return this.persistManager.clear()}destroy(){this.persistManager.destroy()}};var Z=class{constructor(t){this.pluginManager=t}initialize(){this.pluginManager.setupAll()}beforeValidate(t){return this.pluginManager.beforeValidate(t)}afterValidate(t){return this.pluginManager.afterValidate(t)}beforeSubmit(t){return this.pluginManager.beforeSubmit(t)}afterSubmit(t){return this.pluginManager.afterSubmit(t)}onFieldChange(t){this.pluginManager.onFieldChange(t)}reportOperationalError(t){return this.pluginManager.reportError(t.source,t.error,t.payload)}destroy(){this.pluginManager.destroy()}};function ui(){if(typeof globalThis>"u")return;let s;try{s=globalThis.localStorage??void 0}catch{return}if(s)return{getItem:t=>s.getItem(t),setItem:(t,e)=>s.setItem(t,e),removeItem:t=>s.removeItem(t)}}var tt=class{constructor(t,e,i,r,n={}){this.config=t;this.getValues=e;this.getDirtyValues=i;this.applyRestoredValues=r;this.callbacks=n}timer;getStorage(){return this.config.storage||ui()}canPersist(){return!!(this.config.enabled&&this.config.key&&this.getStorage())}handleError(t){this.callbacks.onError?.(t),this.config.onError?.(t)}async persistPayload(){let t=this.getStorage();if(!t)return;let e=this.config.mode==="dirtyValues"?this.getDirtyValues():this.getValues(),i=this.config.serialize(e);await t.setItem(this.config.key,i)}async saveNow(){if(this.canPersist())try{await this.persistPayload()}catch(t){throw this.handleError(t),t}}queueSave(){!this.canPersist()||!this.config.autoSave||(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.callbacks.onAutoSaveStart?.(),this.saveNow().then(()=>{this.callbacks.onAutoSaveSuccess?.()}).catch(t=>{this.callbacks.onAutoSaveError?.(t)})},this.config.debounceMs))}async restore(){if(!this.canPersist())return!1;let t=this.getStorage();if(!t)return!1;try{let e=await t.getItem(this.config.key);if(!e)return!1;let i=this.config.deserialize(e);return!i||typeof i!="object"?!1:(this.applyRestoredValues(i),!0)}catch(e){return this.handleError(e),!1}}async clear(){if(!this.canPersist())return;let t=this.getStorage();if(t)try{await t.removeItem(this.config.key)}catch(e){this.handleError(e)}}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=void 0)}};var et=class{constructor(t,e){this.plugins=t;this.contextFactory=e}teardownFns=[];notifyingError=!1;pendingErrorQueue=[];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=i.hooks?.onFieldChange;if(r)try{let n=r(t,e);Promise.resolve(n).catch(o=>{this.reportError("onFieldChange",o,t,i.name)})}catch(n){this.reportError("onFieldChange",n,t,i.name)}})}async reportError(t,e,i,r){let n=this.getContext();if(this.pendingErrorQueue.push({source:t,pluginName:r,error:e,event:i,values:n.getState().values,state:n.getState()}),!this.notifyingError){this.notifyingError=!0;try{for(;this.pendingErrorQueue.length>0;){let o=this.pendingErrorQueue.shift();if(!o)break;for(let a of this.plugins){let c=a.hooks?.onError;if(c)try{await c(o,n)}catch{}}}}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=r.hooks?.[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}};var Ft=typeof globalThis<"u"?globalThis:typeof global<"u"?global:window;Ft.__BIT_FORM__||(Ft.__BIT_FORM__={stores:{},listeners:new Set,dispatch(s,t){this.listeners.forEach(e=>e(s,t))},subscribe(s){return this.listeners.add(s),()=>{this.listeners.delete(s)}}});var wt=Ft.__BIT_FORM__,pi={stores:{},listeners:new Set,dispatch:()=>{},subscribe:()=>()=>{}};function At(){return pi}function hi(){let s=new Set;return{stores:{},listeners:s,dispatch(t,e){s.forEach(i=>i(t,e))},subscribe(t){return s.add(t),()=>s.delete(t)}}}function fi(s){return s.bus?!0:typeof s.devTools=="boolean"?s.devTools:s.devTools&&typeof s.devTools=="object"?s.devTools.enabled!==!1:!1}function Gt(s){let{storeId:t,storeBusPort:e,config:i,getState:r,getConfig:n,getValues:o,getDirtyValues:a,applyPersistedValues:c,setPersistMetadata:u}=s,l=new tt(i.persist,o,a,c,{onAutoSaveStart:()=>u?.({isSaving:!0,error:null}),onAutoSaveSuccess:()=>u?.({isSaving:!1,error:null}),onAutoSaveError:b=>u?.({isSaving:!1,error:b instanceof Error?b:new Error(String(b))}),onError:b=>i.onUnhandledError(b,"persist")}),d=new et([...i.plugins],()=>({storeId:t,getState:()=>r(),getConfig:()=>n()})),p=fi(i),h=typeof process<"u"&&typeof process.env<"u"&&process.env.VITEST==="true",g=p?i.bus??(h?At():wt):At(),v=new X,f=new Q(l);v.register({name:"persist",onStateUpdated:(b,O)=>f.onStateUpdated(b,O),restorePersisted:()=>f.restorePersisted(),savePersistedNow:()=>f.savePersistedNow(),clearPersisted:()=>f.clearPersisted(),destroy:()=>f.destroy()});let m=new Z(d);v.register({name:"plugins",initialize:()=>m.initialize(),beforeValidate:b=>m.beforeValidate(b),afterValidate:b=>m.afterValidate(b),beforeSubmit:b=>m.beforeSubmit(b),afterSubmit:b=>m.afterSubmit(b),onFieldChange:b=>m.onFieldChange(b),reportOperationalError:b=>m.reportOperationalError(b),destroy:()=>m.destroy()});let T=new G(t,g,p,e);v.register({name:"bus",attachStorePort:b=>T.attachStorePort(b),initialize:()=>T.initialize(),onStateUpdated:b=>T.onStateUpdated(b),destroy:()=>T.destroy()});let P=new Y(v);return P.initialize(),P}function S(s,t,e){return{kind:"state.patch",partialState:s,changedPaths:t,skipComputed:e?.skipComputed}}function It(s){return{kind:"field.touchMany",paths:s}}function w(s){return{kind:"form.persistMeta",patch:s}}function it(s,t){return{kind:"validation.commit",errors:s,isValid:t}}async function Xt(s){let{dispatch:t,effects:e}=s;t(w({isRestoring:!0,error:null}));try{return await e.restorePersisted()}catch(i){return t(w({isRestoring:!1,error:i instanceof Error?i:new Error(String(i))})),!1}finally{t(w({isRestoring:!1}))}}async function Qt(s){let{dispatch:t,effects:e}=s,i=null;t(w({isSaving:!0,error:null}));try{await e.savePersistedNow()}catch(r){i=r instanceof Error?r:new Error(String(r))}finally{t(w({isSaving:!1,error:i}))}}async function Zt(s){let{dispatch:t,effects:e}=s,i=null;t(w({isSaving:!0,error:null}));try{await e.clearPersisted()}catch(r){i=r instanceof Error?r:new Error(String(r))}finally{t(w({isSaving:!1,error:i}))}}function te(s){let{values:t,state:e,initialValues:i,validation:r,fieldRegistry:n,dirtyManager:o,dispatch:a,saveHistorySnapshot:c}=s,u=B(jt(i,t));r.cancelAll(),n.evaluateAll(u);let l=o.rebuild(u,i);a(S({values:u,errors:{},touched:{},isValidating:{},persist:{...e.persist,error:null},isValid:!1,isDirty:l})),c(),r.validate()}function ee(s){let{state:t,path:e}=s,i=`${e}.`,r={...t.errors},n={...t.touched},o=!1;for(let a of Object.keys(r))(a===e||a.startsWith(i))&&(delete r[a],o=!0);for(let a of Object.keys(n))(a===e||a.startsWith(i))&&(delete n[a],o=!0);return o?{errors:r,touched:n}:null}function rt(s){let t=[],e=new Map,i=new Set(s.map(a=>a.path));for(let a of s)if(e.has(a.path)||e.set(a.path,new Set),a.dependsOn)for(let c of a.dependsOn)i.has(c)&&e.get(a.path).add(c);let r=new Set,n=new Set,o=(a,c)=>{r.add(a),n.add(a),c.push(a);let u=e.get(a)||new Set;for(let l of u)if(r.has(l)){if(n.has(l)){let d=c.indexOf(l),p=[...c.slice(d),l];return{cycle:p,paths:Array.from(e.keys()).filter(h=>p.includes(h)),message:`Circular dependency detected: ${p.join(" \u2192 ")}. Check your computed field definitions.`}}}else{let d=o(l,[...c]);if(d)return d}return n.delete(a),null};for(let a of e.keys())if(!r.has(a)){let c=o(a,[]);c&&!t.some(u=>u.message===c.message)&&t.push(c)}return t}function ie(s){return!!(s?.computed||s?.normalize)}function re(s){let{path:t,config:e,state:i,fieldRegistry:r,subscriptions:n,validationCleanupField:o,stateReader:a,invalidateFieldIndexes:c,dispatch:u,getState:l,onUnhandledError:d}=s,p=r.getFieldConfig(t),h=p?.validation?.asyncValidate,g=e.validation?.asyncValidate,v=p?.validation?.asyncValidateOn??"blur",f=e.validation?.asyncValidateOn??"blur";p&&h&&(g!==h||f!==v)&&o(t);let T=!!(p?.computed||e.computed),P=ie(p)||ie(e);if(r.register(t,e,i.values),c(),T){let O=rt(r.getComputedEntries());if(O.length>0){p?r.register(t,p,i.values):r.unregister(t),c(),n.invalidatePathExpansionCache(t),a.invalidatePath(t),d(new Error(O[0].message),"computed");return}}n.invalidatePathExpansionCache(t),a.invalidatePath(t),P&&u(S({values:i.values},["*"]));let b=l();e.scope&&n.notify(b,[I(e.scope)]),r.isHidden(t)&&n.notify(b,[t])}function se(s){let{path:t,state:e,hasStaticConfig:i,fieldRegistry:r,subscriptions:n,validationCleanupField:o,invalidateFieldIndexes:a,dispatch:c}=s;if(i)return;let u=r.getFieldConfig(t);o(t),r.unregister(t),a(),n.invalidatePathExpansionCache(t),u?.scope&&n.notify(e,[I(u.scope)]);let l=ee({state:e,path:t});l&&c(S({errors:l.errors,touched:l.touched}))}function st(s){let{prefix:t,state:e,fieldRegistry:i,subscriptions:r,validationCleanupPrefix:n,invalidateFieldIndexes:o,dispatch:a}=s;n(t);let c=i.unregisterPrefix(t);o(),r.invalidatePathExpansionCache(t),new Set(c.map(([,h])=>h.scope).filter(h=>!!h)).forEach(h=>{r.notify(e,[I(h)])});let l={...e.errors},d={...e.touched},p=!1;for(let[h]of c)l[h]&&(delete l[h],p=!0),d[h]&&(delete d[h],p=!0);p&&a(S({errors:l,touched:d}))}var nt=class{constructor(t,e=500){this.getState=t;this.MAX_PATH_EXPANSION_CACHE_SIZE=e}listeners=new Set;pathScopedSubscriptions=new Map;pathSelectorIndex=new Map;pathExpansionCache=new Map;subscriptionSeenVersion=new Map;notifyVersion=0;MAX_PATH_EXPANSION_CACHE_SIZE;cacheHits=0;cacheMisses=0;cacheEvictions=0;subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}subscribeSelector(t,e,i,r){let n=t(this.getState()),o={notify:c=>{let u=t(c);r(n,u)||(n=u,e(u))}},a=this.normalizeSubscriptionPaths(i.paths);return this.pathScopedSubscriptions.set(o,a),a.forEach(c=>{this.forEachIndexPath(c,u=>{let l=this.pathSelectorIndex.get(u)??new Set;l.add(o),this.pathSelectorIndex.set(u,l)})}),i.emitImmediately&&e(n),()=>{this.subscriptionSeenVersion.delete(o);let c=this.pathScopedSubscriptions.get(o);c&&(c.forEach(u=>{this.forEachIndexPath(u,l=>{let d=this.pathSelectorIndex.get(l);d&&(d.delete(o),d.size===0&&this.pathSelectorIndex.delete(l))})}),this.pathScopedSubscriptions.delete(o))}}notify(t,e){if(this.listeners.forEach(n=>{try{n()}catch(o){console.error("Subscription listener error:",o)}}),this.pathScopedSubscriptions.size===0)return;let i=this.normalizeChangedPathIterable(e);if(i.length===0||i.includes("*")){this.pathScopedSubscriptions.forEach((n,o)=>{try{o.notify(t)}catch(a){console.error("Path subscription notify error:",a)}});return}if(i.length===1&&this.isSimplePath(i[0])){this.collectSubscribersForSingleChangedPath(i[0]).forEach(o=>{try{o.notify(t)}catch(a){console.error("Path subscription notify error:",a)}});return}this.collectSubscribersForChangedPaths(i).forEach(n=>{try{n.notify(t)}catch(o){console.error("Path subscription notify error:",o)}})}destroy(){this.listeners.clear(),this.pathScopedSubscriptions.clear(),this.pathSelectorIndex.clear(),this.pathExpansionCache.clear(),this.subscriptionSeenVersion.clear()}getPathExpansionCacheStats(){return{cacheSize:this.pathExpansionCache.size,cacheLimit:this.MAX_PATH_EXPANSION_CACHE_SIZE,cacheHits:this.cacheHits,cacheMisses:this.cacheMisses,cacheEvictions:this.cacheEvictions}}getActiveSubscribersCount(){return this.pathScopedSubscriptions.size}invalidatePathExpansionCache(t){if(!t){this.pathExpansionCache.clear();return}let e=A(t);if(e.length===0){this.pathExpansionCache.clear();return}for(let i of this.pathExpansionCache.keys())(x(i,e)||x(e,i))&&this.pathExpansionCache.delete(i)}normalizeSubscriptionPaths(t){if(!t||t.length===0)return[];let e=new Set,i=[];for(let r of t){let n=r.trim();n.length===0||e.has(n)||(e.add(n),i.push(n))}return i}normalizeChangedPathIterable(t){if(!t)return[];let e=new Set,i=[];for(let r of t){let n=r.trim();n.length===0||e.has(n)||(e.add(n),i.push(n))}return i}collectSubscribersForChangedPaths(t){let e=[],i=++this.notifyVersion,r=n=>{let o=this.pathSelectorIndex.get(n);o&&o.forEach(a=>{(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=>{(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)}};var ot=class{constructor(t){this.store=t}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)),this.store.unregisterPrefix?.(C(t));let i=y(this.store.getState().values,t)??[];this.commitArrayMutationWithFieldPipeline({path:t,nextArray:[e,...i],meta:{origin:"array",operation:"prepend"},reindex:r=>r+1})}insertItem(t,e,i){let r=this.getCurrentArrayLength(t),n=Math.max(0,Math.min(e,r));if(this.withPathIds(t,c=>{let u=[...c];return u.splice(n,0,this.store.createArrayItemId(t,n)),u}),this.store.unregisterPrefix)for(let c=n;c<r;c++)this.store.unregisterPrefix(C(t,c));let a=[...y(this.store.getState().values,t)??[]];a.splice(n,0,i),this.commitArrayMutationWithFieldPipeline({path:t,nextArray:a,meta:{origin:"array",operation:"insert",index:n},reindex:c=>c<n?c:c+1})}removeItem(t,e){let i=this.store.getState(),r=y(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=y(r.values,t);if(!Array.isArray(n)||e<0||e>=n.length||i<0||i>=n.length)return;this.withPathIds(t,a=>{let c=[...a];return[c[e],c[i]]=[c[i],c[e]],c});let o=[...n];[o[e],o[i]]=[o[i],o[e]],this.store.unregisterPrefix&&(this.store.unregisterPrefix(C(t,e)),this.store.unregisterPrefix(C(t,i))),this.commitArrayMutationWithFieldPipeline({path:t,nextArray:o,meta:{origin:"array",operation:"swap",from:e,to:i},reindex:a=>a===e?i:a===i?e:a})}moveItem(t,e,i){let r=this.store.getState(),n=y(r.values,t);if(!Array.isArray(n)||e<0||e>=n.length||i<0||i>=n.length)return;this.withPathIds(t,c=>{let u=[...c],[l]=u.splice(e,1);return u.splice(i,0,l),u});let o=[...n],[a]=o.splice(e,1);if(o.splice(i,0,a),this.store.unregisterPrefix){let c=Math.min(e,i),u=Math.max(e,i);for(let l=c;l<=u;l+=1)this.store.unregisterPrefix(C(t,l))}this.commitArrayMutationWithFieldPipeline({path:t,nextArray:o,meta:{origin:"array",operation:"move",from:e,to:i},reindex:c=>c===e?i:e<i&&c>e&&c<=i?c-1:e>i&&c>=i&&c<e?c+1:c})}replaceItems(t,e){this.store.unregisterPrefix?.(C(t)),this.pathIds.set(t,e.map((i,r)=>this.store.createArrayItemId(t,r))),this.commitArrayMutationWithFieldPipeline({path:t,nextArray:e,meta:{origin:"array",operation:"replace"},reindex:i=>i<e.length?i:null})}clearItems(t){this.pathIds.set(t,[]),this.store.unregisterPrefix&&this.store.unregisterPrefix(C(t)),this.commitArrayMutationWithFieldPipeline({path:t,nextArray:[],meta:{origin:"array",operation:"clear"},reindex:()=>null})}mutateArrayWithSetField(t,e,i){let r=y(this.store.getState().values,t)||[];this.store.setFieldWithMeta(t,e(r),i),this.store.internalSaveSnapshot()}withPathIds(t,e){let i=this.getCurrentArrayLength(t),r=this.ensureIds(t,i);this.pathIds.set(t,e(r))}ensureIds(t,e){let i=this.pathIds.get(t)??[];if(i.length===e)return i;if(i.length<e){let n=[...i];for(let o=i.length;o<e;o+=1)n.push(this.store.createArrayItemId(t,o));return this.pathIds.set(t,n),n}let r=i.slice(0,e);return this.pathIds.set(t,r),r}getCurrentArrayLength(t){let e=y(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=zt(o,e,n);this.store.remapValidationPaths?.(e,n),this.store.dispatch(S({errors:a.errors,touched:a.touched,isValidating:a.isValidating},[e])),this.store.internalSaveSnapshot()}};var at=class{constructor(t,e,i){this.getState=t;this.dispatch=e;this.reportError=i}reportInvalidInput(t,e){this.reportError?.(new Error(e===void 0?t:`${t}: ${String(e)}`))}setError(t,e){if(!t||typeof t!="string"){this.reportInvalidInput("setError received an invalid path",t);return}if(e!==void 0&&typeof e!="string"){this.reportInvalidInput("setError received an invalid message",e);return}let i={...this.getState().errors,[t]:e};e===void 0&&delete i[t],this.dispatch(S({errors:i}))}setErrors(t){if(!t||typeof t!="object"){this.reportInvalidInput("setErrors received an invalid payload");return}let e={};Object.entries(t).forEach(([i,r])=>{if(!i){this.reportInvalidInput("setErrors ignored an empty path");return}if(r!==void 0&&typeof r!="string"){this.reportInvalidInput("setErrors ignored a non-string message",i);return}e[i]=r}),this.dispatch(S({errors:{...this.getState().errors,...e}}))}setServerErrors(t,e){let i=e?.arrayStrategy??"first",r=e?.joinSeparator??"; ",n={};for(let[o,a]of Object.entries(t)){if(!o){this.reportInvalidInput("setServerErrors ignored an empty path");continue}if(Array.isArray(a)){let c=a.filter(u=>typeof u=="string"&&u.length>0);if(c.length===0)continue;n[o]=i==="join"?c.join(r):c[0];continue}n[o]=a}this.setErrors(n)}};var lt=class{constructor(t,e,i){this.fieldMetadataProvider=t;this.getState=e;this.isPathDirty=i}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]}};function ne(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp)}function oe(s,t){let e=[],i=new Map,r=(n,o,a,c,u)=>{if(!(c&&u&&j(n,o))){if(n!==null&&typeof n=="object"&&o!==null&&typeof o=="object"){let l=i.get(n);if(l?.has(o))return;l?l.add(o):i.set(n,new Set([o]))}try{if(ne(n)&&ne(o)&&c&&u){let l=new Set([...Object.keys(n),...Object.keys(o)]);for(let d of l){let p=a?`${a}.${d}`:d,h=Object.prototype.hasOwnProperty.call(n,d),g=Object.prototype.hasOwnProperty.call(o,d);r(n[d],o[d],p,h,g)}return}e.push({path:a,previousValue:B(n),nextValue:B(o),hadPreviousValue:c,hasNextValue:u})}finally{if(n!==null&&typeof n=="object"&&o!==null&&typeof o=="object"){let l=i.get(n);l?.delete(o),l&&l.size===0&&i.delete(n)}}}};return r(s,t,"",!0,!0),{operations:e}}function ct(s,t,e){let i=s,r=[],n=[];for(let o of t.operations){let a=e==="undo"?o.hadPreviousValue:o.hasNextValue,c=e==="undo"?o.previousValue:o.nextValue;if(!o.path){i=a?c:{},r.length=0,n.length=0;continue}if(a){r.push([o.path,c]);continue}n.push(o.path)}return r.length>0&&(i=F(i,r)),n.length>0&&(i=Ut(i,n)),i}var dt=class{constructor(t,e){this.enableHistory=t;this.maxHistory=e}baseSnapshot=null;currentSnapshot=null;patches=[];historyIndex=-1;historySize=0;saveSnapshot(t){if(!this.enableHistory)return;if(!this.currentSnapshot||this.baseSnapshot===null){this.reset(t);return}let e=oe(this.currentSnapshot,t);if(e.operations.length!==0)for(this.historyIndex<this.historySize-1&&(this.patches.splice(this.historyIndex),this.historySize=this.historyIndex+1),this.patches.push(e),this.currentSnapshot=t,this.historyIndex+=1,this.historySize=this.historyIndex+1;this.historySize>this.getCapacity();)this.compactOldestSnapshot()}get canUndo(){return this.enableHistory?this.historyIndex>0:!1}get canRedo(){return this.enableHistory?this.historyIndex<this.historySize-1:!1}undo(){if(!this.canUndo||!this.currentSnapshot)return null;let t=this.patches[this.historyIndex-1],e=ct(this.currentSnapshot,t,"undo");return this.currentSnapshot=e,this.historyIndex-=1,e}redo(){if(!this.canRedo||!this.currentSnapshot)return null;let t=this.patches[this.historyIndex],e=ct(this.currentSnapshot,t,"redo");return this.currentSnapshot=e,this.historyIndex+=1,e}reset(t){if(!this.enableHistory){this.baseSnapshot=null,this.currentSnapshot=null,this.patches=[],this.historyIndex=-1,this.historySize=0;return}this.baseSnapshot=B(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)}};function Dt(s,t,e){if(!Object.prototype.hasOwnProperty.call(s,t))return[s,e];let r=s,n=e;return n||(r={...s},n=!0),delete r[t],[r,n]}var D=class{constructor(t){this.steps=t}async run(t){for(let e of this.steps){if(t.halted)break;await e.run(t)}}},ut=class{constructor(t){this.steps=t}run(t){for(let e of this.steps){if(t.halted)break;let i=e.run(t);if(i!=null&&typeof i.then=="function")throw new Error(`BitSyncPipelineRunner: step "${e.name}" returned a Promise. Use BitPipelineRunner for async steps.`)}}};var pt=class{constructor(t){this.store=t;this.fieldUpdatePipeline=new ut([{name:"field:clear-current-error",run:e=>this.clearCurrentError(e)},{name:"field:update-dependencies",run:e=>this.updateDependencies(e)},{name:"field:update-dirty",run:e=>this.updateDirtyState(e)},{name:"field:commit-state",run:e=>this.commitFieldState(e)},{name:"field:emit-change",run:e=>this.emitFieldChange(e)},{name:"field:trigger-validate",run:e=>this.triggerResolverValidation(e)},{name:"field:trigger-async-validate",run:e=>this.triggerAsyncValidation(e)}])}fieldUpdatePipeline;updateField(t,e,i={origin:"setField"}){let r=this.store.getState(),n=y(r.values,t),o={path:t,value:e,meta:i,previousValue:n,nextValues:V(r.values,t,e),nextErrors:r.errors,hasMutatedErrors:!1,dependencyDiff:{affectedFields:[],visibilityChanged:[],requiredChanged:[]},isDirty:!1};this.fieldUpdatePipeline.run(o)}clearCurrentError(t){[t.nextErrors,t.hasMutatedErrors]=Dt(t.nextErrors,t.path,t.hasMutatedErrors),this.store.clearFieldValidation(t.path)}updateDependencies(t){if(typeof this.store.hasDependentFields=="function"&&!this.store.hasDependentFields(t.path)){t.dependencyDiff.affectedFields.length=0,t.dependencyDiff.visibilityChanged.length=0,t.dependencyDiff.requiredChanged.length=0;return}t.dependencyDiff=this.store.updateDependencies(t.path,this.store.getState().values,t.nextValues),new Set([...t.dependencyDiff.visibilityChanged,...t.dependencyDiff.requiredChanged]).forEach(i=>{[t.nextErrors,t.hasMutatedErrors]=Dt(t.nextErrors,i,t.hasMutatedErrors),this.store.clearFieldValidation(i)})}updateDirtyState(t){t.isDirty=this.store.updateDirtyForPath(t.path,t.nextValues,this.store.getBaselineValues())}commitFieldState(t){let e=Array.from(new Set([t.path,...t.dependencyDiff.visibilityChanged,...t.dependencyDiff.requiredChanged]));this.store.dispatch(S({values:t.nextValues,errors:t.nextErrors,isDirty:t.isDirty},e))}emitFieldChange(t){this.store.emitFieldChange({path:t.path,previousValue:t.previousValue,nextValue:t.value,values:this.store.getState().values,state:this.store.getState(),meta:t.meta})}triggerResolverValidation(t){let e=Array.from(new Set([t.path,...t.dependencyDiff.visibilityChanged,...t.dependencyDiff.requiredChanged]));(this.store.config.resolver||t.dependencyDiff.visibilityChanged.length>0||t.dependencyDiff.requiredChanged.length>0)&&this.store.triggerValidation(e)}triggerAsyncValidation(t){this.store.isFieldHidden(t.path)||(typeof this.store.getFieldConfig=="function"?this.store.getFieldConfig(t.path)?.validation?.asyncValidateOn:void 0)!=="change"||this.store.handleFieldAsyncValidation(t.path,t.value)}};var ht=class{executors=new Map;register(t,e){let i=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[...this.executors.get(t)??[]].sort((i,r)=>i.phase-r.phase)}};var ft=class{constructor(t){this.store=t;this.submitPipeline=new D([{name:"submit:start",run:async e=>this.startSubmit(e)},{name:"submit:invalid",run:async e=>this.handleInvalidSubmit(e)},{name:"submit:prepare",run:e=>this.prepareSubmitValues(e)},{name:"submit:before-hooks",run:async e=>this.runBeforeSubmitHooks(e)},{name:"submit:user-handler",run:async e=>this.runSubmitHandler(e)},{name:"submit:after-hooks",run:async e=>this.runAfterSubmitHooks(e)}])}submitPipeline;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:B(this.store.getState().values),dirtyValues:{}};try{return await this.submitPipeline.run(i),i.invalid?{status:"invalid"}:{status:"submitted"}}catch(r){return i.error=r,await this.store.emitOperationalError({source:"submit",error:r}),await this.store.emitAfterSubmit({values:i.valuesToSubmit,dirtyValues:i.dirtyValues,state:this.store.getState(),success:!1,error:r}),this.store.config.onUnhandledError(r,"submit"),{status:"failed",error:r}}finally{this.store.dispatch(S({isSubmitting:!1}))}}async startSubmit(t){this.store.dispatch(S({isSubmitting:!0})),t.isValid=await this.store.validateNow()}async handleInvalidSubmit(t){if(t.isValid)return;let e=this.store.getState().errors,i={...this.store.getState().touched};Object.keys(e).forEach(r=>{i[r]=!0}),this.store.batchStateUpdates(()=>{this.store.dispatch(S({touched:i}))}),t.dirtyValues=this.store.buildDirtyValues(this.store.getState().values),t.invalid=!0,await this.store.emitAfterSubmit({values:this.store.getState().values,dirtyValues:t.dirtyValues,state:this.store.getState(),success:!1,invalid:!0}),t.halted=!0}prepareSubmitValues(t){let e=[],i=this.store.getHiddenFields();i.forEach(r=>{e.push([r,void 0])}),e.length>0&&(t.valuesToSubmit=F(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(qt(e)){this.store.setServerErrors(Lt(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(e?.rebase){this.rebaseValues(t);return}if(e?.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?F(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=B(t);this.store.setBaselineValues(t),this.store.cancelAllValidations(),this.store.evaluateAllDependencies(i),this.store.clearDirtyState(),this.store.dispatch(S({values:i,errors:{},touched:{},isValidating:{},isValid:!1,isDirty:!1},["*"])),this.store.resetHistory(i),this.store.validateNow().catch(r=>{this.store.config?.onUnhandledError(r,"rebaseValues")}),this.store.emitFieldChange({path:"*",previousValue:e,nextValue:i,values:this.store.getState().values,state:this.store.getState(),meta:{origin:"rebase"}})}applyHistoryState(t){this.store.cancelAllValidations();let e=this.store.rebuildDirtyState(t,this.store.getBaselineValues());this.store.dispatch(S({values:t,errors:{},isValid:!1,isDirty:e},["*"])),this.store.validateNow().catch(i=>{this.store.config?.onUnhandledError(i,"applyHistoryState")})}reset(){this.store.cancelAllValidations();let t=B(this.store.getBaselineValues());this.store.evaluateAllDependencies(t),this.store.clearDirtyState(),this.store.dispatch(S({values:t,errors:{},touched:{},isValidating:{},isValid:!0,isDirty:!1},["*"])),this.store.resetHistory(t)}replaceValuesInternal(t,e="replaceValues",i=["*"]){let r=this.store.getState().values,n=B(t);this.store.cancelAllValidations(),this.store.evaluateAllDependencies(n);let o=this.store.rebuildDirtyState(n,this.store.getBaselineValues());this.store.dispatch(S({values:n,errors:{},isValidating:{},isValid:!1,isDirty:o},i)),this.store.internalSaveSnapshot(),this.store.validateNow().catch(a=>{this.store.config?.onUnhandledError(a,"replaceValuesInternal")}),this.store.emitFieldChange({path:"*",previousValue:r,nextValue:n,values:this.store.getState().values,state:this.store.getState(),meta:{origin:e}})}};var mt=class{constructor(t){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,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()})}fieldUpdate;values;submitFlow;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"})}};var yt=class{constructor(t,e,i,r){this.getState=t;this.getInitialValues=e;this.getScopeFields=i;this.isPathDirty=r}getScopeStatus(t){let e=this.getScopeFields(t),i=this.getState(),r=e.some(a=>!!i.errors[a]),n=e.some(a=>this.isPathDirty(a)),o=this.getScopeErrors(t);return{hasErrors:r,isDirty:n,errors:o}}getScopeErrors(t){let e=this.getScopeFields(t),i=this.getState(),r={};for(let n of e){let o=i.errors[n];o&&(r[n]=o)}return r}};var ae=Symbol("bit.async.validation.timeout"),St=class{constructor(t){this.port=t}cancelSchedulerTimeout;abortControllers=new Map;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{}finally{this.cancelSchedulerTimeout=void 0}this.abortControllers.forEach(t=>{try{t.abort()}catch{}}),this.pendingJobs.clear(),this.abortControllers.clear()}schedulePendingJobs(){this.cancelSchedulerTimeout&&(this.cancelSchedulerTimeout(),this.cancelSchedulerTimeout=void 0);let t=Number.POSITIVE_INFINITY;for(let e of this.pendingJobs.values())e.dueAt<t&&(t=e.dueAt);Number.isFinite(t)&&(this.cancelSchedulerTimeout=this.port.schedule(()=>{this.cancelSchedulerTimeout=void 0,this.flushPendingJobs().catch(e=>{this.port.onError(e)})},Math.max(0,t-Date.now())))}async flushPendingJobs(){this.cancelSchedulerTimeout=void 0;let t=Date.now(),e=[];for(let[r,n]of this.pendingJobs.entries())n.dueAt<=t&&e.push([r,n]);if(e.length===0){this.schedulePendingJobs();return}e.forEach(([r])=>{this.pendingJobs.delete(r)});let i=await Promise.allSettled(e.map(([r,n])=>this.runJob(r,n)));for(let r of i)r.status==="rejected"&&this.port.onError(r.reason);this.schedulePendingJobs()}async runJob(t,e){if(!e.controller.signal.aborted)try{let i=e.validate(e.value,this.port.getValues());if(typeof e.timeoutMs=="number"&&e.timeoutMs>0){let o;i=Promise.race([i,new Promise(a=>{o=setTimeout(()=>a(ae),e.timeoutMs)})]).finally(()=>{o&&clearTimeout(o)})}let r=await i;if(e.controller.signal.aborted)return;let n=y(this.port.getValues(),t);if(!E(n,e.value)||r===ae)return;r!=null?this.port.setAsyncError(t,r):(this.port.clearAsyncError(t),await this.port.onValidationPassed(t))}finally{let i=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}};function k(s){for(let t in s)if(s[t]!==void 0)return!0;return!1}async function kt(s){let{scopeFields:t,store:e,asyncErrors:i}=s,r=e.getState(),n=e.config.resolver?await e.config.resolver(r.values,{scopeFields:t}):{},o=e.getState();if(t.some(d=>r.values[d]!==o.values[d]))return;let c=e.getRequiredErrors(o.values),u={...n,...c};e.getHiddenFields().forEach(d=>{delete u[d],i.delete(d)});let l={...o.errors};t.forEach(d=>{u[d]?l[d]=u[d]:i.has(d)?l[d]=i.get(d):delete l[d]}),e.dispatch(it(l,!k(l)))}var bt=class{currentValidationId=0;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()}};var Bt=class{constructor(t){this.port=t}cancelTimeout;pendingScopeFields=null;trigger(t,e){this.cancelTimeout&&(this.cancelTimeout(),this.cancelTimeout=void 0);let i=this.port.validationDelay??300,r=e?.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}};var le=Symbol("bit.async.validation.timeout");function ce(s){let{targetFields:t,currentErrors:e,allErrors:i,asyncErrors:r}=s;if(t&&t.length>0){let o=e,a=!1,c=()=>(a||(o={...e},a=!0),o);t.forEach(l=>{let d=l,p=e[d];if(i[l]!==void 0)p!==i[l]&&(c()[d]=i[l]);else if(r.has(l)){let h=r.get(l);p!==h&&(c()[d]=h)}else p!==void 0&&delete c()[d]});let u=t.every(l=>i[l]===void 0&&!r.has(l));return{committedErrors:a?o:e,result:u,mode:"scoped"}}let n={};return r.forEach((o,a)=>{n[a]=o}),Object.entries(i).forEach(([o,a])=>{a!==void 0&&(n[o]=a)}),{committedErrors:n,result:void 0,mode:"global"}}function de(s){let{targetFields:t,hiddenFields:e,getFieldConfig:i,forEachFieldConfig:r}=s,n=[];if(t&&t.length>0){for(let o of t){if(e.has(o))continue;i(o)?.validation?.asyncValidate&&n.push(o)}return n}return r&&r((o,a)=>{!o.validation?.asyncValidate||e.has(a)||n.push(a)}),n}async function ue(s){let{path:t,values:e,validationId:i,getCurrentValidationId:r,getFieldConfig:n,cancelFieldAsync:o,createAbortController:a,setAbortController:c,clearAbortController:u,setFieldValidating:l,setAsyncError:d,clearAsyncError:p}=s,h=n(t)?.validation?.asyncValidate;if(!h){p(t);return}o(t),p(t);let g=a();c(t,g),l(t,!0);try{let v=n(t)?.validation?.asyncValidateTimeout,f=h(y(e,t),e);if(typeof v=="number"&&v>0){let T;f=Promise.race([f,new Promise(P=>{T=setTimeout(()=>P(le),v)})]).finally(()=>{T&&clearTimeout(T)})}let m=await f;if(g.signal.aborted||i!==r())return;m===le||(m!=null?d(t,m):p(t))}finally{u(t,g)&&l(t,!1)}}function pe(s){let{ctx:t,deps:e}=s,i=t.options;if(i?.scope&&i.scopeFields?.length){e.store.config.onUnhandledError(new Error("validate received both 'scope' and 'scopeFields'. 'scopeFields' takes precedence."),"validation");return}if(!t.options?.scopeFields?.length&&t.options?.scope){let r=e.store.getScopeFields(t.options.scope);r.length>0&&(t.targetFields=r)}}async function he(s){let{ctx:t,deps:e}=s;await e.store.emitBeforeValidate({values:t.currentState.values,state:t.currentState,scope:t.options?.scope,scopeFields:t.targetFields})}async function fe(s){let{ctx:t,deps:e}=s,i=e.store.config.resolver?await e.store.config.resolver(t.currentState.values,{scopeFields:t.targetFields}):{},r=e.store.getRequiredErrors(t.currentState.values);t.allErrors={...i,...r},e.store.getHiddenFields().forEach(n=>{delete t.allErrors[n],e.asyncErrors.delete(n)})}async function ge(s){let{ctx:t,deps:e}=s,i=de({targetFields:t.targetFields,hiddenFields:e.store.getHiddenFields(),getFieldConfig:n=>e.store.getFieldConfig(n),forEachFieldConfig:e.store.forEachFieldConfig});if(i.length===0)return;let r=await Promise.allSettled(i.map(n=>e.runImmediateAsyncValidation(n,t.currentState.values,t.validationId)));for(let n of r)n.status==="rejected"&&e.store.config.onUnhandledError(n.reason,"validation")}function me(s){let{ctx:t,deps:e}=s,i=ce({targetFields:t.targetFields,currentErrors:t.currentState.errors,allErrors:t.allErrors,asyncErrors:e.asyncErrors});t.committedErrors=i.committedErrors,t.isValid=!k(i.committedErrors),t.result=i.mode==="scoped"?i.result:t.isValid}async function Mt(s){let{ctx:t,deps:e}=s;t.validationId!==e.getCurrentValidationId()&&(t.aborted=!0,t.result=e.store.getState().isValid,t.halted=!0)}async function ye(s){let{ctx:t,deps:e}=s;e.store.dispatch(it(t.committedErrors,t.isValid)),await e.store.emitAfterValidate({values:e.store.getState().values,state:e.store.getState(),scope:t.options?.scope,scopeFields:t.targetFields,errors:t.committedErrors,result:t.result}),t.halted=!0}var vt=class{constructor(t){this.deps=t;this.runner=new D([{name:"validate:resolve-target-fields",run:e=>pe({ctx:e,deps:this.deps})},{name:"validate:before-hooks",run:async e=>he({ctx:e,deps:this.deps})},{name:"validate:sync-track",run:async e=>fe({ctx:e,deps:this.deps})},{name:"validate:abort-check-pre-async",run:async e=>Mt({ctx:e,deps:this.deps})},{name:"validate:async-track",run:async e=>ge({ctx:e,deps:this.deps})},{name:"validate:abort-check",run:async e=>Mt({ctx:e,deps:this.deps})},{name:"validate:async-track-merge",run:e=>me({ctx:e,deps:this.deps})},{name:"validate:commit",run:async e=>ye({ctx:e,deps:this.deps})}])}runner;async run(t){await this.runner.run(t)}};var Tt=class{constructor(t){this.store=t;this.schedule=t.config.scheduler?.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:t.config.validationDelay??300}),this.pipelineStore={getState:()=>this.store.getState(),dispatch:i=>this.store.dispatch(i),config:this.store.config,getFieldConfig:i=>this.store.getFieldConfig(i),forEachFieldConfig:i=>this.store.forEachFieldConfig(i),getScopeFields:i=>this.store.getScopeFields(i),getRequiredErrors:i=>this.store.getRequiredErrors(i),getHiddenFields:()=>this.store.getHiddenFields(),emitBeforeValidate:i=>this.store.emitBeforeValidate(i),emitAfterValidate:i=>this.store.emitAfterValidate(i)},this.asyncScheduler=new St({schedule:(i,r)=>this.schedule(i,r),getValues:()=>this.store.getState().values,setFieldValidating:(i,r)=>this.updateFieldValidating(i,r),setAsyncError:(i,r)=>{this.asyncErrors.set(i,r),this.store.setError(i,r)},clearAsyncError:i=>{let r=this.asyncErrors.get(i);this.asyncErrors.delete(i),r&&!this.store.config.resolver&&this.store.getState().errors[i]===r&&this.store.setError(i,void 0),kt({scopeFields:[i],store:this.pipelineStore,asyncErrors:this.asyncErrors}).catch(n=>{this.store.config.onUnhandledError(n,"validation")})},onValidationPassed:async i=>{await kt({scopeFields:[i],store:this.pipelineStore,asyncErrors:this.asyncErrors})},onError:i=>{this.store.config.onUnhandledError(i,"validation")}});let e={store:this.pipelineStore,asyncErrors:this.asyncErrors,getCurrentValidationId:()=>this.coordinator.getCurrentValidationId(),runImmediateAsyncValidation:(i,r,n)=>this.runImmediateAsyncValidation(i,r,n)};this.validationPipeline=new vt(e)}validatingCount=0;asyncErrors=new Map;coordinator=new bt;validationPipeline;pipelineStore;schedule;asyncScheduler;debouncer;updateFieldValidating(t,e){let i=this.store.getState();if(!!i.isValidating[t]===e)return;let n={...i.isValidating};e?(n[t]=!0,this.validatingCount+=1):(delete n[t],this.validatingCount=Math.max(0,this.validatingCount-1)),this.store.dispatch(S({isValidating:n}))}cancelFieldAsync(t){this.asyncScheduler.cancel(t),this.coordinator.cancelImmediate(t)}cleanupField(t){this.cancelFieldAsync(t),this.asyncErrors.delete(t),this.updateFieldValidating(t,!1)}cleanupPrefix(t){this.asyncScheduler.cleanupPrefix(t),this.coordinator.cancelImmediatePrefix(t,e=>{this.asyncErrors.delete(e),this.updateFieldValidating(e,!1)})}remapArrayPaths(t,e){let i=`${t}.`;this.asyncScheduler.remapPaths(n=>H(n,i,e)),this.coordinator.remapImmediateControllers(n=>H(n,i,e));let r=new Map;this.asyncErrors.forEach((n,o)=>{let a=H(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=i?.validation?.asyncValidate,n=i?.validation?.asyncValidateOn??"blur";if(!r||n!=="change"){this.cancelFieldAsync(t),this.updateFieldValidating(t,!1);return}let o=i.validation?.asyncValidateDelay??500,a=i.validation?.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{t?.scopeFields?.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:t?.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:e.options?.scope,scopeFields:e.targetFields,errors:i.errors,result:i.isValid,aborted:!0})}return e.result}catch(e){return this.store.config.onUnhandledError(e,"validation"),!1}}clear(t){this.cancelFieldAsync(t),this.updateFieldValidating(t,!1),this.asyncErrors.delete(t)}cancelAll(){this.validatingCount=0,this.debouncer.cancelPending(),this.asyncScheduler.cancelAll(),this.asyncErrors.clear(),this.coordinator.cancelAllImmediate(),this.store.dispatch(S({isValidating:{}}))}async runImmediateAsyncValidation(t,e,i){await ue({path:t,values:e,validationId:i,getCurrentValidationId:()=>this.coordinator.getCurrentValidationId(),getFieldConfig:r=>this.store.getFieldConfig(r),cancelFieldAsync:r=>this.cancelFieldAsync(r),createAbortController:()=>new AbortController,setAbortController:(r,n)=>{this.coordinator.setImmediateController(r,n)},clearAbortController:(r,n)=>this.coordinator.clearImmediateController(r,n),setFieldValidating:(r,n)=>this.updateFieldValidating(r,n),setAsyncError:(r,n)=>{this.asyncErrors.set(r,n)},clearAsyncError:r=>{this.asyncErrors.delete(r)}})}};var Rt=class{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")}}};function Se(){return new Rt}function gi(s){let{registry:t,ports:e,fieldRegistry:i}=s;t.register("validation",new Tt(e.validationPort)),t.register("lifecycle",new mt(e.lifecyclePorts)),t.register("history",new dt(!!e.config.history.enabled,e.config.history.limit??50)),t.register("arrays",new ot(e.arrayPort)),t.register("scope",new yt(()=>e.getState(),()=>e.getBaselineValues(),r=>e.getScopeFields(r),r=>e.isPathDirty(r))),t.register("query",new lt(i,()=>e.getState(),r=>e.isPathDirty(r))),t.register("error",new at(()=>e.getState(),r=>e.dispatch(r),r=>e.config.onUnhandledError(r,"errors")))}function be(s){let{ports:t,fieldRegistry:e}=s,i=Se();return gi({registry:i,ports:t,fieldRegistry:e}),{registry:i,capabilities:i.toCapabilities()}}function Be(s){let{config:t,fieldRegistry:e,computedManager:i}=s,r=B(t.initialValues);t.fields&&Object.entries(t.fields).forEach(([a,c])=>{e.register(a,c,r)});let n=rt(e.getComputedEntries());if(n.length>0)throw new Error(n[0].message);return{values:J({values:r,normalizerEntries:e.getNormalizerEntries(),applyComputed:(a,c)=>i.apply(a,c),onError:(a,c)=>{t.onUnhandledError(a,"derivation")}}),errors:{},touched:{},isValidating:{},persist:{isSaving:!1,isRestoring:!1,error:null},isValid:!0,isSubmitting:!1,isDirty:!1}}function ve(s){return{getState:s.getState,dispatch:s.dispatch,setError:s.setError,getFieldConfig:s.getFieldConfig,forEachFieldConfig:t=>s.fieldRegistry.forEachFieldConfig((e,i)=>t(e,i)),getScopeFields:s.getScopeFields,config:s.config,getRequiredErrors:t=>s.fieldRegistry.getRequiredErrors(t),getHiddenFields:()=>s.fieldRegistry.getHiddenFields(),emitBeforeValidate:t=>s.getEffects().beforeValidate(t),emitAfterValidate:t=>s.getEffects().afterValidate(t)}}function Te(s){let t={getState:s.getState,dispatch:s.dispatch,config:s.config,getFieldConfig:r=>s.fieldRegistry.getFieldConfig(r),updateDependencies:(r,n,o)=>s.fieldRegistry.updateDependencies(r,n,o),hasDependentFields:r=>s.fieldRegistry.hasDependents(r),isFieldHidden:r=>s.fieldRegistry.isHidden(r),clearFieldValidation:r=>s.getValidation().clear(r),triggerValidation:(r,n)=>s.getValidation().trigger(r,n),handleFieldAsyncValidation:(r,n)=>s.getValidation().handleAsync(r,n),updateDirtyForPath:(r,n,o)=>s.dirtyManager.updateForPath(r,n,o),getBaselineValues:s.getBaselineValues,emitFieldChange:r=>s.getEffects().onFieldChange(r)},e={getState:s.getState,dispatch:s.dispatch,config:s.config,internalSaveSnapshot:s.saveHistorySnapshot,evaluateAllDependencies:r=>s.fieldRegistry.evaluateAll(r),cancelAllValidations:()=>s.getValidation().cancelAll(),validateNow:r=>s.getValidation().validate(r),rebuildDirtyState:(r,n)=>s.dirtyManager.rebuild(r,n),clearDirtyState:s.dirtyManager.clear.bind(s.dirtyManager),getBaselineValues:s.getBaselineValues,setBaselineValues:s.setBaselineValues,resetHistory:r=>s.getHistory().reset(r),emitFieldChange:r=>s.getEffects().onFieldChange(r),triggerValidation:(r,n)=>s.getValidation().trigger(r,n)},i={getState:s.getState,dispatch:s.dispatch,batchStateUpdates:s.runStateBatch,config:s.config,getTransformEntries:s.getTransformEntries,getHiddenFields:()=>s.fieldRegistry.getHiddenFields(),cancelAllValidations:()=>s.getValidation().cancelAll(),validateNow:r=>s.getValidation().validate(r),hasValidationsInProgress:r=>s.getValidation().hasValidationsInProgress(r),buildDirtyValues:r=>s.dirtyManager.buildDirtyValues(r),setServerErrors:(r,n)=>s.setServerErrors(r,n),emitBeforeSubmit:r=>s.getEffects().beforeSubmit(r),emitAfterSubmit:r=>s.getEffects().afterSubmit(r),emitOperationalError:r=>s.getEffects().reportOperationalError(r)};return{fieldUpdate:t,values:e,submit:i}}function Pe(s){return{getState:s.getState,setFieldWithMeta:s.setFieldWithMeta,dispatch:s.dispatch,internalSaveSnapshot:s.saveHistorySnapshot,unregisterPrefix:s.unregisterPrefix,remapValidationPaths:s.remapValidationPaths,createArrayItemId:s.createArrayItemId}}function Ee(s){let{config:t,fieldRegistry:e,dirtyManager:i,baselineManager:r,runtimeContext:n}=s,{stateAccess:o,fieldAccess:a,featureAccess:c,actions:u}=n,l=ve({config:t,fieldRegistry:e,getState:o.getState,dispatch:o.dispatch,setError:u.setError,getFieldConfig:a.getFieldConfig,getScopeFields:a.getScopeFields,getEffects:c.getEffects}),d=Te({config:t,fieldRegistry:e,dirtyManager:i,getState:o.getState,dispatch:o.dispatch,setServerErrors:u.setServerErrors,saveHistorySnapshot:o.saveHistorySnapshot,runStateBatch:o.runStateBatch,getTransformEntries:a.getTransformEntries,getBaselineValues:()=>r.getValues(),setBaselineValues:h=>r.setValues(h),getValidation:c.getValidation,getHistory:c.getHistory,getEffects:c.getEffects}),p=Pe({getState:o.getState,dispatch:o.dispatch,setFieldWithMeta:(h,g,v)=>u.setFieldWithMeta(h,g,v),unregisterPrefix:u.unregisterPrefix,remapValidationPaths:(h,g)=>c.getValidation().remapArrayPaths(h,g),saveHistorySnapshot:o.saveHistorySnapshot,createArrayItemId:(h,g)=>t.idFactory({scope:"array",path:h,index:g})});return be({ports:{validationPort:l,lifecyclePorts:d,arrayPort:p,config:t,getScopeFields:a.getScopeFields,getState:o.getState,dispatch:o.dispatch,getBaselineValues:()=>r.getValues(),isPathDirty:h=>i.isPathDirty(h)},fieldRegistry:e})}function xe(s){let{config:t,fieldRegistry:e,dirtyManager:i,computedManager:r,rawConfig:n,baselineManager:o,runtimeContext:a}=s,{stateAccess:c,fieldAccess:u,featureAccess:l,actions:d}=a,p=Ee({config:t,fieldRegistry:e,dirtyManager:i,baselineManager:o,runtimeContext:{stateAccess:c,fieldAccess:u,featureAccess:l,actions:d}}),h=Be({config:t,fieldRegistry:e,computedManager:r}),g=new nt(c.getState,t.subscriptionCacheSize),v=n.storeId||t.name||t.idFactory({scope:"store",storeName:t.name});return{state:h,subscriptions:g,capabilityRegistry:p.registry,storeId:v}}function Ce(){return{depth:0,pendingState:null,changedPathSet:null,changedPathList:null,valuesChanged:!1,pendingHistorySnapshot:!1}}function Ve(s){s.depth+=1}function Fe(s){return s.depth-=1,s.depth===0}function Pt(s,t){return t.pendingState??s}function we(s,t){if(s.pendingState=t.nextState,s.valuesChanged||=t.valuesChanged,t.valuesChanged&&(s.pendingHistorySnapshot=!0),t.changedPaths&&t.changedPaths.length>0){let e=s.changedPathSet??new Set,i=s.changedPathList??[];t.changedPaths.forEach(r=>{if(e.has("*")||e.has(r))return;if(r==="*"){e.clear(),i.length=0,e.add("*"),i.push("*");return}if(!i.some(o=>o!=="*"&&r.startsWith(`${o}.`))){for(let o=i.length-1;o>=0;o-=1){let a=i[o];a==="*"||!a.startsWith(`${r}.`)||(e.delete(a),i.splice(o,1))}e.add(r),i.push(r)}}),s.changedPathSet=e,s.changedPathList=i}}function Ae(s){let{currentState:t,batchState:e,applyValueDerivations:i}=s;if(!e.pendingState)return e.pendingHistorySnapshot=!1,null;let r=e.pendingState,n=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:r??t,changedPaths:n,valuesChanged:o}}function mi(s){let t=!1;for(let i of Object.values(s))if(i===void 0){t=!0;break}if(!t)return s;let e={};return Object.entries(s).forEach(([i,r])=>{let n=r;n!==void 0&&(e[i]=n)}),e}function Ot(s){let{currentState:t,partialState:e,changedPaths:i,applyValueDerivations:r,applyComputedValues:n}=s,o=r??(p=>n?n(p):p),a={...t,...e},c=!!e.values;if(e.values&&(a.values=o(e.values,i)),e.errors){a.errors=mi(e.errors);let p=!k(a.errors);a.isValid="isValid"in e?!!e.isValid:p}let u=i&&i.length>0?i:void 0,l=yi(e),d=$(u,l);return{nextState:a,changedPaths:d,valuesChanged:c}}function yi(s){let t=new Set,e=[s.errors,s.touched,s.isValidating];for(let i of e)if(i)for(let r in i)t.add(r);return s.persist&&t.add("persist"),"isValid"in s&&t.add("isValid"),"isDirty"in s&&t.add("isDirty"),"isSubmitting"in s&&t.add("isSubmitting"),t.size>0?Array.from(t):void 0}function Si(s){throw new Error(`BitStore: unsupported operation kind: ${String(s.kind)}`)}function bi(s,t){switch(t.kind){case"state.patch":return t;case"field.touchMany":{if(t.paths.length===0)return null;let e={...s.touched};for(let i of t.paths)e[i]=!0;return S({touched:e},t.paths)}case"form.persistMeta":return S({persist:{...s.persist,...t.patch}});case"history.apply":return S({values:t.values,isDirty:t.isDirty},["*"]);case"validation.commit":return S({errors:t.errors,isValid:t.isValid});default:return Si(t)}}function Bi(s){let{currentState:t,operation:e,applyValueDerivations:i,onOperationError:r}=s,n=Object.prototype.hasOwnProperty.call(e.partialState,"values"),o=e.changedPaths??(n?["*"]:void 0),a;try{a=Ot({currentState:t,partialState:e.partialState,changedPaths:o,applyValueDerivations:i})}catch(c){r?.(c),a=Ot({currentState:t,partialState:e.partialState,changedPaths:o,applyValueDerivations:u=>u})}return a}function Ie(s){let{currentState:t,operation:e,applyValueDerivations:i,onOperationError:r}=s,n=bi(t,e);return n?Bi({currentState:t,operation:n,applyValueDerivations:(o,a)=>n.skipComputed?o:i(o,a),onOperationError:r}):null}function De(s){let{state:t,batchState:e,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o}=s,a=Pt(t,e);if(e.depth>0){let u=Ie({currentState:a,operation:i,applyValueDerivations:l=>l,onOperationError:n});return u&&we(e,u),t}let c=Ie({currentState:t,operation:i,applyValueDerivations:r,onOperationError:n});return c?(o({nextState:c.nextState,changedPaths:c.changedPaths,valuesChanged:c.valuesChanged}),c.nextState):t}function ke(s){let{state:t,batchState:e,applyValueDerivations:i,onStateCommitted:r}=s,n=Ae({currentState:t,batchState:e,applyValueDerivations:i});return n?(r({nextState:n.nextState,changedPaths:n.changedPaths,valuesChanged:n.valuesChanged}),n.nextState):t}function Me(s){let{batchState:t,callback:e,flushBatchedStateUpdates:i}=s;Ve(t);try{return e()}finally{Fe(t)&&i()}}function Re(s){let{payload:t,setState:e,notifySubscriptions:i,notifyEffects:r}=s;e(t.nextState),i(t.nextState,t.changedPaths),r(t.nextState,t.valuesChanged)}function Oe(s){let{state:t,batchState:e,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o}=s;return De({state:t,batchState:e,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o})}function je(s){let{batchState:t,values:e,saveHistory:i}=s;if(t.depth>0){t.pendingHistorySnapshot=!0;return}i(e)}function He(s){let{state:t,batchState:e,applyValueDerivations:i,onStateCommitted:r,saveHistory:n}=s,o=ke({state:t,batchState:e,applyValueDerivations:i,onStateCommitted:r});return e.pendingHistorySnapshot&&(e.pendingHistorySnapshot=!1,n(o.values)),o}var Et=class{constructor(t){this.args=t;this.state=t.state,this.subscriptions=t.subscriptions,this.effects=t.effects,this.capabilityRegistry=t.capabilityRegistry,this.capabilities=t.capabilityRegistry.toCapabilities()}state;batchState=Ce();subscriptions;effects;capabilityRegistry;capabilities;getCapability(t){return this.capabilityRegistry.resolve(t)}getState(){return Pt(this.state,this.batchState)}runBatch(t){return Me({batchState:this.batchState,callback:t,flushBatchedStateUpdates:()=>this.flushBatchedStateUpdates()})}dispatch(t){this.state=Oe({state:this.state,batchState:this.batchState,operation:t,applyValueDerivations:(e,i)=>this.applyValueDerivations(e,i),onOperationError:e=>this.args.onUnhandledError?.(e,"derivation"),onStateCommitted:e=>this.onStateCommitted(e)})}saveHistorySnapshot(){let t=this.capabilities.history.getMetadata();je({batchState:this.batchState,values:this.state.values,saveHistory:i=>this.capabilities.history.saveSnapshot(i)});let e=this.capabilities.history.getMetadata();this.notifyIfHistoryChanged(t,e)}cleanup(){this.subscriptions.destroy(),this.capabilities.validation.cancelAll(),this.effects.destroy()}onStateCommitted(t){Re({payload:t,setState:e=>{this.state=e},notifySubscriptions:(e,i)=>this.subscriptions.notify(e,i),notifyEffects:(e,i)=>this.effects.onStateUpdated(e,i)})}flushBatchedStateUpdates(){let t=this.capabilities.history.getMetadata();this.state=He({state:this.state,batchState:this.batchState,applyValueDerivations:(i,r)=>this.applyValueDerivations(i,r),onStateCommitted:i=>this.onStateCommitted(i),saveHistory:i=>this.capabilities.history.saveSnapshot(i)});let e=this.capabilities.history.getMetadata();this.notifyIfHistoryChanged(t,e)}applyValueDerivations(t,e){return this.args.applyValueDerivations?this.args.applyValueDerivations(t,e):t}notifyIfHistoryChanged(t,e){t.canUndo===e.canUndo&&t.canRedo===e.canRedo&&t.historyIndex===e.historyIndex&&t.historySize===e.historySize||this.subscriptions.notify(this.getState(),[U()])}};function Ue(s){let{rawConfig:t,overrides:e}=s,i=Jt(t),r=e?.baselineManager??new z(i.initialValues),n=e?.fieldRegistry??new K(({error:f})=>{i.onUnhandledError(f,"validation")}),o=e?.computedManager??new q(()=>n.getComputedEntries(),f=>i.onUnhandledError(f,"computed")),a=e?.dirtyManager??new L,c=e?.maskManager??new _;i.masks&&Object.entries(i.masks).forEach(([f,m])=>{c.registerMask(f,m)});let u=()=>{n.invalidateIndexes(),o.invalidateReverseDeps()},l,d=()=>{if(!l)throw new Error("BitStore runtime kernel is not initialized yet.");return l},p=xe({rawConfig:t,config:i,fieldRegistry:n,computedManager:o,dirtyManager:a,baselineManager:r,runtimeContext:{stateAccess:{getState:()=>d().getState(),dispatch:f=>d().dispatch(f),saveHistorySnapshot:()=>d().saveHistorySnapshot(),runStateBatch:f=>d().runBatch(f)},fieldAccess:{getFieldConfig:f=>n.getFieldConfig(f),getScopeFields:f=>n.getScopeFields(f),getNormalizerEntries:()=>n.getNormalizerEntries(),getTransformEntries:()=>n.getTransformEntries()},featureAccess:{getEffects:()=>d().effects,getHistory:()=>d().getCapability("history"),getValidation:()=>d().getCapability("validation")},actions:{setError:(f,m)=>{d().getCapability("error").setError(f,m)},setServerErrors:(f,m)=>{d().getCapability("error").setServerErrors(f,m)},validate:f=>d().getCapability("validation").validate(f),setFieldWithMeta:(f,m,T={origin:"setField"})=>{d().runBatch(()=>{d().getCapability("lifecycle").updateField(f,m,T)})},unregisterPrefix:f=>{st({prefix:f,state:d().getState(),fieldRegistry:n,subscriptions:d().subscriptions,validationCleanupPrefix:m=>d().getCapability("validation").cleanupPrefix(m),invalidateFieldIndexes:u,dispatch:m=>d().dispatch(m)})},triggerValidation:(f,m)=>{d().getCapability("validation").trigger(f,m)}}}}),h=()=>{let f=d().getState();return a.buildDirtyValues(f.values)},g=f=>{te({values:f,state:d().getState(),initialValues:r.getValues(),validation:d().getCapability("validation"),fieldRegistry:n,dirtyManager:a,dispatch:m=>d().dispatch(m),saveHistorySnapshot:()=>d().saveHistorySnapshot()})},v=Gt({storeId:p.storeId,config:i,getState:()=>d().getState(),getConfig:()=>i,getValues:()=>d().getState().values,getDirtyValues:h,applyPersistedValues:g,setPersistMetadata:f=>d().dispatch({kind:"form.persistMeta",patch:f})});return l=new Et({state:p.state,subscriptions:p.subscriptions,effects:v,capabilityRegistry:p.capabilityRegistry,onUnhandledError:(f,m)=>i.onUnhandledError(f,m),applyValueDerivations:(f,m)=>{try{return J({values:f,changedPaths:m,normalizerEntries:n.getNormalizerEntries(),applyComputed:(T,P)=>o.apply(T,P),onError:(T,P)=>{i.onUnhandledError(T,"derivation")}})}catch(T){return i.onUnhandledError(T,"derivation"),f}}}),l.saveHistorySnapshot(),{config:i,storeId:p.storeId,runtime:l,fieldRegistry:n,computedManager:o,dirtyManager:a,maskManager:c,baselineManager:r}}function ze(s){let{dispatch:t,effects:e}=s;return Xt({dispatch:t,effects:e})}function qe(s){let{dispatch:t,effects:e}=s;return Qt({dispatch:t,effects:e})}function Le(s){let{dispatch:t,effects:e}=s;return Zt({dispatch:t,effects:e})}function _e(s){let{history:t,applyHistoryState:e}=s,i=t.undo();i&&e(i)}function Ne(s){let{history:t,applyHistoryState:e}=s,i=t.redo();i&&e(i)}function We(s){return s.history.getMetadata()}function Ke(s,t){let e=new Set,i=(o,a)=>o===null||typeof o!="object"?o:new Proxy(o,{get:(c,u,l)=>{if(typeof u=="symbol")return Reflect.get(c,u,l);let d=String(u),p=a?`${a}.${d}`:d;e.add(p);let h=Reflect.get(c,u,l);return i(h,p)}}),r=i(s,"");t(r);let n=new Set;return e.forEach(o=>{let a=vi(o);a&&n.add(a)}),Array.from(n)}function vi(s){if(s)return s==="values"?"*":s.startsWith("values.")?s.slice(7):s==="errors"||s==="touched"||s==="isValidating"?"*":s.startsWith("errors.")?s.slice(7):s.startsWith("touched.")?s.slice(8):s.startsWith("isValidating.")?s.slice(13):s==="persist"||s.startsWith("persist.")?"persist":s}function Ti(s,t){if(s.length!==t.length)return!1;let e=new Set(t);for(let i of s)if(!e.has(i))return!1;return!0}function Pi(s,t){return s.length===0?{emitImmediately:t?.emitImmediately,equalityFn:t?.equalityFn,mode:"scoped",paths:["*"]}:{emitImmediately:t?.emitImmediately,equalityFn:t?.equalityFn,mode:"scoped",paths:s}}function $e(s){let{getState:t,subscribeSelector:e,selector:i,listener:r,options:n}=s,o=null,a=Ke(t(),i),c=!1,u=!1,l=d=>{let p=o;o=e(i,h=>{r(h);let g=Ke(t(),i);Ti(a,g)||(a=g,!(u||c)&&(u=!0,queueMicrotask(()=>{u=!1,!c&&(o?.(),l(a))})))},Pi(d,n)),p?.()};return l(a),()=>{c=!0,o?.(),o=null}}function Je(s){let{getState:t,subscriptions:e,selector:i,listener:r,options:n,trackedSubscriptionsEnabled:o}=s,a=n?.equalityFn??E;if(n?.mode==="tracked"){if(!o)throw new Error('BitForm: subscribeSelector com mode="tracked" est\xE1 desabilitado por padr\xE3o. Ative config.trackedSubscriptions=true para habilitar o modo avan\xE7ado.');return $e({getState:t,subscribeSelector:(c,u,l)=>e.subscribeSelector(c,u,l,a),selector:i,listener:r,options:n})}return e.subscribeSelector(i,r,n,a)}function Ye(s){let{path:t,listener:e,options:i,subscribeSelector:r}=s,n=[...i?.paths??[],t];return r(o=>y(o.values,t),e,{...i,paths:n})}function Ge(s){let{path:t,listener:e,getFieldState:i,subscribeSelector:r}=s;return r(()=>i(t),e,{paths:[t],equalityFn:Wt})}function Xe(s){let{listener:t,subscribeSelector:e}=s;return e(i=>({isValid:i.isValid,isDirty:i.isDirty,isSubmitting:i.isSubmitting}),t,{paths:["isValid","isDirty","isSubmitting"],equalityFn:(i,r)=>i.isValid===r.isValid&&i.isDirty===r.isDirty&&i.isSubmitting===r.isSubmitting})}function Qe(s){let{listener:t,subscribeSelector:e}=s;return e(i=>i.persist,t,{paths:["persist"],equalityFn:(i,r)=>i.isSaving===r.isSaving&&i.isRestoring===r.isRestoring&&i.error===r.error})}function Ze(s){let{readHistoryMeta:t,subscribeSelector:e,listener:i}=s;return e(()=>t(),i,{paths:[U()],equalityFn:(r,n)=>Nt(r,n)})}function ti(s){let{scopeName:t,getScopeFields:e,readScopeStatus:i,subscribeSelector:r,listener:n}=s,o=I(t),a=i(t),c=()=>{},u=()=>{c();let d=_t(e(t));c=r(()=>i(t),p=>{Vt(a,p)||(a=p,n(p))},{paths:[...d,o]})};u();let l=r(()=>e(t).length,()=>{u();let d=i(t);Vt(a,d)||(a=d,n(d))},{paths:[o]});return()=>{c(),l()}}function ei(s){let{runtime:t,config:e,fieldRegistry:i,dirtyManager:r,stateReader:n}=s,o={getState:()=>B(n.getState()),getFieldState:l=>B(n.getFieldState(l)),getIsValid:()=>n.getFlag("isValid"),getIsSubmitting:()=>n.getFlag("isSubmitting"),getIsDirty:()=>n.getFlag("isDirty"),isHidden:l=>t.capabilities.query.isHidden(l),isRequired:l=>t.capabilities.query.isRequired(l),isFieldDirty:l=>t.capabilities.query.isFieldDirty(l),isFieldValidating:l=>t.capabilities.query.isFieldValidating(l),getDirtyValues:()=>r.buildDirtyValues(n.getState().values),getPersistMetadata:()=>n.getPersistMetadata(),getHistoryMetadata:()=>We({history:t.capabilities.history}),getScopeStatus:l=>t.capabilities.scope.getScopeStatus(l),getScopeErrors:l=>t.capabilities.scope.getScopeErrors(l),getCanUndo:()=>t.capabilities.history.canUndo,getCanRedo:()=>t.capabilities.history.canRedo,getScopeFields:l=>i.getScopeFields(l)},a={subscribe:l=>t.subscriptions.subscribe(l),subscribePersistMeta:l=>Qe({listener:l,subscribeSelector:(d,p,h)=>a.subscribeSelector(d,p,h)}),subscribeHistoryMeta:l=>Ze({readHistoryMeta:()=>o.getHistoryMetadata(),subscribeSelector:(d,p,h)=>a.subscribeSelector(d,p,h),listener:l}),subscribeScopeStatus:(l,d)=>ti({scopeName:l,getScopeFields:p=>o.getScopeFields(p),readScopeStatus:p=>o.getScopeStatus(p),subscribeSelector:(p,h,g)=>a.subscribeSelector(p,h,g),listener:d}),subscribeSelector:(l,d,p)=>Je({getState:()=>o.getState(),subscriptions:t.subscriptions,selector:l,listener:d,options:p,trackedSubscriptionsEnabled:!!e.trackedSubscriptions}),subscribePath:(l,d,p)=>Ye({path:l,listener:d,options:p,subscribeSelector:(h,g,v)=>a.subscribeSelector(h,g,v)}),subscribeFieldState:(l,d)=>Ge({path:l,listener:d,getFieldState:p=>o.getFieldState(p),subscribeSelector:(p,h,g)=>a.subscribeSelector(p,h,g)}),subscribeFormMeta:l=>Xe({listener:l,subscribeSelector:(d,p,h)=>a.subscribeSelector(d,p,h)})};return{read:o,observe:a,write:{registerField:(l,d)=>{re({path:l,config:d,state:t.getState(),fieldRegistry:i,subscriptions:t.subscriptions,validationCleanupField:p=>t.capabilities.validation.cleanupField(p),stateReader:n,invalidateFieldIndexes:()=>{i.invalidateIndexes()},dispatch:p=>t.dispatch(p),getState:()=>t.getState(),onUnhandledError:(p,h)=>e.onUnhandledError(p,h)})},unregisterField:l=>{se({path:l,state:t.getState(),hasStaticConfig:!!e.fields?.[l],fieldRegistry:i,subscriptions:t.subscriptions,validationCleanupField:d=>t.capabilities.validation.cleanupField(d),invalidateFieldIndexes:()=>{i.invalidateIndexes()},dispatch:d=>t.dispatch(d)})},unregisterPrefix:l=>{st({prefix:l,state:t.getState(),fieldRegistry:i,subscriptions:t.subscriptions,validationCleanupPrefix:d=>t.capabilities.validation.cleanupPrefix(d),invalidateFieldIndexes:()=>{i.invalidateIndexes()},dispatch:d=>t.dispatch(d)})},setField:(l,d)=>{t.runBatch(()=>{t.capabilities.lifecycle.updateField(l,d,{origin:"setField"})})},blurField:l=>{t.capabilities.query.isTouched(l)||t.runBatch(()=>{t.dispatch(It([l]))}),t.capabilities.validation.trigger([l])},markFieldsTouched:l=>{l.length!==0&&t.dispatch(It(l))},setValues:(l,d)=>{t.capabilities.lifecycle.setValues(l,d)},setError:(l,d)=>{t.capabilities.error.setError(l,d)},setErrors:l=>{t.capabilities.error.setErrors(l)},setServerErrors:(l,d)=>{t.capabilities.error.setServerErrors(l,d)},reset:()=>{t.runBatch(()=>{t.capabilities.lifecycle.reset()})},transaction:l=>t.runBatch(l),submit:l=>t.capabilities.lifecycle.submit(l),pushItem:(l,d)=>t.capabilities.arrays.pushItem(l,d),prependItem:(l,d)=>t.capabilities.arrays.prependItem(l,d),insertItem:(l,d,p)=>t.capabilities.arrays.insertItem(l,d,p),removeItem:(l,d)=>t.capabilities.arrays.removeItem(l,d),swapItems:(l,d,p)=>t.capabilities.arrays.swapItems(l,d,p),moveItem:(l,d,p)=>t.capabilities.arrays.moveItem(l,d,p),replaceItems:(l,d)=>t.capabilities.arrays.replaceItems(l,d),clearItems:l=>t.capabilities.arrays.clearItems(l)},feature:{undo:()=>{_e({history:t.capabilities.history,applyHistoryState:l=>t.capabilities.lifecycle.applyHistoryState(l)})},redo:()=>{Ne({history:t.capabilities.history,applyHistoryState:l=>t.capabilities.lifecycle.applyHistoryState(l)})},validate:l=>t.capabilities.validation.validate(l),hasValidationsInProgress:l=>t.capabilities.validation.hasValidationsInProgress(l),triggerValidation:(l,d)=>t.capabilities.validation.trigger(l,d),restorePersisted:()=>ze({dispatch:l=>t.dispatch(l),effects:t.effects}),forceSave:()=>qe({dispatch:l=>t.dispatch(l),effects:t.effects}),clearPersisted:()=>Le({dispatch:l=>t.dispatch(l),effects:t.effects}),getArrayItemIds:(l,d)=>t.capabilities.arrays.getItemIds(l,d),cleanup:()=>t.cleanup()}}}function ii(s){let t=()=>s.read.getState();return{read:{get storeId(){return s.identity.storeId},get config(){return s.identity.config},get isValid(){return s.read.getIsValid()},get isSubmitting(){return s.read.getIsSubmitting()},get isDirty(){return s.read.getIsDirty()},getState:t,getFieldConfig:o=>s.getFieldConfig(o),getFieldState:o=>s.read.getFieldState(o),isHidden:o=>s.read.isHidden(o),isRequired:o=>s.read.isRequired(o),isFieldDirty:o=>s.read.isFieldDirty(o),isFieldValidating:o=>s.read.isFieldValidating(o),getDirtyValues:()=>s.read.getDirtyValues(),getPersistMetadata:()=>s.read.getPersistMetadata(),getHistoryMetadata:()=>s.read.getHistoryMetadata(),getScopeStatus:o=>s.read.getScopeStatus(o),getScopeErrors:o=>s.read.getScopeErrors(o),getScopeFields:o=>s.read.getScopeFields(o)},observe:{getState:t,subscribe:o=>s.observe.subscribe(o),subscribePersistMeta:o=>s.observe.subscribePersistMeta(o),subscribeHistoryMeta:o=>s.observe.subscribeHistoryMeta(o),subscribeScopeStatus:(o,a)=>s.observe.subscribeScopeStatus(o,a),subscribeFormMeta:o=>s.observe.subscribeFormMeta(o),subscribeSelector:(o,a,c)=>s.observe.subscribeSelector(o,a,c),subscribePath:(o,a,c)=>s.observe.subscribePath(o,a,c),subscribeFieldState:(o,a)=>s.observe.subscribeFieldState(o,a)},write:{setField:(o,a)=>s.write.setField(o,a),blurField:o=>s.write.blurField(o),markFieldsTouched:o=>s.write.markFieldsTouched(o),setValues:(o,a)=>s.write.setValues(o,a),setError:(o,a)=>s.write.setError(o,a),setErrors:o=>s.write.setErrors(o),setServerErrors:(o,a)=>s.write.setServerErrors(o,a),reset:()=>s.write.reset(),transaction:o=>s.write.transaction(o),submit:o=>s.write.submit(o)},feature:{cleanup:()=>s.feature.cleanup(),validate:o=>s.feature.validate(o),triggerValidation:(o,a)=>s.feature.triggerValidation(o,a),restorePersisted:()=>s.feature.restorePersisted(),forceSave:()=>s.feature.forceSave(),clearPersisted:()=>s.feature.clearPersisted(),registerField:(o,a)=>s.write.registerField(o,a),unregisterField:o=>s.write.unregisterField(o),unregisterPrefix:o=>s.write.unregisterPrefix(o),pushItem:(o,a)=>s.write.pushItem(o,a),prependItem:(o,a)=>s.write.prependItem(o,a),insertItem:(o,a,c)=>s.write.insertItem(o,a,c),removeItem:(o,a)=>s.write.removeItem(o,a),moveItem:(o,a,c)=>s.write.moveItem(o,a,c),swapItems:(o,a,c)=>s.write.swapItems(o,a,c),replaceItems:(o,a)=>s.write.replaceItems(o,a),clearItems:o=>s.write.clearItems(o),getArrayItemIds:(o,a)=>s.feature.getArrayItemIds(o,a),get canUndo(){return s.read.getCanUndo()},get canRedo(){return s.read.getCanRedo()},hasValidationsInProgress:o=>s.feature.hasValidationsInProgress(o),resolveMask:o=>s.resolveMask(o),createArrayItemId:(o,a)=>s.createArrayItemId(o,a),undo:()=>s.feature.undo(),redo:()=>s.feature.redo()}}}var xt=class{constructor(t){this.deps=t}fieldStateCache=new Map;getState(){return this.deps.getState()}getUserLayer(){let t=this.deps.getState();return{values:t.values,touched:t.touched}}getValidationLayer(){let t=this.deps.getState();return{errors:t.errors,isValidating:t.isValidating,isValid:t.isValid}}getDerivedLayer(){return{isDirty:this.deps.getState().isDirty}}getFeatureLayer(){let t=this.deps.getState();return{persist:t.persist,isSubmitting:t.isSubmitting}}getFlag(t){return this.deps.getState()[t]}getPersistMetadata(){return this.deps.getState().persist}getFieldState(t){let e=t,i=this.deps.getState(),r=this.fieldStateCache.get(e),n=y(i.values,e),o=i.errors[e],a=!!i.touched[e],c=this.deps.isHidden(e),u=this.deps.isRequired(e),l=this.deps.isFieldDirty(e),d=this.deps.isFieldValidating(e);if(r){let h=r.snapshot;if(h.value===n&&h.error===o&&h.touched===a&&h.isHidden===c&&h.isRequired===u&&h.isDirty===l&&h.isValidating===d)return h}let p=$t({state:i,path:t,value:n,isHidden:c,isRequired:u,isDirty:l,isValidating:d});return this.fieldStateCache.set(e,{state:i,snapshot:p}),p}invalidatePath(t){this.fieldStateCache.delete(t)}};var Ct=class{[R]=!0;[M]=!0;storeId;_config;read;observe;write;feature;constructor(t={}){let e=Ue({rawConfig:t});this._config=e.config,this.storeId=e.storeId;let i=new xt({getState:()=>e.runtime.getState(),isHidden:o=>e.runtime.capabilities.query.isHidden(o),isRequired:o=>e.runtime.capabilities.query.isRequired(o),isFieldDirty:o=>e.runtime.capabilities.query.isFieldDirty(o),isFieldValidating:o=>e.runtime.capabilities.query.isFieldValidating(o)}),r=ei({runtime:e.runtime,config:this._config,fieldRegistry:e.fieldRegistry,dirtyManager:e.dirtyManager,stateReader:i}),n=ii({identity:{storeId:this.storeId,config:this._config},read:r.read,observe:r.observe,write:r.write,feature:r.feature,getFieldConfig:o=>e.fieldRegistry.getFieldConfig(o),resolveMask:o=>Kt({path:o,getFieldConfig:a=>e.fieldRegistry.getFieldConfig(a),masks:e.maskManager.getAllMasks()}),createArrayItemId:(o,a)=>this._config.idFactory({scope:"array",path:o,index:a})});this.read=n.read,this.observe=n.observe,this.write=n.write,this.feature=n.feature,e.runtime.effects.attachStorePort({getState:()=>this.read.getState(),getHistoryMetadata:()=>this.read.getHistoryMetadata(),undo:()=>this.feature.undo(),redo:()=>this.feature.redo(),reset:()=>this.write.reset()})}};function ri(s={}){return new Ct(s)}function si(s){if(!s||typeof s!="object")return!1;let t=s;return t[R]===!0&&!!t.read&&!!t.observe&&!!t.write&&!!t.feature}function Ei(s){if(si(s))return s;throw new Error("BitForm: o store informado n\xE3o exp\xF5e a API necess\xE1ria para hooks/framework bindings.")}function xi(s){return!s||typeof s!="object"?!1:s[M]===!0}function Ci(s){if(!si(s))throw new Error("BitForm: o store informado n\xE3o possui branding de hooks (BIT_HOOKS_API_SYMBOL).");if(!xi(s))throw new Error("BitForm: o store informado n\xE3o possui branding de framework (BIT_FRAMEWORK_STORE_SYMBOL).");return s}function Vi(s){return Object.defineProperty(s,R,{value:!0,enumerable:!1,configurable:!1,writable:!1}),Object.defineProperty(s,M,{value:!0,enumerable:!1,configurable:!1,writable:!1}),s}function Fi(s={}){let t=ri(s),e={read:t.read,observe:t.observe,write:t.write,feature:t.feature};return Vi(e)}function wi(s){return s.read}function Ai(s){return s.observe}function Ii(s){return s.write}function Di(s){return s.feature}function ki(s,t){let e={};for(let i of t)e[i]=s[i];return e}export{wt as a,hi as b,Ei as c,Ci as d,Fi as e,wi as f,Ai as g,Ii as h,Di as i,ki as j};
2
+ //# sourceMappingURL=chunk-G4HK5QTU.js.map