@object-ui/console 3.0.3 → 3.1.1
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 +1 -1
- package/dist/assets/AdvancedChartImpl-D711bBuO.js +7 -0
- package/dist/assets/AppManagementPage-D_71FpIH.js +1 -0
- package/dist/assets/AuditLogPage-D3g_VEdE.js +1 -0
- package/dist/assets/AuthPageLayout-9l5xWV_-.js +1 -0
- package/dist/assets/{ChartImpl-2ivTljUi.js → ChartImpl-B9B4Fnbe.js} +1 -1
- package/dist/assets/CreateAppPage-mqt5j4rK.js +1 -0
- package/dist/assets/DashboardDesignPage-Cijb3jeF.js +1 -0
- package/dist/assets/DashboardView-DjhlMHLV.js +1 -0
- package/dist/assets/EditAppPage-BiK_DWcO.js +1 -0
- package/dist/assets/ForgotPasswordPage-Bzady8r_.js +1 -0
- package/dist/assets/KanbanEnhanced-OvdpYe81.js +1 -0
- package/dist/assets/KanbanImpl-EcxwmGw7.js +1 -0
- package/dist/assets/LoginPage-valW4Wu1.js +1 -0
- package/dist/assets/{MarkdownImpl-BshtTFK2.js → MarkdownImpl-C0wRapHT.js} +2 -2
- package/dist/assets/OrgManagementPage-D0d52PdP.js +1 -0
- package/dist/assets/PageDesignPage-hpFLdWCR.js +1 -0
- package/dist/assets/PageView-DxIAf-SB.js +2 -0
- package/dist/assets/PermissionManagementPage-ELCC8HyK.js +1 -0
- package/dist/assets/ProfilePage-Dj1N0mY3.js +1 -0
- package/dist/assets/RecordDetailView-DS9tEr5f.js +1 -0
- package/dist/assets/RegisterPage-DqUU8oW-.js +1 -0
- package/dist/assets/ReportView-CNi0A66t.js +1 -0
- package/dist/assets/RoleManagementPage-DRvuG53j.js +1 -0
- package/dist/assets/SearchResultsPage-nMlMQCb8.js +1 -0
- package/dist/assets/SystemHubPage-CAY-YvG2.js +1 -0
- package/dist/assets/UserManagementPage-fzvfJxav.js +1 -0
- package/dist/assets/data-adapter-rvE3xy2B.js +1 -0
- package/dist/assets/framework-BM176iet.js +10 -0
- package/dist/assets/index-B6cpm7bF.css +1 -0
- package/dist/assets/index-CTBPkbPG.js +9 -0
- package/dist/assets/index-Dv78M4Xq.js +1 -0
- package/dist/assets/infrastructure-n1j_TN6w.js +1 -0
- package/dist/assets/maplibre-gl-DVmJFhI2.js +811 -0
- package/dist/assets/plugins-core-qwgXbAqa.js +8 -0
- package/dist/assets/plugins-views-CveFN6PV.js +62 -0
- package/dist/assets/ui-components-BxvihT61.js +36 -0
- package/dist/assets/ui-components-CRV2BvKI.css +1 -0
- package/dist/assets/ui-layout-C6KWQtRO.js +1 -0
- package/dist/assets/{vendor-charts-CSvoW-yB.js → vendor-charts-BLNOCZWl.js} +2 -2
- package/dist/assets/vendor-dndkit-CX1oDZqy.js +5 -0
- package/dist/assets/vendor-i18n-E3-WitRV.js +9 -0
- package/dist/assets/{vendor-icons-CQ8b-fGy.js → vendor-icons-ndICq8DC.js} +3425 -3535
- package/dist/assets/vendor-objectstack-YKtcdalX.js +34 -0
- package/dist/assets/{vendor-radix-BbeYj_o4.js → vendor-radix-C6qchjxv.js} +1 -1
- package/dist/assets/vendor-react-9M-xu2bR.js +60 -0
- package/dist/assets/vendor-ui-utils-3tkeUVaX.js +1 -0
- package/dist/assets/vendor-zod-DxQVy2_o.js +39 -0
- package/dist/index.html +23 -22
- package/package.json +49 -46
- package/plugin.d.ts +1 -2
- package/plugin.js +1 -2
- package/plugin.ts +1 -2
- package/dist/assets/AdvancedChartImpl-DAS1mU9o.js +0 -7
- package/dist/assets/AdvancedChartImpl-DAS1mU9o.js.br +0 -0
- package/dist/assets/AdvancedChartImpl-DAS1mU9o.js.gz +0 -0
- package/dist/assets/AuditLogPage-CyY7VZJW.js +0 -1
- package/dist/assets/AuditLogPage-CyY7VZJW.js.br +0 -0
- package/dist/assets/AuditLogPage-CyY7VZJW.js.gz +0 -0
- package/dist/assets/ChartImpl-2ivTljUi.js.br +0 -0
- package/dist/assets/ChartImpl-2ivTljUi.js.gz +0 -0
- package/dist/assets/DashboardView-DSh9LYBb.js +0 -1
- package/dist/assets/DashboardView-DSh9LYBb.js.br +0 -0
- package/dist/assets/DashboardView-DSh9LYBb.js.gz +0 -0
- package/dist/assets/ForgotPasswordPage-DUfjj-wh.js +0 -1
- package/dist/assets/KanbanEnhanced-ZOndyXyg.js +0 -1
- package/dist/assets/KanbanEnhanced-ZOndyXyg.js.br +0 -0
- package/dist/assets/KanbanEnhanced-ZOndyXyg.js.gz +0 -0
- package/dist/assets/KanbanImpl-BsMtStI7.js +0 -1
- package/dist/assets/KanbanImpl-BsMtStI7.js.br +0 -0
- package/dist/assets/KanbanImpl-BsMtStI7.js.gz +0 -0
- package/dist/assets/LoginPage-2CoFvwsL.js +0 -1
- package/dist/assets/MarkdownImpl-BshtTFK2.js.br +0 -0
- package/dist/assets/MarkdownImpl-BshtTFK2.js.gz +0 -0
- package/dist/assets/OrgManagementPage-BJt5Iiun.js +0 -1
- package/dist/assets/OrgManagementPage-BJt5Iiun.js.br +0 -0
- package/dist/assets/OrgManagementPage-BJt5Iiun.js.gz +0 -0
- package/dist/assets/PageView-bHvRhycc.js +0 -1
- package/dist/assets/PageView-bHvRhycc.js.br +0 -0
- package/dist/assets/PageView-bHvRhycc.js.gz +0 -0
- package/dist/assets/ProfilePage-MVUfKMrp.js +0 -1
- package/dist/assets/ProfilePage-MVUfKMrp.js.br +0 -0
- package/dist/assets/ProfilePage-MVUfKMrp.js.gz +0 -0
- package/dist/assets/RecordDetailView-Sm8_iQw_.js +0 -1
- package/dist/assets/RecordDetailView-Sm8_iQw_.js.br +0 -0
- package/dist/assets/RecordDetailView-Sm8_iQw_.js.gz +0 -0
- package/dist/assets/RegisterPage-B9itUVYp.js +0 -1
- package/dist/assets/ReportView-B0D9jx4v.js +0 -1
- package/dist/assets/ReportView-B0D9jx4v.js.br +0 -0
- package/dist/assets/ReportView-B0D9jx4v.js.gz +0 -0
- package/dist/assets/RoleManagementPage-BRqaeF_L.js +0 -1
- package/dist/assets/RoleManagementPage-BRqaeF_L.js.br +0 -0
- package/dist/assets/RoleManagementPage-BRqaeF_L.js.gz +0 -0
- package/dist/assets/SearchResultsPage-wlC0eLLr.js +0 -1
- package/dist/assets/SearchResultsPage-wlC0eLLr.js.br +0 -0
- package/dist/assets/SearchResultsPage-wlC0eLLr.js.gz +0 -0
- package/dist/assets/UserManagementPage-DOH6ql6-.js +0 -1
- package/dist/assets/UserManagementPage-DOH6ql6-.js.br +0 -0
- package/dist/assets/UserManagementPage-DOH6ql6-.js.gz +0 -0
- package/dist/assets/ViewDesignerPage-TCaXYb43.js +0 -1
- package/dist/assets/ViewDesignerPage-TCaXYb43.js.br +0 -0
- package/dist/assets/ViewDesignerPage-TCaXYb43.js.gz +0 -0
- package/dist/assets/data-adapter-D15yh-pb.js +0 -1
- package/dist/assets/data-adapter-D15yh-pb.js.br +0 -0
- package/dist/assets/data-adapter-D15yh-pb.js.gz +0 -0
- package/dist/assets/framework-mHWN965c.js +0 -10
- package/dist/assets/framework-mHWN965c.js.br +0 -0
- package/dist/assets/framework-mHWN965c.js.gz +0 -0
- package/dist/assets/index-CUnVdETN.css +0 -1
- package/dist/assets/index-CUnVdETN.css.br +0 -0
- package/dist/assets/index-CUnVdETN.css.gz +0 -0
- package/dist/assets/index-RAPqkKVL.js +0 -9
- package/dist/assets/index-RAPqkKVL.js.br +0 -0
- package/dist/assets/index-RAPqkKVL.js.gz +0 -0
- package/dist/assets/infrastructure-Di0WqY4l.js +0 -1
- package/dist/assets/infrastructure-Di0WqY4l.js.br +0 -0
- package/dist/assets/infrastructure-Di0WqY4l.js.gz +0 -0
- package/dist/assets/maplibre-gl-D2AsLM0J.js +0 -811
- package/dist/assets/maplibre-gl-D2AsLM0J.js.br +0 -0
- package/dist/assets/maplibre-gl-D2AsLM0J.js.gz +0 -0
- package/dist/assets/plugins-core-Cv2TPt86.js +0 -4
- package/dist/assets/plugins-core-Cv2TPt86.js.br +0 -0
- package/dist/assets/plugins-core-Cv2TPt86.js.gz +0 -0
- package/dist/assets/plugins-views-P3eB-els.css.br +0 -0
- package/dist/assets/plugins-views-P3eB-els.css.gz +0 -0
- package/dist/assets/plugins-views-divN-xXs.js +0 -60
- package/dist/assets/plugins-views-divN-xXs.js.br +0 -0
- package/dist/assets/plugins-views-divN-xXs.js.gz +0 -0
- package/dist/assets/systemObjects-DSpePIIy.js.br +0 -2
- package/dist/assets/systemObjects-DSpePIIy.js.gz +0 -0
- package/dist/assets/ui-components-CseD2Dpn.js +0 -31
- package/dist/assets/ui-components-CseD2Dpn.js.br +0 -0
- package/dist/assets/ui-components-CseD2Dpn.js.gz +0 -0
- package/dist/assets/ui-components-GrNdJOi1.css +0 -1
- package/dist/assets/ui-components-GrNdJOi1.css.br +0 -0
- package/dist/assets/ui-components-GrNdJOi1.css.gz +0 -0
- package/dist/assets/ui-layout-CF_1bNSv.js +0 -1
- package/dist/assets/ui-layout-CF_1bNSv.js.br +0 -0
- package/dist/assets/ui-layout-CF_1bNSv.js.gz +0 -0
- package/dist/assets/vendor-charts-CSvoW-yB.js.br +0 -0
- package/dist/assets/vendor-charts-CSvoW-yB.js.gz +0 -0
- package/dist/assets/vendor-dndkit-DRGpK6sP.js +0 -5
- package/dist/assets/vendor-dndkit-DRGpK6sP.js.br +0 -0
- package/dist/assets/vendor-dndkit-DRGpK6sP.js.gz +0 -0
- package/dist/assets/vendor-i18n-D5KbMT7w.js +0 -9
- package/dist/assets/vendor-i18n-D5KbMT7w.js.br +0 -0
- package/dist/assets/vendor-i18n-D5KbMT7w.js.gz +0 -0
- package/dist/assets/vendor-icons-CQ8b-fGy.js.br +0 -0
- package/dist/assets/vendor-icons-CQ8b-fGy.js.gz +0 -0
- package/dist/assets/vendor-objectstack-Bifvxvds.js +0 -1
- package/dist/assets/vendor-objectstack-Bifvxvds.js.br +0 -0
- package/dist/assets/vendor-objectstack-Bifvxvds.js.gz +0 -0
- package/dist/assets/vendor-radix-BbeYj_o4.js.br +0 -0
- package/dist/assets/vendor-radix-BbeYj_o4.js.gz +0 -0
- package/dist/assets/vendor-react-Dy_xkBQQ.js +0 -60
- package/dist/assets/vendor-react-Dy_xkBQQ.js.br +0 -0
- package/dist/assets/vendor-react-Dy_xkBQQ.js.gz +0 -0
- package/dist/assets/vendor-ui-utils-h6yAcIi9.js +0 -1
- package/dist/assets/vendor-ui-utils-h6yAcIi9.js.br +0 -0
- package/dist/assets/vendor-ui-utils-h6yAcIi9.js.gz +0 -0
- package/dist/assets/vendor-zod-UZPqlszj.js +0 -39
- package/dist/assets/vendor-zod-UZPqlszj.js.br +0 -0
- package/dist/assets/vendor-zod-UZPqlszj.js.gz +0 -0
- package/dist/index.html.br +0 -0
- package/dist/index.html.gz +0 -0
- package/dist/mockServiceWorker.js.br +0 -0
- package/dist/mockServiceWorker.js.gz +0 -0
- package/dist/stats.html +0 -4949
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import{r as F,j as J,R as x}from"./vendor-react-Dy_xkBQQ.js";class qt{components=new Map;register(e,t,s){const n=s?.namespace?`${s.namespace}:${e}`:e;s?.namespace||console.warn(`Registering component "${e}" without a namespace is deprecated. Please provide a namespace in the meta parameter.
|
|
2
|
-
|
|
3
|
-
Migration:
|
|
4
|
-
// Before (deprecated):
|
|
5
|
-
registry.register('${e}', MyComponent);
|
|
6
|
-
|
|
7
|
-
// After:
|
|
8
|
-
registry.register('${e}', MyComponent, { namespace: 'my-plugin' });
|
|
9
|
-
|
|
10
|
-
See: https://github.com/objectstack-ai/objectui/blob/main/MIGRATION_GUIDE.md`),this.components.has(n),this.components.set(n,{type:n,component:t,...s}),s?.namespace&&!s?.skipFallback&&this.components.set(e,{type:n,component:t,...s})}get(e,t){if(t){const s=`${t}:${e}`;return this.components.get(s)?.component}return this.components.get(e)?.component}getConfig(e,t){if(t){const s=`${t}:${e}`;return this.components.get(s)}return this.components.get(e)}has(e,t){if(t){const s=`${t}:${e}`;return this.components.has(s)}return this.components.has(e)}getAllTypes(){return Array.from(this.components.keys())}getAllConfigs(){return Array.from(this.components.values())}getNamespaceComponents(e){return Array.from(this.components.values()).filter(t=>t.namespace===e)}}const Wt=new qt;function zt(r){return{$eq:"=",$ne:"!=",$gt:">",$gte:">=",$lt:"<",$lte:"<=",$in:"in",$nin:"notin",$notin:"notin",$contains:"contains",$startswith:"startswith",$between:"between"}[r]||null}function Or(r){const e=[];for(const[t,s]of Object.entries(r))if(s!=null)if(typeof s=="object"&&!Array.isArray(s))for(const[n,i]of Object.entries(s)){if(n==="$regex"){console.warn(`[ObjectUI] Warning: $regex operator is not fully supported. Converting to 'contains' which only supports substring matching, not regex patterns. Field: '${t}', Value: ${JSON.stringify(i)}. Consider using $contains or $startswith instead.`),e.push([t,"contains",i]);continue}const o=zt(n);if(o)e.push([t,o,i]);else throw new Error(`[ObjectUI] Unknown filter operator '${n}' for field '${t}'. Supported operators: $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $contains, $startswith, $between. If you need exact object matching, use the value directly without an operator.`)}else e.push([t,"=",s]);return e.length===0?r:e.length===1?e[0]:["and",...e]}class Se{scopes=[];constructor(e={}){this.scopes.push(new Map(Object.entries(e)))}pushScope(e){this.scopes.push(new Map(Object.entries(e)))}popScope(){this.scopes.length>1&&this.scopes.pop()}get(e){const t=e.split("."),s=t[0];for(let n=this.scopes.length-1;n>=0;n--)if(this.scopes[n].has(s)){let i=this.scopes[n].get(s);for(let o=1;o<t.length;o++)if(i&&typeof i=="object")i=i[t[o]];else return;return i}}set(e,t){this.scopes.length>0&&this.scopes[this.scopes.length-1].set(e,t)}has(e){const t=e.split(".")[0];for(let s=this.scopes.length-1;s>=0;s--)if(this.scopes[s].has(t))return!0;return!1}toObject(){const e={};for(const t of this.scopes)for(const[s,n]of t.entries())e[s]=n;return e}createChild(e={}){const t=new Se;return t.scopes=[...this.scopes,new Map(Object.entries(e))],t}}class Yt{cache=new Map;maxSize;constructor(e=1e3){this.maxSize=e}compile(e,t){const s=`${e}::${t.join(",")}`;if(this.cache.has(s)){const o=this.cache.get(s);return o.hitCount++,o}this.cache.size>=this.maxSize&&this.evictLFU();const i={fn:this.compileExpression(e,t),varNames:[...t],expression:e,compiledAt:Date.now(),hitCount:1};return this.cache.set(s,i),i}compileExpression(e,t){return new Function(...t,`"use strict"; return (${e});`)}evictLFU(){let e=null,t=1/0,s=1/0;for(const[n,i]of this.cache.entries())(i.hitCount<s||i.hitCount===s&&i.compiledAt<t)&&(e=n,t=i.compiledAt,s=i.hitCount);e&&this.cache.delete(e)}has(e,t){const s=`${e}::${t.join(",")}`;return this.cache.has(s)}clear(){this.cache.clear()}getStats(){let e=0;const t=[];for(const s of this.cache.values())e+=s.hitCount,t.push({expression:s.expression,hitCount:s.hitCount});return{size:this.cache.size,maxSize:this.maxSize,totalHits:e,entries:t.sort((s,n)=>n.hitCount-s.hitCount)}}}class bt{functions=new Map;constructor(){this.registerDefaults()}register(e,t){this.functions.set(e.toUpperCase(),t)}get(e){return this.functions.get(e.toUpperCase())}has(e){return this.functions.has(e.toUpperCase())}getNames(){return Array.from(this.functions.keys())}toObject(){const e={};for(const[t,s]of this.functions)e[t]=s;return e}registerDefaults(){this.registerAggregationFunctions(),this.registerDateFunctions(),this.registerLogicFunctions(),this.registerStringFunctions(),this.registerStringSearchFunctions(),this.registerStatisticalFunctions()}registerAggregationFunctions(){this.register("SUM",(...e)=>ae(e).reduce((s,n)=>s+n,0)),this.register("AVG",(...e)=>{const t=ae(e);return t.length===0?0:t.reduce((s,n)=>s+n,0)/t.length}),this.register("COUNT",(...e)=>wt(e).filter(s=>s!=null).length),this.register("MIN",(...e)=>{const t=ae(e);return t.length===0?0:Math.min(...t)}),this.register("MAX",(...e)=>{const t=ae(e);return t.length===0?0:Math.max(...t)})}registerDateFunctions(){this.register("TODAY",()=>new Date().toISOString().split("T")[0]),this.register("NOW",()=>new Date().toISOString()),this.register("DATEADD",(e,t,s)=>{const n=new Date(e);if(isNaN(n.getTime()))throw new Error(`DATEADD: Invalid date "${e}"`);switch(String(s).toLowerCase()){case"day":case"days":n.setDate(n.getDate()+t);break;case"month":case"months":n.setMonth(n.getMonth()+t);break;case"year":case"years":n.setFullYear(n.getFullYear()+t);break;case"hour":case"hours":n.setHours(n.getHours()+t);break;case"minute":case"minutes":n.setMinutes(n.getMinutes()+t);break;default:throw new Error(`DATEADD: Unsupported unit "${s}"`)}return n.toISOString()}),this.register("DATEDIFF",(e,t,s)=>{const n=new Date(e),i=new Date(t);if(isNaN(n.getTime()))throw new Error(`DATEDIFF: Invalid date "${e}"`);if(isNaN(i.getTime()))throw new Error(`DATEDIFF: Invalid date "${t}"`);const o=i.getTime()-n.getTime();switch(String(s).toLowerCase()){case"day":case"days":return Math.floor(o/(1e3*60*60*24));case"month":case"months":return(i.getFullYear()-n.getFullYear())*12+(i.getMonth()-n.getMonth());case"year":case"years":return i.getFullYear()-n.getFullYear();case"hour":case"hours":return Math.floor(o/(1e3*60*60));case"minute":case"minutes":return Math.floor(o/(1e3*60));default:throw new Error(`DATEDIFF: Unsupported unit "${s}"`)}}),this.register("DATEFORMAT",(e,t)=>{const s=new Date(e);if(isNaN(s.getTime()))throw new Error(`DATEFORMAT: Invalid date "${e}"`);const n=(i,o=2)=>String(i).padStart(o,"0");return t.replace("YYYY",String(s.getFullYear())).replace("YY",String(s.getFullYear()).slice(-2)).replace("MM",n(s.getMonth()+1)).replace("DD",n(s.getDate())).replace("HH",n(s.getHours())).replace("mm",n(s.getMinutes())).replace("ss",n(s.getSeconds()))})}registerLogicFunctions(){this.register("IF",(e,t,s)=>e?t:s),this.register("AND",(...e)=>e.every(Boolean)),this.register("OR",(...e)=>e.some(Boolean)),this.register("NOT",e=>!e),this.register("SWITCH",(e,...t)=>{for(let s=0;s<t.length-1;s+=2)if(e===t[s])return t[s+1];if(t.length%2===1)return t[t.length-1]})}registerStringFunctions(){this.register("CONCAT",(...e)=>e.map(t=>String(t??"")).join("")),this.register("LEFT",(e,t)=>String(e??"").substring(0,t)),this.register("RIGHT",(e,t)=>{const s=String(e??"");return s.substring(Math.max(0,s.length-t))}),this.register("TRIM",e=>String(e??"").trim()),this.register("UPPER",e=>String(e??"").toUpperCase()),this.register("LOWER",e=>String(e??"").toLowerCase())}registerStringSearchFunctions(){this.register("FIND",(e,t,s)=>String(t??"").indexOf(String(e??""),s??0)),this.register("REPLACE",(e,t,s)=>String(e??"").split(String(t??"")).join(String(s??""))),this.register("SUBSTRING",(e,t,s)=>{const n=String(e??"");return s!==void 0?n.substring(t,t+s):n.substring(t)}),this.register("REGEX",(e,t,s)=>{const n=String(e??"");return new RegExp(t,s).test(n)}),this.register("LEN",e=>String(e??"").length)}registerStatisticalFunctions(){this.register("MEDIAN",(...e)=>{const t=ae(e).sort((n,i)=>n-i);if(t.length===0)return 0;const s=Math.floor(t.length/2);return t.length%2!==0?t[s]:(t[s-1]+t[s])/2}),this.register("STDEV",(...e)=>{const t=ae(e);if(t.length<2)return 0;const s=t.reduce((o,c)=>o+c,0)/t.length,i=t.map(o=>(o-s)**2).reduce((o,c)=>o+c,0)/(t.length-1);return Math.sqrt(i)}),this.register("VARIANCE",(...e)=>{const t=ae(e);if(t.length<2)return 0;const s=t.reduce((i,o)=>i+o,0)/t.length;return t.map(i=>(i-s)**2).reduce((i,o)=>i+o,0)/(t.length-1)}),this.register("PERCENTILE",(e,...t)=>{const s=ae(t).sort((p,V)=>p-V);if(s.length===0)return 0;const i=Math.max(0,Math.min(100,e))/100*(s.length-1),o=Math.floor(i),c=Math.ceil(i);if(o===c)return s[o];const m=i-o;return s[o]+m*(s[c]-s[o])})}}function ae(r){const e=[];for(const t of r)if(Array.isArray(t))e.push(...ae(t));else{const s=Number(t);isNaN(s)||e.push(s)}return e}function wt(r){const e=[];for(const t of r)Array.isArray(t)?e.push(...wt(t)):e.push(t);return e}class be{context;cache;formulas;constructor(e,t,s){e instanceof Se?this.context=e:this.context=new Se(e||{}),this.cache=t||new Yt,this.formulas=s||new bt}evaluate(e,t={}){if(typeof e!="string")return e;const{defaultValue:s,throwOnError:n=!1,sanitize:i=!0}=t;try{if(!e.includes("${"))return e;const c=e.match(/^\$\{([^}]+)\}$/);return c?this.evaluateExpression(c[1].trim(),{sanitize:i}):e.replace(/\$\{([^}]+)\}/g,(m,p)=>{try{const V=this.evaluateExpression(p.trim(),{sanitize:i});return String(V??"")}catch(V){if(n)throw V;return console.warn(`Expression evaluation failed for: ${p}`,V),m}})}catch(o){if(n)throw o;return console.warn(`Failed to evaluate expression: ${e}`,o),s??e}}evaluateExpression(e,t={}){const{sanitize:s=!0}=t;if(!(!e||e.trim()==="")){if(s&&this.isDangerous(e))throw new Error(`Potentially dangerous expression detected: ${e}`);try{const n=this.context.toObject(),o={...this.formulas.toObject(),...n},c=Object.keys(o),m=Object.values(o);return this.cache.compile(e,c).fn(...m)}catch(n){throw new Error(`Failed to evaluate expression "${e}": ${n.message}`)}}}isDangerous(e){return[/eval\s*\(/i,/Function\s*\(/i,/setTimeout\s*\(/i,/setInterval\s*\(/i,/import\s*\(/i,/require\s*\(/i,/process\./i,/global\./i,/window\./i,/document\./i,/__proto__/i,/constructor\s*\(/i,/prototype\./i].some(s=>s.test(e))}evaluateCondition(e,t={}){return typeof e=="boolean"?e:e?!!this.evaluate(e,t):!0}updateContext(e){Object.entries(e).forEach(([t,s])=>{this.context.set(t,s)})}getContext(){return this.context}withContext(e){return new be(this.context.createChild(e),this.cache,this.formulas)}getCacheStats(){return this.cache.getStats()}clearCache(){this.cache.clear()}getFormulas(){return this.formulas}registerFunction(e,t){this.formulas.register(e,t)}}new bt;class xt{handlers=new Map;evaluator;context;confirmHandler;toastHandler;modalHandler;navigationHandler;paramCollectionHandler;constructor(e={}){this.context=e,this.evaluator=new be(e),this.confirmHandler=async t=>window.confirm(t),this.toastHandler=null,this.modalHandler=null,this.navigationHandler=null,this.paramCollectionHandler=null}setConfirmHandler(e){this.confirmHandler=e}setToastHandler(e){this.toastHandler=e}setModalHandler(e){this.modalHandler=e}setNavigationHandler(e){this.navigationHandler=e}setParamCollectionHandler(e){this.paramCollectionHandler=e}registerHandler(e,t){this.handlers.set(e,t)}unregisterHandler(e){this.handlers.delete(e)}async execute(e){try{const t=e.type||e.actionType||e.name||"";if(e.condition&&!this.evaluator.evaluateCondition(e.condition))return{success:!1,error:"Action condition not met"};if(e.disabled&&(typeof e.disabled=="string"?this.evaluator.evaluateCondition(e.disabled):e.disabled))return{success:!1,error:"Action is disabled"};const s=e.confirm?.message||e.confirmText;if(s&&!await this.confirmHandler(this.evaluator.evaluate(s),e.confirm?{title:e.confirm.title,confirmText:e.confirm.confirmText,cancelText:e.confirm.cancelText}:void 0))return{success:!1,error:"Action cancelled by user"};if(e.actionParams&&Array.isArray(e.actionParams)&&e.actionParams.length>0&&this.paramCollectionHandler){const i=await this.paramCollectionHandler(e.actionParams);if(i===null)return{success:!1,error:"Action cancelled by user (params)"};e.params={...e.params||{},...i}}if(t&&this.handlers.has(t)){const o=await this.handlers.get(t)(e,this.context);return await this.handlePostExecution(e,o),o}let n;switch(t){case"script":n=await this.executeScript(e);break;case"url":n=await this.executeUrl(e);break;case"modal":n=await this.executeModal(e);break;case"flow":n=await this.executeFlow(e);break;case"api":n=await this.executeAPI(e);break;case"navigation":n=await this.executeNavigation(e);break;default:e.navigate?n=await this.executeNavigation(e):e.api||e.endpoint?n=await this.executeAPI(e):e.onClick?(await e.onClick(),n={success:!0}):n=await this.executeActionSchema(e)}return await this.handlePostExecution(e,n),n}catch(t){const s={success:!1,error:t.message};return await this.handlePostExecution(e,s),s}}async executeChain(e,t="sequential"){if(e.length===0)return{success:!0};if(t==="parallel"){const n=await Promise.allSettled(e.map(c=>this.execute(c)));if(n.filter(c=>c.status==="rejected"||c.status==="fulfilled"&&!c.value.success).length>0)return{success:!1,error:n.find(m=>m.status==="fulfilled"&&!m.value.success)?.value?.error||"One or more parallel actions failed"};const o=n[n.length-1];return o.status==="fulfilled"?o.value:{success:!1,error:"Action failed"}}let s={success:!0};for(const n of e)if(s=await this.execute(n),!s.success)return s;return s}async handlePostExecution(e,t){if(this.toastHandler){const s=e.toast??{showOnSuccess:!0,showOnError:!0},n=e.toast?.duration;if(t.success&&s.showOnSuccess!==!1){const i=e.successMessage||"Action completed successfully";this.toastHandler(i,{type:"success",duration:n})}if(!t.success&&s.showOnError!==!1&&t.error){const i=e.errorMessage||t.error;this.toastHandler(i,{type:"error",duration:n})}}if(e.refreshAfter&&t.success&&(t.reload=!0),e.chain&&e.chain.length>0&&t.success){const s=await this.executeChain(e.chain,e.chainMode||"sequential");s.success||(t.success=!1,t.error=s.error),s.data&&(t.data=s.data),s.redirect&&(t.redirect=s.redirect),s.reload&&(t.reload=!0)}if(t.success&&e.onSuccess){const s=Array.isArray(e.onSuccess)?e.onSuccess:[e.onSuccess];await this.executeChain(s,"sequential")}if(!t.success&&e.onFailure){const s=Array.isArray(e.onFailure)?e.onFailure:[e.onFailure];await this.executeChain(s,"sequential")}}async executeScript(e){const t=e.execute||e.target;if(!t)return{success:!1,error:"No script provided for script action"};try{return{success:!0,data:this.evaluator.evaluate(`\${${t}}`)}}catch(s){return{success:!1,error:`Script execution failed: ${s.message}`}}}async executeUrl(e){const t=e.target||e.redirect;if(!t)return{success:!1,error:"No URL provided for url action"};const s=this.evaluator.evaluate(t);if(!this.isValidUrl(s))return{success:!1,error:"Invalid URL scheme. Only http://, https://, and relative URLs are allowed."};const n=s.startsWith("http://")||s.startsWith("https://"),i=e.params?.newTab??n;if(this.navigationHandler)return this.navigationHandler(s,{external:n,newTab:i}),{success:!0};if(i)window.open(s,"_blank","noopener,noreferrer");else return{success:!0,redirect:s};return{success:!0}}async executeModal(e){const t=e.modal||e.target||e.params?.schema;return t?this.modalHandler?await this.modalHandler(t,this.context):{success:!0,modal:t}:{success:!1,error:"No modal schema or target provided for modal action"}}async executeFlow(e){const t=e.target||e.name;return t?this.handlers.has("flow")?await this.handlers.get("flow")(e,this.context):{success:!1,error:`Flow handler not registered. Cannot execute flow: ${t}`}:{success:!1,error:"No flow target provided for flow action"}}async executeActionSchema(e){const t={success:!0};if(e.api||e.endpoint){const s=await this.executeAPI(e);if(!s.success)return s;t.data=s.data}return e.onClick&&await e.onClick(),t.reload=e.reload!==!1,t.close=e.close!==!1,e.redirect&&(t.redirect=this.evaluator.evaluate(e.redirect)),t}async executeNavigation(e){const t=e.navigate||e,s=this.evaluator.evaluate(t.to||t.target);if(!this.isValidUrl(s))return{success:!1,error:"Invalid URL scheme. Only http://, https://, and relative URLs are allowed."};const n=t.external||typeof s=="string"&&(s.startsWith("http://")||s.startsWith("https://"));if(this.navigationHandler)return this.navigationHandler(s,{external:n,newTab:t.newTab??n,replace:t.replace}),{success:!0};if(n)window.open(s,"_blank","noopener,noreferrer");else return{success:!0,redirect:s};return{success:!0}}async executeAPI(e){const t=e.api||e.endpoint||e.target;if(!t)return{success:!1,error:"No API endpoint provided"};try{let s,n,i={"Content-Type":"application/json"},o,c="json";if(typeof t=="string")s=t,n=e.method||"POST",o=JSON.stringify(e.params||this.context.data||{});else{const y=t;if(s=y.url,n=y.method||e.method||"POST",i={...i,...y.headers},c=y.responseType||"json",y.queryParams){const _=new URLSearchParams(y.queryParams);s=`${s}${s.includes("?")?"&":"?"}${_.toString()}`}y.body?o=typeof y.body=="string"?y.body:JSON.stringify(y.body):n!=="GET"&&n!=="HEAD"&&(o=JSON.stringify(e.params||this.context.data||{}))}const m={method:n,headers:i};o&&n!=="GET"&&n!=="HEAD"&&(m.body=o);const p=await fetch(s,m);if(!p.ok)throw new Error(`HTTP ${p.status}: ${p.statusText}`);let V;switch(c){case"text":V=await p.text();break;case"blob":V=await p.blob();break;default:V=await p.json()}return{success:!0,data:V}}catch(s){return{success:!1,error:s.message}}}isValidUrl(e){return typeof e=="string"&&(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")||e.startsWith("./"))}updateContext(e){this.context={...this.context,...e},this.evaluator.updateContext(e)}getContext(){return this.context}getEvaluator(){return this.evaluator}}var Gt={};function Ue(){try{const r=typeof globalThis<"u"&&globalThis.OBJECTUI_DEBUG;return r===!0||r==="true"||typeof process<"u"&&Gt?.OBJECTUI_DEBUG==="true"}catch{return!1}}function it(r,e,t){Ue()&&(t!==void 0?console.log(`[ObjectUI Debug][${r}] ${e}`,t):console.log(`[ObjectUI Debug][${r}] ${e}`))}const Re=new Map;function Jt(r){Ue()&&Re.set(r,performance.now())}function Kt(r){if(!Ue())return;const e=Re.get(r);if(e!==void 0){const t=(performance.now()-e).toFixed(2);console.log(`[ObjectUI Debug][perf] ${r}: ${t}ms`),Re.delete(r)}}const Ve=F.createContext(null),Mr=({children:r,dataSource:e,debug:t})=>{const s=F.useMemo(()=>({dataSource:e,debug:t}),[e,t]);return J.jsx(Ve.Provider,{value:s,children:r})},Rr=()=>{const r=F.useContext(Ve);if(!r)throw new Error("useSchemaContext must be used within a SchemaRendererProvider");return r},Nr=r=>{const t=F.useContext(Ve)?.dataSource;return!t||!r?t:r.split(".").reduce((s,n)=>s&&s[n],t)};function Qt(r){if(r!=null)return typeof r=="string"?r:r.defaultValue||r.key}function Xt(r){const e={};return r.ariaLabel&&(e["aria-label"]=Qt(r.ariaLabel)),r.ariaDescribedBy&&(e["aria-describedby"]=r.ariaDescribedBy),r.role&&(e.role=r.role),e}class Zt extends F.Component{state={hasError:!1,error:null};static getDerivedStateFromError(e){return{hasError:!0,error:e}}handleRetry=()=>{this.setState({hasError:!1,error:null})};render(){if(this.state.hasError&&this.state.error){const e=this.state.error;return J.jsxs("div",{className:"p-4 border border-orange-400 rounded bg-orange-50 text-orange-700 my-2",role:"alert",children:[J.jsxs("p",{className:"font-medium",children:["Component",this.props.componentType?` "${this.props.componentType}"`:""," failed to render"]}),J.jsx("p",{className:"text-sm mt-1",children:e.message}),!1,J.jsx("button",{onClick:this.handleRetry,className:"mt-2 text-sm underline hover:no-underline",children:"Retry"})]})}return this.props.children}}const er=F.forwardRef(({schema:r,...e},t)=>{const n=F.useContext(Ve)?.dataSource||{},i=F.useMemo(()=>{if(!r||typeof r=="string")return r;const A=new be({data:n}),C={...r};if(C.properties&&Object.assign(C,C.properties),typeof C.content=="string"&&(C.content=A.evaluate(C.content)),C.props){const j={...C.props};for(const[Z,ee]of Object.entries(j))j[Z]=A.evaluate(ee);C.props=j}return C},[r,n]);if(!i)return null;if(typeof i=="string")return J.jsx(J.Fragment,{children:i});it("schema","Rendering schema node",{type:i.type,id:i.id});const o=Wt.get(i.type);if(!o)return it("schema","Component not found in registry",{type:i.type}),J.jsxs("div",{className:"p-4 border border-red-500 rounded text-red-500 bg-red-50 my-2",role:"alert",children:[J.jsxs("p",{className:"font-medium",children:["Unknown component type: ",J.jsx("strong",{children:i.type})]}),!1,J.jsx("pre",{className:"text-xs mt-2 overflow-auto",children:JSON.stringify(i,null,2)})]});const{type:c,children:m,body:p,schema:V,visible:y,visibleOn:_,hidden:v,hiddenOn:R,disabled:E,disabledOn:S,...D}=i,w=Xt(i);Jt(`render:${i.type}:${i.id??"anon"}`);const N=J.jsx(Zt,{componentType:i.type,children:x.createElement(o,{schema:i,...D,...i.props||{},...w,className:i.className,"data-obj-id":i.id,"data-obj-type":i.type,...e})});return Kt(`render:${i.type}:${i.id??"anon"}`),N});er.displayName="SchemaRenderer";function $r(r,e={}){return F.useMemo(()=>new be(e).evaluateCondition(r),[r,e])}function Ir(r={}){const e="context"in r?r:{context:r},{context:t={},onConfirm:s,onToast:n,onModal:i,onNavigate:o}=e,[c,m]=F.useState(!1),[p,V]=F.useState(null),[y,_]=F.useState(null),v=F.useMemo(()=>{const S=new xt(t);return s&&S.setConfirmHandler(s),n&&S.setToastHandler(n),i&&S.setModalHandler(i),o&&S.setNavigationHandler(o),S},[JSON.stringify(t)]),R=F.useCallback(async S=>{m(!0),V(null),_(null);try{const D=await v.execute(S);return _(D),D.success||V(D.error||"Action failed"),D}catch(D){const w=D.message;V(w);const N={success:!1,error:w};return _(N),N}finally{m(!1)}},[v]),E=F.useCallback(S=>{v.updateContext(S)},[v]);return{execute:R,loading:c,error:p,result:y,updateContext:E,runner:v}}function Ur(r){const{navigation:e,objectName:t,onNavigate:s,onRowClick:n}=r,[i,o]=F.useState(!1),[c,m]=F.useState(null),p=e?.mode??"page",V=e?.width,y=p==="drawer"||p==="modal"||p==="split"||p==="popover",_=F.useCallback(()=>{o(!1),m(null)},[]),v=F.useCallback(E=>{m(E),o(!0)},[]),R=F.useCallback(E=>{if(n){n(E);return}if(!e){const S=E._id||E.id;s&&S!=null&&s(S,"view");return}if(!(p==="none"||e.preventNavigation)){if(p==="new_window"||e.openNewTab){const S=E._id||E.id,D=t?`/${t}/${S}`:`/${S}`;window.open(D,"_blank");return}if(p==="page"){const S=E._id||E.id;s&&S!=null&&s(S,"view");return}if(y){m(E),o(!0);return}}},[n,e,p,t,s,y]);return F.useMemo(()=>({isOpen:i,selectedRecord:c,mode:p,close:_,open:v,setIsOpen:o,handleClick:R,width:V,isOverlay:y}),[i,c,p,_,v,R,V,y])}const tr=F.createContext(null);function at(r){if(!r||r.length===0)return{};const e={};for(const t of r)if(t.defaultValue!==void 0)e[t.name]=t.defaultValue;else switch(t.type){case"number":e[t.name]=0;break;case"boolean":e[t.name]=!1;break;case"object":e[t.name]={};break;case"array":e[t.name]=[];break;case"string":default:e[t.name]="";break}return e}const rr=({definitions:r,children:e})=>{const[t,s]=F.useState(()=>at(r)),n=F.useCallback((m,p)=>{s(V=>({...V,[m]:p}))},[]),i=F.useCallback(m=>{s(p=>({...p,...m}))},[]),o=F.useCallback(()=>{s(at(r))},[r]),c=F.useMemo(()=>({variables:t,setVariable:n,setVariables:i,resetVariables:o}),[t,n,i,o]);return J.jsx(tr.Provider,{value:c,children:e})};rr.displayName="PageVariablesProvider";F.createContext(null);function sr(r){return typeof window>"u"?()=>{}:(window.addEventListener("online",r),window.addEventListener("offline",r),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",r)})}function nr(){return typeof navigator<"u"?navigator.onLine:!0}function ir(){return!0}const St="objectui-offline-queue";function ar(){if(typeof localStorage>"u")return[];try{const r=localStorage.getItem(St);return r?JSON.parse(r):[]}catch{return[]}}function or(r){if(!(typeof localStorage>"u"))try{localStorage.setItem(St,JSON.stringify(r))}catch{}}let ot=0;function ur(){return ot+=1,`mut_${Date.now()}_${ot}`}const ye={enabled:!0,strategy:"network_first",offlineIndicator:!0,offlineMessage:"You are currently offline. Changes will be synced when reconnected.",queueMaxSize:100};function Pr(r={}){const{enabled:e=ye.enabled,strategy:t=ye.strategy,offlineIndicator:s=ye.offlineIndicator,offlineMessage:n=ye.offlineMessage,queueMaxSize:i=ye.queueMaxSize,sync:o}=r,c=F.useSyncExternalStore(sr,nr,ir),[m,p]=F.useState(ar),[V,y]=F.useState("idle"),_=F.useRef(o);_.current=o,F.useEffect(()=>{or(m)},[m]),F.useEffect(()=>{e&&(c?V==="offline"&&y("idle"):y("offline"))},[c,e,V]);const v=F.useCallback(S=>{e&&p(D=>{const w={...S,id:ur(),timestamp:Date.now()},N=[...D,w];return N.length>i?N.slice(N.length-i):N})},[e,i]),R=F.useCallback(()=>{p([])},[]),E=F.useCallback(async()=>{if(!(!e||m.length===0)){y("syncing");try{const S=_.current?.batchSize??m.length,D=m.slice(0,S);await new Promise(w=>setTimeout(w,0)),p(w=>w.filter(N=>!D.some(A=>A.id===N.id))),y("idle")}catch{y("error")}}},[e,m]);return F.useEffect(()=>{if(!e||!c||m.length===0)return;const S=setTimeout(()=>{E()},100);return()=>clearTimeout(S)},[c,e]),F.useMemo(()=>({isOnline:c,enabled:e,syncState:V,strategy:t,pendingCount:m.length,queueMutation:v,sync:E,clearQueue:R,showIndicator:s&&!c,offlineMessage:n}),[c,e,V,t,m.length,v,E,R,s,n])}const lr=F.createContext(null);function Lr(){const r=F.useContext(lr);if(!r){const e=new xt;return{execute:t=>e.execute(t),executeChain:(t,s)=>e.executeChain(t,s),loading:!1,error:null,result:null,runner:e,updateContext:t=>e.updateContext(t)}}return r}F.createContext(null);const _t=F.createContext(null);function Hr(){const r=F.useContext(_t);if(!r)throw new Error("useDnd must be used within a <DndProvider>. Wrap your app with <DndProvider> to use the drag and drop system.");return r}function jr(){return F.useContext(_t)!==null}var we=r=>r.type==="checkbox",le=r=>r instanceof Date,Y=r=>r==null;const Ct=r=>typeof r=="object";var L=r=>!Y(r)&&!Array.isArray(r)&&Ct(r)&&!le(r),Ft=r=>L(r)&&r.target?we(r.target)?r.target.checked:r.target.value:r,cr=r=>r.substring(0,r.search(/\.\d+(\.|$)/))||r,Vt=(r,e)=>r.has(cr(e)),dr=r=>{const e=r.constructor&&r.constructor.prototype;return L(e)&&e.hasOwnProperty("isPrototypeOf")},Pe=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function U(r){if(r instanceof Date)return new Date(r);const e=typeof FileList<"u"&&r instanceof FileList;if(Pe&&(r instanceof Blob||e))return r;const t=Array.isArray(r);if(!t&&!(L(r)&&dr(r)))return r;const s=t?[]:Object.create(Object.getPrototypeOf(r));for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&(s[n]=U(r[n]));return s}var Ae=r=>/^\w*$/.test(r),I=r=>r===void 0,Le=r=>Array.isArray(r)?r.filter(Boolean):[],He=r=>Le(r.replace(/["|']|\]/g,"").split(/\.|\[/)),h=(r,e,t)=>{if(!e||!L(r))return t;const s=(Ae(e)?[e]:He(e)).reduce((n,i)=>Y(n)?n:n[i],r);return I(s)||s===r?I(r[e])?t:r[e]:s},K=r=>typeof r=="boolean",z=r=>typeof r=="function",$=(r,e,t)=>{let s=-1;const n=Ae(e)?[e]:He(e),i=n.length,o=i-1;for(;++s<i;){const c=n[s];let m=t;if(s!==o){const p=r[c];m=L(p)||Array.isArray(p)?p:isNaN(+n[s+1])?{}:[]}if(c==="__proto__"||c==="constructor"||c==="prototype")return;r[c]=m,r=r[c]}};const _e={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},re={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ie={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},je=x.createContext(null);je.displayName="HookFormControlContext";const Be=()=>x.useContext(je);var At=(r,e,t,s=!0)=>{const n={defaultValues:e._defaultValues};for(const i in r)Object.defineProperty(n,i,{get:()=>{const o=i;return e._proxyFormState[o]!==re.all&&(e._proxyFormState[o]=!s||re.all),t&&(t[o]=!0),r[o]}});return n};const qe=typeof window<"u"?x.useLayoutEffect:x.useEffect;function fr(r){const e=Be(),{control:t=e,disabled:s,name:n,exact:i}=r||{},[o,c]=x.useState(t._formState),m=x.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return qe(()=>t._subscribe({name:n,formState:m.current,exact:i,callback:p=>{!s&&c({...t._formState,...p})}}),[n,s,i]),x.useEffect(()=>{m.current.isValid&&t._setValid(!0)},[t]),x.useMemo(()=>At(o,t,m.current,!1),[o,t])}var Q=r=>typeof r=="string",Ne=(r,e,t,s,n)=>Q(r)?(s&&e.watch.add(r),h(t,r,n)):Array.isArray(r)?r.map(i=>(s&&e.watch.add(i),h(t,i))):(s&&(e.watchAll=!0),t),$e=r=>Y(r)||!Ct(r);function se(r,e,t=new WeakSet){if($e(r)||$e(e))return Object.is(r,e);if(le(r)&&le(e))return Object.is(r.getTime(),e.getTime());const s=Object.keys(r),n=Object.keys(e);if(s.length!==n.length)return!1;if(t.has(r)||t.has(e))return!0;t.add(r),t.add(e);for(const i of s){const o=r[i];if(!n.includes(i))return!1;if(i!=="ref"){const c=e[i];if(le(o)&&le(c)||L(o)&&L(c)||Array.isArray(o)&&Array.isArray(c)?!se(o,c,t):!Object.is(o,c))return!1}}return!0}function hr(r){const e=Be(),{control:t=e,name:s,defaultValue:n,disabled:i,exact:o,compute:c}=r||{},m=x.useRef(n),p=x.useRef(c),V=x.useRef(void 0),y=x.useRef(t),_=x.useRef(s);p.current=c;const[v,R]=x.useState(()=>{const A=t._getWatch(s,m.current);return p.current?p.current(A):A}),E=x.useCallback(A=>{const C=Ne(s,t._names,A||t._formValues,!1,m.current);return p.current?p.current(C):C},[t._formValues,t._names,s]),S=x.useCallback(A=>{if(!i){const C=Ne(s,t._names,A||t._formValues,!1,m.current);if(p.current){const j=p.current(C);se(j,V.current)||(R(j),V.current=j)}else R(C)}},[t._formValues,t._names,i,s]);qe(()=>((y.current!==t||!se(_.current,s))&&(y.current=t,_.current=s,S()),t._subscribe({name:s,formState:{values:!0},exact:o,callback:A=>{S(A.values)}})),[t,o,s,S]),x.useEffect(()=>t._removeUnmounted());const D=y.current!==t,w=_.current,N=x.useMemo(()=>{if(i)return null;const A=!D&&!se(w,s);return D||A?E():null},[i,D,s,w,E]);return N!==null?N:v}function gr(r){const e=Be(),{name:t,disabled:s,control:n=e,shouldUnregister:i,defaultValue:o,exact:c=!0}=r,m=Vt(n._names.array,t),p=x.useMemo(()=>h(n._formValues,t,h(n._defaultValues,t,o)),[n,t,o]),V=hr({control:n,name:t,defaultValue:p,exact:c}),y=fr({control:n,name:t,exact:c}),_=x.useRef(r),v=x.useRef(void 0),R=x.useRef(n.register(t,{...r.rules,value:V,...K(r.disabled)?{disabled:r.disabled}:{}}));_.current=r;const E=x.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!h(y.errors,t)},isDirty:{enumerable:!0,get:()=>!!h(y.dirtyFields,t)},isTouched:{enumerable:!0,get:()=>!!h(y.touchedFields,t)},isValidating:{enumerable:!0,get:()=>!!h(y.validatingFields,t)},error:{enumerable:!0,get:()=>h(y.errors,t)}}),[y,t]),S=x.useCallback(A=>R.current.onChange({target:{value:Ft(A),name:t},type:_e.CHANGE}),[t]),D=x.useCallback(()=>R.current.onBlur({target:{value:h(n._formValues,t),name:t},type:_e.BLUR}),[t,n._formValues]),w=x.useCallback(A=>{const C=h(n._fields,t);C&&C._f&&A&&(C._f.ref={focus:()=>z(A.focus)&&A.focus(),select:()=>z(A.select)&&A.select(),setCustomValidity:j=>z(A.setCustomValidity)&&A.setCustomValidity(j),reportValidity:()=>z(A.reportValidity)&&A.reportValidity()})},[n._fields,t]),N=x.useMemo(()=>({name:t,value:V,...K(s)||y.disabled?{disabled:y.disabled||s}:{},onChange:S,onBlur:D,ref:w}),[t,s,y.disabled,S,D,w,V]);return x.useEffect(()=>{const A=n._options.shouldUnregister||i,C=v.current;C&&C!==t&&!m&&n.unregister(C),n.register(t,{..._.current.rules,...K(_.current.disabled)?{disabled:_.current.disabled}:{}});const j=(Z,ee)=>{const ne=h(n._fields,Z);ne&&ne._f&&(ne._f.mount=ee)};if(j(t,!0),A){const Z=U(h(n._options.defaultValues,t,_.current.defaultValue));$(n._defaultValues,t,Z),I(h(n._formValues,t))&&$(n._formValues,t,Z)}return!m&&n.register(t),v.current=t,()=>{(m?A&&!n._state.action:A)?n.unregister(t):j(t,!1)}},[t,n,m,i]),x.useEffect(()=>{n._setDisabledField({disabled:s,name:t})},[s,t,n]),x.useMemo(()=>({field:N,formState:y,fieldState:E}),[N,y,E])}const Br=r=>r.render(gr(r)),We=x.createContext(null);We.displayName="HookFormContext";const qr=()=>x.useContext(We),Wr=r=>{const{children:e,watch:t,getValues:s,getFieldState:n,setError:i,clearErrors:o,setValue:c,trigger:m,formState:p,resetField:V,reset:y,handleSubmit:_,unregister:v,control:R,register:E,setFocus:S,subscribe:D}=r;return x.createElement(We.Provider,{value:x.useMemo(()=>({watch:t,getValues:s,getFieldState:n,setError:i,clearErrors:o,setValue:c,trigger:m,formState:p,resetField:V,reset:y,handleSubmit:_,unregister:v,control:R,register:E,setFocus:S,subscribe:D}),[o,R,p,n,s,_,E,y,V,i,S,c,D,m,v,t])},x.createElement(je.Provider,{value:R},e))};var yr=(r,e,t,s,n)=>e?{...t[r],types:{...t[r]&&t[r].types?t[r].types:{},[s]:n||!0}}:{},pe=r=>Array.isArray(r)?r:[r],ut=()=>{let r=[];return{get observers(){return r},next:n=>{for(const i of r)i.next&&i.next(n)},subscribe:n=>(r.push(n),{unsubscribe:()=>{r=r.filter(i=>i!==n)}}),unsubscribe:()=>{r=[]}}};function Et(r,e){const t={};for(const s in r)if(r.hasOwnProperty(s)){const n=r[s],i=e[s];if(n&&L(n)&&i){const o=Et(n,i);L(o)&&(t[s]=o)}else r[s]&&(t[s]=i)}return t}var W=r=>L(r)&&!Object.keys(r).length,ze=r=>r.type==="file",Ce=r=>{if(!Pe)return!1;const e=r?r.ownerDocument:0;return r instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},Dt=r=>r.type==="select-multiple",Ye=r=>r.type==="radio",mr=r=>Ye(r)||we(r),Me=r=>Ce(r)&&r.isConnected;function pr(r,e){const t=e.slice(0,-1).length;let s=0;for(;s<t;)r=I(r)?s++:r[e[s++]];return r}function vr(r){for(const e in r)if(r.hasOwnProperty(e)&&!I(r[e]))return!1;return!0}function P(r,e){const t=Array.isArray(e)?e:Ae(e)?[e]:He(e),s=t.length===1?r:pr(r,t),n=t.length-1,i=t[n];return s&&delete s[i],n!==0&&(L(s)&&W(s)||Array.isArray(s)&&vr(s))&&P(r,t.slice(0,-1)),r}var br=r=>{for(const e in r)if(z(r[e]))return!0;return!1};function kt(r){return Array.isArray(r)||L(r)&&!br(r)}function Ie(r,e={}){for(const t in r){const s=r[t];kt(s)?(e[t]=Array.isArray(s)?[]:{},Ie(s,e[t])):I(s)||(e[t]=!0)}return e}function de(r,e,t){t||(t=Ie(e));for(const s in r){const n=r[s];if(kt(n))I(e)||$e(t[s])?t[s]=Ie(n,Array.isArray(n)?[]:{}):de(n,Y(e)?{}:e[s],t[s]);else{const i=e[s];t[s]=!se(n,i)}}return t}const lt={value:!1,isValid:!1},ct={value:!0,isValid:!0};var Tt=r=>{if(Array.isArray(r)){if(r.length>1){const e=r.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:e,isValid:!!e.length}}return r[0].checked&&!r[0].disabled?r[0].attributes&&!I(r[0].attributes.value)?I(r[0].value)||r[0].value===""?ct:{value:r[0].value,isValid:!0}:ct:lt}return lt},Ot=(r,{valueAsNumber:e,valueAsDate:t,setValueAs:s})=>I(r)?r:e?r===""?NaN:r&&+r:t&&Q(r)?new Date(r):s?s(r):r;const dt={isValid:!1,value:null};var Mt=r=>Array.isArray(r)?r.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,dt):dt;function ft(r){const e=r.ref;return ze(e)?e.files:Ye(e)?Mt(r.refs).value:Dt(e)?[...e.selectedOptions].map(({value:t})=>t):we(e)?Tt(r.refs).value:Ot(I(e.value)?r.ref.value:e.value,r)}var wr=(r,e,t,s)=>{const n={};for(const i of r){const o=h(e,i);o&&$(n,i,o._f)}return{criteriaMode:t,names:[...r],fields:n,shouldUseNativeValidation:s}},Fe=r=>r instanceof RegExp,me=r=>I(r)?r:Fe(r)?r.source:L(r)?Fe(r.value)?r.value.source:r.value:r,ht=r=>({isOnSubmit:!r||r===re.onSubmit,isOnBlur:r===re.onBlur,isOnChange:r===re.onChange,isOnAll:r===re.all,isOnTouch:r===re.onTouched});const gt="AsyncFunction";var xr=r=>!!r&&!!r.validate&&!!(z(r.validate)&&r.validate.constructor.name===gt||L(r.validate)&&Object.values(r.validate).find(e=>e.constructor.name===gt)),Sr=r=>r.mount&&(r.required||r.min||r.max||r.maxLength||r.minLength||r.pattern||r.validate),yt=(r,e,t)=>!t&&(e.watchAll||e.watch.has(r)||[...e.watch].some(s=>r.startsWith(s)&&/^\.\w+/.test(r.slice(s.length))));const ve=(r,e,t,s)=>{for(const n of t||Object.keys(r)){const i=h(r,n);if(i){const{_f:o,...c}=i;if(o){if(o.refs&&o.refs[0]&&e(o.refs[0],n)&&!s)return!0;if(o.ref&&e(o.ref,o.name)&&!s)return!0;if(ve(c,e))break}else if(L(c)&&ve(c,e))break}}};function mt(r,e,t){const s=h(r,t);if(s||Ae(t))return{error:s,name:t};const n=t.split(".");for(;n.length;){const i=n.join("."),o=h(e,i),c=h(r,i);if(o&&!Array.isArray(o)&&t!==i)return{name:t};if(c&&c.type)return{name:i,error:c};if(c&&c.root&&c.root.type)return{name:`${i}.root`,error:c.root};n.pop()}return{name:t}}var _r=(r,e,t,s)=>{t(r);const{name:n,...i}=r;return W(i)||Object.keys(i).length>=Object.keys(e).length||Object.keys(i).find(o=>e[o]===(!s||re.all))},Cr=(r,e,t)=>!r||!e||r===e||pe(r).some(s=>s&&(t?s===e:s.startsWith(e)||e.startsWith(s))),Fr=(r,e,t,s,n)=>n.isOnAll?!1:!t&&n.isOnTouch?!(e||r):(t?s.isOnBlur:n.isOnBlur)?!r:(t?s.isOnChange:n.isOnChange)?r:!0,Vr=(r,e)=>!Le(h(r,e)).length&&P(r,e),Ar=(r,e,t)=>{const s=pe(h(r,t));return $(s,"root",e[t]),$(r,t,s),r};function pt(r,e,t="validate"){if(Q(r)||Array.isArray(r)&&r.every(Q)||K(r)&&!r)return{type:t,message:Q(r)?r:"",ref:e}}var ce=r=>L(r)&&!Fe(r)?r:{value:r,message:""},vt=async(r,e,t,s,n,i)=>{const{ref:o,refs:c,required:m,maxLength:p,minLength:V,min:y,max:_,pattern:v,validate:R,name:E,valueAsNumber:S,mount:D}=r._f,w=h(t,E);if(!D||e.has(E))return{};const N=c?c[0]:o,A=k=>{n&&N.reportValidity&&(N.setCustomValidity(K(k)?"":k||""),N.reportValidity())},C={},j=Ye(o),Z=we(o),ee=j||Z,ne=(S||ze(o))&&I(o.value)&&I(w)||Ce(o)&&o.value===""||w===""||Array.isArray(w)&&!w.length,X=yr.bind(null,E,s,C),xe=(k,T,H,B=ie.maxLength,te=ie.minLength)=>{const G=k?T:H;C[E]={type:k?B:te,message:G,ref:o,...X(k?B:te,G)}};if(i?!Array.isArray(w)||!w.length:m&&(!ee&&(ne||Y(w))||K(w)&&!w||Z&&!Tt(c).isValid||j&&!Mt(c).isValid)){const{value:k,message:T}=Q(m)?{value:!!m,message:m}:ce(m);if(k&&(C[E]={type:ie.required,message:T,ref:N,...X(ie.required,T)},!s))return A(T),C}if(!ne&&(!Y(y)||!Y(_))){let k,T;const H=ce(_),B=ce(y);if(!Y(w)&&!isNaN(w)){const te=o.valueAsNumber||w&&+w;Y(H.value)||(k=te>H.value),Y(B.value)||(T=te<B.value)}else{const te=o.valueAsDate||new Date(w),G=ge=>new Date(new Date().toDateString()+" "+ge),fe=o.type=="time",he=o.type=="week";Q(H.value)&&w&&(k=fe?G(w)>G(H.value):he?w>H.value:te>new Date(H.value)),Q(B.value)&&w&&(T=fe?G(w)<G(B.value):he?w<B.value:te<new Date(B.value))}if((k||T)&&(xe(!!k,H.message,B.message,ie.max,ie.min),!s))return A(C[E].message),C}if((p||V)&&!ne&&(Q(w)||i&&Array.isArray(w))){const k=ce(p),T=ce(V),H=!Y(k.value)&&w.length>+k.value,B=!Y(T.value)&&w.length<+T.value;if((H||B)&&(xe(H,k.message,T.message),!s))return A(C[E].message),C}if(v&&!ne&&Q(w)){const{value:k,message:T}=ce(v);if(Fe(k)&&!w.match(k)&&(C[E]={type:ie.pattern,message:T,ref:o,...X(ie.pattern,T)},!s))return A(T),C}if(R){if(z(R)){const k=await R(w,t),T=pt(k,N);if(T&&(C[E]={...T,...X(ie.validate,T.message)},!s))return A(T.message),C}else if(L(R)){let k={};for(const T in R){if(!W(k)&&!s)break;const H=pt(await R[T](w,t),N,T);H&&(k={...H,...X(T,H.message)},A(H.message),s&&(C[E]=k))}if(!W(k)&&(C[E]={ref:N,...k},!s))return C}}return A(!0),C};const Er={mode:re.onSubmit,reValidateMode:re.onChange,shouldFocusError:!0};function Dr(r={}){let e={...Er,...r},t={submitCount:0,isDirty:!1,isReady:!1,isLoading:z(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},s={},n=L(e.defaultValues)||L(e.values)?U(e.defaultValues||e.values)||{}:{},i=e.shouldUnregister?{}:U(n),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},c={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},m,p=0;const V={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},y={...V};let _={...y};const v={array:ut(),state:ut()},R=e.criteriaMode===re.all,E=a=>u=>{clearTimeout(p),p=setTimeout(a,u)},S=async a=>{if(!o.keepIsValid&&!e.disabled&&(y.isValid||_.isValid||a)){let u;e.resolver?(u=W((await ee()).errors),D()):u=await X(s,!0),u!==t.isValid&&v.state.next({isValid:u})}},D=(a,u)=>{!e.disabled&&(y.isValidating||y.validatingFields||_.isValidating||_.validatingFields)&&((a||Array.from(c.mount)).forEach(l=>{l&&(u?$(t.validatingFields,l,u):P(t.validatingFields,l))}),v.state.next({validatingFields:t.validatingFields,isValidating:!W(t.validatingFields)}))},w=(a,u=[],l,g,f=!0,d=!0)=>{if(g&&l&&!e.disabled){if(o.action=!0,d&&Array.isArray(h(s,a))){const b=l(h(s,a),g.argA,g.argB);f&&$(s,a,b)}if(d&&Array.isArray(h(t.errors,a))){const b=l(h(t.errors,a),g.argA,g.argB);f&&$(t.errors,a,b),Vr(t.errors,a)}if((y.touchedFields||_.touchedFields)&&d&&Array.isArray(h(t.touchedFields,a))){const b=l(h(t.touchedFields,a),g.argA,g.argB);f&&$(t.touchedFields,a,b)}(y.dirtyFields||_.dirtyFields)&&(t.dirtyFields=de(n,i)),v.state.next({name:a,isDirty:k(a,u),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else $(i,a,u)},N=(a,u)=>{$(t.errors,a,u),v.state.next({errors:t.errors})},A=a=>{t.errors=a,v.state.next({errors:t.errors,isValid:!1})},C=(a,u,l,g)=>{const f=h(s,a);if(f){const d=h(i,a,I(l)?h(n,a):l);I(d)||g&&g.defaultChecked||u?$(i,a,u?d:ft(f._f)):B(a,d),o.mount&&!o.action&&S()}},j=(a,u,l,g,f)=>{let d=!1,b=!1;const O={name:a};if(!e.disabled){if(!l||g){(y.isDirty||_.isDirty)&&(b=t.isDirty,t.isDirty=O.isDirty=k(),d=b!==O.isDirty);const M=se(h(n,a),u);b=!!h(t.dirtyFields,a),M?P(t.dirtyFields,a):$(t.dirtyFields,a,!0),O.dirtyFields=t.dirtyFields,d=d||(y.dirtyFields||_.dirtyFields)&&b!==!M}if(l){const M=h(t.touchedFields,a);M||($(t.touchedFields,a,l),O.touchedFields=t.touchedFields,d=d||(y.touchedFields||_.touchedFields)&&M!==l)}d&&f&&v.state.next(O)}return d?O:{}},Z=(a,u,l,g)=>{const f=h(t.errors,a),d=(y.isValid||_.isValid)&&K(u)&&t.isValid!==u;if(e.delayError&&l?(m=E(()=>N(a,l)),m(e.delayError)):(clearTimeout(p),m=null,l?$(t.errors,a,l):P(t.errors,a)),(l?!se(f,l):f)||!W(g)||d){const b={...g,...d&&K(u)?{isValid:u}:{},errors:t.errors,name:a};t={...t,...b},v.state.next(b)}},ee=async a=>(D(a,!0),await e.resolver(i,e.context,wr(a||c.mount,s,e.criteriaMode,e.shouldUseNativeValidation))),ne=async a=>{const{errors:u}=await ee(a);if(D(a),a)for(const l of a){const g=h(u,l);g?$(t.errors,l,g):P(t.errors,l)}else t.errors=u;return u},X=async(a,u,l={valid:!0})=>{for(const g in a){const f=a[g];if(f){const{_f:d,...b}=f;if(d){const O=c.array.has(d.name),M=f._f&&xr(f._f);M&&y.validatingFields&&D([d.name],!0);const q=await vt(f,c.disabled,i,R,e.shouldUseNativeValidation&&!u,O);if(M&&y.validatingFields&&D([d.name]),q[d.name]&&(l.valid=!1,u||r.shouldUseNativeValidation))break;!u&&(h(q,d.name)?O?Ar(t.errors,q,d.name):$(t.errors,d.name,q[d.name]):P(t.errors,d.name))}!W(b)&&await X(b,u,l)}}return l.valid},xe=()=>{for(const a of c.unMount){const u=h(s,a);u&&(u._f.refs?u._f.refs.every(l=>!Me(l)):!Me(u._f.ref))&&Ee(a)}c.unMount=new Set},k=(a,u)=>!e.disabled&&(a&&u&&$(i,a,u),!se(Ge(),n)),T=(a,u,l)=>Ne(a,c,{...o.mount?i:I(u)?n:Q(a)?{[a]:u}:u},l,u),H=a=>Le(h(o.mount?i:n,a,e.shouldUnregister?h(n,a,[]):[])),B=(a,u,l={})=>{const g=h(s,a);let f=u;if(g){const d=g._f;d&&(!d.disabled&&$(i,a,Ot(u,d)),f=Ce(d.ref)&&Y(u)?"":u,Dt(d.ref)?[...d.ref.options].forEach(b=>b.selected=f.includes(b.value)):d.refs?we(d.ref)?d.refs.forEach(b=>{(!b.defaultChecked||!b.disabled)&&(Array.isArray(f)?b.checked=!!f.find(O=>O===b.value):b.checked=f===b.value||!!f)}):d.refs.forEach(b=>b.checked=b.value===f):ze(d.ref)?d.ref.value="":(d.ref.value=f,d.ref.type||v.state.next({name:a,values:U(i)})))}(l.shouldDirty||l.shouldTouch)&&j(a,f,l.shouldTouch,l.shouldDirty,!0),l.shouldValidate&&ge(a)},te=(a,u,l)=>{for(const g in u){if(!u.hasOwnProperty(g))return;const f=u[g],d=a+"."+g,b=h(s,d);(c.array.has(a)||L(f)||b&&!b._f)&&!le(f)?te(d,f,l):B(d,f,l)}},G=(a,u,l={})=>{const g=h(s,a),f=c.array.has(a),d=U(u);$(i,a,d),f?(v.array.next({name:a,values:U(i)}),(y.isDirty||y.dirtyFields||_.isDirty||_.dirtyFields)&&l.shouldDirty&&v.state.next({name:a,dirtyFields:de(n,i),isDirty:k(a,d)})):g&&!g._f&&!Y(d)?te(a,d,l):B(a,d,l),yt(a,c)?v.state.next({...t,name:a,values:U(i)}):v.state.next({name:o.mount?a:void 0,values:U(i)})},fe=async a=>{o.mount=!0;const u=a.target;let l=u.name,g=!0;const f=h(s,l),d=M=>{g=Number.isNaN(M)||le(M)&&isNaN(M.getTime())||se(M,h(i,l,M))},b=ht(e.mode),O=ht(e.reValidateMode);if(f){let M,q;const ue=u.type?ft(f._f):Ft(a),oe=a.type===_e.BLUR||a.type===_e.FOCUS_OUT,Ht=!Sr(f._f)&&!e.resolver&&!h(t.errors,l)&&!f._f.deps||Fr(oe,h(t.touchedFields,l),t.isSubmitted,O,b),Te=yt(l,c,oe);$(i,l,ue),oe?(!u||!u.readOnly)&&(f._f.onBlur&&f._f.onBlur(a),m&&m(0)):f._f.onChange&&f._f.onChange(a);const Oe=j(l,ue,oe),jt=!W(Oe)||Te;if(!oe&&v.state.next({name:l,type:a.type,values:U(i)}),Ht)return(y.isValid||_.isValid)&&(e.mode==="onBlur"?oe&&S():oe||S()),jt&&v.state.next({name:l,...Te?{}:Oe});if(!oe&&Te&&v.state.next({...t}),e.resolver){const{errors:st}=await ee([l]);if(D([l]),d(ue),g){const Bt=mt(t.errors,s,l),nt=mt(st,s,Bt.name||l);M=nt.error,l=nt.name,q=W(st)}}else D([l],!0),M=(await vt(f,c.disabled,i,R,e.shouldUseNativeValidation))[l],D([l]),d(ue),g&&(M?q=!1:(y.isValid||_.isValid)&&(q=await X(s,!0)));g&&(f._f.deps&&(!Array.isArray(f._f.deps)||f._f.deps.length>0)&&ge(f._f.deps),Z(l,q,M,Oe))}},he=(a,u)=>{if(h(t.errors,u)&&a.focus)return a.focus(),1},ge=async(a,u={})=>{let l,g;const f=pe(a);if(e.resolver){const d=await ne(I(a)?a:f);l=W(d),g=a?!f.some(b=>h(d,b)):l}else a?(g=(await Promise.all(f.map(async d=>{const b=h(s,d);return await X(b&&b._f?{[d]:b}:b)}))).every(Boolean),!(!g&&!t.isValid)&&S()):g=l=await X(s);return v.state.next({...!Q(a)||(y.isValid||_.isValid)&&l!==t.isValid?{}:{name:a},...e.resolver||!a?{isValid:l}:{},errors:t.errors}),u.shouldFocus&&!g&&ve(s,he,a?f:c.mount),g},Ge=(a,u)=>{let l={...o.mount?i:n};return u&&(l=Et(u.dirtyFields?t.dirtyFields:t.touchedFields,l)),I(a)?l:Q(a)?h(l,a):a.map(g=>h(l,g))},Je=(a,u)=>({invalid:!!h((u||t).errors,a),isDirty:!!h((u||t).dirtyFields,a),error:h((u||t).errors,a),isValidating:!!h(t.validatingFields,a),isTouched:!!h((u||t).touchedFields,a)}),Rt=a=>{a&&pe(a).forEach(u=>P(t.errors,u)),v.state.next({errors:a?t.errors:{}})},Ke=(a,u,l)=>{const g=(h(s,a,{_f:{}})._f||{}).ref,f=h(t.errors,a)||{},{ref:d,message:b,type:O,...M}=f;$(t.errors,a,{...M,...u,ref:g}),v.state.next({name:a,errors:t.errors,isValid:!1}),l&&l.shouldFocus&&g&&g.focus&&g.focus()},Nt=(a,u)=>z(a)?v.state.subscribe({next:l=>"values"in l&&a(T(void 0,u),l)}):T(a,u,!0),Qe=a=>v.state.subscribe({next:u=>{Cr(a.name,u.name,a.exact)&&_r(u,a.formState||y,Lt,a.reRenderRoot)&&a.callback({values:{...i},...t,...u,defaultValues:n})}}).unsubscribe,$t=a=>(o.mount=!0,_={..._,...a.formState},Qe({...a,formState:{...V,...a.formState}})),Ee=(a,u={})=>{for(const l of a?pe(a):c.mount)c.mount.delete(l),c.array.delete(l),u.keepValue||(P(s,l),P(i,l)),!u.keepError&&P(t.errors,l),!u.keepDirty&&P(t.dirtyFields,l),!u.keepTouched&&P(t.touchedFields,l),!u.keepIsValidating&&P(t.validatingFields,l),!e.shouldUnregister&&!u.keepDefaultValue&&P(n,l);v.state.next({values:U(i)}),v.state.next({...t,...u.keepDirty?{isDirty:k()}:{}}),!u.keepIsValid&&S()},Xe=({disabled:a,name:u})=>{if(K(a)&&o.mount||a||c.disabled.has(u)){const f=c.disabled.has(u)!==!!a;a?c.disabled.add(u):c.disabled.delete(u),f&&o.mount&&!o.action&&S()}},De=(a,u={})=>{let l=h(s,a);const g=K(u.disabled)||K(e.disabled);return $(s,a,{...l||{},_f:{...l&&l._f?l._f:{ref:{name:a}},name:a,mount:!0,...u}}),c.mount.add(a),l?Xe({disabled:K(u.disabled)?u.disabled:e.disabled,name:a}):C(a,!0,u.value),{...g?{disabled:u.disabled||e.disabled}:{},...e.progressive?{required:!!u.required,min:me(u.min),max:me(u.max),minLength:me(u.minLength),maxLength:me(u.maxLength),pattern:me(u.pattern)}:{},name:a,onChange:fe,onBlur:fe,ref:f=>{if(f){De(a,u),l=h(s,a);const d=I(f.value)&&f.querySelectorAll&&f.querySelectorAll("input,select,textarea")[0]||f,b=mr(d),O=l._f.refs||[];if(b?O.find(M=>M===d):d===l._f.ref)return;$(s,a,{_f:{...l._f,...b?{refs:[...O.filter(Me),d,...Array.isArray(h(n,a))?[{}]:[]],ref:{type:d.type,name:a}}:{ref:d}}}),C(a,!1,void 0,d)}else l=h(s,a,{}),l._f&&(l._f.mount=!1),(e.shouldUnregister||u.shouldUnregister)&&!(Vt(c.array,a)&&o.action)&&c.unMount.add(a)}}},ke=()=>e.shouldFocusError&&ve(s,he,c.mount),It=a=>{K(a)&&(v.state.next({disabled:a}),ve(s,(u,l)=>{const g=h(s,l);g&&(u.disabled=g._f.disabled||a,Array.isArray(g._f.refs)&&g._f.refs.forEach(f=>{f.disabled=g._f.disabled||a}))},0,!1))},Ze=(a,u)=>async l=>{let g;l&&(l.preventDefault&&l.preventDefault(),l.persist&&l.persist());let f=U(i);if(v.state.next({isSubmitting:!0}),e.resolver){const{errors:d,values:b}=await ee();D(),t.errors=d,f=U(b)}else await X(s);if(c.disabled.size)for(const d of c.disabled)P(f,d);if(P(t.errors,"root"),W(t.errors)){v.state.next({errors:{}});try{await a(f,l)}catch(d){g=d}}else u&&await u({...t.errors},l),ke(),setTimeout(ke);if(v.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:W(t.errors)&&!g,submitCount:t.submitCount+1,errors:t.errors}),g)throw g},Ut=(a,u={})=>{h(s,a)&&(I(u.defaultValue)?G(a,U(h(n,a))):(G(a,u.defaultValue),$(n,a,U(u.defaultValue))),u.keepTouched||P(t.touchedFields,a),u.keepDirty||(P(t.dirtyFields,a),t.isDirty=u.defaultValue?k(a,U(h(n,a))):k()),u.keepError||(P(t.errors,a),y.isValid&&S()),v.state.next({...t}))},et=(a,u={})=>{const l=a?U(a):n,g=U(l),f=W(a),d=f?n:g;if(u.keepDefaultValues||(n=l),!u.keepValues){if(u.keepDirtyValues){const b=new Set([...c.mount,...Object.keys(de(n,i))]);for(const O of Array.from(b)){const M=h(t.dirtyFields,O),q=h(i,O),ue=h(d,O);M&&!I(q)?$(d,O,q):!M&&!I(ue)&&G(O,ue)}}else{if(Pe&&I(a))for(const b of c.mount){const O=h(s,b);if(O&&O._f){const M=Array.isArray(O._f.refs)?O._f.refs[0]:O._f.ref;if(Ce(M)){const q=M.closest("form");if(q){q.reset();break}}}}if(u.keepFieldsRef)for(const b of c.mount)G(b,h(d,b));else s={}}i=e.shouldUnregister?u.keepDefaultValues?U(n):{}:U(d),v.array.next({values:{...d}}),v.state.next({values:{...d}})}c={mount:u.keepDirtyValues?c.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!y.isValid||!!u.keepIsValid||!!u.keepDirtyValues||!e.shouldUnregister&&!W(d),o.watch=!!e.shouldUnregister,o.keepIsValid=!!u.keepIsValid,o.action=!1,u.keepErrors||(t.errors={}),v.state.next({submitCount:u.keepSubmitCount?t.submitCount:0,isDirty:f?!1:u.keepDirty?t.isDirty:!!(u.keepDefaultValues&&!se(a,n)),isSubmitted:u.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:f?{}:u.keepDirtyValues?u.keepDefaultValues&&i?de(n,i):t.dirtyFields:u.keepDefaultValues&&a?de(n,a):u.keepDirty?t.dirtyFields:{},touchedFields:u.keepTouched?t.touchedFields:{},errors:u.keepErrors?t.errors:{},isSubmitSuccessful:u.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:n})},tt=(a,u)=>et(z(a)?a(i):a,{...e.resetOptions,...u}),Pt=(a,u={})=>{const l=h(s,a),g=l&&l._f;if(g){const f=g.refs?g.refs[0]:g.ref;f.focus&&setTimeout(()=>{f.focus(),u.shouldSelect&&z(f.select)&&f.select()})}},Lt=a=>{t={...t,...a}},rt={control:{register:De,unregister:Ee,getFieldState:Je,handleSubmit:Ze,setError:Ke,_subscribe:Qe,_runSchema:ee,_updateIsValidating:D,_focusError:ke,_getWatch:T,_getDirty:k,_setValid:S,_setFieldArray:w,_setDisabledField:Xe,_setErrors:A,_getFieldArray:H,_reset:et,_resetDefaultValues:()=>z(e.defaultValues)&&e.defaultValues().then(a=>{tt(a,e.resetOptions),v.state.next({isLoading:!1})}),_removeUnmounted:xe,_disableForm:It,_subjects:v,_proxyFormState:y,get _fields(){return s},get _formValues(){return i},get _state(){return o},set _state(a){o=a},get _defaultValues(){return n},get _names(){return c},set _names(a){c=a},get _formState(){return t},get _options(){return e},set _options(a){e={...e,...a}}},subscribe:$t,trigger:ge,register:De,handleSubmit:Ze,watch:Nt,setValue:G,getValues:Ge,reset:tt,resetField:Ut,clearErrors:Rt,unregister:Ee,setError:Ke,setFocus:Pt,getFieldState:Je};return{...rt,formControl:rt}}function zr(r={}){const e=x.useRef(void 0),t=x.useRef(void 0),[s,n]=x.useState({isDirty:!1,isValidating:!1,isLoading:z(r.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:r.errors||{},disabled:r.disabled||!1,isReady:!1,defaultValues:z(r.defaultValues)?void 0:r.defaultValues});if(!e.current)if(r.formControl)e.current={...r.formControl,formState:s},r.defaultValues&&!z(r.defaultValues)&&r.formControl.reset(r.defaultValues,r.resetOptions);else{const{formControl:o,...c}=Dr(r);e.current={...c,formState:s}}const i=e.current.control;return i._options=r,qe(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>n({...i._formState}),reRenderRoot:!0});return n(c=>({...c,isReady:!0})),i._formState.isReady=!0,o},[i]),x.useEffect(()=>i._disableForm(r.disabled),[i,r.disabled]),x.useEffect(()=>{r.mode&&(i._options.mode=r.mode),r.reValidateMode&&(i._options.reValidateMode=r.reValidateMode)},[i,r.mode,r.reValidateMode]),x.useEffect(()=>{r.errors&&(i._setErrors(r.errors),i._focusError())},[i,r.errors]),x.useEffect(()=>{r.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,r.shouldUnregister]),x.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==s.isDirty&&i._subjects.state.next({isDirty:o})}},[i,s.isDirty]),x.useEffect(()=>{var o;r.values&&!se(r.values,t.current)?(i._reset(r.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((o=i._options.resetOptions)===null||o===void 0)&&o.keepIsValid||i._setValid(),t.current=r.values,n(c=>({...c}))):i._resetDefaultValues()},[i,r.values]),x.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),e.current.formState=x.useMemo(()=>At(s,i),[i,s]),e.current}export{Wt as C,be as E,Wr as F,rr as P,er as S,Br as a,zr as b,Nr as c,Lr as d,$r as e,Ur as f,Rr as g,Or as h,jr as i,Hr as j,Pr as k,Ir as l,Mr as m,qr as u};
|
|
Binary file
|
|
Binary file
|