@reformer/builder 3.0.0-beta.2 → 3.0.0-beta.4
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 +42 -0
- package/dist/assets/{App-C2kGmk3T.js → App-BzMuBv1U.js} +254 -265
- package/dist/assets/{BootError-Dp_qeCXo.js → BootError-CH4BoW__.js} +1 -1
- package/dist/assets/ChatPanel-9qHpjmLO.js +82 -0
- package/dist/assets/{CodeEditor-BMT0-Si7.js → CodeEditor-CuHAtGtB.js} +1 -1
- package/dist/assets/{MarkdownPreview-CwYEjUKp.js → MarkdownPreview-DwyxNTbn.js} +3 -3
- package/dist/assets/{RawJsonEditor-B53MaFaH.js → RawJsonEditor-jYY7XCW2.js} +1 -1
- package/dist/assets/{boot-DX03holy.js → boot-DTWnczkO.js} +1 -1
- package/dist/assets/byok-BM21dMSQ.js +120 -0
- package/dist/assets/{editor.api-B3o_tHWm.js → editor.api-B4g2PJYj.js} +1 -1
- package/dist/assets/{freemarker2-rMo56xTZ.js → freemarker2-BlPZHoyx.js} +1 -1
- package/dist/assets/{handlebars-DfNb208j.js → handlebars-Dd8yor3z.js} +1 -1
- package/dist/assets/{html-9LDotOCL.js → html-C3wl1HPz.js} +1 -1
- package/dist/assets/index-BC3M-FCZ.js +3 -0
- package/dist/assets/index-BmJVVkA_.js +1 -0
- package/dist/assets/index-BxUg93Np.css +1 -0
- package/dist/assets/{index-CF8Ccj_6.js → index-CU07HM8S.js} +1 -1
- package/dist/assets/{index-BHFOCWR2.js → index-CY45QPm-.js} +2 -2
- package/dist/assets/{index-BoP3c_G3.js → index-DCa3wFwm.js} +3 -3
- package/dist/assets/{index-BpPqEX1B.js → index-OZOUDUGD.js} +2 -2
- package/dist/assets/{javascript-N_FRLUgy.js → javascript-BF-EEvQI.js} +1 -1
- package/dist/assets/{jsonMode-BIEjtnm2.js → jsonMode-DGlgsS1d.js} +1 -1
- package/dist/assets/{liquid-B38K7XEX.js → liquid-C0Gfg9TY.js} +1 -1
- package/dist/assets/load-FrEYc91y.js +11 -0
- package/dist/assets/{mdx-r__dUMQk.js → mdx-bIG0iFaA.js} +1 -1
- package/dist/assets/{monaco-languages-DgGCkmJH.js → monaco-languages-D5Bh48hh.js} +2 -2
- package/dist/assets/{monaco-setup-iY5dE17u.js → monaco-setup-CAOrXrMd.js} +3 -3
- package/dist/assets/{python-DCCl1tnR.js → python-CciOb-4N.js} +1 -1
- package/dist/assets/{razor-ZE4EjIKg.js → razor-cbEBt-Vr.js} +1 -1
- package/dist/assets/{reformer-ui-kit-11-n64q8JVB.js → reformer-ui-kit-11-BhXMU01R.js} +1 -1
- package/dist/assets/{reformer-ui-kit-Ut2rhAV-.js → reformer-ui-kit-D8fAdwPH.js} +1 -1
- package/dist/assets/{typescript-6dpKS065.js → typescript-4hiO_obL.js} +1 -1
- package/dist/assets/{typescript-BauA6Emw.js → typescript-CNVC9ZHk.js} +1 -1
- package/dist/assets/useFormField-BLbvmpme-BASGgtAT.js +1 -0
- package/dist/assets/{xml-DBtzGd88.js → xml-RU_PX54U.js} +1 -1
- package/dist/assets/{yaml-DtEf6xfz.js → yaml-DsXE0ah6.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +7 -2
- package/dist/assets/index-BMro_ca-.js +0 -1
- package/dist/assets/index-VCC7PvcK.css +0 -1
- package/dist/assets/index-gMkDz7rv.js +0 -3
- package/dist/assets/load-Ca2Wh9wu.js +0 -11
- package/dist/assets/useFormField-BLbvmpme-Dyj_El2W.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as he,b as de,r as f,W as fe,j as S}from"./index-BHFOCWR2.js";var ve=de();const Er=he(ve);function pe(...e){return t=>{for(const r of e)typeof r=="function"?r(t):r!=null&&(r.current=t)}}function me(e){return Object.getOwnPropertyDescriptor(e.props,"ref")?.get?.isReactWarning?e.ref:Object.getOwnPropertyDescriptor(e,"ref")?.get?.isReactWarning?e.props.ref:e.props.ref??e.ref}function ye(e,t){const r={...e};for(const i of Object.keys(t)){const s=e[i],n=t[i];i.startsWith("on")&&typeof s=="function"&&typeof n=="function"?r[i]=(...o)=>{n(...o),s(...o)}:i==="className"&&typeof s=="string"&&typeof n=="string"?r[i]=[n,s].filter(Boolean).join(" "):i==="style"&&typeof s=="object"&&typeof n=="object"?r[i]={...n,...s}:i==="disabled"?r[i]=!!s||!!n:n!==void 0&&(r[i]=n)}return r}const K=f.forwardRef(({children:e,...t},r)=>{const i=f.Children.only(e);if(!f.isValidElement(i))return null;const s=i.props,n=ye(t,s),o=me(i),a=pe(r,o);return f.cloneElement(i,{...n,ref:a})});K.displayName="Slot";var ge=Symbol.for("preact-signals");function rt(){if(x>1)x--;else{var e,t=!1;for((function(){var s=Q;for(Q=void 0;s!==void 0;)s.S.v===s.v&&(s.S.i=s.i),s=s.o})();U!==void 0;){var r=U;for(U=void 0,H++;r!==void 0;){var i=r.u;if(r.u=void 0,r.f&=-3,!(8&r.f)&&Vt(r))try{r.c()}catch(s){t||(e=s,t=!0)}r=i}}if(H=0,x--,t)throw e}}function q(e){if(x>0)return e();lt=++be,x++;try{return e()}finally{rt()}}var m=void 0;function it(e){var t=m;m=void 0;try{return e()}finally{m=t}}var $,U=void 0,x=0,H=0,be=0,lt=0,Q=void 0,Y=0;function Ct(e){if(m!==void 0){var t=e.n;if(t===void 0||t.t!==m)return t={i:0,S:e,p:m.s,n:void 0,t:m,e:void 0,x:void 0,r:t},m.s!==void 0&&(m.s.n=t),m.s=t,e.n=t,32&m.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=m.s,t.n=void 0,m.s.n=t,m.s=t),t}}function E(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}E.prototype.brand=ge;E.prototype.h=function(){return!0};E.prototype.S=function(e){var t=this,r=this.t;r!==e&&e.e===void 0&&(e.x=r,this.t=e,r!==void 0?r.e=e:it(function(){var i;(i=t.W)==null||i.call(t)}))};E.prototype.U=function(e){var t=this;if(this.t!==void 0){var r=e.e,i=e.x;r!==void 0&&(r.x=i,e.e=void 0),i!==void 0&&(i.e=r,e.x=void 0),e===this.t&&(this.t=i,i===void 0&&it(function(){var s;(s=t.Z)==null||s.call(t)}))}};E.prototype.subscribe=function(e){var t=this;return b(function(){var r=t.value,i=m;m=void 0;try{e(r)}finally{m=i}},{name:"sub"})};E.prototype.valueOf=function(){return this.value};E.prototype.toString=function(){return this.value+""};E.prototype.toJSON=function(){return this.value};E.prototype.peek=function(){var e=m;m=void 0;try{return this.value}finally{m=e}};Object.defineProperty(E.prototype,"value",{get:function(){var e=Ct(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(H>100)throw new Error("Cycle detected");(function(r){x!==0&&H===0&&r.l!==lt&&(r.l=lt,Q={S:r,v:r.v,i:r.i,o:Q})})(this),this.v=e,this.i++,Y++,x++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{rt()}}}});function w(e,t){return new E(e,t)}function Vt(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Pt(e){for(var t=e.s;t!==void 0;t=t.n){var r=t.S.n;if(r!==void 0&&(t.r=r),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Ot(e){for(var t=e.s,r=void 0;t!==void 0;){var i=t.p;t.i===-1?(t.S.U(t),i!==void 0&&(i.n=t.n),t.n!==void 0&&(t.n.p=i)):r=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=i}e.s=r}function V(e,t){E.call(this,void 0),this.x=e,this.s=void 0,this.g=Y-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}V.prototype=new E;V.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Y))return!0;if(this.g=Y,this.f|=1,this.i>0&&!Vt(this))return this.f&=-2,!0;var e=m;try{Pt(this),m=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(r){this.v=r,this.f|=16,this.i++}return m=e,Ot(this),this.f&=-2,!0};V.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}E.prototype.S.call(this,e)};V.prototype.U=function(e){if(this.t!==void 0&&(E.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};V.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(V.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Ct(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function v(e,t){return new V(e,t)}function jt(e){var t=e.m;if(e.m=void 0,typeof t=="function"){x++;var r=m;m=void 0;try{t()}catch(i){throw e.f&=-2,e.f|=8,ft(e),i}finally{m=r,rt()}}}function ft(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,jt(e)}function we(e){if(m!==this)throw new Error("Out-of-order effect");Ot(this),m=e,this.f&=-2,8&this.f&&ft(this),rt()}function O(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,$&&$.push(this)}O.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};O.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,jt(this),Pt(this),x++;var e=m;return m=this,we.bind(this,e)};O.prototype.N=function(){2&this.f||(this.f|=2,this.u=U,U=this)};O.prototype.d=function(){this.f|=8,1&this.f||ft(this)};O.prototype.dispose=function(){this.d()};function b(e,t){var r=new O(e,t);try{r.c()}catch(s){throw r.d(),s}var i=r.d.bind(r);return i[Symbol.dispose]=i,i}function vt(e){return function(){var t=arguments,r=this;return q(function(){return it(function(){return e.apply(r,[].slice.call(t))})})}}function Ee(){var e=$;return $=[],function(){var t=$;return $&&e&&(e=e.concat($)),$=e,t}}var Dt=function(e){for(var t in e){var r=e[t];typeof r=="function"?e[t]=vt(r):typeof r=="object"&&r!==null&&!("brand"in r)&&Dt(r)}};function ke(e){return function(){var t,r,i=Ee();try{r=e.apply(void 0,[].slice.call(arguments))}catch(s){throw $=void 0,s}finally{t=i()}return Dt(r),r[Symbol.dispose]=vt(function(){if(t)for(var s=0;s<t.length;s++)t[s].dispose();t=void 0}),r}}const kr=Object.freeze(Object.defineProperty({__proto__:null,Computed:V,Effect:O,Signal:E,action:vt,batch:q,computed:v,createModel:ke,effect:b,signal:w,untracked:it},Symbol.toStringTag,{value:"Module"})),D=new WeakMap;function _e(e){D.set(e,(D.get(e)??0)+1)}function Ae(e){const t=D.get(e);t!==void 0&&(t<=1?D.delete(e):D.set(e,t-1))}function X(e){return D.has(e)}const tt=e=>!(e===null||typeof e!="object"||Array.isArray(e)||e instanceof Date||typeof Blob<"u"&&e instanceof Blob||typeof File<"u"&&e instanceof File),F=(e,t)=>e===""?String(t):`${e}.${t}`,ut=e=>/^\d+$/.test(e),M=e=>{if(Array.isArray(e))return e.map(M);if(tt(e)){const t={};for(const r of Object.keys(e))t[r]=M(e[r]);return t}return e},et=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((r,i)=>et(r,t[i]));if(tt(e)&&tt(t)){const r=Object.keys(e),i=Object.keys(t);return r.length!==i.length?!1:r.every(s=>et(e[s],t[s]))}return!1};let Se=class{constructor(t,r){this.path=r;const i=w(t);i.__path=r,this.signal=i,this.initial=M(t)}kind="leaf";signal;initial;rebase(t){this.path=t,this.signal.__path=t}read(){return this.signal.value}peek(){return this.signal.peek()}set(t){this.signal.value=t}resetToInitial(){this.signal.value=M(this.initial)}captureInitial(){this.initial=M(this.signal.peek())}dirty(){return!et(this.signal.peek(),this.initial)}},It=class{constructor(t,r){this.path=r;for(const i of Object.keys(t))this.children.set(i,W(t[i],F(r,i)))}kind="group";children=new Map;rebase(t){this.path=t;for(const[r,i]of this.children)i.rebase(F(t,r))}read(){const t={};for(const[r,i]of this.children)t[r]=i.read();return t}peek(){const t={};for(const[r,i]of this.children)t[r]=i.peek();return t}set(t){if(t==null||typeof t!="object")return;const r=t;q(()=>{for(const[i,s]of this.children)i in r&&(s.kind==="leaf"&&X(s.signal)||s.set(r[i]))})}resetToInitial(){q(()=>{for(const t of this.children.values())t.resetToInitial()})}captureInitial(){for(const t of this.children.values())t.captureInitial()}dirty(){for(const t of this.children.values())if(t.dirty())return!0;return!1}},$e=class{constructor(t,r){this.path=r,this.items=w(t.map((i,s)=>W(i,F(r,s)))),this.initial=M(t)}kind="array";items;initial;rebase(t){this.path=t,this.items.peek().forEach((r,i)=>r.rebase(F(t,i)))}reindex(){this.items.peek().forEach((t,r)=>t.rebase(F(this.path,r)))}push(t){const r=this.items.peek();this.items.value=[...r,W(t,F(this.path,r.length))]}insertAt(t,r){const i=[...this.items.peek()];i.splice(t,0,W(r,F(this.path,t))),this.items.value=i,this.reindex()}removeAt(t){const r=[...this.items.peek()];r.splice(t,1),this.items.value=r,this.reindex()}move(t,r){const i=[...this.items.peek()],[s]=i.splice(t,1);s&&i.splice(r,0,s),this.items.value=i,this.reindex()}swap(t,r){const i=[...this.items.peek()];t<0||r<0||t>=i.length||r>=i.length||t===r||([i[t],i[r]]=[i[r],i[t]],this.items.value=i,this.reindex())}clear(){this.items.value=[]}read(){return this.items.value.map(t=>t.read())}peek(){return this.items.peek().map(t=>t.peek())}set(t){const r=Array.isArray(t)?t:[];this.items.value=r.map((i,s)=>W(i,F(this.path,s)))}resetToInitial(){this.set(M(this.initial))}captureInitial(){this.initial=M(this.peek())}dirty(){return!et(this.peek(),this.initial)}};function W(e,t){return Array.isArray(e)?new $e(e,t):tt(e)?new It(e,t):new Se(e,t)}function j(e){if(e)return e.kind==="group"?Wt(e):e.kind==="array"?xe(e):e.read()}function xe(e){const t={get length(){return e.items.value.length},push:r=>e.push(r),insertAt:(r,i)=>e.insertAt(r,i),removeAt:r=>e.removeAt(r),move:(r,i)=>e.move(r,i),swap:(r,i)=>e.swap(r,i),clear:()=>e.clear(),at:r=>j(e.items.value[r]),map:r=>e.items.value.map((i,s)=>r(j(i),s)),forEach:r=>e.items.value.forEach((i,s)=>r(j(i),s)),toArray:()=>e.peek(),[Symbol.iterator]:function*(){const r=e.items.value;for(let i=0;i<r.length;i++)yield j(r[i])}};return new Proxy(t,{get:(r,i,s)=>i==="__path"?e.path:typeof i=="string"&&ut(i)?j(e.items.value[Number(i)]):Reflect.get(r,i,s),has:(r,i)=>typeof i=="string"&&ut(i)?Number(i)<e.items.value.length:Reflect.has(r,i)})}const kt=new WeakMap;function Fe(e){const t=v(()=>e.read());return{get value(){return t.value},peek:()=>t.peek(),subscribe:r=>t.subscribe(r),valueOf:()=>t.value,toString:()=>String(t.value),toJSON:()=>t.value,brand:t.brand}}function Tt(e){if(e.kind==="leaf")return e.signal;const t=kt.get(e);if(t)return t;const r=Fe(e),i=e.kind==="group",s=a=>i?e.children.get(a):ut(a)?e.items.value[Number(a)]:void 0,n=i?{}:{get length(){return e.items.value.length}},o=new Proxy(n,{get:(a,l,d)=>{if(l==="__path")return e.path;if(l==="__kind")return e.kind;if(typeof l!="string")return Reflect.get(r,l,r);const c=s(l);return c?Tt(c):!i&&Reflect.has(a,l)?Reflect.get(a,l,d):Reflect.get(r,l,r)},has:(a,l)=>typeof l=="string"&&(s(l)!==void 0||!i&&Reflect.has(a,l)),ownKeys:()=>i?[...e.children.keys()]:Reflect.ownKeys(n),getOwnPropertyDescriptor:(a,l)=>typeof l=="string"&&s(l)?{enumerable:!0,configurable:!0}:i?void 0:Reflect.getOwnPropertyDescriptor(a,l)});return kt.set(e,o),o}function Ne(e){if(e==null||typeof e!="object")return!1;const t=e.__kind;return t==="group"||t==="array"}function Me(e,t){if(!t)return;let r=e;for(const i of t.split(".")){if(!r)return;if(r.kind==="group")r=r.children.get(i);else if(r.kind==="array")r=r.items.peek()[Number(i)];else return}return r&&r.kind==="leaf"?r.signal:void 0}const _t=new Set(["$","get","set","patch","isDirty","reset","captureInitial","signalAt"]),At=new WeakMap,Rt=new WeakMap;function Wt(e){const t=At.get(e);if(t)return t;const r={$:Tt(e),get:()=>e.peek(),set:s=>e.set(s),patch:s=>e.set(s),isDirty:()=>e.dirty(),reset:()=>e.resetToInitial(),captureInitial:()=>e.captureInitial(),signalAt:s=>Me(e,s)},i=new Proxy({},{get:(s,n)=>{if(n==="__path")return e.path;if(typeof n!="string")return;const o=e.children.get(n);if(o)return j(o);if(_t.has(n))return r[n]},set:(s,n,o)=>{if(typeof n!="string")return!1;const a=e.children.get(n);return a?(a.set(o),!0):!1},has:(s,n)=>typeof n=="string"&&(e.children.has(n)||_t.has(n)),ownKeys:()=>[...e.children.keys()],getOwnPropertyDescriptor:(s,n)=>typeof n=="string"&&e.children.has(n)?{enumerable:!0,configurable:!0}:void 0});return At.set(e,i),Rt.set(i,e),i}function ct(e,t){if(e.kind==="leaf"){t(e.signal);return}if(e.kind==="group"){for(const r of e.children.values())ct(r,t);return}for(const r of e.items.value)ct(r,t)}function Ce(e,t){const r=Rt.get(e);r&&ct(r,t)}function Ve(e){const t=new It(e,"");return Wt(t)}const Pe="runOutsideEffect";function Oe(e){return typeof e=="object"&&e!==null&&typeof e.then=="function"}function Ut(e,t){try{const r=e();Oe(r)&&r.then(void 0,i=>void 0)}catch{}}function je(e){return(...t)=>{C(()=>e(...t))}}function C(e){let t=!1;return queueMicrotask(()=>{t||Ut(e,Pe)}),()=>{t=!0}}function De(e,t){return()=>{t(()=>Ut(e,"safeDebouncedCallback"))}}function Ie(e,t,r,i){return b(()=>{const s=e.map(o=>o.value);if(i?.when&&!i.when(...s))return;const n=r(...s);t.peek()!==n&&(t.value=n)})}function Te(e,t,r){return b(()=>{const i=e.value;if(r?.when&&!r.when())return;const s=r?.transform?r.transform(i):i;t.peek()!==s&&(t.value=s)})}function Re(e,t,r){let i=!0;return b(()=>{const s=e.value;i&&(i=!1,!r?.immediate)||t(s)})}function We(e,t){let r=!1;return b(()=>{const i=e.value;r||C(()=>{const s=t(i);if(e.peek()!==s){r=!0;try{e.value=s}finally{r=!1}}})})}function Ue(e,t,r){const i=r?.resetValue??null;return b(()=>{const s=t();C(()=>{s&&e.peek()!==i&&(e.value=i)})})}function Be(e,t,r){const i=r?.transform;let s=!1;const n=b(()=>{const a=e.value;s||C(()=>{s=!0;try{const l=i?i(a):a;t.peek()!==l&&(t.value=l)}finally{s=!1}})}),o=b(()=>{const a=t.value;s||C(()=>{s=!0;try{e.peek()!==a&&(e.value=a)}finally{s=!1}})});return()=>{n(),o()}}function Ge(e,t){let r=!0;return b(()=>{if(e.forEach(i=>i.value),r){r=!1;return}C(()=>t())})}let st=class{subscriptions=new Map;add(t,r){return this.subscriptions.has(t)&&this.subscriptions.get(t)?.(),this.subscriptions.set(t,r),()=>this.remove(t)}remove(t){const r=this.subscriptions.get(t);return r?(r(),this.subscriptions.delete(t),!0):!1}clear(){this.subscriptions.forEach(t=>{t()}),this.subscriptions.clear()}size(){return this.subscriptions.size}has(t){return this.subscriptions.has(t)}getKeys(){return Array.from(this.subscriptions.keys())}dispose(){this.clear()}};const Bt=new WeakMap;function Gt(e,t){Bt.set(e,t)}function I(e){return Bt.get(e)}function Lt(e,t,r){return b(()=>{const i=t(),s=I(e);s&&C(()=>{i?s.enable():(s.disable(),r?.resetOnDisable&&s.reset())})})}function Le(e,t,r){return Lt(e,()=>!t(),r)}let B=null;function R(e){if(!B)throw new Error(`[@reformer/core/validation] "${e}" вызван вне схемы валидации — операторы валидации можно вызывать только внутри прогона validateModel(...) (напрямую или через apply/each).`);return B}function pt(e,t){let r=e.errors.get(t);return r||e.errors.set(t,r=[]),r}const mt=e=>e.whenStack.every(t=>t());function qe(e,t){const r=R("validate"),i=pt(r,e);if(!mt(r))return;const s=e.peek();for(const n of t){const o=n(s,r.model,r.model);o&&i.push(o)}}function Ke(e,t){const r=R("validateAsync"),i=pt(r,e);if(!mt(r))return;const s=e.peek(),n=r.signal;for(const o of t)r.pending.push(o(s,{signal:n}).then(a=>{a&&!n.aborted&&i.push(a)},()=>{}))}function ze(e,t){const r=R("validateWhen");r.whenStack.push(e);try{t()}finally{r.whenStack.pop()}}function Je(e,t){const r=R("cross"),i=pt(r,e);if(!mt(r))return;const s=t(r.model.get());s&&i.push(s)}function Ze(e,t){R("each");const r=e.length;for(let i=0;i<r;i++)t(e.at(i))}function He(...e){const t=R("apply").model;for(const r of e)r({model:t})}function Qe(e){return e}const St=new WeakMap;function Ye(e,t){let r=St.get(e);r||St.set(e,r=new WeakMap);let i=r.get(t);return i||r.set(t,i={fields:new Set,ac:null}),i}const Xe=e=>{for(const t of e.values())for(const r of t)if(r.severity!=="warning")return!0;return!1};function tr(e){return e.aborted?Promise.resolve():new Promise(t=>{e.addEventListener("abort",()=>t(),{once:!0})})}async function qt(e,t,r){const i=Ye(e,t);i.ac?.abort();const s=new AbortController;i.ac=s;const n={model:e,errors:new Map,pending:[],whenStack:[],signal:s.signal},o=B;B=n;try{t({model:e})}finally{B=o}if(n.pending.length&&await Promise.race([Promise.all(n.pending),tr(s.signal)]),s.signal.aborted)return!1;const a=new Set(n.errors.keys());for(const l of i.fields)a.has(l)||I(l)?.setErrors([]);for(const l of a)I(l)?.setErrors(n.errors.get(l)??[]);if(r?.touch)for(const l of a)I(l)?.markAsTouched();return i.fields=a,!Xe(n.errors)}function Kt(e,t,r={}){const{strategy:i="submit",debounce:s=0,liveAfterSubmit:n="change"}=r,o=w(!1);let a=0,l=!1,d=!1,c,u;const h=async k=>{a++,o.value=!0;try{return await qt(e,t,{touch:k})}finally{--a===0&&(o.value=!1)}},p=()=>{h(!1)},g=()=>{if(!s){p();return}u&&clearTimeout(u),u=setTimeout(p,s)},y=(k,_)=>{let Et=!0;return b(()=>{if(Ce(e,k),Et){Et=!1;return}i==="afterFirstSubmit"&&!l||_()})},A={async validate(){return l=!0,h(!0)},start(){if(d||c)return()=>A.dispose();const k=i==="afterFirstSubmit"?n:i;return k==="change"?c=y(_=>void _.value,g):k==="blur"&&(c=y(_=>void I(_)?.touched.value,p)),()=>A.dispose()},dispose(){d=!0,u&&(clearTimeout(u),u=void 0),c?.(),c=void 0},get isValidating(){return o.value},get validating(){return o}};return A}const xr=Object.freeze(Object.defineProperty({__proto__:null,apply:He,createFormValidation:Kt,cross:Je,defineValidationSchema:Qe,each:Ze,validate:qe,validateAsync:Ke,validateModel:qt,validateWhen:ze},Symbol.toStringTag,{value:"Module"}));class z{_touched=w(!1);_dirty=w(!1);_status=w("valid");touched=v(()=>this._touched.value);dirty=v(()=>this._dirty.value);status=v(()=>this._status.value);disabled=v(()=>this._status.value==="disabled");getErrors(t){const r=this.errors.value;return t?r.filter(i=>{if(t.code!==void 0&&!(Array.isArray(t.code)?t.code:[t.code]).includes(i.code)||t.message!==void 0&&!i.message.toLowerCase().includes(t.message.toLowerCase()))return!1;if(t.params!==void 0){if(!i.params)return!1;for(const[s,n]of Object.entries(t.params))if(i.params[s]!==n)return!1}return!(t.predicate!==void 0&&!t.predicate(i))}):r}markAsTouched(){this._touched.value=!0,this.onMarkAsTouched()}markAsUntouched(){this._touched.value=!1,this.onMarkAsUntouched()}markAsDirty(){this._dirty.value=!0,this.onMarkAsDirty()}markAsPristine(){this._dirty.value=!1,this.onMarkAsPristine()}touchAll(){this.markAsTouched()}disable(){this._status.value="disabled",this.onDisable()}enable(){this._status.value="valid",this.onEnable()}onMarkAsTouched(){}onMarkAsUntouched(){}onMarkAsDirty(){}onMarkAsPristine(){}onDisable(){}onEnable(){}}const G={Watch:"watch",ComputeFrom:"computeFrom",LinkFields:"linkFields",WatchField:"watchField"};let er=0;function L(e){return`${e}-${++er}`}var N=(e=>(e.THROW="throw",e.LOG="log",e.CONVERT="convert",e))(N||{});let P=class{static handle(t,r,i="throw"){const s=this.extractMessage(t);switch(i){case"throw":throw t;case"log":return;case"convert":return{code:"validator_error",message:s,params:{field:r}}}}static extractMessage(t){return t instanceof Error?t.message:typeof t=="string"?t:typeof t=="object"&&t!==null&&"message"in t?String(t.message):String(t)}static createValidationError(t,r,i){return{code:t,message:r,params:i?{field:i}:void 0}}static isValidationError(t){return typeof t=="object"&&t!==null&&"code"in t&&"message"in t&&typeof t.code=="string"&&typeof t.message=="string"}};class rr{_status;status;valid;invalid;pending;disabled;constructor(t="valid"){this._status=w(t),this.status=v(()=>this._status.value),this.valid=v(()=>this._status.value==="valid"),this.invalid=v(()=>this._status.value==="invalid"),this.pending=v(()=>this._status.value==="pending"),this.disabled=v(()=>this._status.value==="disabled")}startValidation(){this._status.value!=="disabled"&&(this._status.value="pending")}completeValidation(t){this._status.value!=="disabled"&&(this._status.value=t?"invalid":"valid")}setErrors(t){this._status.value!=="disabled"&&(this._status.value=t?"invalid":"valid")}disable(){this._status.value="disabled"}enable(t=!1){this._status.value=t?"invalid":"valid"}}class zt extends z{_value;_errors;_componentProps;statusMachine;value;valid;invalid;pending;status;disabled;errors;componentProps;shouldShowError;validators;asyncValidators;updateOn;initialValue;currentAbortController;debounceMs;validateDebounceTimer;pendingValidation;disposers=new st;component;constructor(t){super(),this.validators=t.validators||[],this.asyncValidators=t.asyncValidators||[],this.updateOn=t.updateOn||"blur",this.debounceMs=t.debounce||0,this.component=t.component,this._value=t.valueSignal??w(t.value),this.initialValue=this._value.peek(),this._errors=w([]),this._componentProps=w(t.componentProps||{}),this.statusMachine=new rr(t.disabled?"disabled":"valid"),this.value=v(()=>this._value.value),this.valid=v(()=>this.statusMachine.valid.value),this.invalid=v(()=>this.statusMachine.invalid.value),this.pending=v(()=>this.statusMachine.pending.value),this.status=v(()=>this.statusMachine.status.value),this.disabled=v(()=>this.statusMachine.disabled.value),this.errors=v(()=>this._errors.value),this.componentProps=v(()=>this._componentProps.value),this.shouldShowError=v(()=>this.statusMachine.invalid.value&&(this._touched.value||this._dirty.value))}getValue(){return this._value.peek()}setValue(t,r){if(this._value.value=t,this._dirty.value=!0,r?.emitEvent===!1)return;const i=this.validators.length>0||this.asyncValidators.length>0,s=this._errors.value.length>0;if(this.updateOn==="change"){this.validate();return}s&&i&&this.validate()}patchValue(t){this.setValue(t)}reset(t){this._value.value=t!==void 0?t:this.initialValue,this._errors.value=[],this._touched.value=!1,this._dirty.value=!1,this.statusMachine.setErrors(!1)}resetToInitial(){this.reset(this.initialValue)}cancelPendingValidation(){this.pendingValidation&&(this.pendingValidation.abortController.abort(),this.pendingValidation.resolve(!1),this.pendingValidation=void 0),this.validateDebounceTimer&&(clearTimeout(this.validateDebounceTimer),this.validateDebounceTimer=void 0),this.currentAbortController&&(this.currentAbortController.abort(),this.currentAbortController=void 0)}async validate(t){const r=t?.debounce??this.debounceMs;if(this.cancelPendingValidation(),r<=0||this.asyncValidators.length===0)return this.validateImmediate();const i=new AbortController;return new Promise(s=>{this.pendingValidation={resolve:s,abortController:i},this.validateDebounceTimer=setTimeout(async()=>{if(this.validateDebounceTimer=void 0,i.signal.aborted){s(!1);return}this.pendingValidation=void 0;const n=await this.validateImmediate(i);s(n)},r),i.signal.addEventListener("abort",()=>{this.validateDebounceTimer&&(clearTimeout(this.validateDebounceTimer),this.validateDebounceTimer=void 0),s(!1)},{once:!0})})}async validateImmediate(t){const r=t??new AbortController;t||this.currentAbortController?.abort(),this.currentAbortController=r;const{signal:i}=r,s=[];for(const n of this.validators){const o=n(this._value.value);o&&s.push(o)}if(i.aborted)return!1;if(s.length>0){this._errors.value=s;const n=s.some(o=>o.severity!=="warning");if(this.statusMachine.setErrors(n),n)return!1}if(this.asyncValidators.length>0){if(i.aborted)return!1;this.statusMachine.startValidation();try{const n=await Promise.all(this.asyncValidators.map(async a=>{if(i.aborted)throw new DOMException("Validation aborted","AbortError");try{const l=await a(this._value.value,{signal:i});if(i.aborted)throw new DOMException("Validation aborted","AbortError");return l}catch(l){if(l instanceof DOMException&&l.name==="AbortError")throw l;return P.handle(l,"FieldNode AsyncValidator",N.CONVERT)}}));if(i.aborted)return!1;const o=n.filter(a=>a!==null);if(o.length>0){this._errors.value=o;const a=o.some(l=>l.severity!=="warning");if(this.statusMachine.completeValidation(a),a)return!1}}catch(n){if(n instanceof DOMException&&n.name==="AbortError")return!1;throw n}}return i.aborted?!1:((this.validators.length>0||this.asyncValidators.length>0)&&(this._errors.value=[],this.statusMachine.completeValidation(!1)),!this._errors.value.some(n=>n.severity!=="warning"))}setErrors(t){this._errors.value=t;const r=t.some(i=>i.severity!=="warning");this.statusMachine.setErrors(r)}clearErrors(){this._errors.value=[],this.statusMachine.setErrors(!1)}onMarkAsTouched(){this.updateOn==="blur"&&this.validate()}onDisable(){this.statusMachine.disable(),this._errors.value=[]}onEnable(){this.statusMachine.enable(this._errors.value.length>0),this.validate()}updateComponentProps(t){this._componentProps.value={...this._componentProps.value,...t}}setUpdateOn(t){this.updateOn=t}getUpdateOn(){return this.updateOn}watch(t){const r=new AbortController,i=b(()=>{const n=this.value.value;t(n,r.signal)}),s=L(G.Watch);return this.disposers.add(s,()=>{r.abort(),i()})}computeFrom(t,r){const i=b(()=>{const n=t.map(a=>a.value),o=r(...n);this.setValue(o,{emitEvent:!1})}),s=L(G.ComputeFrom);return this.disposers.add(s,i)}dispose(){try{this.disposers.dispose()}finally{this.cancelPendingValidation()}}}function yt(e){const{getChildren:t,ownErrors:r,disabled:i}=e,s=v(()=>r.value.length>0?!1:t().every(u=>u.disabled.value||u.valid.value)),n=v(()=>!s.value),o=v(()=>t().some(u=>u.pending.value)),a=v(()=>t().some(u=>u.touched.value)),l=v(()=>t().some(u=>u.dirty.value)),d=v(()=>{const u=[...r.value];for(const h of t())u.push(...h.errors.value);return u}),c=v(()=>i?.value?"disabled":o.value?"pending":n.value?"invalid":"valid");return{valid:s,invalid:n,pending:o,touched:a,dirty:l,errors:d,status:c}}function $t(e){return typeof e=="object"&&e!==null&&"getProxy"in e&&typeof e.getProxy=="function"}const xt="$";function ir(e,t){let r;const i=()=>{if(!r){const s={};t.forEach((n,o)=>{s[o]=n&&$t(n)?n.getProxy():n}),r=s}return r};return new Proxy(e,{get:(s,n)=>{if(n===xt)return i();if(n in s)return s[n];if(typeof n=="string"&&t.has(n)){const o=t.get(n);return o&&$t(o)?o.getProxy():o}},set:(s,n,o)=>typeof n=="string"&&t.has(n)?!1:(s[n]=o,!0),has:(s,n)=>n===xt||typeof n=="string"&&t.has(n)?!0:n in s,ownKeys:s=>{const n=Reflect.ownKeys(s),o=Array.from(t.keys());return[...new Set([...n,...o])]},getOwnPropertyDescriptor:(s,n)=>typeof n=="string"&&t.has(n)?{enumerable:!0,configurable:!0}:Reflect.getOwnPropertyDescriptor(s,n)})}class Jt{constructor(t){this.form=t}_submitting=w(!1);submitting=v(()=>this._submitting.value);async submit(t,r){const{skipValidation:i=!1,skipTouch:s=!1}=r||{};if(s||this.form.markAsTouched(),!i&&!await this.form.validate())return null;this._submitting.value=!0;try{return await t(this.form.getValue())}finally{this._submitting.value=!1}}async submitWithResult(t,r){const{skipValidation:i=!1,skipTouch:s=!1}=r||{};if(s||this.form.markAsTouched(),!i&&!await this.form.validate())return{success:!1,data:null};this._submitting.value=!0;try{return{success:!0,data:await t(this.form.getValue())}}catch(n){return{success:!1,data:null,error:n instanceof Error?n:new Error(String(n))}}finally{this._submitting.value=!1}}}function sr(e){const t=[];for(const r of e.split(".")){const i=/^([^[\]]+)(?:\[(\d+)\])?$/.exec(r);if(!i)return[];t.push(i[2]!==void 0?{key:i[1],index:Number(i[2])}:{key:i[1]})}return t}let T=class Zt extends z{id=crypto.randomUUID();_fields=new Map;disposers=new st;_proxyInstance;_behaviorCleanup;nodeFactory=new Ht;formSubmitter;_disabled=w(!1);_formErrors=w([]);_fieldSignals=new WeakMap;value;valid;invalid;touched;dirty;pending;errors;status;submitting;constructor(t){super(),this.formSubmitter=new Jt(this);const r=t.form,i=r!=null&&typeof r=="object"&&("valueSignal"in r||"value"in r),s="form"in t&&!i?t.form:t;for(const[o,a]of Object.entries(s)){const l=this.createNode(a);this._fields.set(o,l)}this.value=v(()=>{const o={};return this._fields.forEach((a,l)=>{o[l]=a.value.value}),o});const n=yt({getChildren:()=>Array.from(this._fields.values()),ownErrors:this._formErrors,disabled:this._disabled});this.valid=n.valid,this.invalid=n.invalid,this.pending=n.pending,this.touched=n.touched,this.dirty=n.dirty,this.errors=n.errors,this.status=n.status,this.submitting=this.formSubmitter.submitting}buildProxy(){return ir(this,this._fields)}getValue(){const t={};return this._fields.forEach((r,i)=>{t[i]=r.getValue()}),t}setValue(t,r){for(const[i,s]of Object.entries(t)){const n=this._fields.get(i);if(n){const o=this._fieldSignals.get(n)??n.value;if(X(o))continue;n.setValue(s,r)}}}patchValue(t){q(()=>{for(const[r,i]of Object.entries(t)){const s=this._fields.get(r);if(s&&i!==void 0){const n=this._fieldSignals.get(s)??s.value;if(X(n))continue;s.setValue(i,{emitEvent:!1})}}})}reset(t){this._formErrors.value=[],this._fields.forEach((r,i)=>{const s=t?.[i];r.reset(s)})}resetToInitial(){this._formErrors.value=[],this._fields.forEach(t=>{"resetToInitial"in t&&typeof t.resetToInitial=="function"?t.resetToInitial():t.reset()})}async validate(){return this.clearErrors(),await Promise.all(Array.from(this._fields.values()).map(t=>t.validate())),Array.from(this._fields.values()).every(t=>t.valid.value||t.disabled.value)}setErrors(t){this._formErrors.value=t}clearErrors(){this._formErrors.value=[],this._fields.forEach(t=>t.clearErrors())}getField(t){return this._fields.get(t)}get fields(){return this._fields}getProxy(){return this._proxyInstance||(this._proxyInstance=this.buildProxy()),this._proxyInstance}getAllFields(){return this._fields.values()}onMarkAsTouched(){this._fields.forEach(t=>t.markAsTouched())}onMarkAsUntouched(){this._fields.forEach(t=>t.markAsUntouched())}onMarkAsDirty(){this._fields.forEach(t=>t.markAsDirty())}onMarkAsPristine(){this._fields.forEach(t=>t.markAsPristine())}async submit(t,r){return this.formSubmitter.submit(t,r)}async submitWithResult(t,r){return this.formSubmitter.submitWithResult(t,r)}getFieldByPath(t){if(t.startsWith(".")||t.endsWith("."))return;const r=sr(t);if(r.length===0)return;let i=this;for(const s of r){if(!(i instanceof Zt)||(i=i.getField(s.key),!i))return;if(s.index!==void 0)if("at"in i&&"length"in i&&typeof i.at=="function"){const n=i.at(s.index);if(!n)return;i=n}else return}return i}createNode(t){return this.nodeFactory.createNode(t)}linkFields(t,r,i){const s=this._fields.get(t),n=this._fields.get(r);if(!s||!n){const l=s?r:t;throw new Error(`GroupNode.linkFields: field "${String(l)}" not found`)}const o=b(()=>{const l=s.value.value,d=i?i(l):l;n.setValue(d,{emitEvent:!1})}),a=L(G.LinkFields);return this.disposers.add(a,o)}watchField(t,r){const i=this.getFieldByPath(t);if(!i)throw new Error(`GroupNode.watchField: field "${t}" not found`);const s=b(()=>{r(i.value.value)}),n=L(G.WatchField);return this.disposers.add(n,s)}watchFieldByPath(t,r){const i=this.getFieldByPath(t);if(!i)throw new Error(`GroupNode.watchFieldByPath: field "${t}" not found`);const s=b(()=>{r(i.value.value)}),n=L(G.WatchField);return this.disposers.add(n,s)}onDisable(){this._disabled.value=!0,this._fields.forEach(t=>t.disable())}onEnable(){this._disabled.value=!1,this._fields.forEach(t=>t.enable())}attachBehaviorCleanup(t){this._behaviorCleanup=t}registerFieldSignal(t,r){this._fieldSignals.set(t,r)}dispose(){this._behaviorCleanup?.(),this._behaviorCleanup=void 0,this.disposers.dispose(),this._fields.forEach(t=>{"dispose"in t&&typeof t.dispose=="function"&&t.dispose()})}};class ht extends z{items;itemSchema;initialItems;disposers=new st;_arrayErrors=w([]);value;valid;invalid;touched;dirty;pending;errors;status;length;constructor(t,r=[]){super(),this.itemSchema=t,this.initialItems=r,this.items=w([]);for(const s of r)this.push(s);this.length=v(()=>this.items.value.length),this.value=v(()=>this.items.value.map(s=>s.value.value));const i=yt({getChildren:()=>this.items.value,ownErrors:this._arrayErrors});this.valid=i.valid,this.invalid=i.invalid,this.pending=i.pending,this.touched=i.touched,this.dirty=i.dirty,this.errors=i.errors,this.status=i.status}push(t){const r=this.createItem(t);this.items.value=[...this.items.value,r]}removeAt(t){if(t<0||t>=this.items.value.length){P.handle(new Error(`ArrayNode.removeAt: index ${t} out of bounds (length: ${this.items.value.length})`),"ArrayNode.removeAt",N.LOG);return}const r=this.items.value[t];this.items.value=this.items.value.filter((i,s)=>s!==t),r&&"dispose"in r&&typeof r.dispose=="function"&&r.dispose()}insert(t,r){if(t<0||t>this.items.value.length){P.handle(new Error(`ArrayNode.insert: index ${t} out of bounds (length: ${this.items.value.length})`),"ArrayNode.insert",N.LOG);return}const i=this.createItem(r),s=[...this.items.value];s.splice(t,0,i),this.items.value=s}move(t,r){const i=this.items.value.length;if(t<0||t>=i||r<0||r>=i){P.handle(new Error(`ArrayNode.move: index out of bounds (from=${t}, to=${r}, length=${i})`),"ArrayNode.move",N.LOG);return}if(t===r)return;const s=[...this.items.value],[n]=s.splice(t,1);s.splice(r,0,n),this.items.value=s}swap(t,r){const i=this.items.value.length;if(t<0||t>=i||r<0||r>=i){P.handle(new Error(`ArrayNode.swap: index out of bounds (a=${t}, b=${r}, length=${i})`),"ArrayNode.swap",N.LOG);return}if(t===r)return;const s=[...this.items.value];[s[t],s[r]]=[s[r],s[t]],this.items.value=s}clear(){const t=[...this.items.value];this.items.value=[],t.forEach(r=>{"dispose"in r&&typeof r.dispose=="function"&&r.dispose()})}at(t){const r=this.items.value[t];if(r)return r.getProxy()}getValue(){return this.items.value.map(t=>t.getValue())}setValue(t,r){this.clear(),t.forEach(i=>this.push(i)),r?.emitEvent!==!1&&this.validate().catch(i=>{P.handle(i,"ArrayNode.setValue",N.LOG)})}patchValue(t){t.forEach((r,i)=>{this.items.value[i]&&r!==void 0&&this.items.value[i].patchValue(r)})}reset(t){this._arrayErrors.value=[],this.clear(),t&&t.forEach(r=>this.push(r))}resetToInitial(){this._arrayErrors.value=[],this.clear(),this.initialItems.forEach(t=>this.push(t))}async validate(){return(await Promise.all(this.items.value.map(t=>t.validate()))).every(Boolean)&&this._arrayErrors.value.length===0}setErrors(t){this._arrayErrors.value=t}clearErrors(){this._arrayErrors.value=[],this.items.value.forEach(t=>t.clearErrors())}onMarkAsTouched(){this.items.value.forEach(t=>t.markAsTouched())}onMarkAsUntouched(){this.items.value.forEach(t=>t.markAsUntouched())}onMarkAsDirty(){this.items.value.forEach(t=>t.markAsDirty())}onMarkAsPristine(){this.items.value.forEach(t=>t.markAsPristine())}forEach(t){this.items.value.forEach((r,i)=>{const s=r.getProxy();t(s,i)})}map(t){return this.items.value.map((r,i)=>{const s=r.getProxy();return t(s,i)})}createItem(t){if(this.isGroupSchema(this.itemSchema)){const r=new T(this.itemSchema);return t&&r.patchValue(t),r}throw new Error("ArrayNode поддерживает только GroupNode элементы. Для массива примитивов используйте обычное поле с типом массива.")}isGroupSchema(t){return typeof t=="object"&&t!==null&&!("component"in t)&&!Array.isArray(t)}dispose(){this.disposers.dispose(),this.items.value.forEach(t=>{"dispose"in t&&typeof t.dispose=="function"&&t.dispose()})}onDisable(){this.items.value.forEach(t=>{t.disable()})}onEnable(){this.items.value.forEach(t=>{t.enable()})}}class Ht{createNode(t){if(Array.isArray(t)&&t.length>=1)return this.createArrayNodeFromArray(t);if(this.isFieldConfig(t))return new zt(t);if(this.isArrayConfig(t))return new ht(t.schema,t.initialItems);if(this.isGroupConfig(t))return new T(t);throw new Error(`NodeFactory: Unknown node config. Expected FieldConfig, GroupConfig, or ArrayConfig, but got: ${JSON.stringify(t)}`)}createArrayNodeFromArray(t){const[r,...i]=t,s=[];this.isGroupConfig(r)&&s.push(this.extractValues(r));for(const n of i)this.isGroupConfig(n)?s.push(this.extractValues(n)):s.push(n);return new ht(r,s)}extractValues(t){if(this.isFieldConfig(t))return t.value;if(Array.isArray(t))return t.map(r=>this.extractValues(r));if(this.isGroupConfig(t)){const r={};for(const[i,s]of Object.entries(t))r[i]=this.extractValues(s);return r}return t}isFieldConfig(t){return t==null||typeof t!="object"?!1:"valueSignal"in t?!0:"value"in t?"component"in t||"componentProps"in t||"validators"in t||"asyncValidators"in t||"updateOn"in t||"debounce"in t:!1}isArrayConfig(t){return t!=null&&typeof t=="object"&&"schema"in t&&!("value"in t)}isGroupConfig(t){return t!=null&&typeof t=="object"&&!this.isFieldConfig(t)&&!this.isArrayConfig(t)}}class Qt extends z{constructor(t,r){super(),this.control=t,this.buildItem=r,this.initial=t.toArray(),this.disposeSync=b(()=>{const s=t.length,n=[],o=[];for(let d=0;d<s;d++){const c=t.at(d);if(!c)continue;let u=this.cache.get(c);u||(u=r(c),this.cache.set(c,u)),n.push(c),o.push(u)}const a=new Set(n),l=[];for(const d of this.mountedModels){if(a.has(d))continue;const c=this.cache.get(d);this.cache.delete(d),c&&l.push(c)}this.mountedModels=n,this.itemNodes.value=o,l.forEach(d=>this.disposeItemNode(d))}),this.length=v(()=>this.itemNodes.value.length),this.value=v(()=>this.itemNodes.value.map(s=>s.value.value));const i=yt({getChildren:()=>this.itemNodes.value,ownErrors:this._arrayErrors});this.valid=i.valid,this.invalid=i.invalid,this.pending=i.pending,this.touched=i.touched,this.dirty=i.dirty,this.errors=i.errors,this.status=i.status}itemNodes=w([]);cache=new WeakMap;mountedModels=[];initial;_arrayErrors=w([]);disposeSync;get items(){return this.itemNodes}value;valid;invalid;pending;touched;dirty;errors;status;length;at(t){return this.itemNodes.value[t]}map(t){return this.itemNodes.value.map((r,i)=>t(r,i))}forEach(t){this.itemNodes.value.forEach((r,i)=>t(r,i))}push(t){this.control.push(t??{})}insert(t,r){this.control.insertAt(t,r??{})}removeAt(t){this.control.removeAt(t)}move(t,r){this.control.move(t,r)}swap(t,r){this.control.swap(t,r)}clear(){this.control.clear()}getValue(){return this.control.toArray()}setValue(t){this.control.clear(),(t??[]).forEach(r=>this.control.push(r))}patchValue(t){this.setValue(t)}reset(t){this._arrayErrors.value=[],this.setValue(t??this.initial)}resetToInitial(){this.reset(this.initial)}async validate(){return(await Promise.all(this.itemNodes.value.map(t=>t.validate()))).every(Boolean)&&this._arrayErrors.value.length===0}setErrors(t){this._arrayErrors.value=t}clearErrors(){this._arrayErrors.value=[],this.itemNodes.value.forEach(t=>t.clearErrors?.())}onMarkAsTouched(){this.itemNodes.value.forEach(t=>t.markAsTouched?.())}onMarkAsUntouched(){this.itemNodes.value.forEach(t=>t.markAsUntouched?.())}onMarkAsDirty(){this.itemNodes.value.forEach(t=>t.markAsDirty?.())}onMarkAsPristine(){this.itemNodes.value.forEach(t=>t.markAsPristine?.())}onDisable(){this.itemNodes.value.forEach(t=>t.disable?.())}onEnable(){this.itemNodes.value.forEach(t=>t.enable?.())}disposeItemNode(t){t.dispose?.()}dispose(){this.disposeSync(),this.itemNodes.value.forEach(t=>this.disposeItemNode(t)),this.mountedModels=[]}}const Yt=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof Date)&&!(typeof Blob<"u"&&e instanceof Blob)&&!(typeof File<"u"&&e instanceof File);function dt(e,t,r){if(e==null||typeof e!="object"||e instanceof E)return;if(Array.isArray(e)){for(const n of e)dt(n,t,r);return}const i=e,s=i.array;if(s&&typeof s.__path=="string"&&typeof i.item=="function"){r.set(s.__path,i.item);return}i.value instanceof E&&t.set(i.value,{component:i.component,componentProps:i.componentProps,updateOn:i.updateOn,disabled:i.disabled,debounce:i.debounce});for(const[n,o]of Object.entries(i))n!=="value"&&dt(o,t,r)}function Xt(e,t,r,i){const s={};for(const[n,o]of Object.entries(t)){const a=r===""?n:`${r}.${n}`;if(Array.isArray(o))continue;if(Yt(o)){s[n]=Xt(e,o,a,i);continue}const l=e.signalAt(a);if(!l)throw new Error(`createForm({ model }): не найден сигнал для пути "${a}"`);const d=i.get(l)??{};s[n]={...d,valueSignal:l}}return s}function te(e,t,r){for(const[i,s]of Object.entries(e)){const n=t===""?i:`${t}.${i}`;Array.isArray(s)||(Yt(s)?te(s,n,r):r.push(n))}}function gt(e){const{model:t,schema:r,behavior:i}=e,s=new Map,n=new Map;r!==void 0&&dt(r,s,n);const o=Xt(t,t.get(),"",s),a=new T(o),l=t.get();for(const[u,h]of Object.entries(l)){if(!Array.isArray(h))continue;const p=n.get(u);if(!p)continue;const g=t[u],y=k=>gt({model:k,schema:p(k)}),A=new Qt(g,y);a.fields.set(u,A)}const d=a.getProxy(),c=[];te(t.get(),"",c);for(const u of c){const h=t.signalAt(u),p=a.getFieldByPath(u);if(h&&p){Gt(h,p);const g=u.lastIndexOf("."),y=g===-1?a:a.getFieldByPath(u.slice(0,g));y instanceof T&&y.registerFieldSignal(p,h)}}return i&&a.attachBehaviorCleanup(i.__run(t,d)),d}const nr=e=>e!=null&&typeof e=="object"&&"model"in e&&typeof e.model?.signalAt=="function";function or(e){return nr(e)?gt(e):new T(e).getProxy()}function J(e){return e==null?!1:typeof e=="object"&&"value"in e&&"setValue"in e&&"getValue"in e&&"validate"in e}function ee(e){return J(e)&&"validators"in e&&"asyncValidators"in e&&typeof e.markAsTouched=="function"&&!("fields"in e)&&!("items"in e)}function re(e){return J(e)&&"getFieldByPath"in e&&"fields"in e&&!("items"in e)&&!("push"in e)&&!("removeAt"in e)}function ie(e){return J(e)&&"items"in e&&"length"in e&&"push"in e&&"removeAt"in e&&"at"in e&&typeof e.push=="function"&&typeof e.removeAt=="function"}function ar(e){return ee(e)?"FieldNode":re(e)?"GroupNode":ie(e)?"ArrayNode":J(e)?"FormNode":"Unknown"}var Ft={exports:{}},at={},Nt;function lr(){if(Nt)return at;Nt=1;var e=fe;function t(u,h){return u===h&&(u!==0||1/u===1/h)||u!==u&&h!==h}var r=typeof Object.is=="function"?Object.is:t,i=e.useState,s=e.useEffect,n=e.useLayoutEffect,o=e.useDebugValue;function a(u,h){var p=h(),g=i({inst:{value:p,getSnapshot:h}}),y=g[0].inst,A=g[1];return n(function(){y.value=p,y.getSnapshot=h,l(y)&&A({inst:y})},[u,p,h]),s(function(){return l(y)&&A({inst:y}),u(function(){l(y)&&A({inst:y})})},[u]),o(p),p}function l(u){var h=u.getSnapshot;u=u.value;try{var p=h();return!r(u,p)}catch{return!0}}function d(u,h){return h()}var c=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:a;return at.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:c,at}var Mt;function ur(){return Mt||(Mt=1,Ft.exports=lr()),Ft.exports}var nt=ur();function cr(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function bt(e,t,r,i){const s=f.useRef(null),n=f.useRef(e);n.current=e;const o=f.useRef(t);o.current=t;const a=f.useRef(r);if(a.current=r,s.current===null){const c={};for(const u in e)c[u]=e[u].value;s.current={...c,__snapshot:null}}const l=f.useCallback(c=>{let u=!0;return b(()=>{const h=n.current;for(const p in h)h[p].value;if(u){u=!1;return}c()})},[i]),d=f.useCallback(()=>{const c=s.current,u=n.current,h={};for(const g in u)h[g]=u[g].value;let p=!1;for(const g of o.current){const{key:y,useShallowArrayEqual:A}=g,k=h[y],_=c[y];if(A){if(!cr(_,k)){p=!0;break}}else if(_!==k){p=!0;break}}if(!p&&c.__snapshot)return c.__snapshot;for(const g in u)c[g]=h[g];return c.__snapshot=a.current(h),c.__snapshot},[i]);return nt.useSyncExternalStore(l,d,d)}function hr(e){const t={value:e.value,disabled:e.disabled,errors:e.errors,pending:e.pending,valid:e.valid,invalid:e.invalid,touched:e.touched,dirty:e.dirty,shouldShowError:e.shouldShowError,componentProps:e.componentProps},r=[{key:"value"},{key:"disabled"},{key:"errors",useShallowArrayEqual:!0},{key:"pending"},{key:"valid"},{key:"invalid"},{key:"touched"},{key:"dirty"},{key:"shouldShowError"},{key:"componentProps"}],i=f.useCallback(s=>({value:s.value,pending:s.pending,disabled:s.disabled,errors:s.errors,valid:s.valid,invalid:s.invalid,touched:s.touched,dirty:s.dirty,shouldShowError:s.shouldShowError,componentProps:s.componentProps}),[]);return bt(t,r,i,e)}function dr(e){const t={value:e.value,length:e.length,errors:e.errors,pending:e.pending,valid:e.valid,invalid:e.invalid,touched:e.touched,dirty:e.dirty,disabled:e.disabled},r=[{key:"value"},{key:"length"},{key:"errors",useShallowArrayEqual:!0},{key:"pending"},{key:"valid"},{key:"invalid"},{key:"touched"},{key:"dirty"},{key:"disabled"}],i=f.useCallback(s=>({value:s.value,length:s.length,pending:s.pending,errors:s.errors,valid:s.valid,invalid:s.invalid,touched:s.touched,dirty:s.dirty,disabled:s.disabled}),[]);return bt(t,r,i,e)}function fr(){const e=f.useCallback(()=>({value:[],length:0,pending:!1,errors:[],valid:!0,invalid:!1,touched:!1,dirty:!1,disabled:!1}),[]);return bt({},[],e)}function se(e){const t=e&&"length"in e&&"map"in e;return e?t?dr(e):hr(e):fr()}function vr(e){const t=f.useRef({value:e.value.value}),r=f.useCallback(s=>{let n=!0;return b(()=>{if(e.value.value,n){n=!1;return}s()})},[e]),i=f.useCallback(()=>{const s=e.value.value;return t.current.value===s?t.current.value:(t.current.value=s,s)},[e]);return nt.useSyncExternalStore(r,i,i)}function pr(e){const t=f.useRef({length:e.length.value}),r=f.useCallback(s=>{let n=!0;return b(()=>{if(e.length.value,n){n=!1;return}s()})},[e]),i=f.useCallback(()=>{const s=e.length.value;return t.current.length===s?t.current.length:(t.current.length=s,s)},[e]);return nt.useSyncExternalStore(r,i,i)}function mr(e){const{model:t,schema:r,strategy:i,debounce:s,liveAfterSubmit:n}=e,o=f.useMemo(()=>Kt(t,r,{strategy:i,debounce:s,liveAfterSubmit:n}),[t,r,i,s,n]);f.useEffect(()=>o.start(),[o]);const a=nt.useSyncExternalStore(f.useCallback(d=>o.validating.subscribe(d),[o]),()=>o.validating.peek(),()=>!1),l=f.useCallback(()=>o.validate(),[o]);return{submit:l,validate:l,isValidating:a}}const yr=Object.freeze({runtime:"reformer-core",v:1}),Nr=Object.freeze(Object.defineProperty({__proto__:null,ArrayNode:ht,CORE_RUNTIME_TOKEN:yr,ErrorStrategy:N,FieldNode:zt,FormErrorHandler:P,FormNode:z,FormSubmitter:Jt,GroupNode:T,ModelArrayNode:Qt,NodeFactory:Ht,SubscriptionManager:st,computeFrom:Ie,copyFrom:Te,createForm:or,createFormFromModel:gt,createModel:Ve,disableWhen:Le,enableWhen:Lt,getNodeForSignal:I,getNodeType:ar,isArrayNode:ie,isDerived:X,isFieldNode:ee,isFormNode:J,isGroupNode:re,isModelContainerSignal:Ne,markDerived:_e,registerSignalNode:Gt,resetWhen:Ue,revalidateWhen:Ge,runOutsideEffect:C,safeCallback:je,safeDebouncedCallback:De,syncFields:Be,transformValue:We,unmarkDerived:Ae,useArrayLength:pr,useFormControl:se,useFormControlValue:vr,useFormValidation:mr,watchField:Re},Symbol.toStringTag,{value:"Module"})),gr=e=>e.message||e.code,br=f.createContext(gr);function ne(){return f.useContext(br)}const oe=f.createContext(null);function ot(){const e=f.useContext(oe);if(!e)throw new Error("FormField.* components must be used within <FormField.Root>. Wrap your field with <FormField.Root control={control}>.");return e}function wt({control:e,children:t,id:r,hasDescription:i=!1}){const s=f.useId(),n=r??s,o=f.useMemo(()=>({controlId:`control-${n}`,labelId:`label-${n}`,descriptionId:`desc-${n}`,errorId:`error-${n}`}),[n]),a=se(e),l=ne(),d=f.useMemo(()=>{const{value:c,errors:u,pending:h,disabled:p,valid:g,invalid:y,touched:A,shouldShowError:k,componentProps:_}=a;return{value:c,errors:u,pending:h,disabled:p,valid:g,invalid:y,touched:A,shouldShowError:k,error:k&&u[0]?l(u[0]):void 0,label:_.label,required:!!_.required,componentProps:_,control:e,ids:o,hasDescription:i}},[a,e,o,i,l]);return S.jsx(oe.Provider,{value:d,children:t})}wt.displayName="FormField.Root";const ae=f.forwardRef(({asChild:e=!1,children:t,forceRender:r=!1,...i},s)=>{const{label:n,required:o,ids:a}=ot(),l=t??n;return!l&&!r?null:S.jsxs(e?K:"label",{ref:s,id:a.labelId,htmlFor:e?void 0:a.controlId,...i,children:[l,o&&S.jsx("span",{"aria-hidden":"true",children:" *"})]})});ae.displayName="FormField.Label";const le=f.forwardRef(({asChild:e=!1,children:t,...r},i)=>{const{control:s,value:n,disabled:o,shouldShowError:a,errors:l,required:d,ids:c,hasDescription:u,componentProps:h}=ot(),p=[u?c.descriptionId:null,a&&l.length>0?c.errorId:null].filter(Boolean).join(" ")||void 0,g={id:c.controlId,"aria-labelledby":c.labelId,"aria-invalid":a?!0:void 0,"aria-describedby":p,"aria-errormessage":a&&l.length>0?c.errorId:void 0,"aria-required":d?!0:void 0};if(t||e)return S.jsx(K,{ref:i,...g,...r,value:n,disabled:o,onChange:_=>s.setValue(_),onBlur:()=>s.markAsTouched(),children:t});const y=s.component,{testId:A,...k}=h??{};return S.jsx(y,{ref:i,...k,...g,...r,value:n,disabled:o,onChange:_=>s.setValue(_),onBlur:()=>s.markAsTouched()})});le.displayName="FormField.Control";const ue=f.forwardRef(({asChild:e=!1,multi:t=!1,render:r,children:i,...s},n)=>{const{shouldShowError:o,errors:a,ids:l}=ot(),d=ne();if(!o||a.length===0)return null;const c=e?K:"p";return r?S.jsx(S.Fragment,{children:a.map((u,h)=>S.jsx(c,{ref:h===0?n:void 0,id:h===0?l.errorId:void 0,role:"alert",...s,children:r(u,h)},u.code??h))}):t?S.jsx(S.Fragment,{children:a.map((u,h)=>{const p=d(u);return S.jsx(c,{ref:h===0?n:void 0,id:h===0?l.errorId:void 0,role:"alert",...s,children:e?S.jsx("span",{children:p}):p},u.code??h)})}):S.jsx(c,{ref:n,id:l.errorId,role:"alert",...s,children:i??d(a[0])})});ue.displayName="FormField.Error";const ce=f.forwardRef(({asChild:e=!1,children:t,...r},i)=>{const{ids:s}=ot();return S.jsx(e?K:"p",{ref:i,id:s.descriptionId,...r,children:t})});ce.displayName="FormField.Description";const Z=wt;Z.Root=wt;Z.Label=ae;Z.Control=le;Z.Error=ue;Z.Description=ce;export{Ve as C,Ue as D,Te as E,_e as F,Kt as G,Ae as K,se as M,or as N,X as P,Er as R,Ne as W,v as a,C as b,Lt as c,Be as d,We as e,je as f,I as g,De as h,xr as i,b as j,Ie as k,E as l,Nr as m,q as n,it as o,Z as p,ot as q,ve as r,kr as s,st as t,K as u,ne as v,Re as w,Ge as x,w as y};
|