text: import r,{createContext as t,useContext as e,useEffect as n,forwardRef as o,useState as i,useCallback as u,useImperativeHandle as a}from"react";import c from"dot-object";var f=t({});function l(r){var t=e(f),o=t.initialData,i=t.errors,u=t.scopePath,a=t.unregisterField,l=t.registerField,s=u?u+"."+r:r;n((function(){return function(){return a(s)}}),[s,a]);var p=c.pick(s,o),v=i[s];return{fieldName:s,registerField:l,defaultValue:p,error:v}}
  /*! *****************************************************************************
  Copyright (c) Microsoft Corporation. All rights reserved.
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  this file except in compliance with the License. You may obtain a copy of the
  License at http://www.apache.org/licenses/LICENSE-2.0
  
  THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  MERCHANTABLITY OR NON-INFRINGEMENT.
  
  See the Apache Version 2.0 License for specific language governing permissions
  and limitations under the License.
  ***************************************************************************** */var s=function(){return(s=Object.assign||function(r){for(var t,e=1,n=arguments.length;e<n;e++)for(var o in t=arguments[e])Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=t[o]);return r}).apply(this,arguments)};function p(r,t){var e,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(r,u)}catch(r){i=[6,r],n=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var v=o((function(t,e){var n=t.initialData,o=void 0===n?{}:n,l=t.children,v=t.onSubmit,h=i({}),d=h[0],b=h[1],y=i([]),g=y[0],m=y[1],w=u((function(r){return g.find((function(t){return t.name===r}))}),[g]),F=u((function(r){var t=r.ref,e=r.path,n=r.getValue;return n?n(t):c.pick(e,t)}),[]),O=u((function(r,t){var e=r.path,n=r.ref,o=r.setValue;return o?o(n,t):c.set(e,t,n)}),[]),P=u((function(r){var t=r.clearValue,e=r.ref,n=r.path;return t?t(e,""):c.set(n,"",e)}),[]),E=u((function(r){void 0===r&&(r={}),g.forEach((function(t){var e=t.name,n=t.ref,o=t.path,i=t.clearValue;return i?i(n,r[e]):c.set(o,r[e]?r[e]:"",n)}))}),[g]),j=u((function(r){var t=c.dot(r);Object.entries(t).forEach((function(r){var t=r[0],e=r[1],n=w(t);n&&O(n,e)}))}),[w,O]),x=u((function(r){var t=c.dot(r);b(t)}),[]),V=u((function(){var r={};return g.forEach((function(t){r[t.name]=F(t)})),c.object(r),r}),[g,F]),k=u((function(r){return t=void 0,e=void 0,o=function(){var t;return p(this,(function(e){return r&&r.preventDefault(),t=V(),v(t,{reset:E}),[2]}))},new((n=void 0)||(n=Promise))((function(r,i){function u(r){try{c(o.next(r))}catch(r){i(r)}}function a(r){try{c(o.throw(r))}catch(r){i(r)}}function c(t){t.done?r(t.value):new n((function(r){r(t.value)})).then(u,a)}c((o=o.apply(t,e||[])).next())}));var t,e,n,o}),[v,V,E]),D=u((function(r){m((function(t){return function(){for(var r=0,t=0,e=arguments.length;t<e;t++)r+=arguments[t].length;var n=Array(r),o=0;for(t=0;t<e;t++)for(var i=arguments[t],u=0,a=i.length;u<a;u++,o++)n[o]=i[u];return n}(t,[r])}))}),[]),S=u((function(r){m((function(t){return t.filter((function(t){return t.name!==r}))}))}),[]);return a(e,(function(){return{getFieldValue:function(r){var t=w(r);return!!t&&F(t)},setFieldValue:function(r,t){var e=w(r);return!!e&&O(e,t)},getFieldError:function(r){return d[r]},setFieldError:function(r,t){var e;b(s(s({},d),((e={})[r]=t,e)))},clearField:function(r){var t=w(r);t&&P(t)},getErrors:function(){return d},setErrors:function(r){return x(r)},getData:function(){return V()},getFieldRef:function(r){var t=w(r);return!!t&&t.ref},setData:function(r){return j(r)},reset:function(r){return E(r)},submitForm:function(){k()}}})),r.createElement(f.Provider,{value:{initialData:o,errors:d,scopePath:"",registerField:D,unregisterField:S,handleSubmit:k}},l)}));function h(t){var n=t.path,o=t.children,i=e(f),u=i.scopePath,a=function(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(null!=r&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(r);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(r,n[o])&&(e[n[o]]=r[n[o]])}return e}(i,["scopePath"]);return r.createElement(f.Provider,{value:s(s({},a),{scopePath:u.concat(u?"."+n:n)})},o)}export{v as Form,f as FormContext,h as Scope,l as useField};
  //# sourceMappingURL=index.es.js.map
  