@lehnihon/bit-form 2.2.7 → 2.2.9
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.
- package/README.md +6 -6
- package/dist/angular/index.cjs +1 -1
- package/dist/angular/index.cjs.map +1 -1
- package/dist/angular/index.d.cts +18 -15
- package/dist/angular/index.d.ts +18 -15
- package/dist/angular/index.js +1 -1
- package/dist/angular/index.js.map +1 -1
- package/dist/{array-controller-DtkmcnUr.d.ts → array-controller-C61ByyG6.d.ts} +5 -5
- package/dist/{array-controller-C1A5VKYd.d.cts → array-controller-CtlqjA0e.d.cts} +5 -5
- package/dist/bus-BKuMV3E7.d.ts +19 -0
- package/dist/bus-WOHGxuVy.d.cts +19 -0
- package/dist/chunk-2QLQPMCZ.js +2 -0
- package/dist/chunk-2QLQPMCZ.js.map +1 -0
- package/dist/chunk-3KI3GEU3.cjs +2 -0
- package/dist/chunk-3KI3GEU3.cjs.map +1 -0
- package/dist/chunk-5NA2TFPG.js +1 -0
- package/dist/chunk-5NA2TFPG.js.map +1 -0
- package/dist/chunk-6LNXTSZ6.cjs +2 -0
- package/dist/chunk-6LNXTSZ6.cjs.map +1 -0
- package/dist/chunk-BSGJ3T5S.cjs +2 -0
- package/dist/chunk-BSGJ3T5S.cjs.map +1 -0
- package/dist/chunk-GGZPA7AO.cjs +2 -0
- package/dist/chunk-GGZPA7AO.cjs.map +1 -0
- package/dist/chunk-ICYXODTQ.js +2 -0
- package/dist/chunk-ICYXODTQ.js.map +1 -0
- package/dist/chunk-J5ALITQW.cjs +2 -0
- package/dist/chunk-J5ALITQW.cjs.map +1 -0
- package/dist/chunk-J5GQLEVA.js +2 -0
- package/dist/chunk-J5GQLEVA.js.map +1 -0
- package/dist/chunk-KDHPLXZF.cjs +2 -0
- package/dist/chunk-KDHPLXZF.cjs.map +1 -0
- package/dist/chunk-N4HCGMMM.js +2 -0
- package/dist/chunk-N4HCGMMM.js.map +1 -0
- package/dist/chunk-OLQVH24Z.cjs +2 -0
- package/dist/chunk-OLQVH24Z.cjs.map +1 -0
- package/dist/chunk-QX2IVNMK.js +2 -0
- package/dist/chunk-QX2IVNMK.js.map +1 -0
- package/dist/chunk-RHMJPKNV.cjs +2 -0
- package/dist/chunk-RHMJPKNV.cjs.map +1 -0
- package/dist/chunk-UARLAXZX.js +2 -0
- package/dist/chunk-UARLAXZX.js.map +1 -0
- package/dist/chunk-UIKO6GGW.js +2 -0
- package/dist/chunk-UIKO6GGW.js.map +1 -0
- package/dist/chunk-W2E5UIXT.js +2 -0
- package/dist/chunk-W2E5UIXT.js.map +1 -0
- package/dist/chunk-W5CLDRRE.cjs +1 -0
- package/dist/chunk-W5CLDRRE.cjs.map +1 -0
- package/dist/chunk-X5UCRGYJ.cjs +2 -0
- package/dist/chunk-X5UCRGYJ.cjs.map +1 -0
- package/dist/chunk-Y3XVQGCU.js +2 -0
- package/dist/chunk-Y3XVQGCU.js.map +1 -0
- package/dist/cli/index.cjs +2 -2
- package/dist/core/bindings.cjs +2 -0
- package/dist/core/bindings.cjs.map +1 -0
- package/dist/core/bindings.d.cts +89 -0
- package/dist/core/bindings.d.ts +89 -0
- package/dist/core/bindings.js +2 -0
- package/dist/core/bindings.js.map +1 -0
- package/dist/core/status.cjs +2 -0
- package/dist/core/status.cjs.map +1 -0
- package/dist/core/status.d.cts +44 -0
- package/dist/core/status.d.ts +44 -0
- package/dist/core/status.js +2 -0
- package/dist/core/status.js.map +1 -0
- package/dist/core/store.cjs +2 -0
- package/dist/core/store.cjs.map +1 -0
- package/dist/core/store.d.cts +84 -0
- package/dist/core/store.d.ts +84 -0
- package/dist/core/store.js +2 -0
- package/dist/core/store.js.map +1 -0
- package/dist/core/utils.cjs +2 -0
- package/dist/core/utils.cjs.map +1 -0
- package/dist/core/utils.d.cts +74 -0
- package/dist/core/utils.d.ts +74 -0
- package/dist/core/utils.js +2 -0
- package/dist/core/utils.js.map +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +14 -122
- package/dist/core.d.ts +14 -122
- package/dist/core.js +1 -1
- package/dist/devtools/bridge.cjs +1 -1
- package/dist/devtools/bridge.cjs.map +1 -1
- package/dist/devtools/bridge.d.cts +3 -2
- package/dist/devtools/bridge.d.ts +3 -2
- package/dist/devtools/bridge.js +1 -1
- package/dist/devtools/index.cjs +2 -2
- package/dist/devtools/index.cjs.map +1 -1
- package/dist/devtools/index.d.cts +3 -2
- package/dist/devtools/index.d.ts +3 -2
- package/dist/devtools/index.js +1 -1
- package/dist/devtools/index.js.map +1 -1
- package/dist/{field-binding-X5TkvfUt.d.cts → field-binding-B_OX3bjp.d.cts} +1 -1
- package/dist/{field-binding-Bi1g-D8X.d.ts → field-binding-MX6jVQbT.d.ts} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -85
- package/dist/index.d.ts +8 -85
- package/dist/index.js +1 -1
- package/dist/mask.cjs +1 -1
- package/dist/mask.cjs.map +1 -1
- package/dist/mask.d.cts +2 -2
- package/dist/mask.d.ts +2 -2
- package/dist/mask.js +1 -1
- package/dist/mask.js.map +1 -1
- package/dist/meta-types-Bzmm21TP.d.cts +18 -0
- package/dist/meta-types-Bzmm21TP.d.ts +18 -0
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +11 -9
- package/dist/react/index.d.ts +11 -9
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react-native/index.cjs +1 -1
- package/dist/react-native/index.cjs.map +1 -1
- package/dist/react-native/index.d.cts +9 -7
- package/dist/react-native/index.d.ts +9 -7
- package/dist/react-native/index.js +1 -1
- package/dist/react-native/index.js.map +1 -1
- package/dist/resolvers/index.cjs +1 -1
- package/dist/resolvers/index.cjs.map +1 -1
- package/dist/resolvers/index.d.cts +3 -2
- package/dist/resolvers/index.d.ts +3 -2
- package/dist/resolvers/index.js +1 -1
- package/dist/resolvers/joi.d.cts +3 -2
- package/dist/resolvers/joi.d.ts +3 -2
- package/dist/resolvers/yup.d.cts +3 -2
- package/dist/resolvers/yup.d.ts +3 -2
- package/dist/resolvers/zod.d.cts +3 -2
- package/dist/resolvers/zod.d.ts +3 -2
- package/dist/store-api-types-Bm3EAqR_.d.cts +161 -0
- package/dist/store-api-types-DfTFy2h4.d.ts +161 -0
- package/dist/{bus-DgilLszS.d.ts → types-CRCP4Pgq.d.ts} +82 -45
- package/dist/{types-CUXh7PqD.d.cts → types-D8DgIUhJ.d.cts} +1 -1
- package/dist/{types-CUXh7PqD.d.ts → types-D8DgIUhJ.d.ts} +1 -1
- package/dist/{bus-rcUiufS7.d.cts → types-SOg9xEce.d.cts} +82 -45
- package/dist/{upload-EXnJLq8k.d.cts → upload-C2mpfhp1.d.cts} +1 -1
- package/dist/{upload-EXnJLq8k.d.ts → upload-C2mpfhp1.d.ts} +1 -1
- package/dist/{use-bit-persist-CIKFwtdM.d.cts → use-bit-persist-BDMZmxBh.d.ts} +8 -6
- package/dist/{use-bit-persist-Bc06fmqZ.d.ts → use-bit-persist-CBTZIMc5.d.cts} +8 -6
- package/dist/utils.cjs +2 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +6 -0
- package/dist/utils.d.ts +6 -0
- package/dist/utils.js +2 -0
- package/dist/utils.js.map +1 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.cts +9 -7
- package/dist/vue/index.d.ts +9 -7
- package/dist/vue/index.js +1 -1
- package/dist/vue/index.js.map +1 -1
- package/package.json +39 -14
- package/dist/chunk-DIEE6LUO.js +0 -2
- package/dist/chunk-DIEE6LUO.js.map +0 -1
- package/dist/chunk-FUUQB4DV.cjs +0 -2
- package/dist/chunk-FUUQB4DV.cjs.map +0 -1
- package/dist/chunk-KWLLYQOL.cjs +0 -2
- package/dist/chunk-KWLLYQOL.cjs.map +0 -1
- package/dist/chunk-LIYZPSWM.js +0 -2
- package/dist/chunk-LIYZPSWM.js.map +0 -1
- package/dist/chunk-QAL6J5GQ.cjs +0 -2
- package/dist/chunk-QAL6J5GQ.cjs.map +0 -1
- package/dist/chunk-SA47B5OP.js +0 -2
- package/dist/chunk-SA47B5OP.js.map +0 -1
- package/dist/store-api-types-9ipdute1.d.ts +0 -187
- package/dist/store-api-types-B6_bPoVI.d.cts +0 -187
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/utils/field-meta.ts"],"names":["deriveFieldMeta","state","error","hasError"],"mappings":"AAaO,kFAASA,CAAAA,CACdC,CAAAA,CACqB,CACrB,IAAMC,CAAAA,CAAQD,CAAAA,CAAM,OAAA,CAAUA,CAAAA,CAAM,KAAA,CAAQ,KAAA,CAAA,CACtCE,CAAAA,CAAW,CAAC,CAACF,CAAAA,CAAM,KAAA,CAEzB,MAAO,CACL,KAAA,CAAAC,CAAAA,CACA,OAAA,CAASD,CAAAA,CAAM,OAAA,CACf,OAAA,CAAS,CAAC,CAAA,CAAEA,CAAAA,CAAM,OAAA,EAAWA,CAAAA,CAAM,KAAA,CAAA,CACnC,YAAA,CAAcA,CAAAA,CAAM,YAAA,CACpB,OAAA,CAASA,CAAAA,CAAM,OAAA,CACf,QAAA,CAAUA,CAAAA,CAAM,QAAA,CAChB,UAAA,CAAYA,CAAAA,CAAM,UAAA,CAClB,QAAA,CAAAE,CACF,CACF,CAAA,cAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-3KI3GEU3.cjs","sourcesContent":["import type { BitFieldState } from \"../store/contracts/types\";\n\nexport interface BitDerivedFieldMeta {\n error: string | undefined;\n touched: boolean;\n invalid: boolean;\n isValidating: boolean;\n isDirty: boolean;\n isHidden: boolean;\n isRequired: boolean;\n hasError: boolean;\n}\n\nexport function deriveFieldMeta<T extends object, TValue>(\n state: Readonly<BitFieldState<T, TValue>>,\n): BitDerivedFieldMeta {\n const error = state.touched ? state.error : undefined;\n const hasError = !!state.error;\n\n return {\n error,\n touched: state.touched,\n invalid: !!(state.touched && state.error),\n isValidating: state.isValidating,\n isDirty: state.isDirty,\n isHidden: state.isHidden,\n isRequired: state.isRequired,\n hasError,\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-5NA2TFPG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }function p(e){if(e===null||typeof e!="object")return e;if(typeof structuredClone=="function")return structuredClone(e);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e))return e.map(r=>p(r));let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=p(e[r]));return n}function d(e){return p(e)}function m(e,n){if(n===void 0)return d(e);if(n===null||typeof n!="object"||n instanceof Date||n instanceof RegExp||Array.isArray(n))return d(n);let r=e&&typeof e=="object"&&!Array.isArray(e)?d(e):{};for(let t of Object.keys(n)){let s=n[t],a=r[t];if(s!==null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp)){r[t]=m(a,s);continue}r[t]=d(s)}return r}function k(e,n){return e===n?!0:e===null||typeof e!="object"||n===null||typeof n!="object"?!1:h(e,n)}function h(e,n){if(e===n)return!0;if(e===null||typeof e!="object"||n===null||typeof n!="object")return!1;if(e instanceof Date&&n instanceof Date)return e.getTime()===n.getTime();if(e instanceof RegExp&&n instanceof RegExp)return e.toString()===n.toString();let r=Object.keys(e),t=Object.keys(n);if(r.length!==t.length)return!1;for(let s of r)if(!Object.prototype.hasOwnProperty.call(n,s)||!h(e[s],n[s]))return!1;return!0}function V(e,n,r="",t=new Set){if(k(e,n))return t;if(e===null||typeof e!="object"||n===null||typeof n!="object")return r&&t.add(r),t;if(Array.isArray(e)||Array.isArray(n))return!k(e,n)&&r&&t.add(r),t;let s=new Set;for(let a of Object.keys(e||{}))s.add(a);for(let a of Object.keys(n||{}))s.add(a);for(let a of s){let o=r?`${r}.${a}`:a;V(_optionalChain([e, 'optionalAccess', _ => _[a]]),_optionalChain([n, 'optionalAccess', _2 => _2[a]]),o,t)}return t}var g=new Map;function T(e,n){if(g.has(e))g.delete(e);else if(g.size>=5e3){let r=g.keys().next().value;r!==void 0&&g.delete(r)}g.set(e,n)}function A(e){let n=g.get(e);if(n)return n;let r=e.split(".");return T(e,r),r}function K(e,n){if(!n)return e;let r=A(n),t=e;for(let s of r){if(t==null)return;t=t[s]}return t}function D(e,n,r){if(!n)return r;let t=A(n),s=Array.isArray(e)?[...e]:{...e},a=s;for(let o=0;o<t.length-1;o++){let i=t[o],c=t[o+1],u=Number(c),y=Number.isInteger(u)&&String(u)===c,f=a[i];f==null?a[i]=y?[]:{}:a[i]=Array.isArray(f)?[...f]:{...f},a=a[i]}return a[t[t.length-1]]=r,s}function b(e,n){if(n.length===0)return e;let r=Array.isArray(e)?[...e]:{...e},t=new WeakSet;r&&typeof r=="object"&&t.add(r);for(let[s,a]of n){let o=A(s),i=r;for(let c=0;c<o.length-1;c++){let u=o[c],y=o[c+1],f=Number(y),R=Number.isInteger(f)&&String(f)===y,l=i[u];l==null?(i[u]=R?[]:{},t.add(i[u])):typeof l=="object"?t.has(l)||(i[u]=Array.isArray(l)?[...l]:{...l},t.add(i[u])):(i[u]=R?[]:{},t.add(i[u])),i=i[u]}i[o[o.length-1]]=a}return r}function E(e,n){if(n.length===0)return e;let r=Array.isArray(e)?[...e]:{...e},t=new WeakSet;r&&typeof r=="object"&&t.add(r);for(let s of n){if(!s)return Array.isArray(e)?[]:{};let a=A(s),o=r;for(let c=0;c<a.length-1;c++){let u=a[c],y=_optionalChain([o, 'optionalAccess', _3 => _3[u]]);if(y==null){o=void 0;break}if(typeof y=="object")t.has(y)||(o[u]=Array.isArray(y)?[...y]:{...y},t.add(o[u]));else{o=void 0;break}o=o[u]}if(!o)continue;let i=a[a.length-1];Array.isArray(o)?o.splice(Number(i),1):o&&typeof o=="object"&&delete o[i]}return r}function O(e,n){let r={},t=`${n}.`;for(let s in e)s!==n&&!s.startsWith(t)&&(r[s]=e[s]);return r}function $(e,n,r){let t={},s={},a={},o=`${n}.`;for(let i of Object.keys(e.errors)){let c=x(i,o,r);c&&(t[c]=e.errors[i])}for(let i of Object.keys(e.touched)){let c=x(i,o,r);c&&(s[c]=e.touched[i])}for(let i of Object.keys(e.isValidating)){let c=x(i,o,r);c&&(a[c]=e.isValidating[i])}return{errors:t,touched:s,isValidating:a}}function x(e,n,r){if(!e.startsWith(n))return e;let s=e.substring(n.length).split("."),a=parseInt(s[0],10),o=r(a);if(o===null)return null;let i=s.slice(1).join(".");return i?`${n}${o}.${i}`:`${n}${o}`}function w(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let n=_nullishCoalesce(e.errors, () => (e));return typeof n!="object"||n===null||Array.isArray(n)?!1:Object.values(n).every(r=>typeof r=="string"||Array.isArray(r)&&r.every(t=>typeof t=="string"))}function N(e){return w(e)?_nullishCoalesce(e.errors, () => (e)):{}}exports.a = d; exports.b = m; exports.c = k; exports.d = h; exports.e = V; exports.f = K; exports.g = D; exports.h = b; exports.i = E; exports.j = O; exports.k = $; exports.l = w; exports.m = N;
|
|
2
|
+
//# sourceMappingURL=chunk-6LNXTSZ6.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/utils/clone.ts","../src/core/utils/structural.ts"],"names":["cloneValue","obj","item","clone","key","deepClone","deepMerge","target","source","base","sourceValue","baseValue","valueEqual","a","b","deepEqual","keysA","keysB","collectDirtyPaths","initial","prefix","result","allKeys","k","p"],"mappings":"AAAO,0rBAASA,CAAAA,CAAcC,CAAAA,CAAW,CACvC,EAAA,CAAIA,CAAAA,GAAQ,IAAA,EAAQ,OAAOA,CAAAA,EAAQ,QAAA,CACjC,OAAOA,CAAAA,CAGT,EAAA,CAAI,OAAO,eAAA,EAAoB,UAAA,CAC7B,OAAO,eAAA,CAAgBA,CAAG,CAAA,CAG5B,EAAA,CAAIA,EAAAA,WAAe,IAAA,CACjB,OAAO,IAAI,IAAA,CAAKA,CAAAA,CAAI,OAAA,CAAQ,CAAC,CAAA,CAG/B,EAAA,CAAIA,EAAAA,WAAe,MAAA,CACjB,OAAO,IAAI,MAAA,CAAOA,CAAAA,CAAI,MAAA,CAAQA,CAAAA,CAAI,KAAK,CAAA,CAGzC,EAAA,CAAI,KAAA,CAAM,OAAA,CAAQA,CAAG,CAAA,CACnB,OAAOA,CAAAA,CAAI,GAAA,CAAKC,CAAAA,EAASF,CAAAA,CAAWE,CAAI,CAAC,CAAA,CAG3C,IAAMC,CAAAA,CAAa,CAAC,CAAA,CACpB,GAAA,CAAA,IAAWC,EAAAA,GAAOH,CAAAA,CACZ,MAAA,CAAO,SAAA,CAAU,cAAA,CAAe,IAAA,CAAKA,CAAAA,CAAKG,CAAG,CAAA,EAAA,CAC/CD,CAAAA,CAAMC,CAAG,CAAA,CAAIJ,CAAAA,CAAYC,CAAAA,CAAYG,CAAG,CAAC,CAAA,CAAA,CAI7C,OAAOD,CACT,CC3BO,SAASE,CAAAA,CAAaJ,CAAAA,CAAW,CACtC,OAAOD,CAAAA,CAAWC,CAAG,CACvB,CAEO,SAASK,CAAAA,CAAaC,CAAAA,CAAWC,CAAAA,CAAgB,CACtD,EAAA,CAAIA,CAAAA,GAAW,KAA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ACb,CACb,EAAA,CAAIT,CAAAA,CAAWX,CAAAA,CAAKkB,CAAO,CAAA,CAAG,OAAOE,CAAAA,CACrC,EAAA,CACEpB,CAAAA,GAAQ,IAAA,EACR,OAAOA,CAAAA,EAAQ,QAAA,EACfkB,CAAAA,GAAY,IAAA,EACZ,OAAOA,CAAAA,EAAY,QAAA,CAEnB,OAAIC,CAAAA,EAAQC,CAAAA,CAAO,GAAA,CAAID,CAAM,CAAA,CACtBC,CAAAA,CAET,EAAA,CAAI,KAAA,CAAM,OAAA,CAAQpB,CAAG,CAAA,EAAK,KAAA,CAAM,OAAA,CAAQkB,CAAO,CAAA,CAC7C,MAAI,CAACP,CAAAA,CAAWX,CAAAA,CAAKkB,CAAO,CAAA,EAAKC,CAAAA,EAAQC,CAAAA,CAAO,GAAA,CAAID,CAAM,CAAA,CACnDC,CAAAA,CAET,IAAMC,CAAAA,CAAU,IAAI,GAAA,CACpB,GAAA,CAAA,IAAWlB,EAAAA,GAAO,MAAA,CAAO,IAAA,CAAKH,CAAAA,EAAO,CAAC,CAAC,CAAA,CACrCqB,CAAAA,CAAQ,GAAA,CAAIlB,CAAG,CAAA,CAEjB,GAAA,CAAA,IAAWA,EAAAA,GAAO,MAAA,CAAO,IAAA,CAAKe,CAAAA,EAAW,CAAC,CAAC,CAAA,CACzCG,CAAAA,CAAQ,GAAA,CAAIlB,CAAG,CAAA,CAEjB,GAAA,CAAA,IAAWmB,EAAAA,GAAKD,CAAAA,CAAS,CACvB,IAAME,CAAAA,CAAIJ,CAAAA,CAAS,CAAA,EAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-6LNXTSZ6.cjs","sourcesContent":["export function cloneValue<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") {\n return obj;\n }\n\n if (typeof structuredClone === \"function\") {\n return structuredClone(obj);\n }\n\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as any as T;\n }\n\n if (obj instanceof RegExp) {\n return new RegExp(obj.source, obj.flags) as any as T;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => cloneValue(item)) as any as T;\n }\n\n const clone: any = {};\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n clone[key] = cloneValue((obj as any)[key]);\n }\n }\n\n return clone as T;\n}\n","import { cloneValue } from \"./clone\";\n\nexport function deepClone<T>(obj: T): T {\n return cloneValue(obj);\n}\n\nexport function deepMerge<T>(target: T, source: any): T {\n if (source === undefined) {\n return deepClone(target);\n }\n\n if (\n source === null ||\n typeof source !== \"object\" ||\n source instanceof Date ||\n source instanceof RegExp ||\n Array.isArray(source)\n ) {\n return deepClone(source as T);\n }\n\n const base =\n target && typeof target === \"object\" && !Array.isArray(target)\n ? deepClone(target as any)\n : ({} as Record<string, unknown>);\n\n for (const key of Object.keys(source)) {\n const sourceValue = source[key];\n const baseValue = (base as Record<string, unknown>)[key];\n\n if (\n sourceValue !== null &&\n typeof sourceValue === \"object\" &&\n !Array.isArray(sourceValue) &&\n !(sourceValue instanceof Date) &&\n !(sourceValue instanceof RegExp)\n ) {\n (base as Record<string, unknown>)[key] = deepMerge(\n baseValue,\n sourceValue,\n );\n continue;\n }\n\n (base as Record<string, unknown>)[key] = deepClone(sourceValue);\n }\n\n return base as T;\n}\n\nexport function valueEqual(a: any, b: any): boolean {\n if (a === b) return true;\n if (\n a === null ||\n typeof a !== \"object\" ||\n b === null ||\n typeof b !== \"object\"\n ) {\n return false;\n }\n return deepEqual(a, b);\n}\n\nexport function deepEqual(a: any, b: any): boolean {\n if (a === b) return true;\n if (\n a === null ||\n typeof a !== \"object\" ||\n b === null ||\n typeof b !== \"object\"\n ) {\n return false;\n }\n\n if (a instanceof Date && b instanceof Date)\n return a.getTime() === b.getTime();\n if (a instanceof RegExp && b instanceof RegExp)\n return a.toString() === b.toString();\n\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (\n !Object.prototype.hasOwnProperty.call(b, key) ||\n !deepEqual(a[key], b[key])\n ) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function collectDirtyPaths(\n obj: any,\n initial: any,\n prefix = \"\",\n result: Set<string> = new Set(),\n): Set<string> {\n if (valueEqual(obj, initial)) return result;\n if (\n obj === null ||\n typeof obj !== \"object\" ||\n initial === null ||\n typeof initial !== \"object\"\n ) {\n if (prefix) result.add(prefix);\n return result;\n }\n if (Array.isArray(obj) || Array.isArray(initial)) {\n if (!valueEqual(obj, initial) && prefix) result.add(prefix);\n return result;\n }\n const allKeys = new Set<string>();\n for (const key of Object.keys(obj || {})) {\n allKeys.add(key);\n }\n for (const key of Object.keys(initial || {})) {\n allKeys.add(key);\n }\n for (const k of allKeys) {\n const p = prefix ? `${prefix}.${k}` : k;\n collectDirtyPaths((obj as any)?.[k], (initial as any)?.[k], p, result);\n }\n return result;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/scope-status.ts"],"names":["observeScopeStatusSnapshot","store","scopeName","listener"],"mappings":"AAOO,kFAASA,CAAAA,CACdC,CAAAA,CAWAC,CAAAA,CACAC,CAAAA,CACY,CACZ,OAAAA,CAAAA,CAASF,CAAAA,CAAM,IAAA,CAAK,cAAA,CAAeC,CAAS,CAAC,CAAA,CAEtCD,CAAAA,CAAM,OAAA,CAAQ,oBAAA,CAAqBC,CAAAA,CAAWC,CAAQ,CAC/D,CAAA,cAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-BSGJ3T5S.cjs","sourcesContent":["import type { ScopeStatus } from \"./store/contracts/types\";\nexport {\n areScopeErrorsEqual,\n isScopeStatusEqual,\n getScopeSubscriptionPaths,\n} from \"./store/shared/scope-status\";\n\nexport function observeScopeStatusSnapshot(\n store: {\n read: {\n getScopeStatus(scopeName: string): ScopeStatus;\n };\n observe: {\n subscribeScopeStatus(\n scopeName: string,\n listener: (status: ScopeStatus) => void,\n ): () => void;\n };\n },\n scopeName: string,\n listener: (status: ScopeStatus) => void,\n): () => void {\n listener(store.read.getScopeStatus(scopeName));\n\n return store.observe.subscribeScopeStatus(scopeName, listener);\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkQKGTVKBUcjs = require('./chunk-QKGTVKBU.cjs');var _chunkJ5ALITQWcjs = require('./chunk-J5ALITQW.cjs');function R(e){return{values:e.values,errors:e.errors,touched:e.touched,isValid:e.isValid,isDirty:e.isDirty,isSubmitting:e.isSubmitting,isValidating:e.isValidating,persist:e.persist}}function k(e){let o=e.getHistoryMetadata();return{...R(e.getState()),_meta:{canUndo:o.canUndo,canRedo:o.canRedo,totalSteps:o.historySize,currentIndex:o.historyIndex}}}function b(e){let o={};for(let[t,i]of Object.entries(e))o[t]=k(i);return o}function w(e){if(!e||typeof e!="object")return!1;let o=e;return typeof o.getState=="function"&&typeof o.getHistoryMetadata=="function"}function I(e){if(!w(e))return!1;let o=e;return typeof o.undo=="function"&&typeof o.redo=="function"&&typeof o.reset=="function"}function B(e,o){let t=e[o];return I(t)?t:null}var S=null,O=50;function N(e,o=_chunkJ5ALITQWcjs.a){S&&(console.warn("[bit-form] Reiniciando ponte do DevTools (Fast Refresh detectado)."),S());let t=null,i=null,f,n=null,a=new Set,T=!1,u=r=>{_optionalChain([t, 'optionalAccess', _ => _.readyState])===WebSocket.OPEN&&t.send(JSON.stringify(r))},h=()=>{if(a.size===0)return;let r=b(Array.from(a).reduce((s,l)=>{let d=o.stores[l];return d&&(s[l]=d),s},{}));a.clear(),n=null,Object.keys(r).length>0&&u({type:"STATE_UPDATE",protocolVersion:1,payload:r})},D=()=>{n||(n=setTimeout(()=>{h()},O))},y=()=>{T=!1,t=new WebSocket(e),t.onopen=()=>{console.log("[bit-form] \u{1F50C} Conectado ao CLI DevTools via WebSocket."),u({type:"HELLO",protocolVersion:1,payload:{role:"server",protocolVersion:1}});let r=b(o.stores);Object.keys(r).length>0&&u({type:"STATE_UPDATE",protocolVersion:1,payload:r}),i=o.subscribe((s,l)=>{a.add(s),D()}),f=setInterval(()=>{u({type:"PING",protocolVersion:1})},3e4)},t.onmessage=r=>{try{let s=JSON.parse(r.data);if(_chunkQKGTVKBUcjs.c.call(void 0, s)){let{storeId:l,action:d}=s.payload,p=B(o.stores,l);if(!p)return;switch(d){case"undo":p.undo();break;case"redo":p.redo();break;case"reset":p.reset();break}}}catch(s){console.warn("[bit-form] Erro ao processar comando do CLI:",s)}},t.onclose=()=>{i&&i(),clearInterval(f),n&&(clearTimeout(n),n=null),a.clear(),T?console.log("[bit-form] Ponte antiga encerrada com sucesso."):(console.log("[bit-form] Conex\xE3o perdida. Reconectando em 3s..."),setTimeout(y,3e3))}};y();let m=()=>{T=!0,i&&i(),clearInterval(f),n&&(clearTimeout(n),n=null),a.clear(),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),S=null};return S=m,m}exports.a = b; exports.b = B; exports.c = N;
|
|
2
|
+
//# sourceMappingURL=chunk-GGZPA7AO.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-GGZPA7AO.cjs","../src/devtools/store-snapshot.ts","../src/devtools/store-port.ts","../src/devtools/bridge.ts"],"names":["normalizeStoreState","state","createDevToolsStoreSnapshot","store","historyMeta","createDevToolsSnapshotMap","stores","snapshots","storeId","instance","isDevToolsReadableStore","value","candidate","isDevToolsActionableStore","getDevToolsActionableStore","activeBridgeCleanup","STATE_BATCH_INTERVAL_MS","setupRemoteBridge","url","bus","bitBus","socket","unsubscribeBus","heartbeatInterval","batchFlushTimeout","pendingStoreIds","isIntentionalDisconnect","sendWhenOpen","message","flushPendingStoreUpdates","payload","acc","storeInstance","scheduleStoreFlush","connect","initialState","_newState","event","isDevToolsActionMessage","action","e","cleanup"],"mappings":"AAAA,qoBAA+C,wDAAyC,SCG/EA,CAAAA,CACPC,CAAAA,CACsC,CACtC,MAAO,CACL,MAAA,CAAQA,CAAAA,CAAM,MAAA,CACd,MAAA,CAAQA,CAAAA,CAAM,MAAA,CACd,OAAA,CAASA,CAAAA,CAAM,OAAA,CACf,OAAA,CAASA,CAAAA,CAAM,OAAA,CACf,OAAA,CAASA,CAAAA,CAAM,OAAA,CACf,YAAA,CAAcA,CAAAA,CAAM,YAAA,CACpB,YAAA,CAAcA,CAAAA,CAAM,YAAA,CACpB,OAAA,CAASA,CAAAA,CAAM,OACjB,CACF,CAEO,SAASC,CAAAA,CAA8CC,CAAAA,CAQpC,CACxB,IAAMC,CAAAA,CAAcD,CAAAA,CAAM,kBAAA,CAAmB,CAAA,CAE7C,MAAO,CACL,GAAGH,CAAAA,CAAoBG,CAAAA,CAAM,QAAA,CAAS,CAAC,CAAA,CACvC,KAAA,CAAO,CACL,OAAA,CAASC,CAAAA,CAAY,OAAA,CACrB,OAAA,CAASA,CAAAA,CAAY,OAAA,CACrB,UAAA,CAAYA,CAAAA,CAAY,WAAA,CACxB,YAAA,CAAcA,CAAAA,CAAY,YAC5B,CACF,CACF,CAEO,SAASC,CAAAA,CACdC,CAAAA,CACwB,CACxB,IAAMC,CAAAA,CAAoC,CAAC,CAAA,CAE3C,GAAA,CAAA,GAAW,CAACC,CAAAA,CAASC,CAAQ,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQH,CAAM,CAAA,CACrDC,CAAAA,CAAUC,CAAO,CAAA,CAAIN,CAAAA,CAA4BO,CAAQ,CAAA,CAG3D,OAAOF,CACT,CC1CO,SAASG,CAAAA,CACdC,CAAAA,CAC2C,CAC3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import type { BitBusStorePort, BitState } from \"../core\";\nimport type { DevToolsStoreSnapshot, DevToolsStoreSnapshots } from \"./protocol\";\n\nfunction normalizeStoreState<T extends object>(\n state: Readonly<BitState<T>>,\n): Omit<DevToolsStoreSnapshot, \"_meta\"> {\n return {\n values: state.values,\n errors: state.errors as Record<string, unknown>,\n touched: state.touched as Record<string, unknown>,\n isValid: state.isValid,\n isDirty: state.isDirty,\n isSubmitting: state.isSubmitting,\n isValidating: state.isValidating as Record<string, unknown>,\n persist: state.persist,\n };\n}\n\nexport function createDevToolsStoreSnapshot<T extends object>(store: {\n getState: () => Readonly<BitState<T>>;\n getHistoryMetadata: () => {\n canUndo: boolean;\n canRedo: boolean;\n historySize: number;\n historyIndex: number;\n };\n}): DevToolsStoreSnapshot {\n const historyMeta = store.getHistoryMetadata();\n\n return {\n ...normalizeStoreState(store.getState()),\n _meta: {\n canUndo: historyMeta.canUndo,\n canRedo: historyMeta.canRedo,\n totalSteps: historyMeta.historySize,\n currentIndex: historyMeta.historyIndex,\n },\n };\n}\n\nexport function createDevToolsSnapshotMap(\n stores: Record<string, BitBusStorePort<object>>,\n): DevToolsStoreSnapshots {\n const snapshots: DevToolsStoreSnapshots = {};\n\n for (const [storeId, instance] of Object.entries(stores)) {\n snapshots[storeId] = createDevToolsStoreSnapshot(instance);\n }\n\n return snapshots;\n}\n","import type { BitBusStorePort } from \"../core\";\n\nexport type BitDevToolsReadableStore<T extends object = object> =\n BitBusStorePort<T>;\n\nexport type BitDevToolsActionableStore<T extends object = object> =\n BitBusStorePort<T>;\n\nexport function isDevToolsReadableStore(\n value: unknown,\n): value is BitDevToolsReadableStore<object> {\n if (!value || typeof value !== \"object\") {\n return false;\n }\n\n const candidate = value as unknown as Record<string, unknown>;\n\n return (\n typeof candidate.getState === \"function\" &&\n typeof candidate.getHistoryMetadata === \"function\"\n );\n}\n\nexport function isDevToolsActionableStore(\n value: unknown,\n): value is BitDevToolsActionableStore<object> {\n if (!isDevToolsReadableStore(value)) {\n return false;\n }\n\n const candidate = value as unknown as Record<string, unknown>;\n\n return (\n typeof candidate.undo === \"function\" &&\n typeof candidate.redo === \"function\" &&\n typeof candidate.reset === \"function\"\n );\n}\n\nexport function getDevToolsActionableStore(\n stores: Record<string, unknown>,\n storeId: string,\n): BitDevToolsActionableStore<object> | null {\n const candidate = stores[storeId];\n return isDevToolsActionableStore(candidate) ? candidate : null;\n}\n","import { bitBus } from \"../core\";\nimport type { BitBus } from \"../core\";\nimport type { BitBusStorePort } from \"../core\";\nimport { DEVTOOLS_PROTOCOL_VERSION, isDevToolsActionMessage } from \"./protocol\";\nimport { createDevToolsSnapshotMap } from \"./store-snapshot\";\nimport { getDevToolsActionableStore } from \"./store-port\";\n\nlet activeBridgeCleanup: (() => void) | null = null;\nconst STATE_BATCH_INTERVAL_MS = 50;\n\nexport function setupRemoteBridge(url: string, bus: BitBus = bitBus) {\n if (activeBridgeCleanup) {\n console.warn(\n \"[bit-form] Reiniciando ponte do DevTools (Fast Refresh detectado).\",\n );\n activeBridgeCleanup();\n }\n\n let socket: WebSocket | null = null;\n let unsubscribeBus: (() => void) | null = null;\n let heartbeatInterval: ReturnType<typeof setInterval>;\n let batchFlushTimeout: ReturnType<typeof setTimeout> | null = null;\n const pendingStoreIds = new Set<string>();\n let isIntentionalDisconnect = false;\n\n const sendWhenOpen = (message: Record<string, unknown>) => {\n if (socket?.readyState !== WebSocket.OPEN) {\n return;\n }\n\n socket.send(JSON.stringify(message));\n };\n\n const flushPendingStoreUpdates = () => {\n if (pendingStoreIds.size === 0) {\n return;\n }\n\n const payload = createDevToolsSnapshotMap(\n Array.from(pendingStoreIds).reduce<\n Record<string, BitBusStorePort<object>>\n >((acc, storeId) => {\n const storeInstance = bus.stores[storeId];\n if (storeInstance) {\n acc[storeId] = storeInstance;\n }\n return acc;\n }, {}),\n );\n\n pendingStoreIds.clear();\n batchFlushTimeout = null;\n\n if (Object.keys(payload).length > 0) {\n sendWhenOpen({\n type: \"STATE_UPDATE\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n payload,\n });\n }\n };\n\n const scheduleStoreFlush = () => {\n if (batchFlushTimeout) {\n return;\n }\n\n batchFlushTimeout = setTimeout(() => {\n flushPendingStoreUpdates();\n }, STATE_BATCH_INTERVAL_MS);\n };\n\n const connect = () => {\n isIntentionalDisconnect = false;\n socket = new WebSocket(url);\n\n socket.onopen = () => {\n console.log(\"[bit-form] 🔌 Conectado ao CLI DevTools via WebSocket.\");\n\n sendWhenOpen({\n type: \"HELLO\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n payload: { role: \"server\", protocolVersion: DEVTOOLS_PROTOCOL_VERSION },\n });\n\n const initialState = createDevToolsSnapshotMap(bus.stores);\n if (Object.keys(initialState).length > 0) {\n sendWhenOpen({\n type: \"STATE_UPDATE\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n payload: initialState,\n });\n }\n\n unsubscribeBus = bus.subscribe((storeId, _newState) => {\n pendingStoreIds.add(storeId);\n scheduleStoreFlush();\n });\n\n heartbeatInterval = setInterval(() => {\n sendWhenOpen({\n type: \"PING\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n });\n }, 30000);\n };\n\n socket.onmessage = (event) => {\n try {\n const message = JSON.parse(event.data) as unknown;\n\n if (isDevToolsActionMessage(message)) {\n const { storeId, action } = message.payload;\n const store = getDevToolsActionableStore(bus.stores, storeId);\n\n if (!store) {\n return;\n }\n\n switch (action) {\n case \"undo\":\n store.undo();\n break;\n case \"redo\":\n store.redo();\n break;\n case \"reset\":\n store.reset();\n break;\n }\n }\n } catch (e) {\n console.warn(\"[bit-form] Erro ao processar comando do CLI:\", e);\n }\n };\n\n socket.onclose = () => {\n if (unsubscribeBus) unsubscribeBus();\n clearInterval(heartbeatInterval);\n if (batchFlushTimeout) {\n clearTimeout(batchFlushTimeout);\n batchFlushTimeout = null;\n }\n pendingStoreIds.clear();\n\n if (!isIntentionalDisconnect) {\n console.log(\"[bit-form] Conexão perdida. Reconectando em 3s...\");\n setTimeout(connect, 3000);\n } else {\n console.log(\"[bit-form] Ponte antiga encerrada com sucesso.\");\n }\n };\n };\n\n connect();\n\n const cleanup = () => {\n isIntentionalDisconnect = true;\n\n if (unsubscribeBus) unsubscribeBus();\n clearInterval(heartbeatInterval);\n if (batchFlushTimeout) {\n clearTimeout(batchFlushTimeout);\n batchFlushTimeout = null;\n }\n pendingStoreIds.clear();\n if (\n socket &&\n (socket.readyState === WebSocket.OPEN ||\n socket.readyState === WebSocket.CONNECTING)\n ) {\n socket.close();\n }\n activeBridgeCleanup = null;\n };\n\n activeBridgeCleanup = cleanup;\n\n return cleanup;\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function o(e){let i=e.touched?e.error:void 0,r=!!e.error;return{error:i,touched:e.touched,invalid:!!(e.touched&&e.error),isValidating:e.isValidating,isDirty:e.isDirty,isHidden:e.isHidden,isRequired:e.isRequired,hasError:r}}export{o as a};
|
|
2
|
+
//# sourceMappingURL=chunk-ICYXODTQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/utils/field-meta.ts"],"sourcesContent":["import type { BitFieldState } from \"../store/contracts/types\";\n\nexport interface BitDerivedFieldMeta {\n error: string | undefined;\n touched: boolean;\n invalid: boolean;\n isValidating: boolean;\n isDirty: boolean;\n isHidden: boolean;\n isRequired: boolean;\n hasError: boolean;\n}\n\nexport function deriveFieldMeta<T extends object, TValue>(\n state: Readonly<BitFieldState<T, TValue>>,\n): BitDerivedFieldMeta {\n const error = state.touched ? state.error : undefined;\n const hasError = !!state.error;\n\n return {\n error,\n touched: state.touched,\n invalid: !!(state.touched && state.error),\n isValidating: state.isValidating,\n isDirty: state.isDirty,\n isHidden: state.isHidden,\n isRequired: state.isRequired,\n hasError,\n };\n}\n"],"mappings":"AAaO,SAASA,EACdC,EACqB,CACrB,IAAMC,EAAQD,EAAM,QAAUA,EAAM,MAAQ,OACtCE,EAAW,CAAC,CAACF,EAAM,MAEzB,MAAO,CACL,MAAAC,EACA,QAASD,EAAM,QACf,QAAS,CAAC,EAAEA,EAAM,SAAWA,EAAM,OACnC,aAAcA,EAAM,aACpB,QAASA,EAAM,QACf,SAAUA,EAAM,SAChB,WAAYA,EAAM,WAClB,SAAAE,CACF,CACF","names":["deriveFieldMeta","state","error","hasError"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17; var _class18;var _chunkRHMJPKNVcjs = require('./chunk-RHMJPKNV.cjs');var _chunkOLQVH24Zcjs = require('./chunk-OLQVH24Z.cjs');var _chunk6LNXTSZ6cjs = require('./chunk-6LNXTSZ6.cjs');function kt(r){let{path:t,getFieldConfig:e,masks:i}=r,s=_optionalChain([e, 'call', _2 => _2(t), 'optionalAccess', _3 => _3.mask]);if(s)return typeof s=="string"?_optionalChain([i, 'optionalAccess', _4 => _4[s]]):s}function It(r){let{state:t,path:e,value:i,isHidden:s,isRequired:a,isDirty:n,isValidating:o}=r,d=e;return{value:i,error:t.errors[d],touched:!!t.touched[d],isHidden:s,isRequired:a,isDirty:n,isValidating:o}}var D=Symbol.for("bit-form.framework-store-api");var A=Symbol.for("bit-form.hooks-api");var I=class{constructor(t){this.baselineValues=_chunk6LNXTSZ6cjs.a.call(void 0, t)}getValues(){return this.baselineSnapshot||(this.baselineSnapshot=Object.freeze(_chunk6LNXTSZ6cjs.a.call(void 0, this.baselineValues))),this.baselineSnapshot}setValues(t){this.baselineValues=_chunk6LNXTSZ6cjs.a.call(void 0, t),this.baselineSnapshot=void 0}};var O= (_class =class{constructor(t){;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);this.getComputedEntries=t}__init() {this.equalityCache=new Map}__init2() {this.reverseDepsCache=null}__init3() {this.childDepsIndex=null}__init4() {this.validatedEntriesSignature=null}__init5() {this.validatedEntriesRef=null}__init6() {this.orderedAllEntriesCache=null}__init7() {this.orderedIndexByPathCache=null}isCacheableScalar(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 s=this.resolveEntriesToRun(i,e);if(s.length===0)return t;let a=t;for(let n of s){let o=n.compute(a),d=_chunk6LNXTSZ6cjs.f.call(void 0, a,n.path),p=this.equalityCache.get(n.path),l,c=this.isCacheableScalar(d)&&this.isCacheableScalar(o);c&&p&&p.current===d&&p.next===o?l=p.equal:(l=_chunk6LNXTSZ6cjs.d.call(void 0, d,o),c?this.equalityCache.set(n.path,{current:d,next:o,equal:l}):this.equalityCache.delete(n.path)),l||(a=_chunk6LNXTSZ6cjs.g.call(void 0, a,n.path,o))}return a}getReverseDependencies(t){if(this.reverseDepsCache)return this.reverseDepsCache;let e=new Map;for(let s of t)for(let a of s.dependsOn){let n=e.get(a);n||(n=new Set,e.set(a,n)),n.add(s.path)}let i=new Map;for(let s of e.keys()){let a=s.split(".");for(let n=1;n<a.length;n++){let o=a.slice(0,n).join("."),d=i.get(o);d||(d=new Set,i.set(o,d)),d.add(s)}}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),s=new Set,a=[...e],n=0;for(;n<a.length;){let l=a[n++],c=this.getDependentsForPath(i,l);if(c)for(let u of c)s.has(u)||(s.add(u),a.push(u))}if(s.size===0)return[];let o=this.getOrderedAllEntries(t),d=this.getOrderedIndexByPath(t,o),p=[];return s.forEach(l=>{let c=d.get(l);if(c===void 0)return;let u=o[c];u&&p.push({index:c,entry:u})}),p.sort((l,c)=>l.index-c.index),p.map(l=>l.entry)}orderEntries(t){if(t.length<=1)return t;let e=new Map(t.map(o=>[o.path,o])),i=new Map,s=new Map;t.forEach(o=>i.set(o.path,0)),t.forEach(o=>{o.dependsOn.forEach(d=>{if(!e.has(d))return;let p=_nullishCoalesce(s.get(d), () => (new Set));p.has(o.path)||(p.add(o.path),s.set(d,p),i.set(o.path,(_nullishCoalesce(i.get(o.path), () => (0)))+1))})});let a=t.filter(o=>(_nullishCoalesce(i.get(o.path), () => (0)))===0).map(o=>o.path),n=[];for(;a.length>0;){let o=a.shift();n.push(o);let d=s.get(o);d&&d.forEach(p=>{let l=(_nullishCoalesce(i.get(p), () => (0)))-1;i.set(p,l),l===0&&a.push(p)})}if(n.length!==t.length)throw new Error("BitStore: cyclic computed dependencies detected. Check computedDependsOn definitions.");return n.map(o=>e.get(o))}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 s=new Map;return e.forEach((a,n)=>{s.set(a.path,n)}),this.orderedIndexByPathCache={signature:i,indexByPath:s},s}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,s=o=>{let d=t.get(o);d&&d.forEach(p=>i.add(p))};s(e);let a=e.split(".");for(;a.length>1;)a.pop(),s(a.join("."));let n=_optionalChain([this, 'access', _5 => _5.childDepsIndex, 'optionalAccess', _6 => _6.get, 'call', _7 => _7(e)]);if(n)for(let o of n)s(o);return i}assertDependencies(t){if(t.dependsOn.length===0)throw new Error(`BitStore: computed field \`${t.path}\` requires explicit computedDependsOn in v4.`);if(t.dependsOn.includes(t.path))throw new Error(`BitStore: computed field \`${t.path}\` cannot depend on itself.`)}}, _class);var j= (_class2 =class{constructor() { _class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this); }__init8() {this.dirtyPaths=new Set}__init9() {this.dirtyPathIndex=new Set}__init10() {this.dirtyPrefixRefCount=new Map}__init11() {this.childrenByPrefix=new Map}updateForPath(t,e,i){this.removeDirtyChildren(t);let s=_chunk6LNXTSZ6cjs.f.call(void 0, e,t),a=_chunk6LNXTSZ6cjs.f.call(void 0, i,t);return _chunk6LNXTSZ6cjs.c.call(void 0, s,a)?this.removeDirtyPath(t):this.addDirtyPath(t),this.dirtyPaths.size>0}rebuild(t,e){return this.dirtyPaths=_chunk6LNXTSZ6cjs.e.call(void 0, t,e),this.dirtyPrefixRefCount.clear(),this.rebuildIndex(),this.dirtyPaths.size>0}clear(){this.dirtyPaths.clear(),this.dirtyPathIndex.clear(),this.dirtyPrefixRefCount.clear(),this.childrenByPrefix.clear()}get isDirty(){return this.dirtyPaths.size>0}getDirtyPaths(){return this.dirtyPaths}isPathDirty(t){if(this.dirtyPathIndex.has(t))return!0;let e=t.lastIndexOf(".");for(;e>-1;){let i=t.slice(0,e);if((_nullishCoalesce(this.dirtyPrefixRefCount.get(i), () => (0)))>0)return!0;e=t.lastIndexOf(".",e-1)}return!1}buildDirtyValues(t){if(this.dirtyPaths.size===0)return{};let e=[],i=[...this.dirtyPaths].sort(),s=new Set,a=new Set,n=o=>{let d=o.lastIndexOf(".");for(;d>-1;){if(a.has(o.slice(0,d)))return!0;d=o.lastIndexOf(".",d-1)}return!1};for(let o of i){if(n(o))continue;let d=o.match(/^(.+)\.\d+/);if(d){let p=d[1];if(s.has(p))continue;s.add(p);let l=_chunk6LNXTSZ6cjs.f.call(void 0, t,p);e.push([p,l]),a.add(p)}else{let p=_chunk6LNXTSZ6cjs.f.call(void 0, t,o);e.push([o,p]),a.add(o)}}return e.length===0?{}:_chunk6LNXTSZ6cjs.h.call(void 0, {},e)}rebuildIndex(){let t=new Set,e=new Map,i=new Map;for(let s of this.dirtyPaths)this.forEachPathPrefix(s,a=>{t.add(a),e.set(a,(_nullishCoalesce(e.get(a), () => (0)))+1)}),this.forEachAncestorPrefix(s,a=>{let n=i.get(a);n?n.add(s):i.set(a,new Set([s]))});this.dirtyPathIndex=t,this.dirtyPrefixRefCount=e,this.childrenByPrefix=i}removeDirtyChildren(t){let e=this.childrenByPrefix.get(t);if(!(!e||e.size===0))for(let i of[...e])this.removeDirtyPath(i)}addDirtyPath(t){this.dirtyPaths.has(t)||(this.dirtyPaths.add(t),this.forEachPathPrefix(t,e=>{this.dirtyPathIndex.add(e),this.dirtyPrefixRefCount.set(e,(_nullishCoalesce(this.dirtyPrefixRefCount.get(e), () => (0)))+1)}),this.forEachAncestorPrefix(t,e=>{let i=this.childrenByPrefix.get(e);i?i.add(t):this.childrenByPrefix.set(e,new Set([t]))}))}removeDirtyPath(t){this.dirtyPaths.has(t)&&(this.dirtyPaths.delete(t),this.forEachPathPrefix(t,e=>{let i=(_nullishCoalesce(this.dirtyPrefixRefCount.get(e), () => (0)))-1;if(i<=0){this.dirtyPrefixRefCount.delete(e),this.dirtyPathIndex.delete(e);return}this.dirtyPrefixRefCount.set(e,i)}),this.forEachAncestorPrefix(t,e=>{_optionalChain([this, 'access', _8 => _8.childrenByPrefix, 'access', _9 => _9.get, 'call', _10 => _10(e), 'optionalAccess', _11 => _11.delete, 'call', _12 => _12(t)])}))}forEachPathPrefix(t,e){let i=t.split("."),s="";for(let a of i)s=s?`${s}.${a}`:a,e(s)}forEachAncestorPrefix(t,e){let i=t.split("."),s="";for(let a=0;a<i.length-1;a++)s=s?`${s}.${i[a]}`:i[a],e(s)}}, _class2);var H= (_class3 =class{constructor() { _class3.prototype.__init12.call(this); }__init12() {this.masks=new Map}registerMask(t,e){this.masks.set(t,e)}unregisterMask(t){this.masks.has(t)&&this.masks.delete(t)}resolveMask(t){return this.masks.get(t)}getAllMasks(){return Object.fromEntries(this.masks.entries())}clear(){this.masks.clear()}}, _class3);var z= (_class4 =class{constructor() { _class4.prototype.__init13.call(this);_class4.prototype.__init14.call(this);_class4.prototype.__init15.call(this);_class4.prototype.__init16.call(this);_class4.prototype.__init17.call(this); }__init13() {this.fieldConfigs=new Map}__init14() {this.scopeFieldsIndex=null}__init15() {this.computedEntriesCache=null}__init16() {this.normalizerEntriesCache=null}__init17() {this.transformEntriesCache=null}get(t){return this.fieldConfigs.get(t)}set(t,e){this.fieldConfigs.set(t,e),this.registerCachedIndexes(t,e)}delete(t){let e=this.fieldConfigs.get(t);return this.fieldConfigs.delete(t),this.unregisterCachedIndexes(t,e),e}has(t){return this.fieldConfigs.has(t)}forEach(t){this.fieldConfigs.forEach((e,i)=>t(e,i))}entries(){return Array.from(this.fieldConfigs.entries())}getScopeFields(t){if(!this.scopeFieldsIndex){let e=new Map;this.forEach((i,s)=>{if(!i.scope)return;let a=_nullishCoalesce(e.get(i.scope), () => (new Set));a.add(s),e.set(i.scope,a)}),this.scopeFieldsIndex=e}return Array.from(_nullishCoalesce(this.scopeFieldsIndex.get(t), () => ([])))}getComputedEntries(){if(!this.computedEntriesCache){let t=[];this.forEach((e,i)=>{e.computed&&t.push({path:i,compute:e.computed,dependsOn:e.computedDependsOn})}),this.computedEntriesCache=t}return this.computedEntriesCache}getTransformEntries(){if(!this.transformEntriesCache){let t=[];this.forEach((e,i)=>{e.transform&&t.push([i,e.transform])}),this.transformEntriesCache=t}return this.transformEntriesCache}getNormalizerEntries(){if(!this.normalizerEntriesCache){let t=[];this.forEach((e,i)=>{e.normalize&&t.push({path:i,normalize:e.normalize,dependsOn:_optionalChain([e, 'access', _13 => _13.normalizeDependsOn, 'optionalAccess', _14 => _14.length])?e.normalizeDependsOn:[i]})}),this.normalizerEntriesCache=t}return this.normalizerEntriesCache}invalidateIndexes(){this.scopeFieldsIndex=null,this.computedEntriesCache=null,this.normalizerEntriesCache=null,this.transformEntriesCache=null}registerCachedIndexes(t,e){if(this.scopeFieldsIndex&&e.scope){let i=_nullishCoalesce(this.scopeFieldsIndex.get(e.scope), () => (new Set));i.add(t),this.scopeFieldsIndex.set(e.scope,i)}this.computedEntriesCache&&e.computed&&this.computedEntriesCache.push({path:t,compute:e.computed,dependsOn:e.computedDependsOn}),this.normalizerEntriesCache&&e.normalize&&this.normalizerEntriesCache.push({path:t,normalize:e.normalize,dependsOn:_optionalChain([e, 'access', _15 => _15.normalizeDependsOn, 'optionalAccess', _16 => _16.length])?e.normalizeDependsOn:[t]}),this.transformEntriesCache&&e.transform&&this.transformEntriesCache.push([t,e.transform])}unregisterCachedIndexes(t,e){if(!e){this.invalidateIndexes();return}if(this.scopeFieldsIndex&&e.scope){let i=this.scopeFieldsIndex.get(e.scope);i&&(i.delete(t),i.size>0?this.scopeFieldsIndex.set(e.scope,i):this.scopeFieldsIndex.delete(e.scope))}this.computedEntriesCache&&e.computed&&(this.computedEntriesCache=this.computedEntriesCache.filter(i=>i.path!==t)),this.normalizerEntriesCache&&e.normalize&&(this.normalizerEntriesCache=this.normalizerEntriesCache.filter(i=>i.path!==t)),this.transformEntriesCache&&e.transform&&(this.transformEntriesCache=this.transformEntriesCache.filter(([i])=>i!==t))}}, _class4);var q= (_class5 =class{constructor(t){;_class5.prototype.__init18.call(this);_class5.prototype.__init19.call(this);_class5.prototype.__init20.call(this);_class5.prototype.__init21.call(this);_class5.prototype.__init22.call(this);_class5.prototype.__init23.call(this);_class5.prototype.__init24.call(this);this.getFieldConfig=t}__init18() {this.dependencies=new Map}__init19() {this.hiddenFields=new Set}__init20() {this.conditionalVisibilityPaths=new Set}__init21() {this.requiredPathsByDependency=new Map}__init22() {this.requiredConditionalPaths=new Set}__init23() {this.requiredEvaluationVersion=0}__init24() {this.requiredEvaluationCache=new Map}getHiddenFields(){return this.hiddenFields}onRegister(t,e,i){_optionalChain([e, 'access', _17 => _17.conditional, 'optionalAccess', _18 => _18.showIf])&&this.conditionalVisibilityPaths.add(t);let s=_optionalChain([e, 'access', _19 => _19.conditional, 'optionalAccess', _20 => _20.dependsOn]);s&&s.forEach(a=>{this.dependencies.has(a)||this.dependencies.set(a,new Set),this.dependencies.get(a).add(t)}),s&&_optionalChain([e, 'access', _21 => _21.conditional, 'optionalAccess', _22 => _22.requiredIf])&&(this.requiredConditionalPaths.add(t),s.forEach(a=>{this.requiredPathsByDependency.has(a)||this.requiredPathsByDependency.set(a,new Set),this.requiredPathsByDependency.get(a).add(t)})),this.requiredEvaluationVersion+=1,this.requiredEvaluationCache.clear(),this.evaluateFieldCondition(t,i)}onUnregister(t,e){this.hiddenFields.delete(t),this.conditionalVisibilityPaths.delete(t),this.dependencies.delete(t),this.requiredEvaluationVersion+=1,this.requiredEvaluationCache.clear(),this.requiredConditionalPaths.delete(t),_optionalChain([e, 'optionalAccess', _23 => _23.conditional, 'optionalAccess', _24 => _24.dependsOn, 'optionalAccess', _25 => _25.forEach, 'call', _26 => _26(i=>{let s=this.requiredPathsByDependency.get(i);s&&(s.delete(t),s.size===0&&this.requiredPathsByDependency.delete(i))})]),this.dependencies.forEach(i=>{i.delete(t)})}isHidden(t){return this.hiddenFields.has(t)}hasDependents(t){return(_nullishCoalesce(_optionalChain([this, 'access', _27 => _27.dependencies, 'access', _28 => _28.get, 'call', _29 => _29(t), 'optionalAccess', _30 => _30.size]), () => (0)))>0}isRequired(t,e){let i=this.getFieldConfig(t);if(!i||this.isHidden(t)||!_optionalChain([i, 'access', _31 => _31.conditional, 'optionalAccess', _32 => _32.requiredIf]))return!1;let s=this.requiredEvaluationCache.get(t);if(s&&s.version===this.requiredEvaluationVersion&&s.valuesRef===e)return s.result;let a=!!i.conditional.requiredIf(e);return this.requiredEvaluationCache.set(t,{version:this.requiredEvaluationVersion,valuesRef:e,result:a}),a}getRequiredErrors(t){let e={};return this.requiredConditionalPaths.forEach(i=>{let s=this.getFieldConfig(i);if(s&&this.isRequired(i,t)){let a=_chunk6LNXTSZ6cjs.f.call(void 0, t,i);this.isEmpty(a)&&(e[i]=_nullishCoalesce(_optionalChain([s, 'access', _33 => _33.conditional, 'optionalAccess', _34 => _34.requiredMessage]), () => ("required field")))}}),e}evaluateAll(t){this.conditionalVisibilityPaths.forEach(e=>{this.evaluateFieldCondition(e,t)})}updateDependencies(t,e,i){let s=new Set,a=new Set,n=new Set,o=[t],d=new Set;for(;o.length>0;){let p=o.shift();if(d.has(p))continue;d.add(p);let l=this.dependencies.get(p);l&&l.forEach(c=>{s.add(c);let u=this.isHidden(c),h=this.isRequired(c,e);this.evaluateFieldCondition(c,i);let S=this.isHidden(c),B=this.isRequired(c,i);u!==S&&a.add(c),h!==B&&n.add(c),o.push(c)})}return{affectedFields:Array.from(s),visibilityChanged:Array.from(a),requiredChanged:Array.from(n)}}evaluateFieldCondition(t,e){let s=_optionalChain([this, 'access', _35 => _35.getFieldConfig, 'call', _36 => _36(t), 'optionalAccess', _37 => _37.conditional, 'optionalAccess', _38 => _38.showIf]);s&&(s(e)?this.hiddenFields.delete(t):this.hiddenFields.add(t))}isEmpty(t){return t==null||typeof t=="string"&&t.trim()===""||Array.isArray(t)&&t.length===0}}, _class5);function Ge(r){return r.replace(/\.+$/g,"")}function E(r){return Ge(r.trim())}function v(r,t){let e=E(t);return e.length===0?!1:r===e||r.startsWith(`${e}.`)}function bt(r,t){return E(t===void 0?r:`${r}.${t}`)}var U= (_class6 =class{constructor() { _class6.prototype.__init25.call(this);_class6.prototype.__init26.call(this); }__init25() {this.catalog=new z}__init26() {this.conditions=new q(t=>this.catalog.get(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){this.catalog.set(t,e),this.conditions.onRegister(t,e,i)}unregister(t){let e=this.catalog.delete(t);this.conditions.onUnregister(t,e)}unregisterPrefix(t){let e=[],i=E(t);return i.length===0||(this.catalog.forEach((s,a)=>{v(a,i)&&e.push([a,s])}),e.forEach(([s,a])=>{this.catalog.delete(s),this.conditions.onUnregister(s,a)})),e}isHidden(t){return this.conditions.isHidden(t)}hasDependents(t){return this.conditions.hasDependents(t)}isRequired(t,e){return this.conditions.isRequired(t,e)}getRequiredErrors(t){return this.conditions.getRequiredErrors(t)}evaluateAll(t){this.conditions.evaluateAll(t)}updateDependencies(t,e,i){return this.conditions.updateDependencies(t,e,i)}getScopeFields(t){return this.catalog.getScopeFields(t)}getComputedEntries(){return this.catalog.getComputedEntries()}getTransformEntries(){return this.catalog.getTransformEntries()}getNormalizerEntries(){return this.catalog.getNormalizerEntries()}invalidateIndexes(){this.catalog.invalidateIndexes()}}, _class6);function Ye(){return`bit-form-${Math.random().toString(36).slice(2,9)}`}function Xe(r){typeof console<"u"&&typeof console.error=="function"&&console.error(r)}function Ot(r={}){let t=_nullishCoalesce(r.initialValues, () => ({})),e=r.validation,i=r.history,s=r.name?`bit-form:${r.name}:draft`:"bit-form:draft",a=_nullishCoalesce(r.onUnhandledError, () => (Xe)),n=_optionalChain([r, 'access', _39 => _39.persist, 'optionalAccess', _40 => _40.onError]),o={enabled:_nullishCoalesce(_optionalChain([r, 'access', _41 => _41.persist, 'optionalAccess', _42 => _42.enabled]), () => (!1)),key:_nullishCoalesce(_optionalChain([r, 'access', _43 => _43.persist, 'optionalAccess', _44 => _44.key]), () => (s)),storage:_optionalChain([r, 'access', _45 => _45.persist, 'optionalAccess', _46 => _46.storage]),autoSave:_nullishCoalesce(_optionalChain([r, 'access', _47 => _47.persist, 'optionalAccess', _48 => _48.autoSave]), () => (!0)),debounceMs:_nullishCoalesce(_optionalChain([r, 'access', _49 => _49.persist, 'optionalAccess', _50 => _50.debounceMs]), () => (300)),mode:_nullishCoalesce(_optionalChain([r, 'access', _51 => _51.persist, 'optionalAccess', _52 => _52.mode]), () => ("values")),serialize:_nullishCoalesce(_optionalChain([r, 'access', _53 => _53.persist, 'optionalAccess', _54 => _54.serialize]), () => (JSON.stringify)),deserialize:_nullishCoalesce(_optionalChain([r, 'access', _55 => _55.persist, 'optionalAccess', _56 => _56.deserialize]), () => ((d=>JSON.parse(d)))),onError:d=>{if(n){n(d);return}a(d,"persist")}};return{name:r.name,initialValues:_chunk6LNXTSZ6cjs.a.call(void 0, t),resolver:_optionalChain([e, 'optionalAccess', _57 => _57.resolver]),validationDelay:_nullishCoalesce(_optionalChain([e, 'optionalAccess', _58 => _58.delay]), () => (300)),history:{enabled:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _59 => _59.enabled]), () => (!1)),limit:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _60 => _60.limit]), () => (50))},masks:r.masks,fields:r.fields,devTools:r.devTools,persist:o,idFactory:_nullishCoalesce(r.idFactory, () => (Ye)),plugins:_nullishCoalesce(r.plugins, () => ([])),scheduler:r.scheduler,subscriptionCacheSize:r.subscriptionCacheSize,trackedSubscriptions:_nullishCoalesce(r.trackedSubscriptions, () => (!1)),bus:r.bus,onUnhandledError:a}}function _(r,t){if((!r||r.length===0)&&(!t||t.length===0))return;let e=new Set(_nullishCoalesce(r, () => ([])));return _optionalChain([t, 'optionalAccess', _61 => _61.forEach, 'call', _62 => _62(i=>e.add(i))]),Array.from(e)}function jt(r){let{values:t,entries:e,deriveValue:i}=r,s=[];for(let a of e){let n=_chunk6LNXTSZ6cjs.f.call(void 0, t,a.path),o=i(a,n);_chunk6LNXTSZ6cjs.c.call(void 0, n,o)||s.push([a.path,o])}return s}function Ze(r){let t=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _63 => _63.includes, 'call', _64 => _64("*")]), () => (!1)),e=new Set(_nullishCoalesce(r, () => ([]))),i=new Set;for(let s of e){i.add(s);let a=s.lastIndexOf(".");for(;a>-1;)i.add(s.slice(0,a)),a=s.lastIndexOf(".",a-1)}return s=>{if(!r||r.length===0||t||e.has(s)||i.has(s))return!0;let a=s.lastIndexOf(".");for(;a>-1;){if(e.has(s.slice(0,a)))return!0;a=s.lastIndexOf(".",a-1)}return!1}}function Qe(r,t){if(!t||t.length===0||t.includes("*"))return r;let e=Ze(t);return r.filter(i=>i.dependsOn.some(s=>e(s)))}function N(r){let{values:t,changedPaths:e,normalizerEntries:i,applyComputed:s}=r,a=Qe(i,e);if(a.length===0)return s(t,e);let n=jt({values:t,entries:a,deriveValue:(p,l)=>p.normalize(l,t)}),o=n.length>0?_chunk6LNXTSZ6cjs.h.call(void 0, t,n):t,d=_(e,n.map(([p])=>p));return s(o,d)}function Ht(r){let{values:t,sourceValues:e,transformEntries:i}=r;if(i.length===0)return t;let s=jt({values:t,entries:i.map(([a,n])=>({path:a,transform:n})),deriveValue:(a,n)=>a.transform(n,e)});return s.length===0?t:_chunk6LNXTSZ6cjs.h.call(void 0, t,s)}var L=class{constructor(t,e,i=!0,s){this.storeId=t;this.bus=e;this.enableBusDispatch=i;this.storeBusPort=s}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 W=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 K=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()}};var $=class{constructor(t,e,i,s,a=!0,n){this.persistEffects=new W(i),this.pluginEffects=new K(s),this.busEffects=new L(t,e,a,n)}attachStorePort(t){this.busEffects.attachStorePort(t)}initialize(){this.pluginEffects.initialize(),this.busEffects.initialize()}onStateUpdated(t,e){this.persistEffects.onStateUpdated(t,e),this.busEffects.onStateUpdated(t)}restorePersisted(){return this.persistEffects.restorePersisted()}savePersistedNow(){return this.persistEffects.savePersistedNow()}clearPersisted(){return this.persistEffects.clearPersisted()}beforeValidate(t){return this.pluginEffects.beforeValidate(t)}afterValidate(t){return this.pluginEffects.afterValidate(t)}beforeSubmit(t){return this.pluginEffects.beforeSubmit(t)}afterSubmit(t){return this.pluginEffects.afterSubmit(t)}onFieldChange(t){this.pluginEffects.onFieldChange(t)}reportOperationalError(t){return this.pluginEffects.reportOperationalError(t)}destroy(){this.persistEffects.destroy(),this.pluginEffects.destroy(),this.busEffects.destroy()}};function ti(){if(typeof globalThis>"u")return;let r=globalThis.localStorage;if(r)return{getItem:t=>r.getItem(t),setItem:(t,e)=>r.setItem(t,e),removeItem:t=>r.removeItem(t)}}var J=class{constructor(t,e,i,s){this.config=t;this.getValues=e;this.getDirtyValues=i;this.applyRestoredValues=s}getStorage(){return this.config.storage||ti()}canPersist(){return!!(this.config.enabled&&this.config.key&&this.getStorage())}handleError(t){_optionalChain([this, 'access', _65 => _65.config, 'access', _66 => _66.onError, 'optionalCall', _67 => _67(t)])}async saveNow(){if(!this.canPersist())return;let t=this.getStorage();if(t)try{let e=this.config.mode==="dirtyValues"?this.getDirtyValues():this.getValues(),i=this.config.serialize(e);await t.setItem(this.config.key,i)}catch(e){this.handleError(e)}}queueSave(){!this.canPersist()||!this.config.autoSave||(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.saveNow()},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 G= (_class7 =class{constructor(t,e){;_class7.prototype.__init27.call(this);_class7.prototype.__init28.call(this);_class7.prototype.__init29.call(this);this.plugins=t;this.contextFactory=e}__init27() {this.teardownFns=[]}__init28() {this.notifyingError=!1}__init29() {this.cachedContext=null}setupAll(){let t=this.getContext();this.plugins.forEach(e=>{if(e.setup)try{let i=e.setup(t);typeof i=="function"&&this.teardownFns.push(i)}catch(i){this.reportError("setup",i,void 0,e.name)}})}async beforeValidate(t){await this.emitHook("beforeValidate",t)}async afterValidate(t){await this.emitHook("afterValidate",t)}async beforeSubmit(t){await this.emitHook("beforeSubmit",t)}async afterSubmit(t){await this.emitHook("afterSubmit",t)}onFieldChange(t){let e=this.getContext();this.plugins.forEach(i=>{let s=_optionalChain([i, 'access', _68 => _68.hooks, 'optionalAccess', _69 => _69.onFieldChange]);if(s)try{let a=s(t,e);Promise.resolve(a).catch(n=>{this.reportError("onFieldChange",n,t,i.name)})}catch(a){this.reportError("onFieldChange",a,t,i.name)}})}async reportError(t,e,i,s){if(this.notifyingError)return;this.notifyingError=!0;let a=this.getContext(),n={source:t,pluginName:s,error:e,event:i,values:a.getState().values,state:a.getState()};for(let o of this.plugins){let d=_optionalChain([o, 'access', _70 => _70.hooks, 'optionalAccess', _71 => _71.onError]);if(d)try{await d(n,a)}catch (e2){}}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 s of this.plugins){let a=_optionalChain([s, 'access', _72 => _72.hooks, 'optionalAccess', _73 => _73[t]]);if(a)try{await a(e,i)}catch(n){await this.reportError(t,n,e,s.name)}}}getContext(){return this.cachedContext||(this.cachedContext=this.contextFactory()),this.cachedContext}}, _class7);var Bt=typeof globalThis<"u"?globalThis:typeof global<"u"?global:window;Bt.__BIT_FORM__||(Bt.__BIT_FORM__={stores:{},listeners:new Set,dispatch(r,t){this.listeners.forEach(e=>e(r,t))},subscribe(r){return this.listeners.add(r),()=>{this.listeners.delete(r)}}});var Tt=Bt.__BIT_FORM__,ei={stores:{},listeners:new Set,dispatch:()=>{},subscribe:()=>()=>{}};function vt(){return ei}function ii(){let r=new Set;return{stores:{},listeners:r,dispatch(t,e){r.forEach(i=>i(t,e))},subscribe(t){return r.add(t),()=>r.delete(t)}}}function ri(r){return r.bus?!0:typeof r.devTools=="boolean"?r.devTools:r.devTools&&typeof r.devTools=="object"?r.devTools.enabled!==!1:!1}function zt(r){let{storeId:t,storeBusPort:e,config:i,getState:s,getConfig:a,getValues:n,getDirtyValues:o,applyPersistedValues:d}=r,p=new J(i.persist,n,o,d),l=new G([...i.plugins],()=>({storeId:t,getState:()=>s(),getConfig:()=>a()})),c=ri(i),u=typeof process<"u"&&typeof process.env<"u"&&process.env.VITEST==="true",h=c?_nullishCoalesce(i.bus, () => ((u?vt():Tt))):vt(),S=new $(t,h,p,l,c,e);return S.initialize(),S}function g(r,t,e){return{kind:"state.patch",partialState:r,changedPaths:t,skipComputed:_optionalChain([e, 'optionalAccess', _74 => _74.skipComputed])}}function Pt(r){return{kind:"field.touchMany",paths:r}}function P(r){return{kind:"form.persistMeta",patch:r}}function V(r,t){return{kind:"validation.commit",errors:r,isValid:t}}async function qt(r){let{dispatch:t,effects:e}=r;t(P({isRestoring:!0,error:null}));try{return await e.restorePersisted()}catch(i){return t(P({isRestoring:!1,error:i instanceof Error?i:new Error(String(i))})),!1}finally{t(P({isRestoring:!1}))}}async function Ut(r){let{dispatch:t,effects:e}=r;t(P({isSaving:!0,error:null}));try{await e.savePersistedNow()}catch(i){t(P({isSaving:!1,error:i instanceof Error?i:new Error(String(i))}));return}t(P({isSaving:!1}))}async function _t(r){let{dispatch:t,effects:e}=r;t(P({error:null}));try{await e.clearPersisted()}catch(i){t(P({error:i instanceof Error?i:new Error(String(i))}))}}function Nt(r){let{values:t,state:e,initialValues:i,validation:s,fieldRegistry:a,dirtyManager:n,dispatch:o,saveHistorySnapshot:d}=r,p=_chunk6LNXTSZ6cjs.a.call(void 0, _chunk6LNXTSZ6cjs.b.call(void 0, i,t));s.cancelAll(),a.evaluateAll(p);let l=n.rebuild(p,i);o(g({values:p,errors:{},touched:{},isValidating:{},persist:{...e.persist,error:null},isValid:!0,isDirty:l,isSubmitting:!1})),d(),s.validate()}function Lt(r){let{state:t,path:e}=r,i={...t.errors},s={...t.touched},a=!1;return i[e]&&(delete i[e],a=!0),s[e]&&(delete s[e],a=!0),a?{errors:i,touched:s}:null}function Wt(r){let{path:t,config:e,state:i,fieldRegistry:s,subscriptions:a,stateReader:n,invalidateFieldIndexes:o}=r;s.register(t,e,i.values),o(),a.invalidatePathExpansionCache(t),n.invalidatePath(t),e.scope&&a.notify(i,[_chunkRHMJPKNVcjs.d.call(void 0, e.scope)]),s.isHidden(t)&&a.notify(i,[t])}function Kt(r){let{path:t,state:e,hasStaticConfig:i,fieldRegistry:s,subscriptions:a,validationCleanupField:n,invalidateFieldIndexes:o,dispatch:d}=r;if(i)return;let p=s.getFieldConfig(t);n(t),s.unregister(t),o(),a.invalidatePathExpansionCache(t),_optionalChain([p, 'optionalAccess', _75 => _75.scope])&&a.notify(e,[_chunkRHMJPKNVcjs.d.call(void 0, p.scope)]);let l=Lt({state:e,path:t});l&&d(g({errors:l.errors,touched:l.touched}))}function Y(r){let{prefix:t,state:e,fieldRegistry:i,subscriptions:s,validationCleanupPrefix:a,invalidateFieldIndexes:n}=r;a(t);let o=i.unregisterPrefix(t);n(),s.invalidatePathExpansionCache(t),new Set(o.map(([,p])=>p.scope).filter(p=>!!p)).forEach(p=>{s.notify(e,[_chunkRHMJPKNVcjs.d.call(void 0, p)])})}var X= (_class8 =class{constructor(t,e=500){;_class8.prototype.__init30.call(this);_class8.prototype.__init31.call(this);_class8.prototype.__init32.call(this);_class8.prototype.__init33.call(this);_class8.prototype.__init34.call(this);_class8.prototype.__init35.call(this);this.getState=t;this.MAX_PATH_EXPANSION_CACHE_SIZE=e}__init30() {this.listeners=new Set}__init31() {this.pathScopedSubscriptions=new Map}__init32() {this.pathSelectorIndex=new Map}__init33() {this.pathExpansionCache=new Map}__init34() {this.subscriptionSeenVersion=new Map}__init35() {this.notifyVersion=0}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}subscribeSelector(t,e,i,s){let a=t(this.getState()),n={notify:d=>{let p=t(d);s(a,p)||(a=p,e(p))}},o=this.normalizeSubscriptionPaths(i.paths);return this.pathScopedSubscriptions.set(n,o),o.forEach(d=>{this.forEachIndexPath(d,p=>{let l=_nullishCoalesce(this.pathSelectorIndex.get(p), () => (new Set));l.add(n),this.pathSelectorIndex.set(p,l)})}),i.emitImmediately&&e(a),()=>{this.subscriptionSeenVersion.delete(n);let d=this.pathScopedSubscriptions.get(n);d&&(d.forEach(p=>{this.forEachIndexPath(p,l=>{let c=this.pathSelectorIndex.get(l);c&&(c.delete(n),c.size===0&&this.pathSelectorIndex.delete(l))})}),this.pathScopedSubscriptions.delete(n))}}notify(t,e){if(this.listeners.forEach(a=>a()),this.pathScopedSubscriptions.size===0)return;let i=this.normalizeChangedPathIterable(e);if(i.length===0||i.includes("*")){this.pathScopedSubscriptions.forEach((a,n)=>{n.notify(t)});return}if(i.length===1&&this.isSimplePath(i[0])){this.collectSubscribersForSingleChangedPath(i[0]).forEach(n=>{n.notify(t)});return}this.collectSubscribersForChangedPaths(i).forEach(a=>{a.notify(t)})}destroy(){this.listeners.clear(),this.pathScopedSubscriptions.clear(),this.pathSelectorIndex.clear(),this.pathExpansionCache.clear(),this.subscriptionSeenVersion.clear()}invalidatePathExpansionCache(t){if(!t){this.pathExpansionCache.clear();return}let e=E(t);if(e.length===0){this.pathExpansionCache.clear();return}for(let i of this.pathExpansionCache.keys())(v(i,e)||v(e,i))&&this.pathExpansionCache.delete(i)}normalizeSubscriptionPaths(t){if(!t||t.length===0)return[];let e=new Set,i=[];for(let s of t){let a=s.trim();a.length===0||e.has(a)||(e.add(a),i.push(a))}return i}normalizeChangedPathIterable(t){if(!t)return[];let e=new Set,i=[];for(let s of t){let a=s.trim();a.length===0||e.has(a)||(e.add(a),i.push(a))}return i}collectSubscribersForChangedPaths(t){let e=[],i=++this.notifyVersion,s=a=>{let n=this.pathSelectorIndex.get(a);n&&n.forEach(o=>{(_nullishCoalesce(this.subscriptionSeenVersion.get(o), () => (0)))>=i||(this.subscriptionSeenVersion.set(o,i),e.push(o))})};return t.forEach(a=>{this.forEachLookupPath(a,s)}),e}collectSubscribersForSingleChangedPath(t){let e=[],i=++this.notifyVersion,s=a=>{let n=this.pathSelectorIndex.get(a);n&&n.forEach(o=>{(_nullishCoalesce(this.subscriptionSeenVersion.get(o), () => (0)))>=i||(this.subscriptionSeenVersion.set(o,i),e.push(o))})};return this.forEachLookupPath(t,s),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("."),s="";for(let a=0;a<i.length;a+=1)s=s?`${s}.${i[a]}`:i[a],e(s)}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 e;let i=t.split("."),s=[];for(let a=1;a<=i.length;a++)s.push(i.slice(0,a).join("."));return this.setBoundedCacheEntry(this.pathExpansionCache,t,s,this.MAX_PATH_EXPANSION_CACHE_SIZE),s}setBoundedCacheEntry(t,e,i,s){if(t.size>=s){let a=t.keys().next().value;a!==void 0&&t.delete(a)}t.set(e,i)}}, _class8);var w=class{constructor(t){this.steps=t}async run(t){for(let e of this.steps){if(t.halted)break;await e.run(t)}}},Z=class{constructor(t){this.steps=t}run(t){for(let e of this.steps){if(t.halted)break;let i=e.run(t);i!=null&&typeof i.then=="function"&&typeof process<"u"&&_optionalChain([process, 'access', _76 => _76.env, 'optionalAccess', _77 => _77.NODE_ENV])!=="production"&&console.warn(`BitSyncPipelineRunner: step "${e.name}" returned a Promise and will not be awaited.`)}}};function x(r){for(let t in r)return!0;return!1}function $t(r){let{targetFields:t,currentErrors:e,allErrors:i,asyncErrors:s}=r;if(t&&t.length>0){let n=e,o=!1,d=()=>(o||(n={...e},o=!0),n);t.forEach(l=>{let c=l,u=e[c];if(i[l])u!==i[l]&&(d()[c]=i[l]);else if(s.has(l)){let h=s.get(l);u!==h&&(d()[c]=h)}else u!==void 0&&delete d()[c]});let p=t.every(l=>!i[l]&&!s.has(l));return{committedErrors:o?n:e,result:p,mode:"scoped"}}let a={};return s.forEach((n,o)=>{a[o]=n}),Object.entries(i).forEach(([n,o])=>{a[n]=o}),{committedErrors:a,result:void 0,mode:"global"}}function Jt(r){let{targetFields:t,hiddenFields:e,getFieldConfig:i,forEachFieldConfig:s}=r,a=[];if(t&&t.length>0){for(let n of t){if(e.has(n))continue;_optionalChain([i, 'call', _78 => _78(n), 'optionalAccess', _79 => _79.validation, 'optionalAccess', _80 => _80.asyncValidate])&&a.push(n)}return a}return s&&s((n,o)=>{!_optionalChain([n, 'access', _81 => _81.validation, 'optionalAccess', _82 => _82.asyncValidate])||e.has(o)||a.push(o)}),a}async function Gt(r){let{path:t,values:e,validationId:i,currentValidationId:s,getFieldConfig:a,cancelFieldAsync:n,createAbortController:o,setAbortController:d,clearAbortController:p,setFieldValidating:l,setAsyncError:c,clearAsyncError:u}=r,h=_optionalChain([a, 'call', _83 => _83(t), 'optionalAccess', _84 => _84.validation, 'optionalAccess', _85 => _85.asyncValidate]);if(!h){u(t);return}n(t);let S=o();d(t,S),l(t,!0);try{let B=await h(_chunk6LNXTSZ6cjs.f.call(void 0, e,t),e);if(S.signal.aborted||i!==s)return;B?c(t,B):u(t)}finally{!S.signal.aborted&&i===s&&l(t,!1),p(t)}}var Q= (_class9 =class{constructor(t){;_class9.prototype.__init36.call(this);_class9.prototype.__init37.call(this);this.port=t}__init36() {this.abortControllers=new Map}__init37() {this.pendingJobs=new Map}handle(t,e,i,s){if(!i){this.cancel(t),this.port.setFieldValidating(t,!1);return}this.cancel(t),this.port.setFieldValidating(t,!0);let a=new AbortController;this.abortControllers.set(t,a),this.pendingJobs.set(t,{value:e,dueAt:Date.now()+s,validate:i,controller:a}),this.schedulePendingJobs()}cancel(t){this.pendingJobs.has(t)&&(this.pendingJobs.delete(t),this.schedulePendingJobs());let e=this.abortControllers.get(t);e&&(e.abort(),this.abortControllers.delete(t))}cleanupPrefix(t){for(let e of this.pendingJobs.keys())v(e,t)&&(this.cancel(e),this.port.clearAsyncError(e),this.port.setFieldValidating(e,!1))}cancelAll(){this.cancelSchedulerTimeout&&(this.cancelSchedulerTimeout(),this.cancelSchedulerTimeout=void 0),this.pendingJobs.clear(),this.abortControllers.forEach(t=>t.abort()),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()},Math.max(0,t-Date.now())))}async flushPendingJobs(){this.cancelSchedulerTimeout=void 0;let t=Date.now(),e=[];for(let[i,s]of this.pendingJobs.entries())s.dueAt<=t&&e.push([i,s]);if(e.length===0){this.schedulePendingJobs();return}e.forEach(([i])=>{this.pendingJobs.delete(i)}),await Promise.all(e.map(([i,s])=>this.runJob(i,s))),this.schedulePendingJobs()}async runJob(t,e){if(!e.controller.signal.aborted)try{let i=await e.validate(e.value,this.port.getValues());if(e.controller.signal.aborted)return;i?this.port.setAsyncError(t,i):(this.port.clearAsyncError(t),await this.port.onValidationPassed(t))}finally{e.controller.signal.aborted||this.port.setFieldValidating(t,!1),this.abortControllers.delete(t)}}}, _class9);var tt= (_class10 =class{constructor(t){;_class10.prototype.__init38.call(this);this.port=t}__init38() {this.pendingScopeFields=null}trigger(t,e){this.cancelTimeout&&(this.cancelTimeout(),this.cancelTimeout=void 0);let i=_nullishCoalesce(this.port.validationDelay, () => (300)),s=_optionalChain([e, 'optionalAccess', _86 => _86.forceDebounce])?Math.max(1,i):i;if(s>0){if(t&&t.length>0)if(!this.pendingScopeFields)this.pendingScopeFields=new Set(t);else for(let n of t)this.pendingScopeFields.add(n);else this.pendingScopeFields=null;let a=this.pendingScopeFields?Array.from(this.pendingScopeFields):void 0;this.cancelTimeout=this.port.schedule(()=>{this.pendingScopeFields=null,this.cancelTimeout=void 0,this.port.validate({scopeFields:a})},s)}else this.pendingScopeFields=null,this.port.validate({scopeFields:t})}cancelPending(){this.cancelTimeout&&(this.cancelTimeout(),this.cancelTimeout=void 0),this.pendingScopeFields=null}}, _class10);function Yt(r){let{ctx:t,deps:e}=r;if(_optionalChain([t, 'access', _87 => _87.options, 'optionalAccess', _88 => _88.scope])){let i=e.store.getScopeFields(t.options.scope);i.length>0&&(t.targetFields=i)}}async function Xt(r){let{ctx:t,deps:e}=r;await e.store.emitBeforeValidate({values:t.currentState.values,state:t.currentState,scope:_optionalChain([t, 'access', _89 => _89.options, 'optionalAccess', _90 => _90.scope]),scopeFields:t.targetFields})}async function Zt(r){let{ctx:t,deps:e}=r,i=e.store.config.resolver?await e.store.config.resolver(t.currentState.values,{scopeFields:t.targetFields}):{},s=e.store.getRequiredErrors(t.currentState.values);t.allErrors={...i,...s},e.store.getHiddenFields().forEach(a=>{delete t.allErrors[a],e.asyncErrors.delete(a)})}async function Qt(r){let{ctx:t,deps:e}=r,i=Jt({targetFields:t.targetFields,hiddenFields:e.store.getHiddenFields(),getFieldConfig:s=>e.store.getFieldConfig(s),forEachFieldConfig:e.store.forEachFieldConfig});i.length!==0&&await Promise.all(i.map(s=>e.runImmediateAsyncValidation(s,t.currentState.values,t.validationId)))}function te(r){let{ctx:t,deps:e}=r,i=$t({targetFields:t.targetFields,currentErrors:t.currentState.errors,allErrors:t.allErrors,asyncErrors:e.asyncErrors});t.committedErrors=i.committedErrors,t.isValid=!x(i.committedErrors),t.result=i.mode==="scoped"?i.result:t.isValid}async function xt(r){let{ctx:t,deps:e}=r;t.validationId!==e.getCurrentValidationId()&&(t.aborted=!0,t.result=t.currentState.isValid,t.halted=!0)}async function ee(r){let{ctx:t,deps:e}=r;e.store.dispatch(V(t.committedErrors,t.isValid)),await e.store.emitAfterValidate({values:e.store.getState().values,state:e.store.getState(),scope:_optionalChain([t, 'access', _91 => _91.options, 'optionalAccess', _92 => _92.scope]),scopeFields:t.targetFields,errors:t.committedErrors,result:t.result}),t.halted=!0}async function ie(r){let{scopeFields:t,store:e,asyncErrors:i}=r,s=e.getState(),a=e.config.resolver?await e.config.resolver(s.values,{scopeFields:t}):{},n=e.getRequiredErrors(s.values),o={...a,...n};e.getHiddenFields().forEach(p=>{delete o[p],i.delete(p)});let d={...s.errors};t.forEach(p=>{o[p]?d[p]=o[p]:i.has(p)?d[p]=i.get(p):delete d[p]}),e.dispatch(V(d,!x(d)))}var et= (_class11 =class{constructor() { _class11.prototype.__init39.call(this);_class11.prototype.__init40.call(this); }__init39() {this.currentValidationId=0}__init40() {this.immediateAbortControllers=new Map}beginValidation(){return this.currentValidationId+=1,this.currentValidationId}getCurrentValidationId(){return this.currentValidationId}isValidationCurrent(t){return t===this.currentValidationId}setImmediateController(t,e){this.immediateAbortControllers.set(t,e)}clearImmediateController(t){this.immediateAbortControllers.delete(t)}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())v(i,t)&&(this.cancelImmediate(i),e(i))}cancelAllImmediate(){this.immediateAbortControllers.forEach(t=>{t.abort()}),this.immediateAbortControllers.clear()}}, _class11);var it= (_class12 =class{constructor(t){;_class12.prototype.__init41.call(this);_class12.prototype.__init42.call(this);_class12.prototype.__init43.call(this);this.store=t;this.schedule=_nullishCoalesce(_optionalChain([t, 'access', _93 => _93.config, 'access', _94 => _94.scheduler, 'optionalAccess', _95 => _95.schedule]), () => (((i,s)=>{let a=setTimeout(i,s);return()=>clearTimeout(a)}))),this.debouncer=new tt({schedule:(i,s)=>this.schedule(i,s),validate:i=>this.validate(i),validationDelay:_nullishCoalesce(t.config.validationDelay, () => (300))}),this.asyncScheduler=new Q({schedule:(i,s)=>this.schedule(i,s),getValues:()=>this.store.getState().values,setFieldValidating:(i,s)=>this.updateFieldValidating(i,s),setAsyncError:(i,s)=>{this.asyncErrors.set(i,s),this.store.setError(i,s)},clearAsyncError:i=>{this.asyncErrors.delete(i)},onValidationPassed:async i=>{await ie({scopeFields:[i],store:this.store,asyncErrors:this.asyncErrors})}});let e={store:this.store,asyncErrors:this.asyncErrors,getCurrentValidationId:()=>this.coordinator.getCurrentValidationId(),runImmediateAsyncValidation:(i,s,a)=>this.runImmediateAsyncValidation(i,s,a)};this.validationPipeline=new w([{name:"validate:resolve-target-fields",run:i=>Yt({ctx:i,deps:e})},{name:"validate:before-hooks",run:async i=>Xt({ctx:i,deps:e})},{name:"validate:sync-track",run:async i=>Zt({ctx:i,deps:e})},{name:"validate:abort-check-pre-async",run:async i=>xt({ctx:i,deps:e})},{name:"validate:async-track",run:async i=>Qt({ctx:i,deps:e})},{name:"validate:abort-check",run:async i=>xt({ctx:i,deps:e})},{name:"validate:async-track-merge",run:i=>te({ctx:i,deps:e})},{name:"validate:commit",run:async i=>ee({ctx:i,deps:e})}])}__init41() {this.validatingCount=0}__init42() {this.asyncErrors=new Map}__init43() {this.coordinator=new et}updateFieldValidating(t,e){let i=this.store.getState();if(!!i.isValidating[t]===e)return;let a={...i.isValidating};e?(a[t]=!0,this.validatingCount+=1):(delete a[t],this.validatingCount=Math.max(0,this.validatingCount-1)),this.store.dispatch(g({isValidating:a}))}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)})}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}if(this.asyncErrors.delete(t),this.store.validate){await this.store.validate({scopeFields:[t]});return}let i={...this.store.getState().errors};delete i[t],this.store.dispatch(V(i,!x(i)))}handleAsync(t,e){let i=this.store.getFieldConfig(t),s=_optionalChain([i, 'optionalAccess', _96 => _96.validation, 'optionalAccess', _97 => _97.asyncValidate]),a=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _98 => _98.validation, 'optionalAccess', _99 => _99.asyncValidateOn]), () => ("blur"));if(!s||a!=="change"){this.cancelFieldAsync(t),this.updateFieldValidating(t,!1);return}let n=_nullishCoalesce(_optionalChain([i, 'access', _100 => _100.validation, 'optionalAccess', _101 => _101.asyncValidateDelay]), () => (500));this.asyncScheduler.handle(t,e,s,n)}hasValidationsInProgress(t){let e=this.store.getState();return t&&t.length>0?t.some(i=>!!e.isValidating[i]):this.validatingCount>0}trigger(t,e){this.debouncer.trigger(t,e)}async validate(t){try{_optionalChain([t, 'optionalAccess', _102 => _102.scopeFields, 'optionalAccess', _103 => _103.length])&&t.scopeFields.forEach(i=>this.cancelFieldAsync(i));let e={options:t,validationId:this.coordinator.beginValidation(),currentState:this.store.getState(),targetFields:_optionalChain([t, 'optionalAccess', _104 => _104.scopeFields]),allErrors:{},committedErrors:{},isValid:!0,result:!0,aborted:!1};return await this.validationPipeline.run(e),e.aborted&&await this.store.emitAfterValidate({values:this.store.getState().values,state:this.store.getState(),scope:_optionalChain([e, 'access', _105 => _105.options, 'optionalAccess', _106 => _106.scope]),scopeFields:e.targetFields,errors:this.store.getState().errors,result:e.currentState.isValid,aborted:!0}),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(g({isValidating:{}}))}async runImmediateAsyncValidation(t,e,i){await Gt({path:t,values:e,validationId:i,currentValidationId:this.coordinator.getCurrentValidationId(),getFieldConfig:s=>this.store.getFieldConfig(s),cancelFieldAsync:s=>this.cancelFieldAsync(s),createAbortController:()=>new AbortController,setAbortController:(s,a)=>{this.coordinator.setImmediateController(s,a)},clearAbortController:s=>{this.coordinator.clearImmediateController(s)},setFieldValidating:(s,a)=>this.updateFieldValidating(s,a),setAsyncError:(s,a)=>{this.asyncErrors.set(s,a)},clearAsyncError:s=>{this.asyncErrors.delete(s)}})}}, _class12);function Et(r,t,e){if(!Object.prototype.hasOwnProperty.call(r,t))return[r,e];let s=r,a=e;return a||(s={...r},a=!0),delete s[t],[s,a]}var rt=class{constructor(t){this.store=t;this.fieldUpdatePipeline=new Z([{name:"field:clear-current-error",run:e=>this.clearCurrentError(e)},{name:"field:update-dependencies",run:e=>this.updateDependencies(e)},{name:"field:update-dirty",run:e=>this.updateDirtyState(e)},{name:"field:commit-state",run:e=>this.commitFieldState(e)},{name:"field:emit-change",run:e=>this.emitFieldChange(e)},{name:"field:trigger-validate",run:e=>this.triggerResolverValidation(e)},{name:"field:trigger-async-validate",run:e=>this.triggerAsyncValidation(e)}])}updateField(t,e,i={origin:"setField"}){let s=this.store.getState(),a=_chunk6LNXTSZ6cjs.f.call(void 0, s.values,t),n={path:t,value:e,meta:i,previousValue:a,nextValues:_chunk6LNXTSZ6cjs.g.call(void 0, s.values,t,e),nextErrors:s.errors,hasMutatedErrors:!1,dependencyDiff:{affectedFields:[],visibilityChanged:[],requiredChanged:[]},isDirty:!1};this.fieldUpdatePipeline.run(n)}clearCurrentError(t){[t.nextErrors,t.hasMutatedErrors]=Et(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]=Et(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(g({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){(typeof this.store.getFieldConfig=="function"?_optionalChain([this, 'access', _107 => _107.store, 'access', _108 => _108.getFieldConfig, 'call', _109 => _109(t.path), 'optionalAccess', _110 => _110.validation, 'optionalAccess', _111 => _111.asyncValidateOn]):void 0)==="change"&&this.store.handleFieldAsyncValidation(t.path,t.value)}};var st=class{constructor(t){this.store=t}collectChangedUpdates(t,e="",i=[]){return Object.entries(t).forEach(([s,a])=>{let n=e?`${e}.${s}`:s;if(a&&typeof a=="object"&&!Array.isArray(a)&&Object.keys(a).length>0){this.collectChangedUpdates(a,n,i);return}i.push([n,a])}),i}setValues(t,e){if(_optionalChain([e, 'optionalAccess', _112 => _112.rebase])){this.rebaseValues(t);return}if(_optionalChain([e, 'optionalAccess', _113 => _113.partial])){this.hydrateValues(t);return}this.replaceValuesInternal(t,"replaceValues")}hydrateValues(t){let e=this.collectChangedUpdates(t),i=e.map(([a])=>a),s=e.length>0?_chunk6LNXTSZ6cjs.h.call(void 0, this.store.getState().values,e):this.store.getState().values;this.replaceValuesInternal(s,"hydrate",i.length>0?i:["*"])}rebaseValues(t){let e=this.store.getState().values,i=_chunk6LNXTSZ6cjs.a.call(void 0, t);this.store.setBaselineValues(t),this.store.cancelAllValidations(),this.store.evaluateAllDependencies(i),this.store.clearDirtyState(),this.store.dispatch(g({values:i,errors:{},touched:{},isValidating:{},isValid:!0,isDirty:!1,isSubmitting:!1},["*"])),this.store.resetHistory(i),this.store.validateNow(),this.store.emitFieldChange({path:"*",previousValue:e,nextValue:i,values:this.store.getState().values,state:this.store.getState(),meta:{origin:"rebase"}})}applyHistoryState(t){let e=this.store.rebuildDirtyState(t,this.store.getBaselineValues());this.store.dispatch(g({values:t,isDirty:e},["*"])),this.store.triggerValidation(void 0,{forceDebounce:!0})}reset(){this.store.cancelAllValidations();let t=_chunk6LNXTSZ6cjs.a.call(void 0, this.store.getBaselineValues());this.store.evaluateAllDependencies(t),this.store.clearDirtyState(),this.store.dispatch(g({values:t,errors:{},touched:{},isValidating:{},isValid:!0,isDirty:!1,isSubmitting:!1},["*"])),this.store.resetHistory(t)}replaceValuesInternal(t,e="replaceValues",i=["*"]){let s=this.store.getState().values,a=_chunk6LNXTSZ6cjs.a.call(void 0, t);this.store.cancelAllValidations(),this.store.evaluateAllDependencies(a);let n=this.store.rebuildDirtyState(a,this.store.getBaselineValues());this.store.dispatch(g({values:a,errors:{},isValidating:{},isValid:!0,isDirty:n,isSubmitting:!1},i)),this.store.internalSaveSnapshot(),this.store.validateNow(),this.store.emitFieldChange({path:"*",previousValue:s,nextValue:a,values:this.store.getState().values,state:this.store.getState(),meta:{origin:e}})}};var at=class{constructor(t){this.store=t;this.submitPipeline=new w([{name:"submit:start",run:async e=>this.startSubmit(e)},{name:"submit:invalid",run:async e=>this.handleInvalidSubmit(e)},{name:"submit:prepare",run:e=>this.prepareSubmitValues(e)},{name:"submit:before-hooks",run:async e=>this.runBeforeSubmitHooks(e)},{name:"submit:user-handler",run:async e=>this.runSubmitHandler(e)},{name:"submit:after-hooks",run:async e=>this.runAfterSubmitHooks(e)}])}async submit(t){if(this.store.getState().isSubmitting)return{status:"blocked",reason:"isSubmitting"};if(this.store.hasValidationsInProgress())return{status:"blocked",reason:"validating"};this.store.cancelAllValidations();let i={onSuccess:t,isValid:!1,valuesToSubmit:_chunk6LNXTSZ6cjs.a.call(void 0, this.store.getState().values),dirtyValues:{}};try{return await this.submitPipeline.run(i),i.invalid?{status:"invalid"}:{status:"submitted"}}catch(s){return i.error=s,await this.store.emitOperationalError({source:"submit",error:s}),await this.store.emitAfterSubmit({values:this.store.getState().values,dirtyValues:this.store.buildDirtyValues(this.store.getState().values),state:this.store.getState(),success:!1,error:s}),this.store.config.onUnhandledError(s,"submit"),{status:"failed",error:s}}finally{this.store.dispatch(g({isSubmitting:!1}))}}async startSubmit(t){this.store.dispatch(g({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(s=>{i[s]=!0}),this.store.batchStateUpdates(()=>{this.store.dispatch(g({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=[];this.store.getHiddenFields().forEach(i=>{e.push([i,void 0])}),t.valuesToSubmit=Ht({values:t.valuesToSubmit,sourceValues:this.store.getState().values,transformEntries:this.store.getTransformEntries()}),e.length>0&&(t.valuesToSubmit=_chunk6LNXTSZ6cjs.h.call(void 0, t.valuesToSubmit,e)),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){await t.onSuccess(t.valuesToSubmit,t.dirtyValues)}async runAfterSubmitHooks(t){await this.store.emitAfterSubmit({values:t.valuesToSubmit,dirtyValues:t.dirtyValues,state:this.store.getState(),success:!0})}};var nt=class{constructor(t){this.ports=t;this.fieldUpdate=new rt(t.fieldUpdate),this.values=new st(t.values),this.submitFlow=new at(t.submit)}updateField(t,e,i={origin:"setField"}){this.fieldUpdate.updateField(t,e,i)}setValues(t,e){this.values.setValues(t,e)}hydrateValues(t){this.values.hydrateValues(t)}rebaseValues(t){this.values.rebaseValues(t)}applyHistoryState(t){this.values.applyHistoryState(t)}async submit(t){return this.submitFlow.submit(t)}reset(){this.values.reset()}};function re(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)}function se(r,t){let e=[],i=(s,a,n,o,d)=>{if(!(o&&d&&_chunk6LNXTSZ6cjs.d.call(void 0, s,a))){if(re(s)&&re(a)&&o&&d){let p=new Set([...Object.keys(s),...Object.keys(a)]);for(let l of p){let c=n?`${n}.${l}`:l,u=Object.prototype.hasOwnProperty.call(s,l),h=Object.prototype.hasOwnProperty.call(a,l);i(s[l],a[l],c,u,h)}return}e.push({path:n,previousValue:_chunk6LNXTSZ6cjs.a.call(void 0, s),nextValue:_chunk6LNXTSZ6cjs.a.call(void 0, a),hadPreviousValue:o,hasNextValue:d})}};return i(r,t,"",!0,!0),{operations:e}}function ot(r,t,e){let i=r,s=[],a=[];for(let n of t.operations){let o=e==="undo"?n.hadPreviousValue:n.hasNextValue,d=e==="undo"?n.previousValue:n.nextValue;if(!n.path){i=o?d:{},s.length=0,a.length=0;continue}if(o){s.push([n.path,d]);continue}a.push(n.path)}return s.length>0&&(i=_chunk6LNXTSZ6cjs.h.call(void 0, i,s)),a.length>0&&(i=_chunk6LNXTSZ6cjs.i.call(void 0, i,a)),i}var lt= (_class13 =class{constructor(t,e){;_class13.prototype.__init44.call(this);_class13.prototype.__init45.call(this);_class13.prototype.__init46.call(this);_class13.prototype.__init47.call(this);_class13.prototype.__init48.call(this);this.enableHistory=t;this.maxHistory=e}__init44() {this.baseSnapshot=null}__init45() {this.currentSnapshot=null}__init46() {this.patches=[]}__init47() {this.historyIndex=-1}__init48() {this.historySize=0}saveSnapshot(t){if(!this.enableHistory)return;if(!this.currentSnapshot||this.baseSnapshot===null){this.reset(t);return}this.historyIndex<this.historySize-1&&(this.patches.splice(this.historyIndex),this.historySize=this.historyIndex+1);let e=se(this.currentSnapshot,t);if(e.operations.length!==0)for(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=ot(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=ot(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=_chunk6LNXTSZ6cjs.a.call(void 0, t),this.currentSnapshot=this.baseSnapshot,this.patches=[],this.historyIndex=0,this.historySize=1}getMetadata(){return{enabled:this.enableHistory,canUndo:this.canUndo,canRedo:this.canRedo,historyIndex:this.historyIndex,historySize:this.historySize}}compactOldestSnapshot(){let t=this.patches.shift();!t||this.baseSnapshot===null||(this.baseSnapshot=ot(this.baseSnapshot,t,"redo"),this.historySize=Math.max(1,this.historySize-1),this.historyIndex=Math.max(0,this.historyIndex-1))}getCapacity(){return Math.max(1,this.maxHistory)}}, _class13);var dt=class{constructor(t){this.store=t}pushItem(t,e){this.mutateArrayWithSetField(t,i=>[...i,e],{origin:"array",operation:"push"})}prependItem(t,e){this.mutateArrayWithSetField(t,i=>[e,...i],{origin:"array",operation:"prepend"})}insertItem(t,e,i){this.mutateArrayWithSetField(t,s=>{let a=[...s];return a.splice(e,0,i),a},{origin:"array",operation:"insert",index:e})}removeItem(t,e){let i=this.store.getState(),s=_chunk6LNXTSZ6cjs.f.call(void 0, i.values,t);if(!Array.isArray(s))return;let a=[...s];this.store.unregisterPrefix&&this.store.unregisterPrefix(bt(t,e));let n=s.filter((o,d)=>d!==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 s=this.store.getState(),a=[..._chunk6LNXTSZ6cjs.f.call(void 0, s.values,t)||[]];[a[e],a[i]]=[a[i],a[e]],this.commitArrayMutationWithFieldPipeline({path:t,nextArray:a,meta:{origin:"array",operation:"swap",from:e,to:i},reindex:n=>n===e?i:n===i?e:n})}moveItem(t,e,i){let s=this.store.getState(),a=[..._chunk6LNXTSZ6cjs.f.call(void 0, s.values,t)||[]],[n]=a.splice(e,1);a.splice(i,0,n),this.commitArrayMutationWithFieldPipeline({path:t,nextArray:a,meta:{origin:"array",operation:"move",from:e,to:i},reindex:o=>o===e?i:e<i&&o>e&&o<=i?o-1:e>i&&o>=i&&o<e?o+1:o})}replaceItems(t,e){this.commitArrayMutationWithFieldPipeline({path:t,nextArray:e,meta:{origin:"array",operation:"replace"},reindex:i=>i<e.length?i:null})}clearItems(t){this.store.unregisterPrefix&&this.store.unregisterPrefix(bt(t)),this.commitArrayMutationWithFieldPipeline({path:t,nextArray:[],meta:{origin:"array",operation:"clear"},reindex:()=>null})}mutateArrayWithSetField(t,e,i){let s=_chunk6LNXTSZ6cjs.f.call(void 0, this.store.getState().values,t)||[];this.store.setFieldWithMeta(t,e(s),i),this.store.internalSaveSnapshot()}commitArrayMutationWithFieldPipeline(t){let{path:e,nextArray:i,meta:s,reindex:a}=t,n=this.store.getState();this.store.setFieldWithMeta(e,i,s);let o=_chunk6LNXTSZ6cjs.k.call(void 0, n,e,a);this.store.dispatch(g({errors:o.errors,touched:o.touched,isValidating:o.isValidating},[e])),this.store.internalSaveSnapshot()}};var ct=class{constructor(t,e,i,s){this.getState=t;this.getInitialValues=e;this.getScopeFields=i;this.isPathDirty=s}getScopeStatus(t){let e=this.getScopeFields(t),i=this.getState(),s=e.some(o=>!!i.errors[o]),a=e.some(o=>this.isPathDirty(o)),n=this.getScopeErrors(t);return{hasErrors:s,isDirty:a,errors:n}}getScopeErrors(t){let e=this.getScopeFields(t),i=this.getState(),s={};for(let a of e){let n=i.errors[a];n&&(s[a]=n)}return s}};var pt= (_class14 =class{constructor(t,e,i){;_class14.prototype.__init49.call(this);this.fieldMetadataProvider=t;this.getState=e;this.isPathDirty=i}__init49() {this.requiredValuesRef=null}isHidden(t){return this.fieldMetadataProvider.isHidden(t)}isRequired(t){let e=this.getState().values;return this.requiredValuesRef!==e&&(this.requiredValuesRef=e),this.fieldMetadataProvider.isRequired(t,e)}isFieldDirty(t){return this.isPathDirty(t)}isFieldValidating(t){return!!this.getState().isValidating[t]}isTouched(t){return!!this.getState().touched[t]}}, _class14);var ut=class{constructor(t,e){this.getState=t;this.dispatch=e}setError(t,e){let i={...this.getState().errors,[t]:e};e||delete i[t],this.dispatch(g({errors:i}))}setErrors(t){this.dispatch(g({errors:{...this.getState().errors,...t}}))}setServerErrors(t){let e={};for(let[i,s]of Object.entries(t))e[i]=Array.isArray(s)?s[0]:s;this.setErrors(e)}};function ae(r){let t=[],e=new Map;for(let n of r)if(e.has(n.path)||e.set(n.path,new Set),n.dependsOn)for(let o of n.dependsOn)r.find(p=>p.path===o)&&e.get(n.path).add(o);let i=new Set,s=new Set,a=(n,o)=>{i.add(n),s.add(n),o.push(n);let d=e.get(n)||new Set;for(let p of d)if(i.has(p)){if(s.has(p)){let l=o.indexOf(p),c=[...o.slice(l),p];return{cycle:c,paths:Array.from(e.keys()).filter(u=>c.includes(u)),message:`Circular dependency detected: ${c.join(" \u2192 ")}. Check your computed field definitions.`}}}else{let l=a(p,[...o]);if(l)return l}return s.delete(n),null};for(let n of e.keys())if(!i.has(n)){let o=a(n,[]);o&&!t.some(d=>d.message===o.message)&&t.push(o)}return t}var Ft= (_class15 =class{constructor() { _class15.prototype.__init50.call(this); }__init50() {this.entries=new Map}register(t,e){this.entries.set(t,e)}resolve(t){let e=this.entries.get(t);if(!e)throw new Error(`BitStore capability "${String(t)}" n\xE3o foi registrada.`);return e}toCapabilities(){return{validation:this.resolve("validation"),lifecycle:this.resolve("lifecycle"),history:this.resolve("history"),arrays:this.resolve("arrays"),scope:this.resolve("scope"),query:this.resolve("query"),error:this.resolve("error")}}}, _class15);function ne(){return new Ft}function si(r){let{registry:t,ports:e,fieldRegistry:i}=r;t.register("validation",new it(e.validationPort)),t.register("lifecycle",new nt(e.lifecyclePorts)),t.register("history",new lt(!!e.config.history.enabled,_nullishCoalesce(e.config.history.limit, () => (50)))),t.register("arrays",new dt(e.arrayPort)),t.register("scope",new ct(()=>e.getState(),()=>e.getBaselineValues(),s=>e.getScopeFields(s),s=>e.isPathDirty(s))),t.register("query",new pt(i,()=>e.getState(),s=>e.isPathDirty(s))),t.register("error",new ut(()=>e.getState(),s=>e.dispatch(s)))}function oe(r){let{ports:t,fieldRegistry:e}=r,i=ne();return si({registry:i,ports:t,fieldRegistry:e}),{registry:i,capabilities:i.toCapabilities()}}function le(r){let{config:t,fieldRegistry:e,computedManager:i}=r,s=_chunk6LNXTSZ6cjs.a.call(void 0, t.initialValues);t.fields&&Object.entries(t.fields).forEach(([o,d])=>{e.register(o,d,s)});let a=ae(e.getComputedEntries());if(a.length>0)throw new Error(a[0].message);return{values:N({values:s,normalizerEntries:e.getNormalizerEntries(),applyComputed:(o,d)=>i.apply(o,d)}),errors:{},touched:{},isValidating:{},persist:{isSaving:!1,isRestoring:!1,error:null},isValid:!0,isSubmitting:!1,isDirty:!1}}function de(r){return{getState:r.getState,dispatch:r.dispatch,setError:r.setError,validate:r.validate,getFieldConfig:r.getFieldConfig,forEachFieldConfig:t=>r.fieldRegistry.forEachFieldConfig((e,i)=>t(e,i)),getScopeFields:r.getScopeFields,config:r.config,getRequiredErrors:t=>r.fieldRegistry.getRequiredErrors(t),getHiddenFields:()=>r.fieldRegistry.getHiddenFields(),emitBeforeValidate:t=>r.getEffects().beforeValidate(t),emitAfterValidate:t=>r.getEffects().afterValidate(t)}}function ce(r){let t={getState:r.getState,dispatch:r.dispatch,config:r.config,getFieldConfig:s=>r.fieldRegistry.getFieldConfig(s),updateDependencies:(s,a,n)=>r.fieldRegistry.updateDependencies(s,a,n),hasDependentFields:s=>r.fieldRegistry.hasDependents(s),isFieldHidden:s=>r.fieldRegistry.isHidden(s),clearFieldValidation:s=>r.getValidation().clear(s),triggerValidation:(s,a)=>r.getValidation().trigger(s,a),handleFieldAsyncValidation:(s,a)=>r.getValidation().handleAsync(s,a),updateDirtyForPath:(s,a,n)=>r.dirtyManager.updateForPath(s,a,n),getBaselineValues:r.getBaselineValues,emitFieldChange:s=>r.getEffects().onFieldChange(s)},e={getState:r.getState,dispatch:r.dispatch,internalSaveSnapshot:r.saveHistorySnapshot,evaluateAllDependencies:s=>r.fieldRegistry.evaluateAll(s),cancelAllValidations:()=>r.getValidation().cancelAll(),validateNow:s=>r.getValidation().validate(s),rebuildDirtyState:(s,a)=>r.dirtyManager.rebuild(s,a),clearDirtyState:r.dirtyManager.clear.bind(r.dirtyManager),getBaselineValues:r.getBaselineValues,setBaselineValues:r.setBaselineValues,resetHistory:s=>r.getHistory().reset(s),emitFieldChange:s=>r.getEffects().onFieldChange(s),triggerValidation:(s,a)=>r.getValidation().trigger(s,a)},i={getState:r.getState,dispatch:r.dispatch,batchStateUpdates:r.runStateBatch,config:r.config,getTransformEntries:r.getTransformEntries,getHiddenFields:()=>r.fieldRegistry.getHiddenFields(),cancelAllValidations:()=>r.getValidation().cancelAll(),validateNow:s=>r.getValidation().validate(s),hasValidationsInProgress:s=>r.getValidation().hasValidationsInProgress(s),buildDirtyValues:s=>r.dirtyManager.buildDirtyValues(s),emitBeforeSubmit:s=>r.getEffects().beforeSubmit(s),emitAfterSubmit:s=>r.getEffects().afterSubmit(s),emitOperationalError:s=>r.getEffects().reportOperationalError(s)};return{fieldUpdate:t,values:e,submit:i}}function pe(r){return{getState:r.getState,setFieldWithMeta:r.setFieldWithMeta,dispatch:r.dispatch,internalSaveSnapshot:r.saveHistorySnapshot,unregisterPrefix:r.unregisterPrefix}}function ue(r){let{config:t,fieldRegistry:e,dirtyManager:i,baselineManager:s,runtimeContext:a}=r,{stateAccess:n,fieldAccess:o,featureAccess:d,actions:p}=a,l=de({config:t,fieldRegistry:e,getState:n.getState,dispatch:n.dispatch,setError:p.setError,validate:p.validate,getFieldConfig:o.getFieldConfig,getScopeFields:o.getScopeFields,getEffects:d.getEffects}),c=ce({config:t,fieldRegistry:e,dirtyManager:i,getState:n.getState,dispatch:n.dispatch,saveHistorySnapshot:n.saveHistorySnapshot,runStateBatch:n.runStateBatch,getTransformEntries:o.getTransformEntries,getBaselineValues:()=>s.getValues(),setBaselineValues:h=>s.setValues(h),getValidation:d.getValidation,getHistory:d.getHistory,getEffects:d.getEffects}),u=pe({getState:n.getState,dispatch:n.dispatch,setFieldWithMeta:(h,S,B)=>p.setFieldWithMeta(h,S,B),unregisterPrefix:p.unregisterPrefix,saveHistorySnapshot:n.saveHistorySnapshot});return oe({ports:{validationPort:l,lifecyclePorts:c,arrayPort:u,config:t,getScopeFields:o.getScopeFields,getState:n.getState,dispatch:n.dispatch,getBaselineValues:()=>s.getValues(),isPathDirty:h=>i.isPathDirty(h)},fieldRegistry:e})}function he(r){let{config:t,fieldRegistry:e,dirtyManager:i,computedManager:s,rawConfig:a,baselineManager:n,runtimeContext:o}=r,{stateAccess:d,fieldAccess:p,featureAccess:l,actions:c}=o,u=ue({config:t,fieldRegistry:e,dirtyManager:i,baselineManager:n,runtimeContext:{stateAccess:d,fieldAccess:p,featureAccess:l,actions:c}}),h=le({config:t,fieldRegistry:e,computedManager:s}),S=new X(d.getState,t.subscriptionCacheSize),B=a.storeId||t.name||t.idFactory({scope:"store",storeName:t.name});return{state:h,subscriptions:S,capabilityRegistry:u.registry,storeId:B}}function ge(){return{depth:0,pendingState:null,changedPathSet:null,changedPathList:null,valuesChanged:!1,pendingHistorySnapshot:!1}}function fe(r){r.depth+=1}function me(r){return r.depth-=1,r.depth===0}function ht(r,t){return _nullishCoalesce(t.pendingState, () => (r))}function ye(r,t){if(r.pendingState=t.nextState,r.valuesChanged||=t.valuesChanged,t.valuesChanged&&(r.pendingHistorySnapshot=!0),t.changedPaths&&t.changedPaths.length>0){let e=_nullishCoalesce(r.changedPathSet, () => (new Set)),i=_nullishCoalesce(r.changedPathList, () => ([]));t.changedPaths.forEach(s=>{if(e.has("*")||e.has(s))return;if(s==="*"){e.clear(),i.length=0,e.add("*"),i.push("*");return}if(!i.some(n=>n!=="*"&&s.startsWith(`${n}.`))){for(let n=i.length-1;n>=0;n-=1){let o=i[n];o==="*"||!o.startsWith(`${s}.`)||(e.delete(o),i.splice(n,1))}e.add(s),i.push(s)}}),r.changedPathSet=e,r.changedPathList=i}}function Se(r){let{currentState:t,batchState:e,applyValueDerivations:i}=r;if(!e.pendingState)return e.pendingHistorySnapshot=!1,null;let s=e.pendingState,a=_nullishCoalesce(e.changedPathList, () => (void 0)),n=e.valuesChanged;return n&&(s={...s,values:i(s.values,a)}),e.pendingState=null,e.changedPathSet=null,e.changedPathList=null,e.valuesChanged=!1,{nextState:_nullishCoalesce(s, () => (t)),changedPaths:a,valuesChanged:n}}function ai(r){let t=!1;for(let i of Object.values(r))if(i===void 0){t=!0;break}if(!t)return r;let e={};return Object.entries(r).forEach(([i,s])=>{let a=s;a!==void 0&&(e[i]=a)}),e}function be(r){let{currentState:t,partialState:e,changedPaths:i,applyValueDerivations:s,applyComputedValues:a}=r,n=_nullishCoalesce(s, () => ((u=>a?a(u):u))),o={...t,...e},d=!!e.values;e.values&&(o.values=n(e.values,i)),e.errors&&(o.errors=ai(e.errors),o.isValid=!x(o.errors));let p=i&&i.length>0?i:void 0,l=ni(e),c=_(p,l);return{nextState:o,changedPaths:c,valuesChanged:d}}function ni(r){let t=new Set,e=[r.errors,r.touched,r.isValidating];for(let i of e)if(i)for(let s in i)t.add(s);return r.persist&&t.add("persist"),"isValid"in r&&t.add("isValid"),"isDirty"in r&&t.add("isDirty"),"isSubmitting"in r&&t.add("isSubmitting"),t.size>0?Array.from(t):void 0}function oi(r){throw new Error(`BitStore: unsupported operation kind: ${String(r.kind)}`)}function li(r,t){switch(t.kind){case"state.patch":return t;case"field.touchMany":{if(t.paths.length===0)return null;let e={...r.touched};for(let i of t.paths)e[i]=!0;return g({touched:e},t.paths)}case"form.persistMeta":return g({persist:{...r.persist,...t.patch}});case"history.apply":return g({values:t.values,isDirty:t.isDirty},["*"]);case"validation.commit":return g({errors:t.errors,isValid:t.isValid});default:return oi(t)}}function di(r){let{currentState:t,operation:e,applyValueDerivations:i}=r,s=Object.prototype.hasOwnProperty.call(e.partialState,"values"),a=_nullishCoalesce(e.changedPaths, () => ((s?["*"]:void 0)));return be({currentState:t,partialState:e.partialState,changedPaths:a,applyValueDerivations:i})}function Be(r){let{currentState:t,operation:e,applyValueDerivations:i}=r,s=li(t,e);return s?di({currentState:t,operation:s,applyValueDerivations:(a,n)=>s.skipComputed?a:i(a,n)}):null}function Te(r){let{state:t,batchState:e,operation:i,applyValueDerivations:s,onStateCommitted:a}=r,n=ht(t,e);if(e.depth>0){let d=Be({currentState:n,operation:i,applyValueDerivations:p=>p});return d&&ye(e,d),t}let o=Be({currentState:t,operation:i,applyValueDerivations:s});return o?(a({nextState:o.nextState,changedPaths:o.changedPaths,valuesChanged:o.valuesChanged}),o.nextState):t}function ve(r){let{state:t,batchState:e,applyValueDerivations:i,onStateCommitted:s}=r,a=Se({currentState:t,batchState:e,applyValueDerivations:i});return a?(s({nextState:a.nextState,changedPaths:a.changedPaths,valuesChanged:a.valuesChanged}),a.nextState):t}function Pe(r){let{batchState:t,callback:e,flushBatchedStateUpdates:i}=r;fe(t);try{return e()}finally{me(t)&&i()}}function xe(r){let{payload:t,setState:e,notifySubscriptions:i,notifyEffects:s}=r;e(t.nextState),i(t.nextState,t.changedPaths),s(t.nextState,t.valuesChanged)}function Ee(r){let{state:t,batchState:e,operation:i,applyValueDerivations:s,onStateCommitted:a}=r;return Te({state:t,batchState:e,operation:i,applyValueDerivations:s,onStateCommitted:a})}function Fe(r){let{batchState:t,values:e,saveHistory:i}=r;if(t.depth>0){t.pendingHistorySnapshot=!0;return}i(e)}function Ce(r){let{state:t,batchState:e,applyValueDerivations:i,onStateCommitted:s,saveHistory:a}=r,n=ve({state:t,batchState:e,applyValueDerivations:i,onStateCommitted:s});return e.pendingHistorySnapshot&&(e.pendingHistorySnapshot=!1,a(n.values)),n}var gt= (_class16 =class{constructor(t){;_class16.prototype.__init51.call(this);this.args=t;this.state=t.state,this.subscriptions=t.subscriptions,this.effects=t.effects,this.capabilityRegistry=t.capabilityRegistry,this.capabilities=t.capabilityRegistry.toCapabilities()}__init51() {this.batchState=ge()}getCapability(t){return this.capabilityRegistry.resolve(t)}getState(){return ht(this.state,this.batchState)}runBatch(t){return Pe({batchState:this.batchState,callback:t,flushBatchedStateUpdates:()=>this.flushBatchedStateUpdates()})}dispatch(t){this.state=Ee({state:this.state,batchState:this.batchState,operation:t,applyValueDerivations:(e,i)=>this.applyValueDerivations(e,i),onStateCommitted:e=>this.onStateCommitted(e)})}saveHistorySnapshot(){let t=this.capabilities.history.getMetadata();Fe({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){xe({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=Ce({state:this.state,batchState:this.batchState,applyValueDerivations:(i,s)=>this.applyValueDerivations(i,s),onStateCommitted:i=>this.onStateCommitted(i),saveHistory:i=>this.capabilities.history.saveSnapshot(i)});let e=this.capabilities.history.getMetadata();this.notifyIfHistoryChanged(t,e)}applyValueDerivations(t,e){return this.args.applyValueDerivations?this.args.applyValueDerivations(t,e):t}notifyIfHistoryChanged(t,e){t.canUndo===e.canUndo&&t.canRedo===e.canRedo&&t.historyIndex===e.historyIndex&&t.historySize===e.historySize||this.subscriptions.notify(this.getState(),[_chunkRHMJPKNVcjs.h.call(void 0, )])}}, _class16);function Ve(r){let{rawConfig:t,overrides:e}=r,i=Ot(t),s=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _114 => _114.baselineManager]), () => (new I(i.initialValues))),a=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _115 => _115.fieldRegistry]), () => (new U)),n=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _116 => _116.computedManager]), () => (new O(()=>a.getComputedEntries()))),o=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _117 => _117.dirtyManager]), () => (new j)),d=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _118 => _118.maskManager]), () => (new H));i.masks&&Object.entries(i.masks).forEach(([f,b])=>{d.registerMask(f,b)});let p=()=>{a.invalidateIndexes(),n.invalidateReverseDeps()},l,c=()=>{if(!l)throw new Error("BitStore runtime kernel is not initialized yet.");return l},u=he({rawConfig:t,config:i,fieldRegistry:a,computedManager:n,dirtyManager:o,baselineManager:s,runtimeContext:{stateAccess:{getState:()=>c().getState(),dispatch:f=>c().dispatch(f),saveHistorySnapshot:()=>c().saveHistorySnapshot(),runStateBatch:f=>c().runBatch(f)},fieldAccess:{getFieldConfig:f=>a.getFieldConfig(f),getScopeFields:f=>a.getScopeFields(f),getNormalizerEntries:()=>a.getNormalizerEntries(),getTransformEntries:()=>a.getTransformEntries()},featureAccess:{getEffects:()=>c().effects,getHistory:()=>c().getCapability("history"),getValidation:()=>c().getCapability("validation")},actions:{setError:(f,b)=>{c().getCapability("error").setError(f,b)},validate:f=>c().getCapability("validation").validate(f),setFieldWithMeta:(f,b,yt={origin:"setField"})=>{c().runBatch(()=>{c().getCapability("lifecycle").updateField(f,b,yt)})},unregisterPrefix:f=>{Y({prefix:f,state:c().getState(),fieldRegistry:a,subscriptions:c().subscriptions,validationCleanupPrefix:b=>c().getCapability("validation").cleanupPrefix(b),invalidateFieldIndexes:p})},triggerValidation:(f,b)=>{c().getCapability("validation").trigger(f,b)}}}}),h=()=>{let f=c().getState();return o.buildDirtyValues(f.values)},S=f=>{Nt({values:f,state:c().getState(),initialValues:s.getValues(),validation:c().getCapability("validation"),fieldRegistry:a,dirtyManager:o,dispatch:b=>c().dispatch(b),saveHistorySnapshot:()=>c().saveHistorySnapshot()})},B=zt({storeId:u.storeId,config:i,getState:()=>c().getState(),getConfig:()=>i,getValues:()=>c().getState().values,getDirtyValues:h,applyPersistedValues:S});return l=new gt({state:u.state,subscriptions:u.subscriptions,effects:B,capabilityRegistry:u.capabilityRegistry,applyValueDerivations:(f,b)=>N({values:f,changedPaths:b,normalizerEntries:a.getNormalizerEntries(),applyComputed:(yt,Je)=>n.apply(yt,Je)})}),l.saveHistorySnapshot(),{config:i,storeId:u.storeId,runtime:l,fieldRegistry:a,computedManager:n,dirtyManager:o,maskManager:d,baselineManager:s}}function we(r){let{dispatch:t,effects:e}=r;return qt({dispatch:t,effects:e})}function De(r){let{dispatch:t,effects:e}=r;return Ut({dispatch:t,effects:e})}function Ae(r){let{dispatch:t,effects:e}=r;return _t({dispatch:t,effects:e})}function Me(r){let{history:t,applyHistoryState:e}=r,i=t.undo();i&&e(i)}function Re(r){let{history:t,applyHistoryState:e}=r,i=t.redo();i&&e(i)}function ke(r){return r.history.getMetadata()}function Ie(r,t){let e=new Set,i=(n,o)=>n===null||typeof n!="object"?n:new Proxy(n,{get:(d,p,l)=>{if(typeof p=="symbol")return Reflect.get(d,p,l);let c=String(p),u=o?`${o}.${c}`:c;e.add(u);let h=Reflect.get(d,p,l);return i(h,u)}}),s=i(r,"");t(s);let a=new Set;return e.forEach(n=>{let o=ci(n);o&&a.add(o)}),Array.from(a)}function ci(r){if(r)return r==="values"?"*":r.startsWith("values.")?r.slice(7):r==="errors"||r==="touched"||r==="isValidating"?"*":r.startsWith("errors.")?r.slice(7):r.startsWith("touched.")?r.slice(8):r.startsWith("isValidating.")?r.slice(13):r==="persist"||r.startsWith("persist.")?"persist":r}function pi(r,t){if(r.length!==t.length)return!1;let e=new Set(t);for(let i of r)if(!e.has(i))return!1;return!0}function ui(r,t){return r.length===0?{emitImmediately:_optionalChain([t, 'optionalAccess', _119 => _119.emitImmediately]),equalityFn:_optionalChain([t, 'optionalAccess', _120 => _120.equalityFn]),mode:"scoped",paths:["*"]}:{emitImmediately:_optionalChain([t, 'optionalAccess', _121 => _121.emitImmediately]),equalityFn:_optionalChain([t, 'optionalAccess', _122 => _122.equalityFn]),mode:"scoped",paths:r}}function Oe(r){let{getState:t,subscribeSelector:e,selector:i,listener:s,options:a}=r,n=null,o=Ie(t(),i),d=!1,p=!1,l=c=>{n=e(i,u=>{s(u);let h=Ie(t(),i);pi(o,h)||(o=h,!(p||d)&&(p=!0,queueMicrotask(()=>{p=!1,!d&&(_optionalChain([n, 'optionalCall', _123 => _123()]),l(o))})))},ui(c,a))};return l(o),()=>{d=!0,_optionalChain([n, 'optionalCall', _124 => _124()]),n=null}}function je(r){let{getState:t,subscriptions:e,selector:i,listener:s,options:a,trackedSubscriptionsEnabled:n}=r,o=_nullishCoalesce(_optionalChain([a, 'optionalAccess', _125 => _125.equalityFn]), () => (_chunk6LNXTSZ6cjs.c));if(_optionalChain([a, 'optionalAccess', _126 => _126.mode])==="tracked"){if(!n)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 Oe({getState:t,subscribeSelector:(d,p,l)=>e.subscribeSelector(d,p,l,o),selector:i,listener:s,options:a})}return e.subscribeSelector(i,s,a,o)}function He(r){let{path:t,listener:e,options:i,subscribeSelector:s}=r,a=[..._nullishCoalesce(_optionalChain([i, 'optionalAccess', _127 => _127.paths]), () => ([])),t];return s(n=>_chunk6LNXTSZ6cjs.f.call(void 0, n.values,t),e,{...i,paths:a})}function ze(r){let{path:t,listener:e,getFieldState:i,subscribeSelector:s}=r;return s(()=>i(t),e,{paths:[t],equalityFn:_chunkOLQVH24Zcjs.c})}function qe(r){let{listener:t,subscribeSelector:e}=r;return e(i=>({isValid:i.isValid,isDirty:i.isDirty,isSubmitting:i.isSubmitting}),t,{paths:["isValid","isDirty","isSubmitting"],equalityFn:(i,s)=>i.isValid===s.isValid&&i.isDirty===s.isDirty&&i.isSubmitting===s.isSubmitting})}function Ue(r){let{listener:t,subscribeSelector:e}=r;return e(i=>i.persist,t,{paths:["persist"],equalityFn:(i,s)=>i.isSaving===s.isSaving&&i.isRestoring===s.isRestoring&&i.error===s.error})}function _e(r){let{readHistoryMeta:t,subscribeSelector:e,listener:i}=r;return e(()=>t(),i,{paths:[_chunkRHMJPKNVcjs.h.call(void 0, )],equalityFn:(s,a)=>_chunkRHMJPKNVcjs.e.call(void 0, s,a)})}function Ne(r){let{scopeName:t,getScopeFields:e,readScopeStatus:i,subscribeSelector:s,listener:a}=r,n=_chunkRHMJPKNVcjs.d.call(void 0, t),o=i(t),d=()=>{},p=()=>{d();let c=_chunkRHMJPKNVcjs.c.call(void 0, e(t));d=s(()=>i(t),u=>{_chunkRHMJPKNVcjs.b.call(void 0, o,u)||(o=u,a(u))},{paths:[...c,n]})};p();let l=s(()=>e(t).length,()=>{p();let c=i(t);_chunkRHMJPKNVcjs.b.call(void 0, o,c)||(o=c,a(c))},{paths:[n]});return()=>{d(),l()}}function Le(r){let{runtime:t,config:e,fieldRegistry:i,dirtyManager:s,stateReader:a}=r,n={getState:()=>a.getState(),getFieldState:l=>a.getFieldState(l),getIsValid:()=>a.getFlag("isValid"),getIsSubmitting:()=>a.getFlag("isSubmitting"),getIsDirty:()=>a.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:()=>s.buildDirtyValues(a.getState().values),getPersistMetadata:()=>a.getPersistMetadata(),getHistoryMetadata:()=>ke({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)},o={subscribe:l=>t.subscriptions.subscribe(l),subscribePersistMeta:l=>Ue({listener:l,subscribeSelector:(c,u,h)=>o.subscribeSelector(c,u,h)}),subscribeHistoryMeta:l=>_e({readHistoryMeta:()=>n.getHistoryMetadata(),subscribeSelector:(c,u,h)=>o.subscribeSelector(c,u,h),listener:l}),subscribeScopeStatus:(l,c)=>Ne({scopeName:l,getScopeFields:u=>n.getScopeFields(u),readScopeStatus:u=>n.getScopeStatus(u),subscribeSelector:(u,h,S)=>o.subscribeSelector(u,h,S),listener:c}),subscribeSelector:(l,c,u)=>je({getState:()=>n.getState(),subscriptions:t.subscriptions,selector:l,listener:c,options:u,trackedSubscriptionsEnabled:!!e.trackedSubscriptions}),subscribePath:(l,c,u)=>He({path:l,listener:c,options:u,subscribeSelector:(h,S,B)=>o.subscribeSelector(h,S,B)}),subscribeFieldState:(l,c)=>ze({path:l,listener:c,getFieldState:u=>n.getFieldState(u),subscribeSelector:(u,h,S)=>o.subscribeSelector(u,h,S)}),subscribeFormMeta:l=>qe({listener:l,subscribeSelector:(c,u,h)=>o.subscribeSelector(c,u,h)})};return{read:n,observe:o,write:{registerField:(l,c)=>{Wt({path:l,config:c,state:t.getState(),fieldRegistry:i,subscriptions:t.subscriptions,stateReader:a,invalidateFieldIndexes:()=>{i.invalidateIndexes()}})},unregisterField:l=>{Kt({path:l,state:t.getState(),hasStaticConfig:!!_optionalChain([e, 'access', _128 => _128.fields, 'optionalAccess', _129 => _129[l]]),fieldRegistry:i,subscriptions:t.subscriptions,validationCleanupField:c=>t.capabilities.validation.cleanupField(c),invalidateFieldIndexes:()=>{i.invalidateIndexes()},dispatch:c=>t.dispatch(c)})},unregisterPrefix:l=>{Y({prefix:l,state:t.getState(),fieldRegistry:i,subscriptions:t.subscriptions,validationCleanupPrefix:c=>t.capabilities.validation.cleanupPrefix(c),invalidateFieldIndexes:()=>{i.invalidateIndexes()}})},setField:(l,c)=>{t.runBatch(()=>{t.capabilities.lifecycle.updateField(l,c,{origin:"setField"})})},blurField:l=>{t.capabilities.query.isTouched(l)||t.runBatch(()=>{t.dispatch(Pt([l]))}),t.capabilities.validation.trigger([l])},markFieldsTouched:l=>{l.length!==0&&t.dispatch(Pt(l))},setValues:(l,c)=>{t.capabilities.lifecycle.setValues(l,c)},setError:(l,c)=>{t.capabilities.error.setError(l,c)},setErrors:l=>{t.capabilities.error.setErrors(l)},setServerErrors:l=>{t.capabilities.error.setServerErrors(l)},reset:()=>{t.runBatch(()=>{t.capabilities.lifecycle.reset()})},transaction:l=>t.runBatch(l),submit:l=>t.capabilities.lifecycle.submit(l),pushItem:(l,c)=>t.capabilities.arrays.pushItem(l,c),prependItem:(l,c)=>t.capabilities.arrays.prependItem(l,c),insertItem:(l,c,u)=>t.capabilities.arrays.insertItem(l,c,u),removeItem:(l,c)=>t.capabilities.arrays.removeItem(l,c),swapItems:(l,c,u)=>t.capabilities.arrays.swapItems(l,c,u),moveItem:(l,c,u)=>t.capabilities.arrays.moveItem(l,c,u),replaceItems:(l,c)=>t.capabilities.arrays.replaceItems(l,c),clearItems:l=>t.capabilities.arrays.clearItems(l)},feature:{undo:()=>{Me({history:t.capabilities.history,applyHistoryState:l=>t.capabilities.lifecycle.applyHistoryState(l)})},redo:()=>{Re({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,c)=>t.capabilities.validation.trigger(l,c),restorePersisted:()=>we({dispatch:l=>t.dispatch(l),effects:t.effects}),forceSave:()=>De({dispatch:l=>t.dispatch(l),effects:t.effects}),clearPersisted:()=>Ae({dispatch:l=>t.dispatch(l),effects:t.effects}),cleanup:()=>t.cleanup()}}}function We(r){let t=()=>r.read.getState();return{read:{get storeId(){return r.identity.storeId},get config(){return r.identity.config},get isValid(){return r.read.getIsValid()},get isSubmitting(){return r.read.getIsSubmitting()},get isDirty(){return r.read.getIsDirty()},getState:t,getFieldConfig:n=>r.getFieldConfig(n),getFieldState:n=>r.read.getFieldState(n),isHidden:n=>r.read.isHidden(n),isRequired:n=>r.read.isRequired(n),isFieldDirty:n=>r.read.isFieldDirty(n),isFieldValidating:n=>r.read.isFieldValidating(n),getDirtyValues:()=>r.read.getDirtyValues(),getPersistMetadata:()=>r.read.getPersistMetadata(),getHistoryMetadata:()=>r.read.getHistoryMetadata(),getScopeStatus:n=>r.read.getScopeStatus(n),getScopeErrors:n=>r.read.getScopeErrors(n),getScopeFields:n=>r.read.getScopeFields(n)},observe:{getState:t,subscribe:n=>r.observe.subscribe(n),subscribePersistMeta:n=>r.observe.subscribePersistMeta(n),subscribeHistoryMeta:n=>r.observe.subscribeHistoryMeta(n),subscribeScopeStatus:(n,o)=>r.observe.subscribeScopeStatus(n,o),subscribeFormMeta:n=>r.observe.subscribeFormMeta(n),subscribeSelector:(n,o,d)=>r.observe.subscribeSelector(n,o,d),subscribePath:(n,o,d)=>r.observe.subscribePath(n,o,d),subscribeFieldState:(n,o)=>r.observe.subscribeFieldState(n,o)},write:{setField:(n,o)=>r.write.setField(n,o),blurField:n=>r.write.blurField(n),markFieldsTouched:n=>r.write.markFieldsTouched(n),setValues:(n,o)=>r.write.setValues(n,o),setError:(n,o)=>r.write.setError(n,o),setErrors:n=>r.write.setErrors(n),setServerErrors:n=>r.write.setServerErrors(n),reset:()=>r.write.reset(),transaction:n=>r.write.transaction(n),submit:n=>r.write.submit(n)},feature:{cleanup:()=>r.feature.cleanup(),validate:n=>r.feature.validate(n),triggerValidation:(n,o)=>r.feature.triggerValidation(n,o),restorePersisted:()=>r.feature.restorePersisted(),forceSave:()=>r.feature.forceSave(),clearPersisted:()=>r.feature.clearPersisted(),registerField:(n,o)=>r.write.registerField(n,o),unregisterField:n=>r.write.unregisterField(n),unregisterPrefix:n=>r.write.unregisterPrefix(n),pushItem:(n,o)=>r.write.pushItem(n,o),prependItem:(n,o)=>r.write.prependItem(n,o),insertItem:(n,o,d)=>r.write.insertItem(n,o,d),removeItem:(n,o)=>r.write.removeItem(n,o),moveItem:(n,o,d)=>r.write.moveItem(n,o,d),swapItems:(n,o,d)=>r.write.swapItems(n,o,d),replaceItems:(n,o)=>r.write.replaceItems(n,o),clearItems:n=>r.write.clearItems(n),get canUndo(){return r.read.getCanUndo()},get canRedo(){return r.read.getCanRedo()},hasValidationsInProgress:n=>r.feature.hasValidationsInProgress(n),resolveMask:n=>r.resolveMask(n),createArrayItemId:(n,o)=>r.createArrayItemId(n,o),undo:()=>r.feature.undo(),redo:()=>r.feature.redo()}}}var ft= (_class17 =class{constructor(t){;_class17.prototype.__init52.call(this);this.deps=t}__init52() {this.fieldStateCache=new Map}getState(){return this.deps.getState()}getFlag(t){return this.deps.getState()[t]}getPersistMetadata(){return this.deps.getState().persist}getFieldState(t){let e=t,i=this.deps.getState(),s=this.fieldStateCache.get(e),a=_chunk6LNXTSZ6cjs.f.call(void 0, i.values,e),n=i.errors[e],o=!!i.touched[e],d=this.deps.isHidden(e),p=this.deps.isRequired(e),l=this.deps.isFieldDirty(e),c=this.deps.isFieldValidating(e);if(s){let h=s.snapshot;if(h.value===a&&h.error===n&&h.touched===o&&h.isHidden===d&&h.isRequired===p&&h.isDirty===l&&h.isValidating===c)return h}let u=It({state:i,path:t,value:a,isHidden:d,isRequired:p,isDirty:l,isValidating:c});return this.fieldStateCache.set(e,{state:i,snapshot:u}),u}invalidatePath(t){this.fieldStateCache.delete(t)}}, _class17);var mt= (_class18 =class{__init53() {this[A]=!0}__init54() {this[D]=!0}constructor(t={}){;_class18.prototype.__init53.call(this);_class18.prototype.__init54.call(this);let e=Ve({rawConfig:t});this._config=e.config,this.storeId=e.storeId;let i=new ft({getState:()=>e.runtime.getState(),isHidden:n=>e.runtime.capabilities.query.isHidden(n),isRequired:n=>e.runtime.capabilities.query.isRequired(n),isFieldDirty:n=>e.runtime.capabilities.query.isFieldDirty(n),isFieldValidating:n=>e.runtime.capabilities.query.isFieldValidating(n)}),s=Le({runtime:e.runtime,config:this._config,fieldRegistry:e.fieldRegistry,dirtyManager:e.dirtyManager,stateReader:i}),a=We({identity:{storeId:this.storeId,config:this._config},read:s.read,observe:s.observe,write:s.write,feature:s.feature,getFieldConfig:n=>e.fieldRegistry.getFieldConfig(n),resolveMask:n=>kt({path:n,getFieldConfig:o=>e.fieldRegistry.getFieldConfig(o),masks:e.maskManager.getAllMasks()}),createArrayItemId:(n,o)=>this._config.idFactory({scope:"array",path:n,index:o})});this.read=a.read,this.observe=a.observe,this.write=a.write,this.feature=a.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()})}}, _class18);function Ke(r={}){return new mt(r)}function $e(r){if(!r||typeof r!="object")return!1;let t=r;return t[A]===!0&&!!t.read&&!!t.observe&&!!t.write&&!!t.feature}function hi(r){if($e(r))return r;throw new Error("BitForm: o store informado n\xE3o exp\xF5e a API necess\xE1ria para hooks/framework bindings.")}function gi(r){return!r||typeof r!="object"?!1:r[D]===!0}function fi(r){if(!$e(r))throw new Error("BitForm: o store informado n\xE3o possui branding de hooks (BIT_HOOKS_API_SYMBOL).");if(!gi(r))throw new Error("BitForm: o store informado n\xE3o possui branding de framework (BIT_FRAMEWORK_STORE_SYMBOL).");return r}function mi(r){return Object.defineProperty(r,A,{value:!0,enumerable:!1,configurable:!1,writable:!1}),Object.defineProperty(r,D,{value:!0,enumerable:!1,configurable:!1,writable:!1}),r}function yi(r={}){let t=Ke(r),e={read:t.read,observe:t.observe,write:t.write,feature:t.feature};return mi(e)}function Si(r){return r.read}function bi(r){return r.observe}function Bi(r){return r.write}function Ti(r){return r.feature}function vi(r,t){let e={};for(let i of t)e[i]=r[i];return e}exports.a = Tt; exports.b = ii; exports.c = hi; exports.d = fi; exports.e = yi; exports.f = Si; exports.g = bi; exports.h = Bi; exports.i = Ti; exports.j = vi;
|
|
2
|
+
//# sourceMappingURL=chunk-J5ALITQW.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-J5ALITQW.cjs","../src/core/store/engines/store-field-query-engine.ts","../src/core/store/orchestration/framework-store-brand.ts","../src/core/store/orchestration/hook-brand.ts","../src/core/store/managers/core/baseline-manager.ts","../src/core/store/managers/core/computed-manager.ts"],"names":["resolveFieldMask","args","path","getFieldConfig","masks","maskOption","createFieldStateSnapshot","state","value","isHidden","isRequired","isDirty","isValidating","pathKey","BIT_FRAMEWORK_STORE_SYMBOL","BIT_HOOKS_API_SYMBOL","BitBaselineManager","baselineValues","deepClone","values","BitComputedManager","getComputedEntries","changedPaths","computedEntries","entriesToRun","nextValues","entry","newValue","currentValue","getDeepValue","cached","valuesEqual","canUseScalarCache","deepEqual","setDeepValue","entries","map","dep","dependents","childIdx","segments","len","prefix","children","reverseDependencies","affectedPaths","queue","queueIndex","currentPath","dependentPath","orderedAllEntries","indexByPath","affectedEntries","entryIndex","left","right","item","entryByPath","inDegree","dependencyPath","nextDependents","orderedPaths","nextDegree","signature","ordered","orderedEntries","index"],"mappings":"AAAA,29BAAuE,wDAA0C,wDAA4G,SCU7MA,EAAAA,CAAmCC,CAAAA,CAI3B,CACtB,GAAM,CAAE,IAAA,CAAAC,CAAAA,CAAM,cAAA,CAAAC,CAAAA,CAAgB,KAAA,CAAAC,CAAM,CAAA,CAAIH,CAAAA,CAClCI,CAAAA,iBAAaF,CAAAA,mBAAeD,CAAI,CAAA,6BAAG,MAAA,CAEzC,EAAA,CAAKG,CAAAA,CAIL,OAAI,OAAOA,CAAAA,EAAe,QAAA,iBACjBD,CAAAA,4BAAAA,CAAQC,CAAgC,GAAA,C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,GAAA,CAAKT,CAAAA,EAAU,CAAA,EAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-J5ALITQW.cjs","sourcesContent":[null,"import type { BitMask, BitMaskName } from \"../../mask/types\";\nimport type {\n BitErrors,\n BitFieldDefinition,\n BitFieldState,\n BitPath,\n BitPathValue,\n BitState,\n} from \"../contracts/types\";\n\nexport function resolveFieldMask<T extends object>(args: {\n path: string;\n getFieldConfig: (path: string) => BitFieldDefinition<T> | undefined;\n masks: Record<BitMaskName, BitMask> | undefined;\n}): BitMask | undefined {\n const { path, getFieldConfig, masks } = args;\n const maskOption = getFieldConfig(path)?.mask;\n\n if (!maskOption) {\n return undefined;\n }\n\n if (typeof maskOption === \"string\") {\n return masks?.[maskOption as keyof typeof masks];\n }\n\n return maskOption;\n}\n\nexport function createFieldStateSnapshot<\n TForm extends object,\n P extends BitPath<TForm>,\n>(args: {\n state: Readonly<BitState<TForm>>;\n path: P;\n value: BitPathValue<TForm, P>;\n isHidden: boolean;\n isRequired: boolean;\n isDirty: boolean;\n isValidating: boolean;\n}): BitFieldState<TForm, BitPathValue<TForm, P>> {\n const { state, path, value, isHidden, isRequired, isDirty, isValidating } =\n args;\n const pathKey = path as string;\n\n return {\n value,\n error: state.errors[pathKey as keyof BitErrors<TForm>],\n touched: !!state.touched[pathKey as keyof typeof state.touched],\n isHidden,\n isRequired,\n isDirty,\n isValidating,\n };\n}\n","export const BIT_FRAMEWORK_STORE_SYMBOL = Symbol.for(\n \"bit-form.framework-store-api\",\n);\n","export const BIT_HOOKS_API_SYMBOL = Symbol.for(\"bit-form.hooks-api\");\n","import { deepClone } from \"../../../utils\";\n\nexport class BitBaselineManager<T extends object> {\n constructor(baselineValues: T) {\n this.baselineValues = deepClone(baselineValues);\n }\n\n private baselineValues: T;\n private baselineSnapshot?: Readonly<T>;\n\n getValues(): T {\n if (!this.baselineSnapshot) {\n this.baselineSnapshot = Object.freeze(deepClone(this.baselineValues));\n }\n\n return this.baselineSnapshot as T;\n }\n\n setValues(values: T): void {\n this.baselineValues = deepClone(values);\n this.baselineSnapshot = undefined;\n }\n}\n","import { deepEqual, getDeepValue, setDeepValue } from \"../../../utils\";\nimport type { BitComputedFn } from \"../../contracts/types\";\n\nexport interface BitComputedEntry<T extends object> {\n path: string;\n compute: BitComputedFn<T>;\n dependsOn: readonly string[];\n}\n\nexport class BitComputedManager<T extends object> {\n private equalityCache = new Map<\n string,\n { current: unknown; next: unknown; equal: boolean }\n >();\n private reverseDepsCache: Map<string, Set<string>> | null = null;\n private childDepsIndex: Map<string, Set<string>> | null = null;\n private validatedEntriesSignature: string | null = null;\n private validatedEntriesRef: BitComputedEntry<T>[] | null = null;\n private orderedAllEntriesCache: {\n signature: string;\n ordered: BitComputedEntry<T>[];\n } | null = null;\n private orderedIndexByPathCache: {\n signature: string;\n indexByPath: Map<string, number>;\n } | null = null;\n\n constructor(private getComputedEntries: () => BitComputedEntry<T>[]) {}\n\n private isCacheableScalar(value: unknown): boolean {\n return (\n value === null ||\n (typeof value !== \"object\" && typeof value !== \"function\")\n );\n }\n\n invalidateReverseDeps(): void {\n this.reverseDepsCache = null;\n this.childDepsIndex = null;\n this.orderedAllEntriesCache = null;\n this.validatedEntriesSignature = null;\n this.validatedEntriesRef = null;\n this.orderedIndexByPathCache = null;\n this.equalityCache.clear();\n }\n\n apply(values: T, changedPaths?: readonly string[]): T {\n const computedEntries = this.getComputedEntries();\n if (computedEntries.length === 0) return values;\n\n this.ensureEntriesAreValid(computedEntries);\n\n const entriesToRun = this.resolveEntriesToRun(\n computedEntries,\n changedPaths,\n );\n\n if (entriesToRun.length === 0) {\n return values;\n }\n\n let nextValues = values;\n\n for (const entry of entriesToRun) {\n const newValue = entry.compute(nextValues);\n const currentValue = getDeepValue(nextValues, entry.path);\n\n const cached = this.equalityCache.get(entry.path);\n let valuesEqual: boolean;\n const canUseScalarCache =\n this.isCacheableScalar(currentValue) &&\n this.isCacheableScalar(newValue);\n\n if (\n canUseScalarCache &&\n cached &&\n cached.current === currentValue &&\n cached.next === newValue\n ) {\n valuesEqual = cached.equal;\n } else {\n valuesEqual = deepEqual(currentValue, newValue);\n\n if (canUseScalarCache) {\n this.equalityCache.set(entry.path, {\n current: currentValue,\n next: newValue,\n equal: valuesEqual,\n });\n } else {\n this.equalityCache.delete(entry.path);\n }\n }\n\n if (!valuesEqual) {\n nextValues = setDeepValue(nextValues, entry.path, newValue);\n }\n }\n return nextValues;\n }\n\n private getReverseDependencies(\n entries: BitComputedEntry<T>[],\n ): Map<string, Set<string>> {\n if (this.reverseDepsCache) return this.reverseDepsCache;\n\n const map = new Map<string, Set<string>>();\n\n for (const entry of entries) {\n for (const dep of entry.dependsOn) {\n let dependents = map.get(dep);\n if (!dependents) {\n dependents = new Set();\n map.set(dep, dependents);\n }\n dependents.add(entry.path);\n }\n }\n\n const childIdx = new Map<string, Set<string>>();\n\n for (const dep of map.keys()) {\n const segments = dep.split(\".\");\n for (let len = 1; len < segments.length; len++) {\n const prefix = segments.slice(0, len).join(\".\");\n let children = childIdx.get(prefix);\n if (!children) {\n children = new Set();\n childIdx.set(prefix, children);\n }\n children.add(dep);\n }\n }\n\n this.reverseDepsCache = map;\n this.childDepsIndex = childIdx;\n return map;\n }\n\n private resolveEntriesToRun(\n entries: BitComputedEntry<T>[],\n changedPaths?: readonly string[],\n ): BitComputedEntry<T>[] {\n if (\n !changedPaths ||\n changedPaths.length === 0 ||\n changedPaths.includes(\"*\")\n ) {\n return this.getOrderedAllEntries(entries);\n }\n\n const reverseDependencies = this.getReverseDependencies(entries);\n const affectedPaths = new Set<string>();\n const queue = [...changedPaths];\n let queueIndex = 0;\n\n while (queueIndex < queue.length) {\n const currentPath = queue[queueIndex++]!;\n const dependents = this.getDependentsForPath(\n reverseDependencies,\n currentPath,\n );\n\n if (!dependents) {\n continue;\n }\n\n for (const dependentPath of dependents) {\n if (affectedPaths.has(dependentPath)) {\n continue;\n }\n\n affectedPaths.add(dependentPath);\n queue.push(dependentPath);\n }\n }\n\n if (affectedPaths.size === 0) {\n return [];\n }\n\n const orderedAllEntries = this.getOrderedAllEntries(entries);\n const indexByPath = this.getOrderedIndexByPath(entries, orderedAllEntries);\n const affectedEntries: Array<{\n index: number;\n entry: BitComputedEntry<T>;\n }> = [];\n\n affectedPaths.forEach((path) => {\n const entryIndex = indexByPath.get(path);\n if (entryIndex === undefined) {\n return;\n }\n\n const entry = orderedAllEntries[entryIndex];\n if (!entry) {\n return;\n }\n\n affectedEntries.push({ index: entryIndex, entry });\n });\n\n affectedEntries.sort((left, right) => left.index - right.index);\n return affectedEntries.map((item) => item.entry);\n }\n\n private orderEntries(entries: BitComputedEntry<T>[]) {\n if (entries.length <= 1) {\n return entries;\n }\n\n const entryByPath = new Map(entries.map((entry) => [entry.path, entry]));\n const inDegree = new Map<string, number>();\n const dependents = new Map<string, Set<string>>();\n\n entries.forEach((entry) => inDegree.set(entry.path, 0));\n\n entries.forEach((entry) => {\n entry.dependsOn.forEach((dependencyPath) => {\n if (!entryByPath.has(dependencyPath)) {\n return;\n }\n\n const nextDependents = dependents.get(dependencyPath) ?? new Set();\n if (!nextDependents.has(entry.path)) {\n nextDependents.add(entry.path);\n dependents.set(dependencyPath, nextDependents);\n inDegree.set(entry.path, (inDegree.get(entry.path) ?? 0) + 1);\n }\n });\n });\n\n const queue = entries\n .filter((entry) => (inDegree.get(entry.path) ?? 0) === 0)\n .map((entry) => entry.path);\n const orderedPaths: string[] = [];\n\n while (queue.length > 0) {\n const currentPath = queue.shift()!;\n orderedPaths.push(currentPath);\n\n const nextDependents = dependents.get(currentPath);\n if (!nextDependents) {\n continue;\n }\n\n nextDependents.forEach((dependentPath) => {\n const nextDegree = (inDegree.get(dependentPath) ?? 0) - 1;\n inDegree.set(dependentPath, nextDegree);\n\n if (nextDegree === 0) {\n queue.push(dependentPath);\n }\n });\n }\n\n if (orderedPaths.length !== entries.length) {\n throw new Error(\n \"BitStore: cyclic computed dependencies detected. Check computedDependsOn definitions.\",\n );\n }\n\n return orderedPaths.map((path) => entryByPath.get(path)!);\n }\n\n private getOrderedAllEntries(entries: BitComputedEntry<T>[]) {\n const signature = this.createEntriesSignature(entries);\n if (\n this.orderedAllEntriesCache &&\n this.orderedAllEntriesCache.signature === signature\n ) {\n return this.orderedAllEntriesCache.ordered;\n }\n\n const ordered = this.orderEntries(entries);\n this.orderedAllEntriesCache = { signature, ordered };\n return ordered;\n }\n\n private getOrderedIndexByPath(\n entries: BitComputedEntry<T>[],\n orderedEntries: BitComputedEntry<T>[],\n ): Map<string, number> {\n const signature = this.createEntriesSignature(entries);\n if (\n this.orderedIndexByPathCache &&\n this.orderedIndexByPathCache.signature === signature\n ) {\n return this.orderedIndexByPathCache.indexByPath;\n }\n\n const indexByPath = new Map<string, number>();\n orderedEntries.forEach((entry, index) => {\n indexByPath.set(entry.path, index);\n });\n\n this.orderedIndexByPathCache = { signature, indexByPath };\n return indexByPath;\n }\n\n private ensureEntriesAreValid(entries: BitComputedEntry<T>[]) {\n if (this.validatedEntriesRef === entries) {\n return;\n }\n\n const signature = this.createEntriesSignature(entries);\n if (this.validatedEntriesSignature === signature) {\n this.validatedEntriesRef = entries;\n return;\n }\n\n entries.forEach((entry) => this.assertDependencies(entry));\n this.invalidateReverseDeps();\n this.validatedEntriesSignature = signature;\n this.validatedEntriesRef = entries;\n }\n\n private createEntriesSignature(entries: BitComputedEntry<T>[]): string {\n return entries\n .map((entry) => `${entry.path}:${entry.dependsOn.join(\",\")}`)\n .join(\"|\");\n }\n\n private getDependentsForPath(\n reverseDependencies: Map<string, Set<string>>,\n changedPath: string,\n ) {\n const dependents = new Set<string>();\n\n const collect = (dependencyPath: string) => {\n const listeners = reverseDependencies.get(dependencyPath);\n if (!listeners) {\n return;\n }\n\n listeners.forEach((path) => dependents.add(path));\n };\n\n collect(changedPath);\n\n const parentSegments = changedPath.split(\".\");\n while (parentSegments.length > 1) {\n parentSegments.pop();\n collect(parentSegments.join(\".\"));\n }\n\n const childKeys = this.childDepsIndex?.get(changedPath);\n if (childKeys) {\n for (const childDep of childKeys) {\n collect(childDep);\n }\n }\n\n return dependents;\n }\n\n private assertDependencies(entry: BitComputedEntry<T>) {\n if (entry.dependsOn.length === 0) {\n throw new Error(\n `BitStore: computed field \\`${entry.path}\\` requires explicit computedDependsOn in v4.`,\n );\n }\n\n if (entry.dependsOn.includes(entry.path)) {\n throw new Error(\n `BitStore: computed field \\`${entry.path}\\` cannot depend on itself.`,\n );\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as M}from"./chunk-UARLAXZX.js";import{a as A,b as C,d as E,e as D,g as U,i as j,j as I,k as q}from"./chunk-Y3XVQGCU.js";import{b as F}from"./chunk-UIKO6GGW.js";import{a as k}from"./chunk-2QLQPMCZ.js";import{c as V,f as w}from"./chunk-QX2IVNMK.js";import{createContext as G,useContext as H}from"react";import{jsx as J}from"react/jsx-runtime";var L=G(null),dt=({store:t,children:e})=>J(L.Provider,{value:M(t),children:e}),c=()=>{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 yt(){let t=c(),[e,r]=O(null),[n,o]=O(null),s=Q(null),m=p(S=>C(t,S),[t]),l=p(()=>{let S=A(t);return s.current&&s.current.isValid===S.isValid&&s.current.isDirty===S.isDirty&&s.current.isSubmitting===S.isSubmitting?s.current:(s.current=S,S)},[t]),i=K(m,l,l),d=W(()=>j(t,{clearSubmissionState:()=>{r(null),o(null)},setSubmissionResult:S=>{o(S)},setSubmissionError:S=>{r(S)}}),[t]),{controller:a,actions:h}=d,x=p(a.submit,[a]),v=p(a.onSubmit,[a]),T=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(()=>({...i,submitError:e,lastResponse:n}),[i,e,n]),getValues:u,getErrors:b,getTouched:B,getDirtyValues:g,submit:x,onSubmit:v,reset:T,...h}}import{useCallback as _,useEffect as X,useMemo as $,useSyncExternalStore as Y}from"react";function Et(t){let e=c(),r=$(()=>U(e,t),[e,t]),n=_(()=>r.readItems(),[r]),o=_(l=>e.observe.subscribePath(t,()=>l()),[e,t]),s=Y(o,n,n),m=$(()=>r.getFields(s),[r,s]);return X(()=>()=>{q(e,`${t}.`)},[e,t]),{fields:m,length:s.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 y,useRef as Z,useSyncExternalStore as N}from"react";function Mt(t){let e=c(),r=Z(null),n=y(()=>{let i=e.read.getScopeStatus(t);return r.current&&F(r.current,i)?r.current:(r.current=i,i)},[e,t]),o=y(i=>e.observe.subscribeScopeStatus(t,()=>i()),[e,t]),s=N(o,n,n),m=y(async()=>{let i=await e.feature.validate({scope:t}),d=e.read.getScopeErrors(t);return{valid:i,errors:d}},[e,t]),l=y(()=>e.read.getScopeErrors(t),[e,t]);return{scopeName:t,status:s,errors:s.errors,validate:m,getErrors:l,isValid:!s.hasErrors,isDirty:s.isDirty}}import{useCallback as f,useRef as tt,useState as et,useSyncExternalStore as rt}from"react";function jt(t){let e=c(),[r,n]=et(0),o=t[r]??"",s=tt(null),m=f(()=>{let u=e.read.getScopeStatus(o);return s.current&&F(s.current,u)?s.current:(s.current=u,u)},[e,o]),l=rt(f(u=>e.observe.subscribeScopeStatus(o,()=>u()),[e,o]),m,m),i=f(async()=>{let u=await e.feature.validate({scope:o}),b=e.read.getScopeErrors(o);return{valid:u,errors:b}},[e,o]),d=f(()=>e.read.getScopeErrors(o),[e,o]),a=f(async()=>{let u=e.read.getScopeFields(o);if(e.feature.hasValidationsInProgress(u))return!1;let b=await e.feature.validate({scope:o});if(b)n(B=>Math.min(B+1,t.length-1));else{let B=e.read.getScopeErrors(o),g=Object.keys(B);g.length>0&&e.write.markFieldsTouched(g)}return b},[e,o,t.length]),h=f(()=>{n(u=>Math.max(u-1,0))},[]),x=f(u=>{n(Math.max(0,Math.min(u-1,t.length-1)))},[t.length]),v=r===0,T=r>=t.length-1;return{step:r+1,stepIndex:r,scope:o,next:a,prev:h,goTo:x,isFirst:v,isLast:T,status:l,errors:l.errors,isValid:!l.hasErrors,isDirty:l.isDirty,validate:i,getErrors:d}}import{useCallback as z,useSyncExternalStore as st,useRef as ot}from"react";function $t(t){let e=c(),r=ot(null),n=z(()=>{let s=w(e.read.getState().values,t);return r.current!==null&&V(r.current,s)?r.current:(r.current=s,s)},[e,t]),o=z(s=>e.observe.subscribePath(t,()=>s()),[e,t]);return st(o,n,n)}import{useCallback as R,useMemo as nt,useSyncExternalStore as it}from"react";function Kt(){let t=c(),e=it(m=>D(t,m),()=>E(t),()=>E(t)),r=R(async()=>t.feature.restorePersisted(),[t]),n=R(async()=>{await t.feature.forceSave()},[t]),o=R(async()=>{await t.feature.clearPersisted()},[t]),s=nt(()=>({isSaving:e.isSaving,isRestoring:e.isRestoring,error:e.error}),[e]);return{restore:r,save:n,clear:o,meta:s}}import{useCallback as P,useEffect as at,useRef as ut,useSyncExternalStore as ct}from"react";function re(t){let e=c(),r=ut(null);at(()=>()=>I(e,t),[e,t]);let n=P(()=>{let i=e.read.getFieldState(t),d=k(i,r.current);return r.current=d,d},[e,t]),o=P(i=>e.observe.subscribeFieldState(t,()=>i()),[e,t]),s=ct(o,n,n),m=P(i=>e.write.setField(t,i),[e,t]),l=P(()=>e.write.blurField(t),[e,t]);return{fieldState:s,setValue:m,setBlur:l,store:e}}export{dt as a,c as b,yt as c,re as d,Et as e,Mt as f,jt as g,$t as h,Kt as i};
|
|
2
|
+
//# sourceMappingURL=chunk-J5GQLEVA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react/context.tsx","../src/react/use-bit-form.ts","../src/react/use-bit-array.ts","../src/react/use-bit-scope.ts","../src/react/use-bit-steps.ts","../src/react/use-bit-watch.ts","../src/react/use-bit-persist.ts","../src/react/use-bit-field-base.ts"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\nimport type { BitFrameworkStoreApi, BitStoreApi } from \"../core\";\nimport { createFrameworkStoreAdapter } from \"../core\";\n\nconst BitContext = createContext<BitFrameworkStoreApi<any> | null>(null);\n\nexport const BitFormProvider = ({\n store,\n children,\n}: {\n store: BitFrameworkStoreApi<any> | BitStoreApi<any>;\n children: React.ReactNode;\n}) => (\n <BitContext.Provider value={createFrameworkStoreAdapter(store)}>\n {children}\n </BitContext.Provider>\n);\n\nexport const useBitStore = <T extends object>() => {\n const store = useContext(BitContext);\n if (!store)\n throw new Error(\n \"BitForm hooks devem ser usados dentro de um BitFormProvider\",\n );\n return store as BitFrameworkStoreApi<T>;\n};\n","import {\n useCallback,\n useSyncExternalStore,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useBitStore } from \"./context\";\nimport {\n createFrameworkFormBinding,\n readFormMetaSnapshot,\n subscribeFormMetaSnapshot,\n} from \"../core\";\nimport type { UseBitFormResult } from \"./types\";\n\nexport function useBitForm<T extends object>(): UseBitFormResult<T> {\n const store = useBitStore<T>();\n\n const [submitError, setSubmitError] = useState<Error | null>(null);\n const [lastResponse, setLastResponse] = useState<unknown>(null);\n const lastMeta = useRef<ReturnType<typeof readFormMetaSnapshot<T>> | null>(\n null,\n );\n\n const subscribeMeta = useCallback(\n (cb: () => void) => subscribeFormMetaSnapshot(store, cb),\n [store],\n );\n const getMetaSnapshot = useCallback(() => {\n const nextMeta = readFormMetaSnapshot(store);\n\n if (\n lastMeta.current &&\n lastMeta.current.isValid === nextMeta.isValid &&\n lastMeta.current.isDirty === nextMeta.isDirty &&\n lastMeta.current.isSubmitting === nextMeta.isSubmitting\n ) {\n return lastMeta.current;\n }\n\n lastMeta.current = nextMeta;\n return nextMeta;\n }, [store]);\n\n const metaState = useSyncExternalStore(\n subscribeMeta,\n getMetaSnapshot,\n getMetaSnapshot,\n );\n\n const binding = useMemo(\n () =>\n createFrameworkFormBinding(store, {\n clearSubmissionState: () => {\n setSubmitError(null);\n setLastResponse(null);\n },\n setSubmissionResult: (result) => {\n setLastResponse(result);\n },\n setSubmissionError: (error) => {\n setSubmitError(error);\n },\n }),\n [store],\n );\n\n const { controller, actions } = binding;\n\n const submit = useCallback(controller.submit, [controller]);\n const onSubmit = useCallback(controller.onSubmit, [controller]);\n const reset = useCallback(controller.reset, [controller]);\n\n const getValues = useCallback(controller.getValues, [controller]);\n const getErrors = useCallback(controller.getErrors, [controller]);\n const getTouched = useCallback(controller.getTouched, [controller]);\n const getDirtyValues = useCallback(controller.getDirtyValues, [controller]);\n\n const meta = useMemo(\n () => ({\n ...metaState,\n submitError,\n lastResponse,\n }),\n [metaState, submitError, lastResponse],\n );\n\n return {\n // Metadata (grouped)\n meta,\n // Getters\n getValues,\n getErrors,\n getTouched,\n getDirtyValues,\n // Main actions (frequent use - flat)\n submit,\n onSubmit,\n reset,\n ...actions,\n };\n}\n","import { useCallback, useEffect, useMemo, useSyncExternalStore } from \"react\";\nimport {\n BitArrayPath,\n cleanupRegisteredPrefix,\n createArrayBinding,\n} from \"../core\";\nimport { useBitStore } from \"./context\";\n\nexport function useBitArray<\n TForm extends object = any,\n P extends BitArrayPath<TForm> = BitArrayPath<TForm>,\n>(path: P) {\n const store = useBitStore<TForm>();\n const controller = useMemo(\n () => createArrayBinding<TForm, P>(store, path),\n [store, path],\n );\n\n const getSnapshot = useCallback(() => {\n return controller.readItems();\n }, [controller]);\n\n const subscribeArray = useCallback(\n (cb: () => void) => store.observe.subscribePath(path, () => cb()),\n [store, path],\n );\n\n const data = useSyncExternalStore(subscribeArray, getSnapshot, getSnapshot);\n\n const fields = useMemo(() => controller.getFields(data), [controller, data]);\n\n useEffect(() => {\n return () => {\n cleanupRegisteredPrefix(store, `${path as string}.`);\n };\n }, [store, path]);\n\n return {\n fields,\n length: data.length,\n append: controller.append,\n prepend: controller.prepend,\n insert: controller.insert,\n remove: controller.remove,\n move: controller.move,\n swap: controller.swap,\n replace: controller.replace,\n clear: controller.clear,\n };\n}\n","import { useCallback, useRef, useSyncExternalStore } from \"react\";\nimport type { ScopeStatus, ValidateScopeResult } from \"../core\";\nimport { isScopeStatusEqual } from \"../core\";\nimport { useBitStore } from \"./context\";\n\nexport type { ScopeStatus, ValidateScopeResult };\n\nexport function useBitScope(scopeName: string) {\n const store = useBitStore();\n\n const lastStatus = useRef<ScopeStatus | null>(null);\n\n const getStatusSnapshot = useCallback(() => {\n const nextStatus = store.read.getScopeStatus(scopeName);\n\n if (\n lastStatus.current &&\n isScopeStatusEqual(lastStatus.current, nextStatus)\n ) {\n return lastStatus.current;\n }\n\n lastStatus.current = nextStatus;\n return nextStatus;\n }, [store, scopeName]);\n\n // Assina apenas os slices de estado relevantes para o escopo (errors e\n // isDirty), evitando execuções desnecessárias do getStatusSnapshot em\n // mudanças não relacionadas (isSubmitting, isValidating de outros campos…)\n const subscribe = useCallback(\n (cb: () => void) =>\n store.observe.subscribeScopeStatus(scopeName, () => cb()),\n [store, scopeName],\n );\n\n const status = useSyncExternalStore(\n subscribe,\n getStatusSnapshot,\n getStatusSnapshot,\n );\n\n const validate = useCallback(async (): Promise<ValidateScopeResult> => {\n const valid = await store.feature.validate({ scope: scopeName });\n const errors = store.read.getScopeErrors(scopeName);\n return { valid, errors };\n }, [store, scopeName]);\n\n const getErrors = useCallback(() => {\n return store.read.getScopeErrors(scopeName);\n }, [store, scopeName]);\n\n return {\n scopeName,\n status,\n errors: status.errors,\n validate,\n getErrors,\n isValid: !status.hasErrors,\n isDirty: status.isDirty,\n };\n}\n","import { useCallback, useRef, useState, useSyncExternalStore } from \"react\";\nimport type { ScopeStatus, ValidateScopeResult } from \"../core\";\nimport { isScopeStatusEqual } from \"../core\";\nimport { useBitStore } from \"./context\";\nimport type { UseBitStepsResult } from \"./types\";\n\nexport function useBitSteps(scopeNames: string[]): UseBitStepsResult {\n const store = useBitStore();\n const [stepIndex, setStepIndex] = useState(0);\n\n const scope = scopeNames[stepIndex] ?? \"\";\n const lastStatus = useRef<ScopeStatus | null>(null);\n\n const getStatusSnapshot = useCallback(() => {\n const nextStatus = store.read.getScopeStatus(scope);\n\n if (\n lastStatus.current &&\n isScopeStatusEqual(lastStatus.current, nextStatus)\n ) {\n return lastStatus.current;\n }\n\n lastStatus.current = nextStatus;\n return nextStatus;\n }, [store, scope]);\n\n const status = useSyncExternalStore(\n useCallback(\n (cb: () => void) => store.observe.subscribeScopeStatus(scope, () => cb()),\n [store, scope],\n ),\n getStatusSnapshot,\n getStatusSnapshot,\n );\n\n const validate = useCallback(async (): Promise<ValidateScopeResult> => {\n const valid = await store.feature.validate({ scope });\n const errors = store.read.getScopeErrors(scope);\n return { valid, errors };\n }, [store, scope]);\n\n const getErrors = useCallback(() => {\n return store.read.getScopeErrors(scope);\n }, [store, scope]);\n\n const next = useCallback(async (): Promise<boolean> => {\n const scopeFields = store.read.getScopeFields(scope);\n\n if (store.feature.hasValidationsInProgress(scopeFields)) {\n return false;\n }\n\n const valid = await store.feature.validate({ scope });\n if (valid) {\n setStepIndex((s) => Math.min(s + 1, scopeNames.length - 1));\n } else {\n const errors = store.read.getScopeErrors(scope);\n const pathsWithErrors = Object.keys(errors);\n if (pathsWithErrors.length > 0) {\n store.write.markFieldsTouched(pathsWithErrors);\n }\n }\n return valid;\n }, [store, scope, scopeNames.length]);\n\n const prev = useCallback(() => {\n setStepIndex((s) => Math.max(s - 1, 0));\n }, []);\n\n const goTo = useCallback(\n (targetStep: number) => {\n setStepIndex(\n Math.max(0, Math.min(targetStep - 1, scopeNames.length - 1)),\n );\n },\n [scopeNames.length],\n );\n\n const isFirst = stepIndex === 0;\n const isLast = stepIndex >= scopeNames.length - 1;\n\n return {\n step: stepIndex + 1,\n stepIndex,\n scope,\n next,\n prev,\n goTo,\n isFirst,\n isLast,\n status,\n errors: status.errors,\n isValid: !status.hasErrors,\n isDirty: status.isDirty,\n validate,\n getErrors,\n };\n}\n","import { useCallback, useSyncExternalStore, useRef } from \"react\";\nimport { useBitStore } from \"./context\";\nimport { getDeepValue, valueEqual, BitPath, BitPathValue } from \"../core\";\n\nexport function useBitWatch<\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n>(path: P): BitPathValue<TForm, P> {\n const store = useBitStore<TForm>();\n const lastValue = useRef<BitPathValue<TForm, P> | null>(null);\n\n const getSnapshot = useCallback(() => {\n const value = getDeepValue(\n store.read.getState().values,\n path as string,\n ) as BitPathValue<TForm, P>;\n\n if (lastValue.current !== null && valueEqual(lastValue.current, value)) {\n return lastValue.current;\n }\n\n lastValue.current = value;\n return value;\n }, [store, path]);\n\n // Assina apenas o path monitorado → evita executar getSnapshot em toda\n // mudança de estado do store (blur, validation, outros campos, etc.)\n const subscribe = useCallback(\n (cb: () => void) => store.observe.subscribePath(path, () => cb()),\n [store, path],\n );\n\n return useSyncExternalStore(\n subscribe,\n getSnapshot,\n getSnapshot,\n ) as BitPathValue<TForm, P>;\n}\n","import { useCallback, useMemo, useSyncExternalStore } from \"react\";\nimport { useBitStore } from \"./context\";\nimport { readPersistMetaSnapshot, subscribePersistMetaSnapshot } from \"../core\";\nimport type { UseBitPersistResult } from \"./types\";\n\nexport function useBitPersist(): UseBitPersistResult {\n const store = useBitStore<any>();\n\n const persistMeta = useSyncExternalStore(\n (cb) => subscribePersistMetaSnapshot(store, cb),\n () => readPersistMetaSnapshot(store),\n () => readPersistMetaSnapshot(store),\n );\n\n const restore = useCallback(async () => {\n return store.feature.restorePersisted();\n }, [store]);\n\n const save = useCallback(async () => {\n await store.feature.forceSave();\n }, [store]);\n\n const clear = useCallback(async () => {\n await store.feature.clearPersisted();\n }, [store]);\n\n const meta = useMemo(\n () => ({\n isSaving: persistMeta.isSaving,\n isRestoring: persistMeta.isRestoring,\n error: persistMeta.error,\n }),\n [persistMeta],\n );\n\n return {\n restore,\n save,\n clear,\n meta,\n };\n}\n","import { useCallback, useEffect, useRef, useSyncExternalStore } from \"react\";\nimport {\n BitFieldSnapshot,\n BitPath,\n BitPathValue,\n cleanupRegisteredField,\n createFieldStateSnapshot,\n} from \"../core\";\nimport { useBitStore } from \"./context\";\n\nexport function useBitFieldBase<\n _TValue = any,\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n>(path: P) {\n const store = useBitStore<TForm>();\n const lastSnapshot = useRef<BitFieldSnapshot<BitPathValue<TForm, P>> | null>(\n null,\n );\n\n useEffect(() => {\n return () => cleanupRegisteredField(store, path as string);\n }, [store, path]);\n\n const getSnapshot = useCallback(() => {\n const nextState = store.read.getFieldState(path);\n const snapshot = createFieldStateSnapshot(nextState, lastSnapshot.current);\n lastSnapshot.current = snapshot;\n return snapshot;\n }, [store, path]);\n\n const subscribe = useCallback(\n (cb: () => void) => store.observe.subscribeFieldState(path, () => cb()),\n [store, path],\n );\n\n const fieldState = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\n const setValue = useCallback(\n (val: BitPathValue<TForm, P>) => store.write.setField(path, val),\n [store, path],\n );\n\n const setBlur = useCallback(() => store.write.blurField(path), [store, path]);\n\n return { fieldState, setValue, setBlur, store };\n}\n"],"mappings":"gQAAA,OAAgB,iBAAAA,EAAe,cAAAC,MAAkB,QAa/C,cAAAC,MAAA,oBATF,IAAMC,EAAaC,EAAgD,IAAI,EAE1DC,GAAkB,CAAC,CAC9B,MAAAC,EACA,SAAAC,CACF,IAIEL,EAACC,EAAW,SAAX,CAAoB,MAAOK,EAA4BF,CAAK,EAC1D,SAAAC,EACH,EAGWE,EAAc,IAAwB,CACjD,IAAMH,EAAQI,EAAWP,CAAU,EACnC,GAAI,CAACG,EACH,MAAM,IAAI,MACR,6DACF,EACF,OAAOA,CACT,ECzBA,OACE,eAAAK,EACA,wBAAAC,EACA,WAAAC,EACA,UAAAC,EACA,YAAAC,MACK,QASA,SAASC,IAAoD,CAClE,IAAMC,EAAQC,EAAe,EAEvB,CAACC,EAAaC,CAAc,EAAIC,EAAuB,IAAI,EAC3D,CAACC,EAAcC,CAAe,EAAIF,EAAkB,IAAI,EACxDG,EAAWC,EACf,IACF,EAEMC,EAA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EAAS,CACT,IAAMC,EAAQC,EAAmB,EAC3BC,EAAeC,GACnB,IACF,EAEAC,GAAU,IACD,IAAMC,EAAuBL,EAAOD,CAAc,EACxD,CAACC,EAAOD,CAAI,CAAC,EAEhB,IAAMO,EAAcC,EAAY,IAAM,CACpC,IAAMC,EAAYR,EAAM,KAAK,cAAcD,CAAI,EACzCU,EAAWC,EAAyBF,EAAWN,EAAa,OAAO,EACzE,OAAAA,EAAa,QAAUO,EAChBA,CACT,EAAG,CAACT,EAAOD,CAAI,CAAC,EAEVY,EAAYJ,EACfK,GAAmBZ,EAAM,QAAQ,oBAAoBD,EAAM,IAAMa,EAAG,CAAC,EACtE,CAACZ,EAAOD,CAAI,CACd,EAEMc,EAAaC,GAAqBH,EAAWL,EAAaA,CAAW,EAErES,EAAWR,EACdS,GAAgChB,EAAM,MAAM,SAASD,EAAMiB,CAAG,EAC/D,CAAChB,EAAOD,CAAI,CACd,EAEMkB,EAAUV,EAAY,IAAMP,EAAM,MAAM,UAAUD,CAAI,EAAG,CAACC,EAAOD,CAAI,CAAC,EAE5E,MAAO,CAAE,WAAAc,EAAY,SAAAE,EAAU,QAAAE,EAAS,MAAAjB,CAAM,CAChD","names":["createContext","useContext","jsx","BitContext","createContext","BitFormProvider","store","children","createFrameworkStoreAdapter","useBitStore","useContext","useCallback","useSyncExternalStore","useMemo","useRef","useState","useBitForm","store","useBitStore","submitError","setSubmitError","useState","lastResponse","setLastResponse","lastMeta","useRef","subscribeMeta","useCallback","cb","subscribeFormMetaSnapshot","getMetaSnapshot","nextMeta","readFormMetaSnapshot","metaState","useSyncExternalStore","binding","useMemo","createFrameworkFormBinding","result","error","controller","actions","submit","onSubmit","reset","getValues","getErrors","getTouched","getDirtyValues","useCallback","useEffect","useMemo","useSyncExternalStore","useBitArray","path","store","useBitStore","controller","useMemo","createArrayBinding","getSnapshot","useCallback","subscribeArray","cb","data","useSyncExternalStore","fields","useEffect","cleanupRegisteredPrefix","useCallback","useRef","useSyncExternalStore","useBitScope","scopeName","store","useBitStore","lastStatus","useRef","getStatusSnapshot","useCallback","nextStatus","isScopeStatusEqual","subscribe","cb","status","useSyncExternalStore","validate","valid","errors","getErrors","useCallback","useRef","useState","useSyncExternalStore","useBitSteps","scopeNames","store","useBitStore","stepIndex","setStepIndex","useState","scope","lastStatus","useRef","getStatusSnapshot","useCallback","nextStatus","isScopeStatusEqual","status","useSyncExternalStore","cb","validate","valid","errors","getErrors","next","scopeFields","s","pathsWithErrors","prev","goTo","targetStep","isFirst","isLast","useCallback","useSyncExternalStore","useRef","useBitWatch","path","store","useBitStore","lastValue","useRef","getSnapshot","useCallback","value","getDeepValue","valueEqual","subscribe","cb","useSyncExternalStore","useCallback","useMemo","useSyncExternalStore","useBitPersist","store","useBitStore","persistMeta","useSyncExternalStore","cb","subscribePersistMetaSnapshot","readPersistMetaSnapshot","restore","useCallback","save","clear","meta","useMemo","useCallback","useEffect","useRef","useSyncExternalStore","useBitFieldBase","path","store","useBitStore","lastSnapshot","useRef","useEffect","cleanupRegisteredField","getSnapshot","useCallback","nextState","snapshot","createFieldStateSnapshot","subscribe","cb","fieldState","useSyncExternalStore","setValue","val","setBlur"]}
|
|
@@ -0,0 +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 _chunk6LNXTSZ6cjs = require('./chunk-6LNXTSZ6.cjs');var _chunkPFPGASVZcjs = require('./chunk-PFPGASVZ.cjs');function c(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 x(e,t){return t(c(e)),f(e,()=>{t(c(e))})}function P(e){return e.read.getPersistMetadata()}function T(e,t){return e.observe.subscribePersistMeta(()=>t())}function h(e,t){return t(P(e)),e.observe.subscribePersistMeta(i=>{t(i)})}function M(e,t){let i=[],n=r=>e.feature.createArrayItemId(t,r),s=r=>Array.isArray(r)?r:[],d=r=>{if(r.length!==i.length)if(r.length>i.length){let a=r.length-i.length;i=[...i,...Array.from({length:a},(o,l)=>n(i.length+l))]}else i=i.slice(0,r.length);return r};return{readItems(){let r=_chunk6LNXTSZ6cjs.f.call(void 0, e.read.getState().values,t);return d(s(r))},getFields(r){return r.map((a,o)=>({key:i[o]||`temp-${o}`,value:a,index:o}))},append(r){i=[...i,n(i.length)],e.feature.pushItem(t,r)},prepend(r){i=[n(0),...i],e.feature.prependItem(t,r)},insert(r,a){let o=[...i];o.splice(r,0,n(r)),i=o,e.feature.insertItem(t,r,a)},remove(r){i=i.filter((a,o)=>o!==r),e.feature.removeItem(t,r)},move(r,a){let o=[...i],[l]=o.splice(r,1);o.splice(a,0,l),i=o,e.feature.moveItem(t,r,a)},swap(r,a){let o=[...i];[o[r],o[a]]=[o[a],o[r]],i=o,e.feature.swapItems(t,r,a)},replace(r){i=r.map((a,o)=>n(o)),e.feature.replaceItems(t,r)},clear(){i=[],e.feature.clearItems(t)}}}function v(e,t,i){return{setValue:r=>{let a=i();e.setField(t,_chunkPFPGASVZcjs.c.call(void 0, r,a))},setBlur:()=>e.blurField(t),displayValue:r=>_chunkPFPGASVZcjs.b.call(void 0, r,i())}}function w(e,t){return{fieldController:v({setField(n,s){e.write.setField(n,s)},blurField(n){e.write.blurField(n)}},t,()=>e.feature.resolveMask(t))}}async function y(e,t,i,n){try{let s=await e(t,i);n.onSuccess(s)}catch(s){if(_chunk6LNXTSZ6cjs.l.call(void 0, s)){n.onServerErrors(_chunk6LNXTSZ6cjs.m.call(void 0, s));return}n.onUnhandledError(s instanceof Error?s:new Error(String(s)))}}function S(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 g(e,t,i){return{submit:r=>async a=>{S(a,i),await e.submit(r)},onSubmit:r=>async a=>{S(a,i),t.setSubmissionError(null),await e.submit(async(o,l)=>{await y(r,o,l,{onSuccess:m=>{t.setSubmissionResult(m),t.setSubmissionError(null)},onServerErrors:m=>{e.setServerErrors(m)},onUnhandledError:m=>{t.setSubmissionError(m)}})})},reset:()=>{e.reset(),t.clearSubmissionState()},getValues:()=>e.getState().values,getErrors:()=>e.getState().errors,getTouched:()=>e.getState().touched,getDirtyValues:()=>e.getDirtyValues()}}function I(e,t,i){let n={getState:e.read.getState,getDirtyValues:e.read.getDirtyValues,submit:e.write.submit,reset:e.write.reset,setServerErrors:e.write.setServerErrors};return{controller:g(n,t,i),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 E(e,t){_optionalChain([e, 'access', _9 => _9.feature, 'optionalAccess', _10 => _10.unregisterPrefix, 'optionalCall', _11 => _11(t)])}exports.a = c; exports.b = f; exports.c = x; exports.d = P; exports.e = T; exports.f = h; exports.g = M; exports.h = w; exports.i = I; exports.j = A; exports.k = E;
|
|
2
|
+
//# sourceMappingURL=chunk-KDHPLXZF.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-KDHPLXZF.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","ids","createId","index","normalizeItems","value","syncIds","items","diff","_","offset","getDeepValue","item"],"mappings":"AAAA,qoBAAsD,wDAAgD,SCGtFA,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,CA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CAAO,CACf,OAAOA,CAAAA,CAAM,GAAA,CAAI,CAACK,CAAAA,CAAMT,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-KDHPLXZF.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 { getDeepValue } from \"../utils\";\n\nexport interface BitArrayBindingField<TItem> {\n key: string;\n value: TItem;\n index: number;\n}\n\nexport interface BitArrayBinding<\n TForm extends object,\n P extends BitArrayPath<TForm>,\n> {\n readItems(): BitArrayItem<BitPathValue<TForm, P>>[];\n getFields(\n items: BitArrayItem<BitPathValue<TForm, P>>[],\n ): BitArrayBindingField<BitArrayItem<BitPathValue<TForm, P>>>[];\n append(value: BitArrayItem<BitPathValue<TForm, P>>): void;\n prepend(value: BitArrayItem<BitPathValue<TForm, P>>): void;\n insert(index: number, value: BitArrayItem<BitPathValue<TForm, P>>): void;\n remove(index: number): void;\n move(from: number, to: number): void;\n swap(indexA: number, indexB: number): void;\n replace(items: BitArrayItem<BitPathValue<TForm, P>>[]): void;\n clear(): void;\n}\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 ids: string[] = [];\n\n const createId = (index?: number) =>\n store.feature.createArrayItemId(path as string, index);\n\n const normalizeItems = (value: unknown): Item[] =>\n Array.isArray(value) ? (value as Item[]) : [];\n\n const syncIds = (items: Item[]): Item[] => {\n if (items.length !== ids.length) {\n if (items.length > ids.length) {\n const diff = items.length - ids.length;\n ids = [\n ...ids,\n ...Array.from({ length: diff }, (_, offset) =>\n createId(ids.length + offset),\n ),\n ];\n } else {\n ids = ids.slice(0, items.length);\n }\n }\n\n return items;\n };\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 syncIds(normalizeItems(value));\n },\n\n getFields(items) {\n return items.map((item, index) => ({\n key: ids[index] || `temp-${index}`,\n value: item,\n index,\n }));\n },\n\n append(value) {\n ids = [...ids, createId(ids.length)];\n store.feature.pushItem(path, value);\n },\n\n prepend(value) {\n ids = [createId(0), ...ids];\n store.feature.prependItem(path, value);\n },\n\n insert(index, value) {\n const nextIds = [...ids];\n nextIds.splice(index, 0, createId(index));\n ids = nextIds;\n store.feature.insertItem(path, index, value);\n },\n\n remove(index) {\n ids = ids.filter((_, currentIndex) => currentIndex !== index);\n store.feature.removeItem(path, index);\n },\n\n move(from, to) {\n const nextIds = [...ids];\n const [item] = nextIds.splice(from, 1);\n nextIds.splice(to, 0, item);\n ids = nextIds;\n store.feature.moveItem(path, from, to);\n },\n\n swap(indexA, indexB) {\n const nextIds = [...ids];\n [nextIds[indexA], nextIds[indexB]] = [nextIds[indexB], nextIds[indexA]];\n ids = nextIds;\n store.feature.swapItems(path, indexA, indexB);\n },\n\n replace(items) {\n ids = items.map((_, index) => createId(index));\n store.feature.replaceItems(path, items);\n },\n\n clear() {\n ids = [];\n store.feature.clearItems(path);\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as c,c as v}from"./chunk-K5X37E3U.js";import{a as g}from"./chunk-UARLAXZX.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-N4HCGMMM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/devtools/store-snapshot.ts","../src/devtools/store-port.ts","../src/devtools/bridge.ts"],"sourcesContent":["import type { BitBusStorePort, BitState } from \"../core\";\nimport type { DevToolsStoreSnapshot, DevToolsStoreSnapshots } from \"./protocol\";\n\nfunction normalizeStoreState<T extends object>(\n state: Readonly<BitState<T>>,\n): Omit<DevToolsStoreSnapshot, \"_meta\"> {\n return {\n values: state.values,\n errors: state.errors as Record<string, unknown>,\n touched: state.touched as Record<string, unknown>,\n isValid: state.isValid,\n isDirty: state.isDirty,\n isSubmitting: state.isSubmitting,\n isValidating: state.isValidating as Record<string, unknown>,\n persist: state.persist,\n };\n}\n\nexport function createDevToolsStoreSnapshot<T extends object>(store: {\n getState: () => Readonly<BitState<T>>;\n getHistoryMetadata: () => {\n canUndo: boolean;\n canRedo: boolean;\n historySize: number;\n historyIndex: number;\n };\n}): DevToolsStoreSnapshot {\n const historyMeta = store.getHistoryMetadata();\n\n return {\n ...normalizeStoreState(store.getState()),\n _meta: {\n canUndo: historyMeta.canUndo,\n canRedo: historyMeta.canRedo,\n totalSteps: historyMeta.historySize,\n currentIndex: historyMeta.historyIndex,\n },\n };\n}\n\nexport function createDevToolsSnapshotMap(\n stores: Record<string, BitBusStorePort<object>>,\n): DevToolsStoreSnapshots {\n const snapshots: DevToolsStoreSnapshots = {};\n\n for (const [storeId, instance] of Object.entries(stores)) {\n snapshots[storeId] = createDevToolsStoreSnapshot(instance);\n }\n\n return snapshots;\n}\n","import type { BitBusStorePort } from \"../core\";\n\nexport type BitDevToolsReadableStore<T extends object = object> =\n BitBusStorePort<T>;\n\nexport type BitDevToolsActionableStore<T extends object = object> =\n BitBusStorePort<T>;\n\nexport function isDevToolsReadableStore(\n value: unknown,\n): value is BitDevToolsReadableStore<object> {\n if (!value || typeof value !== \"object\") {\n return false;\n }\n\n const candidate = value as unknown as Record<string, unknown>;\n\n return (\n typeof candidate.getState === \"function\" &&\n typeof candidate.getHistoryMetadata === \"function\"\n );\n}\n\nexport function isDevToolsActionableStore(\n value: unknown,\n): value is BitDevToolsActionableStore<object> {\n if (!isDevToolsReadableStore(value)) {\n return false;\n }\n\n const candidate = value as unknown as Record<string, unknown>;\n\n return (\n typeof candidate.undo === \"function\" &&\n typeof candidate.redo === \"function\" &&\n typeof candidate.reset === \"function\"\n );\n}\n\nexport function getDevToolsActionableStore(\n stores: Record<string, unknown>,\n storeId: string,\n): BitDevToolsActionableStore<object> | null {\n const candidate = stores[storeId];\n return isDevToolsActionableStore(candidate) ? candidate : null;\n}\n","import { bitBus } from \"../core\";\nimport type { BitBus } from \"../core\";\nimport type { BitBusStorePort } from \"../core\";\nimport { DEVTOOLS_PROTOCOL_VERSION, isDevToolsActionMessage } from \"./protocol\";\nimport { createDevToolsSnapshotMap } from \"./store-snapshot\";\nimport { getDevToolsActionableStore } from \"./store-port\";\n\nlet activeBridgeCleanup: (() => void) | null = null;\nconst STATE_BATCH_INTERVAL_MS = 50;\n\nexport function setupRemoteBridge(url: string, bus: BitBus = bitBus) {\n if (activeBridgeCleanup) {\n console.warn(\n \"[bit-form] Reiniciando ponte do DevTools (Fast Refresh detectado).\",\n );\n activeBridgeCleanup();\n }\n\n let socket: WebSocket | null = null;\n let unsubscribeBus: (() => void) | null = null;\n let heartbeatInterval: ReturnType<typeof setInterval>;\n let batchFlushTimeout: ReturnType<typeof setTimeout> | null = null;\n const pendingStoreIds = new Set<string>();\n let isIntentionalDisconnect = false;\n\n const sendWhenOpen = (message: Record<string, unknown>) => {\n if (socket?.readyState !== WebSocket.OPEN) {\n return;\n }\n\n socket.send(JSON.stringify(message));\n };\n\n const flushPendingStoreUpdates = () => {\n if (pendingStoreIds.size === 0) {\n return;\n }\n\n const payload = createDevToolsSnapshotMap(\n Array.from(pendingStoreIds).reduce<\n Record<string, BitBusStorePort<object>>\n >((acc, storeId) => {\n const storeInstance = bus.stores[storeId];\n if (storeInstance) {\n acc[storeId] = storeInstance;\n }\n return acc;\n }, {}),\n );\n\n pendingStoreIds.clear();\n batchFlushTimeout = null;\n\n if (Object.keys(payload).length > 0) {\n sendWhenOpen({\n type: \"STATE_UPDATE\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n payload,\n });\n }\n };\n\n const scheduleStoreFlush = () => {\n if (batchFlushTimeout) {\n return;\n }\n\n batchFlushTimeout = setTimeout(() => {\n flushPendingStoreUpdates();\n }, STATE_BATCH_INTERVAL_MS);\n };\n\n const connect = () => {\n isIntentionalDisconnect = false;\n socket = new WebSocket(url);\n\n socket.onopen = () => {\n console.log(\"[bit-form] 🔌 Conectado ao CLI DevTools via WebSocket.\");\n\n sendWhenOpen({\n type: \"HELLO\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n payload: { role: \"server\", protocolVersion: DEVTOOLS_PROTOCOL_VERSION },\n });\n\n const initialState = createDevToolsSnapshotMap(bus.stores);\n if (Object.keys(initialState).length > 0) {\n sendWhenOpen({\n type: \"STATE_UPDATE\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n payload: initialState,\n });\n }\n\n unsubscribeBus = bus.subscribe((storeId, _newState) => {\n pendingStoreIds.add(storeId);\n scheduleStoreFlush();\n });\n\n heartbeatInterval = setInterval(() => {\n sendWhenOpen({\n type: \"PING\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n });\n }, 30000);\n };\n\n socket.onmessage = (event) => {\n try {\n const message = JSON.parse(event.data) as unknown;\n\n if (isDevToolsActionMessage(message)) {\n const { storeId, action } = message.payload;\n const store = getDevToolsActionableStore(bus.stores, storeId);\n\n if (!store) {\n return;\n }\n\n switch (action) {\n case \"undo\":\n store.undo();\n break;\n case \"redo\":\n store.redo();\n break;\n case \"reset\":\n store.reset();\n break;\n }\n }\n } catch (e) {\n console.warn(\"[bit-form] Erro ao processar comando do CLI:\", e);\n }\n };\n\n socket.onclose = () => {\n if (unsubscribeBus) unsubscribeBus();\n clearInterval(heartbeatInterval);\n if (batchFlushTimeout) {\n clearTimeout(batchFlushTimeout);\n batchFlushTimeout = null;\n }\n pendingStoreIds.clear();\n\n if (!isIntentionalDisconnect) {\n console.log(\"[bit-form] Conexão perdida. Reconectando em 3s...\");\n setTimeout(connect, 3000);\n } else {\n console.log(\"[bit-form] Ponte antiga encerrada com sucesso.\");\n }\n };\n };\n\n connect();\n\n const cleanup = () => {\n isIntentionalDisconnect = true;\n\n if (unsubscribeBus) unsubscribeBus();\n clearInterval(heartbeatInterval);\n if (batchFlushTimeout) {\n clearTimeout(batchFlushTimeout);\n batchFlushTimeout = null;\n }\n pendingStoreIds.clear();\n if (\n socket &&\n (socket.readyState === WebSocket.OPEN ||\n socket.readyState === WebSocket.CONNECTING)\n ) {\n socket.close();\n }\n activeBridgeCleanup = null;\n };\n\n activeBridgeCleanup = cleanup;\n\n return cleanup;\n}\n"],"mappings":"uFAGA,SAASA,EACPC,EACsC,CACtC,MAAO,CACL,OAAQA,EAAM,OACd,OAAQA,EAAM,OACd,QAASA,EAAM,QACf,QAASA,EAAM,QACf,QAASA,EAAM,QACf,aAAcA,EAAM,aACpB,aAAcA,EAAM,aACpB,QAASA,EAAM,OACjB,CACF,CAEO,SAASC,EAA8CC,EAQpC,CACxB,IAAMC,EAAcD,EAAM,mBAAmB,EAE7C,MAAO,CACL,GAAGH,EAAoBG,EAAM,SAAS,CAAC,EACvC,MAAO,CACL,QAASC,EAAY,QACrB,QAASA,EAAY,QACrB,WAAYA,EAAY,YACxB,aAAcA,EAAY,YAC5B,CACF,CACF,CAEO,SAASC,EACdC,EACwB,CACxB,IAAMC,EAAoC,CAAC,EAE3C,OAAW,CAACC,EAASC,CAAQ,IAAK,OAAO,QAAQH,CAAM,EACrDC,EAAUC,CAAO,EAAIN,EAA4BO,CAAQ,EAG3D,OAAOF,CACT,CC1CO,SAASG,EACdC,EAC2C,CAC3C,GAAI,CAACA,GAAS,OAAOA,GAAU,SAC7B,MAAO,GAGT,IAAMC,EAAYD,EAElB,OACE,OAAOC,EAAU,UAAa,YAC9B,OAAOA,EAAU,oBAAuB,UAE5C,CAEO,SAASC,EACdF,EAC6C,CAC7C,GAAI,CAACD,EAAwBC,CAAK,EAChC,MAAO,GAGT,IAAMC,EAAYD,EAElB,OACE,OAAOC,EAAU,MAAS,YAC1B,OAAOA,EAAU,MAAS,YAC1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,EAAsB8B,EAEfA,CACT","names":["normalizeStoreState","state","createDevToolsStoreSnapshot","store","historyMeta","createDevToolsSnapshotMap","stores","snapshots","storeId","instance","isDevToolsReadableStore","value","candidate","isDevToolsActionableStore","getDevToolsActionableStore","stores","storeId","activeBridgeCleanup","STATE_BATCH_INTERVAL_MS","setupRemoteBridge","url","bus","bitBus","socket","unsubscribeBus","heartbeatInterval","batchFlushTimeout","pendingStoreIds","isIntentionalDisconnect","sendWhenOpen","message","flushPendingStoreUpdates","payload","createDevToolsSnapshotMap","acc","storeId","storeInstance","scheduleStoreFlush","connect","initialState","_newState","event","isDevToolsActionMessage","action","store","getDevToolsActionableStore","e","cleanup"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk6LNXTSZ6cjs = require('./chunk-6LNXTSZ6.cjs');function o(i,e){return e&&e.value===i.value&&e.error===i.error&&e.touched===i.touched&&e.isHidden===i.isHidden&&e.isRequired===i.isRequired&&e.isDirty===i.isDirty&&e.isValidating===i.isValidating?e:{value:i.value,error:i.error,touched:i.touched,isHidden:i.isHidden,isRequired:i.isRequired,isDirty:i.isDirty,isValidating:i.isValidating}}function d(i,e){return i===e?!0:!i||!e?!1:_chunk6LNXTSZ6cjs.d.call(void 0, i.value,e.value)&&i.error===e.error&&i.touched===e.touched&&i.isHidden===e.isHidden&&i.isRequired===e.isRequired&&i.isDirty===e.isDirty&&i.isValidating===e.isValidating}var n=d;exports.a = o; exports.b = d; exports.c = n;
|
|
2
|
+
//# sourceMappingURL=chunk-OLQVH24Z.cjs.map
|