@npm-zenwork/tax-remittance-ui 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +32 -0
  2. package/dist/api/auth.d.ts +3 -0
  3. package/dist/api/bankAccounts.d.ts +4 -0
  4. package/dist/api/client.d.ts +7 -0
  5. package/dist/api/dashboard.d.ts +5 -0
  6. package/dist/api/entities.d.ts +10 -0
  7. package/dist/api/federalPayments.d.ts +8 -0
  8. package/dist/api/form8655Authorization.d.ts +5 -0
  9. package/dist/api/form9783Enrollment.d.ts +5 -0
  10. package/dist/api/statePayments.d.ts +5 -0
  11. package/dist/components/dashboard/DashboardActionBar.d.ts +5 -0
  12. package/dist/components/dashboard/DashboardSectionLoader.d.ts +5 -0
  13. package/dist/components/dashboard/EmptyPaymentCard.d.ts +9 -0
  14. package/dist/components/dashboard/MonthlyOverviewSection.d.ts +8 -0
  15. package/dist/components/dashboard/MyPaymentsTable.d.ts +8 -0
  16. package/dist/components/dashboard/PaymentSummaryCard.d.ts +21 -0
  17. package/dist/components/dashboard/dashboardMappers.d.ts +12 -0
  18. package/dist/components/dashboard/dashboardUtils.d.ts +31 -0
  19. package/dist/components/entities/entityListUtils.d.ts +7 -0
  20. package/dist/components/forms/FormField.d.ts +28 -0
  21. package/dist/components/icons/payment-tabs/DraftTabIcon.d.ts +2 -0
  22. package/dist/components/icons/payment-tabs/PaidTabIcon.d.ts +2 -0
  23. package/dist/components/icons/payment-tabs/RejectedTabIcon.d.ts +2 -0
  24. package/dist/components/icons/payment-tabs/ScheduledTabIcon.d.ts +2 -0
  25. package/dist/components/icons/payment-tabs/SubmittedTabIcon.d.ts +2 -0
  26. package/dist/components/icons/payment-tabs/index.d.ts +5 -0
  27. package/dist/components/onboarding/CreateEntityCard.d.ts +5 -0
  28. package/dist/components/onboarding/EntityForm.d.ts +1 -0
  29. package/dist/components/payments/AddFederalPaymentForm.d.ts +10 -0
  30. package/dist/components/payments/AddStatePaymentForm.d.ts +6 -0
  31. package/dist/components/payments/BankAccountSelect.d.ts +14 -0
  32. package/dist/components/payments/EftpsIndividualEnrollmentForm.d.ts +11 -0
  33. package/dist/components/payments/EntityDetailsCard.d.ts +8 -0
  34. package/dist/components/payments/PaymentField.d.ts +23 -0
  35. package/dist/components/payments/PaymentFormSection.d.ts +8 -0
  36. package/dist/components/payments/PaymentRowActions.d.ts +11 -0
  37. package/dist/components/payments/ReportingAgentAuthorizationForm.d.ts +11 -0
  38. package/dist/components/payments/SettlementDatePicker.d.ts +8 -0
  39. package/dist/components/payments/SignatureFieldGroup.d.ts +17 -0
  40. package/dist/components/payments/StatePaymentAuthorizationForm.d.ts +8 -0
  41. package/dist/components/payments/TaxPeriodMonthPicker.d.ts +9 -0
  42. package/dist/components/payments/eftpsIndividualEnrollmentConfig.d.ts +3 -0
  43. package/dist/components/payments/federalPaymentUtils.d.ts +7 -0
  44. package/dist/components/payments/federalSubcategoryRules.d.ts +32 -0
  45. package/dist/components/payments/federalTaxPeriodRules.d.ts +11 -0
  46. package/dist/components/payments/paymentsTableConfig.d.ts +15 -0
  47. package/dist/components/payments/remittancePaymentMappers.d.ts +19 -0
  48. package/dist/components/payments/reportingAgentAuthorizationConfig.d.ts +3 -0
  49. package/dist/components/payments/settlementDateRules.d.ts +12 -0
  50. package/dist/components/payments/statePaymentAuthorizationConfig.d.ts +2 -0
  51. package/dist/components/payments/statePaymentConfig.d.ts +20 -0
  52. package/dist/components/settings/AddBankAccountManualForm.d.ts +7 -0
  53. package/dist/components/settings/AddBankAccountModal.d.ts +8 -0
  54. package/dist/components/settings/BankAccountsSection.d.ts +5 -0
  55. package/dist/components/settings/PaymentHistorySection.d.ts +9 -0
  56. package/dist/components/settings/SettingsNav.d.ts +8 -0
  57. package/dist/components/settings/SettingsPlaceholderSection.d.ts +6 -0
  58. package/dist/components/settings/SettingsSectionHeader.d.ts +9 -0
  59. package/dist/components/settings/TaxAccountsSection.d.ts +9 -0
  60. package/dist/components/settings/settingsNavConfig.d.ts +9 -0
  61. package/dist/components/tax-forms/TaxFormsTable.d.ts +8 -0
  62. package/dist/components/ui/Alert.d.ts +7 -0
  63. package/dist/components/ui/Button.d.ts +8 -0
  64. package/dist/components/ui/Input.d.ts +7 -0
  65. package/dist/config.d.ts +22 -0
  66. package/dist/embedded/EmbeddedAuthContext.d.ts +27 -0
  67. package/dist/embedded/EmbeddedContext.d.ts +16 -0
  68. package/dist/embedded/EmbeddedLayout.d.ts +18 -0
  69. package/dist/embedded/EmbeddedRoutes.d.ts +10 -0
  70. package/dist/embedded/EmbeddedWidgetBase.d.ts +28 -0
  71. package/dist/embedded/EntityGate.d.ts +10 -0
  72. package/dist/embedded/TaxRemittanceEmbedded.d.ts +60 -0
  73. package/dist/embedded/ThemeProvider.d.ts +47 -0
  74. package/dist/embedded/pages/EmbeddedCreateEntityPage.d.ts +7 -0
  75. package/dist/embedded/pages/EmbeddedDashboardPage.d.ts +6 -0
  76. package/dist/embedded/pages/EmbeddedEntityFormPage.d.ts +9 -0
  77. package/dist/embedded/widgets/FederalPaymentWidget.d.ts +22 -0
  78. package/dist/embedded/widgets/StatePaymentWidget.d.ts +22 -0
  79. package/dist/index.cjs +76 -0
  80. package/dist/index.cjs.map +1 -0
  81. package/dist/index.d.ts +10 -0
  82. package/dist/index.mjs +14189 -0
  83. package/dist/index.mjs.map +1 -0
  84. package/dist/lib/admin-storage.d.ts +4 -0
  85. package/dist/lib/auth-events.d.ts +2 -0
  86. package/dist/lib/auth-storage.d.ts +6 -0
  87. package/dist/lib/entityAccountType.d.ts +3 -0
  88. package/dist/lib/errors.d.ts +1 -0
  89. package/dist/lib/initials.d.ts +7 -0
  90. package/dist/lib/navigation.d.ts +4 -0
  91. package/dist/lib/paymentStatus.d.ts +13 -0
  92. package/dist/lib/paymentsNavigation.d.ts +2 -0
  93. package/dist/lib/query-client.d.ts +2 -0
  94. package/dist/pages/AddFederalPaymentPage.d.ts +1 -0
  95. package/dist/pages/AddStatePaymentPage.d.ts +1 -0
  96. package/dist/pages/EditFederalPaymentPage.d.ts +2 -0
  97. package/dist/pages/EftpsIndividualEnrollmentPage.d.ts +1 -0
  98. package/dist/pages/FederalPaymentEditorPage.d.ts +5 -0
  99. package/dist/pages/PaymentsPage.d.ts +4 -0
  100. package/dist/pages/ReportingAgentAuthorizationPage.d.ts +1 -0
  101. package/dist/pages/SettingsPage.d.ts +1 -0
  102. package/dist/pages/StatePaymentAuthorizationPage.d.ts +1 -0
  103. package/dist/pages/TaxFormsPage.d.ts +1 -0
  104. package/dist/styles.css +1 -0
  105. package/dist/styles.css.d.ts +4 -0
  106. package/dist/types/api.d.ts +18 -0
  107. package/dist/types/apiClient.d.ts +29 -0
  108. package/dist/types/auth.d.ts +28 -0
  109. package/dist/types/bankAccount.d.ts +11 -0
  110. package/dist/types/createBankAccount.d.ts +7 -0
  111. package/dist/types/dashboard.d.ts +50 -0
  112. package/dist/types/entity.d.ts +54 -0
  113. package/dist/types/federalPayment.d.ts +62 -0
  114. package/dist/types/federalPaymentFlow.d.ts +41 -0
  115. package/dist/types/form8655Authorization.d.ts +48 -0
  116. package/dist/types/form8655AuthorizationFlow.d.ts +25 -0
  117. package/dist/types/form9783Enrollment.d.ts +70 -0
  118. package/dist/types/form9783EnrollmentFlow.d.ts +32 -0
  119. package/dist/types/paymentHistory.d.ts +11 -0
  120. package/dist/types/statePayment.d.ts +32 -0
  121. package/dist/types/statePaymentFlow.d.ts +28 -0
  122. package/dist/types/taxAccount.d.ts +9 -0
  123. package/dist/types/taxForm.d.ts +11 -0
  124. package/package.json +61 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,76 @@
1
+ "use strict";var ru=Object.defineProperty;var _i=e=>{throw TypeError(e)};var nu=(e,t,r)=>t in e?ru(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Tn=(e,t,r)=>nu(e,typeof t!="symbol"?t+"":t,r),Ts=(e,t,r)=>t.has(e)||_i("Cannot "+r);var g=(e,t,r)=>(Ts(e,t,"read from private field"),r?r.call(e):t.get(e)),W=(e,t,r)=>t.has(e)?_i("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),$=(e,t,r,n)=>(Ts(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),te=(e,t,r)=>(Ts(e,t,"access private method"),r);var In=(e,t,r,n)=>({set _(a){$(e,t,a,r)},get _(){return g(e,t,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),_=require("react");function su(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const C=su(_);/**
2
+ * react-router v7.18.1
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */var Aa=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,au=/^[\\/]{2}/;function iu(e,t){return t+e.replace(/\\/g,"/")}function Ai(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function ou(e={}){let{initialEntries:t=["/"],initialIndex:r,v5Compat:n=!1}=e,a;a=t.map((f,y)=>d(f,typeof f=="string"?null:f.state,y===0?"default":void 0,typeof f=="string"?void 0:f.mask));let i=c(r??a.length-1),o="POP",l=null;function c(f){return Math.min(Math.max(f,0),a.length-1)}function u(){return a[i]}function d(f,y=null,x,w){let v=cu(a?u().pathname:"/",f,y,x,w);return Je(v.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(f)}`),v}function h(f){return typeof f=="string"?f:Kn(f)}return{get index(){return i},get action(){return o},get location(){return u()},createHref:h,createURL(f){return new URL(h(f),"http://localhost")},encodeLocation(f){let y=typeof f=="string"?dr(f):f;return{pathname:y.pathname||"",search:y.search||"",hash:y.hash||""}},push(f,y){o="PUSH";let x=Ai(f)?f:d(f,y);i+=1,a.splice(i,a.length,x),n&&l&&l({action:o,location:x,delta:1})},replace(f,y){o="REPLACE";let x=Ai(f)?f:d(f,y);a[i]=x,n&&l&&l({action:o,location:x,delta:0})},go(f){o="POP";let y=c(i+f),x=a[y];i=y,l&&l({action:o,location:x,delta:f})},listen(f){return l=f,()=>{l=null}}}}function pe(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Je(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function lu(){return Math.random().toString(36).substring(2,10)}function cu(e,t,r=null,n,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?dr(t):t,state:r,key:t&&t.key||n||lu(),mask:a}}function Kn({pathname:e="/",search:t="",hash:r=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function dr(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substring(r),e=e.substring(0,r));let n=e.indexOf("?");n>=0&&(t.search=e.substring(n),e=e.substring(0,n)),e&&(t.pathname=e)}return t}function el(e,t,r="/"){return uu(e,t,r,!1)}function uu(e,t,r,n,a){let i=typeof t=="string"?dr(t):t,o=Et(i.pathname||"/",r);if(o==null)return null;let l=du(e),c=null,u=wu(o);for(let d=0;c==null&&d<l.length;++d)c=ju(l[d],u,n);return c}function du(e){let t=tl(e);return hu(t),t}function tl(e,t=[],r=[],n="",a=!1){let i=(o,l,c=a,u)=>{let d={relativePath:u===void 0?o.path||"":u,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(n)&&c)return;pe(d.relativePath.startsWith(n),`Absolute route path "${d.relativePath}" nested under path "${n}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(n.length)}let h=ct([n,d.relativePath]),m=r.concat(d);o.children&&o.children.length>0&&(pe(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),tl(o.children,t,m,h,c)),!(o.path==null&&!o.index)&&t.push({path:h,score:bu(h,o.index),routesMeta:m.map((f,y)=>{let[x,w]=sl(f.relativePath,f.caseSensitive,y===m.length-1);return{...f,matcher:x,compiledParams:w}})})};return e.forEach((o,l)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))i(o,l);else for(let u of rl(o.path))i(o,l,!0,u)}),t}function rl(e){let t=e.split("/");if(t.length===0)return[];let[r,...n]=t,a=r.endsWith("?"),i=r.replace(/\?$/,"");if(n.length===0)return a?[i,""]:[i];let o=rl(n.join("/")),l=[];return l.push(...o.map(c=>c===""?i:[i,c].join("/"))),a&&l.push(...o),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function hu(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:vu(t.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}var mu=/^:[\w-]+$/,fu=3,pu=2,xu=1,gu=10,yu=-2,Pi=e=>e==="*";function bu(e,t){let r=e.split("/"),n=r.length;return r.some(Pi)&&(n+=yu),t&&(n+=pu),r.filter(a=>!Pi(a)).reduce((a,i)=>a+(mu.test(i)?fu:i===""?xu:gu),n)}function vu(e,t){return e.length===t.length&&e.slice(0,-1).every((n,a)=>n===t[a])?e[e.length-1]-t[t.length-1]:0}function ju(e,t,r=!1){let{routesMeta:n}=e,a={},i="/",o=[];for(let l=0;l<n.length;++l){let c=n[l],u=l===n.length-1,d=i==="/"?t:t.slice(i.length)||"/",h={path:c.relativePath,caseSensitive:c.caseSensitive,end:u},m=c.matcher&&c.compiledParams?nl(h,d,c.matcher,c.compiledParams):Yn(h,d),f=c.route;if(!m&&u&&r&&!n[n.length-1].route.index&&(m=Yn({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!m)return null;Object.assign(a,m.params),o.push({params:a,pathname:ct([i,m.pathname]),pathnameBase:ku(ct([i,m.pathnameBase])),route:f}),m.pathnameBase!=="/"&&(i=ct([i,m.pathnameBase]))}return o}function Yn(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,n]=sl(e.path,e.caseSensitive,e.end);return nl(e,t,r,n)}function nl(e,t,r,n){let a=t.match(r);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:n.reduce((u,{paramName:d,isOptional:h},m)=>{if(d==="*"){let y=l[m]||"";o=i.slice(0,i.length-y.length).replace(/(.)\/+$/,"$1")}const f=l[m];return h&&!f?u[d]=void 0:u[d]=(f||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:o,pattern:e}}function sl(e,t=!1,r=!0){Je(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let n=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c,u,d)=>{if(n.push({paramName:l,isOptional:c!=null}),c){let h=d.charAt(u+o.length);return h&&h!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(n.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),n]}function wu(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Je(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Et(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,n=e.charAt(r);return n&&n!=="/"?null:e.slice(r)||"/"}function Nu(e,t="/"){let{pathname:r,search:n="",hash:a=""}=typeof e=="string"?dr(e):e,i;return r?(r=al(r),r.startsWith("/")?i=Ei(r.substring(1),"/"):i=Ei(r,t)):i=t,{pathname:i,search:Cu(n),hash:_u(a)}}function Ei(e,t){let r=Jn(t).split("/");return e.split("/").forEach(a=>{a===".."?r.length>1&&r.pop():a!=="."&&r.push(a)}),r.length>1?r.join("/"):"/"}function Is(e,t,r,n){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(n)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Su(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function Pa(e){let t=Su(e);return t.map((r,n)=>n===t.length-1?r.pathname:r.pathnameBase)}function us(e,t,r,n=!1){let a;typeof e=="string"?a=dr(e):(a={...e},pe(!a.pathname||!a.pathname.includes("?"),Is("?","pathname","search",a)),pe(!a.pathname||!a.pathname.includes("#"),Is("#","pathname","hash",a)),pe(!a.search||!a.search.includes("#"),Is("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,l;if(o==null)l=r;else{let h=t.length-1;if(!n&&o.startsWith("..")){let m=o.split("/");for(;m[0]==="..";)m.shift(),h-=1;a.pathname=m.join("/")}l=h>=0?t[h]:"/"}let c=Nu(a,l),u=o&&o!=="/"&&o.endsWith("/"),d=(i||o===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var al=e=>e.replace(/[\\/]{2,}/g,"/"),ct=e=>al(e.join("/")),Jn=e=>e.replace(/\/+$/,""),ku=e=>Jn(e).replace(/^\/*/,"/"),Cu=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,_u=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Au=class{constructor(e,t,r,n=!1){this.status=e,this.statusText=t||"",this.internal=n,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}};function Pu(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Eu(e){let t=e.map(r=>r.route.path).filter(Boolean);return ct(t)||"/"}var il=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ol(e,t){let r=e;if(typeof r!="string"||!Aa.test(r))return{absoluteURL:void 0,isExternal:!1,to:r};let n=r,a=!1;if(il)try{let i=new URL(window.location.href),o=au.test(r)?new URL(iu(r,i.protocol)):new URL(r),l=Et(o.pathname,t);o.origin===i.origin&&l!=null?r=l+o.search+o.hash:a=!0}catch{Je(!1,`<Link to="${r}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:n,isExternal:a,to:r}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var ll=["POST","PUT","PATCH","DELETE"];new Set(ll);var Tu=["GET",...ll];new Set(Tu);var Iu=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function Fu(e){try{return Iu.includes(new URL(e).protocol)}catch{return!1}}var Lr=C.createContext(null);Lr.displayName="DataRouter";var ds=C.createContext(null);ds.displayName="DataRouterState";var cl=C.createContext(!1);function Du(){return C.useContext(cl)}var ul=C.createContext({isTransitioning:!1});ul.displayName="ViewTransition";var Ru=C.createContext(new Map);Ru.displayName="Fetchers";var $u=C.createContext(null);$u.displayName="Await";var Ge=C.createContext(null);Ge.displayName="Navigation";var gn=C.createContext(null);gn.displayName="Location";var rt=C.createContext({outlet:null,matches:[],isDataRoute:!1});rt.displayName="Route";var Ea=C.createContext(null);Ea.displayName="RouteError";var dl="REACT_ROUTER_ERROR",Ou="REDIRECT",zu="ROUTE_ERROR_RESPONSE";function Lu(e){if(e.startsWith(`${dl}:${Ou}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function Mu(e){if(e.startsWith(`${dl}:${zu}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Au(t.status,t.statusText,t.data)}catch{}}function Vu(e,{relative:t}={}){pe(Mr(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:n}=C.useContext(Ge),{hash:a,pathname:i,search:o}=yn(e,{relative:t}),l=i;return r!=="/"&&(l=i==="/"?r:ct([r,i])),n.createHref({pathname:l,search:o,hash:a})}function Mr(){return C.useContext(gn)!=null}function we(){return pe(Mr(),"useLocation() may be used only in the context of a <Router> component."),C.useContext(gn).location}var hl="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function ml(e){C.useContext(Ge).static||C.useLayoutEffect(e)}function Te(){let{isDataRoute:e}=C.useContext(rt);return e?rd():qu()}function qu(){pe(Mr(),"useNavigate() may be used only in the context of a <Router> component.");let e=C.useContext(Lr),{basename:t,navigator:r}=C.useContext(Ge),{matches:n}=C.useContext(rt),{pathname:a}=we(),i=JSON.stringify(Pa(n)),o=C.useRef(!1);return ml(()=>{o.current=!0}),C.useCallback((c,u={})=>{if(Je(o.current,hl),!o.current)return;if(typeof c=="number"){r.go(c);return}let d=us(c,JSON.parse(i),a,u.relative==="path");e==null&&t!=="/"&&(d.pathname=d.pathname==="/"?t:ct([t,d.pathname])),(u.replace?r.replace:r.push)(d,u.state,u)},[t,r,i,a,e])}var fl=C.createContext(null);function vt(){return C.useContext(fl)}function Uu(e){let t=C.useContext(rt).outlet;return C.useMemo(()=>t&&C.createElement(fl.Provider,{value:e},t),[t,e])}function Zu(){let{matches:e}=C.useContext(rt),t=e[e.length-1];return(t==null?void 0:t.params)??{}}function yn(e,{relative:t}={}){let{matches:r}=C.useContext(rt),{pathname:n}=we(),a=JSON.stringify(Pa(r));return C.useMemo(()=>us(e,JSON.parse(a),n,t==="path"),[e,a,n,t])}function Bu(e,t){return pl(e,t)}function pl(e,t,r){var w;pe(Mr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:n}=C.useContext(Ge),{matches:a}=C.useContext(rt),i=a[a.length-1],o=i?i.params:{},l=i?i.pathname:"/",c=i?i.pathnameBase:"/",u=i&&i.route;{let v=u&&u.path||"";gl(l,!u||v.endsWith("*")||v.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${v}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
11
+
12
+ Please change the parent <Route path="${v}"> to <Route path="${v==="/"?"*":`${v}/*`}">.`)}let d=we(),h;if(t){let v=typeof t=="string"?dr(t):t;pe(c==="/"||((w=v.pathname)==null?void 0:w.startsWith(c)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${v.pathname}" was given in the \`location\` prop.`),h=v}else h=d;let m=h.pathname||"/",f=m;if(c!=="/"){let v=c.replace(/^\//,"").split("/");f="/"+m.replace(/^\//,"").split("/").slice(v.length).join("/")}let y=r&&r.state.matches.length?r.state.matches.map(v=>Object.assign(v,{route:r.manifest[v.route.id]||v.route})):el(e,{pathname:f});Je(u||y!=null,`No routes matched location "${h.pathname}${h.search}${h.hash}" `),Je(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.length-1].route.lazy!==void 0,`Matched leaf route at location "${h.pathname}${h.search}${h.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let x=Yu(y&&y.map(v=>Object.assign({},v,{params:Object.assign({},o,v.params),pathname:ct([c,n.encodeLocation?n.encodeLocation(v.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?c:ct([c,n.encodeLocation?n.encodeLocation(v.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:v.pathnameBase])})),a,r);return t&&x?C.createElement(gn.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...h},navigationType:"POP"}},x):x}function Wu(){let e=td(),t=Pu(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:n},i={padding:"2px 4px",backgroundColor:n},o=null;return console.error("Error handled by React Router default ErrorBoundary:",e),o=C.createElement(C.Fragment,null,C.createElement("p",null,"💿 Hey developer 👋"),C.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",C.createElement("code",{style:i},"ErrorBoundary")," or"," ",C.createElement("code",{style:i},"errorElement")," prop on your route.")),C.createElement(C.Fragment,null,C.createElement("h2",null,"Unexpected Application Error!"),C.createElement("h3",{style:{fontStyle:"italic"}},t),r?C.createElement("pre",{style:a},r):null,o)}var Hu=C.createElement(Wu,null),xl=class extends C.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const r=Mu(e.digest);r&&(e=r)}let t=e!==void 0?C.createElement(rt.Provider,{value:this.props.routeContext},C.createElement(Ea.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?C.createElement(Qu,{error:e},t):t}};xl.contextType=cl;var Fs=new WeakMap;function Qu({children:e,error:t}){let{basename:r}=C.useContext(Ge);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let n=Lu(t.digest);if(n){let a=Fs.get(t);if(a)throw a;let i=ol(n.location,r),o=i.absoluteURL||i.to;if(Fu(o))throw new Error("Invalid redirect location");if(il&&!Fs.get(t))if(i.isExternal||n.reloadDocument)window.location.href=o;else{const l=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:n.replace}));throw Fs.set(t,l),l}return C.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o}`})}}return e}function Ku({routeContext:e,match:t,children:r}){let n=C.useContext(Lr);return n&&n.static&&n.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(n.staticContext._deepestRenderedBoundaryId=t.route.id),C.createElement(rt.Provider,{value:e},r)}function Yu(e,t=[],r){let n=r==null?void 0:r.state;if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,i=n==null?void 0:n.errors;if(i!=null){let d=a.findIndex(h=>h.route.id&&(i==null?void 0:i[h.route.id])!==void 0);pe(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,d+1))}let o=!1,l=-1;if(r&&n){o=n.renderFallback;for(let d=0;d<a.length;d++){let h=a[d];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(l=d),h.route.id){let{loaderData:m,errors:f}=n,y=h.route.loader&&!m.hasOwnProperty(h.route.id)&&(!f||f[h.route.id]===void 0);if(h.route.lazy||y){r.isStatic&&(o=!0),l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}}let c=r==null?void 0:r.onError,u=n&&c?(d,h)=>{var m,f;c(d,{location:n.location,params:((f=(m=n.matches)==null?void 0:m[0])==null?void 0:f.params)??{},pattern:Eu(n.matches),errorInfo:h})}:void 0;return a.reduceRight((d,h,m)=>{let f,y=!1,x=null,w=null;n&&(f=i&&h.route.id?i[h.route.id]:void 0,x=h.route.errorElement||Hu,o&&(l<0&&m===0?(gl("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),y=!0,w=null):l===m&&(y=!0,w=h.route.hydrateFallbackElement||null)));let v=t.concat(a.slice(0,m+1)),j=()=>{let b;return f?b=x:y?b=w:h.route.Component?b=C.createElement(h.route.Component,null):h.route.element?b=h.route.element:b=d,C.createElement(Ku,{match:h,routeContext:{outlet:d,matches:v,isDataRoute:n!=null},children:b})};return n&&(h.route.ErrorBoundary||h.route.errorElement||m===0)?C.createElement(xl,{location:n.location,revalidation:n.revalidation,component:x,error:f,children:j(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:u}):j()},null)}function Ta(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ju(e){let t=C.useContext(Lr);return pe(t,Ta(e)),t}function Gu(e){let t=C.useContext(ds);return pe(t,Ta(e)),t}function Xu(e){let t=C.useContext(rt);return pe(t,Ta(e)),t}function Ia(e){let t=Xu(e),r=t.matches[t.matches.length-1];return pe(r.route.id,`${e} can only be used on routes that contain a unique "id"`),r.route.id}function ed(){return Ia("useRouteId")}function td(){var n;let e=C.useContext(Ea),t=Gu("useRouteError"),r=Ia("useRouteError");return e!==void 0?e:(n=t.errors)==null?void 0:n[r]}function rd(){let{router:e}=Ju("useNavigate"),t=Ia("useNavigate"),r=C.useRef(!1);return ml(()=>{r.current=!0}),C.useCallback(async(a,i={})=>{Je(r.current,hl),r.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...i}))},[e,t])}var Ti={};function gl(e,t,r){!t&&!Ti[e]&&(Ti[e]=!0,Je(!1,r))}C.memo(nd);function nd({routes:e,manifest:t,future:r,state:n,isStatic:a,onError:i}){return pl(e,void 0,{manifest:t,state:n,isStatic:a,onError:i})}function sd({basename:e,children:t,initialEntries:r,initialIndex:n,useTransitions:a}){let i=C.useRef();i.current==null&&(i.current=ou({initialEntries:r,initialIndex:n,v5Compat:!0}));let o=i.current,[l,c]=C.useState({action:o.action,location:o.location}),u=C.useCallback(d=>{a===!1?c(d):C.startTransition(()=>c(d))},[a]);return C.useLayoutEffect(()=>o.listen(u),[o,u]),C.createElement(id,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:o,useTransitions:a})}function ut({to:e,replace:t,state:r,relative:n}){pe(Mr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=C.useContext(Ge);Je(!a,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:i}=C.useContext(rt),{pathname:o}=we(),l=Te(),c=us(e,Pa(i),o,n==="path"),u=JSON.stringify(c);return C.useEffect(()=>{l(JSON.parse(u),{replace:t,state:r,relative:n})},[l,u,n,t,r]),null}function ad(e){return Uu(e.context)}function re(e){pe(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function id({basename:e="/",children:t=null,location:r,navigationType:n="POP",navigator:a,static:i=!1,useTransitions:o}){pe(!Mr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=C.useMemo(()=>({basename:l,navigator:a,static:i,useTransitions:o,future:{}}),[l,a,i,o]);typeof r=="string"&&(r=dr(r));let{pathname:u="/",search:d="",hash:h="",state:m=null,key:f="default",mask:y}=r,x=C.useMemo(()=>{let w=Et(u,l);return w==null?null:{location:{pathname:w,search:d,hash:h,state:m,key:f,mask:y},navigationType:n}},[l,u,d,h,m,f,n,y]);return Je(x!=null,`<Router basename="${l}"> is not able to match the URL "${u}${d}${h}" because it does not start with the basename, so the <Router> won't render anything.`),x==null?null:C.createElement(Ge.Provider,{value:c},C.createElement(gn.Provider,{children:t,value:x}))}function Fa({children:e,location:t}){return Bu(Ws(e),t)}function Ws(e,t=[]){let r=[];return C.Children.forEach(e,(n,a)=>{if(!C.isValidElement(n))return;let i=[...t,a];if(n.type===C.Fragment){r.push.apply(r,Ws(n.props.children,i));return}pe(n.type===re,`[${typeof n.type=="string"?n.type:n.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),pe(!n.props.index||!n.props.children,"An index route cannot have child routes.");let o={id:n.props.id||i.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,middleware:n.props.middleware,loader:n.props.loader,action:n.props.action,hydrateFallbackElement:n.props.hydrateFallbackElement,HydrateFallback:n.props.HydrateFallback,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.hasErrorBoundary===!0||n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(o.children=Ws(n.props.children,i)),r.push(o)}),r}var Un="get",Zn="application/x-www-form-urlencoded";function hs(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function od(e){return hs(e)&&e.tagName.toLowerCase()==="button"}function ld(e){return hs(e)&&e.tagName.toLowerCase()==="form"}function cd(e){return hs(e)&&e.tagName.toLowerCase()==="input"}function ud(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function dd(e,t){return e.button===0&&(!t||t==="_self")&&!ud(e)}function Hs(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map(a=>[r,a]):[[r,n]])},[]))}function hd(e,t){let r=Hs(e);return t&&t.forEach((n,a)=>{r.has(a)||t.getAll(a).forEach(i=>{r.append(a,i)})}),r}var Fn=null;function md(){if(Fn===null)try{new FormData(document.createElement("form"),0),Fn=!1}catch{Fn=!0}return Fn}var fd=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ds(e){return e!=null&&!fd.has(e)?(Je(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Zn}"`),null):e}function pd(e,t){let r,n,a,i,o;if(ld(e)){let l=e.getAttribute("action");n=l?Et(l,t):null,r=e.getAttribute("method")||Un,a=Ds(e.getAttribute("enctype"))||Zn,i=new FormData(e)}else if(od(e)||cd(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||l.getAttribute("action");if(n=c?Et(c,t):null,r=e.getAttribute("formmethod")||l.getAttribute("method")||Un,a=Ds(e.getAttribute("formenctype"))||Ds(l.getAttribute("enctype"))||Zn,i=new FormData(l,e),!md()){let{name:u,type:d,value:h}=e;if(d==="image"){let m=u?`${u}.`:"";i.append(`${m}x`,"0"),i.append(`${m}y`,"0")}else u&&i.append(u,h)}}else{if(hs(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=Un,n=null,a=Zn,o=e}return i&&a==="text/plain"&&(o=i,i=void 0),{action:n,method:r.toLowerCase(),encType:a,formData:i,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Da(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function yl(e,t,r,n){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return r?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${n}`:a.pathname=`${a.pathname}.${n}`:a.pathname==="/"?a.pathname=`_root.${n}`:t&&Et(a.pathname,t)==="/"?a.pathname=`${Jn(t)}/_root.${n}`:a.pathname=`${Jn(a.pathname)}.${n}`,a}async function xd(e,t){if(e.id in t)return t[e.id];try{let r=await import(e.module);return t[e.id]=r,r}catch(r){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(r),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function gd(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function yd(e,t,r){let n=await Promise.all(e.map(async a=>{let i=t.routes[a.route.id];if(i){let o=await xd(i,r);return o.links?o.links():[]}return[]}));return wd(n.flat(1).filter(gd).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function Ii(e,t,r,n,a,i){let o=(c,u)=>r[u]?c.route.id!==r[u].route.id:!0,l=(c,u)=>{var d;return r[u].pathname!==c.pathname||((d=r[u].route.path)==null?void 0:d.endsWith("*"))&&r[u].params["*"]!==c.params["*"]};return i==="assets"?t.filter((c,u)=>o(c,u)||l(c,u)):i==="data"?t.filter((c,u)=>{var h;let d=n.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(o(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let m=c.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((h=r[0])==null?void 0:h.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof m=="boolean")return m}return!0}):[]}function bd(e,t,{includeHydrateFallback:r}={}){return vd(e.map(n=>{let a=t.routes[n.route.id];if(!a)return[];let i=[a.module];return a.clientActionModule&&(i=i.concat(a.clientActionModule)),a.clientLoaderModule&&(i=i.concat(a.clientLoaderModule)),r&&a.hydrateFallbackModule&&(i=i.concat(a.hydrateFallbackModule)),a.imports&&(i=i.concat(a.imports)),i}).flat(1))}function vd(e){return[...new Set(e)]}function jd(e){let t={},r=Object.keys(e).sort();for(let n of r)t[n]=e[n];return t}function wd(e,t){let r=new Set;return new Set(t),e.reduce((n,a)=>{let i=JSON.stringify(jd(a));return r.has(i)||(r.add(i),n.push({key:i,link:a})),n},[])}function Ra(){let e=C.useContext(Lr);return Da(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Nd(){let e=C.useContext(ds);return Da(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var $a=C.createContext(void 0);$a.displayName="FrameworkContext";function ms(){let e=C.useContext($a);return Da(e,"You must render this element inside a <HydratedRouter> element"),e}function Sd(e,t){let r=C.useContext($a),[n,a]=C.useState(!1),[i,o]=C.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:h}=t,m=C.useRef(null);C.useEffect(()=>{if(e==="render"&&o(!0),e==="viewport"){let x=v=>{v.forEach(j=>{o(j.isIntersecting)})},w=new IntersectionObserver(x,{threshold:.5});return m.current&&w.observe(m.current),()=>{w.disconnect()}}},[e]),C.useEffect(()=>{if(n){let x=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(x)}}},[n]);let f=()=>{a(!0)},y=()=>{a(!1),o(!1)};return r?e!=="intent"?[i,m,{}]:[i,m,{onFocus:Yr(l,f),onBlur:Yr(c,y),onMouseEnter:Yr(u,f),onMouseLeave:Yr(d,y),onTouchStart:Yr(h,f)}]:[!1,m,{}]}function Yr(e,t){return r=>{e&&e(r),r.defaultPrevented||t(r)}}function kd({page:e,...t}){let r=Du(),{nonce:n}=ms(),{router:a}=Ra(),i=C.useMemo(()=>el(a.routes,e,a.basename),[a.routes,e,a.basename]);return i?(t.nonce==null&&n&&(t={...t,nonce:n}),r?C.createElement(_d,{page:e,matches:i,...t}):C.createElement(Ad,{page:e,matches:i,...t})):null}function Cd(e){let{manifest:t,routeModules:r}=ms(),[n,a]=C.useState([]);return C.useEffect(()=>{let i=!1;return yd(e,t,r).then(o=>{i||a(o)}),()=>{i=!0}},[e,t,r]),n}function _d({page:e,matches:t,...r}){let n=we(),{future:a}=ms(),{basename:i}=Ra(),o=C.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let l=yl(e,i,a.v8_trailingSlashAwareDataRequests,"rsc"),c=!1,u=[];for(let d of t)typeof d.route.shouldRevalidate=="function"?c=!0:u.push(d.route.id);return c&&u.length>0&&l.searchParams.set("_routes",u.join(",")),[l.pathname+l.search]},[i,a.v8_trailingSlashAwareDataRequests,e,n,t]);return C.createElement(C.Fragment,null,o.map(l=>C.createElement("link",{key:l,rel:"prefetch",as:"fetch",href:l,...r})))}function Ad({page:e,matches:t,...r}){let n=we(),{future:a,manifest:i,routeModules:o}=ms(),{basename:l}=Ra(),{loaderData:c,matches:u}=Nd(),d=C.useMemo(()=>Ii(e,t,u,i,n,"data"),[e,t,u,i,n]),h=C.useMemo(()=>Ii(e,t,u,i,n,"assets"),[e,t,u,i,n]),m=C.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let x=new Set,w=!1;if(t.forEach(j=>{var k;let b=i.routes[j.route.id];!b||!b.hasLoader||(!d.some(P=>P.route.id===j.route.id)&&j.route.id in c&&((k=o[j.route.id])!=null&&k.shouldRevalidate)||b.hasClientLoader?w=!0:x.add(j.route.id))}),x.size===0)return[];let v=yl(e,l,a.v8_trailingSlashAwareDataRequests,"data");return w&&x.size>0&&v.searchParams.set("_routes",t.filter(j=>x.has(j.route.id)).map(j=>j.route.id).join(",")),[v.pathname+v.search]},[l,a.v8_trailingSlashAwareDataRequests,c,n,i,d,t,e,o]),f=C.useMemo(()=>bd(h,i),[h,i]),y=Cd(h);return C.createElement(C.Fragment,null,m.map(x=>C.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...r})),f.map(x=>C.createElement("link",{key:x,rel:"modulepreload",href:x,...r})),y.map(({key:x,link:w})=>C.createElement("link",{key:x,nonce:r.nonce,...w,crossOrigin:w.crossOrigin??r.crossOrigin})))}function Pd(...e){return t=>{e.forEach(r=>{typeof r=="function"?r(t):r!=null&&(r.current=t)})}}var Ed=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Ed&&(window.__reactRouterVersion="7.18.1")}catch{}var bl=C.forwardRef(function({onClick:t,discover:r="render",prefetch:n="none",relative:a,reloadDocument:i,replace:o,mask:l,state:c,target:u,to:d,preventScrollReset:h,viewTransition:m,defaultShouldRevalidate:f,...y},x){let{basename:w,navigator:v,useTransitions:j}=C.useContext(Ge),b=typeof d=="string"&&Aa.test(d),k=ol(d,w);d=k.to;let P=Vu(d,{relative:a}),A=we(),L=null;if(l){let ee=us(l,[],A.mask?A.mask.pathname:"/",!0);w!=="/"&&(ee.pathname=ee.pathname==="/"?w:ct([w,ee.pathname])),L=v.createHref(ee)}let[O,V,J]=Sd(n,y),H=Dd(d,{replace:o,mask:l,state:c,target:u,preventScrollReset:h,relative:a,viewTransition:m,defaultShouldRevalidate:f,useTransitions:j});function K(ee){t&&t(ee),ee.defaultPrevented||H(ee)}let Z=!(k.isExternal||i),U=C.createElement("a",{...y,...J,href:(Z?L:void 0)||k.absoluteURL||P,onClick:Z?K:t,ref:Pd(x,V),target:u,"data-discover":!b&&r==="render"?"true":void 0});return O&&!b?C.createElement(C.Fragment,null,U,C.createElement(kd,{page:P})):U});bl.displayName="Link";var Td=C.forwardRef(function({"aria-current":t="page",caseSensitive:r=!1,className:n="",end:a=!1,style:i,to:o,viewTransition:l,children:c,...u},d){let h=yn(o,{relative:u.relative}),m=we(),f=C.useContext(ds),{navigator:y,basename:x}=C.useContext(Ge),w=f!=null&&Md(h)&&l===!0,v=y.encodeLocation?y.encodeLocation(h).pathname:h.pathname,j=m.pathname,b=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;r||(j=j.toLowerCase(),b=b?b.toLowerCase():null,v=v.toLowerCase()),b&&x&&(b=Et(b,x)||b);const k=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let P=j===v||!a&&j.startsWith(v)&&j.charAt(k)==="/",A=b!=null&&(b===v||!a&&b.startsWith(v)&&b.charAt(v.length)==="/"),L={isActive:P,isPending:A,isTransitioning:w},O=P?t:void 0,V;typeof n=="function"?V=n(L):V=[n,P?"active":null,A?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let J=typeof i=="function"?i(L):i;return C.createElement(bl,{...u,"aria-current":O,className:V,ref:d,style:J,to:o,viewTransition:l},typeof c=="function"?c(L):c)});Td.displayName="NavLink";var Id=C.forwardRef(({discover:e="render",fetcherKey:t,navigate:r,reloadDocument:n,replace:a,state:i,method:o=Un,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:h,defaultShouldRevalidate:m,...f},y)=>{let{useTransitions:x}=C.useContext(Ge),w=zd(),v=Ld(l,{relative:u}),j=o.toLowerCase()==="get"?"get":"post",b=typeof l=="string"&&Aa.test(l),k=P=>{if(c&&c(P),P.defaultPrevented)return;P.preventDefault();let A=P.nativeEvent.submitter,L=(A==null?void 0:A.getAttribute("formmethod"))||o,O=()=>w(A||P.currentTarget,{fetcherKey:t,method:L,navigate:r,replace:a,state:i,relative:u,preventScrollReset:d,viewTransition:h,defaultShouldRevalidate:m});x&&r!==!1?C.startTransition(()=>O()):O()};return C.createElement("form",{ref:y,method:j,action:v,onSubmit:n?c:k,...f,"data-discover":!b&&e==="render"?"true":void 0})});Id.displayName="Form";function Fd(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function vl(e){let t=C.useContext(Lr);return pe(t,Fd(e)),t}function Dd(e,{target:t,replace:r,mask:n,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c,useTransitions:u}={}){let d=Te(),h=we(),m=yn(e,{relative:o});return C.useCallback(f=>{if(dd(f,t)){f.preventDefault();let y=r!==void 0?r:Kn(h)===Kn(m),x=()=>d(e,{replace:y,mask:n,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c});u?C.startTransition(()=>x()):x()}},[h,d,m,r,n,a,t,e,i,o,l,c,u])}function Rd(e){Je(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=C.useRef(Hs(e)),r=C.useRef(!1),n=we(),a=C.useMemo(()=>hd(n.search,r.current?null:t.current),[n.search]),i=Te(),o=C.useCallback((l,c)=>{const u=Hs(typeof l=="function"?l(new URLSearchParams(a)):l);r.current=!0,i("?"+u,c)},[i,a]);return[a,o]}var $d=0,Od=()=>`__${String(++$d)}__`;function zd(){let{router:e}=vl("useSubmit"),{basename:t}=C.useContext(Ge),r=ed(),n=e.fetch,a=e.navigate;return C.useCallback(async(i,o={})=>{let{action:l,method:c,encType:u,formData:d,body:h}=pd(i,t);if(o.navigate===!1){let m=o.fetcherKey||Od();await n(m,r,o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:h,formMethod:o.method||c,formEncType:o.encType||u,flushSync:o.flushSync})}else await a(o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:h,formMethod:o.method||c,formEncType:o.encType||u,replace:o.replace,state:o.state,fromRouteId:r,flushSync:o.flushSync,viewTransition:o.viewTransition})},[n,a,t,r])}function Ld(e,{relative:t}={}){let{basename:r}=C.useContext(Ge),n=C.useContext(rt);pe(n,"useFormAction must be used inside a RouteContext");let[a]=n.matches.slice(-1),i={...yn(e||".",{relative:t})},o=we();if(e==null){i.search=o.search;let l=new URLSearchParams(i.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(h=>h).forEach(h=>l.append("index",h));let d=l.toString();i.search=d?`?${d}`:""}}return(!e||e===".")&&a.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),r!=="/"&&(i.pathname=i.pathname==="/"?r:ct([r,i.pathname])),Kn(i)}function Md(e,{relative:t}={}){let r=C.useContext(ul);pe(r!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:n}=vl("useViewTransitionState"),a=yn(e,{relative:t});if(!r.isTransitioning)return!1;let i=Et(r.currentLocation.pathname,n)||r.currentLocation.pathname,o=Et(r.nextLocation.pathname,n)||r.nextLocation.pathname;return Yn(a.pathname,o)!=null||Yn(a.pathname,i)!=null}var Vr=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Gt,$t,Cr,Uo,Vd=(Uo=class extends Vr{constructor(){super();W(this,Gt);W(this,$t);W(this,Cr);$(this,Cr,t=>{if(typeof window<"u"&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){g(this,$t)||this.setEventListener(g(this,Cr))}onUnsubscribe(){var t;this.hasListeners()||((t=g(this,$t))==null||t.call(this),$(this,$t,void 0))}setEventListener(t){var r;$(this,Cr,t),(r=g(this,$t))==null||r.call(this),$(this,$t,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){g(this,Gt)!==t&&($(this,Gt,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof g(this,Gt)=="boolean"?g(this,Gt):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Gt=new WeakMap,$t=new WeakMap,Cr=new WeakMap,Uo),Oa=new Vd,qd={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},ft,Xt,Zo,Ud=(Zo=class{constructor(){W(this,ft,qd);W(this,Xt,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&g(this,Xt)&&e!==g(this,ft)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:g(this,ft),provider:e}),$(this,ft,e),process.env.NODE_ENV!=="production"&&$(this,Xt,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&$(this,Xt,!0),g(this,ft).setTimeout(e,t)}clearTimeout(e){g(this,ft).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&$(this,Xt,!0),g(this,ft).setInterval(e,t)}clearInterval(e){g(this,ft).clearInterval(e)}},ft=new WeakMap,Xt=new WeakMap,Zo),Yt=new Ud;function Zd(e){setTimeout(e,0)}var Bd=typeof window>"u"||"Deno"in globalThis;function Ve(){}function Wd(e,t){return typeof e=="function"?e(t):e}function Qs(e){return typeof e=="number"&&e>=0&&e!==1/0}function jl(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Bt(e,t){return typeof e=="function"?e(t):e}function Qe(e,t){return typeof e=="function"?e(t):e}function Fi(e,t){const{type:r="all",exact:n,fetchStatus:a,predicate:i,queryKey:o,stale:l}=e;if(o){if(n){if(t.queryHash!==za(o,t.options))return!1}else if(!on(t.queryKey,o))return!1}if(r!=="all"){const c=t.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||a&&a!==t.state.fetchStatus||i&&!i(t))}function Di(e,t){const{exact:r,status:n,predicate:a,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(r){if(lr(t.options.mutationKey)!==lr(i))return!1}else if(!on(t.options.mutationKey,i))return!1}return!(n&&t.state.status!==n||a&&!a(t))}function za(e,t){return((t==null?void 0:t.queryKeyHashFn)||lr)(e)}function lr(e){return JSON.stringify(e,(t,r)=>Ys(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function on(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>on(e[r],t[r])):!1}var Hd=Object.prototype.hasOwnProperty;function Ks(e,t,r=0){if(e===t)return e;if(r>500)return t;const n=Ri(e)&&Ri(t);if(!n&&!(Ys(e)&&Ys(t)))return t;const i=(n?e:Object.keys(e)).length,o=n?t:Object.keys(t),l=o.length,c=n?new Array(l):{};let u=0;for(let d=0;d<l;d++){const h=n?d:o[d],m=e[h],f=t[h];if(m===f){c[h]=m,(n?d<i:Hd.call(e,h))&&u++;continue}if(m===null||f===null||typeof m!="object"||typeof f!="object"){c[h]=f;continue}const y=Ks(m,f,r+1);c[h]=y,y===m&&u++}return i===l&&u===i?e:c}function Gn(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function Ri(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ys(e){if(!$i(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!$i(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function $i(e){return Object.prototype.toString.call(e)==="[object Object]"}function Qd(e){return new Promise(t=>{Yt.setTimeout(t,e)})}function Js(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Ks(e,t)}catch(n){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${n}`),n}return Ks(e,t)}return t}function Kd(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function Yd(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var Xn=Symbol();function wl(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Xn&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Xn?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function La(e,t){return typeof e=="function"?e(...t):!!e}function Jd(e,t,r){let n=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),n||(n=!0,a.aborted?r():a.addEventListener("abort",r,{once:!0})),a)}),e}var ln=(()=>{let e=()=>Bd;return{isServer(){return e()},setIsServer(t){e=t}}})();function Gs(){let e,t;const r=new Promise((a,i)=>{e=a,t=i});r.status="pending",r.catch(()=>{});function n(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{n({status:"fulfilled",value:a}),e(a)},r.reject=a=>{n({status:"rejected",reason:a}),t(a)},r}var Gd=Zd;function Xd(){let e=[],t=0,r=l=>{l()},n=l=>{l()},a=Gd;const i=l=>{t?e.push(l):a(()=>{r(l)})},o=()=>{const l=e;e=[],l.length&&a(()=>{n(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||o()}return c},batchCalls:l=>(...c)=>{i(()=>{l(...c)})},schedule:i,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{n=l},setScheduler:l=>{a=l}}}var _e=Xd(),_r,Ot,Ar,Bo,eh=(Bo=class extends Vr{constructor(){super();W(this,_r,!0);W(this,Ot);W(this,Ar);$(this,Ar,t=>{if(typeof window<"u"&&window.addEventListener){const r=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){g(this,Ot)||this.setEventListener(g(this,Ar))}onUnsubscribe(){var t;this.hasListeners()||((t=g(this,Ot))==null||t.call(this),$(this,Ot,void 0))}setEventListener(t){var r;$(this,Ar,t),(r=g(this,Ot))==null||r.call(this),$(this,Ot,t(this.setOnline.bind(this)))}setOnline(t){g(this,_r)!==t&&($(this,_r,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return g(this,_r)}},_r=new WeakMap,Ot=new WeakMap,Ar=new WeakMap,Bo),es=new eh;function th(e){return Math.min(1e3*2**e,3e4)}function Nl(e){return(e??"online")==="online"?es.isOnline():!0}var Xs=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Sl(e){let t=!1,r=0,n;const a=Gs(),i=()=>a.status!=="pending",o=x=>{var w;if(!i()){const v=new Xs(x);m(v),(w=e.onCancel)==null||w.call(e,v)}},l=()=>{t=!0},c=()=>{t=!1},u=()=>Oa.isFocused()&&(e.networkMode==="always"||es.isOnline())&&e.canRun(),d=()=>Nl(e.networkMode)&&e.canRun(),h=x=>{i()||(n==null||n(),a.resolve(x))},m=x=>{i()||(n==null||n(),a.reject(x))},f=()=>new Promise(x=>{var w;n=v=>{(i()||u())&&x(v)},(w=e.onPause)==null||w.call(e)}).then(()=>{var x;n=void 0,i()||(x=e.onContinue)==null||x.call(e)}),y=()=>{if(i())return;let x;const w=r===0?e.initialPromise:void 0;try{x=w??e.fn()}catch(v){x=Promise.reject(v)}Promise.resolve(x).then(h).catch(v=>{var A;if(i())return;const j=e.retry??(ln.isServer()?0:3),b=e.retryDelay??th,k=typeof b=="function"?b(r,v):b,P=j===!0||typeof j=="number"&&r<j||typeof j=="function"&&j(r,v);if(t||!P){m(v);return}r++,(A=e.onFail)==null||A.call(e,r,v),Qd(k).then(()=>u()?void 0:f()).then(()=>{t?m(v):y()})})};return{promise:a,status:()=>a.status,cancel:o,continue:()=>(n==null||n(),a),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?y():f().then(y),a)}}var er,Wo,kl=(Wo=class{constructor(){W(this,er)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Qs(this.gcTime)&&$(this,er,Yt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ln.isServer()?1/0:300*1e3))}clearGcTimeout(){g(this,er)!==void 0&&(Yt.clearTimeout(g(this,er)),$(this,er,void 0))}},er=new WeakMap,Wo);function rh(e){return{onFetch:(t,r)=>{var d,h,m,f,y;const n=t.options,a=(m=(h=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:h.fetchMore)==null?void 0:m.direction,i=((f=t.state.data)==null?void 0:f.pages)||[],o=((y=t.state.data)==null?void 0:y.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let x=!1;const w=b=>{Jd(b,()=>t.signal,()=>x=!0)},v=wl(t.options,t.fetchOptions),j=async(b,k,P)=>{if(x)return Promise.reject(t.signal.reason);if(k==null&&b.pages.length)return Promise.resolve(b);const L=(()=>{const H={client:t.client,queryKey:t.queryKey,pageParam:k,direction:P?"backward":"forward",meta:t.options.meta};return w(H),H})(),O=await v(L),{maxPages:V}=t.options,J=P?Yd:Kd;return{pages:J(b.pages,O,V),pageParams:J(b.pageParams,k,V)}};if(a&&i.length){const b=a==="backward",k=b?nh:Oi,P={pages:i,pageParams:o},A=k(n,P);l=await j(P,A,b)}else{const b=e??i.length;do{const k=c===0?o[0]??n.initialPageParam:Oi(n,l);if(c>0&&k==null)break;l=await j(l,k),c++}while(c<b)}return l};t.options.persister?t.fetchFn=()=>{var x,w;return(w=(x=t.options).persister)==null?void 0:w.call(x,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r)}:t.fetchFn=u}}}function Oi(e,{pages:t,pageParams:r}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function nh(e,{pages:t,pageParams:r}){var n;return t.length>0?(n=e.getPreviousPageParam)==null?void 0:n.call(e,t[0],t,r[0],r):void 0}var Pr,tr,Er,et,rr,Pe,hn,nr,He,Cl,St,Ho,sh=(Ho=class extends kl{constructor(t){super();W(this,He);W(this,Pr);W(this,tr);W(this,Er);W(this,et);W(this,rr);W(this,Pe);W(this,hn);W(this,nr);$(this,nr,!1),$(this,hn,t.defaultOptions),this.setOptions(t.options),this.observers=[],$(this,rr,t.client),$(this,et,g(this,rr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,$(this,tr,Li(this.options)),this.state=t.state??g(this,tr),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return g(this,Pr)}get promise(){var t;return(t=g(this,Pe))==null?void 0:t.promise}setOptions(t){if(this.options={...g(this,hn),...t},t!=null&&t._type&&$(this,Pr,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=Li(this.options);r.data!==void 0&&(this.setState(zi(r.data,r.dataUpdatedAt)),$(this,tr,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&g(this,et).remove(this)}setData(t,r){const n=Js(this.state.data,t,this.options);return te(this,He,St).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(t){te(this,He,St).call(this,{type:"setState",state:t})}cancel(t){var n,a;const r=(n=g(this,Pe))==null?void 0:n.promise;return(a=g(this,Pe))==null||a.cancel(t),r?r.then(Ve).catch(Ve):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return g(this,tr)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>Qe(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Xn||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Bt(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!jl(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=this.observers.find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=g(this,Pe))==null||r.continue()}onOnline(){var r;const t=this.observers.find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=g(this,Pe))==null||r.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),g(this,et).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(g(this,Pe)&&(g(this,nr)||te(this,He,Cl).call(this)?g(this,Pe).cancel({revert:!0}):g(this,Pe).cancelRetry()),this.scheduleGc()),g(this,et).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||te(this,He,St).call(this,{type:"invalidate"})}async fetch(t,r){var u,d,h,m,f,y,x,w,v,j,b;if(this.state.fetchStatus!=="idle"&&((u=g(this,Pe))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(g(this,Pe))return g(this,Pe).continueRetry(),g(this,Pe).promise}if(t&&this.setOptions(t),!this.options.queryFn){const k=this.observers.find(P=>P.options.queryFn);k&&this.setOptions(k.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,a=k=>{Object.defineProperty(k,"signal",{enumerable:!0,get:()=>($(this,nr,!0),n.signal)})},i=()=>{const k=wl(this.options,r),A=(()=>{const L={client:g(this,rr),queryKey:this.queryKey,meta:this.meta};return a(L),L})();return $(this,nr,!1),this.options.persister?this.options.persister(k,A,this):k(A)},l=(()=>{const k={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:g(this,rr),state:this.state,fetchFn:i};return a(k),k})(),c=g(this,Pr)==="infinite"?rh(this.options.pages):this.options.behavior;c==null||c.onFetch(l,this),$(this,Er,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=l.fetchOptions)==null?void 0:d.meta))&&te(this,He,St).call(this,{type:"fetch",meta:(h=l.fetchOptions)==null?void 0:h.meta}),$(this,Pe,Sl({initialPromise:r==null?void 0:r.initialPromise,fn:l.fetchFn,onCancel:k=>{k instanceof Xs&&k.revert&&this.setState({...g(this,Er),fetchStatus:"idle"}),n.abort()},onFail:(k,P)=>{te(this,He,St).call(this,{type:"failed",failureCount:k,error:P})},onPause:()=>{te(this,He,St).call(this,{type:"pause"})},onContinue:()=>{te(this,He,St).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const k=await g(this,Pe).start();if(k===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(k),(f=(m=g(this,et).config).onSuccess)==null||f.call(m,k,this),(x=(y=g(this,et).config).onSettled)==null||x.call(y,k,this.state.error,this),k}catch(k){if(k instanceof Xs){if(k.silent)return g(this,Pe).promise;if(k.revert){if(this.state.data===void 0)throw k;return this.state.data}}throw te(this,He,St).call(this,{type:"error",error:k}),(v=(w=g(this,et).config).onError)==null||v.call(w,k,this),(b=(j=g(this,et).config).onSettled)==null||b.call(j,this.state.data,k,this),k}finally{this.scheduleGc()}}},Pr=new WeakMap,tr=new WeakMap,Er=new WeakMap,et=new WeakMap,rr=new WeakMap,Pe=new WeakMap,hn=new WeakMap,nr=new WeakMap,He=new WeakSet,Cl=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},St=function(t){const r=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,..._l(n.data,this.options),fetchMeta:t.meta??null};case"success":const a={...n,...zi(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return $(this,Er,t.manual?a:void 0),a;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=r(this.state),_e.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),g(this,et).notify({query:this,type:"updated",action:t})})},Ho);function _l(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Nl(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function zi(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Li(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Ue,ne,mn,Me,sr,Tr,kt,zt,fn,Ir,Fr,ar,ir,Lt,Dr,ie,tn,ea,ta,ra,na,sa,aa,ia,Al,Qo,ah=(Qo=class extends Vr{constructor(t,r){super();W(this,ie);W(this,Ue);W(this,ne);W(this,mn);W(this,Me);W(this,sr);W(this,Tr);W(this,kt);W(this,zt);W(this,fn);W(this,Ir);W(this,Fr);W(this,ar);W(this,ir);W(this,Lt);W(this,Dr,new Set);this.options=r,$(this,Ue,t),$(this,zt,null),$(this,kt,Gs()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(g(this,ne).addObserver(this),Mi(g(this,ne),this.options)?te(this,ie,tn).call(this):this.updateResult(),te(this,ie,na).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return oa(g(this,ne),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return oa(g(this,ne),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,te(this,ie,sa).call(this),te(this,ie,aa).call(this),g(this,ne).removeObserver(this)}setOptions(t){const r=this.options,n=g(this,ne);if(this.options=g(this,Ue).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Qe(this.options.enabled,g(this,ne))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");te(this,ie,ia).call(this),g(this,ne).setOptions(this.options),r._defaulted&&!Gn(this.options,r)&&g(this,Ue).getQueryCache().notify({type:"observerOptionsUpdated",query:g(this,ne),observer:this});const a=this.hasListeners();a&&Vi(g(this,ne),n,this.options,r)&&te(this,ie,tn).call(this),this.updateResult(),a&&(g(this,ne)!==n||Qe(this.options.enabled,g(this,ne))!==Qe(r.enabled,g(this,ne))||Bt(this.options.staleTime,g(this,ne))!==Bt(r.staleTime,g(this,ne)))&&te(this,ie,ea).call(this);const i=te(this,ie,ta).call(this);a&&(g(this,ne)!==n||Qe(this.options.enabled,g(this,ne))!==Qe(r.enabled,g(this,ne))||i!==g(this,Lt))&&te(this,ie,ra).call(this,i)}getOptimisticResult(t){const r=g(this,Ue).getQueryCache().build(g(this,Ue),t),n=this.createResult(r,t);return oh(this,n)&&($(this,Me,n),$(this,Tr,this.options),$(this,sr,g(this,ne).state)),n}getCurrentResult(){return g(this,Me)}trackResult(t,r){return new Proxy(t,{get:(n,a)=>(this.trackProp(a),r==null||r(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&g(this,kt).status==="pending"&&g(this,kt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,a))})}trackProp(t){g(this,Dr).add(t)}getCurrentQuery(){return g(this,ne)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=g(this,Ue).defaultQueryOptions(t),n=g(this,Ue).getQueryCache().build(g(this,Ue),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(t){return te(this,ie,tn).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),g(this,Me)))}createResult(t,r){var V;const n=g(this,ne),a=this.options,i=g(this,Me),o=g(this,sr),l=g(this,Tr),u=t!==n?t.state:g(this,mn),{state:d}=t;let h={...d},m=!1,f;if(r._optimisticResults){const J=this.hasListeners(),H=!J&&Mi(t,r),K=J&&Vi(t,n,r,a);(H||K)&&(h={...h,..._l(d.data,t.options)}),r._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:y,errorUpdatedAt:x,status:w}=h;f=h.data;let v=!1;if(r.placeholderData!==void 0&&f===void 0&&w==="pending"){let J;i!=null&&i.isPlaceholderData&&r.placeholderData===(l==null?void 0:l.placeholderData)?(J=i.data,v=!0):J=typeof r.placeholderData=="function"?r.placeholderData((V=g(this,Fr))==null?void 0:V.state.data,g(this,Fr)):r.placeholderData,J!==void 0&&(w="success",f=Js(i==null?void 0:i.data,J,r),m=!0)}if(r.select&&f!==void 0&&!v)if(i&&f===(o==null?void 0:o.data)&&r.select===g(this,fn))f=g(this,Ir);else try{$(this,fn,r.select),f=r.select(f),f=Js(i==null?void 0:i.data,f,r),$(this,Ir,f),$(this,zt,null)}catch(J){$(this,zt,J)}g(this,zt)&&(y=g(this,zt),f=g(this,Ir),x=Date.now(),w="error");const j=h.fetchStatus==="fetching",b=w==="pending",k=w==="error",P=b&&j,A=f!==void 0,O={status:w,fetchStatus:h.fetchStatus,isPending:b,isSuccess:w==="success",isError:k,isInitialLoading:P,isLoading:P,data:f,dataUpdatedAt:h.dataUpdatedAt,error:y,errorUpdatedAt:x,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:j,isRefetching:j&&!b,isLoadingError:k&&!A,isPaused:h.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:k&&A,isStale:Ma(t,r),refetch:this.refetch,promise:g(this,kt),isEnabled:Qe(r.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const J=O.data!==void 0,H=O.status==="error"&&!J,K=ee=>{H?ee.reject(O.error):J&&ee.resolve(O.data)},Z=()=>{const ee=$(this,kt,O.promise=Gs());K(ee)},U=g(this,kt);switch(U.status){case"pending":t.queryHash===n.queryHash&&K(U);break;case"fulfilled":(H||O.data!==U.value)&&Z();break;case"rejected":(!H||O.error!==U.reason)&&Z();break}}return O}updateResult(){const t=g(this,Me),r=this.createResult(g(this,ne),this.options);if($(this,sr,g(this,ne).state),$(this,Tr,this.options),g(this,sr).data!==void 0&&$(this,Fr,g(this,ne)),Gn(r,t))return;$(this,Me,r);const n=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!g(this,Dr).size)return!0;const o=new Set(i??g(this,Dr));return this.options.throwOnError&&o.add("error"),Object.keys(g(this,Me)).some(l=>{const c=l;return g(this,Me)[c]!==t[c]&&o.has(c)})};te(this,ie,Al).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&te(this,ie,na).call(this)}},Ue=new WeakMap,ne=new WeakMap,mn=new WeakMap,Me=new WeakMap,sr=new WeakMap,Tr=new WeakMap,kt=new WeakMap,zt=new WeakMap,fn=new WeakMap,Ir=new WeakMap,Fr=new WeakMap,ar=new WeakMap,ir=new WeakMap,Lt=new WeakMap,Dr=new WeakMap,ie=new WeakSet,tn=function(t){te(this,ie,ia).call(this);let r=g(this,ne).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(Ve)),r},ea=function(){te(this,ie,sa).call(this);const t=Bt(this.options.staleTime,g(this,ne));if(ln.isServer()||g(this,Me).isStale||!Qs(t))return;const n=jl(g(this,Me).dataUpdatedAt,t)+1;$(this,ar,Yt.setTimeout(()=>{g(this,Me).isStale||this.updateResult()},n))},ta=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(g(this,ne)):this.options.refetchInterval)??!1},ra=function(t){te(this,ie,aa).call(this),$(this,Lt,t),!(ln.isServer()||Qe(this.options.enabled,g(this,ne))===!1||!Qs(g(this,Lt))||g(this,Lt)===0)&&$(this,ir,Yt.setInterval(()=>{(this.options.refetchIntervalInBackground||Oa.isFocused())&&te(this,ie,tn).call(this)},g(this,Lt)))},na=function(){te(this,ie,ea).call(this),te(this,ie,ra).call(this,te(this,ie,ta).call(this))},sa=function(){g(this,ar)!==void 0&&(Yt.clearTimeout(g(this,ar)),$(this,ar,void 0))},aa=function(){g(this,ir)!==void 0&&(Yt.clearInterval(g(this,ir)),$(this,ir,void 0))},ia=function(){const t=g(this,Ue).getQueryCache().build(g(this,Ue),this.options);if(t===g(this,ne))return;const r=g(this,ne);$(this,ne,t),$(this,mn,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},Al=function(t){_e.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(g(this,Me))}),g(this,Ue).getQueryCache().notify({query:g(this,ne),type:"observerResultsUpdated"})})},Qo);function ih(e,t){return Qe(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Qe(t.retryOnMount,e)===!1)}function Mi(e,t){return ih(e,t)||e.state.data!==void 0&&oa(e,t,t.refetchOnMount)}function oa(e,t,r){if(Qe(t.enabled,e)!==!1&&Bt(t.staleTime,e)!=="static"){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&Ma(e,t)}return!1}function Vi(e,t,r,n){return(e!==t||Qe(n.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&Ma(e,r)}function Ma(e,t){return Qe(t.enabled,e)!==!1&&e.isStaleByTime(Bt(t.staleTime,e))}function oh(e,t){return!Gn(e.getCurrentResult(),t)}var pn,pt,$e,or,xt,Ft,Ko,lh=(Ko=class extends kl{constructor(t){super();W(this,xt);W(this,pn);W(this,pt);W(this,$e);W(this,or);$(this,pn,t.client),this.mutationId=t.mutationId,$(this,$e,t.mutationCache),$(this,pt,[]),this.state=t.state||Pl(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){g(this,pt).includes(t)||(g(this,pt).push(t),this.clearGcTimeout(),g(this,$e).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){$(this,pt,g(this,pt).filter(r=>r!==t)),this.scheduleGc(),g(this,$e).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){g(this,pt).length||(this.state.status==="pending"?this.scheduleGc():g(this,$e).remove(this))}continue(){var t;return((t=g(this,or))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,c,u,d,h,m,f,y,x,w,v,j,b,k,P,A,L;const r=()=>{te(this,xt,Ft).call(this,{type:"continue"})},n={client:g(this,pn),meta:this.options.meta,mutationKey:this.options.mutationKey};$(this,or,Sl({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(O,V)=>{te(this,xt,Ft).call(this,{type:"failed",failureCount:O,error:V})},onPause:()=>{te(this,xt,Ft).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>g(this,$e).canRun(this)}));const a=this.state.status==="pending",i=!g(this,or).canStart();try{if(a)r();else{te(this,xt,Ft).call(this,{type:"pending",variables:t,isPaused:i}),g(this,$e).config.onMutate&&await g(this,$e).config.onMutate(t,this,n);const V=await((l=(o=this.options).onMutate)==null?void 0:l.call(o,t,n));V!==this.state.context&&te(this,xt,Ft).call(this,{type:"pending",context:V,variables:t,isPaused:i})}const O=await g(this,or).start();return await((u=(c=g(this,$e).config).onSuccess)==null?void 0:u.call(c,O,t,this.state.context,this,n)),await((h=(d=this.options).onSuccess)==null?void 0:h.call(d,O,t,this.state.context,n)),await((f=(m=g(this,$e).config).onSettled)==null?void 0:f.call(m,O,null,this.state.variables,this.state.context,this,n)),await((x=(y=this.options).onSettled)==null?void 0:x.call(y,O,null,t,this.state.context,n)),te(this,xt,Ft).call(this,{type:"success",data:O}),O}catch(O){try{await((v=(w=g(this,$e).config).onError)==null?void 0:v.call(w,O,t,this.state.context,this,n))}catch(V){Promise.reject(V)}try{await((b=(j=this.options).onError)==null?void 0:b.call(j,O,t,this.state.context,n))}catch(V){Promise.reject(V)}try{await((P=(k=g(this,$e).config).onSettled)==null?void 0:P.call(k,void 0,O,this.state.variables,this.state.context,this,n))}catch(V){Promise.reject(V)}try{await((L=(A=this.options).onSettled)==null?void 0:L.call(A,void 0,O,t,this.state.context,n))}catch(V){Promise.reject(V)}throw te(this,xt,Ft).call(this,{type:"error",error:O}),O}finally{g(this,$e).runNext(this)}}},pn=new WeakMap,pt=new WeakMap,$e=new WeakMap,or=new WeakMap,xt=new WeakSet,Ft=function(t){const r=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=r(this.state),_e.batch(()=>{g(this,pt).forEach(n=>{n.onMutationUpdate(t)}),g(this,$e).notify({mutation:this,type:"updated",action:t})})},Ko);function Pl(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ct,ot,xn,Yo,ch=(Yo=class extends Vr{constructor(t={}){super();W(this,Ct);W(this,ot);W(this,xn);this.config=t,$(this,Ct,new Set),$(this,ot,new Map),$(this,xn,0)}build(t,r,n){const a=new lh({client:t,mutationCache:this,mutationId:++In(this,xn)._,options:t.defaultMutationOptions(r),state:n});return this.add(a),a}add(t){g(this,Ct).add(t);const r=Dn(t);if(typeof r=="string"){const n=g(this,ot).get(r);n?n.push(t):g(this,ot).set(r,[t])}this.notify({type:"added",mutation:t})}remove(t){if(g(this,Ct).delete(t)){const r=Dn(t);if(typeof r=="string"){const n=g(this,ot).get(r);if(n)if(n.length>1){const a=n.indexOf(t);a!==-1&&n.splice(a,1)}else n[0]===t&&g(this,ot).delete(r)}}this.notify({type:"removed",mutation:t})}canRun(t){const r=Dn(t);if(typeof r=="string"){const n=g(this,ot).get(r),a=n==null?void 0:n.find(i=>i.state.status==="pending");return!a||a===t}else return!0}runNext(t){var n;const r=Dn(t);if(typeof r=="string"){const a=(n=g(this,ot).get(r))==null?void 0:n.find(i=>i!==t&&i.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){_e.batch(()=>{g(this,Ct).forEach(t=>{this.notify({type:"removed",mutation:t})}),g(this,Ct).clear(),g(this,ot).clear()})}getAll(){return Array.from(g(this,Ct))}find(t){const r={exact:!0,...t};return this.getAll().find(n=>Di(r,n))}findAll(t={}){return this.getAll().filter(r=>Di(t,r))}notify(t){_e.batch(()=>{this.listeners.forEach(r=>{r(t)})})}resumePausedMutations(){const t=this.getAll().filter(r=>r.state.isPaused);return _e.batch(()=>Promise.all(t.map(r=>r.continue().catch(Ve))))}},Ct=new WeakMap,ot=new WeakMap,xn=new WeakMap,Yo);function Dn(e){var t;return(t=e.options.scope)==null?void 0:t.id}var _t,Mt,Ze,At,Pt,Bn,la,Jo,uh=(Jo=class extends Vr{constructor(t,r){super();W(this,Pt);W(this,_t);W(this,Mt);W(this,Ze);W(this,At);$(this,_t,t),this.setOptions(r),this.bindMethods(),te(this,Pt,Bn).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var n;const r=this.options;this.options=g(this,_t).defaultMutationOptions(t),Gn(this.options,r)||g(this,_t).getMutationCache().notify({type:"observerOptionsUpdated",mutation:g(this,Ze),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&lr(r.mutationKey)!==lr(this.options.mutationKey)?this.reset():((n=g(this,Ze))==null?void 0:n.state.status)==="pending"&&g(this,Ze).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=g(this,Ze))==null||t.removeObserver(this)}onMutationUpdate(t){te(this,Pt,Bn).call(this),te(this,Pt,la).call(this,t)}getCurrentResult(){return g(this,Mt)}reset(){var t;(t=g(this,Ze))==null||t.removeObserver(this),$(this,Ze,void 0),te(this,Pt,Bn).call(this),te(this,Pt,la).call(this)}mutate(t,r){var n;return $(this,At,r),(n=g(this,Ze))==null||n.removeObserver(this),$(this,Ze,g(this,_t).getMutationCache().build(g(this,_t),this.options)),g(this,Ze).addObserver(this),g(this,Ze).execute(t)}},_t=new WeakMap,Mt=new WeakMap,Ze=new WeakMap,At=new WeakMap,Pt=new WeakSet,Bn=function(){var r;const t=((r=g(this,Ze))==null?void 0:r.state)??Pl();$(this,Mt,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},la=function(t){_e.batch(()=>{var r,n,a,i,o,l,c,u;if(g(this,At)&&this.hasListeners()){const d=g(this,Mt).variables,h=g(this,Mt).context,m={client:g(this,_t),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(n=(r=g(this,At)).onSuccess)==null||n.call(r,t.data,d,h,m)}catch(f){Promise.reject(f)}try{(i=(a=g(this,At)).onSettled)==null||i.call(a,t.data,null,d,h,m)}catch(f){Promise.reject(f)}}else if((t==null?void 0:t.type)==="error"){try{(l=(o=g(this,At)).onError)==null||l.call(o,t.error,d,h,m)}catch(f){Promise.reject(f)}try{(u=(c=g(this,At)).onSettled)==null||u.call(c,void 0,t.error,d,h,m)}catch(f){Promise.reject(f)}}}this.listeners.forEach(d=>{d(g(this,Mt))})})},Jo),gt,Go,dh=(Go=class extends Vr{constructor(t={}){super();W(this,gt);this.config=t,$(this,gt,new Map)}build(t,r,n){const a=r.queryKey,i=r.queryHash??za(a,r);let o=this.get(i);return o||(o=new sh({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(r),state:n,defaultOptions:t.getQueryDefaults(a)}),this.add(o)),o}add(t){g(this,gt).has(t.queryHash)||(g(this,gt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=g(this,gt).get(t.queryHash);r&&(t.destroy(),r===t&&g(this,gt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){_e.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return g(this,gt).get(t)}getAll(){return[...g(this,gt).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(n=>Fi(r,n))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(n=>Fi(t,n)):r}notify(t){_e.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){_e.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){_e.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},gt=new WeakMap,Go),je,Vt,qt,Rr,$r,Ut,Or,zr,Xo,hh=(Xo=class{constructor(e={}){W(this,je);W(this,Vt);W(this,qt);W(this,Rr);W(this,$r);W(this,Ut);W(this,Or);W(this,zr);$(this,je,e.queryCache||new dh),$(this,Vt,e.mutationCache||new ch),$(this,qt,e.defaultOptions||{}),$(this,Rr,new Map),$(this,$r,new Map),$(this,Ut,0)}mount(){In(this,Ut)._++,g(this,Ut)===1&&($(this,Or,Oa.subscribe(async e=>{e&&(await this.resumePausedMutations(),g(this,je).onFocus())})),$(this,zr,es.subscribe(async e=>{e&&(await this.resumePausedMutations(),g(this,je).onOnline())})))}unmount(){var e,t;In(this,Ut)._--,g(this,Ut)===0&&((e=g(this,Or))==null||e.call(this),$(this,Or,void 0),(t=g(this,zr))==null||t.call(this),$(this,zr,void 0))}isFetching(e){return g(this,je).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return g(this,Vt).findAll({...e,status:"pending"}).length}getQueryData(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=g(this,je).get(t.queryHash))==null?void 0:r.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=g(this,je).build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(Bt(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return g(this,je).findAll(e).map(({queryKey:t,state:r})=>{const n=r.data;return[t,n]})}setQueryData(e,t,r){const n=this.defaultQueryOptions({queryKey:e}),a=g(this,je).get(n.queryHash),i=a==null?void 0:a.state.data,o=Wd(t,i);if(o!==void 0)return g(this,je).build(this,n).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return _e.batch(()=>g(this,je).findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=g(this,je).get(t.queryHash))==null?void 0:r.state}removeQueries(e){const t=g(this,je);_e.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=g(this,je);return _e.batch(()=>(r.findAll(e).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const r={revert:!0,...t},n=_e.batch(()=>g(this,je).findAll(e).map(a=>a.cancel(r)));return Promise.all(n).then(Ve).catch(Ve)}invalidateQueries(e,t={}){return _e.batch(()=>(g(this,je).findAll(e).forEach(r=>{r.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const r={...t,cancelRefetch:t.cancelRefetch??!0},n=_e.batch(()=>g(this,je).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,r);return r.throwOnError||(i=i.catch(Ve)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(Ve)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=g(this,je).build(this,t);return r.isStaleByTime(Bt(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ve).catch(Ve)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ve).catch(Ve)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return es.isOnline()?g(this,Vt).resumePausedMutations():Promise.resolve()}getQueryCache(){return g(this,je)}getMutationCache(){return g(this,Vt)}getDefaultOptions(){return g(this,qt)}setDefaultOptions(e){$(this,qt,e)}setQueryDefaults(e,t){g(this,Rr).set(lr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...g(this,Rr).values()],r={};return t.forEach(n=>{on(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){g(this,$r).set(lr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...g(this,$r).values()],r={};return t.forEach(n=>{on(e,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...g(this,qt).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=za(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Xn&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...g(this,qt).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){g(this,je).clear(),g(this,Vt).clear()}},je=new WeakMap,Vt=new WeakMap,qt=new WeakMap,Rr=new WeakMap,$r=new WeakMap,Ut=new WeakMap,Or=new WeakMap,zr=new WeakMap,Xo),El=C.createContext(void 0),Tt=e=>{const t=C.useContext(El);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},mh=({client:e,children:t})=>(C.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(El.Provider,{value:e,children:t})),Tl=C.createContext(!1),fh=()=>C.useContext(Tl);Tl.Provider;function ph(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var xh=C.createContext(ph()),gh=()=>C.useContext(xh),yh=(e,t,r)=>{const n=r!=null&&r.state.error&&typeof e.throwOnError=="function"?La(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||n)&&(t.isReset()||(e.retryOnMount=!1))},bh=e=>{C.useEffect(()=>{e.clearReset()},[e])},vh=({result:e,errorResetBoundary:t,throwOnError:r,query:n,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(a&&e.data===void 0||La(r,[e.error,n])),jh=e=>{if(e.suspense){const r=a=>a==="static"?a:Math.max(a??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...a)=>r(n(...a)):r(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},wh=(e,t)=>e.isLoading&&e.isFetching&&!t,Nh=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,qi=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function Sh(e,t,r){var f,y,x,w;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=fh(),a=gh(),i=Tt(),o=i.defaultQueryOptions(e);(y=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||y.call(f,o);const l=i.getQueryCache().get(o.queryHash);process.env.NODE_ENV!=="production"&&(o.queryFn||console.error(`[${o.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`));const c=e.subscribed!==!1;o._optimisticResults=n?"isRestoring":c?"optimistic":void 0,jh(o),yh(o,a,l),bh(a);const u=!i.getQueryCache().get(o.queryHash),[d]=C.useState(()=>new t(i,o)),h=d.getOptimisticResult(o),m=!n&&c;if(C.useSyncExternalStore(C.useCallback(v=>{const j=m?d.subscribe(_e.batchCalls(v)):Ve;return d.updateResult(),j},[d,m]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),C.useEffect(()=>{d.setOptions(o)},[o,d]),Nh(o,h))throw qi(o,d,a);if(vh({result:h,errorResetBoundary:a,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw h.error;if((w=(x=i.getDefaultOptions().queries)==null?void 0:x._experimental_afterQuery)==null||w.call(x,o,h),o.experimental_prefetchInRender&&!ln.isServer()&&wh(h,n)){const v=u?qi(o,d,a):l==null?void 0:l.promise;v==null||v.catch(Ve).finally(()=>{d.updateResult()})}return o.notifyOnChangeProps?h:d.trackResult(h)}function Ee(e,t){return Sh(e,ah)}function kh(e,t){const r=Tt(),[n]=C.useState(()=>new uh(r,e));C.useEffect(()=>{n.setOptions(e)},[n,e]);const a=C.useSyncExternalStore(C.useCallback(o=>n.subscribe(_e.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=C.useCallback((o,l)=>{n.mutate(o,l).catch(Ve)},[n]);if(a.error&&La(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}function Il(e){return e.trim().replace(/\/+$/,"")}let ca=null;function Fl(e){ca=Il(e)}let Dl=null;function Ch(e){Dl=e}function _h(){return Dl}let Rl=null;function Ah(e){Rl=e.trim()}function Ph(){return Rl}function Eh(){return ca!==null?ca:Il("")}const Ui={get apiBaseUrl(){return Eh()},apiVersion:"v1"};function Th(e){const t=e.startsWith("/")?e:`/${e}`;return`${Ui.apiBaseUrl}/api/${Ui.apiVersion}${t}`}const ua="auth:session-expired";function Ih(){window.dispatchEvent(new CustomEvent(ua))}const Fh=_.createContext(null);function Dh({accessToken:e,onSessionExpired:t,children:r}){return Ch(e),_.useEffect(()=>{if(!t)return;const n=()=>t();return window.addEventListener(ua,n),()=>window.removeEventListener(ua,n)},[t]),s.jsx(Fh.Provider,{value:{accessToken:e},children:r})}class bn extends Error{constructor(r,n,a,i){super(a??n);Tn(this,"status");Tn(this,"title");Tn(this,"details");this.name="ApiError",this.status=r,this.title=n,this.details=i}}const $l="tax-remittance.auth";function Rh(){var t;const e=localStorage.getItem($l);if(!e)return null;try{const r=JSON.parse(e);return!r.accessToken||!((t=r.user)!=null&&t.userId)?null:new Date(r.user.expiresAt)<=new Date?(da(),null):r}catch{return da(),null}}function da(){localStorage.removeItem($l)}function $h(){var e;return((e=Rh())==null?void 0:e.accessToken)??null}async function Oh(e){let t=null;try{t=await e.json()}catch{}return new bn(e.status,(t==null?void 0:t.title)??"Request failed",t==null?void 0:t.detail,t==null?void 0:t.errors)}async function zh(e,t={}){const{body:r,auth:n=!0,headers:a,...i}=t,o=new Headers(a);if(o.set("Accept","application/json"),r!==void 0&&o.set("Content-Type","application/json"),n){const u=_h()??$h();u&&o.set("Authorization",`Bearer ${u}`)}const l=Ph();l&&o.set("X-Client-ID",l);const c=await fetch(Th(e),{...i,headers:o,body:r!==void 0?JSON.stringify(r):void 0});if(!c.ok){const u=await Oh(c);throw n&&(u.status===401||u.status===403)&&(da(),Ih()),u}if(c.status!==204)return await c.json()}async function ue(e,t={}){return(await zh(e,t)).data}function Ol(){return ue("/portal/entities/mine")}function Lh(e){return ue("/portal/entities",{method:"POST",body:e})}const zl=_.createContext(null);function Mh({onOrganizationCreated:e,children:t}){var h;const[r,n]=_.useState(null),{data:a=[],isLoading:i,refetch:o}=Ee({queryKey:["entities","mine"],queryFn:Ol}),l=_.useRef(0);_.useEffect(()=>{if(!i){if(a.length>l.current){const m=a[a.length-1];e==null||e(m)}l.current=a.length}},[a,i,e]);const c=r!==null&&a.some(m=>m.entityId===r)?r:((h=a[0])==null?void 0:h.entityId)??null,u=a.find(m=>m.entityId===c)??null,d=async()=>{await o()};return s.jsx(zl.Provider,{value:{entities:a,isLoading:i,selectedEntity:u,setSelectedEntityId:n,refetchEntities:d},children:t})}function Va(){const e=_.useContext(zl);if(!e)throw new Error("useEmbeddedContext must be used inside EmbeddedContextProvider");return e}function Vh({theme:e,children:t}){const r={},n=r,a=(e==null?void 0:e.primaryColor)??"#2563eb";n["--embedded-primary"]=a,n["--embedded-primary-dark"]=`color-mix(in srgb, ${a} 82%, black)`,n["--embedded-primary-light"]=`color-mix(in srgb, ${a} 15%, white)`;const i=(e==null?void 0:e.secondaryColor)??"#0891b2";n["--embedded-secondary"]=i,n["--embedded-secondary-dark"]=`color-mix(in srgb, ${i} 82%, black)`,n["--embedded-secondary-light"]=`color-mix(in srgb, ${i} 15%, white)`;const o=(e==null?void 0:e.tertiaryColor)??"#7c3aed";return n["--embedded-tertiary"]=o,n["--embedded-tertiary-dark"]=`color-mix(in srgb, ${o} 82%, black)`,n["--embedded-tertiary-light"]=`color-mix(in srgb, ${o} 15%, white)`,e!=null&&e.borderRadius&&(n["--embedded-radius"]=e.borderRadius),e!=null&&e.fontFamily&&(r.fontFamily=e.fontFamily),n.minHeight="100%",s.jsx("div",{className:"tax-remittance-embedded",style:r,children:t})}function qh(e){return e.startsWith("/dashboard")?"dashboard":e.startsWith("/payments")?"payments":e.startsWith("/tax-forms")?"tax-forms":e.startsWith("/settings")?"settings":e.startsWith("/create-entity")?"create-entity":"other"}function Uh({navigateFnRef:e,onNavigate:t}){const r=Te(),n=we();return _.useEffect(()=>(e.current=r,()=>{e.current=null}),[r,e]),_.useEffect(()=>{t==null||t(qh(n.pathname),n.pathname)},[n.pathname,t]),null}function qa({appKey:e,accessToken:t,apiBaseUrl:r,theme:n,onSessionExpired:a,onOrganizationCreated:i,onNavigate:o,navigateFnRef:l,children:c}){Fl(r),Ah(e);const[u]=_.useState(()=>new hh({defaultOptions:{queries:{retry:1,staleTime:300*1e3,refetchOnWindowFocus:!1}}}));return s.jsx(Vh,{theme:n,children:s.jsx(mh,{client:u,children:s.jsx(Dh,{accessToken:t,onSessionExpired:a,children:s.jsx(sd,{children:s.jsxs(Mh,{onOrganizationCreated:i,children:[s.jsx(Uh,{navigateFnRef:l,onNavigate:o}),c]})})})})})}function Ua(){const{entities:e,isLoading:t}=Va(),r=Te();return _.useEffect(()=>{t||(e.length===0?r("/create-entity",{replace:!0}):r("/dashboard",{replace:!0}))},[t,e,r]),t?s.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:s.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-slate-200 border-t-slate-600"})}):null}function Za(){const{entities:e,selectedEntity:t,setSelectedEntityId:r}=Va(),n=Te(),o=!(we().pathname==="/dashboard");return s.jsxs("div",{className:"flex min-h-full flex-col bg-slate-50",children:[s.jsxs("div",{className:"flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3",children:[o&&s.jsxs("button",{type:"button",onClick:()=>n(-1),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-sm text-slate-500 transition hover:bg-slate-100 hover:text-slate-700",children:[s.jsx(Zh,{}),"Back"]}),s.jsx("div",{className:"flex-1"}),e.length>1&&s.jsx("select",{value:(t==null?void 0:t.entityId)??"",onChange:l=>r(Number(l.target.value)),className:"rounded-lg border border-slate-200 bg-white px-3 py-1.5 text-sm text-slate-700 focus:outline-none focus:ring-2 focus:ring-slate-300",children:e.map(l=>s.jsx("option",{value:l.entityId,children:l.tradeName||l.firstName},l.entityId))}),e.length===1&&t&&s.jsx("span",{className:"text-sm font-medium text-slate-700",children:t.tradeName||t.firstName})]}),s.jsx("main",{className:"flex-1 p-5",children:s.jsx(ad,{context:{entities:e,selectedEntity:t,setSelectedEntityId:r}})})]})}function Zh(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}const Bh=["Organization name & EIN","Business type & primary state","Automatic dashboard access","Start managing tax payments"];function Wh({onCreateClick:e}){return s.jsxs("div",{className:"w-full max-w-[400px]",children:[s.jsxs("div",{className:"overflow-hidden rounded-2xl border border-slate-200/80 bg-white shadow-xl shadow-slate-200/60",children:[s.jsxs("div",{className:"bg-gov-600 px-8 pb-8 pt-10 text-center",children:[s.jsx("div",{className:"mx-auto mb-5 flex h-14 w-14 items-center justify-center rounded-2xl bg-white/15 ring-1 ring-white/20",children:s.jsx(Zi,{className:"h-7 w-7 text-white"})}),s.jsx("h2",{className:"text-xl font-bold text-white",children:"Create Your Entity"}),s.jsx("p",{className:"mt-2 text-sm text-white/80",children:"Get set up in under 1 minute"})]}),s.jsxs("div",{className:"space-y-4 px-8 py-8",children:[s.jsx("ul",{className:"space-y-3.5",children:Bh.map(t=>s.jsxs("li",{className:"flex items-center gap-3 text-sm text-slate-700",children:[s.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-gov-100 text-gov-600",children:s.jsx(Bi,{})}),t]},t))}),s.jsxs("button",{type:"button",onClick:e,className:"mt-6 flex h-12 w-full items-center justify-center gap-2 rounded-xl bg-gov-600 text-sm font-semibold text-white transition hover:bg-gov-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-500 focus-visible:ring-offset-2",children:[s.jsx(Zi,{className:"h-4 w-4"}),"Create Entity",s.jsx(Hh,{})]})]})]}),s.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-2 text-xs text-slate-500",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(Qh,{}),"SOC 2 Certified"]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(Bi,{className:"h-3.5 w-3.5"}),"Bank-grade encryption"]}),s.jsx("span",{children:"Free to start"})]})]})}function Zi({className:e="h-5 w-5"}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 21h19.5m-18-18v18m10.5-18v18m6-13.5V21M6.75 6.75h.75m-.75 3h.75m-.75 3h.75m3-6h.75m-.75 3h.75m-.75 3h.75M6.75 21v-3.375c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21M3 21h18M12 3l9 4.5v1.5H3V7.5L12 3z"})})}function Bi({className:e="h-3 w-3"}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 16 16",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.5 8.5l3 3 6-6"})})}function Hh(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3"})})}function Qh(){return s.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 013.598 6 11.99 11.99 0 003 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285z"})})}function Ba(){const e=Te(),t=()=>{e("/create-entity/form",{state:{from:"/dashboard"}})};return s.jsx("div",{className:"flex min-h-full items-center justify-center bg-slate-100/80 px-4 py-12",children:s.jsx(Wh,{onCreateClick:t})})}var vn=e=>e.type==="checkbox",Zt=e=>e instanceof Date,De=e=>e==null;const Wa=e=>typeof e=="object";var fe=e=>!De(e)&&!Array.isArray(e)&&Wa(e)&&!Zt(e),ha=e=>fe(e)&&e.target?vn(e.target)?e.target.checked:e.target.value:e,Ll=(e,t)=>t.split(".").some((r,n,a)=>!isNaN(Number(r))&&e.has(a.slice(0,n).join("."))),Ml=e=>{const t=e.constructor&&e.constructor.prototype;return fe(t)&&t.hasOwnProperty("isPrototypeOf")},fs=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function ve(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(fs&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(fe(e)&&Ml(e)))return e;const n=r?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=ve(e[a]));return n}const Dt={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},lt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},it={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Vl="root",Ha=["__proto__","constructor","prototype"],Kh=/^\w*$/;var jn=e=>Kh.test(e),ce=e=>e===void 0;const Yh=/[.[\]'"]/;var ps=e=>e.split(Yh).filter(Boolean),D=(e,t,r)=>{if(!t||!fe(e))return r;const n=jn(t)?[t]:ps(t);if(n.some(i=>Ha.includes(i)))return r;const a=n.reduce((i,o)=>De(i)?void 0:i[o],e);return ce(a)||a===e?ce(e[t])?r:e[t]:a},Ke=e=>typeof e=="boolean",Oe=e=>typeof e=="function",ae=(e,t,r)=>{let n=-1;const a=jn(t)?[t]:ps(t),i=a.length,o=i-1;for(;++n<i;){const l=a[n];let c=r;if(n!==o){const u=e[l];c=fe(u)||Array.isArray(u)?u:isNaN(+a[n+1])?{}:[]}if(Ha.includes(l))return;e[l]=c,e=e[l]}};const ql=_.createContext(null);ql.displayName="HookFormControlContext";const Qa=()=>_.useContext(ql);var Ul=(e,t,r,n=!0)=>{const a={};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return t._proxyFormState[o]!==lt.all&&(t._proxyFormState[o]=!n||lt.all),r&&(r[o]=!0),e[o]}});return a};const Ka=fs?_.useLayoutEffect:_.useEffect;function Jh(e){const t=Qa(),{control:r=t,disabled:n,name:a,exact:i}=e||{},[o,l]=_.useState(()=>({...r._formState,defaultValues:r._defaultValues})),c=_.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Ka(()=>r._subscribe({name:a,formState:c.current,exact:i,callback:u=>{!n&&l({...r._formState,...u,defaultValues:r._defaultValues})}}),[a,n,i]),_.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),_.useMemo(()=>Ul(o,r,c.current,!1),[o,r])}var ze=e=>typeof e=="string",ma=(e,t,r,n,a)=>ze(e)?(n&&t.watch.add(e),D(r,e,a)):Array.isArray(e)?e.map(i=>(n&&t.watch.add(i),D(r,i))):(n&&(t.watchAll=!0),r),fa=e=>De(e)||!Wa(e);const Wi=(e,t)=>t.length===0&&!Array.isArray(e)&&!Ml(e);function Ye(e,t,r=new WeakMap){if(e===t)return!0;if(fa(e)||fa(t))return Object.is(e,t);if(Zt(e)&&Zt(t))return Object.is(e.getTime(),t.getTime());const n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;if(Wi(e,n)||Wi(t,a))return Object.is(e,t);if(!n.length&&Array.isArray(e)!==Array.isArray(t))return!1;const i=r.get(e);if(i&&i.has(t))return!0;if(i)i.add(t);else{const o=new WeakSet;o.add(t),r.set(e,o)}for(const o of n){const l=e[o];if(!(o in t))return!1;if(o!=="ref"){const c=t[o];if(Zt(l)&&Zt(c)||(fe(l)||Array.isArray(l))&&(fe(c)||Array.isArray(c))?!Ye(l,c,r):!Object.is(l,c))return!1}}return!0}function Gh(e){const t=Qa(),{control:r=t,name:n,defaultValue:a,disabled:i,exact:o,compute:l}=e||{},c=_.useRef(a),u=_.useRef(l),d=_.useRef(void 0),h=_.useRef(r),m=_.useRef(n);u.current=l;const[f,y]=_.useState(()=>{const k=r._getWatch(n,c.current);return u.current?u.current(k):k}),x=_.useCallback(k=>{const P=ma(n,r._names,k||r._formValues,!1,c.current);return u.current?u.current(P):P},[r._formValues,r._names,n]),w=_.useCallback(k=>{if(!i){const P=ma(n,r._names,k||r._formValues,!1,c.current);if(u.current){const A=u.current(P);Ye(A,d.current)||(y(A),d.current=A)}else y(P)}},[r._formValues,r._names,i,n]);Ka(()=>((h.current!==r||!Ye(m.current,n))&&(h.current=r,m.current=n,w()),r._subscribe({name:n,formState:{values:!0},exact:o,callback:k=>{w(k.values)}})),[r,o,n,w]),_.useEffect(()=>r._removeUnmounted());const v=h.current!==r,j=m.current,b=_.useMemo(()=>{if(i)return null;const k=!v&&!Ye(j,n);return v||k?x():null},[i,v,n,j,x]);return b!==null?b:f}function Xh(e){const t=Qa(),{name:r,disabled:n,control:a=t,shouldUnregister:i,defaultValue:o,exact:l=!0}=e,c=Ll(a._names.array,r),u=_.useMemo(()=>D(a._formValues,r,D(a._defaultValues,r,o)),[a,r,o]),d=Gh({control:a,name:r,defaultValue:u,exact:l}),h=Jh({control:a,name:r,exact:l}),m=_.useRef(e),f=_.useRef(null),y=_.useRef(a.register(r,{...e.rules,value:d,...Ke(e.disabled)?{disabled:e.disabled}:{}}));m.current=e;const x=_.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!D(h.errors,r)},isDirty:{enumerable:!0,get:()=>!!D(h.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!D(h.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!D(h.validatingFields,r)},error:{enumerable:!0,get:()=>D(h.errors,r)}}),[h,r]),w=_.useCallback(k=>{const P=ha(k);return D(a._fields,r)||(y.current=a.register(r,{...m.current.rules,value:P})),y.current.onChange({target:{value:ha(k),name:r},type:Dt.CHANGE})},[r,a]),v=_.useCallback(()=>y.current.onBlur({target:{value:D(a._formValues,r),name:r},type:Dt.BLUR}),[r,a._formValues]),j=_.useCallback(k=>{k&&(f.current={focus:()=>Oe(k.focus)&&k.focus(),select:()=>Oe(k.select)&&k.select(),setCustomValidity:A=>Oe(k.setCustomValidity)&&k.setCustomValidity(A),reportValidity:()=>Oe(k.reportValidity)&&k.reportValidity()});const P=D(a._fields,r);P&&P._f&&k&&(P._f.ref=f.current)},[a._fields,r]),b=_.useMemo(()=>({name:r,value:d,...Ke(n)||h.disabled?{disabled:h.disabled||n}:{},onChange:w,onBlur:v,ref:j}),[r,n,h.disabled,w,v,j,d]);return _.useEffect(()=>{const k=a._options.shouldUnregister||i;a.register(r,{...m.current.rules,...Ke(m.current.disabled)?{disabled:m.current.disabled}:{}});const P=(A,L)=>{const O=D(a._fields,A);O&&O._f&&(O._f.mount=L)};if(P(r,!0),k){const A=ve(D(i?a._defaultValues:a._options.values||a._defaultValues,r,D(a._options.defaultValues,r,m.current.defaultValue)));ae(a._defaultValues,r,A),ce(D(a._formValues,r))&&ae(a._formValues,r,A)}if(!c&&a.register(r),f.current){const A=D(a._fields,r);A&&A._f&&(A._f.ref=f.current)}return()=>{(c?k&&!a._state.action:k)?a.unregister(r):P(r,!1)}},[r,a,c,i]),_.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),_.useMemo(()=>({field:b,formState:h,fieldState:x}),[b,h,x])}const Wn=e=>e.render(Xh(e)),Zl=e=>{const t={};for(const r of Object.keys(e))if(Wa(e[r])&&e[r]!==null&&!Zt(e[r])){const n=Zl(e[r]);for(const a of Object.keys(n))t[`${r}.${a}`]=n[a]}else t[r]=e[r];return t},em=_.createContext(null);em.displayName="HookFormContext";var Ya=(e,t,r,n,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:a||!0}}:{},Bl=e=>Array.isArray(e)?e.filter(Boolean):[],Hn=e=>Array.isArray(e)?e:[e],Hi=()=>{let e=[];return{get observers(){return e},next:a=>{for(const i of e)i.next&&i.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(i=>i!==a)}}),unsubscribe:()=>{e=[]}}};function Wl(e,t){const r={};for(const n in e)if(e.hasOwnProperty(n)){const a=e[n],i=t[n];if(a&&fe(a)&&i){const o=Wl(a,i);fe(o)&&(r[n]=o)}else e[n]&&(r[n]=i)}return r}var Fe=e=>fe(e)&&!Object.keys(e).length,Ja=e=>e.type==="file",ts=e=>{if(!fs)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Hl=e=>e.type==="select-multiple",Ga=e=>e.type==="radio",tm=e=>Ga(e)||vn(e),Rs=e=>ts(e)&&e.isConnected;function rm(e,t){const r=t.slice(0,-1).length;let n=0;for(;n<r;){if(De(e)){e=void 0;break}e=e[t[n]],n++}return e}function nm(e){for(const t in e)if(e.hasOwnProperty(t)&&!ce(e[t]))return!1;return!0}function Ne(e,t){if(ze(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;const r=Array.isArray(t)?t:jn(t)?[t]:ps(t);if(r.some(o=>Ha.includes(String(o))))return e;const n=r.length===1?e:rm(e,r),a=r.length-1,i=r[a];return n&&delete n[i],a!==0&&(fe(n)&&Fe(n)||Array.isArray(n)&&nm(n))&&Ne(e,r.slice(0,-1)),e}var sm=e=>{for(const t in e)if(Oe(e[t]))return!0;return!1};function Ql(e){return Array.isArray(e)||fe(e)&&!sm(e)}function pa(e,t={}){for(const r in e){const n=e[r];Ql(n)?(t[r]=Array.isArray(n)?[]:{},pa(n,t[r])):ce(n)||(t[r]=!0)}return t}function xa(e){if(e!==!1){if(e===!0)return!0;if(Array.isArray(e)){const t=e.map(r=>xa(r));return t.some(r=>r!==void 0)?t:void 0}if(fe(e)){const t={};for(const r in e){const n=xa(e[r]);ce(n)||(t[r]=n)}return Object.keys(t).length?t:void 0}}}function Kt(e,t,r){r||(r=pa(t));for(const n in e){const a=e[n];if(Ql(a))ce(t)||fa(r[n])?r[n]=pa(a,Array.isArray(a)?[]:{}):Kt(a,De(t)?{}:t[n],r[n]);else{const i=t[n];r[n]=!Ye(a,i)}}return xa(r)||{}}const Qi={value:!1,isValid:!1},Ki={value:!0,isValid:!0};var Kl=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!ce(e[0].attributes.value)?ce(e[0].value)||e[0].value===""?Ki:{value:e[0].value,isValid:!0}:Ki:Qi}return Qi},Yl=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:n})=>ce(e)?e:t?e===""?NaN:e&&+e:r&&ze(e)?new Date(e):n?n(e):e;const Yi={isValid:!1,value:null};var Jl=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,Yi):Yi;function Ji(e){const t=e.ref;return Ja(t)?t.files:Ga(t)?Jl(e.refs).value:Hl(t)?[...t.selectedOptions].map(({value:r})=>r):vn(t)?Kl(e.refs).value:Yl(ce(t.value)?e.ref.value:t.value,e)}var am=(e,t,r,n)=>{const a={};for(const i of e){const o=D(t,i);o&&ae(a,i,o._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:n}},rs=e=>e instanceof RegExp,Jr=e=>ce(e)?e:rs(e)?e.source:fe(e)?rs(e.value)?e.value.source:e.value:e,Rn=e=>({isOnSubmit:!e||e===lt.onSubmit,isOnBlur:e===lt.onBlur,isOnChange:e===lt.onChange,isOnAll:e===lt.all,isOnTouch:e===lt.onTouched});const Gi="AsyncFunction";var im=e=>{if(!e||!e.validate)return!1;if(Oe(e.validate))return e.validate.constructor.name===Gi;if(fe(e.validate)){for(const t in e.validate)if(e.validate[t].constructor.name===Gi)return!0}return!1},om=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),$s=(e,t,r)=>{if(r)return!1;if(t.watchAll||t.watch.has(e))return!0;for(const n of t.watch)if(e.startsWith(n)&&e.charAt(n.length)===".")return!0;return!1};const nn=(e,t,r,n)=>{for(const a of r||Object.keys(e)){const i=D(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],a)&&!n)return!0;if(o.ref&&t(o.ref,o.name)&&!n)return!0;if(nn(l,t))break}else if(fe(l)&&nn(l,t))break}}};function Xi(e,t,r){const n=D(e,r);if(n||jn(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const i=a.join("."),o=D(t,i),l=D(e,i);if(o&&!Array.isArray(o)&&r!==i)return{name:r};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};a.pop()}return{name:r}}var lm=(e,t,r,n)=>{r(e);const{name:a,...i}=e,o=Object.keys(i);return!o.length||n&&o.length>=Object.keys(t).length||o.find(l=>t[l]===(!n||lt.all))},cm=(e,t,r)=>!e||!t||e===t||Hn(e).some(n=>n&&(r?n===t||n.startsWith(t+"."):n.startsWith(t)||t.startsWith(n))),um=(e,t,r,n,a)=>a.isOnAll?!1:!r&&a.isOnTouch?!(t||e):(r?n.isOnBlur:a.isOnBlur)?!e:(r?n.isOnChange:a.isOnChange)?e:!0,dm=(e,t)=>!Bl(D(e,t)).length&&Ne(e,t),eo=(e,t,r)=>{const n=D(e,r),a=Array.isArray(n)?n:[];return ae(a,Vl,t[r]),ae(e,r,a),e};function to(e,t,r="validate"){if(ze(e)||Array.isArray(e)&&e.every(ze)||Ke(e)&&!e)return{type:r,message:ze(e)?e:"",ref:t}}var jr=e=>fe(e)&&!rs(e)?e:{value:e,message:""},ro=async(e,t,r,n,a,i)=>{const{ref:o,refs:l,required:c,maxLength:u,minLength:d,min:h,max:m,pattern:f,validate:y,name:x,valueAsNumber:w,mount:v}=e._f,j=D(r,x);if(!v||t.has(x))return{};const b=l?l[0]:o,k=K=>{if(a&&b.reportValidity){const Z=Ke(K)?"":K||"";l?l.forEach(U=>U.setCustomValidity(Z)):b.setCustomValidity(Z),b.reportValidity()}},P={},A=Ga(o),L=vn(o),O=A||L,V=(w||Ja(o))&&ce(o.value)&&ce(j)||ts(o)&&o.value===""||j===""||Array.isArray(j)&&!j.length,J=Ya.bind(null,x,n,P),H=(K,Z,U,ee=it.maxLength,oe=it.minLength)=>{const ge=K?Z:U;P[x]={type:K?ee:oe,message:ge,ref:o,...J(K?ee:oe,ge)}};if(i?!Array.isArray(j)||!j.length:c&&(!O&&(V||De(j))||Ke(j)&&!j||L&&!Kl(l).isValid||A&&!Jl(l).isValid)){const{value:K,message:Z}=ze(c)?{value:!!c,message:c}:jr(c);if(K&&(P[x]={type:it.required,message:Z,ref:b,...J(it.required,Z)},!n))return k(Z),P}if(!V&&(!De(h)||!De(m))){let K,Z;const U=jr(m),ee=jr(h);if(!De(j)&&!isNaN(j)){const oe=o.valueAsNumber||j&&+j;De(U.value)||(K=oe>U.value),De(ee.value)||(Z=oe<ee.value)}else{const oe=o.valueAsDate||new Date(j),ge=st=>new Date(new Date().toDateString()+" "+st),q=o.type=="time",ye=o.type=="week";ze(U.value)&&j&&(K=q?ge(j)>ge(U.value):ye?j>U.value:oe>new Date(U.value)),ze(ee.value)&&j&&(Z=q?ge(j)<ge(ee.value):ye?j<ee.value:oe<new Date(ee.value))}if((K||Z)&&(H(!!K,U.message,ee.message,it.max,it.min),!n))return k(P[x].message),P}if((u||d)&&!V&&(ze(j)||i&&Array.isArray(j))){const K=jr(u),Z=jr(d),U=!De(K.value)&&j.length>+K.value,ee=!De(Z.value)&&j.length<+Z.value;if((U||ee)&&(H(U,K.message,Z.message),!n))return k(P[x].message),P}if(f&&!V&&ze(j)){const{value:K,message:Z}=jr(f);if(rs(K)&&!j.match(K)&&(P[x]={type:it.pattern,message:Z,ref:o,...J(it.pattern,Z)},!n))return k(Z),P}if(y){if(Oe(y)){const K=await y(j,r),Z=to(K,b);if(Z&&(P[x]={...Z,...J(it.validate,Z.message)},!n))return k(Z.message),P}else if(fe(y)){let K={};for(const Z in y){if(!Fe(K)&&!n)break;const U=to(await y[Z](j,r),b,Z);U&&(K={...U,...J(Z,U.message)},k(U.message),n&&(P[x]=K))}if(!Fe(K)&&(P[x]={ref:b,...K},!n))return P}}return k(!0),P};const hm={mode:lt.onSubmit,reValidateMode:lt.onChange,shouldFocusError:!0},Os="form",Gl={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function mm(e={}){let t={...hm,...e},r={...ve(Gl),isLoading:Oe(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},n={},a=fe(t.defaultValues)||fe(t.values)?ve(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:ve(a),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set},c,u=0,d=0,h=Rn(t.mode),m=Rn(t.reValidateMode);const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},y={...f};let x={...y};const w={array:Hi(),state:Hi()},v=t.criteriaMode===lt.all,j=p=>N=>{clearTimeout(u),u=setTimeout(p,N)},b=async p=>{if(!o.keepIsValid&&!t.disabled&&(y.isValid||x.isValid||p)){let N;t.resolver?(N=Fe((await Z()).errors),k()):N=await oe({fields:n,onlyCheckValid:!0,eventType:Dt.VALID}),N!==r.isValid&&w.state.next({isValid:N})}},k=(p,N)=>{!t.disabled&&(y.isValidating||y.validatingFields||x.isValidating||x.validatingFields)&&((p||Array.from(l.mount)).forEach(S=>{S&&(N?ae(r.validatingFields,S,N):Ne(r.validatingFields,S))}),w.state.next({validatingFields:r.validatingFields,isValidating:!Fe(r.validatingFields)}))},P=()=>{r.dirtyFields=Kt(a,i)},A=(p,N=[],S,T,I=!0,z=!0)=>{if(T&&S&&!t.disabled){if(o.action=!0,z&&Array.isArray(D(n,p))){const R=S(D(n,p),T.argA,T.argB);I&&ae(n,p,R)}if(z&&Array.isArray(D(r.errors,p))){const R=S(D(r.errors,p),T.argA,T.argB);I&&ae(r.errors,p,R),dm(r.errors,p)}if((y.touchedFields||x.touchedFields)&&z&&Array.isArray(D(r.touchedFields,p))){const R=S(D(r.touchedFields,p),T.argA,T.argB);I&&ae(r.touchedFields,p,R)}(y.dirtyFields||x.dirtyFields)&&P(),w.state.next({name:p,isDirty:q(p,N),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else ae(i,p,N)},L=(p,N)=>{ae(r.errors,p,N),r.errors={...r.errors},w.state.next({errors:r.errors})},O=p=>{r.errors=p,w.state.next({errors:r.errors,isValid:!1})},V=p=>{const N=jn(p)?[p]:ps(p);let S=i,T=a;for(let I=0;I<N.length-1;I++){const z=N[I];if(S=De(S)?S:S[z],T=De(T)?T:T[z],S===null&&T!==null)return!0}return!1},J=(p,N,S,T)=>{const I=D(n,p);if(I){if(V(p))return;const z=ce(D(i,p)),R=D(i,p,ce(S)?D(a,p):S);ce(R)||T&&T.defaultChecked||N?ae(i,p,N?R:Ji(I._f)):Be(p,R),o.mount&&!o.action&&(b(),z&&r.isDirty&&(y.isDirty||x.isDirty)&&(q()||(r.isDirty=!1,w.state.next({...r}))),e.shouldUnregister&&z&&!ce(D(i,p))&&$s(p,l)&&(o.watch=!0))}},H=(p,N,S,T,I)=>{let z=!1,R=!1;const M={name:p};if(!t.disabled){if(!S||T){const X=Ye(D(a,p),N);(y.isDirty||x.isDirty)&&(R=r.isDirty,r.isDirty=M.isDirty=!X||q(),z=R!==M.isDirty),R=!!D(r.dirtyFields,p),X!==r.isDirty?r.dirtyFields=Kt(a,i):X?Ne(r.dirtyFields,p):ae(r.dirtyFields,p,!0),M.dirtyFields=r.dirtyFields,z=z||(y.dirtyFields||x.dirtyFields)&&R!==!X}if(S){const X=D(r.touchedFields,p);X||(ae(r.touchedFields,p,S),M.touchedFields=r.touchedFields,z=z||(y.touchedFields||x.touchedFields)&&X!==S)}z&&I&&w.state.next(M)}return z?M:{}},K=(p,N,S,T)=>{const I=D(r.errors,p),z=(y.isValid||x.isValid)&&Ke(N)&&r.isValid!==N;if(t.delayError&&S?(c=j(()=>L(p,S)),c(t.delayError)):(clearTimeout(u),c=null,S?ae(r.errors,p,S):Ne(r.errors,p),r.errors={...r.errors}),(S?!Ye(I,S):I)||!Fe(T)||z){const R={...T,...z&&Ke(N)?{isValid:N}:{},errors:r.errors,name:p};r={...r,...R},w.state.next(R)}},Z=async p=>(k(p,!0),await t.resolver(i,t.context,am(p||l.mount,n,t.criteriaMode,t.shouldUseNativeValidation))),U=async p=>{const{errors:N}=await Z(p);if(k(p),p){for(const S of p){const T=D(N,S);T?l.array.has(S)&&fe(T)&&!Object.keys(T).some(I=>!Number.isNaN(Number(I)))?eo(r.errors,{[S]:T},S):ae(r.errors,S,T):Ne(r.errors,S)}r.errors={...r.errors}}else r.errors=N;return N},ee=async({name:p,eventType:N})=>{if(e.validate){const S=await e.validate({formValues:i,formState:r,name:p,eventType:N});if(fe(S))for(const T in S){const I=S[T];I&&Ce(`${Os}.${T}`,{message:ze(I.message)?I.message:"",type:I.type||it.validate})}else ze(S)||!S?Ce(Os,{message:S||"",type:it.validate}):me(Os);return S}return!0},oe=async({fields:p,onlyCheckValid:N,name:S,eventType:T,context:I={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(I.runRootValidation=!0,!await ee({name:S,eventType:T})&&(I.valid=!1,N)))return I.valid;for(const z in p){const R=p[z];if(R){const{_f:M,...X}=R;if(M){const de=l.array.has(M.name),We=R._f&&im(R._f),vr=y.validatingFields||y.isValidating||x.validatingFields||x.isValidating;We&&vr&&k([M.name],!0);const Nt=await ro(R,l.disabled,i,v,t.shouldUseNativeValidation&&!N,de);if(We&&vr&&k([M.name]),Nt[M.name]&&(I.valid=!1,N)||(!N&&(D(Nt,M.name)?de?eo(r.errors,Nt,M.name):ae(r.errors,M.name,Nt[M.name]):Ne(r.errors,M.name)),e.shouldUseNativeValidation&&Nt[M.name]))break}!Fe(X)&&await oe({context:I,onlyCheckValid:N,fields:X,name:z,eventType:T})}}return I.valid},ge=()=>{for(const p of l.unMount){const N=D(n,p);N&&(N._f.refs?N._f.refs.every(S=>!Rs(S)):!Rs(N._f.ref))&&gr(p)}l.unMount=new Set},q=(p,N)=>!t.disabled&&(p&&N&&ae(i,p,N),!Ye(o.mount?i:a,a)),ye=(p,N,S)=>ma(p,l,{...o.mount?i:ce(N)?a:ze(p)?{[p]:N}:N},S,N),st=p=>Bl(D(o.mount?i:a,p,t.shouldUnregister?D(a,p,[]):[])),Be=(p,N,S={},T=!1,I=!1)=>{const z=D(n,p);let R=N;if(z){const M=z._f;M&&(!M.disabled&&ae(i,p,Yl(N,M)),R=ts(M.ref)&&De(N)?"":N,Hl(M.ref)?[...M.ref.options].forEach(X=>X.selected=R.includes(X.value)):M.refs?vn(M.ref)?M.refs.forEach(X=>{(!X.defaultChecked||!X.disabled)&&(Array.isArray(R)?X.checked=!!R.find(de=>de===X.value):X.checked=R===X.value||!!R)}):M.refs.forEach(X=>X.checked=X.value===R):Ja(M.ref)?M.ref.value="":(M.ref.value=R,!M.ref.type&&!I&&w.state.next({name:p,values:T?i:ve(i)})))}(S.shouldDirty||S.shouldTouch)&&H(p,R,S.shouldTouch,S.shouldDirty,!I),S.shouldValidate&&be(p)},Xe=(p,N,S,T=!1,I=!1)=>{for(const z in N){if(!N.hasOwnProperty(z))return;const R=N[z],M=p+"."+z,X=D(n,M);(l.array.has(p)||fe(R)||X&&!X._f)&&!Zt(R)?Xe(M,R,S,T,I):Be(M,R,S,T,I)}},qe=(p,N,S,T,I=!1)=>{const z=D(n,p),R=l.array.has(p),M=T?N:ve(N),X=D(i,p),de=Ye(X,M);if(de||ae(i,p,M),R)w.array.next({name:p,values:T?i:ve(i)}),(y.isDirty||y.dirtyFields||x.isDirty||x.dirtyFields)&&S.shouldDirty&&(P(),I||w.state.next({name:p,dirtyFields:r.dirtyFields,isDirty:q(p,M)}));else{const We=Array.isArray(M)&&!M.length||Fe(M);!z||z._f||De(M)||We?Be(p,M,S,T,I):Xe(p,M,S,T,I)}if(!de&&!I){const We=$s(p,l),vr=T?i:ve(i);w.state.next({...We&&r,name:o.mount||We?p:void 0,values:vr})}},Ie=(p,N,S={})=>qe(p,N,S,!1),wt=(p,N={})=>{const S=Oe(p)?p(i):p;if(!Ye(i,S)){i={...i,...S};const T=Zl(S);for(const I of l.mount)I in T&&qe(I,T[I],N,!0,!0);w.state.next({...r,name:void 0,type:void 0,...d?{values:i}:{}}),N.shouldValidate&&b()}},at=async p=>{o.mount=!0;const N=p.target;let S=N.name,T=!0;const I=D(n,S),z=R=>{T=Number.isNaN(R)||Zt(R)&&isNaN(R.getTime())||Ye(R,D(i,S,R))};if(I){let R,M;const X=N.type?Ji(I._f):ha(p),de=p.type===Dt.BLUR||p.type===Dt.FOCUS_OUT,We=!om(I._f)&&!e.validate&&!t.resolver&&!D(r.errors,S)&&!I._f.deps,vr=We||um(de,D(r.touchedFields,S),r.isSubmitted,m,h),Nt=$s(S,l,de);ae(i,S,X),de?(!N||!N.readOnly)&&(I._f.onBlur&&I._f.onBlur(p),c&&c(0)):I._f.onChange&&I._f.onChange(p);const Kr=H(S,X,de),eu=!Fe(Kr)||Nt;if(!de&&w.state.next({name:S,type:p.type,...d?{values:ve(i)}:{}}),vr)return(!We||!r.isValid)&&(y.isValid||x.isValid)&&(t.mode==="onBlur"?de&&b():de||b()),eu&&w.state.next({name:S,...Nt?{}:Kr});if(!t.resolver&&e.validate&&await ee({name:S,eventType:p.type}),!de&&Nt&&w.state.next({...r}),t.resolver){const{errors:ki}=await Z([S]);if(k([S]),z(X),!T){!Fe(Kr)&&w.state.next(Kr);return}const tu=Xi(r.errors,n,S),Ci=Xi(ki,n,tu.name||S);R=Ci.error,S=Ci.name,M=Fe(ki)}else k([S],!0),R=(await ro(I,l.disabled,i,v,t.shouldUseNativeValidation))[S],k([S]),z(X),T&&(R?M=!1:(y.isValid||x.isValid)&&(M=await oe({fields:n,onlyCheckValid:!0,name:S,eventType:p.type})));T&&(I._f.deps&&(!Array.isArray(I._f.deps)||I._f.deps.length>0)&&be(I._f.deps),K(S,M,R,Kr))}},se=(p,N)=>{if(D(r.errors,N)&&p.focus)return p.focus(),1},be=async(p,N={})=>{let S,T;const I=Hn(p);if(t.resolver){const z=await U(ce(p)?p:I);S=Fe(z),T=p?!I.some(R=>D(z,R)):S}else p?(T=(await Promise.all(I.map(async z=>{const R=D(n,z);return await oe({fields:R&&R._f?{[z]:R}:R,eventType:Dt.TRIGGER})}))).every(Boolean),!(!T&&!r.isValid)&&b()):T=S=await oe({fields:n,name:p,eventType:Dt.TRIGGER});return w.state.next({...!ze(p)||(y.isValid||x.isValid)&&S!==r.isValid?{}:{name:p},...t.resolver||!p?{isValid:S}:{},errors:r.errors}),N.shouldFocus&&!T&&nn(n,se,p?I:l.mount),T},dt=(p,N)=>{let S={...o.mount?i:a};return N&&(S=Wl(N.dirtyFields?r.dirtyFields:r.touchedFields,S)),ce(p)?S:ze(p)?D(S,p):p.map(T=>D(S,T))},ht=(p,N)=>({invalid:!!D((N||r).errors,p),isDirty:!!D((N||r).dirtyFields,p),error:D((N||r).errors,p),isValidating:!!D(r.validatingFields,p),isTouched:!!D((N||r).touchedFields,p)}),me=p=>{const N=p?Hn(p):void 0;N==null||N.forEach(S=>Ne(r.errors,S)),N?N.forEach(S=>{w.state.next({name:S,errors:r.errors})}):w.state.next({errors:{}})},Ce=(p,N,S)=>{const T=(D(n,p,{_f:{}})._f||{}).ref,I=D(r.errors,p)||{},{ref:z,message:R,type:M,...X}=I;ae(r.errors,p,{...X,...N,ref:T}),w.state.next({name:p,errors:r.errors,isValid:!1}),S&&S.shouldFocus&&T&&T.focus&&T.focus()},xr=(p,N)=>{if(Oe(p)){d++;const{unsubscribe:S}=w.state.subscribe({next:I=>"values"in I&&p(I.values||ye(void 0,N),I)});let T=!1;return{unsubscribe:()=>{T||(T=!0,d--,S())}}}return ye(p,N,!0)},It=p=>{var N;const S=!!(!((N=p.formState)===null||N===void 0)&&N.values);S&&d++;const{unsubscribe:T}=w.state.subscribe({next:z=>{if(cm(p.name,z.name,p.exact)&&lm(z,p.formState||y,En,p.reRenderRoot)){const R={...i};p.callback({values:R,...r,...z,defaultValues:a})}}});if(!S)return T;let I=!1;return()=>{I||(I=!0,d--,T())}},Cn=p=>(o.mount=!0,x={...x,...p.formState},It({...p,formState:{...f,...p.formState}})),gr=(p,N={})=>{for(const S of p?Hn(p):l.mount)l.mount.delete(S),l.array.delete(S),N.keepValue||(Ne(n,S),Ne(i,S)),!N.keepError&&Ne(r.errors,S),!N.keepDirty&&Ne(r.dirtyFields,S),!N.keepTouched&&Ne(r.touchedFields,S),!N.keepIsValidating&&Ne(r.validatingFields,S),!t.shouldUnregister&&!N.keepDefaultValue&&Ne(a,S);w.state.next({values:ve(i)}),w.state.next({...r,...N.keepDirty?{isDirty:q()}:{}}),!N.keepIsValid&&b()},Br=({disabled:p,name:N})=>{if(Ke(p)&&o.mount||p||l.disabled.has(N)){const I=l.disabled.has(N)!==!!p;p?l.disabled.add(N):l.disabled.delete(N),I&&o.mount&&!o.action&&b()}},yr=(p,N={})=>{let S=D(n,p);const T=Ke(N.disabled)||Ke(t.disabled),I=!l.registerName.has(p)&&S&&S._f&&!S._f.mount;return ae(n,p,{...S||{},_f:{...S&&S._f?S._f:{ref:{name:p}},name:p,mount:!0,...N}}),l.mount.add(p),S&&!I?Br({disabled:Ke(N.disabled)?N.disabled:t.disabled,name:p}):J(p,!0,N.value),{...T?{disabled:N.disabled||t.disabled}:{},...t.progressive?{required:!!N.required,min:Jr(N.min),max:Jr(N.max),minLength:Jr(N.minLength),maxLength:Jr(N.maxLength),pattern:Jr(N.pattern)}:{},name:p,onChange:at,onBlur:at,ref:z=>{if(z){l.registerName.add(p),yr(p,N),l.registerName.delete(p),S=D(n,p);const R=ce(z.value)&&z.querySelectorAll&&z.querySelectorAll("input,select,textarea")[0]||z,M=tm(R),X=S._f.refs||[];if(M?X.find(de=>de===R):R===S._f.ref)return;ae(n,p,{_f:{...S._f,...M?{refs:[...X.filter(Rs),R,...Array.isArray(D(a,p))?[{}]:[]],ref:{type:R.type,name:p}}:{ref:R}}}),J(p,!1,void 0,R)}else S=D(n,p,{}),S._f&&(S._f.mount=!1),(t.shouldUnregister||N.shouldUnregister)&&!(Ll(l.array,p)&&o.action)&&l.unMount.add(p)}}},br=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&nn(n,se,l.mount),_n=p=>{Ke(p)&&(w.state.next({disabled:p}),nn(n,(N,S)=>{const T=D(n,S);T&&(N.disabled=T._f.disabled||p,Array.isArray(T._f.refs)&&T._f.refs.forEach(I=>{I.disabled=T._f.disabled||p}))},0,!1))},Wr=(p,N)=>async S=>{let T;S&&(S.preventDefault&&S.preventDefault(),S.persist&&S.persist());let I=ve(i);if(w.state.next({isSubmitting:!0}),t.resolver){const{errors:z,values:R}=await Z();k(),r.errors=z,I=ve(R)}else await oe({fields:n,eventType:Dt.SUBMIT});if(l.disabled.size)for(const z of l.disabled)Ne(I,z);if(Ne(r.errors,Vl),Fe(r.errors)){w.state.next({errors:{}});try{await p(I,S)}catch(z){T=z}}else N&&await N({...r.errors},S),br(),setTimeout(br);if(w.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Fe(r.errors)&&!T,submitCount:r.submitCount+1,errors:r.errors}),T)throw T},An=(p,N={})=>{D(n,p)&&(ce(N.defaultValue)?Ie(p,ve(D(a,p))):(Ie(p,N.defaultValue),ae(a,p,ve(N.defaultValue))),N.keepTouched||Ne(r.touchedFields,p),N.keepDirty||(Ne(r.dirtyFields,p),r.isDirty=N.defaultValue?q(p,ve(D(a,p))):q()),N.keepError||(Ne(r.errors,p),y.isValid&&b()),w.state.next({...r}))},Hr=(p,N={})=>{const S=p?ve(p):a,T=ve(S),I=Fe(p),z=T;if(N.keepDefaultValues||(a=S),!N.keepValues){if(N.keepDirtyValues){const R=new Set([...l.mount,...Object.keys(Kt(a,i))]);for(const M of Array.from(R)){const X=D(r.dirtyFields,M),de=D(i,M),We=D(z,M);X&&!ce(de)?ae(z,M,de):!X&&!ce(We)&&Ie(M,We)}}else{if(fs&&ce(p))for(const R of l.mount){const M=D(n,R);if(M&&M._f){const X=Array.isArray(M._f.refs)?M._f.refs[0]:M._f.ref;if(ts(X)){const de=X.closest("form");if(de){de.reset();break}}}}if(N.keepFieldsRef)for(const R of l.mount)Ie(R,D(z,R));else n={}}if(t.shouldUnregister){if(i=N.keepDefaultValues?ve(a):{},N.keepFieldsRef)for(const R of l.mount)ae(i,R,D(z,R))}else i=ve(z);w.array.next({values:{...z}}),w.state.next({name:void 0,type:void 0,values:{...z}})}l={mount:N.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!y.isValid||!!N.keepIsValid||!!N.keepDirtyValues||!t.shouldUnregister&&!Fe(z),o.watch=!!t.shouldUnregister,o.keepIsValid=!!N.keepIsValid,o.action=!1,N.keepErrors||(r.errors={}),w.state.next({submitCount:N.keepSubmitCount?r.submitCount:0,isDirty:I?!1:N.keepDirty?r.isDirty:N.keepValues?q():!!(N.keepDefaultValues&&!Ye(p,a)),isSubmitted:N.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:I?{}:N.keepDirtyValues?N.keepDefaultValues&&i?Kt(a,i):r.dirtyFields:N.keepDefaultValues&&p?Kt(a,p):N.keepDirty?r.dirtyFields:{},touchedFields:N.keepTouched?r.touchedFields:{},errors:N.keepErrors?r.errors:{},isSubmitSuccessful:N.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},Qr=(p,N)=>Hr(Oe(p)?p(i):p,{...t.resetOptions,...N}),Pn=(p,N={})=>{const S=D(n,p),T=S&&S._f;if(T){const I=T.refs?T.refs[0]:T.ref;I.focus&&setTimeout(()=>{I.focus(),N.shouldSelect&&Oe(I.select)&&I.select()})}},En=p=>{const{name:N,type:S,values:T,...I}=p;r={...r,...I}},mt={control:{register:yr,unregister:gr,getFieldState:ht,handleSubmit:Wr,setError:Ce,_subscribe:It,_runSchema:Z,_updateIsValidating:k,_focusError:br,_getWatch:ye,_getDirty:q,_setValid:b,_setFieldArray:A,_setDisabledField:Br,_setErrors:O,_getFieldArray:st,_reset:Hr,_resetDefaultValues:()=>Oe(t.defaultValues)&&t.defaultValues().then(p=>{Qr(p,t.resetOptions),w.state.next({isLoading:!1})}),_removeUnmounted:ge,_disableForm:_n,_subjects:w,_proxyFormState:y,get _fields(){return n},get _formValues(){return i},get _state(){return o},set _state(p){o=p},get _defaultValues(){return a},get _names(){return l},set _names(p){l=p},get _formState(){return r},get _options(){return t},set _options(p){t={...t,...p},h=Rn(t.mode),m=Rn(t.reValidateMode)}},subscribe:Cn,trigger:be,register:yr,handleSubmit:Wr,watch:xr,setValue:Ie,setValues:wt,getValues:dt,reset:Qr,resetField:An,resetDefaultValues:(p,N={})=>{if(a=ve(p),!N.keepDirty){const S=Kt(a,i);r.dirtyFields=S,r.isDirty=!Fe(S)}N.keepIsValid||b(),w.state.next({...r,defaultValues:a})},clearErrors:me,unregister:gr,setError:Ce,setFocus:Pn,getFieldState:ht};return{...mt,formControl:mt}}function hr(e={}){const t=_.useRef(void 0),r=_.useRef(void 0),n=_.useRef(e.formControl),[a,i]=_.useState(()=>({...ve(Gl),isLoading:Oe(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Oe(e.defaultValues)?void 0:e.defaultValues}));if(!t.current||e.formControl&&n.current!==e.formControl)if(n.current=e.formControl,e.formControl)t.current={...e.formControl,formState:a},e.defaultValues&&!Oe(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...c}=mm(e);t.current={...c,formState:a}}const o=t.current.control;return o._options=e,Ka(()=>{const l=o._subscribe({formState:o._proxyFormState,callback:()=>i({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return i(c=>({...c,isReady:!0})),o._formState.isReady=!0,l},[o]),_.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),_.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),_.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),_.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),_.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==a.isDirty&&o._subjects.state.next({isDirty:l})}},[o,a.isDirty]),_.useEffect(()=>{var l;e.values&&!Ye(e.values,r.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((l=o._options.resetOptions)===null||l===void 0)&&l.keepIsValid||o._setValid(),r.current=e.values,i(c=>({...c}))):o._resetDefaultValues()},[o,e.values]),_.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=_.useMemo(()=>Ul(a,o),[o,a]),t.current}const no=(e,t,r)=>{if(e&&"reportValidity"in e){const n=D(r,t);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},ga=(e,t)=>{for(const r in t.fields){const n=t.fields[r];n&&n.ref&&"reportValidity"in n.ref?no(n.ref,r,e):n&&n.refs&&n.refs.forEach(a=>no(a,r,e))}},so=(e,t)=>{t.shouldUseNativeValidation&&ga(e,t);const r={};for(const n in e){const a=D(t.fields,n),i=Object.assign(e[n]||{},{ref:a&&a.ref});if(fm(t.names||Object.keys(e),n)){const o=Object.assign({},D(r,n));ae(o,"root",i),ae(r,n,o)}else ae(r,n,i)}return r},fm=(e,t)=>{const r=ao(t).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(n=>ao(n).match(`^${r}\\.\\d+`))};function ao(e){return e.replace(/[\[\]]/g,"")}var io;function E(e,t,r){function n(l,c){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,c);const u=o.prototype,d=Object.keys(u);for(let h=0;h<d.length;h++){const m=d[h];m in l||(l[m]=u[m].bind(l))}}const a=(r==null?void 0:r.Parent)??Object;class i extends a{}Object.defineProperty(i,"name",{value:e});function o(l){var c;const u=r!=null&&r.Parent?new i:this;n(u,l),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:l=>{var c,u;return r!=null&&r.Parent&&l instanceof r.Parent?!0:(u=(c=l==null?void 0:l._zod)==null?void 0:c.traits)==null?void 0:u.has(e)}}),Object.defineProperty(o,"name",{value:e}),o}class Sr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Xl extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(io=globalThis).__zod_globalConfig??(io.__zod_globalConfig={});const Xa=globalThis.__zod_globalConfig;function cr(e){return Xa}function ec(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,a])=>t.indexOf(+n)===-1).map(([n,a])=>a)}function ya(e,t){return typeof t=="bigint"?t.toString():t}function ei(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ti(e){return e==null}function ri(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}const oo=Symbol("evaluating");function le(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==oo)return n===void 0&&(n=oo,n=r()),n},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function mr(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Wt(...e){const t={};for(const r of e){const n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function lo(e){return JSON.stringify(e)}function pm(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const tc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ns(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const xm=ei(()=>{var e;if(Xa.jitless||typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function cn(e){if(ns(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(ns(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function rc(e){return cn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const gm=new Set(["string","number","symbol"]);function xs(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ht(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r!=null&&r.parent)&&(n._zod.parent=e),n}function G(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function ym(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function bm(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=Wt(e._zod.def,{get shape(){const o={};for(const l in t){if(!(l in r.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(o[l]=r.shape[l])}return mr(this,"shape",o),o},checks:[]});return Ht(e,i)}function vm(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=Wt(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const l in t){if(!(l in r.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete o[l]}return mr(this,"shape",o),o},checks:[]});return Ht(e,i)}function jm(e,t){if(!cn(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const i=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const a=Wt(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return mr(this,"shape",i),i}});return Ht(e,a)}function wm(e,t){if(!cn(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=Wt(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return mr(this,"shape",n),n}});return Ht(e,r)}function Nm(e,t){var n;if((n=e._zod.def.checks)!=null&&n.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const r=Wt(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return mr(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Ht(e,r)}function Sm(e,t,r){const a=t._zod.def.checks;if(a&&a.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=Wt(t._zod.def,{get shape(){const l=t._zod.def.shape,c={...l};if(r)for(const u in r){if(!(u in l))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=e?new e({type:"optional",innerType:l[u]}):l[u])}else for(const u in l)c[u]=e?new e({type:"optional",innerType:l[u]}):l[u];return mr(this,"shape",c),c},checks:[]});return Ht(t,o)}function km(e,t,r){const n=Wt(t._zod.def,{get shape(){const a=t._zod.def.shape,i={...a};if(r)for(const o in r){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=new e({type:"nonoptional",innerType:a[o]}))}else for(const o in a)i[o]=new e({type:"nonoptional",innerType:a[o]});return mr(this,"shape",i),i}});return Ht(t,n)}function wr(e,t=0){var r;if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(((r=e.issues[n])==null?void 0:r.continue)!==!0)return!0;return!1}function Cm(e,t=0){var r;if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(((r=e.issues[n])==null?void 0:r.continue)===!1)return!0;return!1}function nc(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function $n(e){return typeof e=="string"?e:e==null?void 0:e.message}function ur(e,t,r){var c,u,d,h,m,f;const n=e.message?e.message:$n((d=(u=(c=e.inst)==null?void 0:c._zod.def)==null?void 0:u.error)==null?void 0:d.call(u,e))??$n((h=t==null?void 0:t.error)==null?void 0:h.call(t,e))??$n((m=r.customError)==null?void 0:m.call(r,e))??$n((f=r.localeError)==null?void 0:f.call(r,e))??"Invalid input",{inst:a,continue:i,input:o,...l}=e;return l.path??(l.path=[]),l.message=n,t!=null&&t.reportInput&&(l.input=o),l}function ni(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function un(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const sc=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ya,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},si=E("$ZodError",sc),gs=E("$ZodError",sc,{Parent:Error});function _m(e,t=r=>r.message){const r={},n=[];for(const a of e.issues)a.path.length>0?(r[a.path[0]]=r[a.path[0]]||[],r[a.path[0]].push(t(a))):n.push(t(a));return{formErrors:n,fieldErrors:r}}function Am(e,t=r=>r.message){const r={_errors:[]},n=(a,i=[])=>{for(const o of a.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(l=>n({issues:l},[...i,...o.path]));else if(o.code==="invalid_key")n({issues:o.issues},[...i,...o.path]);else if(o.code==="invalid_element")n({issues:o.issues},[...i,...o.path]);else{const l=[...i,...o.path];if(l.length===0)r._errors.push(t(o));else{let c=r,u=0;for(;u<l.length;){const d=l[u];u===l.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(t(o))):c[d]=c[d]||{_errors:[]},c=c[d],u++}}}};return n(e),r}const ys=e=>(t,r,n,a)=>{const i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Sr;if(o.issues.length){const l=new((a==null?void 0:a.Err)??e)(o.issues.map(c=>ur(c,i,cr())));throw tc(l,a==null?void 0:a.callee),l}return o.value},Pm=ys(gs),bs=e=>async(t,r,n,a)=>{const i=n?{...n,async:!0}:{async:!0};let o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const l=new((a==null?void 0:a.Err)??e)(o.issues.map(c=>ur(c,i,cr())));throw tc(l,a==null?void 0:a.callee),l}return o.value},Em=bs(gs),vs=e=>(t,r,n)=>{const a=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},a);if(i instanceof Promise)throw new Sr;return i.issues.length?{success:!1,error:new(e??si)(i.issues.map(o=>ur(o,a,cr())))}:{success:!0,data:i.value}},Tm=vs(gs),js=e=>async(t,r,n)=>{const a=n?{...n,async:!0}:{async:!0};let i=t._zod.run({value:r,issues:[]},a);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(o=>ur(o,a,cr())))}:{success:!0,data:i.value}},Im=js(gs),Fm=e=>(t,r,n)=>{const a=n?{...n,direction:"backward"}:{direction:"backward"};return ys(e)(t,r,a)},Dm=e=>(t,r,n)=>ys(e)(t,r,n),Rm=e=>async(t,r,n)=>{const a=n?{...n,direction:"backward"}:{direction:"backward"};return bs(e)(t,r,a)},$m=e=>async(t,r,n)=>bs(e)(t,r,n),Om=e=>(t,r,n)=>{const a=n?{...n,direction:"backward"}:{direction:"backward"};return vs(e)(t,r,a)},zm=e=>(t,r,n)=>vs(e)(t,r,n),Lm=e=>async(t,r,n)=>{const a=n?{...n,direction:"backward"}:{direction:"backward"};return js(e)(t,r,a)},Mm=e=>async(t,r,n)=>js(e)(t,r,n),Vm=/^[cC][0-9a-z]{6,}$/,qm=/^[0-9a-z]+$/,Um=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Zm=/^[0-9a-vA-V]{20}$/,Bm=/^[A-Za-z0-9]{27}$/,Wm=/^[a-zA-Z0-9_-]{21}$/,Hm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Qm=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,co=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Km=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ym="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Jm(){return new RegExp(Ym,"u")}const Gm=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Xm=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ef=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,tf=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,rf=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ac=/^[A-Za-z0-9_-]*$/,nf=/^https?$/,sf=/^\+[1-9]\d{6,14}$/,ic="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",af=new RegExp(`^${ic}$`);function oc(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function of(e){return new RegExp(`^${oc(e)}$`)}function lf(e){const t=oc({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${ic}T(?:${n})$`)}const cf=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},uf=/^(?:true|false)$/i,df=/^[^A-Z]*$/,hf=/^[^a-z]*$/,jt=E("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),mf=E("$ZodCheckMaxLength",(e,t)=>{var r;jt.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!ti(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const a=n.value;if(a.length<=t.maximum)return;const o=ni(a);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),ff=E("$ZodCheckMinLength",(e,t)=>{var r;jt.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!ti(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const a=n.value;if(a.length>=t.minimum)return;const o=ni(a);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),pf=E("$ZodCheckLengthEquals",(e,t)=>{var r;jt.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!ti(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=n=>{const a=n.value,i=a.length;if(i===t.length)return;const o=ni(a),l=i>t.length;n.issues.push({origin:o,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ws=E("$ZodCheckStringFormat",(e,t)=>{var r,n;jt.init(e,t),e._zod.onattach.push(a=>{const i=a._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),xf=E("$ZodCheckRegex",(e,t)=>{ws.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),gf=E("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=df),ws.init(e,t)}),yf=E("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=hf),ws.init(e,t)}),bf=E("$ZodCheckIncludes",(e,t)=>{jt.init(e,t);const r=xs(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=a=>{a.value.includes(t.includes,t.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:a.value,inst:e,continue:!t.abort})}}),vf=E("$ZodCheckStartsWith",(e,t)=>{jt.init(e,t);const r=new RegExp(`^${xs(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),jf=E("$ZodCheckEndsWith",(e,t)=>{jt.init(e,t);const r=new RegExp(`.*${xs(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),wf=E("$ZodCheckOverwrite",(e,t)=>{jt.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class Nf{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(`
13
+ `).filter(o=>o),a=Math.min(...n.map(o=>o.length-o.trimStart().length)),i=n.map(o=>o.slice(a)).map(o=>" ".repeat(this.indent*2)+o);for(const o of i)this.content.push(o)}compile(){const t=Function,r=this==null?void 0:this.args,a=[...((this==null?void 0:this.content)??[""]).map(i=>` ${i}`)];return new t(...r,a.join(`
14
+ `))}}const Sf={major:4,minor:4,patch:3},Se=E("$ZodType",(e,t)=>{var a;var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Sf;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const i of n)for(const o of i._zod.onattach)o(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),(a=e._zod.deferred)==null||a.push(()=>{e._zod.run=e._zod.parse});else{const i=(l,c,u)=>{let d=wr(l),h;for(const m of c){if(m._zod.def.when){if(Cm(l)||!m._zod.def.when(l))continue}else if(d)continue;const f=l.issues.length,y=m._zod.check(l);if(y instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Sr;if(h||y instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await y,l.issues.length!==f&&(d||(d=wr(l,f)))});else{if(l.issues.length===f)continue;d||(d=wr(l,f))}}return h?h.then(()=>l):l},o=(l,c,u)=>{if(wr(l))return l.aborted=!0,l;const d=i(c,n,u);if(d instanceof Promise){if(u.async===!1)throw new Sr;return d.then(h=>e._zod.parse(h,u))}return e._zod.parse(d,u)};e._zod.run=(l,c)=>{if(c.skipChecks)return e._zod.parse(l,c);if(c.direction==="backward"){const d=e._zod.parse({value:l.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(h=>o(h,l,c)):o(d,l,c)}const u=e._zod.parse(l,c);if(u instanceof Promise){if(c.async===!1)throw new Sr;return u.then(d=>i(d,n,c))}return i(u,n,c)}}le(e,"~standard",()=>({validate:i=>{var o;try{const l=Tm(e,i);return l.success?{value:l.data}:{issues:(o=l.error)==null?void 0:o.issues}}catch{return Im(e,i).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),ai=E("$ZodString",(e,t)=>{var r;Se.init(e,t),e._zod.pattern=[...((r=e==null?void 0:e._zod.bag)==null?void 0:r.patterns)??[]].pop()??cf(e._zod.bag),e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),he=E("$ZodStringFormat",(e,t)=>{ws.init(e,t),ai.init(e,t)}),kf=E("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Qm),he.init(e,t)}),Cf=E("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=co(n))}else t.pattern??(t.pattern=co());he.init(e,t)}),_f=E("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Km),he.init(e,t)}),Af=E("$ZodURL",(e,t)=>{he.init(e,t),e._zod.check=r=>{var n;try{const a=r.value.trim();if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===nf.source&&!/^https?:\/\//i.test(a)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}const i=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=i.href:r.value=a;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Pf=E("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Jm()),he.init(e,t)}),Ef=E("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Wm),he.init(e,t)}),Tf=E("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Vm),he.init(e,t)}),If=E("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=qm),he.init(e,t)}),Ff=E("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Um),he.init(e,t)}),Df=E("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Zm),he.init(e,t)}),Rf=E("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Bm),he.init(e,t)}),$f=E("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=lf(t)),he.init(e,t)}),Of=E("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=af),he.init(e,t)}),zf=E("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=of(t)),he.init(e,t)}),Lf=E("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Hm),he.init(e,t)}),Mf=E("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Gm),he.init(e,t),e._zod.bag.format="ipv4"}),Vf=E("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Xm),he.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),qf=E("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ef),he.init(e,t)}),Uf=E("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=tf),he.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[a,i]=n;if(!i)throw new Error;const o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${a}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function lc(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Zf=E("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=rf),he.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{lc(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Bf(e){if(!ac.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return lc(r)}const Wf=E("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ac),he.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{Bf(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Hf=E("$ZodE164",(e,t)=>{t.pattern??(t.pattern=sf),he.init(e,t)});function Qf(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const a=JSON.parse(atob(n));return!("typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||t&&(!("alg"in a)||a.alg!==t))}catch{return!1}}const Kf=E("$ZodJWT",(e,t)=>{he.init(e,t),e._zod.check=r=>{Qf(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Yf=E("$ZodBoolean",(e,t)=>{Se.init(e,t),e._zod.pattern=uf,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}const a=r.value;return typeof a=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:a,inst:e}),r}}),Jf=E("$ZodUnknown",(e,t)=>{Se.init(e,t),e._zod.parse=r=>r}),Gf=E("$ZodNever",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function uo(e,t,r){e.issues.length&&t.issues.push(...nc(r,e.issues)),t.value[r]=e.value}const Xf=E("$ZodArray",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{const a=r.value;if(!Array.isArray(a))return r.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),r;r.value=Array(a.length);const i=[];for(let o=0;o<a.length;o++){const l=a[o],c=t.element._zod.run({value:l,issues:[]},n);c instanceof Promise?i.push(c.then(u=>uo(u,r,o))):uo(c,r,o)}return i.length?Promise.all(i).then(()=>r):r}});function ss(e,t,r,n,a,i){const o=r in n;if(e.issues.length){if(a&&i&&!o)return;t.issues.push(...nc(r,e.issues))}if(!o&&!a){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?o&&(t.value[r]=void 0):t.value[r]=e.value}function cc(e){var n,a,i,o;const t=Object.keys(e.shape);for(const l of t)if(!((o=(i=(a=(n=e.shape)==null?void 0:n[l])==null?void 0:a._zod)==null?void 0:i.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${l}": expected a Zod schema`);const r=ym(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function uc(e,t,r,n,a,i){const o=[],l=a.keySet,c=a.catchall._zod,u=c.def.type,d=c.optin==="optional",h=c.optout==="optional";for(const m in t){if(m==="__proto__"||l.has(m))continue;if(u==="never"){o.push(m);continue}const f=c.run({value:t[m],issues:[]},n);f instanceof Promise?e.push(f.then(y=>ss(y,r,m,t,d,h))):ss(f,r,m,t,d,h)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}const ep=E("$ZodObject",(e,t)=>{Se.init(e,t);const r=Object.getOwnPropertyDescriptor(t,"shape");if(!(r!=null&&r.get)){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...l};return Object.defineProperty(t,"shape",{value:c}),c}})}const n=ei(()=>cc(t));le(e._zod,"propValues",()=>{const l=t.shape,c={};for(const u in l){const d=l[u]._zod;if(d.values){c[u]??(c[u]=new Set);for(const h of d.values)c[u].add(h)}}return c});const a=ns,i=t.catchall;let o;e._zod.parse=(l,c)=>{o??(o=n.value);const u=l.value;if(!a(u))return l.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),l;l.value={};const d=[],h=o.shape;for(const m of o.keys){const f=h[m],y=f._zod.optin==="optional",x=f._zod.optout==="optional",w=f._zod.run({value:u[m],issues:[]},c);w instanceof Promise?d.push(w.then(v=>ss(v,l,m,u,y,x))):ss(w,l,m,u,y,x)}return i?uc(d,u,l,c,n.value,e):d.length?Promise.all(d).then(()=>l):l}}),tp=E("$ZodObjectJIT",(e,t)=>{ep.init(e,t);const r=e._zod.parse,n=ei(()=>cc(t)),a=m=>{var b,k;const f=new Nf(["shape","payload","ctx"]),y=n.value,x=P=>{const A=lo(P);return`shape[${A}]._zod.run({ value: input[${A}], issues: [] }, ctx)`};f.write("const input = payload.value;");const w=Object.create(null);let v=0;for(const P of y.keys)w[P]=`key_${v++}`;f.write("const newResult = {};");for(const P of y.keys){const A=w[P],L=lo(P),O=m[P],V=((b=O==null?void 0:O._zod)==null?void 0:b.optin)==="optional",J=((k=O==null?void 0:O._zod)==null?void 0:k.optout)==="optional";f.write(`const ${A} = ${x(P)};`),V&&J?f.write(`
15
+ if (${A}.issues.length) {
16
+ if (${L} in input) {
17
+ payload.issues = payload.issues.concat(${A}.issues.map(iss => ({
18
+ ...iss,
19
+ path: iss.path ? [${L}, ...iss.path] : [${L}]
20
+ })));
21
+ }
22
+ }
23
+
24
+ if (${A}.value === undefined) {
25
+ if (${L} in input) {
26
+ newResult[${L}] = undefined;
27
+ }
28
+ } else {
29
+ newResult[${L}] = ${A}.value;
30
+ }
31
+
32
+ `):V?f.write(`
33
+ if (${A}.issues.length) {
34
+ payload.issues = payload.issues.concat(${A}.issues.map(iss => ({
35
+ ...iss,
36
+ path: iss.path ? [${L}, ...iss.path] : [${L}]
37
+ })));
38
+ }
39
+
40
+ if (${A}.value === undefined) {
41
+ if (${L} in input) {
42
+ newResult[${L}] = undefined;
43
+ }
44
+ } else {
45
+ newResult[${L}] = ${A}.value;
46
+ }
47
+
48
+ `):f.write(`
49
+ const ${A}_present = ${L} in input;
50
+ if (${A}.issues.length) {
51
+ payload.issues = payload.issues.concat(${A}.issues.map(iss => ({
52
+ ...iss,
53
+ path: iss.path ? [${L}, ...iss.path] : [${L}]
54
+ })));
55
+ }
56
+ if (!${A}_present && !${A}.issues.length) {
57
+ payload.issues.push({
58
+ code: "invalid_type",
59
+ expected: "nonoptional",
60
+ input: undefined,
61
+ path: [${L}]
62
+ });
63
+ }
64
+
65
+ if (${A}_present) {
66
+ if (${A}.value === undefined) {
67
+ newResult[${L}] = undefined;
68
+ } else {
69
+ newResult[${L}] = ${A}.value;
70
+ }
71
+ }
72
+
73
+ `)}f.write("payload.value = newResult;"),f.write("return payload;");const j=f.compile();return(P,A)=>j(m,P,A)};let i;const o=ns,l=!Xa.jitless,u=l&&xm.value,d=t.catchall;let h;e._zod.parse=(m,f)=>{h??(h=n.value);const y=m.value;return o(y)?l&&u&&(f==null?void 0:f.async)===!1&&f.jitless!==!0?(i||(i=a(t.shape)),m=i(m,f),d?uc([],y,m,f,h,e):m):r(m,f):(m.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),m)}});function ho(e,t,r,n){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const a=e.filter(i=>!wr(i));return a.length===1?(t.value=a[0].value,a[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(o=>ur(o,n,cr())))}),t)}const rp=E("$ZodUnion",(e,t)=>{Se.init(e,t),le(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),le(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),le(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),le(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){const n=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${n.map(a=>ri(a.source)).join("|")})$`)}});const r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,a)=>{if(r)return r(n,a);let i=!1;const o=[];for(const l of t.options){const c=l._zod.run({value:n.value,issues:[]},a);if(c instanceof Promise)o.push(c),i=!0;else{if(c.issues.length===0)return c;o.push(c)}}return i?Promise.all(o).then(l=>ho(l,n,e,a)):ho(o,n,e,a)}}),np=E("$ZodIntersection",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{const a=r.value,i=t.left._zod.run({value:a,issues:[]},n),o=t.right._zod.run({value:a,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,u])=>mo(r,c,u)):mo(r,i,o)}});function ba(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(cn(e)&&cn(t)){const r=Object.keys(t),n=Object.keys(e).filter(i=>r.indexOf(i)!==-1),a={...e,...t};for(const i of n){const o=ba(e[i],t[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};a[i]=o.data}return{valid:!0,data:a}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const a=e[n],i=t[n],o=ba(a,i);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function mo(e,t,r){const n=new Map;let a;for(const l of t.issues)if(l.code==="unrecognized_keys"){a??(a=l);for(const c of l.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(l);for(const l of r.issues)if(l.code==="unrecognized_keys")for(const c of l.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(l);const i=[...n].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(i.length&&a&&e.issues.push({...a,keys:i}),wr(e))return e;const o=ba(t.value,r.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const sp=E("$ZodEnum",(e,t)=>{Se.init(e,t);const r=ec(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(a=>gm.has(typeof a)).map(a=>typeof a=="string"?xs(a):a.toString()).join("|")})$`),e._zod.parse=(a,i)=>{const o=a.value;return n.has(o)||a.issues.push({code:"invalid_value",values:r,input:o,inst:e}),a}}),ap=E("$ZodTransform",(e,t)=>{Se.init(e,t),e._zod.optin="optional",e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Xl(e.constructor.name);const a=t.transform(r.value,r);if(n.async)return(a instanceof Promise?a:Promise.resolve(a)).then(o=>(r.value=o,r.fallback=!0,r));if(a instanceof Promise)throw new Sr;return r.value=a,r.fallback=!0,r}});function fo(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const dc=E("$ZodOptional",(e,t)=>{Se.init(e,t),e._zod.optin="optional",e._zod.optout="optional",le(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),le(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${ri(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const a=r.value,i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>fo(o,a)):fo(i,a)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),ip=E("$ZodExactOptional",(e,t)=>{dc.init(e,t),le(e._zod,"values",()=>t.innerType._zod.values),le(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),op=E("$ZodNullable",(e,t)=>{Se.init(e,t),le(e._zod,"optin",()=>t.innerType._zod.optin),le(e._zod,"optout",()=>t.innerType._zod.optout),le(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${ri(r.source)}|null)$`):void 0}),le(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),lp=E("$ZodDefault",(e,t)=>{Se.init(e,t),e._zod.optin="optional",le(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(i=>po(i,t)):po(a,t)}});function po(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const cp=E("$ZodPrefault",(e,t)=>{Se.init(e,t),e._zod.optin="optional",le(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),up=E("$ZodNonOptional",(e,t)=>{Se.init(e,t),le(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(i=>xo(i,e)):xo(a,e)}});function xo(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const dp=E("$ZodCatch",(e,t)=>{Se.init(e,t),e._zod.optin="optional",le(e._zod,"optout",()=>t.innerType._zod.optout),le(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(o=>ur(o,n,cr()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=a.value,a.issues.length&&(r.value=t.catchValue({...r,error:{issues:a.issues.map(i=>ur(i,n,cr()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),hp=E("$ZodPipe",(e,t)=>{Se.init(e,t),le(e._zod,"values",()=>t.in._zod.values),le(e._zod,"optin",()=>t.in._zod.optin),le(e._zod,"optout",()=>t.out._zod.optout),le(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const i=t.out._zod.run(r,n);return i instanceof Promise?i.then(o=>On(o,t.in,n)):On(i,t.in,n)}const a=t.in._zod.run(r,n);return a instanceof Promise?a.then(i=>On(i,t.out,n)):On(a,t.out,n)}});function On(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}const mp=E("$ZodReadonly",(e,t)=>{Se.init(e,t),le(e._zod,"propValues",()=>t.innerType._zod.propValues),le(e._zod,"values",()=>t.innerType._zod.values),le(e._zod,"optin",()=>{var r,n;return(n=(r=t.innerType)==null?void 0:r._zod)==null?void 0:n.optin}),le(e._zod,"optout",()=>{var r,n;return(n=(r=t.innerType)==null?void 0:r._zod)==null?void 0:n.optout}),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(go):go(a)}});function go(e){return e.value=Object.freeze(e.value),e}const fp=E("$ZodCustom",(e,t)=>{jt.init(e,t),Se.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,a=t.fn(n);if(a instanceof Promise)return a.then(i=>yo(i,r,n,e));yo(a,r,n,e)}});function yo(e,t,r,n){if(!e){const a={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(a.params=n._zod.def.params),t.issues.push(un(a))}}var bo;class pp{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){const n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const n={...this.get(r)??{}};delete n.id;const a={...n,...this._map.get(t)};return Object.keys(a).length?a:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function xp(){return new pp}(bo=globalThis).__zod_globalRegistry??(bo.__zod_globalRegistry=xp());const rn=globalThis.__zod_globalRegistry;function gp(e,t){return new e({type:"string",...G(t)})}function hc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...G(t)})}function vo(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...G(t)})}function yp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...G(t)})}function bp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...G(t)})}function vp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...G(t)})}function jp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...G(t)})}function wp(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...G(t)})}function Np(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...G(t)})}function Sp(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...G(t)})}function kp(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...G(t)})}function Cp(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...G(t)})}function _p(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...G(t)})}function Ap(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...G(t)})}function Pp(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...G(t)})}function Ep(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...G(t)})}function Tp(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...G(t)})}function Ip(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...G(t)})}function Fp(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...G(t)})}function Dp(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...G(t)})}function Rp(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...G(t)})}function $p(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...G(t)})}function Op(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...G(t)})}function zp(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...G(t)})}function Lp(e,t){return new e({type:"string",format:"date",check:"string_format",...G(t)})}function Mp(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...G(t)})}function Vp(e,t){return new e({type:"string",format:"duration",check:"string_format",...G(t)})}function qp(e,t){return new e({type:"boolean",...G(t)})}function Up(e){return new e({type:"unknown"})}function Zp(e,t){return new e({type:"never",...G(t)})}function mc(e,t){return new mf({check:"max_length",...G(t),maximum:e})}function as(e,t){return new ff({check:"min_length",...G(t),minimum:e})}function fc(e,t){return new pf({check:"length_equals",...G(t),length:e})}function Bp(e,t){return new xf({check:"string_format",format:"regex",...G(t),pattern:e})}function Wp(e){return new gf({check:"string_format",format:"lowercase",...G(e)})}function Hp(e){return new yf({check:"string_format",format:"uppercase",...G(e)})}function Qp(e,t){return new bf({check:"string_format",format:"includes",...G(t),includes:e})}function Kp(e,t){return new vf({check:"string_format",format:"starts_with",...G(t),prefix:e})}function Yp(e,t){return new jf({check:"string_format",format:"ends_with",...G(t),suffix:e})}function qr(e){return new wf({check:"overwrite",tx:e})}function Jp(e){return qr(t=>t.normalize(e))}function Gp(){return qr(e=>e.trim())}function Xp(){return qr(e=>e.toLowerCase())}function ex(){return qr(e=>e.toUpperCase())}function tx(){return qr(e=>pm(e))}function rx(e,t,r){return new e({type:"array",element:t,...G(r)})}function nx(e,t,r){return new e({type:"custom",check:"custom",fn:t,...G(r)})}function sx(e,t){const r=ax(n=>(n.addIssue=a=>{if(typeof a=="string")n.issues.push(un(a,n.value,r._zod.def));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),n.issues.push(un(i))}},e(n.value,n)),t);return r}function ax(e,t){const r=new jt({check:"custom",...G(t)});return r._zod.check=e,r}function pc(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??rn,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function Re(e,t,r={path:[],schemaPath:[]}){var d,h;var n;const a=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o);const l=(h=(d=e._zod).toJSONSchema)==null?void 0:h.call(d);if(l)o.schema=l;else{const m={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,m);else{const y=o.schema,x=t.processors[a.type];if(!x)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);x(e,t,y,m)}const f=e._zod.parent;f&&(o.ref||(o.ref=f),Re(f,t,m),t.seen.get(f).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io==="input"&&Le(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function xc(e,t){var o,l,c,u;const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const d of e.seen.entries()){const h=(o=e.metadataRegistry.get(d[0]))==null?void 0:o.id;if(h){const m=n.get(h);if(m&&m!==d[0])throw new Error(`Duplicate schema id "${h}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(h,d[0])}}const a=d=>{var x;const h=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const w=(x=e.external.registry.get(d[0]))==null?void 0:x.id,v=e.external.uri??(b=>b);if(w)return{ref:v(w)};const j=d[1].defId??d[1].schema.id??`schema${e.counter++}`;return d[1].defId=j,{defId:j,ref:`${v("__shared")}#/${h}/${j}`}}if(d[1]===r)return{ref:"#"};const f=`#/${h}/`,y=d[1].schema.id??`__schema${e.counter++}`;return{defId:y,ref:f+y}},i=d=>{if(d[1].schema.$ref)return;const h=d[1],{ref:m,defId:f}=a(d);h.def={...h.schema},f&&(h.defId=f);const y=h.schema;for(const x in y)delete y[x];y.$ref=m};if(e.cycles==="throw")for(const d of e.seen.entries()){const h=d[1];if(h.cycle)throw new Error(`Cycle detected: #/${(l=h.cycle)==null?void 0:l.join("/")}/<root>
74
+
75
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of e.seen.entries()){const h=d[1];if(t===d[0]){i(d);continue}if(e.external){const f=(c=e.external.registry.get(d[0]))==null?void 0:c.id;if(t!==d[0]&&f){i(d);continue}}if((u=e.metadataRegistry.get(d[0]))==null?void 0:u.id){i(d);continue}if(h.cycle){i(d);continue}if(h.count>1&&e.reused==="ref"){i(d);continue}}}function gc(e,t){var l,c,u,d;const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=h=>{const m=e.seen.get(h);if(m.ref===null)return;const f=m.def??m.schema,y={...f},x=m.ref;if(m.ref=null,x){n(x);const v=e.seen.get(x),j=v.schema;if(j.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(j)):Object.assign(f,j),Object.assign(f,y),h._zod.parent===x)for(const k in f)k==="$ref"||k==="allOf"||k in y||delete f[k];if(j.$ref&&v.def)for(const k in f)k==="$ref"||k==="allOf"||k in v.def&&JSON.stringify(f[k])===JSON.stringify(v.def[k])&&delete f[k]}const w=h._zod.parent;if(w&&w!==x){n(w);const v=e.seen.get(w);if(v!=null&&v.schema.$ref&&(f.$ref=v.schema.$ref,v.def))for(const j in f)j==="$ref"||j==="allOf"||j in v.def&&JSON.stringify(f[j])===JSON.stringify(v.def[j])&&delete f[j]}e.override({zodSchema:h,jsonSchema:f,path:m.path??[]})};for(const h of[...e.seen.entries()].reverse())n(h[0]);const a={};if(e.target==="draft-2020-12"?a.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?a.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?a.$schema="http://json-schema.org/draft-04/schema#":e.target,(l=e.external)!=null&&l.uri){const h=(c=e.external.registry.get(t))==null?void 0:c.id;if(!h)throw new Error("Schema is missing an `id` property");a.$id=e.external.uri(h)}Object.assign(a,r.def??r.schema);const i=(u=e.metadataRegistry.get(t))==null?void 0:u.id;i!==void 0&&a.id===i&&delete a.id;const o=((d=e.external)==null?void 0:d.defs)??{};for(const h of e.seen.entries()){const m=h[1];m.def&&m.defId&&(m.def.id===m.defId&&delete m.def.id,o[m.defId]=m.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?a.$defs=o:a.definitions=o);try{const h=JSON.parse(JSON.stringify(a));return Object.defineProperty(h,"~standard",{value:{...t["~standard"],jsonSchema:{input:is(t,"input",e.processors),output:is(t,"output",e.processors)}},enumerable:!1,writable:!1}),h}catch{throw new Error("Error converting schema to JSON.")}}function Le(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Le(n.element,r);if(n.type==="set")return Le(n.valueType,r);if(n.type==="lazy")return Le(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Le(n.innerType,r);if(n.type==="intersection")return Le(n.left,r)||Le(n.right,r);if(n.type==="record"||n.type==="map")return Le(n.keyType,r)||Le(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Le(n.in,r)||Le(n.out,r);if(n.type==="object"){for(const a in n.shape)if(Le(n.shape[a],r))return!0;return!1}if(n.type==="union"){for(const a of n.options)if(Le(a,r))return!0;return!1}if(n.type==="tuple"){for(const a of n.items)if(Le(a,r))return!0;return!!(n.rest&&Le(n.rest,r))}return!1}const ix=(e,t={})=>r=>{const n=pc({...r,processors:t});return Re(e,n),xc(n,e),gc(n,e)},is=(e,t,r={})=>n=>{const{libraryOptions:a,target:i}=n??{},o=pc({...a??{},target:i,io:t,processors:r});return Re(e,o),xc(o,e),gc(o,e)},ox={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},lx=(e,t,r,n)=>{const a=r;a.type="string";const{minimum:i,maximum:o,format:l,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(a.minLength=i),typeof o=="number"&&(a.maxLength=o),l&&(a.format=ox[l]??l,a.format===""&&delete a.format,l==="time"&&delete a.format),u&&(a.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?a.pattern=d[0].source:d.length>1&&(a.allOf=[...d.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},cx=(e,t,r,n)=>{r.type="boolean"},ux=(e,t,r,n)=>{r.not={}},dx=(e,t,r,n)=>{},hx=(e,t,r,n)=>{const a=e._zod.def,i=ec(a.entries);i.every(o=>typeof o=="number")&&(r.type="number"),i.every(o=>typeof o=="string")&&(r.type="string"),r.enum=i},mx=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},fx=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},px=(e,t,r,n)=>{const a=r,i=e._zod.def,{minimum:o,maximum:l}=e._zod.bag;typeof o=="number"&&(a.minItems=o),typeof l=="number"&&(a.maxItems=l),a.type="array",a.items=Re(i.element,t,{...n,path:[...n.path,"items"]})},xx=(e,t,r,n)=>{var u;const a=r,i=e._zod.def;a.type="object",a.properties={};const o=i.shape;for(const d in o)a.properties[d]=Re(o[d],t,{...n,path:[...n.path,"properties",d]});const l=new Set(Object.keys(o)),c=new Set([...l].filter(d=>{const h=i.shape[d]._zod;return t.io==="input"?h.optin===void 0:h.optout===void 0}));c.size>0&&(a.required=Array.from(c)),((u=i.catchall)==null?void 0:u._zod.def.type)==="never"?a.additionalProperties=!1:i.catchall?i.catchall&&(a.additionalProperties=Re(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(a.additionalProperties=!1)},gx=(e,t,r,n)=>{const a=e._zod.def,i=a.inclusive===!1,o=a.options.map((l,c)=>Re(l,t,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));i?r.oneOf=o:r.anyOf=o},yx=(e,t,r,n)=>{const a=e._zod.def,i=Re(a.left,t,{...n,path:[...n.path,"allOf",0]}),o=Re(a.right,t,{...n,path:[...n.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(i)?i.allOf:[i],...l(o)?o.allOf:[o]];r.allOf=c},bx=(e,t,r,n)=>{const a=e._zod.def,i=Re(a.innerType,t,n),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=a.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},vx=(e,t,r,n)=>{const a=e._zod.def;Re(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType},jx=(e,t,r,n)=>{const a=e._zod.def;Re(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType,r.default=JSON.parse(JSON.stringify(a.defaultValue))},wx=(e,t,r,n)=>{const a=e._zod.def;Re(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(a.defaultValue)))},Nx=(e,t,r,n)=>{const a=e._zod.def;Re(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType;let o;try{o=a.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=o},Sx=(e,t,r,n)=>{const a=e._zod.def,i=a.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?i?a.out:a.in:a.out;Re(o,t,n);const l=t.seen.get(e);l.ref=o},kx=(e,t,r,n)=>{const a=e._zod.def;Re(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType,r.readOnly=!0},yc=(e,t,r,n)=>{const a=e._zod.def;Re(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType};function va(){return va=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},va.apply(null,arguments)}function jo(e,t){try{var r=e()}catch(n){return t(n)}return r&&r.then?r.then(void 0,t):r}function Cx(e,t){for(var r={};e.length;){var n=e[0],a=n.code,i=n.message,o=n.path.join(".");if(!r[o])if("unionErrors"in n){var l=n.unionErrors[0].errors[0];r[o]={message:l.message,type:l.code}}else r[o]={message:i,type:a};if("unionErrors"in n&&n.unionErrors.forEach(function(d){return d.errors.forEach(function(h){return e.push(h)})}),t){var c=r[o].types,u=c&&c[n.code];r[o]=Ya(o,t,r,a,u?[].concat(u,n.message):n.message)}e.shift()}return r}function _x(e,t){for(var r={},n=function(){var a=e[0],i=a.code,o=a.message,l=a.path.join(".");if(!r[l])if(a.code==="invalid_union"&&a.errors.length>0){var c=a.errors[0][0];r[l]={message:c.message,type:c.code}}else r[l]={message:o,type:i};if(a.code==="invalid_union"&&a.errors.forEach(function(h){return h.forEach(function(m){return e.push(va({},m,{path:[].concat(a.path,m.path)}))})}),t){var u=r[l].types,d=u&&u[a.code];r[l]=Ya(l,t,r,i,d?[].concat(d,a.message):a.message)}e.shift()};e.length;)n();return r}function fr(e,t,r){if(r===void 0&&(r={}),(function(n){return"_def"in n&&typeof n._def=="object"&&"typeName"in n._def})(e))return function(n,a,i){try{return Promise.resolve(jo(function(){return Promise.resolve(e[r.mode==="sync"?"parse":"parseAsync"](n,t)).then(function(o){return i.shouldUseNativeValidation&&ga({},i),{errors:{},values:r.raw?Object.assign({},n):o}})},function(o){if((function(l){return Array.isArray(l==null?void 0:l.issues)})(o))return{values:{},errors:so(Cx(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};if((function(n){return"_zod"in n&&typeof n._zod=="object"})(e))return function(n,a,i){try{return Promise.resolve(jo(function(){return Promise.resolve((r.mode==="sync"?Pm:Em)(e,n,t)).then(function(o){return i.shouldUseNativeValidation&&ga({},i),{errors:{},values:r.raw?Object.assign({},n):o}})},function(o){if((function(l){return l instanceof si})(o))return{values:{},errors:so(_x(o.issues,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}const Ax=E("ZodISODateTime",(e,t)=>{$f.init(e,t),xe.init(e,t)});function Px(e){return zp(Ax,e)}const Ex=E("ZodISODate",(e,t)=>{Of.init(e,t),xe.init(e,t)});function Tx(e){return Lp(Ex,e)}const Ix=E("ZodISOTime",(e,t)=>{zf.init(e,t),xe.init(e,t)});function Fx(e){return Mp(Ix,e)}const Dx=E("ZodISODuration",(e,t)=>{Lf.init(e,t),xe.init(e,t)});function Rx(e){return Vp(Dx,e)}const $x=(e,t)=>{si.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Am(e,r)},flatten:{value:r=>_m(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,ya,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,ya,2)}},isEmpty:{get(){return e.issues.length===0}}})},nt=E("ZodError",$x,{Parent:Error}),Ox=ys(nt),zx=bs(nt),Lx=vs(nt),Mx=js(nt),Vx=Fm(nt),qx=Dm(nt),Ux=Rm(nt),Zx=$m(nt),Bx=Om(nt),Wx=zm(nt),Hx=Lm(nt),Qx=Mm(nt),wo=new WeakMap;function Ns(e,t,r){const n=Object.getPrototypeOf(e);let a=wo.get(n);if(a||(a=new Set,wo.set(n,a)),!a.has(t)){a.add(t);for(const i in r){const o=r[i];Object.defineProperty(n,i,{configurable:!0,enumerable:!1,get(){const l=o.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:l}),l},set(l){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:l})}})}}}const ke=E("ZodType",(e,t)=>(Se.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:is(e,"input"),output:is(e,"output")}}),e.toJSONSchema=ix(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,n)=>Ox(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Lx(e,r,n),e.parseAsync=async(r,n)=>zx(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Mx(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>Vx(e,r,n),e.decode=(r,n)=>qx(e,r,n),e.encodeAsync=async(r,n)=>Ux(e,r,n),e.decodeAsync=async(r,n)=>Zx(e,r,n),e.safeEncode=(r,n)=>Bx(e,r,n),e.safeDecode=(r,n)=>Wx(e,r,n),e.safeEncodeAsync=async(r,n)=>Hx(e,r,n),e.safeDecodeAsync=async(r,n)=>Qx(e,r,n),Ns(e,"ZodType",{check(...r){const n=this.def;return this.clone(Wt(n,{checks:[...n.checks??[],...r.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return Ht(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(Mg(r,n))},superRefine(r,n){return this.check(Vg(r,n))},overwrite(r){return this.check(qr(r))},optional(){return ko(this)},exactOptional(){return _g(this)},nullable(){return Co(this)},nullish(){return ko(Co(this))},nonoptional(r){return Fg(this,r)},array(){return yg(this)},or(r){return jg([this,r])},and(r){return Ng(this,r)},transform(r){return _o(this,kg(r))},default(r){return Eg(this,r)},prefault(r){return Ig(this,r)},catch(r){return Rg(this,r)},pipe(r){return _o(this,r)},readonly(){return zg(this)},describe(r){const n=this.clone();return rn.add(n,{description:r}),n},meta(...r){if(r.length===0)return rn.get(this);const n=this.clone();return rn.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){var r;return(r=rn.get(e))==null?void 0:r.description},configurable:!0}),e)),bc=E("_ZodString",(e,t)=>{ai.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,a,i)=>lx(e,n,a);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,Ns(e,"_ZodString",{regex(...n){return this.check(Bp(...n))},includes(...n){return this.check(Qp(...n))},startsWith(...n){return this.check(Kp(...n))},endsWith(...n){return this.check(Yp(...n))},min(...n){return this.check(as(...n))},max(...n){return this.check(mc(...n))},length(...n){return this.check(fc(...n))},nonempty(...n){return this.check(as(1,...n))},lowercase(n){return this.check(Wp(n))},uppercase(n){return this.check(Hp(n))},trim(){return this.check(Gp())},normalize(...n){return this.check(Jp(...n))},toLowerCase(){return this.check(Xp())},toUpperCase(){return this.check(ex())},slugify(){return this.check(tx())}})}),Kx=E("ZodString",(e,t)=>{ai.init(e,t),bc.init(e,t),e.email=r=>e.check(hc(vc,r)),e.url=r=>e.check(wp(Jx,r)),e.jwt=r=>e.check(Op(hg,r)),e.emoji=r=>e.check(Np(Gx,r)),e.guid=r=>e.check(vo(No,r)),e.uuid=r=>e.check(yp(zn,r)),e.uuidv4=r=>e.check(bp(zn,r)),e.uuidv6=r=>e.check(vp(zn,r)),e.uuidv7=r=>e.check(jp(zn,r)),e.nanoid=r=>e.check(Sp(Xx,r)),e.guid=r=>e.check(vo(No,r)),e.cuid=r=>e.check(kp(eg,r)),e.cuid2=r=>e.check(Cp(tg,r)),e.ulid=r=>e.check(_p(rg,r)),e.base64=r=>e.check(Dp(cg,r)),e.base64url=r=>e.check(Rp(ug,r)),e.xid=r=>e.check(Ap(ng,r)),e.ksuid=r=>e.check(Pp(sg,r)),e.ipv4=r=>e.check(Ep(ag,r)),e.ipv6=r=>e.check(Tp(ig,r)),e.cidrv4=r=>e.check(Ip(og,r)),e.cidrv6=r=>e.check(Fp(lg,r)),e.e164=r=>e.check($p(dg,r)),e.datetime=r=>e.check(Px(r)),e.date=r=>e.check(Tx(r)),e.time=r=>e.check(Fx(r)),e.duration=r=>e.check(Rx(r))});function F(e){return gp(Kx,e)}const xe=E("ZodStringFormat",(e,t)=>{he.init(e,t),bc.init(e,t)}),vc=E("ZodEmail",(e,t)=>{_f.init(e,t),xe.init(e,t)});function Yx(e){return hc(vc,e)}const No=E("ZodGUID",(e,t)=>{kf.init(e,t),xe.init(e,t)}),zn=E("ZodUUID",(e,t)=>{Cf.init(e,t),xe.init(e,t)}),Jx=E("ZodURL",(e,t)=>{Af.init(e,t),xe.init(e,t)}),Gx=E("ZodEmoji",(e,t)=>{Pf.init(e,t),xe.init(e,t)}),Xx=E("ZodNanoID",(e,t)=>{Ef.init(e,t),xe.init(e,t)}),eg=E("ZodCUID",(e,t)=>{Tf.init(e,t),xe.init(e,t)}),tg=E("ZodCUID2",(e,t)=>{If.init(e,t),xe.init(e,t)}),rg=E("ZodULID",(e,t)=>{Ff.init(e,t),xe.init(e,t)}),ng=E("ZodXID",(e,t)=>{Df.init(e,t),xe.init(e,t)}),sg=E("ZodKSUID",(e,t)=>{Rf.init(e,t),xe.init(e,t)}),ag=E("ZodIPv4",(e,t)=>{Mf.init(e,t),xe.init(e,t)}),ig=E("ZodIPv6",(e,t)=>{Vf.init(e,t),xe.init(e,t)}),og=E("ZodCIDRv4",(e,t)=>{qf.init(e,t),xe.init(e,t)}),lg=E("ZodCIDRv6",(e,t)=>{Uf.init(e,t),xe.init(e,t)}),cg=E("ZodBase64",(e,t)=>{Zf.init(e,t),xe.init(e,t)}),ug=E("ZodBase64URL",(e,t)=>{Wf.init(e,t),xe.init(e,t)}),dg=E("ZodE164",(e,t)=>{Hf.init(e,t),xe.init(e,t)}),hg=E("ZodJWT",(e,t)=>{Kf.init(e,t),xe.init(e,t)}),mg=E("ZodBoolean",(e,t)=>{Yf.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>cx(e,r,n)});function kr(e){return qp(mg,e)}const fg=E("ZodUnknown",(e,t)=>{Jf.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>dx()});function So(){return Up(fg)}const pg=E("ZodNever",(e,t)=>{Gf.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ux(e,r,n)});function xg(e){return Zp(pg,e)}const gg=E("ZodArray",(e,t)=>{Xf.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>px(e,r,n,a),e.element=t.element,Ns(e,"ZodArray",{min(r,n){return this.check(as(r,n))},nonempty(r){return this.check(as(1,r))},max(r,n){return this.check(mc(r,n))},length(r,n){return this.check(fc(r,n))},unwrap(){return this.element}})});function yg(e,t){return rx(gg,e,t)}const bg=E("ZodObject",(e,t)=>{tp.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>xx(e,r,n,a),le(e,"shape",()=>t.shape),Ns(e,"ZodObject",{keyof(){return Ss(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:So()})},loose(){return this.clone({...this._zod.def,catchall:So()})},strict(){return this.clone({...this._zod.def,catchall:xg()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return jm(this,r)},safeExtend(r){return wm(this,r)},merge(r){return Nm(this,r)},pick(r){return bm(this,r)},omit(r){return vm(this,r)},partial(...r){return Sm(jc,this,r[0])},required(...r){return km(wc,this,r[0])}})});function pr(e,t){const r={type:"object",shape:e??{},...G(t)};return new bg(r)}const vg=E("ZodUnion",(e,t)=>{rp.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>gx(e,r,n,a),e.options=t.options});function jg(e,t){return new vg({type:"union",options:e,...G(t)})}const wg=E("ZodIntersection",(e,t)=>{np.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>yx(e,r,n,a)});function Ng(e,t){return new wg({type:"intersection",left:e,right:t})}const ja=E("ZodEnum",(e,t)=>{sp.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,a,i)=>hx(e,n,a),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,a)=>{const i={};for(const o of n)if(r.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new ja({...t,checks:[],...G(a),entries:i})},e.exclude=(n,a)=>{const i={...t.entries};for(const o of n)if(r.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new ja({...t,checks:[],...G(a),entries:i})}});function Ss(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new ja({type:"enum",entries:r,...G(t)})}const Sg=E("ZodTransform",(e,t)=>{ap.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>fx(e,r),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Xl(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(un(i,r.value,t));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),r.issues.push(un(o))}};const a=t.transform(r.value,r);return a instanceof Promise?a.then(i=>(r.value=i,r.fallback=!0,r)):(r.value=a,r.fallback=!0,r)}});function kg(e){return new Sg({type:"transform",transform:e})}const jc=E("ZodOptional",(e,t)=>{dc.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>yc(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function ko(e){return new jc({type:"optional",innerType:e})}const Cg=E("ZodExactOptional",(e,t)=>{ip.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>yc(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function _g(e){return new Cg({type:"optional",innerType:e})}const Ag=E("ZodNullable",(e,t)=>{op.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>bx(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Co(e){return new Ag({type:"nullable",innerType:e})}const Pg=E("ZodDefault",(e,t)=>{lp.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>jx(e,r,n,a),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Eg(e,t){return new Pg({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():rc(t)}})}const Tg=E("ZodPrefault",(e,t)=>{cp.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>wx(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Ig(e,t){return new Tg({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():rc(t)}})}const wc=E("ZodNonOptional",(e,t)=>{up.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>vx(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Fg(e,t){return new wc({type:"nonoptional",innerType:e,...G(t)})}const Dg=E("ZodCatch",(e,t)=>{dp.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Nx(e,r,n,a),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Rg(e,t){return new Dg({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const $g=E("ZodPipe",(e,t)=>{hp.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Sx(e,r,n,a),e.in=t.in,e.out=t.out});function _o(e,t){return new $g({type:"pipe",in:e,out:t})}const Og=E("ZodReadonly",(e,t)=>{mp.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>kx(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function zg(e){return new Og({type:"readonly",innerType:e})}const Lg=E("ZodCustom",(e,t)=>{fp.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,n,a)=>mx(e,r)});function Mg(e,t={}){return nx(Lg,e,t)}function Vg(e,t){return sx(e,t)}const Gr={custom:"custom"};function os({label:e,required:t=!1,htmlFor:r}){return s.jsxs("label",{htmlFor:r,className:"mb-1.5 block text-sm text-slate-600",children:[e,t?s.jsx("span",{className:"text-red-500",children:" *"}):null]})}const tt=_.forwardRef(function({label:t,required:r=!1,error:n,id:a,className:i="",...o},l){const c=a??o.name;return s.jsxs("div",{children:[s.jsx(os,{label:t,required:r,htmlFor:c}),s.jsx("input",{ref:l,id:c,className:`block w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${n?"border-red-300":"border-slate-200"} ${i}`,...o}),n?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:n}):null]})}),Qn=_.forwardRef(function({label:t,required:r=!1,error:n,id:a,className:i="",children:o,...l},c){const u=a??l.name;return s.jsxs("div",{children:[s.jsx(os,{label:t,required:r,htmlFor:u}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{ref:c,id:u,className:`block w-full appearance-none rounded-lg border bg-white px-3 py-2.5 pr-10 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${n?"border-red-300":"border-slate-200"} ${i}`,...l,children:o}),s.jsx(qg,{})]}),n?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:n}):null]})});function wa({step:e,title:t,muted:r=!1,children:n}){return s.jsxs("section",{className:"space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[e?s.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-gov-600 text-xs font-semibold text-white",children:e}):null,s.jsx("h3",{className:`text-sm font-semibold tracking-wide ${r?"text-slate-400":"text-gov-700"}`,children:t})]}),n]})}function qg(){return s.jsx("svg",{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function Ur({variant:e="error",title:t,message:r}){const n=e==="error"?"border-red-200 bg-red-50 text-red-800":"border-slate-200 bg-white text-slate-700";return s.jsxs("div",{className:`rounded-lg border px-4 py-3 text-sm ${n}`,role:"alert",children:[t?s.jsx("p",{className:"font-medium",children:t}):null,s.jsx("p",{className:t?"mt-1":void 0,children:r})]})}function bt(e,t){var r;if(e instanceof bn){if(e.details){const n=(r=Object.values(e.details)[0])==null?void 0:r[0];if(n)return n}return e.message||t}return e instanceof Error&&e.message?e.message:t}function Zr(e,t){const r=e==null?void 0:e.from;return r&&r.startsWith("/")&&!r.startsWith("//")?r:t}const Ug=["LLP","LLC","Corporation","S-Corp","Sole Proprietorship","Partnership"],Zg=["AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY"],Bg=pr({accountType:Ss(["Business","Individual"]),businessName:F().min(1,"Business name is required"),tradeName:F(),ein:F().min(1,"EIN is required").refine(e=>e.replace(/\D/g,"").length===9,"EIN must be 9 digits"),entityType:F().min(1,"Entity type is required"),email:Yx("Enter a valid email"),countryCode:F().min(1),phoneNumber:F().min(1,"Phone number is required").refine(e=>e.replace(/\D/g,"").length===9,"Phone number must be 9 digits"),address1:F().min(1,"Address is required"),address2:F(),city:F().min(1,"City is required"),state:F().min(1,"State is required"),zipCode:F().min(1,"ZIP code is required"),country:F().min(1,"Country is required")});function Wg(e){const t=e.businessName.trim().split(/\s+/),r=t[0]??e.businessName,n=e.accountType==="Individual"?t.slice(1).join(" ")||r:e.businessName.trim();return{accountType:e.accountType,firstName:r,lastName:n,idNumber:e.ein.replace(/\D/g,""),entityType:e.entityType,tradeName:e.tradeName,phoneNumber:`${e.countryCode}${e.phoneNumber.replace(/\D/g,"")}`,email:e.email,address1:e.address1,address2:e.address2||null,city:e.city,state:e.state,country:e.country,zipCode:e.zipCode}}function Hg(){var j,b,k,P,A,L,O,V,J,H,K;const e=Te(),t=we(),r=Tt(),{data:n=[]}=Ee({queryKey:["entities","mine"],queryFn:Ol}),[a,i]=_.useState(null),[o,l]=_.useState(!1),c=n.length===0,u=c?"/create-entity":"/",d=Zr(t.state,u),h=()=>{e(d)},{register:m,handleSubmit:f,watch:y,formState:{errors:x}}=hr({resolver:fr(Bg),defaultValues:{accountType:"Individual",businessName:"",tradeName:"",ein:"",entityType:"LLP",email:"",countryCode:"+1",phoneNumber:"",address1:"",address2:"",city:"",state:"",zipCode:"",country:"United States"}}),w=y("accountType"),v=f(async Z=>{i(null),l(!0);try{await Lh(Wg(Z)),await r.invalidateQueries({queryKey:["entities","mine"]}),e(c?"/":d,{replace:!0})}catch(U){i(bt(U,"Unable to save entity. Please try again."))}finally{l(!1)}});return s.jsxs("form",{onSubmit:v,noValidate:!0,className:"space-y-8",children:[a?s.jsx(Ur,{message:a}):null,s.jsx(wa,{step:1,title:"ENTITY DETAILS",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx(os,{label:"Account Type",required:!0}),s.jsxs("div",{className:"mt-2 flex items-center gap-6",children:[s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:"Business",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...m("accountType")}),"Business"]}),s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:"Individual",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...m("accountType")}),"Individual"]})]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(tt,{label:w==="Individual"?"Full name":"Business Name",required:!0,placeholder:"Enter",error:(j=x.businessName)==null?void 0:j.message,...m("businessName")}),s.jsx(tt,{label:"Trade Name, if any",placeholder:"Enter",error:(b=x.tradeName)==null?void 0:b.message,...m("tradeName")})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(tt,{label:"EIN",required:!0,placeholder:"**-*******",maxLength:10,error:(k=x.ein)==null?void 0:k.message,...m("ein")}),s.jsx(Qn,{label:"Entity Type",required:!0,error:(P=x.entityType)==null?void 0:P.message,...m("entityType"),children:Ug.map(Z=>s.jsx("option",{value:Z,children:Z},Z))})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(tt,{label:"Email ID",required:!0,type:"email",placeholder:"sample@mail.com",error:(A=x.email)==null?void 0:A.message,...m("email")}),s.jsxs("div",{children:[s.jsx(os,{label:"Phone Number",required:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{className:"w-24 shrink-0 appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200",...m("countryCode"),children:[s.jsx("option",{value:"+1",children:"+1"}),s.jsx("option",{value:"+91",children:"+91"})]}),s.jsx("input",{type:"tel",placeholder:"9 digits",maxLength:9,className:`block w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${x.phoneNumber?"border-red-300":"border-slate-200"}`,...m("phoneNumber")})]}),x.phoneNumber?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:x.phoneNumber.message}):null]})]})]})}),s.jsx("div",{className:"border-t border-slate-200"}),s.jsx(wa,{title:"ADDRESS DETAILS",muted:!0,children:s.jsxs("div",{className:"space-y-5",children:[s.jsx(tt,{label:"Address Line 1",required:!0,error:(L=x.address1)==null?void 0:L.message,...m("address1")}),s.jsx(tt,{label:"Address Line 2",error:(O=x.address2)==null?void 0:O.message,...m("address2")}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(tt,{label:"City",required:!0,error:(V=x.city)==null?void 0:V.message,...m("city")}),s.jsxs(Qn,{label:"State",required:!0,error:(J=x.state)==null?void 0:J.message,...m("state"),children:[s.jsx("option",{value:"",children:"Select"}),Zg.map(Z=>s.jsx("option",{value:Z,children:Z},Z))]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(tt,{label:"ZIP Code",required:!0,error:(H=x.zipCode)==null?void 0:H.message,...m("zipCode")}),s.jsxs(Qn,{label:"Country",required:!0,error:(K=x.country)==null?void 0:K.message,...m("country"),children:[s.jsx("option",{value:"United States",children:"United States"}),s.jsx("option",{value:"Canada",children:"Canada"})]})]})]})}),s.jsxs("div",{className:"flex items-center gap-3 border-t border-slate-200 pt-6",children:[s.jsx("button",{type:"button",onClick:h,className:"inline-flex h-10 items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:o,className:"inline-flex h-10 items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:o?"Saving…":"Save"})]})]})}function ii(){return s.jsx("div",{className:"min-h-full bg-slate-100/80 px-4 py-8 sm:px-6 sm:py-10",children:s.jsx("div",{className:"mx-auto max-w-3xl rounded-2xl border border-slate-200/80 bg-white p-6 shadow-sm sm:p-8",children:s.jsx(Hg,{})})})}function Qg(e,t){const r=new URLSearchParams({entityId:String(e)});return t!==void 0&&r.set("taxYear",String(t)),ue(`/portal/dashboard?${r}`)}function Kg(e,t,r){const n=new URLSearchParams({entityId:String(e),category:t,taxYear:String(r)});return ue(`/portal/dashboard/summary?${n}`)}function Yg(e,t,r){const n=new URLSearchParams({entityId:String(e),month:String(t)});return r!==void 0&&n.set("year",String(r)),ue(`/portal/dashboard/monthly-overview?${n}`)}function Jg({entityId:e,search:t,taxYear:r,status:n,page:a=1,pageSize:i=20}){const o=new URLSearchParams({entityId:String(e),page:String(a),pageSize:String(i)});return t&&o.set("search",t),r&&o.set("taxYear",r),n&&n!=="all"&&o.set("status",n),ue(`/portal/dashboard/payments?${o}`)}function Ao({entityCount:e}){const t=Te();return s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>t("/payments/federal/new",{state:{from:"/"}}),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:[s.jsx(zs,{}),"Add Federal Payments"]}),s.jsxs("button",{type:"button",onClick:()=>t("/payments/state/new",{state:{from:"/"}}),className:"inline-flex items-center gap-2 rounded-lg border border-gov-600 bg-white px-4 py-2.5 text-sm font-semibold text-gov-600 transition hover:bg-gov-50",children:[s.jsx(zs,{}),"Add State Payment"]}),s.jsxs("button",{type:"button",disabled:!0,title:"Coming soon",className:"inline-flex cursor-not-allowed items-center gap-2 rounded-lg border border-slate-200 bg-slate-50 px-4 py-2.5 text-sm font-semibold text-slate-400",children:[s.jsx(zs,{}),"Add Local Payment",s.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>t("/entities"),className:"inline-flex items-center gap-2 rounded-lg border border-slate-200 bg-white px-4 py-2.5 text-sm font-medium text-slate-700 shadow-sm transition hover:bg-slate-50",children:[s.jsx(Gg,{}),"Entities (",e,")"]}),s.jsxs("button",{type:"button",onClick:()=>t("/create-entity/form",{state:{from:"/"}}),className:"inline-flex items-center gap-2 rounded-lg border border-dashed border-emerald-400 bg-white px-4 py-2.5 text-sm font-medium text-slate-700 shadow-sm transition hover:bg-emerald-50/50",children:[s.jsx(Xg,{}),"Add Entity"]})]})]})}function zs(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function Gg(){return s.jsx("svg",{className:"h-4 w-4 text-slate-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19.128a9.38 9.38 0 002.625.372 9.337 9.337 0 004.121-.952 4.125 4.125 0 00-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 018.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0111.964-3.07M12 6.375a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zm8.25 2.25a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z"})})}function Xg(){return s.jsx("svg",{className:"h-4 w-4 text-emerald-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zM4 19.235v-.11a6.375 6.375 0 0112.75 0v.109A12.318 12.318 0 0110.374 21c-2.356 0-4.564-.64-6.374-1.766z"})})}function ey({title:e,description:t,buttonLabel:r,onAdd:n,comingSoon:a=!1}){return s.jsxs("article",{className:"flex flex-col rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-sm",children:[s.jsx("h2",{className:"text-lg font-bold text-slate-900",children:e}),s.jsx("p",{className:"mx-auto mt-4 max-w-xs text-sm leading-relaxed text-slate-500",children:t}),a?s.jsx("span",{className:"mx-auto mt-8 inline-flex items-center gap-2 rounded-lg border border-slate-200 bg-slate-50 px-5 py-2.5 text-sm font-semibold text-slate-500",children:"Coming Soon"}):s.jsxs("button",{type:"button",onClick:n,className:"mx-auto mt-8 inline-flex items-center gap-2 rounded-lg bg-gov-600 px-5 py-2.5 text-sm font-semibold text-white transition hover:bg-gov-700",children:[s.jsx(ty,{}),r]})]})}function ty(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function oi({label:e="Loading…"}){return s.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center rounded-[inherit] bg-white/75","aria-live":"polite","aria-busy":"true",children:s.jsxs("div",{className:"flex items-center gap-2.5 text-sm text-slate-500",children:[s.jsx(ry,{}),s.jsx("span",{children:e})]})})}function ry(){return s.jsxs("svg",{className:"h-5 w-5 animate-spin text-gov-600",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":"true",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}const ny={Draft:"Draft"};function Nc(e){switch((e??ny.Draft).trim().toLowerCase()){case"draft":case"pending":return"drafts";case"scheduled":return"scheduled";case"processing":return"submitted";case"rejected":return"rejected";case"accepted":return"paid";default:return"drafts"}}function ks(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:e%1===0?0:2,maximumFractionDigits:2}).format(e)}function sy(e){const t=e.submitted+e.paid+e.scheduled+e.failed;return t<=0?[{color:"bg-emerald-400",width:0},{color:"bg-orange-400",width:0},{color:"bg-amber-400",width:0},{color:"bg-red-400",width:0}]:[{color:"bg-emerald-400",width:e.paid/t*100},{color:"bg-orange-400",width:e.submitted/t*100},{color:"bg-amber-400",width:e.scheduled/t*100},{color:"bg-red-400",width:e.failed/t*100}]}const ay=["January","February","March","April","May","June","July","August","September","October","November","December"];function iy({entityId:e,initialOverview:t,isDashboardLoading:r=!1}){const n=Te(),a=(t==null?void 0:t.year)??new Date().getFullYear(),[i,o]=_.useState(null);_.useEffect(()=>{o(null)},[e]);const l=i??(t==null?void 0:t.month)??new Date().getMonth()+1,c=i===null,{data:u,isFetching:d}=Ee({queryKey:["dashboard","monthly-overview",e,i,a],queryFn:()=>Yg(e,i,a),enabled:e!==null&&i!==null,placeholderData:x=>x}),h={submitted:0,paid:0,scheduled:0,failed:0},m=c?t??h:u??h,f=r||d&&!c,y=[{key:"submitted",label:"Submitted to Fed/State/Local",amount:m.submitted,icon:ly,iconClassName:"rounded-xl bg-orange-50 text-orange-500",amountClassName:"text-orange-500"},{key:"paid",label:"Paid",amount:m.paid,icon:cy,iconClassName:"rounded-full bg-emerald-50 text-emerald-600",amountClassName:"text-emerald-600"},{key:"scheduled",label:"Scheduled",amount:m.scheduled,icon:uy,iconClassName:"rounded-xl bg-amber-50 text-amber-500",amountClassName:"text-amber-500"},{key:"failed",label:"Failed",amount:m.failed,icon:dy,iconClassName:"rounded-full bg-red-50 text-red-500",amountClassName:"text-red-500"}];return s.jsxs("section",{className:"relative rounded-xl border border-slate-200 bg-white p-6",children:[f?s.jsx(oi,{}):null,s.jsxs("div",{className:"mb-6 flex flex-wrap items-center gap-4",children:[s.jsx("h2",{className:"text-sm font-bold uppercase tracking-wide text-slate-500",children:"Overview of Month"}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:l,onChange:x=>o(Number(x.target.value)),disabled:f,className:"appearance-none rounded-full border border-gov-600 bg-white py-1.5 pl-4 pr-8 text-sm font-medium text-gov-600 focus:border-gov-600 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:ay.map((x,w)=>s.jsx("option",{value:w+1,children:x},x))}),s.jsx(oy,{className:"pointer-events-none absolute right-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-gov-600"})]})]}),s.jsx("div",{className:"grid gap-6 sm:grid-cols-2 xl:grid-cols-4",children:y.map(x=>{const w=x.icon;return s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:`flex h-11 w-11 shrink-0 items-center justify-center ${x.iconClassName}`,children:s.jsx(w,{})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-xs leading-4 text-slate-500",children:x.label}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:[s.jsx("p",{className:`text-xl font-bold leading-7 ${x.amountClassName}`,children:ks(x.amount)}),s.jsx("button",{type:"button",onClick:()=>n("/payments"),className:"text-sm font-medium text-gov-600 underline decoration-gov-600 underline-offset-2 hover:text-gov-700",children:"View Details"})]})]})]},x.key)})})]})}function oy({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function ly(){return s.jsxs("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 14.25v-1.5M11.25 13.5h1.5"})]})}function cy(){return s.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}function uy(){return s.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})})}function dy(){return s.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"})})}function Po(e){return{count:e.count,submitted:e.submitted,paid:e.paid,scheduled:e.scheduled,failed:e.failed,percentDone:e.percentDone}}function hy(e){return{id:e.id,jurisdiction:e.jurisdiction,period:e.period,amount:e.amount,paymentDate:e.paymentDate,status:e.status,statusLabel:e.statusLabel,formType:e.formType,category:e.category}}function Eo(){return{count:0,submitted:0,paid:0,scheduled:0,failed:0,percentDone:0}}const my=[{value:"all",label:"All"},{value:"scheduled",label:"Scheduled"},{value:"paid",label:"Completed"},{value:"submitted",label:"Submitted"},{value:"failed",label:"Failed"}],To={total:0,items:[]};function fy({label:e,status:t}){const r={scheduled:"bg-amber-50 text-amber-700",paid:"bg-emerald-50 text-emerald-700",submitted:"bg-orange-50 text-orange-700",failed:"bg-red-50 text-red-600"};return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${r[t]}`,children:e})}function py({entityId:e,initialPayments:t,isDashboardLoading:r=!1}){const[n,a]=_.useState(""),[i,o]=_.useState(""),[l,c]=_.useState(""),[u,d]=_.useState("all");_.useEffect(()=>{const j=window.setTimeout(()=>o(n),300);return()=>window.clearTimeout(j)},[n]);const h=!!i||!!l||u!=="all",{data:m,isFetching:f}=Ee({queryKey:["dashboard","payments",e,i,l,u],queryFn:()=>Jg({entityId:e,search:i||void 0,taxYear:l||void 0,status:u}),enabled:e!==null&&h,placeholderData:j=>j}),y=h?m??t??To:t??To,x=_.useMemo(()=>y.items.map(hy),[y.items]),w=_.useMemo(()=>{const j=new Date().getFullYear();return[j,j-1,j-2].map(String)},[]),v=r||h&&f;return s.jsxs("section",{className:"relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[v?s.jsx(oi,{label:"Loading payments…"}):null,s.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-slate-200 px-6 py-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-gov-50 text-gov-600",children:s.jsx(gy,{})}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-base font-bold text-slate-900",children:"My Payments"}),s.jsxs("p",{className:"text-xs text-slate-500",children:[y.total," total payments"]})]})]})}),s.jsx("div",{className:"border-b border-slate-200 p-6",children:s.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1.4fr)_minmax(0,0.8fr)_minmax(0,0.8fr)] lg:items-end",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"payment-search",className:"mb-1.5 block text-sm text-slate-600",children:"Search by State/Form Type"}),s.jsxs("div",{className:"relative",children:[s.jsx(xy,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),s.jsx("input",{id:"payment-search",type:"text",value:n,onChange:j=>a(j.target.value),placeholder:"All",disabled:r,className:"block w-full rounded-lg border border-slate-200 bg-white py-2.5 pl-10 pr-3 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60"})]})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"tax-period-filter",className:"mb-1.5 block text-sm text-slate-600",children:"Filter by Tax Period"}),s.jsxs("div",{className:"relative",children:[s.jsxs("select",{id:"tax-period-filter",value:l,onChange:j=>c(j.target.value),disabled:r,className:"block w-full appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:[s.jsx("option",{value:"",children:"Select Year"}),w.map(j=>s.jsx("option",{value:j,children:j},j))]}),s.jsx(Io,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"})]})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"status-filter",className:"mb-1.5 block text-sm text-slate-600",children:"Filter by Status"}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{id:"status-filter",value:u,onChange:j=>d(j.target.value),disabled:r,className:"block w-full appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:my.map(j=>s.jsx("option",{value:j.value,children:j.label},j.value))}),s.jsx(Io,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"})]})]})]})}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[960px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-6 py-3",children:"ID"}),s.jsx("th",{className:"px-6 py-3",children:"Jurisdiction / Type"}),s.jsx("th",{className:"px-6 py-3",children:"Period"}),s.jsx("th",{className:"px-6 py-3",children:"Amount"}),s.jsx("th",{className:"px-6 py-3",children:"Payment"}),s.jsx("th",{className:"px-6 py-3",children:"Status"}),s.jsx("th",{className:"px-6 py-3",children:"Form Type"}),s.jsx("th",{className:"px-6 py-3",children:"Actions"})]})}),s.jsx("tbody",{children:!v&&x.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-slate-500",children:h?"No payments match your filters.":"No payments yet."})}):x.map((j,b)=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsxs("td",{className:"px-6 py-4 font-medium text-slate-900",children:["#",b+1]}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.jurisdiction}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.period}),s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:ks(j.amount)}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.paymentDate}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(fy,{label:j.statusLabel,status:j.status})}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.formType}),s.jsx("td",{className:"px-6 py-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{type:"button",className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"}),s.jsx("button",{type:"button",className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"Edit"})]})})]},`${j.category}-${j.id}`))})]})})]})}function xy({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"})})}function Io({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function gy(){return s.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}function Ls({entityId:e,category:t,title:r,subtitlePrefix:n,defaultTaxYear:a,taxYearOptions:i,initialSummary:o,isDashboardLoading:l=!1,stats:c,comingSoon:u=!1}){const[d,h]=_.useState(a);if(_.useEffect(()=>{h(a)},[e,a]),u)return s.jsxs("article",{className:"flex min-h-[220px] flex-col rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("h3",{className:"text-base font-bold text-slate-900",children:r}),s.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:n})]}),s.jsx("div",{className:"flex flex-1 items-center justify-center",children:s.jsx("span",{className:"rounded-full border border-slate-200 bg-slate-50 px-4 py-2 text-sm font-semibold text-slate-500",children:"Coming Soon"})})]});const m=d===a,{data:f,isFetching:y}=Ee({queryKey:["dashboard","summary",e,t,d],queryFn:()=>Kg(e,t,d),enabled:e!==null&&!m,placeholderData:j=>j}),x=m?o?Po(o):Eo():f?Po(f):Eo(),w=sy(x),v=l||y&&!m;return s.jsxs("article",{className:"relative flex flex-col rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[v?s.jsx(oi,{}):null,s.jsxs("div",{className:"mb-4 flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-bold text-slate-900",children:r}),s.jsxs("p",{className:"mt-0.5 text-xs text-slate-500",children:[n," (",x.count,")"]})]}),s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("select",{value:d,onChange:j=>h(Number(j.target.value)),disabled:v,className:"appearance-none rounded-lg border border-slate-200 bg-white py-1.5 pl-3 pr-8 text-xs font-medium text-slate-700 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:i.map(j=>s.jsxs("option",{value:j,children:["TY ",j]},j))}),s.jsx(yy,{className:"pointer-events-none absolute right-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400"})]})]}),s.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:c.map(j=>s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${j.dotClassName}`}),s.jsx("span",{className:"text-xs text-slate-500",children:j.label})]}),s.jsx("p",{className:"mt-1 text-sm font-semibold text-slate-900",children:ks(x[j.key])})]},j.label))}),s.jsxs("div",{className:"mt-5",children:[s.jsx("div",{className:"flex h-2 overflow-hidden rounded-full bg-slate-100",children:w.map((j,b)=>j.width>0?s.jsx("span",{className:`${j.color} h-full`,style:{width:`${j.width}%`}},b):null)}),s.jsxs("p",{className:"mt-2 text-xs font-medium text-slate-600",children:[x.percentDone,"% done"]})]})]})}function yy({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}const by="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",vy=[{key:"federal",title:"Add Your First Federal Payment",buttonLabel:"Add Federal Payment"},{key:"state",title:"Add Your First State Payment",buttonLabel:"Add State Payment"},{key:"local",title:"Add Your First Local Payment",buttonLabel:"Add Local Payments"}],Rt=new Date().getFullYear(),Ms=[Rt,Rt-1,Rt-2],jy=[{label:"Submitted to IRS",key:"submitted",dotClassName:"bg-orange-400"},{label:"Paid",key:"paid",dotClassName:"bg-emerald-400"},{label:"Scheduled",key:"scheduled",dotClassName:"bg-amber-400"},{label:"Failed",key:"failed",dotClassName:"bg-red-400"}],wy=[{label:"Submitted to State",key:"submitted",dotClassName:"bg-orange-400"},{label:"Paid",key:"paid",dotClassName:"bg-emerald-400"},{label:"Scheduled",key:"scheduled",dotClassName:"bg-amber-400"},{label:"Failed",key:"failed",dotClassName:"bg-red-400"}],Ny=[{label:"Submitted",key:"submitted",dotClassName:"bg-orange-400"},{label:"Paid",key:"paid",dotClassName:"bg-emerald-400"},{label:"Scheduled",key:"scheduled",dotClassName:"bg-amber-400"},{label:"Failed",key:"failed",dotClassName:"bg-red-400"}];function li(){const e=Te(),{entities:t,selectedEntity:r}=Va(),n=(r==null?void 0:r.entityId)??null,{data:a,isLoading:i}=Ee({queryKey:["dashboard",n,Rt],queryFn:()=>Qg(n,Rt),enabled:n!==null});return!i&&a&&!a.hasPayments?s.jsxs("div",{className:"space-y-6",children:[s.jsx(Ao,{entityCount:t.length}),s.jsx("div",{className:"grid gap-6 lg:grid-cols-3",children:vy.map(o=>s.jsx(ey,{title:o.title,description:by,buttonLabel:o.buttonLabel,onAdd:o.key==="federal"?()=>e("/payments/federal/new",{state:{from:"/dashboard"}}):o.key==="state"?()=>e("/payments/state/new",{state:{from:"/dashboard"}}):void 0,comingSoon:o.key==="local"},o.key))})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsx(Ao,{entityCount:t.length}),s.jsxs("div",{className:"grid gap-5 xl:grid-cols-3",children:[s.jsx(Ls,{entityId:n,category:"federal",title:"Federal Payments",subtitlePrefix:"IRS & Federal agencies",defaultTaxYear:Rt,taxYearOptions:Ms,initialSummary:a==null?void 0:a.federal,isDashboardLoading:i,stats:jy}),s.jsx(Ls,{entityId:n,category:"state",title:"All State Payments",subtitlePrefix:"State tax authorities",defaultTaxYear:Rt,taxYearOptions:Ms,initialSummary:a==null?void 0:a.state,isDashboardLoading:i,stats:wy}),s.jsx(Ls,{entityId:n,category:"local",title:"Local Payments",subtitlePrefix:"Local tax authorities",defaultTaxYear:Rt,taxYearOptions:Ms,initialSummary:a==null?void 0:a.local,isDashboardLoading:i,stats:Ny,comingSoon:!0})]}),s.jsx(iy,{entityId:n,initialOverview:a==null?void 0:a.monthlyOverview,isDashboardLoading:i}),s.jsx(py,{entityId:n,initialPayments:a==null?void 0:a.payments,isDashboardLoading:i})]})}function Sy(e){return ue(`/portal/federal-payments?entityId=${e}`)}function ci(e){return ue(`/portal/federal-payments/${e}`)}function ky(e){return ue(`/portal/federal-payments/form-types?entityId=${e}`)}function Cy(e){const t=new URLSearchParams({formType:e});return ue(`/portal/federal-payments/tax-type-codes?${t.toString()}`)}function ui(e){return ue("/portal/federal-payments",{method:"POST",body:e})}function di(e,t){return ue(`/portal/federal-payments/${e}`,{method:"PATCH",body:t})}function _y(e){return ue(`/portal/federal-payments/${e}/submit`,{method:"POST"})}function Ay(e){return ue(`/portal/state-payments?entityId=${e}`)}function Py(e){return ue("/portal/state-payments",{method:"POST",body:e})}function Ey(e,t){return ue(`/portal/state-payments/${e}`,{method:"PATCH",body:t})}function Sc(e){return ue(`/portal/state-payments/${e}/submit`,{method:"POST"})}function Ty({actionType:e,onView:t,onEdit:r,onSubmit:n,isSubmitting:a=!1}){return e==="draft-actions"?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"}),s.jsx("button",{type:"button",onClick:r,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"Edit"}),s.jsx("button",{type:"button",onClick:n,disabled:a,className:"rounded-lg bg-gov-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-gov-700 disabled:opacity-60",children:a?"Submitting…":"Submit"})]}):e==="view-pdf"?s.jsx("button",{type:"button",className:"rounded-lg border border-gov-200 bg-gov-50 px-4 py-1.5 text-sm font-medium text-gov-600 hover:bg-gov-100",children:"View PDF"}):e==="rejected-actions"?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"}),s.jsx("button",{type:"button",className:"rounded-lg border border-red-200 bg-red-50 px-3 py-1.5 text-xs font-semibold text-red-600 hover:bg-red-100",children:"Re-Submit"})]}):s.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"})}function kc(e){const t=/^(\d{4})-Q([1-4])$/.exec(e);if(t)return`Q${t[2]} ${t[1]}`;if(e.length!==6)return e;const r=e.slice(0,4),n=Number.parseInt(e.slice(4,6),10);return Number.isNaN(n)||n<1||n>12?e:`Q${Math.ceil(n/3)} ${r}`}function Iy(e){return{id:e.federalPaymentId,category:"federal",referenceNo:`FED-${e.federalPaymentId}`,jurisdiction:"IRS - Federal",period:kc(e.taxPeriod),amount:e.paymentAmount,paymentDate:e.settlementDate,status:e.status,reason:e.reason,tab:Nc(e.status)}}function Fy(e){return{id:e.statePaymentDetailId,category:"state",referenceNo:`ST-${e.statePaymentDetailId}`,jurisdiction:`${e.state} (State)`,period:kc(e.taxPeriod),amount:e.taxAmount,paymentDate:e.paymentDate,status:e.status,reason:e.reason,tab:Nc(e.status)}}function Dy(e,t,r){return e.filter(n=>n.tab!==t?!1:r==="all"?!0:n.category===r)}function Ry(e){return e.reduce((t,r)=>(t[r.tab]+=1,t),{drafts:0,scheduled:0,submitted:0,rejected:0,paid:0})}function $y({className:e,...t}){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:[s.jsx("path",{d:"M9.375 1.25H3.75C3.41848 1.25 3.10054 1.3817 2.86612 1.61612C2.6317 1.85054 2.5 2.16848 2.5 2.5V12.5C2.5 12.8315 2.6317 13.1495 2.86612 13.3839C3.10054 13.6183 3.41848 13.75 3.75 13.75H11.25C11.5815 13.75 11.8995 13.6183 12.1339 13.3839C12.3683 13.1495 12.5 12.8315 12.5 12.5V4.375L9.375 1.25Z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M8.75 1.25V3.75C8.75 4.08152 8.8817 4.39946 9.11612 4.63388C9.35054 4.8683 9.66848 5 10 5H12.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M6.25 5.625H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 8.125H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 10.625H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Oy({className:e,...t}){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:[s.jsxs("g",{clipPath:"url(#scheduled-tab-icon-clip)",children:[s.jsx("path",{d:"M7.5 13.75C10.9518 13.75 13.75 10.9518 13.75 7.5C13.75 4.04822 10.9518 1.25 7.5 1.25C4.04822 1.25 1.25 4.04822 1.25 7.5C1.25 10.9518 4.04822 13.75 7.5 13.75Z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.5 3.75V7.5L10 8.75",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("defs",{children:s.jsx("clipPath",{id:"scheduled-tab-icon-clip",children:s.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}function zy({className:e,...t}){return s.jsx("svg",{width:"12",height:"10",viewBox:"0 0 12 10",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:s.jsx("path",{d:"M0 10V0L11.875 5L0 10ZM1.25 8.125L8.65625 5L1.25 1.875V4.0625L5 5L1.25 5.9375V8.125Z",fill:"currentColor"})})}function Ly({className:e,...t}){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:[s.jsxs("g",{clipPath:"url(#rejected-tab-icon-clip)",children:[s.jsx("path",{d:"M7.5 13.75C10.9518 13.75 13.75 10.9518 13.75 7.5C13.75 4.04822 10.9518 1.25 7.5 1.25C4.04822 1.25 1.25 4.04822 1.25 7.5C1.25 10.9518 4.04822 13.75 7.5 13.75Z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.5 5V7.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.5 10H7.50625",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("defs",{children:s.jsx("clipPath",{id:"rejected-tab-icon-clip",children:s.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}function My({className:e,...t}){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:[s.jsxs("g",{clipPath:"url(#paid-tab-icon-clip)",children:[s.jsx("path",{d:"M7.5 13.75C10.9518 13.75 13.75 10.9518 13.75 7.5C13.75 4.04822 10.9518 1.25 7.5 1.25C4.04822 1.25 1.25 4.04822 1.25 7.5C1.25 10.9518 4.04822 13.75 7.5 13.75Z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M5.625 7.5L6.875 8.75L9.375 6.25",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("defs",{children:s.jsx("clipPath",{id:"paid-tab-icon-clip",children:s.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}const Cc=[{key:"drafts",label:"DRAFTS",Icon:$y,iconClassName:"text-gray-500"},{key:"scheduled",label:"SCHEDULED",Icon:Oy,iconClassName:"text-yellow-500"},{key:"submitted",label:"SUBMITTED TO FED/STATE",Icon:zy,iconClassName:"text-[#FF733D]"},{key:"rejected",label:"REJECTED",Icon:Ly,iconClassName:"text-red-500"},{key:"paid",label:"PAID",Icon:My,iconClassName:"text-green-500"}],Vy={drafts:{columns:["ID","Jurisdiction / Type","Period","Amount","Payment Date","Actions"],emptyMessage:"No draft payments to display yet.",actionType:"draft-actions"},scheduled:{columns:["Reference No","Jurisdiction / Type","Period","Amount","Scheduled Date","Actions"],emptyMessage:"No scheduled payments to display yet.",actionType:"view-pdf"},submitted:{columns:["Reference No","Jurisdiction / Type","Period","Amount","Submitted Date","Actions"],emptyMessage:"No submitted to fed/state payments to display yet.",actionType:"view-link"},rejected:{columns:["Reference No","Jurisdiction / Type","Period","Amount","Failed Date","Reason","Actions"],emptyMessage:"No rejected payments to display yet.",actionType:"rejected-actions"},paid:{columns:["Reference No","Jurisdiction / Type","Period","Amount","Actions"],emptyMessage:"No paid payments to display yet.",actionType:"view-link"}},_c="drafts";function yt(){return`/payments?tab=${_c}`}function Fo(e){return e!==null&&Cc.some(t=>t.key===e)}function hi({paymentsMode:e="all"}){const t=Te(),r=Tt(),[n]=Rd(),{selectedEntity:a}=vt(),i=(a==null?void 0:a.entityId)??null,o=n.get("tab"),[l,c]=_.useState(Fo(o)?o:_c),[u,d]=_.useState(e==="all"?"all":e),[h,m]=_.useState(null);_.useEffect(()=>{Fo(o)&&c(o)},[o]);const f=Vy[l],{data:y=[],isLoading:x}=Ee({queryKey:["remittance-payments",i,e],queryFn:async()=>{const[A,L]=await Promise.all([e!=="state"?Sy(i):Promise.resolve([]),e!=="federal"?Ay(i):Promise.resolve([])]);return[...A.map(Iy),...L.map(Fy)]},enabled:i!==null}),w=_.useMemo(()=>Ry(y),[y]),v=_.useMemo(()=>Dy(y,l,u),[y,l,u]),j=kh({mutationFn:async A=>{if(A.category==="federal"){await _y(A.id);return}await Sc(A.id)},onSuccess:async()=>{await r.invalidateQueries({queryKey:["remittance-payments"]}),await r.invalidateQueries({queryKey:["dashboard"]}),await r.invalidateQueries({queryKey:["federal-payments"]}),await r.invalidateQueries({queryKey:["state-payments"]})},onSettled:()=>m(null)}),b=A=>{m(`${A.category}-${A.id}`),j.mutate(A)},k=A=>{t(`/payments/federal/${A.id}/view`)},P=A=>{t(`/payments/federal/${A.id}/edit`)};return s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:"flex flex-wrap gap-3",children:[e!=="state"&&s.jsxs("button",{type:"button",onClick:()=>t("/payments/federal/new",{state:{from:"/payments"}}),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:[s.jsx(Vs,{}),"Add Federal Payment"]}),e!=="federal"&&s.jsxs("button",{type:"button",onClick:()=>t("/payments/state/new",{state:{from:"/payments"}}),className:"inline-flex items-center gap-2 rounded-lg border border-gov-600 bg-white px-4 py-2.5 text-sm font-semibold text-gov-600 transition hover:bg-gov-50",children:[s.jsx(Vs,{}),"Add State Payment"]}),e==="all"&&s.jsxs("button",{type:"button",disabled:!0,title:"Coming soon",className:"inline-flex cursor-not-allowed items-center gap-2 rounded-lg border border-slate-200 bg-slate-50 px-4 py-2.5 text-sm font-semibold text-slate-400",children:[s.jsx(Vs,{}),"Add Local Payments",s.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),s.jsxs("div",{className:"overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[s.jsx("div",{className:"flex flex-wrap gap-1 border-b border-slate-200 px-4 pt-4",children:Cc.map(A=>{const L=l===A.key,O=A.Icon;return s.jsxs("button",{type:"button",onClick:()=>c(A.key),className:`mb-[-1px] flex items-center gap-2 border-b-2 px-4 py-3 text-xs font-semibold tracking-wide transition ${L?"border-gov-600 text-gov-600":"border-transparent text-slate-500 hover:text-slate-700"}`,children:[s.jsx(O,{className:`shrink-0 ${A.iconClassName}`}),A.label," (",w[A.key],")"]},A.key)})}),s.jsxs("div",{className:"border-b border-slate-200 px-6 py-4",children:[s.jsx("label",{className:"mb-1.5 block text-sm text-slate-600",children:"Select Payment Type"}),s.jsxs("select",{value:u,onChange:A=>d(A.target.value),className:"w-full max-w-xs rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200",children:[s.jsx("option",{value:"all",children:"All"}),s.jsx("option",{value:"federal",children:"Federal"}),s.jsx("option",{value:"state",children:"State"}),s.jsx("option",{value:"local",disabled:!0,children:"Local (Coming Soon)"})]})]}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[800px] text-left text-sm",children:[s.jsx("thead",{children:s.jsx("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:f.columns.map(A=>s.jsx("th",{className:"px-6 py-3",children:A},A))})}),s.jsx("tbody",{children:x?s.jsx("tr",{children:s.jsx("td",{colSpan:f.columns.length,className:"px-6 py-12 text-center text-slate-500",children:"Loading payments…"})}):v.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:f.columns.length,className:"px-6 py-12 text-center text-slate-500",children:f.emptyMessage})}):v.map(A=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:l==="drafts"?`#${A.id}`:A.referenceNo}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:A.jurisdiction}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:A.period}),s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:ks(A.amount)}),l!=="paid"?s.jsx("td",{className:"px-6 py-4 text-slate-700",children:A.paymentDate}):null,l==="rejected"?s.jsx("td",{className:"px-6 py-4 text-slate-700",children:A.reason??"—"}):null,s.jsx("td",{className:"px-6 py-4",children:s.jsx(Ty,{actionType:f.actionType,onView:()=>{A.category==="federal"&&k(A)},onEdit:()=>{A.category==="federal"&&P(A)},onSubmit:()=>b(A),isSubmitting:h===`${A.category}-${A.id}`})})]},`${A.category}-${A.id}`))})]})})]})]})}function Vs(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function Cs(e){return ue(`/portal/bank-accounts?entityId=${e}`)}function qy(e){return ue("/portal/bank-accounts",{method:"POST",body:e})}function dn({title:e,children:t,isFirst:r=!1}){return s.jsxs("section",{className:r?"":"mt-8 border-t border-slate-100 pt-8",children:[s.jsxs("div",{className:"mb-5 flex items-center gap-2 text-gov-600",children:[s.jsx(Uy,{}),s.jsx("h3",{className:"text-base font-semibold",children:e})]}),t]})}function Uy(){return s.jsx("svg",{className:"h-4 w-4 shrink-0 text-gov-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}const Ac=["Checking","Savings"],Zy=pr({accountNumber:F().min(1,"Account number is required"),confirmAccountNumber:F().min(1,"Please confirm the account number"),routingNumber:F().min(1,"Routing number is required").refine(e=>/^\d{9}$/.test(e.replace(/\D/g,"")),"Routing number must be 9 digits"),accountType:Ss(Ac,{message:"Account type is required"}),bankName:F().min(1,"Bank name is required")}).refine(e=>e.accountNumber===e.confirmAccountNumber,{message:"Account numbers do not match",path:["confirmAccountNumber"]});function By({entityId:e,onCancel:t,onSuccess:r}){var m,f,y,x,w;const n=Tt(),[a,i]=_.useState(null),[o,l]=_.useState(!1),{register:c,handleSubmit:u,formState:{errors:d}}=hr({resolver:fr(Zy),defaultValues:{accountNumber:"",confirmAccountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}}),h=u(async v=>{i(null),l(!0);try{const j=await qy({entityId:e,bankName:v.bankName.trim(),accountNumber:v.accountNumber.trim(),routingNumber:v.routingNumber.replace(/\D/g,""),accountType:v.accountType});await n.invalidateQueries({queryKey:["bank-accounts",e]}),r(j.bankAccountDetailId)}catch(j){i(bt(j,"Unable to save bank account."))}finally{l(!1)}});return s.jsxs("form",{onSubmit:h,className:"space-y-6",children:[s.jsxs(wa,{step:2,title:"Add Bank Account Manually",children:[s.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-slate-400",children:"Bank Account"}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsx(tt,{label:"Account Number",required:!0,placeholder:"Bank account number",error:(m=d.accountNumber)==null?void 0:m.message,...c("accountNumber")}),s.jsx(tt,{label:"Confirm Account Number",required:!0,placeholder:"Re-enter account number",error:(f=d.confirmAccountNumber)==null?void 0:f.message,...c("confirmAccountNumber")}),s.jsx(tt,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",error:(y=d.routingNumber)==null?void 0:y.message,...c("routingNumber")}),s.jsx(Qn,{label:"Account Type",required:!0,error:(x=d.accountType)==null?void 0:x.message,...c("accountType"),children:Ac.map(v=>s.jsx("option",{value:v,children:v},v))})]}),s.jsx(tt,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",error:(w=d.bankName)==null?void 0:w.message,...c("bankName")})]}),a?s.jsx(Ur,{message:a}):null,s.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.jsx("button",{type:"button",onClick:t,disabled:o,className:"inline-flex h-11 items-center justify-center rounded-lg border border-slate-200 bg-white px-6 text-sm font-semibold text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:o,className:"inline-flex h-11 items-center justify-center rounded-lg bg-gov-600 px-6 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:o?"Saving…":"Save"})]})]})}function Pc({open:e,entityId:t,onClose:r,onAccountAdded:n}){const[a,i]=_.useState("choose");if(_.useEffect(()=>{e||i("choose")},[e]),_.useEffect(()=>{if(!e)return;const l=c=>{c.key==="Escape"&&r()};return document.addEventListener("keydown",l),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",l),document.body.style.overflow=""}},[e,r]),!e)return null;const o=a==="manual";return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[s.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:r}),s.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"add-bank-account-title",className:`relative w-full rounded-3xl bg-white p-8 shadow-xl ${o?"max-w-2xl":"max-w-[420px]"}`,children:o&&t?s.jsx(By,{entityId:t,onCancel:()=>i("choose"),onSuccess:l=>{n==null||n(l),r()}}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gov-600 text-sm font-semibold text-white",children:"1"}),s.jsx("h2",{id:"add-bank-account-title",className:"text-sm font-medium uppercase tracking-[0.2em] text-slate-400",children:"Add Bank Account"})]}),s.jsx("div",{className:"my-6 h-px bg-slate-200"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("button",{type:"button",onClick:()=>i("manual"),disabled:!t,className:"flex w-full items-center gap-4 rounded-full border border-slate-200 px-5 py-4 text-left transition hover:border-slate-300 hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-gov-600 text-white",children:s.jsx(Wy,{className:"h-5 w-5"})}),s.jsx("span",{className:"text-base font-semibold text-slate-900",children:"Add Manually"})]}),s.jsxs("button",{type:"button",disabled:!0,title:"Coming soon",className:"flex w-full cursor-not-allowed items-center gap-4 rounded-full border border-slate-200 px-5 py-4 text-left opacity-60",children:[s.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg border border-slate-200 bg-white",children:s.jsx(Hy,{className:"h-6 w-6"})}),s.jsx("span",{className:"text-base font-medium text-slate-400",children:"Connect with Plaid"})]})]})]})})]})}function Wy({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 7.5h10.5M6.75 12h10.5m-10.5 4.5h10.5M3.75 6.75A2.25 2.25 0 016 3.75h12A2.25 2.25 0 0120.25 6.75v10.5A2.25 2.25 0 0118 21H6A2.25 2.25 0 013.75 18.75V6.75z"})})}function Hy({className:e}){return s.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1",fill:"#111827"}),s.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1",fill:"#111827"}),s.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1",fill:"#111827"}),s.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1",fill:"#111827",opacity:"0.35"})]})}const Qy=12,Ky=["January","February","March","April","May","June","July","August","September","October","November","December"];function Jt(e){const t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${n}`}function Na(e){const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;const r=Number.parseInt(t[1],10),n=Number.parseInt(t[2],10)-1,a=Number.parseInt(t[3],10),i=new Date(r,n,a);return i.getFullYear()!==r||i.getMonth()!==n||i.getDate()!==a?null:i}function _s(e=new Date){const t=new Date(e);return e.getHours()>=Qy&&t.setDate(t.getDate()+1),t.setHours(0,0,0,0),Jt(t)}function Ec(e=new Date){const t=new Date(e);return t.setFullYear(t.getFullYear()+1),t.setHours(0,0,0,0),Jt(t)}function Yy(e){const t=e.getDay();return t!==0&&t!==6}function Sa(e,t=new Date){if(!Yy(e))return!1;const r=Jt(e);return r>=_s(t)&&r<=Ec(t)}function Tc(e,t=new Date){const r=Na(e);return r?Sa(r,t):!1}function Jy(e,t){return`${Ky[t]} ${e}`}function Gy(e,t){const r=new Date(e,t,1),n=new Date(e,t+1,0).getDate(),a=r.getDay(),i=[];for(let o=0;o<a;o+=1)i.push(null);for(let o=1;o<=n;o+=1)i.push(new Date(e,t,o));return i}function Do(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function wn(e){const t=Number.parseFloat(e);return!e||Number.isNaN(t)?"—":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(t)}function Ic({label:e,required:t=!1,htmlFor:r}){return s.jsx("label",{htmlFor:r,className:"mb-1.5 flex items-center gap-1.5 text-sm text-slate-600",children:s.jsxs("span",{children:[e,t?s.jsx("span",{className:"text-red-500",children:" *"}):null]})})}function Q({label:e,required:t,error:r,children:n}){return s.jsxs("div",{children:[s.jsx(Ic,{label:e,required:t}),n,r?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:r}):null]})}const Fc=e=>`block w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${e?"border-red-300":"border-slate-200"}`;function Y(e,t=!1){return t?`block w-full cursor-default rounded-lg border bg-[#F9FAFB] px-3 py-2.5 text-sm text-slate-700 focus:outline-none ${e?"border-red-300":"border-[#E5E7EB]"}`:Fc(e)}function sn(e){return`${Fc(e)} appearance-none`}function Nr({className:e}){return s.jsx("svg",{className:e??"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function an({children:e}){return s.jsx("div",{className:"relative",children:e})}function Xy(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.length===1?t[0].slice(0,2).toUpperCase():`${t[0][0]}${t[t.length-1][0]}`.toUpperCase()}function Qt(e){return e.tradeName.trim()?e.tradeName:e.accountType==="Business"?e.firstName:`${e.firstName} ${e.lastName}`.trim()}function Dc({value:e,onChange:t,entityId:r,entityType:n="",bankAccounts:a,isLoading:i=!1,disabled:o=!1,error:l,label:c="Bank Account Number"}){const[u,d]=_.useState(!1),[h,m]=_.useState(!1),f=_.useRef(null),y=a.find(w=>String(w.bankAccountDetailId)===e);_.useEffect(()=>{if(!u)return;const w=v=>{var j;(j=f.current)!=null&&j.contains(v.target)||d(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[u]);const x=w=>{t(String(w)),m(!1),d(!1)};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{ref:f,className:"relative",children:[s.jsx(Ic,{label:c,required:!0}),s.jsxs("button",{type:"button",disabled:o||!r,onClick:()=>d(w=>!w),className:`flex w-full items-center justify-between rounded-lg border bg-white px-3 py-2.5 text-left text-sm transition focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:cursor-not-allowed disabled:opacity-60 ${l?"border-red-300":"border-slate-200"}`,children:[s.jsx("span",{className:y?"text-slate-900":"text-slate-400",children:i?"Loading accounts…":y?Do(y.accountNumber):"Bank account number"}),s.jsx(tb,{className:`shrink-0 text-slate-400 transition ${u?"rotate-180":""}`})]}),l?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:l}):null,u?s.jsxs("div",{className:"absolute left-0 right-0 z-20 mt-2 overflow-hidden rounded-xl border border-slate-200 bg-white shadow-lg",children:[s.jsx("div",{className:"p-3",children:s.jsxs("button",{type:"button",onClick:()=>{d(!1),m(!0)},className:"inline-flex w-full items-center justify-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white transition hover:bg-gov-700",children:[s.jsx(eb,{}),"Add Bank Account"]})}),s.jsx("div",{className:"border-t border-slate-200 px-4 py-2",children:s.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-slate-400",children:"List of Bank Accounts"})}),s.jsx("div",{className:"max-h-64 overflow-y-auto pb-2",children:a.length===0?s.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No bank accounts yet."}):a.map(w=>{const v=String(w.bankAccountDetailId)===e;return s.jsxs("button",{type:"button",onClick:()=>{t(String(w.bankAccountDetailId)),d(!1)},className:`flex w-full items-center gap-3 px-4 py-3 text-left transition hover:bg-slate-50 ${v?"bg-gov-50":""}`,children:[s.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-gov-600 text-xs font-semibold text-white",children:Xy(w.bankName)}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate text-sm font-semibold text-slate-900",children:w.bankName}),s.jsxs("span",{className:"block truncate text-xs text-slate-500",children:[Do(w.accountNumber),n?` · ${n}`:` · ${w.accountType}`]})]})]},w.bankAccountDetailId)})})]}):null]}),s.jsx(Pc,{open:h,entityId:r,onClose:()=>m(!1),onAccountAdded:x})]})}function eb(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function tb({className:e=""}){return s.jsx("svg",{className:`h-4 w-4 ${e}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function mi(e){const t=e.replace(/\D/g,"");return t.length!==9?e:`${t.slice(0,2)}-${t.slice(2)}`}function Nn(e){const t=e.replace(/\D/g,""),r=t.length===11&&t.startsWith("1")?t.slice(1):t;return r.length!==10?e:`+1 (${r.slice(0,3)}) ${r.slice(3,6)}-${r.slice(6)}`}function rb(e){const t=e.address2?`, ${e.address2}`:"";return`${e.address1}${t}, ${e.city}, ${e.state} ${e.zipCode}`}function Sn({entity:e,remittanceAmount:t="—",className:r=""}){if(!e)return s.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${r}`,children:[s.jsx("div",{className:"bg-[#7F95B0] px-5 py-3.5 text-xs font-semibold uppercase tracking-wider text-white",children:"Entity Details"}),s.jsx("div",{className:"p-5 text-sm text-slate-500",children:"No entity selected."})]});const n=Qt(e);return s.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${r}`,children:[s.jsx("div",{className:"bg-[#7F95B0] px-5 py-3.5 text-xs font-semibold uppercase tracking-wider text-white",children:"Entity Details"}),s.jsxs("dl",{className:"space-y-4 p-5 text-sm",children:[s.jsx(Xr,{label:"Entity Name",value:n}),s.jsx(Xr,{label:"Tax ID",value:mi(e.idNumber)}),s.jsx(Xr,{label:"Email ID",value:e.email}),s.jsx(Xr,{label:"Phone Number",value:Nn(e.phoneNumber)}),s.jsx(Xr,{label:"Address",value:rb(e)})]}),s.jsxs("div",{className:"border-t border-slate-100 px-5 py-4",children:[s.jsx("p",{className:"text-sm font-medium text-[#99A1AF]",children:"Remittance Amount"}),s.jsx("p",{className:"mt-1.5 text-xl font-bold text-gov-600",children:t})]})]})}function Xr({label:e,value:t}){return s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm font-medium text-slate-500",children:e}),s.jsx("dd",{className:"mt-0.5 text-sm leading-relaxed text-slate-800",children:t})]})}const nb=[0,1,3,4,6,7,9,10],sb=[0,1,2,3,4,5,6,7,8,9,10],ab=[0,1,2,3,4,5,6,8,9,10,11],ib=[0,1,2,3,4,5,6,7,9,10,11],ob=["720","941"],lb=["706-GS (D)","706-GS (T)","926","940","943","944","945","1042","2438","3520","6069","8752","CT-1"],cb=["7200D"],ub=["8963"];function Rc(e){return ob.includes(e)?nb:lb.includes(e)?sb:cb.includes(e)?ab:ub.includes(e)?ib:[]}function db(e){return e.length!==6?"":`${e.slice(0,4)}-${e.slice(4,6)}`}function ls(e){if(e.length!==6)return null;const t=Number.parseInt(e.slice(0,4),10),r=Number.parseInt(e.slice(4,6),10);return Number.isNaN(t)||Number.isNaN(r)||r<1||r>12?null:{year:t,month:r-1}}function hb(e,t){return`${e}${String(t+1).padStart(2,"0")}`}function $c(){const e=new Date().getFullYear();return{minYear:e-2,maxYear:e}}const cs={941:"94105",944:"94405","CT-1":"10005"},en={socialSecurity:"Social Security",medicare:"Medicare",withheld:"Withheld",tier1:"Tier 1(FICA)",tier2:"Tier 2 (Industry)"},Ro="Payment amount must be a number greater than 0, can include up to 2 decimal places, and must not exceed 100,000,000.",mb=/^(?!0+(?:\.0+)?$)(?:100000000(?:\.00?)?|(?:\d{1,8}|\d{1,7}\d)(?:\.\d{1,2})?)$/;function fi(e,t){return!e||!t?!1:cs[e]===t}function As(e,t){return e==="CT-1"&&t===cs["CT-1"]}function fb(e,t){return e==="941"&&t===cs[941]||e==="944"&&t===cs[944]}function pb(e){return e==="CT-1"?{code1:en.tier1,code2:en.tier2,code3:""}:{code1:en.socialSecurity,code2:en.medicare,code3:en.withheld}}function ka(e){return mb.test(e)}function Oc(e){return ka(e)?Number.parseFloat(e):null}function xb(e,t,r,n){const a=[e,t];return n&&a.push(r),a.reduce((i,o)=>{const l=Oc(o);return l===null?i:i+l},0)}function gb(e,t){return Math.abs(e-t)<.005}function yb(e,t,r,n,a){if(!fi(e,t))return{subcategoryCode1:null,subcategoryCode2:null,subcategoryCode3:null};const i=As(e,t);return{subcategoryCode1:r.trim()?"1":null,subcategoryCode2:n.trim()?"2":null,subcategoryCode3:!i&&a.trim()?"3":null}}const bb=["Su","Mo","Tu","We","Th","Fr","Sa"];function vb(){return s.jsxs("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"16",rx:"2",className:"stroke-gov-600",strokeWidth:"1.5"}),s.jsx("path",{d:"M3 9h18",className:"stroke-gov-600",strokeWidth:"1.5"}),s.jsx("path",{d:"M8 3v4M16 3v4",className:"stroke-gov-600",strokeWidth:"1.5",strokeLinecap:"round"}),s.jsx("circle",{cx:"12",cy:"15",r:"1.5",className:"fill-gov-600"})]})}function jb({value:e,onChange:t,disabled:r=!1,hasError:n=!1}){const a=Na(e),i=_s(),o=Ec(),[l,c]=_.useState(!1),[u,d]=_.useState(()=>a??Na(i)??new Date),h=_.useRef(null),m=_.useId();_.useEffect(()=>{a&&d(a)},[e]),_.useEffect(()=>{if(!l)return;const v=j=>{var b;(b=h.current)!=null&&b.contains(j.target)||c(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[l]);const f=_.useMemo(()=>Gy(u.getFullYear(),u.getMonth()),[u]),y=_.useMemo(()=>{const v=new Date(u.getFullYear(),u.getMonth()-1,1),j=new Date(v.getFullYear(),v.getMonth()+1,0);return Jt(j)>=i},[u,i]),x=_.useMemo(()=>{const v=new Date(u.getFullYear(),u.getMonth()+1,1);return Jt(v)<=o},[u,o]),w=v=>{Sa(v)&&(t(Jt(v)),c(!1))};return s.jsxs("div",{ref:h,className:"relative",children:[s.jsxs("div",{className:`flex items-center gap-2 border-b bg-transparent pb-2 transition ${n?"border-red-400":"border-slate-300 focus-within:border-gov-500"}`,children:[s.jsx("input",{id:m,type:"text",readOnly:!0,disabled:r,value:e,placeholder:"YYYY-MM-DD",onClick:()=>!r&&c(v=>!v),className:"w-full cursor-pointer border-0 bg-transparent text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60"}),s.jsx("button",{type:"button",disabled:r,onClick:()=>c(v=>!v),className:"shrink-0 rounded p-0.5 text-gov-600 transition hover:bg-gov-50 disabled:cursor-not-allowed disabled:opacity-60","aria-label":"Open settlement date picker",children:s.jsx(vb,{})})]}),l?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+8px)] z-50 w-[300px] rounded-xl border border-slate-200 bg-white shadow-lg",children:[s.jsx("div",{className:"absolute -top-2 left-8 h-4 w-4 rotate-45 border-l border-t border-slate-200 bg-white"}),s.jsxs("div",{className:"flex items-center justify-between rounded-t-xl bg-slate-50 px-4 py-3",children:[s.jsx("button",{type:"button",disabled:!y,onClick:()=>d(v=>new Date(v.getFullYear(),v.getMonth()-1,1)),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Previous month",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),s.jsx("span",{className:"text-sm font-semibold text-slate-900",children:Jy(u.getFullYear(),u.getMonth())}),s.jsx("button",{type:"button",disabled:!x,onClick:()=>d(v=>new Date(v.getFullYear(),v.getMonth()+1,1)),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Next month",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})})]}),s.jsx("div",{className:"grid grid-cols-7 gap-1 px-3 pt-2 text-center text-xs font-medium text-slate-500",children:bb.map(v=>s.jsx("div",{className:"py-1",children:v},v))}),s.jsx("div",{className:"grid grid-cols-7 gap-1 p-3 pt-1",children:f.map((v,j)=>{if(!v)return s.jsx("div",{},`empty-${j}`);const b=Jt(v),k=e===b,P=!Sa(v);return s.jsx("button",{type:"button","aria-disabled":P,onClick:()=>w(v),className:`rounded-lg px-1 py-2 text-sm transition ${P?"cursor-not-allowed text-slate-300 hover:bg-sky-50":k?"bg-sky-100 font-semibold text-slate-900":"font-medium text-slate-800 hover:bg-slate-50"}`,children:v.getDate()},b)})})]}):null]})}const wb=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Nb(){return s.jsxs("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"16",rx:"2",className:"stroke-gov-600",strokeWidth:"1.5"}),s.jsx("path",{d:"M3 9h18",className:"stroke-gov-600",strokeWidth:"1.5"}),s.jsx("path",{d:"M8 3v4M16 3v4",className:"stroke-gov-600",strokeWidth:"1.5",strokeLinecap:"round"}),s.jsx("circle",{cx:"12",cy:"15",r:"1.5",className:"fill-gov-600"})]})}function Sb({value:e,onChange:t,disabled:r=!1,hasError:n=!1,disabledMonths:a=[]}){const{minYear:i,maxYear:o}=$c(),l=ls(e),[c,u]=_.useState(!1),[d,h]=_.useState((l==null?void 0:l.year)??o),m=_.useRef(null),f=_.useId();_.useEffect(()=>{l&&h(l.year)},[e]),_.useEffect(()=>{if(!c)return;const b=k=>{var P;(P=m.current)!=null&&P.contains(k.target)||u(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[c]);const y=db(e),x=b=>!!a.includes(b),w=b=>{x(b)||(t(hb(d,b)),u(!1))},v=d>i,j=d<o;return s.jsxs("div",{ref:m,className:"relative",children:[s.jsxs("div",{className:`flex items-center gap-2 border-b bg-transparent pb-2 transition ${n?"border-red-400":"border-slate-300 focus-within:border-gov-500"}`,children:[s.jsx("input",{id:f,type:"text",readOnly:!0,disabled:r,value:y,placeholder:"YYYY-MM",onClick:()=>!r&&u(b=>!b),className:"w-full cursor-pointer border-0 bg-transparent text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60"}),s.jsx("button",{type:"button",disabled:r,onClick:()=>u(b=>!b),className:"shrink-0 rounded p-0.5 text-gov-600 transition hover:bg-gov-50 disabled:cursor-not-allowed disabled:opacity-60","aria-label":"Open tax period picker",children:s.jsx(Nb,{})})]}),c?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+8px)] z-50 w-[280px] rounded-xl border border-slate-200 bg-white shadow-lg",children:[s.jsx("div",{className:"absolute -top-2 left-8 h-4 w-4 rotate-45 border-l border-t border-slate-200 bg-white"}),s.jsxs("div",{className:"flex items-center justify-between rounded-t-xl bg-slate-50 px-4 py-3",children:[s.jsx("button",{type:"button",disabled:!v,onClick:()=>h(b=>b-1),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Previous year",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),s.jsx("span",{className:"text-sm font-semibold text-slate-900",children:d}),s.jsx("button",{type:"button",disabled:!j,onClick:()=>h(b=>b+1),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Next year",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})})]}),s.jsx("div",{className:"grid grid-cols-3 gap-1 p-3",children:wb.map((b,k)=>{const P=(l==null?void 0:l.year)===d&&l.month===k&&e.length===6,A=x(k);return s.jsx("button",{type:"button","aria-disabled":A,onClick:()=>w(k),className:`rounded-lg px-2 py-2.5 text-sm transition ${A?"cursor-not-allowed text-slate-300 hover:bg-sky-50":P?"bg-sky-100 font-semibold text-slate-900":"font-medium text-slate-800 hover:bg-slate-50"}`,children:b},b)})})]}):null]})}function pi(e){var t;return((t=e==null?void 0:e.accountType)==null?void 0:t.trim().toLowerCase())==="individual"}function kb(e){return pi(e)?"/payments/federal/individual-enrollment":"/payments/federal/authorization"}function zc(e){const t=yb(e.taxFormType,e.taxTypeCode,e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??""),r=As(e.taxFormType,e.taxTypeCode);return{subcategoryCode1:t.subcategoryCode1,subcategoryAmount1:e.subcategoryAmount1?Number.parseFloat(e.subcategoryAmount1):null,subcategoryCode2:t.subcategoryCode2,subcategoryAmount2:e.subcategoryAmount2?Number.parseFloat(e.subcategoryAmount2):null,subcategoryCode3:t.subcategoryCode3,subcategoryAmount3:!r&&e.subcategoryAmount3?Number.parseFloat(e.subcategoryAmount3):null}}function xi(e,t){return{entityId:e,taxpayerPin:t.taxpayerPin||null,secondaryTin:t.secondaryTin||null,bankAccountDetailId:Number.parseInt(t.bankAccountDetailId,10),taxFormType:t.taxFormType,taxTypeCode:t.taxTypeCode,taxPeriod:t.taxPeriod,settlementDate:t.settlementDate,paymentAmount:Number.parseFloat(t.paymentAmount),...zc(t)}}function gi(e){return{taxpayerPin:e.taxpayerPin||null,secondaryTin:e.secondaryTin||null,bankAccountDetailId:Number.parseInt(e.bankAccountDetailId,10),taxFormType:e.taxFormType,taxTypeCode:e.taxTypeCode,taxPeriod:e.taxPeriod,settlementDate:e.settlementDate,paymentAmount:Number.parseFloat(e.paymentAmount),...zc(e)}}const yi="federal-payment-draft";function bi(e){sessionStorage.setItem(yi,JSON.stringify(e))}function Ps(){const e=sessionStorage.getItem(yi);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function vi(){sessionStorage.removeItem(yi)}function Cb(e,t={}){return{federalPaymentId:e.federalPaymentId,enrollmentId:e.enrollmentId,taxpayerPin:e.taxpayerPin??"",secondaryTin:e.secondaryTin??"",bankAccountDetailId:e.bankAccountDetailId?String(e.bankAccountDetailId):"",routingNumber:t.routingNumber??"",accountType:t.accountType??"",bankName:t.bankName??"",taxFormType:e.taxFormType,taxTypeCode:e.taxTypeCode,taxPeriod:e.taxPeriod,settlementDate:e.settlementDate,paymentAmount:String(e.paymentAmount),subcategoryAmount1:e.subcategoryAmount1!=null?String(e.subcategoryAmount1):"",subcategoryAmount2:e.subcategoryAmount2!=null?String(e.subcategoryAmount2):"",subcategoryAmount3:e.subcategoryAmount3!=null?String(e.subcategoryAmount3):""}}const _b=pr({taxpayerPin:F().max(4,"Taxpayer PIN must not exceed 4 characters").optional(),secondaryTin:F().max(9,"Secondary TIN must not exceed 9 characters").optional(),bankAccountDetailId:F().min(1,"Bank account is required"),routingNumber:F().optional(),accountType:F().optional(),bankName:F().optional(),taxFormType:F().min(1,"Tax form type is required"),taxTypeCode:F().min(1,"Payment type is required"),taxPeriod:F().min(1,"This field is required").regex(/^\d{6}$/,"Tax period must be in YYYY-MM format").refine(e=>{const t=ls(e);if(!t)return!1;const{minYear:r,maxYear:n}=$c();return t.year>=r&&t.year<=n},"Tax period must be within the last 3 years"),settlementDate:F().min(1,"This field is required").refine(e=>Tc(e),"Settlement date must be a weekday within the allowed range"),paymentAmount:F().min(1,"This field is required").refine(e=>ka(e),Ro),subcategoryCode1:F().optional(),subcategoryAmount1:F().optional(),subcategoryCode2:F().optional(),subcategoryAmount2:F().optional(),subcategoryCode3:F().optional(),subcategoryAmount3:F().optional()}).superRefine((e,t)=>{var l;if(e.taxPeriod&&e.taxFormType){const c=ls(e.taxPeriod);c&&Rc(e.taxFormType).includes(c.month)&&t.addIssue({code:Gr.custom,message:"Tax period must be a valid month for the selected tax form",path:["taxPeriod"]})}if(!fi(e.taxFormType,e.taxTypeCode))return;const r=As(e.taxFormType,e.taxTypeCode),n=fb(e.taxFormType,e.taxTypeCode),a=(c,u,d)=>{if(!(c!=null&&c.trim())){d&&t.addIssue({code:Gr.custom,message:"This field is required",path:[u]});return}ka(c)||t.addIssue({code:Gr.custom,message:Ro,path:[u]})};a(e.subcategoryAmount1,"subcategoryAmount1",!0),a(e.subcategoryAmount2,"subcategoryAmount2",!0),a(e.subcategoryAmount3,"subcategoryAmount3",n);const i=Oc(e.paymentAmount),o=xb(e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??"",n);i!==null&&!gb(i,o)&&t.addIssue({code:Gr.custom,message:"Payment amount must equal the sum of subcategory amounts",path:["paymentAmount"]}),r&&((l=e.subcategoryAmount3)!=null&&l.trim())&&t.addIssue({code:Gr.custom,message:"Subcategory amount 3 is not used for CT-1 payments",path:["subcategoryAmount3"]})}),Ln="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function qs(e){return{taxpayerPin:e.taxpayerPin??"",secondaryTin:e.secondaryTin??"",bankAccountDetailId:e.bankAccountDetailId,routingNumber:e.routingNumber??"",accountType:e.accountType??"",bankName:e.bankName??"",taxFormType:e.taxFormType,taxTypeCode:e.taxTypeCode,taxPeriod:e.taxPeriod,settlementDate:e.settlementDate,paymentAmount:e.paymentAmount,subcategoryCode1:e.subcategoryCode1??"",subcategoryAmount1:e.subcategoryAmount1??"",subcategoryCode2:e.subcategoryCode2??"",subcategoryAmount2:e.subcategoryAmount2??"",subcategoryCode3:e.subcategoryCode3??"",subcategoryAmount3:e.subcategoryAmount3??""}}const Ab={taxpayerPin:"",secondaryTin:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:"",taxFormType:"",taxTypeCode:"",taxPeriod:"",settlementDate:"",paymentAmount:"",subcategoryCode1:"",subcategoryAmount1:"",subcategoryCode2:"",subcategoryAmount2:"",subcategoryCode3:"",subcategoryAmount3:""};function Pb(e,t){if(e)return qs(e);if(t!=null&&t.paymentDraft)return qs(t.paymentDraft);const r=Ps();return r?qs(r):Ab}function Lc({entity:e,initialDraft:t,readonly:r=!1,onCancel:n}){var It,Cn,gr,Br,yr,br,_n,Wr,An,Hr,Qr,Pn,En;const a=Te(),i=we(),o=Tt(),l=Zr(i.state,yt()),c=i.state,u=_.useMemo(()=>t??(c==null?void 0:c.paymentDraft)??Ps()??null,[t,c==null?void 0:c.paymentDraft]),d=_.useRef(u==null?void 0:u.federalPaymentId),h=_.useRef(u==null?void 0:u.enrollmentId),[m,f]=_.useState(null),[y,x]=_.useState(!1),w=_.useMemo(()=>Pb(t,c),[t,c==null?void 0:c.paymentDraft,i.key]);_.useEffect(()=>{u!=null&&u.federalPaymentId&&(d.current=u.federalPaymentId),u!=null&&u.enrollmentId&&(h.current=u.enrollmentId)},[u==null?void 0:u.federalPaymentId,u==null?void 0:u.enrollmentId]);const{data:v=[],isLoading:j}=Ee({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:()=>Cs(e.entityId),enabled:e!==null}),{data:b=[],isLoading:k}=Ee({queryKey:["federal-form-types",e==null?void 0:e.entityId],queryFn:()=>ky(e.entityId),enabled:e!==null}),{register:P,control:A,handleSubmit:L,watch:O,setValue:V,trigger:J,formState:{errors:H}}=hr({resolver:fr(_b),defaultValues:w}),K=O("bankAccountDetailId"),Z=O("paymentAmount"),U=O("taxFormType"),ee=O("taxTypeCode"),oe=O("taxPeriod"),ge=O("settlementDate"),q=O("subcategoryAmount1"),ye=O("subcategoryAmount2"),st=O("subcategoryAmount3"),Be=_.useRef(U),Xe=_.useMemo(()=>U?Rc(U):[],[U]),qe=_.useMemo(()=>fi(U,ee),[U,ee]),Ie=_.useMemo(()=>As(U,ee),[U,ee]),{data:wt=[],isLoading:at}=Ee({queryKey:["federal-tax-type-codes",U],queryFn:()=>Cy(U),enabled:!!U});_.useEffect(()=>{Be.current&&Be.current!==U&&V("taxTypeCode",""),Be.current=U},[U,V]),_.useEffect(()=>{if(!oe||!U)return;const B=ls(oe);B&&Xe.includes(B.month)&&V("taxPeriod","")},[U,oe,Xe,V]),_.useEffect(()=>{ge&&(Tc(ge)||V("settlementDate",""))},[ge,V]),_.useEffect(()=>{if(!qe){V("subcategoryCode1",""),V("subcategoryCode2",""),V("subcategoryCode3",""),V("subcategoryAmount1",""),V("subcategoryAmount2",""),V("subcategoryAmount3","");return}const B=pb(U);V("subcategoryCode1",B.code1),V("subcategoryCode2",B.code2),V("subcategoryCode3",Ie?"":B.code3),Ie&&V("subcategoryAmount3","")},[qe,U,Ie,V]),_.useEffect(()=>{qe&&(J("paymentAmount"),J("subcategoryAmount1"),J("subcategoryAmount2"),J("subcategoryAmount3"))},[q,ye,st,qe,J]),_.useEffect(()=>{const B=v.find(Ae=>String(Ae.bankAccountDetailId)===K);B&&(V("routingNumber",B.routingNumber),V("accountType",B.accountType),V("bankName",B.bankName))},[v,K,V]);const se=B=>({federalPaymentId:d.current,enrollmentId:h.current??(u==null?void 0:u.enrollmentId),form8655AuthorizationId:u==null?void 0:u.form8655AuthorizationId,form9783EnrollmentId:u==null?void 0:u.form9783EnrollmentId,taxpayerPin:B.taxpayerPin??"",secondaryTin:B.secondaryTin??"",bankAccountDetailId:B.bankAccountDetailId,routingNumber:B.routingNumber??"",accountType:B.accountType??"",bankName:B.bankName??"",taxFormType:B.taxFormType,taxTypeCode:B.taxTypeCode,taxPeriod:B.taxPeriod,settlementDate:B.settlementDate,paymentAmount:B.paymentAmount,subcategoryCode1:B.subcategoryCode1,subcategoryAmount1:B.subcategoryAmount1,subcategoryCode2:B.subcategoryCode2,subcategoryAmount2:B.subcategoryAmount2,subcategoryCode3:B.subcategoryCode3,subcategoryAmount3:B.subcategoryAmount3}),be=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},dt=async B=>{if(!e)return null;if(B.federalPaymentId){const mt=await di(B.federalPaymentId,gi(B));return d.current=mt.federalPaymentId,h.current=mt.enrollmentId,mt}const Ae=await ui(xi(e.entityId,B));return d.current=Ae.federalPaymentId,h.current=Ae.enrollmentId,Ae},ht=L(async B=>{if(!(r||!e)){f(null),x(!0);try{const Ae=se(B),mt=await dt(Ae);if(!mt)return;const p={...Ae,federalPaymentId:mt.federalPaymentId,enrollmentId:mt.enrollmentId};await be(),bi(p),a(kb(e),{state:{from:l,paymentDraft:p}})}catch(Ae){f(bt(Ae,"Failed to save payment details."))}finally{x(!1)}}}),me=L(async B=>{if(!(!e||r)){f(null),x(!0);try{const Ae=se(B);await dt(Ae),await be(),vi(),a(yt())}catch(Ae){f(bt(Ae,"Failed to save draft."))}finally{x(!1)}}}),Ce=()=>{if(n){n();return}a(l)},xr=e?Qt(e):"Entity";return s.jsxs("form",{onSubmit:ht,noValidate:!0,className:"w-full space-y-6",children:[m?s.jsx(Ur,{message:m}):null,s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:xr}),s.jsx(Sn,{entity:e,remittanceAmount:wn(Z),className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:[s.jsx(dn,{title:"Enrolment Details",isFirst:!0,children:s.jsxs("div",{className:Ln,children:[s.jsx(Q,{label:"Taxpayer PIN",required:!0,error:(It=H.taxpayerPin)==null?void 0:It.message,children:s.jsx("input",{placeholder:"Taxpayer PIN",className:Y(!!H.taxpayerPin),maxLength:4,disabled:r,...P("taxpayerPin")})}),s.jsx(Q,{label:"Secondary TIN",error:(Cn=H.secondaryTin)==null?void 0:Cn.message,children:s.jsx("input",{placeholder:"Secondary TIN",className:Y(!!H.secondaryTin),maxLength:9,disabled:r,...P("secondaryTin")})}),s.jsx(Wn,{name:"bankAccountDetailId",control:A,render:({field:B})=>{var Ae;return s.jsx(Dc,{value:B.value,onChange:B.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:v,isLoading:j,disabled:!e||r,error:(Ae=H.bankAccountDetailId)==null?void 0:Ae.message})}}),s.jsx(Q,{label:"Routing Number",required:!0,error:(gr=H.routingNumber)==null?void 0:gr.message,children:s.jsx("input",{readOnly:!0,placeholder:"Routing Number",className:Y(!!H.routingNumber,!0),...P("routingNumber")})}),s.jsx(Q,{label:"Account Type",required:!0,error:(Br=H.accountType)==null?void 0:Br.message,children:s.jsx("input",{readOnly:!0,placeholder:"Account Type",className:Y(!!H.accountType,!0),...P("accountType")})}),s.jsx(Q,{label:"Bank Name",required:!0,error:(yr=H.bankName)==null?void 0:yr.message,children:s.jsx("input",{readOnly:!0,placeholder:"Bank Name",className:Y(!!H.bankName,!0),...P("bankName")})})]})}),s.jsx(dn,{title:"Federal Payment",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:Ln,children:[s.jsx(Q,{label:"Tax Form Type",required:!0,error:(br=H.taxFormType)==null?void 0:br.message,children:s.jsxs(an,{children:[s.jsxs("select",{className:sn(!!H.taxFormType),disabled:k||!e||r,...P("taxFormType"),children:[s.jsx("option",{value:"",children:k?"Loading form types…":"Select form type"}),b.map(B=>s.jsx("option",{value:B.value,children:B.value},B.value))]}),s.jsx(Nr,{})]})}),s.jsx(Q,{label:"Payment Type",required:!0,error:(_n=H.taxTypeCode)==null?void 0:_n.message,children:s.jsxs(an,{children:[s.jsxs("select",{className:sn(!!H.taxTypeCode),disabled:!U||at||r,...P("taxTypeCode"),children:[s.jsx("option",{value:"",children:U?at?"Loading payment types…":"Select payment type":"Select tax form first"}),wt.map(B=>s.jsxs("option",{value:B.code,children:[B.code," - ",B.codeName]},B.code))]}),s.jsx(Nr,{})]})}),s.jsx(Q,{label:"Tax Period",required:!0,error:(Wr=H.taxPeriod)==null?void 0:Wr.message,children:s.jsx(Wn,{name:"taxPeriod",control:A,render:({field:B})=>s.jsx(Sb,{value:B.value,onChange:B.onChange,hasError:!!H.taxPeriod,disabled:!U||r,disabledMonths:Xe})})})]}),s.jsxs("div",{className:"grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx(Q,{label:"Settlement Date",required:!0,error:(An=H.settlementDate)==null?void 0:An.message,children:s.jsx(Wn,{name:"settlementDate",control:A,render:({field:B})=>s.jsx(jb,{value:B.value,onChange:B.onChange,hasError:!!H.settlementDate,disabled:r})})}),s.jsx(Q,{label:"Payment Amount",required:!0,error:(Hr=H.paymentAmount)==null?void 0:Hr.message,children:s.jsx("input",{type:"number",step:"0.01",min:"0",placeholder:"0.00",disabled:r,className:Y(!!H.paymentAmount),...P("paymentAmount")})})]}),qe?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:Ln,children:[s.jsx(Q,{label:"Subcategory Code 1",children:s.jsx("input",{readOnly:!0,className:Y(!1,!0),...P("subcategoryCode1")})}),s.jsx(Q,{label:"Subcategory Code 2",children:s.jsx("input",{readOnly:!0,className:Y(!1,!0),...P("subcategoryCode2")})}),Ie?null:s.jsx(Q,{label:"Subcategory Code 3",children:s.jsx("input",{readOnly:!0,className:Y(!1,!0),...P("subcategoryCode3")})})]}),s.jsxs("div",{className:Ln,children:[s.jsx(Q,{label:"Subcategory Amount 1",required:!0,error:(Qr=H.subcategoryAmount1)==null?void 0:Qr.message,children:s.jsx("input",{type:"number",step:"0.01",min:"0",placeholder:"Enter amount",disabled:r,className:Y(!!H.subcategoryAmount1),...P("subcategoryAmount1")})}),s.jsx(Q,{label:"Subcategory Amount 2",required:!0,error:(Pn=H.subcategoryAmount2)==null?void 0:Pn.message,children:s.jsx("input",{type:"number",step:"0.01",min:"0",placeholder:"Enter amount",disabled:r,className:Y(!!H.subcategoryAmount2),...P("subcategoryAmount2")})}),Ie?null:s.jsx(Q,{label:"Subcategory Amount 3",required:!0,error:(En=H.subcategoryAmount3)==null?void 0:En.message,children:s.jsx("input",{type:"number",step:"0.01",min:"0",placeholder:"Enter amount",disabled:r,className:Y(!!H.subcategoryAmount3),...P("subcategoryAmount3")})})]})]}):null]})})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[s.jsx("button",{type:"button",onClick:Ce,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50",children:r?"Back":"Cancel"}),r?null:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:me,disabled:!e||y,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:y?"Saving…":"Save as Draft"}),s.jsx("button",{type:"submit",disabled:!e||y,className:"inline-flex h-11 min-w-[160px] items-center justify-center rounded-lg bg-gov-600 px-10 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:y?"Saving…":"Next"})]})]})]},i.key)}function Mc(){const{selectedEntity:e}=vt();return s.jsx(Lc,{entity:e})}function Vc({mode:e}){var h;const t=Te(),{federalPaymentId:r}=Zu(),{selectedEntity:n}=vt(),a=Number.parseInt(r??"",10),{data:i,isLoading:o,isError:l}=Ee({queryKey:["federal-payment",a],queryFn:()=>ci(a),enabled:Number.isFinite(a)}),{data:c=[]}=Ee({queryKey:["bank-accounts",n==null?void 0:n.entityId],queryFn:()=>Cs(n.entityId),enabled:n!==null&&i!==void 0}),u=_.useMemo(()=>{if(!i)return null;const m=c.find(f=>f.bankAccountDetailId===i.bankAccountDetailId);return Cb(i,{routingNumber:m==null?void 0:m.routingNumber,accountType:m==null?void 0:m.accountType,bankName:m==null?void 0:m.bankName})},[i,c]);if(!Number.isFinite(a))return s.jsx(ut,{to:yt(),replace:!0});if(o)return s.jsx("p",{className:"text-sm text-slate-600",children:"Loading federal payment…"});if(l||!i||!u)return s.jsx(ut,{to:yt(),replace:!0});if(!n||i.entityId!==n.entityId)return s.jsx(ut,{to:yt(),replace:!0});const d=e==="view"||((h=i.status)==null?void 0:h.toLowerCase())!=="draft";return s.jsx(Lc,{entity:n,initialDraft:u,readonly:d,onCancel:()=>t(yt())})}function qc(){return vt(),s.jsx(Vc,{mode:"edit"})}function Uc(){return vt(),s.jsx(Vc,{mode:"view"})}const Eb=["Withholding Tax","Estimated Tax","Income Tax"],$o=[{code:"VA",name:"Virginia"}],Tb=[{value:"Q1",label:"Q1"},{value:"Q2",label:"Q2"},{value:"Q3",label:"Q3"},{value:"Q4",label:"Q4"}];function Ib(){const e=new Date().getFullYear();return[e,e-1,e-2]}const ji="state-payment-draft";function Ca(e){sessionStorage.setItem(ji,JSON.stringify(e))}function Zc(){const e=sessionStorage.getItem(ji);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Oo(){sessionStorage.removeItem(ji)}function Bc(e,t){return`${e}-${t}`}function Fb(e,t){return{entityId:e,state:t.state,reasonForPayment:t.reasonForPayment,stateAccountId:t.stateAccountId,accountId:t.accountId,taxPeriod:Bc(t.taxYear,t.taxPeriod),taxAmount:Number.parseFloat(t.taxAmount),paymentDate:t.paymentDate,bankAccountDetailId:Number.parseInt(t.bankAccountDetailId,10)}}function Db(e){return{state:e.state,reasonForPayment:e.reasonForPayment,stateAccountId:e.stateAccountId,accountId:e.accountId,taxPeriod:Bc(e.taxYear,e.taxPeriod),taxAmount:Number.parseFloat(e.taxAmount),paymentDate:e.paymentDate,bankAccountDetailId:Number.parseInt(e.bankAccountDetailId,10)}}const Rb=pr({state:F().min(1,"State is required"),reasonForPayment:F().min(1,"Reason for payment is required"),stateAccountId:F().min(1,"State ID is required"),accountId:F().min(1,"Account ID is required"),letterId:F().optional(),taxYear:F().min(1,"Tax year is required"),taxPeriod:F().min(1,"Tax period is required"),taxAmount:F().min(1,"Tax amount is required").refine(e=>Number.parseFloat(e)>0,"Tax amount must be greater than 0"),paymentDate:F().min(1,"Payment date is required").refine(e=>e>=_s(),"Payment date must be a future date"),bankAccountDetailId:F().min(1,"Bank account is required"),routingNumber:F().optional(),accountType:F().optional(),bankName:F().optional()}),Us="grid gap-x-6 gap-y-5 sm:grid-cols-3",zo="grid gap-x-6 gap-y-5 sm:grid-cols-2",Lo="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",$b={state:"",reasonForPayment:"",stateAccountId:"",accountId:"",letterId:"",taxYear:"",taxPeriod:"",taxAmount:"",paymentDate:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:""};function Ob({entity:e}){var J,H,K,Z,U,ee,oe,ge;const t=Te(),r=we(),n=Zr(r.state,"/payments"),a=r.state,i=_.useMemo(()=>(a==null?void 0:a.paymentDraft)??Zc()??$b,[a==null?void 0:a.paymentDraft,r.key]),o=_.useMemo(()=>Ib(),[]),l=_s(),{data:c=[],isLoading:u}=Ee({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:()=>Cs(e.entityId),enabled:e!==null}),{register:d,control:h,handleSubmit:m,watch:f,setValue:y,formState:{errors:x}}=hr({resolver:fr(Rb),defaultValues:i}),w=f("state"),v=f("reasonForPayment"),j=f("taxAmount"),b=f("bankAccountDetailId"),k=!!(w&&v),[P,A]=_.useState(!1),L=(J=$o.find(q=>q.code===w))==null?void 0:J.name;_.useEffect(()=>{const q=c.find(ye=>String(ye.bankAccountDetailId)===b);q&&(y("routingNumber",q.routingNumber),y("accountType",q.accountType),y("bankName",q.bankName))},[c,b,y]);const O=m(q=>{const ye={state:q.state,reasonForPayment:q.reasonForPayment,stateAccountId:q.stateAccountId,accountId:q.accountId,letterId:q.letterId,taxYear:q.taxYear,taxPeriod:q.taxPeriod,taxAmount:q.taxAmount,paymentDate:q.paymentDate,bankAccountDetailId:q.bankAccountDetailId,routingNumber:q.routingNumber,accountType:q.accountType,bankName:q.bankName};Ca(ye),t("/payments/state/authorization",{state:{from:n,paymentDraft:ye}})}),V=e?Qt(e):"Entity";return s.jsx("form",{onSubmit:O,noValidate:!0,className:"w-full",children:s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-5 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:V}),s.jsx(Sn,{entity:e,remittanceAmount:wn(j),className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsx("div",{className:"lg:mr-[324px]",children:s.jsxs("div",{className:"mx-auto w-full max-w-[720px] space-y-5",children:[s.jsxs("section",{className:Lo,children:[s.jsx(Mo,{step:1,title:"Choose a State"}),s.jsxs("div",{className:"mt-5 space-y-5",children:[s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",onClick:()=>A(q=>!q),className:"flex w-full items-center justify-between rounded-xl border border-slate-200 bg-slate-50/80 px-4 py-4 text-left transition hover:border-gov-300 hover:bg-gov-50/40",children:[s.jsxs("span",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-gov-100 text-gov-600",children:s.jsx(zb,{})}),s.jsxs("span",{children:[s.jsx("span",{className:"block text-sm font-semibold text-slate-900",children:L??"Choose a state"}),s.jsx("span",{className:"block text-xs text-slate-500",children:"Tap to select the tax jurisdiction"})]})]}),s.jsx(Nr,{className:`h-4 w-4 text-slate-400 transition ${P?"rotate-180":""}`})]}),P?s.jsx("div",{className:"absolute left-0 right-0 z-20 mt-2 max-h-64 overflow-y-auto rounded-xl border border-slate-200 bg-white shadow-lg",children:$o.map(q=>s.jsxs("button",{type:"button",onClick:()=>{y("state",q.code,{shouldValidate:!0}),A(!1)},className:`flex w-full items-center justify-between px-4 py-3 text-left text-sm transition hover:bg-slate-50 ${w===q.code?"bg-gov-50 text-gov-700":"text-slate-700"}`,children:[s.jsx("span",{children:q.name}),s.jsx("span",{className:"text-xs font-medium text-slate-400",children:q.code})]},q.code))}):null,x.state?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:x.state.message}):null]}),s.jsx(Q,{label:"Reason for Payment",required:!0,error:(H=x.reasonForPayment)==null?void 0:H.message,children:s.jsxs(an,{children:[s.jsxs("select",{className:sn(!!x.reasonForPayment),...d("reasonForPayment"),children:[s.jsx("option",{value:"",children:"Select reason"}),Eb.map(q=>s.jsx("option",{value:q,children:q},q))]}),s.jsx(Nr,{})]})})]})]}),s.jsxs("section",{className:`${Lo} transition ${k?"":"opacity-60"}`,children:[s.jsx(Mo,{step:2,title:"Payment Form",className:"mb-5"}),s.jsxs("fieldset",{disabled:!k,className:"min-w-0 border-0 p-0",children:[s.jsx(Zs,{title:"Payment Details",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:Us,children:[s.jsx(Q,{label:"State ID",required:!0,error:(K=x.stateAccountId)==null?void 0:K.message,children:s.jsx("input",{placeholder:"Enter ID",className:Y(!!x.stateAccountId),...d("stateAccountId")})}),s.jsx(Q,{label:"Account ID",required:!0,error:(Z=x.accountId)==null?void 0:Z.message,children:s.jsx("input",{placeholder:"123456789-WHW",className:Y(!!x.accountId),...d("accountId")})}),s.jsx(Q,{label:"Letter ID",children:s.jsx("input",{placeholder:"123456789-WHW",className:Y(),...d("letterId")})})]}),s.jsxs("div",{className:zo,children:[s.jsx(Q,{label:"Tax Year",required:!0,error:(U=x.taxYear)==null?void 0:U.message,children:s.jsxs(an,{children:[s.jsxs("select",{className:sn(!!x.taxYear),...d("taxYear"),children:[s.jsx("option",{value:"",children:"Select TY"}),o.map(q=>s.jsxs("option",{value:String(q),children:["TY ",q]},q))]}),s.jsx(Nr,{})]})}),s.jsx(Q,{label:"Tax Period",required:!0,error:(ee=x.taxPeriod)==null?void 0:ee.message,children:s.jsxs(an,{children:[s.jsxs("select",{className:sn(!!x.taxPeriod),...d("taxPeriod"),children:[s.jsx("option",{value:"",children:"Select"}),Tb.map(q=>s.jsx("option",{value:q.value,children:q.label},q.value))]}),s.jsx(Nr,{})]})})]})]})}),s.jsx(Zs,{title:"Amount Info",children:s.jsxs("div",{className:zo,children:[s.jsx(Q,{label:"Tax Amount",required:!0,error:(oe=x.taxAmount)==null?void 0:oe.message,children:s.jsx("input",{type:"number",step:"0.01",min:"0",placeholder:"0.00",className:Y(!!x.taxAmount),...d("taxAmount")})}),s.jsx(Q,{label:"Payment Date",required:!0,error:(ge=x.paymentDate)==null?void 0:ge.message,children:s.jsx("input",{type:"date",min:l,className:Y(!!x.paymentDate),...d("paymentDate")})})]})}),s.jsx(Zs,{title:"Bank Account",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:Us,children:[s.jsx(Wn,{name:"bankAccountDetailId",control:h,render:({field:q})=>{var ye;return s.jsx(Dc,{value:q.value,onChange:q.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:c,isLoading:u,disabled:!e||!k,error:(ye=x.bankAccountDetailId)==null?void 0:ye.message,label:"Account Number"})}}),s.jsx(Q,{label:"Routing Number",required:!0,children:s.jsx("input",{readOnly:!0,placeholder:"9-digit",className:Y(!1,!0),...d("routingNumber")})}),s.jsx(Q,{label:"Account Type",required:!0,children:s.jsx("input",{readOnly:!0,placeholder:"Select",className:Y(!1,!0),...d("accountType")})})]}),s.jsx("div",{className:Us,children:s.jsx(Q,{label:"Bank Name",children:s.jsx("input",{readOnly:!0,placeholder:"e.g. Chase Bank",className:Y(!1,!0),...d("bankName")})})})]})})]}),k?null:s.jsx("p",{className:"mt-4 text-sm text-slate-500",children:"Select a state and reason for payment to continue."})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("button",{type:"button",onClick:()=>t(n),className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50",children:"Cancel"}),s.jsxs("button",{type:"submit",disabled:!e||!k,className:"inline-flex h-11 min-w-[120px] items-center justify-center gap-2 rounded-lg bg-gov-600 px-6 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:["Next",s.jsx(Lb,{})]})]})]})})]})},r.key)}function Mo({step:e,title:t,className:r=""}){return s.jsxs("div",{className:`flex items-center gap-3 ${r}`,children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gov-600 text-sm font-semibold text-white",children:e}),s.jsx("h3",{className:"text-sm font-bold uppercase tracking-wide text-slate-900",children:t})]})}function Zs({title:e,children:t}){return s.jsxs("div",{className:"mt-6 first:mt-0",children:[s.jsx("h4",{className:"mb-4 text-xs font-semibold uppercase tracking-wide text-slate-400",children:e}),t]})}function zb(){return s.jsxs("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 10.5a3 3 0 11-6 0 3 3 0 016 0z"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 10.5c0 7.142-7.5 11.25-7.5 11.25S4.5 17.642 4.5 10.5a7.5 7.5 0 1115 0z"})]})}function Lb(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3"})})}function Wc(){const{selectedEntity:e}=vt();return s.jsx(Ob,{entity:e})}const Mb="By proceeding, you authorize the payment to the selected tax authority and acknowledge that you are responsible for the accuracy of the information provided.",Vb="I have reviewed the details and authorize this payment.",qb=pr({agreementDate:F().min(1,"Date is required"),agreementAccepted:kr().refine(e=>e,{message:"You must accept the authorization agreement"}),authorizationPersonName:F().min(1,"Name of authorization person is required"),signature:F().min(1,"Signature is required"),title:F().min(1,"Title is required")}),Ub="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",Mn="rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 text-center";function Zb(e){const[t,r,n]=e.split("-");return!t||!r||!n?e:`${r}/${n}/${t}`}function Bb(e){return{agreementDate:new Date().toISOString().slice(0,10),agreementAccepted:!0,authorizationPersonName:e?Qt(e):"",signature:"",title:"Accountant"}}function Wb({entity:e,paymentDraft:t}){const r=Te(),n=we(),a=Tt(),i=Zr(n.state,"/payments"),[o,l]=_.useState(null),[c,u]=_.useState(!1),d=_.useMemo(()=>Bb(e),[e]),h=wn(t.taxAmount),{register:m,handleSubmit:f,watch:y,formState:{errors:x}}=hr({resolver:fr(qb),defaultValues:d}),w=y("agreementDate"),v=y("signature"),j=!!(v!=null&&v.trim()),b=async()=>{await a.invalidateQueries({queryKey:["dashboard"]}),await a.invalidateQueries({queryKey:["state-payments"]}),await a.invalidateQueries({queryKey:["remittance-payments"]})},k=async()=>{if(!e)return null;if(t.statePaymentDetailId){const O=await Ey(t.statePaymentDetailId,Db(t));return await b(),O}const L=await Py(Fb(e.entityId,t));return Ca({...t,statePaymentDetailId:L.statePaymentDetailId}),await b(),L},P=f(async()=>{if(e){l(null),u(!0);try{const L=await k();if(!L)return;await Sc(L.statePaymentDetailId),await b(),Oo(),r(i)}catch(L){l(bt(L,"Failed to submit state payment."))}finally{u(!1)}}}),A=f(async()=>{if(e){l(null),u(!0);try{await k(),Oo(),r(i)}catch(L){l(bt(L,"Failed to save draft."))}finally{u(!1)}}});return s.jsx("form",{onSubmit:P,noValidate:!0,className:"w-full",children:s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-5 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:"Payment Authorization"}),s.jsx(Sn,{entity:e,remittanceAmount:h,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsxs("div",{className:"lg:mr-[324px]",children:[s.jsxs("section",{className:Ub,children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-slate-200 pb-5",children:[s.jsx("h3",{className:"text-base font-semibold text-slate-900",children:"Authorization Agreement"}),s.jsxs("div",{className:`${Mn} min-w-[128px] py-2.5`,children:[s.jsx("p",{className:"text-[11px] font-medium text-slate-500",children:"Date"}),s.jsx("p",{className:"mt-0.5 text-sm font-semibold text-slate-800",children:Zb(w)}),s.jsx("input",{type:"hidden",...m("agreementDate")})]})]}),s.jsx("p",{className:"mt-5 text-sm leading-relaxed text-slate-600",children:Mb}),s.jsxs("label",{className:"mt-5 flex cursor-pointer items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-0.5 h-4 w-4 shrink-0 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...m("agreementAccepted")}),s.jsx("span",{className:"text-sm font-semibold leading-6 text-slate-800",children:Vb})]}),x.agreementAccepted?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:x.agreementAccepted.message}):null,s.jsxs("div",{className:"mt-8 border-t border-slate-100 pt-8",children:[s.jsxs("p",{className:"mb-4 text-sm font-medium text-gov-600",children:["Taxpayer's Signature",s.jsx("span",{className:"text-red-500",children:" *"})]}),s.jsxs("div",{className:"grid gap-5 md:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)_minmax(0,1fr)] md:items-end",children:[s.jsxs("div",{children:[s.jsxs("div",{className:`${Mn} py-7`,children:[s.jsx("input",{placeholder:"John Doe",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...m("authorizationPersonName")}),s.jsx("div",{className:"mx-auto mt-6 w-full max-w-[180px] border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Name of Authorization Person"})]}),x.authorizationPersonName?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:x.authorizationPersonName.message}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:`${Mn} py-5`,children:[s.jsx("input",{placeholder:"Sign here",autoComplete:"off",spellCheck:!1,className:`w-full border-0 bg-transparent text-center focus:outline-none ${j?"min-h-[52px] text-4xl leading-tight tracking-wide text-slate-800":"text-sm text-slate-400 placeholder:text-slate-400"}`,style:j?{fontFamily:"'Great Vibes', 'Segoe Script', cursive"}:void 0,...m("signature")}),s.jsx("div",{className:"mx-auto mt-6 w-full max-w-[220px] border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Signature of Tax Payer"})]}),x.signature?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:x.signature.message}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:`${Mn} py-7`,children:[s.jsx("input",{placeholder:"Accountant",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...m("title")}),s.jsx("div",{className:"mx-auto mt-6 w-full max-w-[140px] border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Title"})]}),x.title?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:x.title.message}):null]})]})]})]}),o?s.jsx("div",{className:"mt-5",children:s.jsx(Ur,{message:o})}):null,s.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[s.jsx("button",{type:"button",onClick:()=>{Ca(t),r("/payments/state/new",{state:{from:i,paymentDraft:t}})},disabled:c,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:A,disabled:c||!e,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-gov-300 bg-gov-50 px-6 text-sm font-semibold text-gov-600 transition hover:bg-gov-100 disabled:cursor-not-allowed disabled:opacity-50",children:"Save as Draft"}),s.jsx("button",{type:"submit",disabled:c||!e,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:"Submit Now"})]})]})]})})}function Hc(){const{selectedEntity:e}=vt(),t=we(),{paymentDraft:r}=t.state??{},n=r??Zc();return n?s.jsx(Wb,{entity:e,paymentDraft:n}):s.jsx(ut,{to:"/payments/state/new",replace:!0})}const wi="/portal/federal-payments/form-8655-authorizations";function Hb(e){return ue(wi,{method:"POST",body:e})}function Qb(e){return ue(`${wi}/by-enrolment/${e}`)}function Kb(e,t){return ue(`${wi}/${e}`,{method:"PATCH",body:t})}async function Qc(e){try{return await Qb(e)}catch(t){if(t instanceof bn&&t.status===404)return null;throw t}}const Vo=["720","940","941","943","944","945","990-PF","990-T","1041","1042","1120","CT-1","Other"],Yb="I understand that this agreement does not relieve me, as the taxpayer, of the responsibility to ensure that all tax returns are filed and that all deposits and payments are made and that I may enroll in the Electronic Federal Tax Payment System (EFTPS) to view deposits and payments made on my behalf.",Jb="I further understand that this agreement does not authorize the reporting agent to sign any tax returns, to otherwise act as a legal representative of the taxpayer, or to represent the taxpayer before the IRS. I also understand that the reporting agent is not responsible for any penalties or interest that may be assessed against the taxpayer. I authorize the reporting agent to complete Form 8655, Reporting Agent Authorization, and to make deposits and payments on my behalf for the tax return(s) indicated above. I also authorize the reporting agent to receive confidential information and to perform acts as specified on Form 2848, Power of Attorney and Declaration of Representative, or Form 8821, Tax Information Authorization, as applicable.";function _a({label:e,required:t=!1,signature:r,title:n,date:a,signatureValue:i,errors:o,signatureCaption:l="Signature of taxpayer"}){const c=!!(i!=null&&i.trim());return s.jsxs("div",{children:[e?s.jsxs("p",{className:"mb-3 text-sm font-medium text-gov-600",children:[e,t?s.jsx("span",{className:"text-red-500",children:" *"}):null]}):null,s.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1.4fr)_minmax(0,0.8fr)_minmax(0,0.8fr)] lg:items-end",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-6",children:[s.jsx("input",{placeholder:"Sign here",autoComplete:"off",spellCheck:!1,className:`w-full border-0 bg-transparent text-center focus:outline-none ${c?"text-4xl leading-tight tracking-wide text-slate-800":"text-sm text-slate-400 placeholder:text-slate-400"}`,style:c?{fontFamily:"'Great Vibes', 'Segoe Script', cursive"}:void 0,...r}),s.jsx("div",{className:"mt-8 border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:l})]}),o!=null&&o.signature?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:o.signature}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-8",children:[s.jsx("input",{placeholder:"Accountant",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...n}),s.jsx("div",{className:"mt-8 border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:"Title"})]}),o!=null&&o.title?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:o.title}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-8",children:[s.jsx("input",{type:"date",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 focus:outline-none",...a}),s.jsx("div",{className:"mt-8 border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:"Date"})]}),o!=null&&o.date?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:o.date}):null]})]})]})}function Gb(e){return e.replace(/\D/g,"")}function Kc(e,t){var r,n;return{enrollmentId:e,taxpayerName:t.taxpayerName.trim(),tradeName:t.tradeName.trim(),ein:Gb(t.ein),address:t.address.trim(),city:t.city.trim(),state:t.state.trim(),zipCode:t.zipCode.trim(),country:t.country.trim(),isSeasonalEmployer:t.isSeasonalEmployer,otherIdentificationNumber:((r=t.otherIdentificationNumber)==null?void 0:r.trim())||null,contactPerson:t.contactPerson.trim(),daytimePhone:t.daytimePhone.trim(),faxNumber:t.faxNumber.trim(),authorizedTaxForm:t.authorizedTaxForm,authorizationStartMonth:((n=t.authorizationMonth)==null?void 0:n.trim())||null,agreementAccepted:t.agreementAccepted,taxpayerSignature:t.signature.trim()||null,taxpayerTitle:t.title.trim(),signatureDate:t.signatureDate}}function Xb(e){const{enrollmentId:t,...r}=Kc(0,e);return r}function e0(e){return{taxpayerName:e.taxpayerName,tradeName:e.tradeName,ein:mi(e.ein),address:e.address,city:e.city,state:e.state,zipCode:e.zipCode,country:e.country,isSeasonalEmployer:e.isSeasonalEmployer,otherIdentificationNumber:e.otherIdentificationNumber??"",contactPerson:e.contactPerson,daytimePhone:Nn(e.daytimePhone),faxNumber:e.faxNumber,authorizedTaxForm:e.authorizedTaxForm,authorizationMonth:e.authorizationStartMonth??"",agreementAccepted:e.agreementAccepted,signature:e.taxpayerSignature??"",title:e.taxpayerTitle,signatureDate:e.signatureDate}}const t0=pr({taxpayerName:F().min(1,"Taxpayer name is required"),tradeName:F().min(1,"Trade name is required"),ein:F().min(1,"EIN is required"),address:F().min(1,"Address is required"),city:F().min(1,"City is required"),state:F().min(1,"State is required"),zipCode:F().min(1,"ZIP code is required"),country:F().min(1,"Country is required"),isSeasonalEmployer:kr(),otherIdentificationNumber:F().optional(),contactPerson:F().min(1,"Contact person is required"),daytimePhone:F().min(1,"Daytime telephone number is required"),faxNumber:F().min(1,"Fax number is required"),authorizedTaxForm:F().min(1,"Select a tax form"),authorizationMonth:F().optional(),agreementAccepted:kr().refine(e=>e,{message:"You must accept the authorization agreement"}),signature:F().min(1,"Signature is required"),title:F().min(1,"Title is required"),signatureDate:F().min(1,"Date is required")}),Bs="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function r0(e){const t=new Date().toISOString().slice(0,10);return{taxpayerName:e?Qt(e):"",tradeName:(e==null?void 0:e.tradeName)||(e==null?void 0:e.firstName)||"",ein:e?mi(e.idNumber):"",address:(e==null?void 0:e.address1)??"",city:(e==null?void 0:e.city)??"",state:(e==null?void 0:e.state)??"",zipCode:(e==null?void 0:e.zipCode)??"",country:(e==null?void 0:e.country)??"United States",isSeasonalEmployer:!1,otherIdentificationNumber:"",contactPerson:e?`${e.firstName} ${e.lastName}`.trim():"",daytimePhone:e?Nn(e.phoneNumber):"",faxNumber:"",authorizedTaxForm:"Other",authorizationMonth:"",agreementAccepted:!0,signature:"",title:"Accountant",signatureDate:t}}function n0({entity:e,paymentDraft:t,initialAuthorization:r=null,readonly:n=!1}){var Z,U,ee,oe,ge,q,ye,st,Be,Xe,qe,Ie,wt,at;const a=Te(),i=we(),o=Tt(),l=Zr(i.state,yt()),c=wn(t.paymentAmount),[u,d]=_.useState(null),[h,m]=_.useState(!1),f=_.useMemo(()=>r?e0(r):r0(e),[e,r]),{register:y,handleSubmit:x,watch:w,setValue:v,reset:j,formState:{errors:b}}=hr({resolver:fr(t0),defaultValues:f});_.useEffect(()=>{j(f)},[f,j]);const k=w("authorizedTaxForm"),P=w("signature"),A=e?Qt(e):"Entity",L=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},O=async()=>{if(!e)return null;if(t.federalPaymentId){const be=await di(t.federalPaymentId,gi(t));return await L(),be}const se=await ui(xi(e.entityId,t));return bi({...t,federalPaymentId:se.federalPaymentId,enrollmentId:se.enrollmentId}),await L(),se},V=async(se,be)=>{var ht;const dt=t.form8655AuthorizationId??((ht=await Qc(se))==null?void 0:ht.form8655AuthorizationId);return dt?Kb(dt,Xb(be)):Hb(Kc(se,be))},J=async se=>{if(!e)return;const be=await O();be&&(await V(be.enrollmentId,se),await o.invalidateQueries({queryKey:["form-8655",be.enrollmentId]}),vi(),a(yt()))},H=x(async se=>{if(!(!e||n)){d(null),m(!0);try{await J(se)}catch(be){d(bt(be,"Failed to save federal payment draft."))}finally{m(!1)}}}),K=x(async se=>{if(!(!e||n)){d(null),m(!0);try{await J(se)}catch(be){d(bt(be,"Failed to save draft."))}finally{m(!1)}}});return s.jsxs("form",{onSubmit:H,noValidate:!0,className:"w-full space-y-6",children:[s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:A}),s.jsx(Sn,{entity:e,remittanceAmount:c,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsx("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:s.jsxs("fieldset",{disabled:n,className:"min-w-0 border-0 p-0",children:[s.jsxs("section",{children:[s.jsxs("div",{className:Bs,children:[s.jsx(Q,{label:"1. a) Name of the Taxpayer",required:!0,error:(Z=b.taxpayerName)==null?void 0:Z.message,children:s.jsx("input",{placeholder:"Enter name",className:Y(!!b.taxpayerName),...y("taxpayerName")})}),s.jsx(Q,{label:"1. b) Trade Name, if any",required:!0,error:(U=b.tradeName)==null?void 0:U.message,children:s.jsx("input",{placeholder:"Enter name",className:Y(!!b.tradeName),...y("tradeName")})}),s.jsx(Q,{label:"2. Employer Identification Number (EIN)",required:!0,error:(ee=b.ein)==null?void 0:ee.message,children:s.jsx("input",{placeholder:"Enter number",className:Y(!!b.ein),...y("ein")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx("div",{className:"sm:col-span-2",children:s.jsx(Q,{label:"3. a) Address (Number, Street, and Room/Suite No)",required:!0,error:(oe=b.address)==null?void 0:oe.message,children:s.jsx("input",{placeholder:"Enter",className:Y(!!b.address),...y("address")})})}),s.jsx(Q,{label:"3. b) City or Town",required:!0,error:(ge=b.city)==null?void 0:ge.message,children:s.jsx("input",{placeholder:"Enter",className:Y(!!b.city),...y("city")})})]}),s.jsxs("div",{className:`mt-5 ${Bs}`,children:[s.jsx(Q,{label:"3. c) State",required:!0,error:(q=b.state)==null?void 0:q.message,children:s.jsx("input",{placeholder:"Enter name",className:Y(!!b.state),...y("state")})}),s.jsx(Q,{label:"3. d) ZIP Code",required:!0,error:(ye=b.zipCode)==null?void 0:ye.message,children:s.jsx("input",{placeholder:"Enter",className:Y(!!b.zipCode),...y("zipCode")})}),s.jsx(Q,{label:"3. e) Country",required:!0,error:(st=b.country)==null?void 0:st.message,children:s.jsx("input",{placeholder:"Enter",className:Y(!!b.country),...y("country")})})]}),s.jsxs("div",{className:`mt-5 ${Bs}`,children:[s.jsx("div",{className:"flex items-end pb-2",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...y("isSeasonalEmployer")}),s.jsx("span",{children:"4. If you are a Seasonal Employer"})]})}),s.jsx(Q,{label:"5. Other Identification Number (Optional)",children:s.jsx("input",{placeholder:"Enter name",className:Y(),...y("otherIdentificationNumber")})}),s.jsx(Q,{label:"6. Contact Person",required:!0,error:(Be=b.contactPerson)==null?void 0:Be.message,children:s.jsx("input",{placeholder:"Enter name",className:Y(!!b.contactPerson),...y("contactPerson")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2",children:[s.jsx(Q,{label:"7. Daytime Telephone Number",required:!0,error:(Xe=b.daytimePhone)==null?void 0:Xe.message,children:s.jsx("input",{placeholder:"Enter number",className:Y(!!b.daytimePhone),...y("daytimePhone")})}),s.jsx(Q,{label:"8. Fax Number",required:!0,error:(qe=b.faxNumber)==null?void 0:qe.message,children:s.jsx("input",{placeholder:"Enter number",className:Y(!!b.faxNumber),...y("faxNumber")})})]})]}),s.jsxs(dn,{title:"Authorization of Reporting Agent To Make and Deposits and Payments (Caution: See Authorization Agreement.)",children:[s.jsx("p",{className:"mb-5 text-sm leading-6 text-slate-600",children:"Indicate the tax return(s) for which the reporting agent is authorized to make deposits or payments. Use the 'YYYY/MM' format to enter the month in which the authorization begins (for example, '2024/8' for August 2024)"}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:Vo.slice(0,6).map(se=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:se,checked:k===se,onChange:()=>v("authorizedTaxForm",se,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200"}),se]},se))}),s.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:Vo.slice(6).map(se=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:se,checked:k===se,onChange:()=>v("authorizedTaxForm",se,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200"}),se]},se))})]}),b.authorizedTaxForm?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:b.authorizedTaxForm.message}):null]}),s.jsxs("section",{className:"mt-8 border-t border-slate-100 pt-8",children:[s.jsx("h3",{className:"mb-4 text-base font-semibold text-slate-900",children:"Authorization Agreement"}),s.jsxs("div",{className:"border-t border-slate-200 pt-5",children:[s.jsxs("label",{className:"flex items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...y("agreementAccepted")}),s.jsxs("span",{className:"text-sm leading-6 text-slate-700",children:[s.jsx("span",{className:"font-semibold text-slate-900",children:Yb})," ",Jb]})]}),b.agreementAccepted?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:b.agreementAccepted.message}):null]})]}),s.jsx("section",{className:"mt-8 border-t border-slate-100 pt-8",children:s.jsx(_a,{label:"Taxpayer's Signature",required:!0,signature:y("signature"),title:y("title"),date:y("signatureDate"),signatureValue:P,errors:{signature:(Ie=b.signature)==null?void 0:Ie.message,title:(wt=b.title)==null?void 0:wt.message,date:(at=b.signatureDate)==null?void 0:at.message}})})]})})]}),u?s.jsx("div",{className:"lg:mr-[324px]",children:s.jsx(Ur,{message:u})}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[s.jsx("button",{type:"button",onClick:()=>a(l),disabled:h,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:K,disabled:h||!e||n,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Save as Draft"}),s.jsx("button",{type:"submit",disabled:h||!e||n,className:"inline-flex h-11 min-w-[180px] items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:"Review and Submit"})]})]})}function Yc(){const{selectedEntity:e}=vt(),t=we(),{paymentDraft:r}=t.state??{},n=r??Ps(),{data:a,isLoading:i}=Ee({queryKey:["federal-payment",n==null?void 0:n.federalPaymentId],queryFn:()=>ci(n.federalPaymentId),enabled:(n==null?void 0:n.federalPaymentId)!=null&&n.enrollmentId==null}),o=(n==null?void 0:n.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=Ee({queryKey:["form-8655",o],queryFn:()=>Qc(o),enabled:o!=null}),u=_.useMemo(()=>n?{...n,enrollmentId:o??n.enrollmentId,form8655AuthorizationId:n.form8655AuthorizationId??(l==null?void 0:l.form8655AuthorizationId)}:null,[n,o,l]);return n?pi(e)?s.jsx(ut,{to:"/payments/federal/individual-enrollment",replace:!0,state:t.state}):n.federalPaymentId!=null&&n.enrollmentId==null&&i||o!=null&&c?s.jsx("p",{className:"text-sm text-slate-600",children:"Loading authorization form…"}):s.jsx(n0,{entity:e,paymentDraft:u??n,initialAuthorization:l}):s.jsx(ut,{to:"/payments/federal/new",replace:!0})}const Ni="/portal/federal-payments/form-9783-enrollments";function s0(e){return ue(Ni,{method:"POST",body:e})}function a0(e){return ue(`${Ni}/by-enrolment/${e}`)}function i0(e,t){return ue(`${Ni}/${e}`,{method:"PATCH",body:t})}async function Jc(e){try{return await a0(e)}catch(t){if(t instanceof bn&&t.status===404)return null;throw t}}const o0="I hereby authorize the contact person listed in item 5 on this form, and the financial institution(s) listed in items 9-11 on this form, to process EFTPS payments and to receive confidential information for enrollment purposes, to answer inquiries regarding my account, and to resolve any issues that may arise. This authorization includes passwords, payment instructions, taxpayer names, and identifying numbers.",l0="By completing the financial institution information in items 9-11 on this form, I authorize the designated Financial Agents of the U.S. Treasury to initiate EFTPS debit entries to my financial institution account for federal tax payments. All debits will be made in accordance with U.S. Treasury regulations. This authorization remains in effect until written notification of termination is received and the Financial Agent has had a reasonable opportunity to act on it.",c0="Under penalties of perjury, I certify that I have the authority to sign this authorization on behalf of the taxpayer. If I am a corporate officer, partner, guardian, executor, receiver, administrator, trustee, or other party, I certify that I have the authority to execute this authorization on behalf of the taxpayer. If I am a tax practitioner, I certify that Form 2848 or Form 8655 is on file with the IRS.";function Vn(e){return e.replace(/\D/g,"")}function Gc(e,t){var r,n,a;return{enrollmentId:e,primarySsn:Vn(t.primarySsn),jointFilerSsn:t.jointFilerSsn?Vn(t.jointFilerSsn):null,taxpayerNames:t.taxpayerNames.trim(),primaryAddress:t.primaryAddress.trim(),city:t.city.trim(),state:t.state.trim(),zipCode:t.zipCode.trim(),country:t.country.trim(),internationalAddress:((r=t.internationalAddress)==null?void 0:r.trim())||null,primaryPhone:t.primaryPhone.trim(),primaryContactName:t.primaryContactName.trim(),primaryContactAddress:t.primaryContactAddress.trim(),contactCity:t.contactCity.trim(),financialPrimarySsn:Vn(t.financialPrimarySsn),routingTransitNumber:Vn(t.routingTransitNumber),accountNumber:t.accountNumber.trim(),accountType:t.accountType,disclosureAgreementOne:t.disclosureAgreementOne,disclosureAgreementTwo:t.disclosureAgreementTwo,authorityAgreement:t.authorityAgreement,taxpayerSignature:t.taxpayerSignature.trim()||null,taxpayerTitle:t.taxpayerTitle.trim(),taxpayerSignatureDate:t.taxpayerSignatureDate,jointFilerSignature:((n=t.jointFilerSignature)==null?void 0:n.trim())||null,jointFilerTitle:((a=t.jointFilerTitle)==null?void 0:a.trim())||null,jointFilerSignatureDate:t.jointFilerSignatureDate||null,primaryTaxpayerPin:null,dateOfBirth:null,priorYearAgi:null,agiTaxYear:null}}function u0(e){const{enrollmentId:t,...r}=Gc(0,e);return r}function d0(e){var r;const t=((r=e.accountType)==null?void 0:r.toLowerCase())==="savings"?"Savings":"Checking";return{primarySsn:e.primarySsn,jointFilerSsn:e.jointFilerSsn??"",taxpayerNames:e.taxpayerNames,primaryAddress:e.primaryAddress,city:e.city,state:e.state,zipCode:e.zipCode,country:e.country,internationalAddress:e.internationalAddress??"",primaryPhone:Nn(e.primaryPhone),primaryContactName:e.primaryContactName,primaryContactAddress:e.primaryContactAddress,contactCity:e.contactCity,financialPrimarySsn:e.financialPrimarySsn,routingTransitNumber:e.routingTransitNumber,accountNumber:e.accountNumber,accountType:t,disclosureAgreementOne:e.disclosureAgreementOne,disclosureAgreementTwo:e.disclosureAgreementTwo,authorityAgreement:e.authorityAgreement,taxpayerSignature:e.taxpayerSignature??"",taxpayerTitle:e.taxpayerTitle,taxpayerSignatureDate:e.taxpayerSignatureDate,jointFilerSignature:e.jointFilerSignature??"",jointFilerTitle:e.jointFilerTitle??"",jointFilerSignatureDate:e.jointFilerSignatureDate??""}}const h0=pr({primarySsn:F().min(1,"Primary SSN is required"),jointFilerSsn:F().optional(),taxpayerNames:F().min(1,"Taxpayer name is required"),primaryAddress:F().min(1,"Primary address is required"),city:F().min(1,"City is required"),state:F().min(1,"State is required"),zipCode:F().min(1,"ZIP code is required"),country:F().min(1,"Country is required"),internationalAddress:F().optional(),primaryPhone:F().min(1,"Primary phone number is required"),primaryContactName:F().min(1,"Primary contact name is required"),primaryContactAddress:F().min(1,"Primary contact address is required"),contactCity:F().min(1,"Contact city is required"),financialPrimarySsn:F().min(1,"Primary SSN is required"),routingTransitNumber:F().min(1,"Routing transit number is required"),accountNumber:F().min(1,"Account number is required"),accountType:Ss(["Checking","Savings"]),disclosureAgreementOne:kr().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),disclosureAgreementTwo:kr().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),authorityAgreement:kr().refine(e=>e,{message:"You must accept the authority agreement"}),taxpayerSignature:F().min(1,"Signature is required"),taxpayerTitle:F().min(1,"Title is required"),taxpayerSignatureDate:F().min(1,"Date is required"),jointFilerSignature:F().optional(),jointFilerTitle:F().optional(),jointFilerSignatureDate:F().optional()}),qn="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function m0(e,t){var i;const r=new Date().toISOString().slice(0,10),n=e?Qt(e):"",a=((i=t.accountType)==null?void 0:i.toLowerCase())==="savings"?"Savings":"Checking";return{primarySsn:(e==null?void 0:e.idNumber)??"",jointFilerSsn:"",taxpayerNames:n,primaryAddress:(e==null?void 0:e.address1)??"",city:(e==null?void 0:e.city)??"",state:(e==null?void 0:e.state)??"",zipCode:(e==null?void 0:e.zipCode)??"",country:(e==null?void 0:e.country)??"United States",internationalAddress:"",primaryPhone:e?Nn(e.phoneNumber):"",primaryContactName:e?`${e.firstName} ${e.lastName}`.trim():"",primaryContactAddress:(e==null?void 0:e.address1)??"",contactCity:(e==null?void 0:e.city)??"",financialPrimarySsn:(e==null?void 0:e.idNumber)??"",routingTransitNumber:t.routingNumber??"",accountNumber:"",accountType:a,disclosureAgreementOne:!0,disclosureAgreementTwo:!0,authorityAgreement:!0,taxpayerSignature:"",taxpayerTitle:"Accountant",taxpayerSignatureDate:r,jointFilerSignature:"",jointFilerTitle:"",jointFilerSignatureDate:r}}function f0({entity:e,paymentDraft:t,initialEnrollment:r=null,readonly:n=!1}){var U,ee,oe,ge,q,ye,st,Be,Xe,qe,Ie,wt,at,se,be,dt,ht;const a=Te(),i=we(),o=Tt(),l=Zr(i.state,yt()),c=wn(t.paymentAmount),[u,d]=_.useState(null),[h,m]=_.useState(!1),f=_.useMemo(()=>r?d0(r):m0(e,t),[e,r,t]),{register:y,handleSubmit:x,watch:w,setValue:v,reset:j,formState:{errors:b}}=hr({resolver:fr(h0),defaultValues:f});_.useEffect(()=>{j(f)},[f,j]);const k=w("taxpayerSignature"),P=w("jointFilerSignature"),A=w("accountType"),L=e?Qt(e):"Entity",O=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},V=async()=>{if(!e)return null;if(t.federalPaymentId){const Ce=await di(t.federalPaymentId,gi(t));return await O(),Ce}const me=await ui(xi(e.entityId,t));return bi({...t,federalPaymentId:me.federalPaymentId,enrollmentId:me.enrollmentId}),await O(),me},J=async(me,Ce)=>{var It;const xr=t.form9783EnrollmentId??((It=await Jc(me))==null?void 0:It.form9783EnrollmentId);return xr?i0(xr,u0(Ce)):s0(Gc(me,Ce))},H=async me=>{if(!e)return;const Ce=await V();Ce&&(await J(Ce.enrollmentId,me),await o.invalidateQueries({queryKey:["form-9783",Ce.enrollmentId]}),vi(),a(yt()))},K=x(async me=>{if(!(!e||n)){d(null),m(!0);try{await H(me)}catch(Ce){d(bt(Ce,"Failed to save federal payment draft."))}finally{m(!1)}}}),Z=x(async me=>{if(!(!e||n)){d(null),m(!0);try{await H(me)}catch(Ce){d(bt(Ce,"Failed to save draft."))}finally{m(!1)}}});return s.jsxs("form",{onSubmit:K,noValidate:!0,className:"w-full space-y-6",children:[s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:L}),s.jsx(Sn,{entity:e,remittanceAmount:c,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsx("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:s.jsxs("fieldset",{disabled:n,className:"min-w-0 border-0 p-0",children:[s.jsxs("section",{children:[s.jsxs("div",{className:qn,children:[s.jsx(Q,{label:"1. a) Primary SSN",required:!0,error:(U=b.primarySsn)==null?void 0:U.message,children:s.jsx("input",{placeholder:"Enter number",className:Y(!!b.primarySsn),...y("primarySsn")})}),s.jsx(Q,{label:"1. b) Joint Filer's Taxpayer ID No (SSN)",children:s.jsx("input",{placeholder:"Enter number",className:Y(),...y("jointFilerSsn")})}),s.jsx(Q,{label:"2. Taxpayer(s) Name(s)",required:!0,error:(ee=b.taxpayerNames)==null?void 0:ee.message,children:s.jsx("input",{placeholder:"Enter name",className:Y(!!b.taxpayerNames),...y("taxpayerNames")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx("div",{className:"sm:col-span-2",children:s.jsx(Q,{label:"3. a) Primary Address (Number, Street, and Room/Suite No)",required:!0,error:(oe=b.primaryAddress)==null?void 0:oe.message,children:s.jsx("input",{placeholder:"Enter",className:Y(!!b.primaryAddress),...y("primaryAddress")})})}),s.jsx(Q,{label:"3. b) City or Town",required:!0,error:(ge=b.city)==null?void 0:ge.message,children:s.jsx("input",{placeholder:"Enter",className:Y(!!b.city),...y("city")})})]}),s.jsxs("div",{className:`mt-5 ${qn}`,children:[s.jsx(Q,{label:"3. c) State",required:!0,error:(q=b.state)==null?void 0:q.message,children:s.jsx("input",{placeholder:"Enter name",className:Y(!!b.state),...y("state")})}),s.jsx(Q,{label:"3. d) ZIP Code",required:!0,error:(ye=b.zipCode)==null?void 0:ye.message,children:s.jsx("input",{placeholder:"Enter",className:Y(!!b.zipCode),...y("zipCode")})}),s.jsx(Q,{label:"3. e) Country",required:!0,error:(st=b.country)==null?void 0:st.message,children:s.jsx("input",{placeholder:"Enter",className:Y(!!b.country),...y("country")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2",children:[s.jsx(Q,{label:"3. International Address",children:s.jsx("input",{placeholder:"Enter",className:Y(),...y("internationalAddress")})}),s.jsx(Q,{label:"4. Primary Taxpayer Phone Number",required:!0,error:(Be=b.primaryPhone)==null?void 0:Be.message,children:s.jsx("input",{placeholder:"Enter number",className:Y(!!b.primaryPhone),...y("primaryPhone")})})]})]}),s.jsx(dn,{title:"2. Contact Information",children:s.jsxs("div",{className:qn,children:[s.jsx(Q,{label:"5. Primary Contact Name",required:!0,error:(Xe=b.primaryContactName)==null?void 0:Xe.message,children:s.jsx("input",{placeholder:"Enter name",className:Y(!!b.primaryContactName),...y("primaryContactName")})}),s.jsx("div",{className:"sm:col-span-2",children:s.jsx(Q,{label:"6. a) Primary Contact Address",required:!0,error:(qe=b.primaryContactAddress)==null?void 0:qe.message,children:s.jsx("input",{placeholder:"Enter",className:Y(!!b.primaryContactAddress),...y("primaryContactAddress")})})}),s.jsx(Q,{label:"6. b) City or Town",required:!0,error:(Ie=b.contactCity)==null?void 0:Ie.message,children:s.jsx("input",{placeholder:"Enter",className:Y(!!b.contactCity),...y("contactCity")})})]})}),s.jsxs(dn,{title:"3. Social Security Number and Financial Institution Information",children:[s.jsxs("div",{className:qn,children:[s.jsx(Q,{label:"9. Primary SSN",required:!0,error:(wt=b.financialPrimarySsn)==null?void 0:wt.message,children:s.jsx("input",{placeholder:"Enter number",className:Y(!!b.financialPrimarySsn),...y("financialPrimarySsn")})}),s.jsx(Q,{label:"10. Routing Transit Number (RTN)",required:!0,error:(at=b.routingTransitNumber)==null?void 0:at.message,children:s.jsx("input",{placeholder:"Enter number",className:Y(!!b.routingTransitNumber),...y("routingTransitNumber")})}),s.jsx(Q,{label:"11. Account Number",required:!0,error:(se=b.accountNumber)==null?void 0:se.message,children:s.jsx("input",{placeholder:"Enter",className:Y(!!b.accountNumber),...y("accountNumber")})})]}),s.jsxs("div",{className:"mt-5",children:[s.jsx("p",{className:"mb-3 text-sm text-slate-600",children:"12. Type of Account"}),s.jsx("div",{className:"flex flex-wrap gap-6",children:["Checking","Savings"].map(me=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:me,checked:A===me,onChange:()=>v("accountType",me,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200"}),me]},me))})]})]}),s.jsxs("section",{className:"mt-8 border-t border-slate-100 pt-8",children:[s.jsx("h3",{className:"mb-4 text-base font-semibold text-slate-900",children:"Authorization Agreement"}),s.jsx("p",{className:"mb-5 text-sm text-slate-600",children:"Read the following authorization agreements"}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Disclosure Authorization Agreement"}),s.jsxs("label",{className:"flex items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...y("disclosureAgreementOne")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:o0})]}),b.disclosureAgreementOne?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:b.disclosureAgreementOne.message}):null]}),s.jsxs("div",{children:[s.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Disclosure Authorization Agreement"}),s.jsxs("label",{className:"flex items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...y("disclosureAgreementTwo")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:l0})]}),b.disclosureAgreementTwo?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:b.disclosureAgreementTwo.message}):null]}),s.jsxs("div",{className:"border-t border-slate-200 pt-6",children:[s.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Authority to Execute an Authorization"}),s.jsxs("label",{className:"flex items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...y("authorityAgreement")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:c0})]}),b.authorityAgreement?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:b.authorityAgreement.message}):null]})]})]}),s.jsxs("section",{className:"mt-8 space-y-8 border-t border-slate-100 pt-8",children:[s.jsx(_a,{label:"Taxpayer's Signature",required:!0,signature:y("taxpayerSignature"),title:y("taxpayerTitle"),date:y("taxpayerSignatureDate"),signatureValue:k,errors:{signature:(be=b.taxpayerSignature)==null?void 0:be.message,title:(dt=b.taxpayerTitle)==null?void 0:dt.message,date:(ht=b.taxpayerSignatureDate)==null?void 0:ht.message}}),s.jsx(_a,{label:"Joint filer(s) Signature (Optional)",signature:y("jointFilerSignature"),title:y("jointFilerTitle"),date:y("jointFilerSignatureDate"),signatureValue:P??"",signatureCaption:"Signature of joint filer"})]})]})})]}),u?s.jsx("div",{className:"lg:mr-[324px]",children:s.jsx(Ur,{message:u})}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[s.jsx("button",{type:"button",onClick:()=>a(l),disabled:h,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:Z,disabled:h||!e||n,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Save as Draft"}),s.jsx("button",{type:"submit",disabled:h||!e||n,className:"inline-flex h-11 min-w-[180px] items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:"Review and Submit"})]})]})}function Xc(){const{selectedEntity:e}=vt(),t=we(),{paymentDraft:r}=t.state??{},n=r??Ps(),{data:a,isLoading:i}=Ee({queryKey:["federal-payment",n==null?void 0:n.federalPaymentId],queryFn:()=>ci(n.federalPaymentId),enabled:(n==null?void 0:n.federalPaymentId)!=null&&n.enrollmentId==null}),o=(n==null?void 0:n.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=Ee({queryKey:["form-9783",o],queryFn:()=>Jc(o),enabled:o!=null}),u=_.useMemo(()=>n?{...n,enrollmentId:o??n.enrollmentId,form9783EnrollmentId:n.form9783EnrollmentId??(l==null?void 0:l.form9783EnrollmentId)}:null,[n,o,l]);return n?e&&!pi(e)?s.jsx(ut,{to:"/payments/federal/authorization",replace:!0,state:t.state}):n.federalPaymentId!=null&&n.enrollmentId==null&&i||o!=null&&c?s.jsx("p",{className:"text-sm text-slate-600",children:"Loading enrollment form…"}):s.jsx(f0,{entity:e,paymentDraft:u??n,initialEnrollment:l}):s.jsx(ut,{to:"/payments/federal/new",replace:!0})}function p0(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function x0({type:e}){return s.jsx("span",{className:"inline-flex rounded-full bg-gov-50 px-2.5 py-0.5 text-xs font-medium text-gov-700",children:e})}function g0({status:e}){const t=e.toLowerCase();let r="bg-slate-100 text-slate-600";return t.includes("submitted to state")||t.includes("submitted to fed")?r="bg-orange-50 text-orange-700":t.includes("irs accepted")?r="bg-emerald-50 text-emerald-700":t.includes("irs rejected")?r="bg-red-50 text-red-600":t.includes("pending")&&(r="bg-amber-50 text-amber-700"),s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${r}`,children:e})}function y0({forms:e=[],isLoading:t=!1,isError:r=!1}){return s.jsx("div",{className:"overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[960px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-6 py-3",children:"File Name"}),s.jsx("th",{className:"px-6 py-3",children:"Type"}),s.jsx("th",{className:"px-6 py-3",children:"Client"}),s.jsx("th",{className:"px-6 py-3",children:"Status"}),s.jsx("th",{className:"px-6 py-3",children:"Date"}),s.jsx("th",{className:"px-6 py-3",children:"Action"})]})}),s.jsx("tbody",{children:t?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"Loading tax forms…"})}):r?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"Unable to load tax forms."})}):e.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"No tax forms to display yet."})}):e.map(n=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-6 py-4",children:s.jsxs("div",{className:"flex items-center gap-3 font-medium text-slate-900",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gov-50 text-gov-600",children:s.jsx(b0,{className:"h-4 w-4"})}),n.fileName]})}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(x0,{type:n.type})}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:n.client}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(g0,{status:n.status})}),s.jsx("td",{className:"px-6 py-4 text-slate-600",children:p0(n.date)}),s.jsx("td",{className:"px-6 py-4",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("button",{type:"button",className:"rounded-full border border-gov-200 bg-gov-50 px-4 py-1.5 text-xs font-semibold text-gov-600 transition hover:bg-gov-100",children:"View PDF"}),n.canSubmit?s.jsx("button",{type:"button",className:"rounded-full bg-gov-600 px-4 py-1.5 text-xs font-semibold text-white transition hover:bg-gov-700",children:"Submit"}):null]})})]},n.taxFormId))})]})})})}function b0({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 12.75V6A2.25 2.25 0 014.5 3.75h4.379a2.25 2.25 0 011.59.659l1.122 1.122A2.25 2.25 0 0013.128 6H19.5a2.25 2.25 0 012.25 2.25v10.5A2.25 2.25 0 0119.5 21H4.5a2.25 2.25 0 01-2.25-2.25v-6.75z"})})}function v0(){return s.jsx(y0,{})}const kn=[{id:"bank-accounts",title:"Bank Accounts",subtitle:"Connected bank accounts",icon:j0},{id:"tax-accounts",title:"Tax Accounts",subtitle:"IRS & state tax accounts",icon:w0},{id:"payment-history",title:"Payment History",subtitle:"Past payment transactions",icon:N0},{id:"entity-details",title:"Entity Details",subtitle:"Your account details",icon:S0}];function j0({className:e,...t}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 8.25h19.5M2.25 9h19.5m-16.5 5.25h6m-6 2.25h3m-3.75 3h15a2.25 2.25 0 002.25-2.25V6.75A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25v10.5A2.25 2.25 0 004.5 19.5z"})})}function w0({className:e,...t}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 21h19.5m-18-18v18m10.5-18v18m6-13.5V21M6.75 6.75h.75m-.75 3h.75m-.75 3h.75m3-6h.75m-.75 3h.75m-.75 3h.75M6.75 21v-3.375c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21M3 21h18M12 3l9 4.5v1.5H3V7.5L12 3z"})})}function N0({className:e,...t}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}function S0({className:e,...t}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z"})})}function Es({title:e,subtitle:t,icon:r,action:n}){return s.jsxs("div",{className:"mb-6 flex flex-wrap items-start justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"flex h-11 w-11 items-center justify-center rounded-xl bg-gov-50 text-gov-600",children:s.jsx(r,{className:"h-5 w-5"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-bold text-slate-900",children:e}),s.jsx("p",{className:"text-sm text-slate-500",children:t})]})]}),n]})}function k0(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function C0({status:e}){const r=(e??"Active").toLowerCase()==="active";return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${r?"bg-emerald-50 text-emerald-700":"bg-red-50 text-red-600"}`,children:r?"Active":"In-active"})}function _0({entityId:e}){const[t,r]=_.useState(!1),n=kn.find(c=>c.id==="bank-accounts"),a=n.icon,{data:i=[],isLoading:o,isError:l}=Ee({queryKey:["bank-accounts",e],queryFn:()=>Cs(e),enabled:e!==null});return s.jsxs("div",{children:[s.jsx(Es,{title:n.title,subtitle:n.subtitle,icon:a,action:s.jsxs("button",{type:"button",disabled:!e,onClick:()=>r(!0),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx(A0,{}),"Add Bank Account"]})}),s.jsx(Pc,{open:t,entityId:e,onClose:()=>r(!1)}),s.jsx("div",{className:"overflow-hidden rounded-xl border border-slate-200",children:s.jsxs("table",{className:"w-full min-w-[700px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-5 py-3",children:"Bank"}),s.jsx("th",{className:"px-5 py-3",children:"Account"}),s.jsx("th",{className:"px-5 py-3",children:"Routing"}),s.jsx("th",{className:"px-5 py-3",children:"Type"}),s.jsx("th",{className:"px-5 py-3",children:"Status"}),s.jsx("th",{className:"px-5 py-3"})]})}),s.jsx("tbody",{children:o?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading bank accounts…"})}):l?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load bank accounts."})}):e?i.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"No bank accounts connected yet."})}):i.map(c=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-5 py-4 font-medium text-slate-900",children:c.bankName}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:k0(c.accountNumber)}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:c.routingNumber}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:c.accountType}),s.jsx("td",{className:"px-5 py-4",children:s.jsx(C0,{status:c.status})}),s.jsx("td",{className:"px-5 py-4 text-right",children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-lg bg-gov-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-gov-700",children:["Actions",s.jsx(P0,{})]})})]},c.bankAccountDetailId)):s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to manage bank accounts."})})})]})})]})}function A0(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function P0(){return s.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})}function E0({activeSection:e,onSectionChange:t,items:r}){return s.jsx("nav",{className:"space-y-2",children:r.map(n=>{const a=e===n.id,i=n.icon;return s.jsxs("button",{type:"button",onClick:()=>t(n.id),className:`flex w-full items-center gap-3 rounded-xl border px-4 py-3.5 text-left transition ${a?"border-gov-200 bg-gov-50 shadow-sm":"border-slate-200 bg-white hover:border-slate-300 hover:bg-slate-50"}`,children:[s.jsx("span",{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg ${a?"bg-gov-600 text-white":"bg-slate-100 text-slate-500"}`,children:s.jsx(i,{className:"h-5 w-5"})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:`block text-sm font-semibold ${a?"text-slate-900":"text-slate-700"}`,children:n.title}),s.jsx("span",{className:"block truncate text-xs text-slate-500",children:n.subtitle})]}),s.jsx(T0,{className:`h-4 w-4 shrink-0 ${a?"text-gov-600":"text-slate-300"}`})]},n.id)})})}function T0({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})}function I0({sectionId:e}){const t=kn.find(n=>n.id===e),r=t.icon;return s.jsxs("div",{children:[s.jsx(Es,{title:t.title,subtitle:t.subtitle,icon:r}),s.jsx("div",{className:"rounded-xl border border-dashed border-slate-200 bg-slate-50/50 px-6 py-16 text-center",children:s.jsxs("p",{className:"text-sm text-slate-500",children:[t.title," will be available soon."]})})]})}function F0(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(e)}function D0(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function R0({type:e}){const t={Federal:"bg-gov-50 text-gov-700",State:"bg-sky-50 text-sky-700",Local:"bg-indigo-50 text-indigo-700"};return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${t[e]}`,children:e})}function $0({entityId:e,transactions:t=[],isLoading:r=!1,isError:n=!1}){const a=kn.find(l=>l.id==="payment-history"),i=a.icon,o=e!==null&&t.length>0;return s.jsxs("div",{children:[s.jsx(Es,{title:a.title,subtitle:a.subtitle,icon:i,action:s.jsxs("button",{type:"button",disabled:!o,className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx(O0,{}),"Export to Excel"]})}),s.jsx("div",{className:"overflow-hidden rounded-xl border border-slate-200",children:s.jsxs("table",{className:"w-full min-w-[900px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-5 py-3",children:"Date"}),s.jsx("th",{className:"px-5 py-3",children:"Amount"}),s.jsx("th",{className:"px-5 py-3",children:"Jurisdiction / Type"}),s.jsx("th",{className:"px-5 py-3",children:"Type"}),s.jsx("th",{className:"px-5 py-3",children:"Account Name"}),s.jsx("th",{className:"px-5 py-3",children:"Reference"})]})}),s.jsx("tbody",{children:r?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading payment history…"})}):n?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load payment history."})}):e?t.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"No payment transactions to display yet."})}):t.map(l=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-5 py-4 text-slate-600",children:D0(l.date)}),s.jsx("td",{className:"px-5 py-4 font-semibold text-slate-900",children:F0(l.amount)}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.jurisdiction}),s.jsx("td",{className:"px-5 py-4",children:s.jsx(R0,{type:l.type})}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.accountName}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.reference})]},l.paymentHistoryId)):s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to view payment history."})})})]})})]})}function O0(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3"})})}function z0({count:e}){const t=e===1?"1 Payment":`${e} Payments`;return s.jsx("span",{className:"inline-flex rounded-full bg-gov-50 px-2.5 py-0.5 text-xs font-medium text-gov-700",children:t})}function L0({status:e}){const r=(e??"Active").toLowerCase()==="active";return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${r?"bg-emerald-50 text-emerald-700":"bg-red-50 text-red-600"}`,children:r?"Active":"In-active"})}function M0(e){return e.length===0?"—":e.length<=3?e.join(", "):`${e.slice(0,3).join(", ")}...`}function V0({entityId:e,accounts:t=[],isLoading:r=!1,isError:n=!1}){const a=kn.find(o=>o.id==="tax-accounts"),i=a.icon;return s.jsxs("div",{children:[s.jsx(Es,{title:a.title,subtitle:a.subtitle,icon:i,action:s.jsxs("button",{type:"button",disabled:!e,className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx(q0,{}),"Add Tax Account"]})}),s.jsx("div",{className:"overflow-hidden rounded-xl border border-slate-200",children:s.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-5 py-3",children:"Account Name"}),s.jsx("th",{className:"px-5 py-3",children:"Federal/State ID"}),s.jsx("th",{className:"px-5 py-3",children:"Payments"}),s.jsx("th",{className:"px-5 py-3",children:"Form Type"}),s.jsx("th",{className:"px-5 py-3",children:"Status"})]})}),s.jsx("tbody",{children:r?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Loading tax accounts…"})}):n?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load tax accounts."})}):e?t.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"No tax accounts connected yet."})}):t.map(o=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-5 py-4 font-medium text-slate-900",children:o.accountName}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:o.federalStateId}),s.jsx("td",{className:"px-5 py-4",children:s.jsx(z0,{count:o.paymentCount})}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:M0(o.formTypes)}),s.jsx("td",{className:"px-5 py-4",children:s.jsx(L0,{status:o.status})})]},o.taxAccountId)):s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to manage tax accounts."})})})]})})]})}function q0(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}const qo="rounded-2xl border border-slate-200 bg-white shadow-sm";function Si(){const{selectedEntity:e}=vt(),[t,r]=_.useState("bank-accounts");return s.jsxs("div",{className:"grid gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[s.jsx("div",{className:`${qo} p-3`,children:s.jsx(E0,{items:kn,activeSection:t,onSectionChange:r})}),s.jsx("div",{className:`${qo} p-6 lg:p-8`,children:t==="bank-accounts"?s.jsx(_0,{entityId:(e==null?void 0:e.entityId)??null}):t==="tax-accounts"?s.jsx(V0,{entityId:(e==null?void 0:e.entityId)??null}):t==="payment-history"?s.jsx($0,{entityId:(e==null?void 0:e.entityId)??null}):s.jsx(I0,{sectionId:t})})]})}function U0({paymentsMode:e="all"}){return s.jsxs(Fa,{children:[s.jsx(re,{index:!0,element:s.jsx(Ua,{})}),s.jsx(re,{path:"create-entity",element:s.jsx(Ba,{})}),s.jsx(re,{path:"create-entity/form",element:s.jsx(ii,{})}),s.jsxs(re,{element:s.jsx(Za,{}),children:[s.jsx(re,{path:"dashboard",element:s.jsx(li,{})}),s.jsx(re,{path:"payments",element:s.jsx(hi,{paymentsMode:e})}),s.jsx(re,{path:"payments/federal/new",element:s.jsx(Mc,{})}),s.jsx(re,{path:"payments/federal/:federalPaymentId/edit",element:s.jsx(qc,{})}),s.jsx(re,{path:"payments/federal/:federalPaymentId/view",element:s.jsx(Uc,{})}),s.jsx(re,{path:"payments/state/new",element:s.jsx(Wc,{})}),s.jsx(re,{path:"payments/state/authorization",element:s.jsx(Hc,{})}),s.jsx(re,{path:"payments/federal/authorization",element:s.jsx(Yc,{})}),s.jsx(re,{path:"payments/federal/individual-enrollment",element:s.jsx(Xc,{})}),s.jsx(re,{path:"tax-forms",element:s.jsx(v0,{})}),s.jsx(re,{path:"settings",element:s.jsx(Si,{})})]}),s.jsx(re,{path:"*",element:s.jsx(ut,{to:"/",replace:!0})})]})}const Z0=_.forwardRef(function(t,r){const n=_.useRef(null);return _.useImperativeHandle(r,()=>({navigate:a=>{var i;return(i=n.current)==null?void 0:i.call(n,a)}})),s.jsx(qa,{...t,navigateFnRef:n,children:s.jsx(U0,{paymentsMode:"all"})})}),B0=_.forwardRef(function(t,r){const n=_.useRef(null);return _.useImperativeHandle(r,()=>({navigate:a=>{var i;return(i=n.current)==null?void 0:i.call(n,a)}})),s.jsx(qa,{...t,navigateFnRef:n,children:s.jsxs(Fa,{children:[s.jsx(re,{index:!0,element:s.jsx(Ua,{})}),s.jsx(re,{path:"create-entity",element:s.jsx(Ba,{})}),s.jsx(re,{path:"create-entity/form",element:s.jsx(ii,{})}),s.jsxs(re,{element:s.jsx(Za,{}),children:[s.jsx(re,{path:"dashboard",element:s.jsx(li,{})}),s.jsx(re,{path:"payments",element:s.jsx(hi,{paymentsMode:"federal"})}),s.jsx(re,{path:"payments/federal/new",element:s.jsx(Mc,{})}),s.jsx(re,{path:"payments/federal/:federalPaymentId/edit",element:s.jsx(qc,{})}),s.jsx(re,{path:"payments/federal/:federalPaymentId/view",element:s.jsx(Uc,{})}),s.jsx(re,{path:"payments/federal/authorization",element:s.jsx(Yc,{})}),s.jsx(re,{path:"payments/federal/individual-enrollment",element:s.jsx(Xc,{})}),s.jsx(re,{path:"settings",element:s.jsx(Si,{})})]}),s.jsx(re,{path:"*",element:s.jsx(ut,{to:"/",replace:!0})})]})})}),W0=_.forwardRef(function(t,r){const n=_.useRef(null);return _.useImperativeHandle(r,()=>({navigate:a=>{var i;return(i=n.current)==null?void 0:i.call(n,a)}})),s.jsx(qa,{...t,navigateFnRef:n,children:s.jsxs(Fa,{children:[s.jsx(re,{index:!0,element:s.jsx(Ua,{})}),s.jsx(re,{path:"create-entity",element:s.jsx(Ba,{})}),s.jsx(re,{path:"create-entity/form",element:s.jsx(ii,{})}),s.jsxs(re,{element:s.jsx(Za,{}),children:[s.jsx(re,{path:"dashboard",element:s.jsx(li,{})}),s.jsx(re,{path:"payments",element:s.jsx(hi,{paymentsMode:"state"})}),s.jsx(re,{path:"payments/state/new",element:s.jsx(Wc,{})}),s.jsx(re,{path:"payments/state/authorization",element:s.jsx(Hc,{})}),s.jsx(re,{path:"settings",element:s.jsx(Si,{})})]}),s.jsx(re,{path:"*",element:s.jsx(ut,{to:"/",replace:!0})})]})})});exports.ApiError=bn;exports.FederalPaymentWidget=B0;exports.StatePaymentWidget=W0;exports.TaxRemittanceEmbedded=Z0;exports.setRuntimeApiBaseUrl=Fl;
76
+ //# sourceMappingURL=index.cjs.map