@npm-zenwork/tax-remittance-ui 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var hd=Object.defineProperty;var co=e=>{throw TypeError(e)};var fd=(e,t,n)=>t in e?hd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var wr=(e,t,n)=>fd(e,typeof t!="symbol"?t+"":t,n),sa=(e,t,n)=>t.has(e)||co("Cannot "+n);var w=(e,t,n)=>(sa(e,t,"read from private field"),n?n.call(e):t.get(e)),ee=(e,t,n)=>t.has(e)?co("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),U=(e,t,n,r)=>(sa(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),le=(e,t,n)=>(sa(e,t,"access private method"),n);var es=(e,t,n,r)=>({set _(a){U(e,t,a,n)},get _(){return w(e,t,r)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),v=require("react"),Br=require("react-dom");function pd(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const P=pd(v);/**
1
+ "use strict";var pd=Object.defineProperty;var uo=e=>{throw TypeError(e)};var xd=(e,t,n)=>t in e?pd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var jr=(e,t,n)=>xd(e,typeof t!="symbol"?t+"":t,n),sa=(e,t,n)=>t.has(e)||uo("Cannot "+n);var w=(e,t,n)=>(sa(e,t,"read from private field"),n?n.call(e):t.get(e)),ee=(e,t,n)=>t.has(e)?uo("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),U=(e,t,n,r)=>(sa(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),oe=(e,t,n)=>(sa(e,t,"access private method"),n);var es=(e,t,n,r)=>({set _(a){U(e,t,a,n)},get _(){return w(e,t,r)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),v=require("react"),qr=require("react-dom");function gd(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const P=gd(v);/**
2
2
  * react-router v7.18.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
@@ -7,11 +7,11 @@
7
7
  * LICENSE.md file in the root directory of this source tree.
8
8
  *
9
9
  * @license MIT
10
- */var ii=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,xd=/^[\\/]{2}/;function gd(e,t){return t+e.replace(/\\/g,"/")}function uo(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function yd(e={}){let{initialEntries:t=["/"],initialIndex:n,v5Compat:r=!1}=e,a;a=t.map((p,y)=>u(p,typeof p=="string"?null:p.state,y===0?"default":void 0,typeof p=="string"?void 0:p.mask));let i=c(n??a.length-1),o="POP",l=null;function c(p){return Math.min(Math.max(p,0),a.length-1)}function d(){return a[i]}function u(p,y=null,x,j){let g=vd(a?d().pathname:"/",p,y,x,j);return dt(g.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(p)}`),g}function m(p){return typeof p=="string"?p:bs(p)}return{get index(){return i},get action(){return o},get location(){return d()},createHref:m,createURL(p){return new URL(m(p),"http://localhost")},encodeLocation(p){let y=typeof p=="string"?On(p):p;return{pathname:y.pathname||"",search:y.search||"",hash:y.hash||""}},push(p,y){o="PUSH";let x=uo(p)?p:u(p,y);i+=1,a.splice(i,a.length,x),r&&l&&l({action:o,location:x,delta:1})},replace(p,y){o="REPLACE";let x=uo(p)?p:u(p,y);a[i]=x,r&&l&&l({action:o,location:x,delta:0})},go(p){o="POP";let y=c(i+p),x=a[y];i=y,l&&l({action:o,location:x,delta:p})},listen(p){return l=p,()=>{l=null}}}}function Ee(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function dt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function bd(){return Math.random().toString(36).substring(2,10)}function vd(e,t,n=null,r,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?On(t):t,state:n,key:t&&t.key||r||bd(),mask:a}}function bs({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function On(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Ll(e,t,n="/"){return jd(e,t,n,!1)}function jd(e,t,n,r,a){let i=typeof t=="string"?On(t):t,o=Gt(i.pathname||"/",n);if(o==null)return null;let l=wd(e),c=null,d=Fd(o);for(let u=0;c==null&&u<l.length;++u)c=_d(l[u],d,r);return c}function wd(e){let t=Ol(e);return Nd(t),t}function Ol(e,t=[],n=[],r="",a=!1){let i=(o,l,c=a,d)=>{let u={relativePath:d===void 0?o.path||"":d,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(u.relativePath.startsWith("/")){if(!u.relativePath.startsWith(r)&&c)return;Ee(u.relativePath.startsWith(r),`Absolute route path "${u.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),u.relativePath=u.relativePath.slice(r.length)}let m=Ct([r,u.relativePath]),h=n.concat(u);o.children&&o.children.length>0&&(Ee(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),Ol(o.children,t,h,m,c)),!(o.path==null&&!o.index)&&t.push({path:m,score:Id(m,o.index),routesMeta:h.map((p,y)=>{let[x,j]=ql(p.relativePath,p.caseSensitive,y===h.length-1);return{...p,matcher:x,compiledParams:j}})})};return e.forEach((o,l)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))i(o,l);else for(let d of zl(o.path))i(o,l,!0,d)}),t}function zl(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let o=zl(r.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 Nd(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Td(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Sd=/^:[\w-]+$/,kd=3,Cd=2,Ad=1,Pd=10,Ed=-2,mo=e=>e==="*";function Id(e,t){let n=e.split("/"),r=n.length;return n.some(mo)&&(r+=Ed),t&&(r+=Cd),n.filter(a=>!mo(a)).reduce((a,i)=>a+(Sd.test(i)?kd:i===""?Ad:Pd),r)}function Td(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function _d(e,t,n=!1){let{routesMeta:r}=e,a={},i="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],d=l===r.length-1,u=i==="/"?t:t.slice(i.length)||"/",m={path:c.relativePath,caseSensitive:c.caseSensitive,end:d},h=c.matcher&&c.compiledParams?Ml(m,u,c.matcher,c.compiledParams):vs(m,u),p=c.route;if(!h&&d&&n&&!r[r.length-1].route.index&&(h=vs({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},u)),!h)return null;Object.assign(a,h.params),o.push({params:a,pathname:Ct([i,h.pathname]),pathnameBase:$d(Ct([i,h.pathnameBase])),route:p}),h.pathnameBase!=="/"&&(i=Ct([i,h.pathnameBase]))}return o}function vs(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ql(e.path,e.caseSensitive,e.end);return Ml(e,t,n,r)}function Ml(e,t,n,r){let a=t.match(n);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:r.reduce((d,{paramName:u,isOptional:m},h)=>{if(u==="*"){let y=l[h]||"";o=i.slice(0,i.length-y.length).replace(/(.)\/+$/,"$1")}const p=l[h];return m&&!p?d[u]=void 0:d[u]=(p||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:o,pattern:e}}function ql(e,t=!1,n=!0){dt(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 r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c,d,u)=>{if(r.push({paramName:l,isOptional:c!=null}),c){let m=u.charAt(d+o.length);return m&&m!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function Fd(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return dt(!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 Gt(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function Dd(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?On(e):e,i;return n?(n=Bl(n),n.startsWith("/")?i=ho(n.substring(1),"/"):i=ho(n,t)):i=t,{pathname:i,search:Ld(r),hash:Od(a)}}function ho(e,t){let n=js(t).split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function aa(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Rd(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function oi(e){let t=Rd(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Ls(e,t,n,r=!1){let a;typeof e=="string"?a=On(e):(a={...e},Ee(!a.pathname||!a.pathname.includes("?"),aa("?","pathname","search",a)),Ee(!a.pathname||!a.pathname.includes("#"),aa("#","pathname","hash",a)),Ee(!a.search||!a.search.includes("#"),aa("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,l;if(o==null)l=n;else{let m=t.length-1;if(!r&&o.startsWith("..")){let h=o.split("/");for(;h[0]==="..";)h.shift(),m-=1;a.pathname=h.join("/")}l=m>=0?t[m]:"/"}let c=Dd(a,l),d=o&&o!=="/"&&o.endsWith("/"),u=(i||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||u)&&(c.pathname+="/"),c}var Bl=e=>e.replace(/[\\/]{2,}/g,"/"),Ct=e=>Bl(e.join("/")),js=e=>e.replace(/\/+$/,""),$d=e=>js(e).replace(/^\/*/,"/"),Ld=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Od=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,zd=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Md(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function qd(e){let t=e.map(n=>n.route.path).filter(Boolean);return Ct(t)||"/"}var Vl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ul(e,t){let n=e;if(typeof n!="string"||!ii.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(Vl)try{let i=new URL(window.location.href),o=xd.test(n)?new URL(gd(n,i.protocol)):new URL(n),l=Gt(o.pathname,t);o.origin===i.origin&&l!=null?n=l+o.search+o.hash:a=!0}catch{dt(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Zl=["POST","PUT","PATCH","DELETE"];new Set(Zl);var Bd=["GET",...Zl];new Set(Bd);var Vd=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function Ud(e){try{return Vd.includes(new URL(e).protocol)}catch{return!1}}var fr=P.createContext(null);fr.displayName="DataRouter";var Os=P.createContext(null);Os.displayName="DataRouterState";var Wl=P.createContext(!1);function Zd(){return P.useContext(Wl)}var Yl=P.createContext({isTransitioning:!1});Yl.displayName="ViewTransition";var Wd=P.createContext(new Map);Wd.displayName="Fetchers";var Yd=P.createContext(null);Yd.displayName="Await";var mt=P.createContext(null);mt.displayName="Navigation";var Vr=P.createContext(null);Vr.displayName="Location";var gt=P.createContext({outlet:null,matches:[],isDataRoute:!1});gt.displayName="Route";var li=P.createContext(null);li.displayName="RouteError";var Hl="REACT_ROUTER_ERROR",Hd="REDIRECT",Kd="ROUTE_ERROR_RESPONSE";function Qd(e){if(e.startsWith(`${Hl}:${Hd}:{`))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 Jd(e){if(e.startsWith(`${Hl}:${Kd}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new zd(t.status,t.statusText,t.data)}catch{}}function Gd(e,{relative:t}={}){Ee(pr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=P.useContext(mt),{hash:a,pathname:i,search:o}=Ur(e,{relative:t}),l=i;return n!=="/"&&(l=i==="/"?n:Ct([n,i])),r.createHref({pathname:l,search:o,hash:a})}function pr(){return P.useContext(Vr)!=null}function Se(){return Ee(pr(),"useLocation() may be used only in the context of a <Router> component."),P.useContext(Vr).location}var Kl="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Ql(e){P.useContext(mt).static||P.useLayoutEffect(e)}function ke(){let{isDataRoute:e}=P.useContext(gt);return e?mm():Xd()}function Xd(){Ee(pr(),"useNavigate() may be used only in the context of a <Router> component.");let e=P.useContext(fr),{basename:t,navigator:n}=P.useContext(mt),{matches:r}=P.useContext(gt),{pathname:a}=Se(),i=JSON.stringify(oi(r)),o=P.useRef(!1);return Ql(()=>{o.current=!0}),P.useCallback((c,d={})=>{if(dt(o.current,Kl),!o.current)return;if(typeof c=="number"){n.go(c);return}let u=Ls(c,JSON.parse(i),a,d.relative==="path");e==null&&t!=="/"&&(u.pathname=u.pathname==="/"?t:Ct([t,u.pathname])),(d.replace?n.replace:n.push)(u,d.state,d)},[t,n,i,a,e])}var Jl=P.createContext(null);function ht(){return P.useContext(Jl)}function em(e){let t=P.useContext(gt).outlet;return P.useMemo(()=>t&&P.createElement(Jl.Provider,{value:e},t),[t,e])}function zs(){let{matches:e}=P.useContext(gt),t=e[e.length-1];return(t==null?void 0:t.params)??{}}function Ur(e,{relative:t}={}){let{matches:n}=P.useContext(gt),{pathname:r}=Se(),a=JSON.stringify(oi(n));return P.useMemo(()=>Ls(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function tm(e,t){return Gl(e,t)}function Gl(e,t,n){var j;Ee(pr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=P.useContext(mt),{matches:a}=P.useContext(gt),i=a[a.length-1],o=i?i.params:{},l=i?i.pathname:"/",c=i?i.pathnameBase:"/",d=i&&i.route;{let g=d&&d.path||"";ec(l,!d||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${g}">) 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.
10
+ */var ii=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,yd=/^[\\/]{2}/;function bd(e,t){return t+e.replace(/\\/g,"/")}function mo(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function vd(e={}){let{initialEntries:t=["/"],initialIndex:n,v5Compat:r=!1}=e,a;a=t.map((p,g)=>u(p,typeof p=="string"?null:p.state,g===0?"default":void 0,typeof p=="string"?void 0:p.mask));let i=c(n??a.length-1),o="POP",l=null;function c(p){return Math.min(Math.max(p,0),a.length-1)}function d(){return a[i]}function u(p,g=null,x,b){let y=wd(a?d().pathname:"/",p,g,x,b);return dt(y.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(p)}`),y}function m(p){return typeof p=="string"?p:bs(p)}return{get index(){return i},get action(){return o},get location(){return d()},createHref:m,createURL(p){return new URL(m(p),"http://localhost")},encodeLocation(p){let g=typeof p=="string"?On(p):p;return{pathname:g.pathname||"",search:g.search||"",hash:g.hash||""}},push(p,g){o="PUSH";let x=mo(p)?p:u(p,g);i+=1,a.splice(i,a.length,x),r&&l&&l({action:o,location:x,delta:1})},replace(p,g){o="REPLACE";let x=mo(p)?p:u(p,g);a[i]=x,r&&l&&l({action:o,location:x,delta:0})},go(p){o="POP";let g=c(i+p),x=a[g];i=g,l&&l({action:o,location:x,delta:p})},listen(p){return l=p,()=>{l=null}}}}function Ee(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function dt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function jd(){return Math.random().toString(36).substring(2,10)}function wd(e,t,n=null,r,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?On(t):t,state:n,key:t&&t.key||r||jd(),mask:a}}function bs({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function On(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function zl(e,t,n="/"){return Nd(e,t,n,!1)}function Nd(e,t,n,r,a){let i=typeof t=="string"?On(t):t,o=Gt(i.pathname||"/",n);if(o==null)return null;let l=Sd(e),c=null,d=Rd(o);for(let u=0;c==null&&u<l.length;++u)c=Fd(l[u],d,r);return c}function Sd(e){let t=Ml(e);return kd(t),t}function Ml(e,t=[],n=[],r="",a=!1){let i=(o,l,c=a,d)=>{let u={relativePath:d===void 0?o.path||"":d,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(u.relativePath.startsWith("/")){if(!u.relativePath.startsWith(r)&&c)return;Ee(u.relativePath.startsWith(r),`Absolute route path "${u.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),u.relativePath=u.relativePath.slice(r.length)}let m=Ct([r,u.relativePath]),h=n.concat(u);o.children&&o.children.length>0&&(Ee(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),Ml(o.children,t,h,m,c)),!(o.path==null&&!o.index)&&t.push({path:m,score:_d(m,o.index),routesMeta:h.map((p,g)=>{let[x,b]=Vl(p.relativePath,p.caseSensitive,g===h.length-1);return{...p,matcher:x,compiledParams:b}})})};return e.forEach((o,l)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))i(o,l);else for(let d of ql(o.path))i(o,l,!0,d)}),t}function ql(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let o=ql(r.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 kd(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Dd(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Cd=/^:[\w-]+$/,Ad=3,Pd=2,Ed=1,Id=10,Td=-2,ho=e=>e==="*";function _d(e,t){let n=e.split("/"),r=n.length;return n.some(ho)&&(r+=Td),t&&(r+=Pd),n.filter(a=>!ho(a)).reduce((a,i)=>a+(Cd.test(i)?Ad:i===""?Ed:Id),r)}function Dd(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function Fd(e,t,n=!1){let{routesMeta:r}=e,a={},i="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],d=l===r.length-1,u=i==="/"?t:t.slice(i.length)||"/",m={path:c.relativePath,caseSensitive:c.caseSensitive,end:d},h=c.matcher&&c.compiledParams?Bl(m,u,c.matcher,c.compiledParams):vs(m,u),p=c.route;if(!h&&d&&n&&!r[r.length-1].route.index&&(h=vs({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},u)),!h)return null;Object.assign(a,h.params),o.push({params:a,pathname:Ct([i,h.pathname]),pathnameBase:Od(Ct([i,h.pathnameBase])),route:p}),h.pathnameBase!=="/"&&(i=Ct([i,h.pathnameBase]))}return o}function vs(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Vl(e.path,e.caseSensitive,e.end);return Bl(e,t,n,r)}function Bl(e,t,n,r){let a=t.match(n);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:r.reduce((d,{paramName:u,isOptional:m},h)=>{if(u==="*"){let g=l[h]||"";o=i.slice(0,i.length-g.length).replace(/(.)\/+$/,"$1")}const p=l[h];return m&&!p?d[u]=void 0:d[u]=(p||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:o,pattern:e}}function Vl(e,t=!1,n=!0){dt(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 r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c,d,u)=>{if(r.push({paramName:l,isOptional:c!=null}),c){let m=u.charAt(d+o.length);return m&&m!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function Rd(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return dt(!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 Gt(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function $d(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?On(e):e,i;return n?(n=Ul(n),n.startsWith("/")?i=fo(n.substring(1),"/"):i=fo(n,t)):i=t,{pathname:i,search:zd(r),hash:Md(a)}}function fo(e,t){let n=js(t).split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function aa(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Ld(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function oi(e){let t=Ld(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Ls(e,t,n,r=!1){let a;typeof e=="string"?a=On(e):(a={...e},Ee(!a.pathname||!a.pathname.includes("?"),aa("?","pathname","search",a)),Ee(!a.pathname||!a.pathname.includes("#"),aa("#","pathname","hash",a)),Ee(!a.search||!a.search.includes("#"),aa("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,l;if(o==null)l=n;else{let m=t.length-1;if(!r&&o.startsWith("..")){let h=o.split("/");for(;h[0]==="..";)h.shift(),m-=1;a.pathname=h.join("/")}l=m>=0?t[m]:"/"}let c=$d(a,l),d=o&&o!=="/"&&o.endsWith("/"),u=(i||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||u)&&(c.pathname+="/"),c}var Ul=e=>e.replace(/[\\/]{2,}/g,"/"),Ct=e=>Ul(e.join("/")),js=e=>e.replace(/\/+$/,""),Od=e=>js(e).replace(/^\/*/,"/"),zd=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Md=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,qd=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Bd(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Vd(e){let t=e.map(n=>n.route.path).filter(Boolean);return Ct(t)||"/"}var Zl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Wl(e,t){let n=e;if(typeof n!="string"||!ii.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(Zl)try{let i=new URL(window.location.href),o=yd.test(n)?new URL(bd(n,i.protocol)):new URL(n),l=Gt(o.pathname,t);o.origin===i.origin&&l!=null?n=l+o.search+o.hash:a=!0}catch{dt(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Yl=["POST","PUT","PATCH","DELETE"];new Set(Yl);var Ud=["GET",...Yl];new Set(Ud);var Zd=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function Wd(e){try{return Zd.includes(new URL(e).protocol)}catch{return!1}}var hr=P.createContext(null);hr.displayName="DataRouter";var Os=P.createContext(null);Os.displayName="DataRouterState";var Hl=P.createContext(!1);function Yd(){return P.useContext(Hl)}var Kl=P.createContext({isTransitioning:!1});Kl.displayName="ViewTransition";var Hd=P.createContext(new Map);Hd.displayName="Fetchers";var Kd=P.createContext(null);Kd.displayName="Await";var mt=P.createContext(null);mt.displayName="Navigation";var Br=P.createContext(null);Br.displayName="Location";var gt=P.createContext({outlet:null,matches:[],isDataRoute:!1});gt.displayName="Route";var li=P.createContext(null);li.displayName="RouteError";var Ql="REACT_ROUTER_ERROR",Qd="REDIRECT",Jd="ROUTE_ERROR_RESPONSE";function Gd(e){if(e.startsWith(`${Ql}:${Qd}:{`))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 Xd(e){if(e.startsWith(`${Ql}:${Jd}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new qd(t.status,t.statusText,t.data)}catch{}}function em(e,{relative:t}={}){Ee(fr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=P.useContext(mt),{hash:a,pathname:i,search:o}=Vr(e,{relative:t}),l=i;return n!=="/"&&(l=i==="/"?n:Ct([n,i])),r.createHref({pathname:l,search:o,hash:a})}function fr(){return P.useContext(Br)!=null}function Se(){return Ee(fr(),"useLocation() may be used only in the context of a <Router> component."),P.useContext(Br).location}var Jl="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Gl(e){P.useContext(mt).static||P.useLayoutEffect(e)}function ke(){let{isDataRoute:e}=P.useContext(gt);return e?fm():tm()}function tm(){Ee(fr(),"useNavigate() may be used only in the context of a <Router> component.");let e=P.useContext(hr),{basename:t,navigator:n}=P.useContext(mt),{matches:r}=P.useContext(gt),{pathname:a}=Se(),i=JSON.stringify(oi(r)),o=P.useRef(!1);return Gl(()=>{o.current=!0}),P.useCallback((c,d={})=>{if(dt(o.current,Jl),!o.current)return;if(typeof c=="number"){n.go(c);return}let u=Ls(c,JSON.parse(i),a,d.relative==="path");e==null&&t!=="/"&&(u.pathname=u.pathname==="/"?t:Ct([t,u.pathname])),(d.replace?n.replace:n.push)(u,d.state,d)},[t,n,i,a,e])}var Xl=P.createContext(null);function ht(){return P.useContext(Xl)}function nm(e){let t=P.useContext(gt).outlet;return P.useMemo(()=>t&&P.createElement(Xl.Provider,{value:e},t),[t,e])}function zs(){let{matches:e}=P.useContext(gt),t=e[e.length-1];return(t==null?void 0:t.params)??{}}function Vr(e,{relative:t}={}){let{matches:n}=P.useContext(gt),{pathname:r}=Se(),a=JSON.stringify(oi(n));return P.useMemo(()=>Ls(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function rm(e,t){return ec(e,t)}function ec(e,t,n){var b;Ee(fr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=P.useContext(mt),{matches:a}=P.useContext(gt),i=a[a.length-1],o=i?i.params:{},l=i?i.pathname:"/",c=i?i.pathnameBase:"/",d=i&&i.route;{let y=d&&d.path||"";nc(l,!d||y.endsWith("*")||y.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${y}">) 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
11
 
12
- Please change the parent <Route path="${g}"> to <Route path="${g==="/"?"*":`${g}/*`}">.`)}let u=Se(),m;if(t){let g=typeof t=="string"?On(t):t;Ee(c==="/"||((j=g.pathname)==null?void 0:j.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 "${g.pathname}" was given in the \`location\` prop.`),m=g}else m=u;let h=m.pathname||"/",p=h;if(c!=="/"){let g=c.replace(/^\//,"").split("/");p="/"+h.replace(/^\//,"").split("/").slice(g.length).join("/")}let y=n&&n.state.matches.length?n.state.matches.map(g=>Object.assign(g,{route:n.manifest[g.route.id]||g.route})):Ll(e,{pathname:p});dt(d||y!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),dt(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 "${m.pathname}${m.search}${m.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=im(y&&y.map(g=>Object.assign({},g,{params:Object.assign({},o,g.params),pathname:Ct([c,r.encodeLocation?r.encodeLocation(g.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?c:Ct([c,r.encodeLocation?r.encodeLocation(g.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),a,n);return t&&x?P.createElement(Vr.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...m},navigationType:"POP"}},x):x}function nm(){let e=dm(),t=Md(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r},i={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",e),o=P.createElement(P.Fragment,null,P.createElement("p",null,"💿 Hey developer 👋"),P.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",P.createElement("code",{style:i},"ErrorBoundary")," or"," ",P.createElement("code",{style:i},"errorElement")," prop on your route.")),P.createElement(P.Fragment,null,P.createElement("h2",null,"Unexpected Application Error!"),P.createElement("h3",{style:{fontStyle:"italic"}},t),n?P.createElement("pre",{style:a},n):null,o)}var rm=P.createElement(nm,null),Xl=class extends P.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 n=Jd(e.digest);n&&(e=n)}let t=e!==void 0?P.createElement(gt.Provider,{value:this.props.routeContext},P.createElement(li.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?P.createElement(sm,{error:e},t):t}};Xl.contextType=Wl;var ia=new WeakMap;function sm({children:e,error:t}){let{basename:n}=P.useContext(mt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=Qd(t.digest);if(r){let a=ia.get(t);if(a)throw a;let i=Ul(r.location,n),o=i.absoluteURL||i.to;if(Ud(o))throw new Error("Invalid redirect location");if(Vl&&!ia.get(t))if(i.isExternal||r.reloadDocument)window.location.href=o;else{const l=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:r.replace}));throw ia.set(t,l),l}return P.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o}`})}}return e}function am({routeContext:e,match:t,children:n}){let r=P.useContext(fr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),P.createElement(gt.Provider,{value:e},n)}function im(e,t=[],n){let r=n==null?void 0:n.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let a=e,i=r==null?void 0:r.errors;if(i!=null){let u=a.findIndex(m=>m.route.id&&(i==null?void 0:i[m.route.id])!==void 0);Ee(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,u+1))}let o=!1,l=-1;if(n&&r){o=r.renderFallback;for(let u=0;u<a.length;u++){let m=a[u];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(l=u),m.route.id){let{loaderData:h,errors:p}=r,y=m.route.loader&&!h.hasOwnProperty(m.route.id)&&(!p||p[m.route.id]===void 0);if(m.route.lazy||y){n.isStatic&&(o=!0),l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}}let c=n==null?void 0:n.onError,d=r&&c?(u,m)=>{var h,p;c(u,{location:r.location,params:((p=(h=r.matches)==null?void 0:h[0])==null?void 0:p.params)??{},pattern:qd(r.matches),errorInfo:m})}:void 0;return a.reduceRight((u,m,h)=>{let p,y=!1,x=null,j=null;r&&(p=i&&m.route.id?i[m.route.id]:void 0,x=m.route.errorElement||rm,o&&(l<0&&h===0?(ec("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),y=!0,j=null):l===h&&(y=!0,j=m.route.hydrateFallbackElement||null)));let g=t.concat(a.slice(0,h+1)),C=()=>{let b;return p?b=x:y?b=j:m.route.Component?b=P.createElement(m.route.Component,null):m.route.element?b=m.route.element:b=u,P.createElement(am,{match:m,routeContext:{outlet:u,matches:g,isDataRoute:r!=null},children:b})};return r&&(m.route.ErrorBoundary||m.route.errorElement||h===0)?P.createElement(Xl,{location:r.location,revalidation:r.revalidation,component:x,error:p,children:C(),routeContext:{outlet:null,matches:g,isDataRoute:!0},onError:d}):C()},null)}function ci(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function om(e){let t=P.useContext(fr);return Ee(t,ci(e)),t}function lm(e){let t=P.useContext(Os);return Ee(t,ci(e)),t}function cm(e){let t=P.useContext(gt);return Ee(t,ci(e)),t}function ui(e){let t=cm(e),n=t.matches[t.matches.length-1];return Ee(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function um(){return ui("useRouteId")}function dm(){var r;let e=P.useContext(li),t=lm("useRouteError"),n=ui("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function mm(){let{router:e}=om("useNavigate"),t=ui("useNavigate"),n=P.useRef(!1);return Ql(()=>{n.current=!0}),P.useCallback(async(a,i={})=>{dt(n.current,Kl),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...i}))},[e,t])}var fo={};function ec(e,t,n){!t&&!fo[e]&&(fo[e]=!0,dt(!1,n))}P.memo(hm);function hm({routes:e,manifest:t,future:n,state:r,isStatic:a,onError:i}){return Gl(e,void 0,{manifest:t,state:r,isStatic:a,onError:i})}function fm({basename:e,children:t,initialEntries:n,initialIndex:r,useTransitions:a}){let i=P.useRef();i.current==null&&(i.current=yd({initialEntries:n,initialIndex:r,v5Compat:!0}));let o=i.current,[l,c]=P.useState({action:o.action,location:o.location}),d=P.useCallback(u=>{a===!1?c(u):P.startTransition(()=>c(u))},[a]);return P.useLayoutEffect(()=>o.listen(d),[o,d]),P.createElement(xm,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:o,useTransitions:a})}function Be({to:e,replace:t,state:n,relative:r}){Ee(pr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=P.useContext(mt);dt(!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}=P.useContext(gt),{pathname:o}=Se(),l=ke(),c=Ls(e,oi(i),o,r==="path"),d=JSON.stringify(c);return P.useEffect(()=>{l(JSON.parse(d),{replace:t,state:n,relative:r})},[l,d,r,t,n]),null}function pm(e){return em(e.context)}function te(e){Ee(!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 xm({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:i=!1,useTransitions:o}){Ee(!pr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=P.useMemo(()=>({basename:l,navigator:a,static:i,useTransitions:o,future:{}}),[l,a,i,o]);typeof n=="string"&&(n=On(n));let{pathname:d="/",search:u="",hash:m="",state:h=null,key:p="default",mask:y}=n,x=P.useMemo(()=>{let j=Gt(d,l);return j==null?null:{location:{pathname:j,search:u,hash:m,state:h,key:p,mask:y},navigationType:r}},[l,d,u,m,h,p,r,y]);return dt(x!=null,`<Router basename="${l}"> is not able to match the URL "${d}${u}${m}" because it does not start with the basename, so the <Router> won't render anything.`),x==null?null:P.createElement(mt.Provider,{value:c},P.createElement(Vr.Provider,{children:t,value:x}))}function di({children:e,location:t}){return tm(Sa(e),t)}function Sa(e,t=[]){let n=[];return P.Children.forEach(e,(r,a)=>{if(!P.isValidElement(r))return;let i=[...t,a];if(r.type===P.Fragment){n.push.apply(n,Sa(r.props.children,i));return}Ee(r.type===te,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Ee(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=Sa(r.props.children,i)),n.push(o)}),n}var fs="get",ps="application/x-www-form-urlencoded";function Ms(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function gm(e){return Ms(e)&&e.tagName.toLowerCase()==="button"}function ym(e){return Ms(e)&&e.tagName.toLowerCase()==="form"}function bm(e){return Ms(e)&&e.tagName.toLowerCase()==="input"}function vm(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function jm(e,t){return e.button===0&&(!t||t==="_self")&&!vm(e)}function ka(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function wm(e,t){let n=ka(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(i=>{n.append(a,i)})}),n}var ts=null;function Nm(){if(ts===null)try{new FormData(document.createElement("form"),0),ts=!1}catch{ts=!0}return ts}var Sm=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function oa(e){return e!=null&&!Sm.has(e)?(dt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ps}"`),null):e}function km(e,t){let n,r,a,i,o;if(ym(e)){let l=e.getAttribute("action");r=l?Gt(l,t):null,n=e.getAttribute("method")||fs,a=oa(e.getAttribute("enctype"))||ps,i=new FormData(e)}else if(gm(e)||bm(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(r=c?Gt(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||fs,a=oa(e.getAttribute("formenctype"))||oa(l.getAttribute("enctype"))||ps,i=new FormData(l,e),!Nm()){let{name:d,type:u,value:m}=e;if(u==="image"){let h=d?`${d}.`:"";i.append(`${h}x`,"0"),i.append(`${h}y`,"0")}else d&&i.append(d,m)}}else{if(Ms(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=fs,r=null,a=ps,o=e}return i&&a==="text/plain"&&(o=i,i=void 0),{action:r,method:n.toLowerCase(),encType:a,formData:i,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function mi(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function tc(e,t,n,r){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${r}`:a.pathname=`${a.pathname}.${r}`:a.pathname==="/"?a.pathname=`_root.${r}`:t&&Gt(a.pathname,t)==="/"?a.pathname=`${js(t)}/_root.${r}`:a.pathname=`${js(a.pathname)}.${r}`,a}async function Cm(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Am(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 Pm(e,t,n){let r=await Promise.all(e.map(async a=>{let i=t.routes[a.route.id];if(i){let o=await Cm(i,n);return o.links?o.links():[]}return[]}));return _m(r.flat(1).filter(Am).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function po(e,t,n,r,a,i){let o=(c,d)=>n[d]?c.route.id!==n[d].route.id:!0,l=(c,d)=>{var u;return n[d].pathname!==c.pathname||((u=n[d].route.path)==null?void 0:u.endsWith("*"))&&n[d].params["*"]!==c.params["*"]};return i==="assets"?t.filter((c,d)=>o(c,d)||l(c,d)):i==="data"?t.filter((c,d)=>{var m;let u=r.routes[c.route.id];if(!u||!u.hasLoader)return!1;if(o(c,d)||l(c,d))return!0;if(c.route.shouldRevalidate){let h=c.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((m=n[0])==null?void 0:m.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function Em(e,t,{includeHydrateFallback:n}={}){return Im(e.map(r=>{let a=t.routes[r.route.id];if(!a)return[];let i=[a.module];return a.clientActionModule&&(i=i.concat(a.clientActionModule)),a.clientLoaderModule&&(i=i.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(i=i.concat(a.hydrateFallbackModule)),a.imports&&(i=i.concat(a.imports)),i}).flat(1))}function Im(e){return[...new Set(e)]}function Tm(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function _m(e,t){let n=new Set;return new Set(t),e.reduce((r,a)=>{let i=JSON.stringify(Tm(a));return n.has(i)||(n.add(i),r.push({key:i,link:a})),r},[])}function hi(){let e=P.useContext(fr);return mi(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Fm(){let e=P.useContext(Os);return mi(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var fi=P.createContext(void 0);fi.displayName="FrameworkContext";function qs(){let e=P.useContext(fi);return mi(e,"You must render this element inside a <HydratedRouter> element"),e}function Dm(e,t){let n=P.useContext(fi),[r,a]=P.useState(!1),[i,o]=P.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:u,onTouchStart:m}=t,h=P.useRef(null);P.useEffect(()=>{if(e==="render"&&o(!0),e==="viewport"){let x=g=>{g.forEach(C=>{o(C.isIntersecting)})},j=new IntersectionObserver(x,{threshold:.5});return h.current&&j.observe(h.current),()=>{j.disconnect()}}},[e]),P.useEffect(()=>{if(r){let x=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(x)}}},[r]);let p=()=>{a(!0)},y=()=>{a(!1),o(!1)};return n?e!=="intent"?[i,h,{}]:[i,h,{onFocus:Nr(l,p),onBlur:Nr(c,y),onMouseEnter:Nr(d,p),onMouseLeave:Nr(u,y),onTouchStart:Nr(m,p)}]:[!1,h,{}]}function Nr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Rm({page:e,...t}){let n=Zd(),{nonce:r}=qs(),{router:a}=hi(),i=P.useMemo(()=>Ll(a.routes,e,a.basename),[a.routes,e,a.basename]);return i?(t.nonce==null&&r&&(t={...t,nonce:r}),n?P.createElement(Lm,{page:e,matches:i,...t}):P.createElement(Om,{page:e,matches:i,...t})):null}function $m(e){let{manifest:t,routeModules:n}=qs(),[r,a]=P.useState([]);return P.useEffect(()=>{let i=!1;return Pm(e,t,n).then(o=>{i||a(o)}),()=>{i=!0}},[e,t,n]),r}function Lm({page:e,matches:t,...n}){let r=Se(),{future:a}=qs(),{basename:i}=hi(),o=P.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let l=tc(e,i,a.v8_trailingSlashAwareDataRequests,"rsc"),c=!1,d=[];for(let u of t)typeof u.route.shouldRevalidate=="function"?c=!0:d.push(u.route.id);return c&&d.length>0&&l.searchParams.set("_routes",d.join(",")),[l.pathname+l.search]},[i,a.v8_trailingSlashAwareDataRequests,e,r,t]);return P.createElement(P.Fragment,null,o.map(l=>P.createElement("link",{key:l,rel:"prefetch",as:"fetch",href:l,...n})))}function Om({page:e,matches:t,...n}){let r=Se(),{future:a,manifest:i,routeModules:o}=qs(),{basename:l}=hi(),{loaderData:c,matches:d}=Fm(),u=P.useMemo(()=>po(e,t,d,i,r,"data"),[e,t,d,i,r]),m=P.useMemo(()=>po(e,t,d,i,r,"assets"),[e,t,d,i,r]),h=P.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let x=new Set,j=!1;if(t.forEach(C=>{var S;let b=i.routes[C.route.id];!b||!b.hasLoader||(!u.some(I=>I.route.id===C.route.id)&&C.route.id in c&&((S=o[C.route.id])!=null&&S.shouldRevalidate)||b.hasClientLoader?j=!0:x.add(C.route.id))}),x.size===0)return[];let g=tc(e,l,a.v8_trailingSlashAwareDataRequests,"data");return j&&x.size>0&&g.searchParams.set("_routes",t.filter(C=>x.has(C.route.id)).map(C=>C.route.id).join(",")),[g.pathname+g.search]},[l,a.v8_trailingSlashAwareDataRequests,c,r,i,u,t,e,o]),p=P.useMemo(()=>Em(m,i),[m,i]),y=$m(m);return P.createElement(P.Fragment,null,h.map(x=>P.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),p.map(x=>P.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),y.map(({key:x,link:j})=>P.createElement("link",{key:x,nonce:n.nonce,...j,crossOrigin:j.crossOrigin??n.crossOrigin})))}function zm(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Mm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Mm&&(window.__reactRouterVersion="7.18.1")}catch{}var nc=P.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:a,reloadDocument:i,replace:o,mask:l,state:c,target:d,to:u,preventScrollReset:m,viewTransition:h,defaultShouldRevalidate:p,...y},x){let{basename:j,navigator:g,useTransitions:C}=P.useContext(mt),b=typeof u=="string"&&ii.test(u),S=Ul(u,j);u=S.to;let I=Gd(u,{relative:a}),R=Se(),E=null;if(l){let Z=Ls(l,[],R.mask?R.mask.pathname:"/",!0);j!=="/"&&(Z.pathname=Z.pathname==="/"?j:Ct([j,Z.pathname])),E=g.createHref(Z)}let[T,L,B]=Dm(r,y),K=Um(u,{replace:o,mask:l,state:c,target:d,preventScrollReset:m,relative:a,viewTransition:h,defaultShouldRevalidate:p,useTransitions:C});function X(Z){t&&t(Z),Z.defaultPrevented||K(Z)}let Y=!(S.isExternal||i),V=P.createElement("a",{...y,...B,href:(Y?E:void 0)||S.absoluteURL||I,onClick:Y?X:t,ref:zm(x,L),target:d,"data-discover":!b&&n==="render"?"true":void 0});return T&&!b?P.createElement(P.Fragment,null,V,P.createElement(Rm,{page:I})):V});nc.displayName="Link";var qm=P.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:a=!1,style:i,to:o,viewTransition:l,children:c,...d},u){let m=Ur(o,{relative:d.relative}),h=Se(),p=P.useContext(Os),{navigator:y,basename:x}=P.useContext(mt),j=p!=null&&Qm(m)&&l===!0,g=y.encodeLocation?y.encodeLocation(m).pathname:m.pathname,C=h.pathname,b=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;n||(C=C.toLowerCase(),b=b?b.toLowerCase():null,g=g.toLowerCase()),b&&x&&(b=Gt(b,x)||b);const S=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let I=C===g||!a&&C.startsWith(g)&&C.charAt(S)==="/",R=b!=null&&(b===g||!a&&b.startsWith(g)&&b.charAt(g.length)==="/"),E={isActive:I,isPending:R,isTransitioning:j},T=I?t:void 0,L;typeof r=="function"?L=r(E):L=[r,I?"active":null,R?"pending":null,j?"transitioning":null].filter(Boolean).join(" ");let B=typeof i=="function"?i(E):i;return P.createElement(nc,{...d,"aria-current":T,className:L,ref:u,style:B,to:o,viewTransition:l},typeof c=="function"?c(E):c)});qm.displayName="NavLink";var Bm=P.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:a,state:i,method:o=fs,action:l,onSubmit:c,relative:d,preventScrollReset:u,viewTransition:m,defaultShouldRevalidate:h,...p},y)=>{let{useTransitions:x}=P.useContext(mt),j=Hm(),g=Km(l,{relative:d}),C=o.toLowerCase()==="get"?"get":"post",b=typeof l=="string"&&ii.test(l),S=I=>{if(c&&c(I),I.defaultPrevented)return;I.preventDefault();let R=I.nativeEvent.submitter,E=(R==null?void 0:R.getAttribute("formmethod"))||o,T=()=>j(R||I.currentTarget,{fetcherKey:t,method:E,navigate:n,replace:a,state:i,relative:d,preventScrollReset:u,viewTransition:m,defaultShouldRevalidate:h});x&&n!==!1?P.startTransition(()=>T()):T()};return P.createElement("form",{ref:y,method:C,action:g,onSubmit:r?c:S,...p,"data-discover":!b&&e==="render"?"true":void 0})});Bm.displayName="Form";function Vm(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function rc(e){let t=P.useContext(fr);return Ee(t,Vm(e)),t}function Um(e,{target:t,replace:n,mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c,useTransitions:d}={}){let u=ke(),m=Se(),h=Ur(e,{relative:o});return P.useCallback(p=>{if(jm(p,t)){p.preventDefault();let y=n!==void 0?n:bs(m)===bs(h),x=()=>u(e,{replace:y,mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c});d?P.startTransition(()=>x()):x()}},[m,u,h,n,r,a,t,e,i,o,l,c,d])}function Zm(e){dt(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=P.useRef(ka(e)),n=P.useRef(!1),r=Se(),a=P.useMemo(()=>wm(r.search,n.current?null:t.current),[r.search]),i=ke(),o=P.useCallback((l,c)=>{const d=ka(typeof l=="function"?l(new URLSearchParams(a)):l);n.current=!0,i("?"+d,c)},[i,a]);return[a,o]}var Wm=0,Ym=()=>`__${String(++Wm)}__`;function Hm(){let{router:e}=rc("useSubmit"),{basename:t}=P.useContext(mt),n=um(),r=e.fetch,a=e.navigate;return P.useCallback(async(i,o={})=>{let{action:l,method:c,encType:d,formData:u,body:m}=km(i,t);if(o.navigate===!1){let h=o.fetcherKey||Ym();await r(h,n,o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:u,body:m,formMethod:o.method||c,formEncType:o.encType||d,flushSync:o.flushSync})}else await a(o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:u,body:m,formMethod:o.method||c,formEncType:o.encType||d,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[r,a,t,n])}function Km(e,{relative:t}={}){let{basename:n}=P.useContext(mt),r=P.useContext(gt);Ee(r,"useFormAction must be used inside a RouteContext");let[a]=r.matches.slice(-1),i={...Ur(e||".",{relative:t})},o=Se();if(e==null){i.search=o.search;let l=new URLSearchParams(i.search),c=l.getAll("index");if(c.some(u=>u==="")){l.delete("index"),c.filter(m=>m).forEach(m=>l.append("index",m));let u=l.toString();i.search=u?`?${u}`:""}}return(!e||e===".")&&a.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(i.pathname=i.pathname==="/"?n:Ct([n,i.pathname])),bs(i)}function Qm(e,{relative:t}={}){let n=P.useContext(Yl);Ee(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=rc("useViewTransitionState"),a=Ur(e,{relative:t});if(!n.isTransitioning)return!1;let i=Gt(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Gt(n.nextLocation.pathname,r)||n.nextLocation.pathname;return vs(a.pathname,o)!=null||vs(a.pathname,i)!=null}var xr=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(){}},Nn,sn,Qn,Cl,Jm=(Cl=class extends xr{constructor(){super();ee(this,Nn);ee(this,sn);ee(this,Qn);U(this,Qn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){w(this,sn)||this.setEventListener(w(this,Qn))}onUnsubscribe(){var t;this.hasListeners()||((t=w(this,sn))==null||t.call(this),U(this,sn,void 0))}setEventListener(t){var n;U(this,Qn,t),(n=w(this,sn))==null||n.call(this),U(this,sn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){w(this,Nn)!==t&&(U(this,Nn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof w(this,Nn)=="boolean"?w(this,Nn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Nn=new WeakMap,sn=new WeakMap,Qn=new WeakMap,Cl),pi=new Jm,Gm={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Tt,Sn,Al,Xm=(Al=class{constructor(){ee(this,Tt,Gm);ee(this,Sn,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&w(this,Sn)&&e!==w(this,Tt)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:w(this,Tt),provider:e}),U(this,Tt,e),process.env.NODE_ENV!=="production"&&U(this,Sn,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&U(this,Sn,!0),w(this,Tt).setTimeout(e,t)}clearTimeout(e){w(this,Tt).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&U(this,Sn,!0),w(this,Tt).setInterval(e,t)}clearInterval(e){w(this,Tt).clearInterval(e)}},Tt=new WeakMap,Sn=new WeakMap,Al),jn=new Xm;function eh(e){setTimeout(e,0)}var th=typeof window>"u"||"Deno"in globalThis;function et(){}function nh(e,t){return typeof e=="function"?e(t):e}function Ca(e){return typeof e=="number"&&e>=0&&e!==1/0}function sc(e,t){return Math.max(e+(t||0)-Date.now(),0)}function pn(e,t){return typeof e=="function"?e(t):e}function lt(e,t){return typeof e=="function"?e(t):e}function xo(e,t){const{type:n="all",exact:r,fetchStatus:a,predicate:i,queryKey:o,stale:l}=e;if(o){if(r){if(t.queryHash!==xi(o,t.options))return!1}else if(!Fr(t.queryKey,o))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||a&&a!==t.state.fetchStatus||i&&!i(t))}function go(e,t){const{exact:n,status:r,predicate:a,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Fn(t.options.mutationKey)!==Fn(i))return!1}else if(!Fr(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||a&&!a(t))}function xi(e,t){return((t==null?void 0:t.queryKeyHashFn)||Fn)(e)}function Fn(e){return JSON.stringify(e,(t,n)=>Pa(n)?Object.keys(n).sort().reduce((r,a)=>(r[a]=n[a],r),{}):n)}function Fr(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Fr(e[n],t[n])):!1}var rh=Object.prototype.hasOwnProperty;function Aa(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=yo(e)&&yo(t);if(!r&&!(Pa(e)&&Pa(t)))return t;const i=(r?e:Object.keys(e)).length,o=r?t:Object.keys(t),l=o.length,c=r?new Array(l):{};let d=0;for(let u=0;u<l;u++){const m=r?u:o[u],h=e[m],p=t[m];if(h===p){c[m]=h,(r?u<i:rh.call(e,m))&&d++;continue}if(h===null||p===null||typeof h!="object"||typeof p!="object"){c[m]=p;continue}const y=Aa(h,p,n+1);c[m]=y,y===h&&d++}return i===l&&d===i?e:c}function ws(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function yo(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Pa(e){if(!bo(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!bo(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function bo(e){return Object.prototype.toString.call(e)==="[object Object]"}function sh(e){return new Promise(t=>{jn.setTimeout(t,e)})}function Ea(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Aa(e,t)}catch(r){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. [${n.queryHash}]: ${r}`),r}return Aa(e,t)}return t}function ah(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function ih(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Ns=Symbol();function ac(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Ns&&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===Ns?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function gi(e,t){return typeof e=="function"?e(...t):!!e}function oh(e,t,n){let r=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),r||(r=!0,a.aborted?n():a.addEventListener("abort",n,{once:!0})),a)}),e}var Dr=(()=>{let e=()=>th;return{isServer(){return e()},setIsServer(t){e=t}}})();function Ia(){let e,t;const n=new Promise((a,i)=>{e=a,t=i});n.status="pending",n.catch(()=>{});function r(a){Object.assign(n,a),delete n.resolve,delete n.reject}return n.resolve=a=>{r({status:"fulfilled",value:a}),e(a)},n.reject=a=>{r({status:"rejected",reason:a}),t(a)},n}var lh=eh;function ch(){let e=[],t=0,n=l=>{l()},r=l=>{l()},a=lh;const i=l=>{t?e.push(l):a(()=>{n(l)})},o=()=>{const l=e;e=[],l.length&&a(()=>{r(()=>{l.forEach(c=>{n(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=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{a=l}}}var ze=ch(),Jn,an,Gn,Pl,uh=(Pl=class extends xr{constructor(){super();ee(this,Jn,!0);ee(this,an);ee(this,Gn);U(this,Gn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){w(this,an)||this.setEventListener(w(this,Gn))}onUnsubscribe(){var t;this.hasListeners()||((t=w(this,an))==null||t.call(this),U(this,an,void 0))}setEventListener(t){var n;U(this,Gn,t),(n=w(this,an))==null||n.call(this),U(this,an,t(this.setOnline.bind(this)))}setOnline(t){w(this,Jn)!==t&&(U(this,Jn,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return w(this,Jn)}},Jn=new WeakMap,an=new WeakMap,Gn=new WeakMap,Pl),Ss=new uh;function dh(e){return Math.min(1e3*2**e,3e4)}function ic(e){return(e??"online")==="online"?Ss.isOnline():!0}var Ta=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function oc(e){let t=!1,n=0,r;const a=Ia(),i=()=>a.status!=="pending",o=x=>{var j;if(!i()){const g=new Ta(x);h(g),(j=e.onCancel)==null||j.call(e,g)}},l=()=>{t=!0},c=()=>{t=!1},d=()=>pi.isFocused()&&(e.networkMode==="always"||Ss.isOnline())&&e.canRun(),u=()=>ic(e.networkMode)&&e.canRun(),m=x=>{i()||(r==null||r(),a.resolve(x))},h=x=>{i()||(r==null||r(),a.reject(x))},p=()=>new Promise(x=>{var j;r=g=>{(i()||d())&&x(g)},(j=e.onPause)==null||j.call(e)}).then(()=>{var x;r=void 0,i()||(x=e.onContinue)==null||x.call(e)}),y=()=>{if(i())return;let x;const j=n===0?e.initialPromise:void 0;try{x=j??e.fn()}catch(g){x=Promise.reject(g)}Promise.resolve(x).then(m).catch(g=>{var R;if(i())return;const C=e.retry??(Dr.isServer()?0:3),b=e.retryDelay??dh,S=typeof b=="function"?b(n,g):b,I=C===!0||typeof C=="number"&&n<C||typeof C=="function"&&C(n,g);if(t||!I){h(g);return}n++,(R=e.onFail)==null||R.call(e,n,g),sh(S).then(()=>d()?void 0:p()).then(()=>{t?h(g):y()})})};return{promise:a,status:()=>a.status,cancel:o,continue:()=>(r==null||r(),a),cancelRetry:l,continueRetry:c,canStart:u,start:()=>(u()?y():p().then(y),a)}}var kn,El,lc=(El=class{constructor(){ee(this,kn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ca(this.gcTime)&&U(this,kn,jn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Dr.isServer()?1/0:300*1e3))}clearGcTimeout(){w(this,kn)!==void 0&&(jn.clearTimeout(w(this,kn)),U(this,kn,void 0))}},kn=new WeakMap,El);function mh(e){return{onFetch:(t,n)=>{var u,m,h,p,y;const r=t.options,a=(h=(m=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:m.fetchMore)==null?void 0:h.direction,i=((p=t.state.data)==null?void 0:p.pages)||[],o=((y=t.state.data)==null?void 0:y.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const d=async()=>{let x=!1;const j=b=>{oh(b,()=>t.signal,()=>x=!0)},g=ac(t.options,t.fetchOptions),C=async(b,S,I)=>{if(x)return Promise.reject(t.signal.reason);if(S==null&&b.pages.length)return Promise.resolve(b);const E=(()=>{const K={client:t.client,queryKey:t.queryKey,pageParam:S,direction:I?"backward":"forward",meta:t.options.meta};return j(K),K})(),T=await g(E),{maxPages:L}=t.options,B=I?ih:ah;return{pages:B(b.pages,T,L),pageParams:B(b.pageParams,S,L)}};if(a&&i.length){const b=a==="backward",S=b?hh:vo,I={pages:i,pageParams:o},R=S(r,I);l=await C(I,R,b)}else{const b=e??i.length;do{const S=c===0?o[0]??r.initialPageParam:vo(r,l);if(c>0&&S==null)break;l=await C(l,S),c++}while(c<b)}return l};t.options.persister?t.fetchFn=()=>{var x,j;return(j=(x=t.options).persister)==null?void 0:j.call(x,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=d}}}function vo(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function hh(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var Xn,Cn,er,xt,An,qe,Lr,Pn,ot,cc,Zt,Il,fh=(Il=class extends lc{constructor(t){super();ee(this,ot);ee(this,Xn);ee(this,Cn);ee(this,er);ee(this,xt);ee(this,An);ee(this,qe);ee(this,Lr);ee(this,Pn);U(this,Pn,!1),U(this,Lr,t.defaultOptions),this.setOptions(t.options),this.observers=[],U(this,An,t.client),U(this,xt,w(this,An).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,U(this,Cn,wo(this.options)),this.state=t.state??w(this,Cn),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return w(this,Xn)}get promise(){var t;return(t=w(this,qe))==null?void 0:t.promise}setOptions(t){if(this.options={...w(this,Lr),...t},t!=null&&t._type&&U(this,Xn,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=wo(this.options);n.data!==void 0&&(this.setState(jo(n.data,n.dataUpdatedAt)),U(this,Cn,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&w(this,xt).remove(this)}setData(t,n){const r=Ea(this.state.data,t,this.options);return le(this,ot,Zt).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t){le(this,ot,Zt).call(this,{type:"setState",state:t})}cancel(t){var r,a;const n=(r=w(this,qe))==null?void 0:r.promise;return(a=w(this,qe))==null||a.cancel(t),n?n.then(et).catch(et):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return w(this,Cn)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>lt(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ns||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>pn(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:!sc(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=w(this,qe))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=w(this,qe))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),w(this,xt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(w(this,qe)&&(w(this,Pn)||le(this,ot,cc).call(this)?w(this,qe).cancel({revert:!0}):w(this,qe).cancelRetry()),this.scheduleGc()),w(this,xt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||le(this,ot,Zt).call(this,{type:"invalidate"})}async fetch(t,n){var d,u,m,h,p,y,x,j,g,C,b;if(this.state.fetchStatus!=="idle"&&((d=w(this,qe))==null?void 0:d.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(w(this,qe))return w(this,qe).continueRetry(),w(this,qe).promise}if(t&&this.setOptions(t),!this.options.queryFn){const S=this.observers.find(I=>I.options.queryFn);S&&this.setOptions(S.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 r=new AbortController,a=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(U(this,Pn,!0),r.signal)})},i=()=>{const S=ac(this.options,n),R=(()=>{const E={client:w(this,An),queryKey:this.queryKey,meta:this.meta};return a(E),E})();return U(this,Pn,!1),this.options.persister?this.options.persister(S,R,this):S(R)},l=(()=>{const S={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:w(this,An),state:this.state,fetchFn:i};return a(S),S})(),c=w(this,Xn)==="infinite"?mh(this.options.pages):this.options.behavior;c==null||c.onFetch(l,this),U(this,er,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=l.fetchOptions)==null?void 0:u.meta))&&le(this,ot,Zt).call(this,{type:"fetch",meta:(m=l.fetchOptions)==null?void 0:m.meta}),U(this,qe,oc({initialPromise:n==null?void 0:n.initialPromise,fn:l.fetchFn,onCancel:S=>{S instanceof Ta&&S.revert&&this.setState({...w(this,er),fetchStatus:"idle"}),r.abort()},onFail:(S,I)=>{le(this,ot,Zt).call(this,{type:"failed",failureCount:S,error:I})},onPause:()=>{le(this,ot,Zt).call(this,{type:"pause"})},onContinue:()=>{le(this,ot,Zt).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const S=await w(this,qe).start();if(S===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(S),(p=(h=w(this,xt).config).onSuccess)==null||p.call(h,S,this),(x=(y=w(this,xt).config).onSettled)==null||x.call(y,S,this.state.error,this),S}catch(S){if(S instanceof Ta){if(S.silent)return w(this,qe).promise;if(S.revert){if(this.state.data===void 0)throw S;return this.state.data}}throw le(this,ot,Zt).call(this,{type:"error",error:S}),(g=(j=w(this,xt).config).onError)==null||g.call(j,S,this),(b=(C=w(this,xt).config).onSettled)==null||b.call(C,this.state.data,S,this),S}finally{this.scheduleGc()}}},Xn=new WeakMap,Cn=new WeakMap,er=new WeakMap,xt=new WeakMap,An=new WeakMap,qe=new WeakMap,Lr=new WeakMap,Pn=new WeakMap,ot=new WeakSet,cc=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Zt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...uc(r.data,this.options),fetchMeta:t.meta??null};case"success":const a={...r,...jo(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return U(this,er,t.manual?a:void 0),a;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),ze.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),w(this,xt).notify({query:this,type:"updated",action:t})})},Il);function uc(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ic(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function jo(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function wo(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var st,me,Or,Xe,En,tr,Wt,on,zr,nr,rr,In,Tn,ln,sr,ye,Pr,_a,Fa,Da,Ra,$a,La,Oa,dc,Tl,ph=(Tl=class extends xr{constructor(t,n){super();ee(this,ye);ee(this,st);ee(this,me);ee(this,Or);ee(this,Xe);ee(this,En);ee(this,tr);ee(this,Wt);ee(this,on);ee(this,zr);ee(this,nr);ee(this,rr);ee(this,In);ee(this,Tn);ee(this,ln);ee(this,sr,new Set);this.options=n,U(this,st,t),U(this,on,null),U(this,Wt,Ia()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(w(this,me).addObserver(this),No(w(this,me),this.options)?le(this,ye,Pr).call(this):this.updateResult(),le(this,ye,Ra).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return za(w(this,me),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return za(w(this,me),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,le(this,ye,$a).call(this),le(this,ye,La).call(this),w(this,me).removeObserver(this)}setOptions(t){const n=this.options,r=w(this,me);if(this.options=w(this,st).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof lt(this.options.enabled,w(this,me))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");le(this,ye,Oa).call(this),w(this,me).setOptions(this.options),n._defaulted&&!ws(this.options,n)&&w(this,st).getQueryCache().notify({type:"observerOptionsUpdated",query:w(this,me),observer:this});const a=this.hasListeners();a&&So(w(this,me),r,this.options,n)&&le(this,ye,Pr).call(this),this.updateResult(),a&&(w(this,me)!==r||lt(this.options.enabled,w(this,me))!==lt(n.enabled,w(this,me))||pn(this.options.staleTime,w(this,me))!==pn(n.staleTime,w(this,me)))&&le(this,ye,_a).call(this);const i=le(this,ye,Fa).call(this);a&&(w(this,me)!==r||lt(this.options.enabled,w(this,me))!==lt(n.enabled,w(this,me))||i!==w(this,ln))&&le(this,ye,Da).call(this,i)}getOptimisticResult(t){const n=w(this,st).getQueryCache().build(w(this,st),t),r=this.createResult(n,t);return gh(this,r)&&(U(this,Xe,r),U(this,tr,this.options),U(this,En,w(this,me).state)),r}getCurrentResult(){return w(this,Xe)}trackResult(t,n){return new Proxy(t,{get:(r,a)=>(this.trackProp(a),n==null||n(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&w(this,Wt).status==="pending"&&w(this,Wt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,a))})}trackProp(t){w(this,sr).add(t)}getCurrentQuery(){return w(this,me)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=w(this,st).defaultQueryOptions(t),r=w(this,st).getQueryCache().build(w(this,st),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return le(this,ye,Pr).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),w(this,Xe)))}createResult(t,n){var L;const r=w(this,me),a=this.options,i=w(this,Xe),o=w(this,En),l=w(this,tr),d=t!==r?t.state:w(this,Or),{state:u}=t;let m={...u},h=!1,p;if(n._optimisticResults){const B=this.hasListeners(),K=!B&&No(t,n),X=B&&So(t,r,n,a);(K||X)&&(m={...m,...uc(u.data,t.options)}),n._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:y,errorUpdatedAt:x,status:j}=m;p=m.data;let g=!1;if(n.placeholderData!==void 0&&p===void 0&&j==="pending"){let B;i!=null&&i.isPlaceholderData&&n.placeholderData===(l==null?void 0:l.placeholderData)?(B=i.data,g=!0):B=typeof n.placeholderData=="function"?n.placeholderData((L=w(this,rr))==null?void 0:L.state.data,w(this,rr)):n.placeholderData,B!==void 0&&(j="success",p=Ea(i==null?void 0:i.data,B,n),h=!0)}if(n.select&&p!==void 0&&!g)if(i&&p===(o==null?void 0:o.data)&&n.select===w(this,zr))p=w(this,nr);else try{U(this,zr,n.select),p=n.select(p),p=Ea(i==null?void 0:i.data,p,n),U(this,nr,p),U(this,on,null)}catch(B){U(this,on,B)}w(this,on)&&(y=w(this,on),p=w(this,nr),x=Date.now(),j="error");const C=m.fetchStatus==="fetching",b=j==="pending",S=j==="error",I=b&&C,R=p!==void 0,T={status:j,fetchStatus:m.fetchStatus,isPending:b,isSuccess:j==="success",isError:S,isInitialLoading:I,isLoading:I,data:p,dataUpdatedAt:m.dataUpdatedAt,error:y,errorUpdatedAt:x,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:m.dataUpdateCount>d.dataUpdateCount||m.errorUpdateCount>d.errorUpdateCount,isFetching:C,isRefetching:C&&!b,isLoadingError:S&&!R,isPaused:m.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:S&&R,isStale:yi(t,n),refetch:this.refetch,promise:w(this,Wt),isEnabled:lt(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const B=T.data!==void 0,K=T.status==="error"&&!B,X=Z=>{K?Z.reject(T.error):B&&Z.resolve(T.data)},Y=()=>{const Z=U(this,Wt,T.promise=Ia());X(Z)},V=w(this,Wt);switch(V.status){case"pending":t.queryHash===r.queryHash&&X(V);break;case"fulfilled":(K||T.data!==V.value)&&Y();break;case"rejected":(!K||T.error!==V.reason)&&Y();break}}return T}updateResult(){const t=w(this,Xe),n=this.createResult(w(this,me),this.options);if(U(this,En,w(this,me).state),U(this,tr,this.options),w(this,En).data!==void 0&&U(this,rr,w(this,me)),ws(n,t))return;U(this,Xe,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!w(this,sr).size)return!0;const o=new Set(i??w(this,sr));return this.options.throwOnError&&o.add("error"),Object.keys(w(this,Xe)).some(l=>{const c=l;return w(this,Xe)[c]!==t[c]&&o.has(c)})};le(this,ye,dc).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&le(this,ye,Ra).call(this)}},st=new WeakMap,me=new WeakMap,Or=new WeakMap,Xe=new WeakMap,En=new WeakMap,tr=new WeakMap,Wt=new WeakMap,on=new WeakMap,zr=new WeakMap,nr=new WeakMap,rr=new WeakMap,In=new WeakMap,Tn=new WeakMap,ln=new WeakMap,sr=new WeakMap,ye=new WeakSet,Pr=function(t){le(this,ye,Oa).call(this);let n=w(this,me).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(et)),n},_a=function(){le(this,ye,$a).call(this);const t=pn(this.options.staleTime,w(this,me));if(Dr.isServer()||w(this,Xe).isStale||!Ca(t))return;const r=sc(w(this,Xe).dataUpdatedAt,t)+1;U(this,In,jn.setTimeout(()=>{w(this,Xe).isStale||this.updateResult()},r))},Fa=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(w(this,me)):this.options.refetchInterval)??!1},Da=function(t){le(this,ye,La).call(this),U(this,ln,t),!(Dr.isServer()||lt(this.options.enabled,w(this,me))===!1||!Ca(w(this,ln))||w(this,ln)===0)&&U(this,Tn,jn.setInterval(()=>{(this.options.refetchIntervalInBackground||pi.isFocused())&&le(this,ye,Pr).call(this)},w(this,ln)))},Ra=function(){le(this,ye,_a).call(this),le(this,ye,Da).call(this,le(this,ye,Fa).call(this))},$a=function(){w(this,In)!==void 0&&(jn.clearTimeout(w(this,In)),U(this,In,void 0))},La=function(){w(this,Tn)!==void 0&&(jn.clearInterval(w(this,Tn)),U(this,Tn,void 0))},Oa=function(){const t=w(this,st).getQueryCache().build(w(this,st),this.options);if(t===w(this,me))return;const n=w(this,me);U(this,me,t),U(this,Or,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},dc=function(t){ze.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(w(this,Xe))}),w(this,st).getQueryCache().notify({query:w(this,me),type:"observerResultsUpdated"})})},Tl);function xh(e,t){return lt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&lt(t.retryOnMount,e)===!1)}function No(e,t){return xh(e,t)||e.state.data!==void 0&&za(e,t,t.refetchOnMount)}function za(e,t,n){if(lt(t.enabled,e)!==!1&&pn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&yi(e,t)}return!1}function So(e,t,n,r){return(e!==t||lt(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&yi(e,n)}function yi(e,t){return lt(t.enabled,e)!==!1&&e.isStaleByTime(pn(t.staleTime,e))}function gh(e,t){return!ws(e.getCurrentResult(),t)}var Mr,_t,Ye,_n,Ft,tn,_l,yh=(_l=class extends lc{constructor(t){super();ee(this,Ft);ee(this,Mr);ee(this,_t);ee(this,Ye);ee(this,_n);U(this,Mr,t.client),this.mutationId=t.mutationId,U(this,Ye,t.mutationCache),U(this,_t,[]),this.state=t.state||mc(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){w(this,_t).includes(t)||(w(this,_t).push(t),this.clearGcTimeout(),w(this,Ye).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){U(this,_t,w(this,_t).filter(n=>n!==t)),this.scheduleGc(),w(this,Ye).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){w(this,_t).length||(this.state.status==="pending"?this.scheduleGc():w(this,Ye).remove(this))}continue(){var t;return((t=w(this,_n))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,c,d,u,m,h,p,y,x,j,g,C,b,S,I,R,E;const n=()=>{le(this,Ft,tn).call(this,{type:"continue"})},r={client:w(this,Mr),meta:this.options.meta,mutationKey:this.options.mutationKey};U(this,_n,oc({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(T,L)=>{le(this,Ft,tn).call(this,{type:"failed",failureCount:T,error:L})},onPause:()=>{le(this,Ft,tn).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>w(this,Ye).canRun(this)}));const a=this.state.status==="pending",i=!w(this,_n).canStart();try{if(a)n();else{le(this,Ft,tn).call(this,{type:"pending",variables:t,isPaused:i}),w(this,Ye).config.onMutate&&await w(this,Ye).config.onMutate(t,this,r);const L=await((l=(o=this.options).onMutate)==null?void 0:l.call(o,t,r));L!==this.state.context&&le(this,Ft,tn).call(this,{type:"pending",context:L,variables:t,isPaused:i})}const T=await w(this,_n).start();return await((d=(c=w(this,Ye).config).onSuccess)==null?void 0:d.call(c,T,t,this.state.context,this,r)),await((m=(u=this.options).onSuccess)==null?void 0:m.call(u,T,t,this.state.context,r)),await((p=(h=w(this,Ye).config).onSettled)==null?void 0:p.call(h,T,null,this.state.variables,this.state.context,this,r)),await((x=(y=this.options).onSettled)==null?void 0:x.call(y,T,null,t,this.state.context,r)),le(this,Ft,tn).call(this,{type:"success",data:T}),T}catch(T){try{await((g=(j=w(this,Ye).config).onError)==null?void 0:g.call(j,T,t,this.state.context,this,r))}catch(L){Promise.reject(L)}try{await((b=(C=this.options).onError)==null?void 0:b.call(C,T,t,this.state.context,r))}catch(L){Promise.reject(L)}try{await((I=(S=w(this,Ye).config).onSettled)==null?void 0:I.call(S,void 0,T,this.state.variables,this.state.context,this,r))}catch(L){Promise.reject(L)}try{await((E=(R=this.options).onSettled)==null?void 0:E.call(R,void 0,T,t,this.state.context,r))}catch(L){Promise.reject(L)}throw le(this,Ft,tn).call(this,{type:"error",error:T}),T}finally{w(this,Ye).runNext(this)}}},Mr=new WeakMap,_t=new WeakMap,Ye=new WeakMap,_n=new WeakMap,Ft=new WeakSet,tn=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,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{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),ze.batch(()=>{w(this,_t).forEach(r=>{r.onMutationUpdate(t)}),w(this,Ye).notify({mutation:this,type:"updated",action:t})})},_l);function mc(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Yt,St,qr,Fl,bh=(Fl=class extends xr{constructor(t={}){super();ee(this,Yt);ee(this,St);ee(this,qr);this.config=t,U(this,Yt,new Set),U(this,St,new Map),U(this,qr,0)}build(t,n,r){const a=new yh({client:t,mutationCache:this,mutationId:++es(this,qr)._,options:t.defaultMutationOptions(n),state:r});return this.add(a),a}add(t){w(this,Yt).add(t);const n=ns(t);if(typeof n=="string"){const r=w(this,St).get(n);r?r.push(t):w(this,St).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(w(this,Yt).delete(t)){const n=ns(t);if(typeof n=="string"){const r=w(this,St).get(n);if(r)if(r.length>1){const a=r.indexOf(t);a!==-1&&r.splice(a,1)}else r[0]===t&&w(this,St).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=ns(t);if(typeof n=="string"){const r=w(this,St).get(n),a=r==null?void 0:r.find(i=>i.state.status==="pending");return!a||a===t}else return!0}runNext(t){var r;const n=ns(t);if(typeof n=="string"){const a=(r=w(this,St).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ze.batch(()=>{w(this,Yt).forEach(t=>{this.notify({type:"removed",mutation:t})}),w(this,Yt).clear(),w(this,St).clear()})}getAll(){return Array.from(w(this,Yt))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>go(n,r))}findAll(t={}){return this.getAll().filter(n=>go(t,n))}notify(t){ze.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return ze.batch(()=>Promise.all(t.map(n=>n.continue().catch(et))))}},Yt=new WeakMap,St=new WeakMap,qr=new WeakMap,Fl);function ns(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Ht,cn,at,Kt,Jt,xs,Ma,Dl,vh=(Dl=class extends xr{constructor(t,n){super();ee(this,Jt);ee(this,Ht);ee(this,cn);ee(this,at);ee(this,Kt);U(this,Ht,t),this.setOptions(n),this.bindMethods(),le(this,Jt,xs).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const n=this.options;this.options=w(this,Ht).defaultMutationOptions(t),ws(this.options,n)||w(this,Ht).getMutationCache().notify({type:"observerOptionsUpdated",mutation:w(this,at),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Fn(n.mutationKey)!==Fn(this.options.mutationKey)?this.reset():((r=w(this,at))==null?void 0:r.state.status)==="pending"&&w(this,at).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=w(this,at))==null||t.removeObserver(this)}onMutationUpdate(t){le(this,Jt,xs).call(this),le(this,Jt,Ma).call(this,t)}getCurrentResult(){return w(this,cn)}reset(){var t;(t=w(this,at))==null||t.removeObserver(this),U(this,at,void 0),le(this,Jt,xs).call(this),le(this,Jt,Ma).call(this)}mutate(t,n){var r;return U(this,Kt,n),(r=w(this,at))==null||r.removeObserver(this),U(this,at,w(this,Ht).getMutationCache().build(w(this,Ht),this.options)),w(this,at).addObserver(this),w(this,at).execute(t)}},Ht=new WeakMap,cn=new WeakMap,at=new WeakMap,Kt=new WeakMap,Jt=new WeakSet,xs=function(){var n;const t=((n=w(this,at))==null?void 0:n.state)??mc();U(this,cn,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Ma=function(t){ze.batch(()=>{var n,r,a,i,o,l,c,d;if(w(this,Kt)&&this.hasListeners()){const u=w(this,cn).variables,m=w(this,cn).context,h={client:w(this,Ht),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(r=(n=w(this,Kt)).onSuccess)==null||r.call(n,t.data,u,m,h)}catch(p){Promise.reject(p)}try{(i=(a=w(this,Kt)).onSettled)==null||i.call(a,t.data,null,u,m,h)}catch(p){Promise.reject(p)}}else if((t==null?void 0:t.type)==="error"){try{(l=(o=w(this,Kt)).onError)==null||l.call(o,t.error,u,m,h)}catch(p){Promise.reject(p)}try{(d=(c=w(this,Kt)).onSettled)==null||d.call(c,void 0,t.error,u,m,h)}catch(p){Promise.reject(p)}}}this.listeners.forEach(u=>{u(w(this,cn))})})},Dl),Dt,Rl,jh=(Rl=class extends xr{constructor(t={}){super();ee(this,Dt);this.config=t,U(this,Dt,new Map)}build(t,n,r){const a=n.queryKey,i=n.queryHash??xi(a,n);let o=this.get(i);return o||(o=new fh({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(a)}),this.add(o)),o}add(t){w(this,Dt).has(t.queryHash)||(w(this,Dt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=w(this,Dt).get(t.queryHash);n&&(t.destroy(),n===t&&w(this,Dt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ze.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return w(this,Dt).get(t)}getAll(){return[...w(this,Dt).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>xo(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>xo(t,r)):n}notify(t){ze.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){ze.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ze.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Dt=new WeakMap,Rl),Fe,un,dn,ar,ir,mn,or,lr,$l,wh=($l=class{constructor(e={}){ee(this,Fe);ee(this,un);ee(this,dn);ee(this,ar);ee(this,ir);ee(this,mn);ee(this,or);ee(this,lr);U(this,Fe,e.queryCache||new jh),U(this,un,e.mutationCache||new bh),U(this,dn,e.defaultOptions||{}),U(this,ar,new Map),U(this,ir,new Map),U(this,mn,0)}mount(){es(this,mn)._++,w(this,mn)===1&&(U(this,or,pi.subscribe(async e=>{e&&(await this.resumePausedMutations(),w(this,Fe).onFocus())})),U(this,lr,Ss.subscribe(async e=>{e&&(await this.resumePausedMutations(),w(this,Fe).onOnline())})))}unmount(){var e,t;es(this,mn)._--,w(this,mn)===0&&((e=w(this,or))==null||e.call(this),U(this,or,void 0),(t=w(this,lr))==null||t.call(this),U(this,lr,void 0))}isFetching(e){return w(this,Fe).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return w(this,un).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=w(this,Fe).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=w(this,Fe).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(pn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return w(this,Fe).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),a=w(this,Fe).get(r.queryHash),i=a==null?void 0:a.state.data,o=nh(t,i);if(o!==void 0)return w(this,Fe).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return ze.batch(()=>w(this,Fe).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=w(this,Fe).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=w(this,Fe);ze.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=w(this,Fe);return ze.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=ze.batch(()=>w(this,Fe).findAll(e).map(a=>a.cancel(n)));return Promise.all(r).then(et).catch(et)}invalidateQueries(e,t={}){return ze.batch(()=>(w(this,Fe).findAll(e).forEach(n=>{n.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 n={...t,cancelRefetch:t.cancelRefetch??!0},r=ze.batch(()=>w(this,Fe).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,n);return n.throwOnError||(i=i.catch(et)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(et)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=w(this,Fe).build(this,t);return n.isStaleByTime(pn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(et).catch(et)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(et).catch(et)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return Ss.isOnline()?w(this,un).resumePausedMutations():Promise.resolve()}getQueryCache(){return w(this,Fe)}getMutationCache(){return w(this,un)}getDefaultOptions(){return w(this,dn)}setDefaultOptions(e){U(this,dn,e)}setQueryDefaults(e,t){w(this,ar).set(Fn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...w(this,ar).values()],n={};return t.forEach(r=>{Fr(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){w(this,ir).set(Fn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...w(this,ir).values()],n={};return t.forEach(r=>{Fr(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...w(this,dn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=xi(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===Ns&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...w(this,dn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){w(this,Fe).clear(),w(this,un).clear()}},Fe=new WeakMap,un=new WeakMap,dn=new WeakMap,ar=new WeakMap,ir=new WeakMap,mn=new WeakMap,or=new WeakMap,lr=new WeakMap,$l),hc=P.createContext(void 0),ft=e=>{const t=P.useContext(hc);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Nh=({client:e,children:t})=>(P.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(hc.Provider,{value:e,children:t})),fc=P.createContext(!1),Sh=()=>P.useContext(fc);fc.Provider;function kh(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Ch=P.createContext(kh()),Ah=()=>P.useContext(Ch),Ph=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?gi(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Eh=e=>{P.useEffect(()=>{e.clearReset()},[e])},Ih=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(a&&e.data===void 0||gi(n,[e.error,r])),Th=e=>{if(e.suspense){const n=a=>a==="static"?a:Math.max(a??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...a)=>n(r(...a)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},_h=(e,t)=>e.isLoading&&e.isFetching&&!t,Fh=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,ko=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Dh(e,t,n){var p,y,x,j;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 r=Sh(),a=Ah(),i=ft(),o=i.defaultQueryOptions(e);(y=(p=i.getDefaultOptions().queries)==null?void 0:p._experimental_beforeQuery)==null||y.call(p,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=r?"isRestoring":c?"optimistic":void 0,Th(o),Ph(o,a,l),Eh(a);const d=!i.getQueryCache().get(o.queryHash),[u]=P.useState(()=>new t(i,o)),m=u.getOptimisticResult(o),h=!r&&c;if(P.useSyncExternalStore(P.useCallback(g=>{const C=h?u.subscribe(ze.batchCalls(g)):et;return u.updateResult(),C},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),P.useEffect(()=>{u.setOptions(o)},[o,u]),Fh(o,m))throw ko(o,u,a);if(Ih({result:m,errorResetBoundary:a,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw m.error;if((j=(x=i.getDefaultOptions().queries)==null?void 0:x._experimental_afterQuery)==null||j.call(x,o,m),o.experimental_prefetchInRender&&!Dr.isServer()&&_h(m,r)){const g=d?ko(o,u,a):l==null?void 0:l.promise;g==null||g.catch(et).finally(()=>{u.updateResult()})}return o.notifyOnChangeProps?m:u.trackResult(m)}function ge(e,t){return Dh(e,ph)}function Rh(e,t){const n=ft(),[r]=P.useState(()=>new vh(n,e));P.useEffect(()=>{r.setOptions(e)},[r,e]);const a=P.useSyncExternalStore(P.useCallback(o=>r.subscribe(ze.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=P.useCallback((o,l)=>{r.mutate(o,l).catch(et)},[r]);if(a.error&&gi(r.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}function pc(e){return e.trim().replace(/\/+$/,"")}const Bs=new Map;function xc(e,t){Bs.set(e,t)}function $h(e){return Bs.get(e)}function Lh(e){Bs.delete(e)}function Oh(e){for(const[t,n]of Bs)if(n.accessToken===e)return t}let qa=null;function gc(e){qa=pc(e)}let yc=null;function zh(e){yc=e}function Mh(){return yc}let bc=null;function qh(e){bc=e.trim()}function Bh(){return bc}function Vh(){return qa!==null?qa:pc("")}const Co={get apiBaseUrl(){return Vh()},apiVersion:"v1"};function Uh(e){const t=e.startsWith("/")?e:`/${e}`;return`${Co.apiBaseUrl}/api/${Co.apiVersion}${t}`}const vc="auth:session-expired";function Zh(){window.dispatchEvent(new CustomEvent(vc))}function jc(e){return`${vc}:${e}`}const Wh=v.createContext(null);function Yh({instanceId:e,accessToken:t,onSessionExpired:n,children:r}){const a=$h(e);return a&&xc(e,{...a,accessToken:t}),zh(t),v.useEffect(()=>{if(!n)return;const i=jc(e),o=()=>n();return window.addEventListener(i,o),()=>window.removeEventListener(i,o)},[e,n]),s.jsx(Wh.Provider,{value:{accessToken:t},children:r})}class gr extends Error{constructor(n,r,a,i,o){super(a??r);wr(this,"status");wr(this,"title");wr(this,"details");wr(this,"extensions");this.name="ApiError",this.status=n,this.title=r,this.details=i,this.extensions=o}}const wc="tax-remittance.auth";function Hh(){var t;const e=localStorage.getItem(wc);if(!e)return null;try{const n=JSON.parse(e);return!n.accessToken||!((t=n.user)!=null&&t.userId)?null:new Date(n.user.expiresAt)<=new Date?(Ba(),null):n}catch{return Ba(),null}}function Ba(){localStorage.removeItem(wc)}function Kh(){var e;return((e=Hh())==null?void 0:e.accessToken)??null}async function Qh(e){let t=null;try{t=await e.json()}catch{}const n=(t==null?void 0:t.title)??"Request failed",r=t==null?void 0:t.detail,a=t==null?void 0:t.errors;return new gr(e.status,n,r,a,t??void 0)}async function Zr(e,t={}){const{body:n,auth:r=!0,headers:a,responseType:i="json",...o}=t,l=new Headers(a);i==="blob"?l.set("Accept","application/pdf"):i==="text"?l.set("Accept","text/html"):l.set("Accept","application/json"),n!==void 0&&l.set("Content-Type","application/json");let c=null;if(r){const m=Mh()??Kh();m&&(c=m,l.set("Authorization",`Bearer ${m}`))}const d=Bh();d&&l.set("X-Client-ID",d);const u=await fetch(Uh(e),{...o,headers:l,body:n!==void 0?JSON.stringify(n):void 0});if(!u.ok){const m=await Qh(u);if(r&&m.status===401){Ba();const h=c?Oh(c):void 0;h?window.dispatchEvent(new CustomEvent(jc(h))):Zh()}throw m}if(u.status!==204)return i==="blob"?await u.blob():i==="text"?await u.text():await u.json()}async function de(e,t={}){return(await Zr(e,t)).data}const it=10;function bi({search:e,pageNumber:t=1,pageSize:n=it}={}){const r=new URLSearchParams({pageNumber:String(t),pageSize:String(n)});return e!=null&&e.trim()&&r.set("search",e.trim()),de(`/portal/entities/mine?${r}`)}function Jh(e){return de("/portal/entities",{method:"POST",body:e})}function Gh(e,t){return de(`/portal/entities/${e}`,{method:"PATCH",body:t})}const Nc=v.createContext(null);function Xh({onOrganizationCreated:e,enabledPayments:t=["federal","state"],onPaymentRequired:n,children:r}){var x;const[a,i]=v.useState(null),{data:o=[],isLoading:l,isError:c,refetch:d}=ge({queryKey:["entities","mine"],queryFn:async()=>(await bi({pageNumber:1,pageSize:100})).items}),u=v.useRef(new Set),m=v.useRef(!1);v.useEffect(()=>{if(l)return;if(!m.current){o.forEach(g=>u.current.add(g.entityId)),m.current=!0;return}o.filter(g=>!u.current.has(g.entityId)).forEach(g=>{u.current.add(g.entityId),e==null||e(g)})},[o,l,e]);const h=a!==null&&o.some(j=>j.entityId===a)?a:((x=o[0])==null?void 0:x.entityId)??null,p=o.find(j=>j.entityId===h)??null,y=async()=>{await d()};return s.jsx(Nc.Provider,{value:{entities:o,isLoading:l,isError:c,selectedEntity:p,setSelectedEntityId:i,refetchEntities:y,enabledPayments:t,onPaymentRequired:n},children:r})}function zn(){const e=v.useContext(Nc);if(!e)throw new Error("useEmbeddedContext must be used inside EmbeddedContextProvider");return e}const ef=v.createContext(null);function tf({theme:e,children:t}){const n={},r=n,a=(e==null?void 0:e.primaryColor)??"#2563eb";r["--embedded-primary"]=a,r["--embedded-primary-dark"]=`color-mix(in srgb, ${a} 82%, black)`,r["--embedded-primary-light"]=`color-mix(in srgb, ${a} 15%, white)`;const i=(e==null?void 0:e.secondaryColor)??"#0891b2";r["--embedded-secondary"]=i,r["--embedded-secondary-dark"]=`color-mix(in srgb, ${i} 82%, black)`,r["--embedded-secondary-light"]=`color-mix(in srgb, ${i} 15%, white)`;const o=(e==null?void 0:e.tertiaryColor)??"#7c3aed";return r["--embedded-tertiary"]=o,r["--embedded-tertiary-dark"]=`color-mix(in srgb, ${o} 82%, black)`,r["--embedded-tertiary-light"]=`color-mix(in srgb, ${o} 15%, white)`,e!=null&&e.borderRadius&&(r["--embedded-radius"]=e.borderRadius),e!=null&&e.fontFamily&&(n.fontFamily=e.fontFamily),r.minHeight="100%",s.jsx("div",{className:"tax-remittance-embedded",style:n,children:t})}const Sc=v.createContext(null),nf=6e3;function rf(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function sf({toast:e,onDismiss:t}){const n=e.variant==="success";return s.jsxs("div",{role:"alert",className:`w-full max-w-md overflow-hidden rounded-xl border shadow-lg ${n?"border-emerald-700 bg-[#E8F7C8]":"border-red-300 bg-[#FCE8EA]"}`,children:[s.jsxs("div",{className:"flex items-start justify-between gap-3 px-5 py-4",children:[s.jsx("p",{className:"text-base font-bold text-slate-900",children:e.title}),s.jsx("button",{type:"button","aria-label":"Dismiss notification",onClick:()=>t(e.id),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full border transition hover:opacity-80 ${n?"border-emerald-800 text-emerald-900":"border-red-400 text-red-700"}`,children:s.jsx(af,{})})]}),s.jsx("div",{className:`mx-5 border-t ${n?"border-emerald-700":"border-red-300"}`}),s.jsx("p",{className:"px-5 py-4 text-sm text-slate-700",children:e.message})]})}function af(){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:"M6 18L18 6M6 6l12 12"})})}function of({children:e}){const[t,n]=v.useState([]),r=v.useCallback(o=>{n(l=>l.filter(c=>c.id!==o))},[]),a=v.useCallback((o,l,c)=>{const d=rf();n(u=>[...u,{id:d,variant:o,title:l,message:c}]),window.setTimeout(()=>{r(d)},nf)},[r]),i=v.useMemo(()=>({showSuccess:(o,l)=>a("success",o,l),showError:(o,l)=>a("error",o,l)}),[a]);return s.jsxs(Sc.Provider,{value:i,children:[e,Br.createPortal(s.jsx("div",{className:"pointer-events-none fixed right-4 top-4 z-[200] flex w-[min(100vw-2rem,28rem)] flex-col gap-3",children:t.map(o=>s.jsx("div",{className:"pointer-events-auto",children:s.jsx(sf,{toast:o,onDismiss:r})},o.id))}),document.body)]})}function Vs(){const e=v.useContext(Sc);if(!e)throw new Error("useToast must be used within ToastProvider");return e}class lf extends v.Component{constructor(t){super(t),this.state={hasError:!1,message:""}}static getDerivedStateFromError(t){return{hasError:!0,message:t instanceof Error?t.message:"Unexpected error"}}render(){return this.state.hasError?s.jsxs("div",{className:"flex min-h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[s.jsx("p",{className:"text-sm font-medium text-red-600",children:"Something went wrong loading this widget."}),s.jsx("p",{className:"text-xs text-slate-400",children:this.state.message}),s.jsx("button",{type:"button",className:"rounded-md bg-slate-100 px-4 py-2 text-sm text-slate-600 hover:bg-slate-200",onClick:()=>this.setState({hasError:!1,message:""}),children:"Try again"})]}):this.props.children}}function cf(e){return e.startsWith("/dashboard")?"dashboard":e.startsWith("/payments")?"payments":e.startsWith("/tax-forms")?"tax-forms":e.startsWith("/settings")?"settings":e.startsWith("/create-entity/form")?"create-entity-form":e.startsWith("/create-entity")?"create-entity":"other"}function uf({navigateFnRef:e,onNavigate:t}){const n=ke(),r=Se();return v.useEffect(()=>(e.current=n,()=>{e.current=null}),[n,e]),v.useEffect(()=>{t==null||t(cf(r.pathname),r.pathname)},[r.pathname,t]),null}function df({selectEntityFnRef:e}){const{setSelectedEntityId:t}=zn();return v.useEffect(()=>(e.current=t,()=>{e.current=null}),[t,e]),null}function vi({appKey:e,accessToken:t,apiBaseUrl:n,theme:r,onSessionExpired:a,onOrganizationCreated:i,onNavigate:o,onPaymentRequired:l,navigateFnRef:c,selectEntityFnRef:d,enabledPayments:u,children:m}){const[h]=v.useState(()=>crypto.randomUUID());xc(h,{apiBaseUrl:n.trim().replace(/\/+$/,""),clientId:e.trim(),accessToken:t}),gc(n),qh(e),v.useEffect(()=>()=>{Lh(h)},[h]);const[p]=v.useState(()=>new wh({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}));return s.jsx(ef.Provider,{value:h,children:s.jsx(tf,{theme:r,children:s.jsx(Nh,{client:p,children:s.jsx(of,{children:s.jsx(Yh,{instanceId:h,accessToken:t,onSessionExpired:a,children:s.jsx(fm,{children:s.jsxs(Xh,{onOrganizationCreated:i,enabledPayments:u,onPaymentRequired:l,children:[s.jsx(uf,{navigateFnRef:c,onNavigate:o}),s.jsx(df,{selectEntityFnRef:d}),s.jsx(lf,{children:m})]})})})})})})})}function ji(){const{entities:e,isLoading:t,isError:n,refetchEntities:r}=zn(),a=ke();return v.useEffect(()=>{t||n||a(e.length===0?"/create-entity":"/dashboard",{replace:!0})},[t,n,e,a]),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"})}):n?s.jsxs("div",{className:"flex min-h-[200px] flex-col items-center justify-center gap-3 px-4 text-center",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-red-50",children:s.jsx("svg",{className:"h-5 w-5 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})})}),s.jsx("p",{className:"text-sm font-medium text-slate-700",children:"Unable to load your account"}),s.jsx("p",{className:"text-xs text-slate-500",children:"Check your connection and try again."}),s.jsx("button",{type:"button",onClick:r,className:"mt-1 rounded-md bg-slate-100 px-4 py-1.5 text-xs font-medium text-slate-600 hover:bg-slate-200",children:"Retry"})]}):null}function wi(){const{entities:e,selectedEntity:t,setSelectedEntityId:n}=zn(),r=ke(),i=Se().pathname.split("/").filter(Boolean).length>1;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:[i&&s.jsxs("button",{type:"button",onClick:()=>r(-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(mf,{}),"Back"]}),s.jsx("div",{className:"flex-1"})]}),s.jsx("main",{className:"flex-1 p-5",children:s.jsx(pm,{context:{entities:e,selectedEntity:t,setSelectedEntityId:n}})})]})}function mf(){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 hf=["Entity name & EIN","Business type & primary state","Automatic dashboard access","Start managing tax payments"];function ff({onCreateClick:e}){return s.jsxs("div",{className:"mx-auto w-full max-w-[528px]",children:[s.jsxs("div",{className:"overflow-hidden rounded-[20px] border border-[#f3f4f6] bg-white shadow-[0_20px_25px_-5px_rgba(0,0,0,0.1),0_8px_10px_-6px_rgba(0,0,0,0.1)] sm:rounded-[24px]",children:[s.jsxs("div",{className:"bg-[#bccadb] px-5 pb-6 pt-6 text-center sm:px-8 sm:pb-8 sm:pt-8",children:[s.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-2xl bg-white/20 sm:h-16 sm:w-16",children:s.jsx(Ao,{className:"h-6 w-6 text-white sm:h-8 sm:w-8"})}),s.jsx("h2",{className:"mt-3 text-xl font-black tracking-tight text-[#1e2939] sm:mt-4 sm:text-2xl",children:"Add Your Entity"}),s.jsx("p",{className:"mt-1 text-sm text-[#1e2939]/80",children:"Get set up in under 1 minute"})]}),s.jsxs("div",{className:"bg-white px-5 py-5 sm:px-8 sm:py-6",children:[s.jsx("ul",{className:"space-y-2.5 sm:space-y-3",children:hf.map(t=>s.jsxs("li",{className:"flex items-center gap-3 text-sm text-[#4a5565]",children:[s.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-[#dfeeff] text-[#156bd5]",children:s.jsx(rs,{})}),t]},t))}),s.jsxs("button",{type:"button",onClick:e,className:"mt-5 flex h-12 w-full items-center justify-center gap-2 rounded-2xl bg-[#156bd5] text-sm font-black text-white transition hover:bg-[#125bb8] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#156bd5] focus-visible:ring-offset-2 sm:mt-6 sm:h-14 sm:text-base",children:[s.jsx(Ao,{className:"h-4 w-4 sm:h-[18px] sm:w-[18px]"}),"Add Entity",s.jsx(pf,{})]})]})]}),s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-x-3 gap-y-2 text-xs text-[#99a1af] sm:mt-5 sm:gap-x-4",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(rs,{className:"h-3 w-3 text-emerald-500"}),"SOC 2 Certified"]}),s.jsx("span",{className:"hidden h-3 w-px bg-[#e5e7eb] sm:block","aria-hidden":!0}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(rs,{className:"h-3 w-3 text-emerald-500"}),"Bank-grade encryption"]}),s.jsx("span",{className:"hidden h-3 w-px bg-[#e5e7eb] sm:block","aria-hidden":!0}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(rs,{className:"h-3 w-3 text-emerald-500"}),"Free to start"]})]})]})}function Ao({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 rs({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 pf(){return s.jsx("svg",{className:"h-4 w-4 sm:h-[18px] sm:w-[18px]",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 Ni(){const e=ke(),t=()=>{e("/create-entity/form",{state:{from:"/create-entity"}})};return s.jsx("div",{className:"flex items-center justify-center bg-transparent px-0 py-0",children:s.jsx(ff,{onCreateClick:t})})}var Wr=e=>e.type==="checkbox",hn=e=>e instanceof Date,Ue=e=>e==null;const Si=e=>typeof e=="object";var Pe=e=>!Ue(e)&&!Array.isArray(e)&&Si(e)&&!hn(e),Va=e=>Pe(e)&&e.target?Wr(e.target)?e.target.checked:e.target.value:e,kc=(e,t)=>t.split(".").some((n,r,a)=>!isNaN(Number(n))&&e.has(a.slice(0,r).join("."))),Cc=e=>{const t=e.constructor&&e.constructor.prototype;return Pe(t)&&t.hasOwnProperty("isPrototypeOf")},Us=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function _e(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Us&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(Pe(e)&&Cc(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=_e(e[a]));return r}const nn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},kt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Nt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Ac="root",ki=["__proto__","constructor","prototype"],xf=/^\w*$/;var Yr=e=>xf.test(e),je=e=>e===void 0;const gf=/[.[\]'"]/;var Zs=e=>e.split(gf).filter(Boolean),q=(e,t,n)=>{if(!t||!Pe(e))return n;const r=Yr(t)?[t]:Zs(t);if(r.some(i=>ki.includes(i)))return n;const a=r.reduce((i,o)=>Ue(i)?void 0:i[o],e);return je(a)||a===e?je(e[t])?n:e[t]:a},ct=e=>typeof e=="boolean",He=e=>typeof e=="function",xe=(e,t,n)=>{let r=-1;const a=Yr(t)?[t]:Zs(t),i=a.length,o=i-1;for(;++r<i;){const l=a[r];let c=n;if(r!==o){const d=e[l];c=Pe(d)||Array.isArray(d)?d:isNaN(+a[r+1])?{}:[]}if(ki.includes(l))return;e[l]=c,e=e[l]}};const Pc=v.createContext(null);Pc.displayName="HookFormControlContext";const Ci=()=>v.useContext(Pc);var Ec=(e,t,n,r=!0)=>{const a={};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return t._proxyFormState[o]!==kt.all&&(t._proxyFormState[o]=!r||kt.all),n&&(n[o]=!0),e[o]}});return a};const Ai=Us?v.useLayoutEffect:v.useEffect;function yf(e){const t=Ci(),{control:n=t,disabled:r,name:a,exact:i}=e||{},[o,l]=v.useState(()=>({...n._formState,defaultValues:n._defaultValues})),c=v.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Ai(()=>n._subscribe({name:a,formState:c.current,exact:i,callback:d=>{!r&&l({...n._formState,...d,defaultValues:n._defaultValues})}}),[a,r,i]),v.useEffect(()=>{c.current.isValid&&n._setValid(!0)},[n]),v.useMemo(()=>Ec(o,n,c.current,!1),[o,n])}var Ke=e=>typeof e=="string",Ua=(e,t,n,r,a)=>Ke(e)?(r&&t.watch.add(e),q(n,e,a)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),q(n,i))):(r&&(t.watchAll=!0),n),Za=e=>Ue(e)||!Si(e);const Po=(e,t)=>t.length===0&&!Array.isArray(e)&&!Cc(e);function ut(e,t,n=new WeakMap){if(e===t)return!0;if(Za(e)||Za(t))return Object.is(e,t);if(hn(e)&&hn(t))return Object.is(e.getTime(),t.getTime());const r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;if(Po(e,r)||Po(t,a))return Object.is(e,t);if(!r.length&&Array.isArray(e)!==Array.isArray(t))return!1;const i=n.get(e);if(i&&i.has(t))return!0;if(i)i.add(t);else{const o=new WeakSet;o.add(t),n.set(e,o)}for(const o of r){const l=e[o];if(!(o in t))return!1;if(o!=="ref"){const c=t[o];if(hn(l)&&hn(c)||(Pe(l)||Array.isArray(l))&&(Pe(c)||Array.isArray(c))?!ut(l,c,n):!Object.is(l,c))return!1}}return!0}function bf(e){const t=Ci(),{control:n=t,name:r,defaultValue:a,disabled:i,exact:o,compute:l}=e||{},c=v.useRef(a),d=v.useRef(l),u=v.useRef(void 0),m=v.useRef(n),h=v.useRef(r);d.current=l;const[p,y]=v.useState(()=>{const S=n._getWatch(r,c.current);return d.current?d.current(S):S}),x=v.useCallback(S=>{const I=Ua(r,n._names,S||n._formValues,!1,c.current);return d.current?d.current(I):I},[n._formValues,n._names,r]),j=v.useCallback(S=>{if(!i){const I=Ua(r,n._names,S||n._formValues,!1,c.current);if(d.current){const R=d.current(I);ut(R,u.current)||(y(R),u.current=R)}else y(I)}},[n._formValues,n._names,i,r]);Ai(()=>((m.current!==n||!ut(h.current,r))&&(m.current=n,h.current=r,j()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:S=>{j(S.values)}})),[n,o,r,j]),v.useEffect(()=>n._removeUnmounted());const g=m.current!==n,C=h.current,b=v.useMemo(()=>{if(i)return null;const S=!g&&!ut(C,r);return g||S?x():null},[i,g,r,C,x]);return b!==null?b:p}function vf(e){const t=Ci(),{name:n,disabled:r,control:a=t,shouldUnregister:i,defaultValue:o,exact:l=!0}=e,c=kc(a._names.array,n),d=v.useMemo(()=>q(a._formValues,n,q(a._defaultValues,n,o)),[a,n,o]),u=bf({control:a,name:n,defaultValue:d,exact:l}),m=yf({control:a,name:n,exact:l}),h=v.useRef(e),p=v.useRef(null),y=v.useRef(a.register(n,{...e.rules,value:u,...ct(e.disabled)?{disabled:e.disabled}:{}}));h.current=e;const x=v.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!q(m.errors,n)},isDirty:{enumerable:!0,get:()=>!!q(m.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!q(m.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!q(m.validatingFields,n)},error:{enumerable:!0,get:()=>q(m.errors,n)}}),[m,n]),j=v.useCallback(S=>{const I=Va(S);return q(a._fields,n)||(y.current=a.register(n,{...h.current.rules,value:I})),y.current.onChange({target:{value:Va(S),name:n},type:nn.CHANGE})},[n,a]),g=v.useCallback(()=>y.current.onBlur({target:{value:q(a._formValues,n),name:n},type:nn.BLUR}),[n,a._formValues]),C=v.useCallback(S=>{S&&(p.current={focus:()=>He(S.focus)&&S.focus(),select:()=>He(S.select)&&S.select(),setCustomValidity:R=>He(S.setCustomValidity)&&S.setCustomValidity(R),reportValidity:()=>He(S.reportValidity)&&S.reportValidity()});const I=q(a._fields,n);I&&I._f&&S&&(I._f.ref=p.current)},[a._fields,n]),b=v.useMemo(()=>({name:n,value:u,...ct(r)||m.disabled?{disabled:m.disabled||r}:{},onChange:j,onBlur:g,ref:C}),[n,r,m.disabled,j,g,C,u]);return v.useEffect(()=>{const S=a._options.shouldUnregister||i;a.register(n,{...h.current.rules,...ct(h.current.disabled)?{disabled:h.current.disabled}:{}});const I=(R,E)=>{const T=q(a._fields,R);T&&T._f&&(T._f.mount=E)};if(I(n,!0),S){const R=_e(q(i?a._defaultValues:a._options.values||a._defaultValues,n,q(a._options.defaultValues,n,h.current.defaultValue)));xe(a._defaultValues,n,R),je(q(a._formValues,n))&&xe(a._formValues,n,R)}if(!c&&a.register(n),p.current){const R=q(a._fields,n);R&&R._f&&(R._f.ref=p.current)}return()=>{(c?S&&!a._state.action:S)?a.unregister(n):I(n,!1)}},[n,a,c,i]),v.useEffect(()=>{a._setDisabledField({disabled:r,name:n})},[r,n,a]),v.useMemo(()=>({field:b,formState:m,fieldState:x}),[b,m,x])}const Ne=e=>e.render(vf(e)),Ic=e=>{const t={};for(const n of Object.keys(e))if(Si(e[n])&&e[n]!==null&&!hn(e[n])){const r=Ic(e[n]);for(const a of Object.keys(r))t[`${n}.${a}`]=r[a]}else t[n]=e[n];return t},jf=v.createContext(null);jf.displayName="HookFormContext";var Pi=(e,t,n,r,a)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:a||!0}}:{},Tc=e=>Array.isArray(e)?e.filter(Boolean):[],gs=e=>Array.isArray(e)?e:[e],Eo=()=>{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 _c(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const a=e[r],i=t[r];if(a&&Pe(a)&&i){const o=_c(a,i);Pe(o)&&(n[r]=o)}else e[r]&&(n[r]=i)}return n}var Ve=e=>Pe(e)&&!Object.keys(e).length,Ei=e=>e.type==="file",ks=e=>{if(!Us)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Fc=e=>e.type==="select-multiple",Ii=e=>e.type==="radio",wf=e=>Ii(e)||Wr(e),la=e=>ks(e)&&e.isConnected;function Nf(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;){if(Ue(e)){e=void 0;break}e=e[t[r]],r++}return e}function Sf(e){for(const t in e)if(e.hasOwnProperty(t)&&!je(e[t]))return!1;return!0}function Le(e,t){if(Ke(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;const n=Array.isArray(t)?t:Yr(t)?[t]:Zs(t);if(n.some(o=>ki.includes(String(o))))return e;const r=n.length===1?e:Nf(e,n),a=n.length-1,i=n[a];return r&&delete r[i],a!==0&&(Pe(r)&&Ve(r)||Array.isArray(r)&&Sf(r))&&Le(e,n.slice(0,-1)),e}var kf=e=>{for(const t in e)if(He(e[t]))return!0;return!1};function Dc(e){return Array.isArray(e)||Pe(e)&&!kf(e)}function Wa(e,t={}){for(const n in e){const r=e[n];Dc(r)?(t[n]=Array.isArray(r)?[]:{},Wa(r,t[n])):je(r)||(t[n]=!0)}return t}function Ya(e){if(e!==!1){if(e===!0)return!0;if(Array.isArray(e)){const t=e.map(n=>Ya(n));return t.some(n=>n!==void 0)?t:void 0}if(Pe(e)){const t={};for(const n in e){const r=Ya(e[n]);je(r)||(t[n]=r)}return Object.keys(t).length?t:void 0}}}function vn(e,t,n){n||(n=Wa(t));for(const r in e){const a=e[r];if(Dc(a))je(t)||Za(n[r])?n[r]=Wa(a,Array.isArray(a)?[]:{}):vn(a,Ue(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!ut(a,i)}}return Ya(n)||{}}const Io={value:!1,isValid:!1},To={value:!0,isValid:!0};var Rc=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!je(e[0].attributes.value)?je(e[0].value)||e[0].value===""?To:{value:e[0].value,isValid:!0}:To:Io}return Io},$c=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>je(e)?e:t?e===""?NaN:e&&+e:n&&Ke(e)?new Date(e):r?r(e):e;const _o={isValid:!1,value:null};var Lc=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,_o):_o;function Fo(e){const t=e.ref;return Ei(t)?t.files:Ii(t)?Lc(e.refs).value:Fc(t)?[...t.selectedOptions].map(({value:n})=>n):Wr(t)?Rc(e.refs).value:$c(je(t.value)?e.ref.value:t.value,e)}var Cf=(e,t,n,r)=>{const a={};for(const i of e){const o=q(t,i);o&&xe(a,i,o._f)}return{criteriaMode:n,names:[...e],fields:a,shouldUseNativeValidation:r}},Cs=e=>e instanceof RegExp,Sr=e=>je(e)?e:Cs(e)?e.source:Pe(e)?Cs(e.value)?e.value.source:e.value:e,ss=e=>({isOnSubmit:!e||e===kt.onSubmit,isOnBlur:e===kt.onBlur,isOnChange:e===kt.onChange,isOnAll:e===kt.all,isOnTouch:e===kt.onTouched});const Do="AsyncFunction";var Af=e=>{if(!e||!e.validate)return!1;if(He(e.validate))return e.validate.constructor.name===Do;if(Pe(e.validate)){for(const t in e.validate)if(e.validate[t].constructor.name===Do)return!0}return!1},Pf=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),ca=(e,t,n)=>{if(n)return!1;if(t.watchAll||t.watch.has(e))return!0;for(const r of t.watch)if(e.startsWith(r)&&e.charAt(r.length)===".")return!0;return!1};const Tr=(e,t,n,r)=>{for(const a of n||Object.keys(e)){const i=q(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],a)&&!r)return!0;if(o.ref&&t(o.ref,o.name)&&!r)return!0;if(Tr(l,t))break}else if(Pe(l)&&Tr(l,t))break}}};function Ro(e,t,n){const r=q(e,n);if(r||Yr(n))return{error:r,name:n};const a=n.split(".");for(;a.length;){const i=a.join("."),o=q(t,i),l=q(e,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};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:n}}var Ef=(e,t,n,r)=>{n(e);const{name:a,...i}=e,o=Object.keys(i);return!o.length||r&&o.length>=Object.keys(t).length||o.find(l=>t[l]===(!r||kt.all))},If=(e,t,n)=>!e||!t||e===t||gs(e).some(r=>r&&(n?r===t||r.startsWith(t+"."):r.startsWith(t)||t.startsWith(r))),Tf=(e,t,n,r,a)=>a.isOnAll?!1:!n&&a.isOnTouch?!(t||e):(n?r.isOnBlur:a.isOnBlur)?!e:(n?r.isOnChange:a.isOnChange)?e:!0,_f=(e,t)=>!Tc(q(e,t)).length&&Le(e,t),$o=(e,t,n)=>{const r=q(e,n),a=Array.isArray(r)?r:[];return xe(a,Ac,t[n]),xe(e,n,a),e};function Lo(e,t,n="validate"){if(Ke(e)||Array.isArray(e)&&e.every(Ke)||ct(e)&&!e)return{type:n,message:Ke(e)?e:"",ref:t}}var Vn=e=>Pe(e)&&!Cs(e)?e:{value:e,message:""},Oo=async(e,t,n,r,a,i)=>{const{ref:o,refs:l,required:c,maxLength:d,minLength:u,min:m,max:h,pattern:p,validate:y,name:x,valueAsNumber:j,mount:g}=e._f,C=q(n,x);if(!g||t.has(x))return{};const b=l?l[0]:o,S=X=>{if(a&&b.reportValidity){const Y=ct(X)?"":X||"";l?l.forEach(V=>V.setCustomValidity(Y)):b.setCustomValidity(Y),b.reportValidity()}},I={},R=Ii(o),E=Wr(o),T=R||E,L=(j||Ei(o))&&je(o.value)&&je(C)||ks(o)&&o.value===""||C===""||Array.isArray(C)&&!C.length,B=Pi.bind(null,x,r,I),K=(X,Y,V,Z=Nt.maxLength,ie=Nt.minLength)=>{const G=X?Y:V;I[x]={type:X?Z:ie,message:G,ref:o,...B(X?Z:ie,G)}};if(i?!Array.isArray(C)||!C.length:c&&(!T&&(L||Ue(C))||ct(C)&&!C||E&&!Rc(l).isValid||R&&!Lc(l).isValid)){const{value:X,message:Y}=Ke(c)?{value:!!c,message:c}:Vn(c);if(X&&(I[x]={type:Nt.required,message:Y,ref:b,...B(Nt.required,Y)},!r))return S(Y),I}if(!L&&(!Ue(m)||!Ue(h))){let X,Y;const V=Vn(h),Z=Vn(m);if(!Ue(C)&&!isNaN(C)){const ie=o.valueAsNumber||C&&+C;Ue(V.value)||(X=ie>V.value),Ue(Z.value)||(Y=ie<Z.value)}else{const ie=o.valueAsDate||new Date(C),G=Ae=>new Date(new Date().toDateString()+" "+Ae),Q=o.type=="time",we=o.type=="week";Ke(V.value)&&C&&(X=Q?G(C)>G(V.value):we?C>V.value:ie>new Date(V.value)),Ke(Z.value)&&C&&(Y=Q?G(C)<G(Z.value):we?C<Z.value:ie<new Date(Z.value))}if((X||Y)&&(K(!!X,V.message,Z.message,Nt.max,Nt.min),!r))return S(I[x].message),I}if((d||u)&&!L&&(Ke(C)||i&&Array.isArray(C))){const X=Vn(d),Y=Vn(u),V=!Ue(X.value)&&C.length>+X.value,Z=!Ue(Y.value)&&C.length<+Y.value;if((V||Z)&&(K(V,X.message,Y.message),!r))return S(I[x].message),I}if(p&&!L&&Ke(C)){const{value:X,message:Y}=Vn(p);if(Cs(X)&&!C.match(X)&&(I[x]={type:Nt.pattern,message:Y,ref:o,...B(Nt.pattern,Y)},!r))return S(Y),I}if(y){if(He(y)){const X=await y(C,n),Y=Lo(X,b);if(Y&&(I[x]={...Y,...B(Nt.validate,Y.message)},!r))return S(Y.message),I}else if(Pe(y)){let X={};for(const Y in y){if(!Ve(X)&&!r)break;const V=Lo(await y[Y](C,n),b,Y);V&&(X={...V,...B(Y,V.message)},S(V.message),r&&(I[x]=X))}if(!Ve(X)&&(I[x]={ref:b,...X},!r))return I}}return S(!0),I};const Ff={mode:kt.onSubmit,reValidateMode:kt.onChange,shouldFocusError:!0},ua="form",Oc={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function Df(e={}){let t={...Ff,...e},n={..._e(Oc),isLoading:He(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},r={},a=Pe(t.defaultValues)||Pe(t.values)?_e(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:_e(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,d=0,u=0,m=ss(t.mode),h=ss(t.reValidateMode);const p={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},y={...p};let x={...y};const j={array:Eo(),state:Eo()},g=t.criteriaMode===kt.all,C=f=>N=>{clearTimeout(d),d=setTimeout(f,N)},b=async f=>{if(!o.keepIsValid&&!t.disabled&&(y.isValid||x.isValid||f)){let N;t.resolver?(N=Ve((await Y()).errors),S()):N=await ie({fields:r,onlyCheckValid:!0,eventType:nn.VALID}),N!==n.isValid&&j.state.next({isValid:N})}},S=(f,N)=>{!t.disabled&&(y.isValidating||y.validatingFields||x.isValidating||x.validatingFields)&&((f||Array.from(l.mount)).forEach(A=>{A&&(N?xe(n.validatingFields,A,N):Le(n.validatingFields,A))}),j.state.next({validatingFields:n.validatingFields,isValidating:!Ve(n.validatingFields)}))},I=()=>{n.dirtyFields=vn(a,i)},R=(f,N=[],A,k,_=!0,W=!0)=>{if(k&&A&&!t.disabled){if(o.action=!0,W&&Array.isArray(q(r,f))){const z=A(q(r,f),k.argA,k.argB);_&&xe(r,f,z)}if(W&&Array.isArray(q(n.errors,f))){const z=A(q(n.errors,f),k.argA,k.argB);_&&xe(n.errors,f,z),_f(n.errors,f)}if((y.touchedFields||x.touchedFields)&&W&&Array.isArray(q(n.touchedFields,f))){const z=A(q(n.touchedFields,f),k.argA,k.argB);_&&xe(n.touchedFields,f,z)}(y.dirtyFields||x.dirtyFields)&&I(),j.state.next({name:f,isDirty:Q(f,N),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else xe(i,f,N)},E=(f,N)=>{xe(n.errors,f,N),n.errors={...n.errors},j.state.next({errors:n.errors})},T=f=>{n.errors=f,j.state.next({errors:n.errors,isValid:!1})},L=f=>{const N=Yr(f)?[f]:Zs(f);let A=i,k=a;for(let _=0;_<N.length-1;_++){const W=N[_];if(A=Ue(A)?A:A[W],k=Ue(k)?k:k[W],A===null&&k!==null)return!0}return!1},B=(f,N,A,k)=>{const _=q(r,f);if(_){if(L(f))return;const W=je(q(i,f)),z=q(i,f,je(A)?q(a,f):A);je(z)||k&&k.defaultChecked||N?xe(i,f,N?z:Fo(_._f)):$e(f,z),o.mount&&!o.action&&(b(),W&&n.isDirty&&(y.isDirty||x.isDirty)&&(Q()||(n.isDirty=!1,j.state.next({...n}))),e.shouldUnregister&&W&&!je(q(i,f))&&ca(f,l)&&(o.watch=!0))}},K=(f,N,A,k,_)=>{let W=!1,z=!1;const H={name:f};if(!t.disabled){if(!A||k){const M=ut(q(a,f),N);(y.isDirty||x.isDirty)&&(z=n.isDirty,n.isDirty=H.isDirty=!M||Q(),W=z!==H.isDirty),z=!!q(n.dirtyFields,f),M!==n.isDirty?n.dirtyFields=vn(a,i):M?Le(n.dirtyFields,f):xe(n.dirtyFields,f,!0),H.dirtyFields=n.dirtyFields,W=W||(y.dirtyFields||x.dirtyFields)&&z!==!M}if(A){const M=q(n.touchedFields,f);M||(xe(n.touchedFields,f,A),H.touchedFields=n.touchedFields,W=W||(y.touchedFields||x.touchedFields)&&M!==A)}W&&_&&j.state.next(H)}return W?H:{}},X=(f,N,A,k)=>{const _=q(n.errors,f),W=(y.isValid||x.isValid)&&ct(N)&&n.isValid!==N;if(t.delayError&&A?(c=C(()=>E(f,A)),c(t.delayError)):(clearTimeout(d),c=null,A?xe(n.errors,f,A):Le(n.errors,f),n.errors={...n.errors}),(A?!ut(_,A):_)||!Ve(k)||W){const z={...k,...W&&ct(N)?{isValid:N}:{},errors:n.errors,name:f};n={...n,...z},j.state.next(z)}},Y=async f=>(S(f,!0),await t.resolver(i,t.context,Cf(f||l.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),V=async f=>{const{errors:N}=await Y(f);if(S(f),f){for(const A of f){const k=q(N,A);k?l.array.has(A)&&Pe(k)&&!Object.keys(k).some(_=>!Number.isNaN(Number(_)))?$o(n.errors,{[A]:k},A):xe(n.errors,A,k):Le(n.errors,A)}n.errors={...n.errors}}else n.errors=N;return N},Z=async({name:f,eventType:N})=>{if(e.validate){const A=await e.validate({formValues:i,formState:n,name:f,eventType:N});if(Pe(A))for(const k in A){const _=A[k];_&&Oe(`${ua}.${k}`,{message:Ke(_.message)?_.message:"",type:_.type||Nt.validate})}else Ke(A)||!A?Oe(ua,{message:A||"",type:Nt.validate}):ve(ua);return A}return!0},ie=async({fields:f,onlyCheckValid:N,name:A,eventType:k,context:_={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(_.runRootValidation=!0,!await Z({name:A,eventType:k})&&(_.valid=!1,N)))return _.valid;for(const W in f){const z=f[W];if(z){const{_f:H,...M}=z;if(H){const ae=l.array.has(H.name),Me=z._f&&Af(z._f),Vt=y.validatingFields||y.isValidating||x.validatingFields||x.isValidating;Me&&Vt&&S([H.name],!0);const Ut=await Oo(z,l.disabled,i,g,t.shouldUseNativeValidation&&!N,ae);if(Me&&Vt&&S([H.name]),Ut[H.name]&&(_.valid=!1,N)||(!N&&(q(Ut,H.name)?ae?$o(n.errors,Ut,H.name):xe(n.errors,H.name,Ut[H.name]):Le(n.errors,H.name)),e.shouldUseNativeValidation&&Ut[H.name]))break}!Ve(M)&&await ie({context:_,onlyCheckValid:N,fields:M,name:W,eventType:k})}}return _.valid},G=()=>{for(const f of l.unMount){const N=q(r,f);N&&(N._f.refs?N._f.refs.every(A=>!la(A)):!la(N._f.ref))&&rt(f)}l.unMount=new Set},Q=(f,N)=>!t.disabled&&(f&&N&&xe(i,f,N),!ut(o.mount?i:a,a)),we=(f,N,A)=>Ua(f,l,{...o.mount?i:je(N)?a:Ke(f)?{[f]:N}:N},A,N),Ae=f=>Tc(q(o.mount?i:a,f,t.shouldUnregister?q(a,f,[]):[])),$e=(f,N,A={},k=!1,_=!1)=>{const W=q(r,f);let z=N;if(W){const H=W._f;H&&(!H.disabled&&xe(i,f,$c(N,H)),z=ks(H.ref)&&Ue(N)?"":N,Fc(H.ref)?[...H.ref.options].forEach(M=>M.selected=z.includes(M.value)):H.refs?Wr(H.ref)?H.refs.forEach(M=>{(!M.defaultChecked||!M.disabled)&&(Array.isArray(z)?M.checked=!!z.find(ae=>ae===M.value):M.checked=z===M.value||!!z)}):H.refs.forEach(M=>M.checked=M.value===z):Ei(H.ref)?H.ref.value="":(H.ref.value=z,!H.ref.type&&!_&&j.state.next({name:f,values:k?i:_e(i)})))}(A.shouldDirty||A.shouldTouch)&&K(f,z,A.shouldTouch,A.shouldDirty,!_),A.shouldValidate&&Te(f)},ce=(f,N,A,k=!1,_=!1)=>{for(const W in N){if(!N.hasOwnProperty(W))return;const z=N[W],H=f+"."+W,M=q(r,H);(l.array.has(f)||Pe(z)||M&&!M._f)&&!hn(z)?ce(H,z,A,k,_):$e(H,z,A,k,_)}},pe=(f,N,A,k,_=!1)=>{const W=q(r,f),z=l.array.has(f),H=k?N:_e(N),M=q(i,f),ae=ut(M,H);if(ae||xe(i,f,H),z)j.array.next({name:f,values:k?i:_e(i)}),(y.isDirty||y.dirtyFields||x.isDirty||x.dirtyFields)&&A.shouldDirty&&(I(),_||j.state.next({name:f,dirtyFields:n.dirtyFields,isDirty:Q(f,H)}));else{const Me=Array.isArray(H)&&!H.length||Ve(H);!W||W._f||Ue(H)||Me?$e(f,H,A,k,_):ce(f,H,A,k,_)}if(!ae&&!_){const Me=ca(f,l),Vt=k?i:_e(i);j.state.next({...Me&&n,name:o.mount||Me?f:void 0,values:Vt})}},$=(f,N,A={})=>pe(f,N,A,!1),fe=(f,N={})=>{const A=He(f)?f(i):f;if(!ut(i,A)){i={...i,...A};const k=Ic(A);for(const _ of l.mount)_ in k&&pe(_,k[_],N,!0,!0);j.state.next({...n,name:void 0,type:void 0,...u?{values:i}:{}}),N.shouldValidate&&b()}},O=async f=>{o.mount=!0;const N=f.target;let A=N.name,k=!0;const _=q(r,A),W=z=>{k=Number.isNaN(z)||hn(z)&&isNaN(z.getTime())||ut(z,q(i,A,z))};if(_){let z,H;const M=N.type?Fo(_._f):Va(f),ae=f.type===nn.BLUR||f.type===nn.FOCUS_OUT,Me=!Pf(_._f)&&!e.validate&&!t.resolver&&!q(n.errors,A)&&!_._f.deps,Vt=Me||Tf(ae,q(n.touchedFields,A),n.isSubmitted,h,m),Ut=ca(A,l,ae);xe(i,A,M),ae?(!N||!N.readOnly)&&(_._f.onBlur&&_._f.onBlur(f),c&&c(0)):_._f.onChange&&_._f.onChange(f);const jr=K(A,M,ae),dd=!Ve(jr)||Ut;if(!ae&&j.state.next({name:A,type:f.type,...u?{values:_e(i)}:{}}),Vt)return(!Me||!n.isValid)&&(y.isValid||x.isValid)&&(t.mode==="onBlur"?ae&&b():ae||b()),dd&&j.state.next({name:A,...Ut?{}:jr});if(!t.resolver&&e.validate&&await Z({name:A,eventType:f.type}),!ae&&Ut&&j.state.next({...n}),t.resolver){const{errors:oo}=await Y([A]);if(S([A]),W(M),!k){!Ve(jr)&&j.state.next(jr);return}const md=Ro(n.errors,r,A),lo=Ro(oo,r,md.name||A);z=lo.error,A=lo.name,H=Ve(oo)}else S([A],!0),z=(await Oo(_,l.disabled,i,g,t.shouldUseNativeValidation))[A],S([A]),W(M),k&&(z?H=!1:(y.isValid||x.isValid)&&(H=await ie({fields:r,onlyCheckValid:!0,name:A,eventType:f.type})));k&&(_._f.deps&&(!Array.isArray(_._f.deps)||_._f.deps.length>0)&&Te(_._f.deps),X(A,H,z,jr))}},ue=(f,N)=>{if(q(n.errors,N)&&f.focus)return f.focus(),1},Te=async(f,N={})=>{let A,k;const _=gs(f);if(t.resolver){const W=await V(je(f)?f:_);A=Ve(W),k=f?!_.some(z=>q(W,z)):A}else f?(k=(await Promise.all(_.map(async W=>{const z=q(r,W);return await ie({fields:z&&z._f?{[W]:z}:z,eventType:nn.TRIGGER})}))).every(Boolean),!(!k&&!n.isValid)&&b()):k=A=await ie({fields:r,name:f,eventType:nn.TRIGGER});return j.state.next({...!Ke(f)||(y.isValid||x.isValid)&&A!==n.isValid?{}:{name:f},...t.resolver||!f?{isValid:A}:{},errors:n.errors}),N.shouldFocus&&!k&&Tr(r,ue,f?_:l.mount),k},Je=(f,N)=>{let A={...o.mount?i:a};return N&&(A=_c(N.dirtyFields?n.dirtyFields:n.touchedFields,A)),je(f)?A:Ke(f)?q(A,f):f.map(k=>q(A,k))},oe=(f,N)=>({invalid:!!q((N||n).errors,f),isDirty:!!q((N||n).dirtyFields,f),error:q((N||n).errors,f),isValidating:!!q(n.validatingFields,f),isTouched:!!q((N||n).touchedFields,f)}),ve=f=>{const N=f?gs(f):void 0;N==null||N.forEach(A=>Le(n.errors,A)),N?N.forEach(A=>{j.state.next({name:A,errors:n.errors})}):j.state.next({errors:{}})},Oe=(f,N,A)=>{const k=(q(r,f,{_f:{}})._f||{}).ref,_=q(n.errors,f)||{},{ref:W,message:z,type:H,...M}=_;xe(n.errors,f,{...M,...N,ref:k}),j.state.next({name:f,errors:n.errors,isValid:!1}),A&&A.shouldFocus&&k&&k.focus&&k.focus()},We=(f,N)=>{if(He(f)){u++;const{unsubscribe:A}=j.state.subscribe({next:_=>"values"in _&&f(_.values||we(void 0,N),_)});let k=!1;return{unsubscribe:()=>{k||(k=!0,u--,A())}}}return we(f,N,!0)},re=f=>{var N;const A=!!(!((N=f.formState)===null||N===void 0)&&N.values);A&&u++;const{unsubscribe:k}=j.state.subscribe({next:W=>{if(If(f.name,W.name,f.exact)&&Ef(W,f.formState||y,It,f.reRenderRoot)){const z={...i};f.callback({values:z,...n,...W,defaultValues:a})}}});if(!A)return k;let _=!1;return()=>{_||(_=!0,u--,k())}},nt=f=>(o.mount=!0,x={...x,...f.formState},re({...f,formState:{...p,...f.formState}})),rt=(f,N={})=>{for(const A of f?gs(f):l.mount)l.mount.delete(A),l.array.delete(A),N.keepValue||(Le(r,A),Le(i,A)),!N.keepError&&Le(n.errors,A),!N.keepDirty&&Le(n.dirtyFields,A),!N.keepTouched&&Le(n.touchedFields,A),!N.keepIsValidating&&Le(n.validatingFields,A),!t.shouldUnregister&&!N.keepDefaultValue&&Le(a,A);j.state.next({values:_e(i)}),j.state.next({...n,...N.keepDirty?{isDirty:Q()}:{}}),!N.keepIsValid&&b()},bt=({disabled:f,name:N})=>{if(ct(f)&&o.mount||f||l.disabled.has(N)){const _=l.disabled.has(N)!==!!f;f?l.disabled.add(N):l.disabled.delete(N),_&&o.mount&&!o.action&&b()}},pt=(f,N={})=>{let A=q(r,f);const k=ct(N.disabled)||ct(t.disabled),_=!l.registerName.has(f)&&A&&A._f&&!A._f.mount;return xe(r,f,{...A||{},_f:{...A&&A._f?A._f:{ref:{name:f}},name:f,mount:!0,...N}}),l.mount.add(f),A&&!_?bt({disabled:ct(N.disabled)?N.disabled:t.disabled,name:f}):B(f,!0,N.value),{...k?{disabled:N.disabled||t.disabled}:{},...t.progressive?{required:!!N.required,min:Sr(N.min),max:Sr(N.max),minLength:Sr(N.minLength),maxLength:Sr(N.maxLength),pattern:Sr(N.pattern)}:{},name:f,onChange:O,onBlur:O,ref:W=>{if(W){l.registerName.add(f),pt(f,N),l.registerName.delete(f),A=q(r,f);const z=je(W.value)&&W.querySelectorAll&&W.querySelectorAll("input,select,textarea")[0]||W,H=wf(z),M=A._f.refs||[];if(H?M.find(ae=>ae===z):z===A._f.ref)return;xe(r,f,{_f:{...A._f,...H?{refs:[...M.filter(la),z,...Array.isArray(q(a,f))?[{}]:[]],ref:{type:z.type,name:f}}:{ref:z}}}),B(f,!1,void 0,z)}else A=q(r,f,{}),A._f&&(A._f.mount=!1),(t.shouldUnregister||N.shouldUnregister)&&!(kc(l.array,f)&&o.action)&&l.unMount.add(f)}}},vt=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&Tr(r,ue,l.mount),zt=f=>{ct(f)&&(j.state.next({disabled:f}),Tr(r,(N,A)=>{const k=q(r,A);k&&(N.disabled=k._f.disabled||f,Array.isArray(k._f.refs)&&k._f.refs.forEach(_=>{_.disabled=k._f.disabled||f}))},0,!1))},jt=(f,N)=>async A=>{let k;A&&(A.preventDefault&&A.preventDefault(),A.persist&&A.persist());let _=_e(i);if(j.state.next({isSubmitting:!0}),t.resolver){const{errors:W,values:z}=await Y();S(),n.errors=W,_=_e(z)}else await ie({fields:r,eventType:nn.SUBMIT});if(l.disabled.size)for(const W of l.disabled)Le(_,W);if(Le(n.errors,Ac),Ve(n.errors)){j.state.next({errors:{}});try{await f(_,A)}catch(W){k=W}}else N&&await N({...n.errors},A),vt(),setTimeout(vt);if(j.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Ve(n.errors)&&!k,submitCount:n.submitCount+1,errors:n.errors}),k)throw k},Mt=(f,N={})=>{q(r,f)&&(je(N.defaultValue)?$(f,_e(q(a,f))):($(f,N.defaultValue),xe(a,f,_e(N.defaultValue))),N.keepTouched||Le(n.touchedFields,f),N.keepDirty||(Le(n.dirtyFields,f),n.isDirty=N.defaultValue?Q(f,_e(q(a,f))):Q()),N.keepError||(Le(n.errors,f),y.isValid&&b()),j.state.next({...n}))},At=(f,N={})=>{const A=f?_e(f):a,k=_e(A),_=Ve(f),W=k;if(N.keepDefaultValues||(a=A),!N.keepValues){if(N.keepDirtyValues){const z=new Set([...l.mount,...Object.keys(vn(a,i))]);for(const H of Array.from(z)){const M=q(n.dirtyFields,H),ae=q(i,H),Me=q(W,H);M&&!je(ae)?xe(W,H,ae):!M&&!je(Me)&&$(H,Me)}}else{if(Us&&je(f))for(const z of l.mount){const H=q(r,z);if(H&&H._f){const M=Array.isArray(H._f.refs)?H._f.refs[0]:H._f.ref;if(ks(M)){const ae=M.closest("form");if(ae){ae.reset();break}}}}if(N.keepFieldsRef)for(const z of l.mount)$(z,q(W,z));else r={}}if(t.shouldUnregister){if(i=N.keepDefaultValues?_e(a):{},N.keepFieldsRef)for(const z of l.mount)xe(i,z,q(W,z))}else i=_e(W);j.array.next({values:{...W}}),j.state.next({name:void 0,type:void 0,values:{...W}})}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&&!Ve(W),o.watch=!!t.shouldUnregister,o.keepIsValid=!!N.keepIsValid,o.action=!1,N.keepErrors||(n.errors={}),j.state.next({submitCount:N.keepSubmitCount?n.submitCount:0,isDirty:_?!1:N.keepDirty?n.isDirty:N.keepValues?Q():!!(N.keepDefaultValues&&!ut(f,a)),isSubmitted:N.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:_?{}:N.keepDirtyValues?N.keepDefaultValues&&i?vn(a,i):n.dirtyFields:N.keepDefaultValues&&f?vn(a,f):N.keepDirty?n.dirtyFields:{},touchedFields:N.keepTouched?n.touchedFields:{},errors:N.keepErrors?n.errors:{},isSubmitSuccessful:N.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},Pt=(f,N)=>At(He(f)?f(i):f,{...t.resetOptions,...N}),Et=(f,N={})=>{const A=q(r,f),k=A&&A._f;if(k){const _=k.refs?k.refs[0]:k.ref;_.focus&&setTimeout(()=>{_.focus(),N.shouldSelect&&He(_.select)&&_.select()})}},It=f=>{const{name:N,type:A,values:k,..._}=f;n={...n,..._}},wt={control:{register:pt,unregister:rt,getFieldState:oe,handleSubmit:jt,setError:Oe,_subscribe:re,_runSchema:Y,_updateIsValidating:S,_focusError:vt,_getWatch:we,_getDirty:Q,_setValid:b,_setFieldArray:R,_setDisabledField:bt,_setErrors:T,_getFieldArray:Ae,_reset:At,_resetDefaultValues:()=>He(t.defaultValues)&&t.defaultValues().then(f=>{Pt(f,t.resetOptions),j.state.next({isLoading:!1})}),_removeUnmounted:G,_disableForm:zt,_subjects:j,_proxyFormState:y,get _fields(){return r},get _formValues(){return i},get _state(){return o},set _state(f){o=f},get _defaultValues(){return a},get _names(){return l},set _names(f){l=f},get _formState(){return n},get _options(){return t},set _options(f){t={...t,...f},m=ss(t.mode),h=ss(t.reValidateMode)}},subscribe:nt,trigger:Te,register:pt,handleSubmit:jt,watch:We,setValue:$,setValues:fe,getValues:Je,reset:Pt,resetField:Mt,resetDefaultValues:(f,N={})=>{if(a=_e(f),!N.keepDirty){const A=vn(a,i);n.dirtyFields=A,n.isDirty=!Ve(A)}N.keepIsValid||b(),j.state.next({...n,defaultValues:a})},clearErrors:ve,unregister:rt,setError:Oe,setFocus:Et,getFieldState:oe};return{...wt,formControl:wt}}function Rt(e={}){const t=v.useRef(void 0),n=v.useRef(void 0),r=v.useRef(e.formControl),[a,i]=v.useState(()=>({..._e(Oc),isLoading:He(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:He(e.defaultValues)?void 0:e.defaultValues}));if(!t.current||e.formControl&&r.current!==e.formControl)if(r.current=e.formControl,e.formControl)t.current={...e.formControl,formState:a},e.defaultValues&&!He(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...c}=Df(e);t.current={...c,formState:a}}const o=t.current.control;return o._options=e,Ai(()=>{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]),v.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),v.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),v.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),v.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),v.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==a.isDirty&&o._subjects.state.next({isDirty:l})}},[o,a.isDirty]),v.useEffect(()=>{var l;e.values&&!ut(e.values,n.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((l=o._options.resetOptions)===null||l===void 0)&&l.keepIsValid||o._setValid(),n.current=e.values,i(c=>({...c}))):o._resetDefaultValues()},[o,e.values]),v.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=v.useMemo(()=>Ec(a,o),[o,a]),t.current}const zo=(e,t,n)=>{if(e&&"reportValidity"in e){const r=q(n,t);e.setCustomValidity(r&&r.message||""),e.reportValidity()}},Ha=(e,t)=>{for(const n in t.fields){const r=t.fields[n];r&&r.ref&&"reportValidity"in r.ref?zo(r.ref,n,e):r&&r.refs&&r.refs.forEach(a=>zo(a,n,e))}},Mo=(e,t)=>{t.shouldUseNativeValidation&&Ha(e,t);const n={};for(const r in e){const a=q(t.fields,r),i=Object.assign(e[r]||{},{ref:a&&a.ref});if(Rf(t.names||Object.keys(e),r)){const o=Object.assign({},q(n,r));xe(o,"root",i),xe(n,r,o)}else xe(n,r,i)}return n},Rf=(e,t)=>{const n=qo(t).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(r=>qo(r).match(`^${n}\\.\\d+`))};function qo(e){return e.replace(/[\[\]]/g,"")}var Bo;function D(e,t,n){function r(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 d=o.prototype,u=Object.keys(d);for(let m=0;m<u.length;m++){const h=u[m];h in l||(l[h]=d[h].bind(l))}}const a=(n==null?void 0:n.Parent)??Object;class i extends a{}Object.defineProperty(i,"name",{value:e});function o(l){var c;const d=n!=null&&n.Parent?new i:this;r(d,l),(c=d._zod).deferred??(c.deferred=[]);for(const u of d._zod.deferred)u();return d}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:l=>{var c,d;return n!=null&&n.Parent&&l instanceof n.Parent?!0:(d=(c=l==null?void 0:l._zod)==null?void 0:c.traits)==null?void 0:d.has(e)}}),Object.defineProperty(o,"name",{value:e}),o}class Wn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class zc extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Bo=globalThis).__zod_globalConfig??(Bo.__zod_globalConfig={});const Ti=globalThis.__zod_globalConfig;function Dn(e){return Ti}function Mc(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,a])=>t.indexOf(+r)===-1).map(([r,a])=>a)}function Ka(e,t){return typeof t=="bigint"?t.toString():t}function _i(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Fi(e){return e==null}function Di(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const Vo=Symbol("evaluating");function be(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Vo)return r===void 0&&(r=Vo,r=n()),r},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function Mn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function gn(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Uo(e){return JSON.stringify(e)}function $f(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const qc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function As(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Lf=_i(()=>{var e;if(Ti.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 Rr(e){if(As(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(As(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Bc(e){return Rr(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Of=new Set(["string","number","symbol"]);function cr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yn(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function se(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 zf(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function Mf(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=gn(e._zod.def,{get shape(){const o={};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(o[l]=n.shape[l])}return Mn(this,"shape",o),o},checks:[]});return yn(e,i)}function qf(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=gn(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete o[l]}return Mn(this,"shape",o),o},checks:[]});return yn(e,i)}function Bf(e,t){if(!Rr(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.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=gn(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Mn(this,"shape",i),i}});return yn(e,a)}function Vf(e,t){if(!Rr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=gn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Mn(this,"shape",r),r}});return yn(e,n)}function Uf(e,t){var r;if((r=e._zod.def.checks)!=null&&r.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=gn(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Mn(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return yn(e,n)}function Zf(e,t,n){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=gn(t._zod.def,{get shape(){const l=t._zod.def.shape,c={...l};if(n)for(const d in n){if(!(d in l))throw new Error(`Unrecognized key: "${d}"`);n[d]&&(c[d]=e?new e({type:"optional",innerType:l[d]}):l[d])}else for(const d in l)c[d]=e?new e({type:"optional",innerType:l[d]}):l[d];return Mn(this,"shape",c),c},checks:[]});return yn(t,o)}function Wf(e,t,n){const r=gn(t._zod.def,{get shape(){const a=t._zod.def.shape,i={...a};if(n)for(const o in n){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);n[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 Mn(this,"shape",i),i}});return yn(t,r)}function Un(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function Yf(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0;return!1}function Vc(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function as(e){return typeof e=="string"?e:e==null?void 0:e.message}function Rn(e,t,n){var c,d,u,m,h,p;const r=e.message?e.message:as((u=(d=(c=e.inst)==null?void 0:c._zod.def)==null?void 0:d.error)==null?void 0:u.call(d,e))??as((m=t==null?void 0:t.error)==null?void 0:m.call(t,e))??as((h=n.customError)==null?void 0:h.call(n,e))??as((p=n.localeError)==null?void 0:p.call(n,e))??"Invalid input",{inst:a,continue:i,input:o,...l}=e;return l.path??(l.path=[]),l.message=r,t!=null&&t.reportInput&&(l.input=o),l}function Ri(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function $r(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Uc=(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,Ka,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},$i=D("$ZodError",Uc),Ws=D("$ZodError",Uc,{Parent:Error});function Hf(e,t=n=>n.message){const n={},r=[];for(const a of e.issues)a.path.length>0?(n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(t(a))):r.push(t(a));return{formErrors:r,fieldErrors:n}}function Kf(e,t=n=>n.message){const n={_errors:[]},r=(a,i=[])=>{for(const o of a.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(l=>r({issues:l},[...i,...o.path]));else if(o.code==="invalid_key")r({issues:o.issues},[...i,...o.path]);else if(o.code==="invalid_element")r({issues:o.issues},[...i,...o.path]);else{const l=[...i,...o.path];if(l.length===0)n._errors.push(t(o));else{let c=n,d=0;for(;d<l.length;){const u=l[d];d===l.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(o))):c[u]=c[u]||{_errors:[]},c=c[u],d++}}}};return r(e),n}const Ys=e=>(t,n,r,a)=>{const i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new Wn;if(o.issues.length){const l=new((a==null?void 0:a.Err)??e)(o.issues.map(c=>Rn(c,i,Dn())));throw qc(l,a==null?void 0:a.callee),l}return o.value},Qf=Ys(Ws),Hs=e=>async(t,n,r,a)=>{const i=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,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=>Rn(c,i,Dn())));throw qc(l,a==null?void 0:a.callee),l}return o.value},Jf=Hs(Ws),Ks=e=>(t,n,r)=>{const a=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},a);if(i instanceof Promise)throw new Wn;return i.issues.length?{success:!1,error:new(e??$i)(i.issues.map(o=>Rn(o,a,Dn())))}:{success:!0,data:i.value}},Gf=Ks(Ws),Qs=e=>async(t,n,r)=>{const a=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},a);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(o=>Rn(o,a,Dn())))}:{success:!0,data:i.value}},Xf=Qs(Ws),ep=e=>(t,n,r)=>{const a=r?{...r,direction:"backward"}:{direction:"backward"};return Ys(e)(t,n,a)},tp=e=>(t,n,r)=>Ys(e)(t,n,r),np=e=>async(t,n,r)=>{const a=r?{...r,direction:"backward"}:{direction:"backward"};return Hs(e)(t,n,a)},rp=e=>async(t,n,r)=>Hs(e)(t,n,r),sp=e=>(t,n,r)=>{const a=r?{...r,direction:"backward"}:{direction:"backward"};return Ks(e)(t,n,a)},ap=e=>(t,n,r)=>Ks(e)(t,n,r),ip=e=>async(t,n,r)=>{const a=r?{...r,direction:"backward"}:{direction:"backward"};return Qs(e)(t,n,a)},op=e=>async(t,n,r)=>Qs(e)(t,n,r),lp=/^[cC][0-9a-z]{6,}$/,cp=/^[0-9a-z]+$/,up=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,dp=/^[0-9a-vA-V]{20}$/,mp=/^[A-Za-z0-9]{27}$/,hp=/^[a-zA-Z0-9_-]{21}$/,fp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,pp=/^([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})$/,Zo=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)$/,xp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,gp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function yp(){return new RegExp(gp,"u")}const bp=/^(?:(?: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])$/,vp=/^(([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}|:))$/,jp=/^((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])$/,wp=/^(([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])$/,Np=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Zc=/^[A-Za-z0-9_-]*$/,Sp=/^https?$/,kp=/^\+[1-9]\d{6,14}$/,Wc="(?:(?:\\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])))",Cp=new RegExp(`^${Wc}$`);function Yc(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 Ap(e){return new RegExp(`^${Yc(e)}$`)}function Pp(e){const t=Yc({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Wc}T(?:${r})$`)}const Ep=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}$`)},Ip=/^(?:true|false)$/i,Tp=/^[^A-Z]*$/,_p=/^[^a-z]*$/,$t=D("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Fp=D("$ZodCheckMaxLength",(e,t)=>{var n;$t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!Fi(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const a=r.value;if(a.length<=t.maximum)return;const o=Ri(a);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),Dp=D("$ZodCheckMinLength",(e,t)=>{var n;$t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!Fi(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const a=r.value;if(a.length>=t.minimum)return;const o=Ri(a);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),Rp=D("$ZodCheckLengthEquals",(e,t)=>{var n;$t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!Fi(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=r=>{const a=r.value,i=a.length;if(i===t.length)return;const o=Ri(a),l=i>t.length;r.issues.push({origin:o,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Js=D("$ZodCheckStringFormat",(e,t)=>{var n,r;$t.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?(n=e._zod).check??(n.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})}):(r=e._zod).check??(r.check=()=>{})}),$p=D("$ZodCheckRegex",(e,t)=>{Js.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Lp=D("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Tp),Js.init(e,t)}),Op=D("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=_p),Js.init(e,t)}),zp=D("$ZodCheckIncludes",(e,t)=>{$t.init(e,t);const n=cr(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),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})}}),Mp=D("$ZodCheckStartsWith",(e,t)=>{$t.init(e,t);const n=new RegExp(`^${cr(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const a=r._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),qp=D("$ZodCheckEndsWith",(e,t)=>{$t.init(e,t);const n=new RegExp(`.*${cr(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const a=r._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Bp=D("$ZodCheckOverwrite",(e,t)=>{$t.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Vp{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 r=t.split(`
12
+ Please change the parent <Route path="${y}"> to <Route path="${y==="/"?"*":`${y}/*`}">.`)}let u=Se(),m;if(t){let y=typeof t=="string"?On(t):t;Ee(c==="/"||((b=y.pathname)==null?void 0:b.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 "${y.pathname}" was given in the \`location\` prop.`),m=y}else m=u;let h=m.pathname||"/",p=h;if(c!=="/"){let y=c.replace(/^\//,"").split("/");p="/"+h.replace(/^\//,"").split("/").slice(y.length).join("/")}let g=n&&n.state.matches.length?n.state.matches.map(y=>Object.assign(y,{route:n.manifest[y.route.id]||y.route})):zl(e,{pathname:p});dt(d||g!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),dt(g==null||g[g.length-1].route.element!==void 0||g[g.length-1].route.Component!==void 0||g[g.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.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=lm(g&&g.map(y=>Object.assign({},y,{params:Object.assign({},o,y.params),pathname:Ct([c,r.encodeLocation?r.encodeLocation(y.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?c:Ct([c,r.encodeLocation?r.encodeLocation(y.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathnameBase])})),a,n);return t&&x?P.createElement(Br.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...m},navigationType:"POP"}},x):x}function sm(){let e=hm(),t=Bd(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r},i={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",e),o=P.createElement(P.Fragment,null,P.createElement("p",null,"💿 Hey developer 👋"),P.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",P.createElement("code",{style:i},"ErrorBoundary")," or"," ",P.createElement("code",{style:i},"errorElement")," prop on your route.")),P.createElement(P.Fragment,null,P.createElement("h2",null,"Unexpected Application Error!"),P.createElement("h3",{style:{fontStyle:"italic"}},t),n?P.createElement("pre",{style:a},n):null,o)}var am=P.createElement(sm,null),tc=class extends P.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 n=Xd(e.digest);n&&(e=n)}let t=e!==void 0?P.createElement(gt.Provider,{value:this.props.routeContext},P.createElement(li.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?P.createElement(im,{error:e},t):t}};tc.contextType=Hl;var ia=new WeakMap;function im({children:e,error:t}){let{basename:n}=P.useContext(mt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=Gd(t.digest);if(r){let a=ia.get(t);if(a)throw a;let i=Wl(r.location,n),o=i.absoluteURL||i.to;if(Wd(o))throw new Error("Invalid redirect location");if(Zl&&!ia.get(t))if(i.isExternal||r.reloadDocument)window.location.href=o;else{const l=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:r.replace}));throw ia.set(t,l),l}return P.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o}`})}}return e}function om({routeContext:e,match:t,children:n}){let r=P.useContext(hr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),P.createElement(gt.Provider,{value:e},n)}function lm(e,t=[],n){let r=n==null?void 0:n.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let a=e,i=r==null?void 0:r.errors;if(i!=null){let u=a.findIndex(m=>m.route.id&&(i==null?void 0:i[m.route.id])!==void 0);Ee(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,u+1))}let o=!1,l=-1;if(n&&r){o=r.renderFallback;for(let u=0;u<a.length;u++){let m=a[u];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(l=u),m.route.id){let{loaderData:h,errors:p}=r,g=m.route.loader&&!h.hasOwnProperty(m.route.id)&&(!p||p[m.route.id]===void 0);if(m.route.lazy||g){n.isStatic&&(o=!0),l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}}let c=n==null?void 0:n.onError,d=r&&c?(u,m)=>{var h,p;c(u,{location:r.location,params:((p=(h=r.matches)==null?void 0:h[0])==null?void 0:p.params)??{},pattern:Vd(r.matches),errorInfo:m})}:void 0;return a.reduceRight((u,m,h)=>{let p,g=!1,x=null,b=null;r&&(p=i&&m.route.id?i[m.route.id]:void 0,x=m.route.errorElement||am,o&&(l<0&&h===0?(nc("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),g=!0,b=null):l===h&&(g=!0,b=m.route.hydrateFallbackElement||null)));let y=t.concat(a.slice(0,h+1)),C=()=>{let j;return p?j=x:g?j=b:m.route.Component?j=P.createElement(m.route.Component,null):m.route.element?j=m.route.element:j=u,P.createElement(om,{match:m,routeContext:{outlet:u,matches:y,isDataRoute:r!=null},children:j})};return r&&(m.route.ErrorBoundary||m.route.errorElement||h===0)?P.createElement(tc,{location:r.location,revalidation:r.revalidation,component:x,error:p,children:C(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:d}):C()},null)}function ci(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function cm(e){let t=P.useContext(hr);return Ee(t,ci(e)),t}function um(e){let t=P.useContext(Os);return Ee(t,ci(e)),t}function dm(e){let t=P.useContext(gt);return Ee(t,ci(e)),t}function ui(e){let t=dm(e),n=t.matches[t.matches.length-1];return Ee(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function mm(){return ui("useRouteId")}function hm(){var r;let e=P.useContext(li),t=um("useRouteError"),n=ui("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function fm(){let{router:e}=cm("useNavigate"),t=ui("useNavigate"),n=P.useRef(!1);return Gl(()=>{n.current=!0}),P.useCallback(async(a,i={})=>{dt(n.current,Jl),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...i}))},[e,t])}var po={};function nc(e,t,n){!t&&!po[e]&&(po[e]=!0,dt(!1,n))}P.memo(pm);function pm({routes:e,manifest:t,future:n,state:r,isStatic:a,onError:i}){return ec(e,void 0,{manifest:t,state:r,isStatic:a,onError:i})}function xm({basename:e,children:t,initialEntries:n,initialIndex:r,useTransitions:a}){let i=P.useRef();i.current==null&&(i.current=vd({initialEntries:n,initialIndex:r,v5Compat:!0}));let o=i.current,[l,c]=P.useState({action:o.action,location:o.location}),d=P.useCallback(u=>{a===!1?c(u):P.startTransition(()=>c(u))},[a]);return P.useLayoutEffect(()=>o.listen(d),[o,d]),P.createElement(ym,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:o,useTransitions:a})}function Be({to:e,replace:t,state:n,relative:r}){Ee(fr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=P.useContext(mt);dt(!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}=P.useContext(gt),{pathname:o}=Se(),l=ke(),c=Ls(e,oi(i),o,r==="path"),d=JSON.stringify(c);return P.useEffect(()=>{l(JSON.parse(d),{replace:t,state:n,relative:r})},[l,d,r,t,n]),null}function gm(e){return nm(e.context)}function te(e){Ee(!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 ym({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:i=!1,useTransitions:o}){Ee(!fr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=P.useMemo(()=>({basename:l,navigator:a,static:i,useTransitions:o,future:{}}),[l,a,i,o]);typeof n=="string"&&(n=On(n));let{pathname:d="/",search:u="",hash:m="",state:h=null,key:p="default",mask:g}=n,x=P.useMemo(()=>{let b=Gt(d,l);return b==null?null:{location:{pathname:b,search:u,hash:m,state:h,key:p,mask:g},navigationType:r}},[l,d,u,m,h,p,r,g]);return dt(x!=null,`<Router basename="${l}"> is not able to match the URL "${d}${u}${m}" because it does not start with the basename, so the <Router> won't render anything.`),x==null?null:P.createElement(mt.Provider,{value:c},P.createElement(Br.Provider,{children:t,value:x}))}function di({children:e,location:t}){return rm(Sa(e),t)}function Sa(e,t=[]){let n=[];return P.Children.forEach(e,(r,a)=>{if(!P.isValidElement(r))return;let i=[...t,a];if(r.type===P.Fragment){n.push.apply(n,Sa(r.props.children,i));return}Ee(r.type===te,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Ee(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=Sa(r.props.children,i)),n.push(o)}),n}var fs="get",ps="application/x-www-form-urlencoded";function Ms(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function bm(e){return Ms(e)&&e.tagName.toLowerCase()==="button"}function vm(e){return Ms(e)&&e.tagName.toLowerCase()==="form"}function jm(e){return Ms(e)&&e.tagName.toLowerCase()==="input"}function wm(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Nm(e,t){return e.button===0&&(!t||t==="_self")&&!wm(e)}function ka(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function Sm(e,t){let n=ka(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(i=>{n.append(a,i)})}),n}var ts=null;function km(){if(ts===null)try{new FormData(document.createElement("form"),0),ts=!1}catch{ts=!0}return ts}var Cm=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function oa(e){return e!=null&&!Cm.has(e)?(dt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ps}"`),null):e}function Am(e,t){let n,r,a,i,o;if(vm(e)){let l=e.getAttribute("action");r=l?Gt(l,t):null,n=e.getAttribute("method")||fs,a=oa(e.getAttribute("enctype"))||ps,i=new FormData(e)}else if(bm(e)||jm(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(r=c?Gt(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||fs,a=oa(e.getAttribute("formenctype"))||oa(l.getAttribute("enctype"))||ps,i=new FormData(l,e),!km()){let{name:d,type:u,value:m}=e;if(u==="image"){let h=d?`${d}.`:"";i.append(`${h}x`,"0"),i.append(`${h}y`,"0")}else d&&i.append(d,m)}}else{if(Ms(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=fs,r=null,a=ps,o=e}return i&&a==="text/plain"&&(o=i,i=void 0),{action:r,method:n.toLowerCase(),encType:a,formData:i,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function mi(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function rc(e,t,n,r){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${r}`:a.pathname=`${a.pathname}.${r}`:a.pathname==="/"?a.pathname=`_root.${r}`:t&&Gt(a.pathname,t)==="/"?a.pathname=`${js(t)}/_root.${r}`:a.pathname=`${js(a.pathname)}.${r}`,a}async function Pm(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Em(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 Im(e,t,n){let r=await Promise.all(e.map(async a=>{let i=t.routes[a.route.id];if(i){let o=await Pm(i,n);return o.links?o.links():[]}return[]}));return Fm(r.flat(1).filter(Em).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function xo(e,t,n,r,a,i){let o=(c,d)=>n[d]?c.route.id!==n[d].route.id:!0,l=(c,d)=>{var u;return n[d].pathname!==c.pathname||((u=n[d].route.path)==null?void 0:u.endsWith("*"))&&n[d].params["*"]!==c.params["*"]};return i==="assets"?t.filter((c,d)=>o(c,d)||l(c,d)):i==="data"?t.filter((c,d)=>{var m;let u=r.routes[c.route.id];if(!u||!u.hasLoader)return!1;if(o(c,d)||l(c,d))return!0;if(c.route.shouldRevalidate){let h=c.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((m=n[0])==null?void 0:m.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function Tm(e,t,{includeHydrateFallback:n}={}){return _m(e.map(r=>{let a=t.routes[r.route.id];if(!a)return[];let i=[a.module];return a.clientActionModule&&(i=i.concat(a.clientActionModule)),a.clientLoaderModule&&(i=i.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(i=i.concat(a.hydrateFallbackModule)),a.imports&&(i=i.concat(a.imports)),i}).flat(1))}function _m(e){return[...new Set(e)]}function Dm(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Fm(e,t){let n=new Set;return new Set(t),e.reduce((r,a)=>{let i=JSON.stringify(Dm(a));return n.has(i)||(n.add(i),r.push({key:i,link:a})),r},[])}function hi(){let e=P.useContext(hr);return mi(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Rm(){let e=P.useContext(Os);return mi(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var fi=P.createContext(void 0);fi.displayName="FrameworkContext";function qs(){let e=P.useContext(fi);return mi(e,"You must render this element inside a <HydratedRouter> element"),e}function $m(e,t){let n=P.useContext(fi),[r,a]=P.useState(!1),[i,o]=P.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:u,onTouchStart:m}=t,h=P.useRef(null);P.useEffect(()=>{if(e==="render"&&o(!0),e==="viewport"){let x=y=>{y.forEach(C=>{o(C.isIntersecting)})},b=new IntersectionObserver(x,{threshold:.5});return h.current&&b.observe(h.current),()=>{b.disconnect()}}},[e]),P.useEffect(()=>{if(r){let x=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(x)}}},[r]);let p=()=>{a(!0)},g=()=>{a(!1),o(!1)};return n?e!=="intent"?[i,h,{}]:[i,h,{onFocus:wr(l,p),onBlur:wr(c,g),onMouseEnter:wr(d,p),onMouseLeave:wr(u,g),onTouchStart:wr(m,p)}]:[!1,h,{}]}function wr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Lm({page:e,...t}){let n=Yd(),{nonce:r}=qs(),{router:a}=hi(),i=P.useMemo(()=>zl(a.routes,e,a.basename),[a.routes,e,a.basename]);return i?(t.nonce==null&&r&&(t={...t,nonce:r}),n?P.createElement(zm,{page:e,matches:i,...t}):P.createElement(Mm,{page:e,matches:i,...t})):null}function Om(e){let{manifest:t,routeModules:n}=qs(),[r,a]=P.useState([]);return P.useEffect(()=>{let i=!1;return Im(e,t,n).then(o=>{i||a(o)}),()=>{i=!0}},[e,t,n]),r}function zm({page:e,matches:t,...n}){let r=Se(),{future:a}=qs(),{basename:i}=hi(),o=P.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let l=rc(e,i,a.v8_trailingSlashAwareDataRequests,"rsc"),c=!1,d=[];for(let u of t)typeof u.route.shouldRevalidate=="function"?c=!0:d.push(u.route.id);return c&&d.length>0&&l.searchParams.set("_routes",d.join(",")),[l.pathname+l.search]},[i,a.v8_trailingSlashAwareDataRequests,e,r,t]);return P.createElement(P.Fragment,null,o.map(l=>P.createElement("link",{key:l,rel:"prefetch",as:"fetch",href:l,...n})))}function Mm({page:e,matches:t,...n}){let r=Se(),{future:a,manifest:i,routeModules:o}=qs(),{basename:l}=hi(),{loaderData:c,matches:d}=Rm(),u=P.useMemo(()=>xo(e,t,d,i,r,"data"),[e,t,d,i,r]),m=P.useMemo(()=>xo(e,t,d,i,r,"assets"),[e,t,d,i,r]),h=P.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let x=new Set,b=!1;if(t.forEach(C=>{var S;let j=i.routes[C.route.id];!j||!j.hasLoader||(!u.some(I=>I.route.id===C.route.id)&&C.route.id in c&&((S=o[C.route.id])!=null&&S.shouldRevalidate)||j.hasClientLoader?b=!0:x.add(C.route.id))}),x.size===0)return[];let y=rc(e,l,a.v8_trailingSlashAwareDataRequests,"data");return b&&x.size>0&&y.searchParams.set("_routes",t.filter(C=>x.has(C.route.id)).map(C=>C.route.id).join(",")),[y.pathname+y.search]},[l,a.v8_trailingSlashAwareDataRequests,c,r,i,u,t,e,o]),p=P.useMemo(()=>Tm(m,i),[m,i]),g=Om(m);return P.createElement(P.Fragment,null,h.map(x=>P.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),p.map(x=>P.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),g.map(({key:x,link:b})=>P.createElement("link",{key:x,nonce:n.nonce,...b,crossOrigin:b.crossOrigin??n.crossOrigin})))}function qm(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Bm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Bm&&(window.__reactRouterVersion="7.18.1")}catch{}var sc=P.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:a,reloadDocument:i,replace:o,mask:l,state:c,target:d,to:u,preventScrollReset:m,viewTransition:h,defaultShouldRevalidate:p,...g},x){let{basename:b,navigator:y,useTransitions:C}=P.useContext(mt),j=typeof u=="string"&&ii.test(u),S=Wl(u,b);u=S.to;let I=em(u,{relative:a}),R=Se(),E=null;if(l){let Z=Ls(l,[],R.mask?R.mask.pathname:"/",!0);b!=="/"&&(Z.pathname=Z.pathname==="/"?b:Ct([b,Z.pathname])),E=y.createHref(Z)}let[T,L,B]=$m(r,g),K=Wm(u,{replace:o,mask:l,state:c,target:d,preventScrollReset:m,relative:a,viewTransition:h,defaultShouldRevalidate:p,useTransitions:C});function X(Z){t&&t(Z),Z.defaultPrevented||K(Z)}let Y=!(S.isExternal||i),V=P.createElement("a",{...g,...B,href:(Y?E:void 0)||S.absoluteURL||I,onClick:Y?X:t,ref:qm(x,L),target:d,"data-discover":!j&&n==="render"?"true":void 0});return T&&!j?P.createElement(P.Fragment,null,V,P.createElement(Lm,{page:I})):V});sc.displayName="Link";var Vm=P.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:a=!1,style:i,to:o,viewTransition:l,children:c,...d},u){let m=Vr(o,{relative:d.relative}),h=Se(),p=P.useContext(Os),{navigator:g,basename:x}=P.useContext(mt),b=p!=null&&Gm(m)&&l===!0,y=g.encodeLocation?g.encodeLocation(m).pathname:m.pathname,C=h.pathname,j=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;n||(C=C.toLowerCase(),j=j?j.toLowerCase():null,y=y.toLowerCase()),j&&x&&(j=Gt(j,x)||j);const S=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let I=C===y||!a&&C.startsWith(y)&&C.charAt(S)==="/",R=j!=null&&(j===y||!a&&j.startsWith(y)&&j.charAt(y.length)==="/"),E={isActive:I,isPending:R,isTransitioning:b},T=I?t:void 0,L;typeof r=="function"?L=r(E):L=[r,I?"active":null,R?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let B=typeof i=="function"?i(E):i;return P.createElement(sc,{...d,"aria-current":T,className:L,ref:u,style:B,to:o,viewTransition:l},typeof c=="function"?c(E):c)});Vm.displayName="NavLink";var Um=P.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:a,state:i,method:o=fs,action:l,onSubmit:c,relative:d,preventScrollReset:u,viewTransition:m,defaultShouldRevalidate:h,...p},g)=>{let{useTransitions:x}=P.useContext(mt),b=Qm(),y=Jm(l,{relative:d}),C=o.toLowerCase()==="get"?"get":"post",j=typeof l=="string"&&ii.test(l),S=I=>{if(c&&c(I),I.defaultPrevented)return;I.preventDefault();let R=I.nativeEvent.submitter,E=(R==null?void 0:R.getAttribute("formmethod"))||o,T=()=>b(R||I.currentTarget,{fetcherKey:t,method:E,navigate:n,replace:a,state:i,relative:d,preventScrollReset:u,viewTransition:m,defaultShouldRevalidate:h});x&&n!==!1?P.startTransition(()=>T()):T()};return P.createElement("form",{ref:g,method:C,action:y,onSubmit:r?c:S,...p,"data-discover":!j&&e==="render"?"true":void 0})});Um.displayName="Form";function Zm(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ac(e){let t=P.useContext(hr);return Ee(t,Zm(e)),t}function Wm(e,{target:t,replace:n,mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c,useTransitions:d}={}){let u=ke(),m=Se(),h=Vr(e,{relative:o});return P.useCallback(p=>{if(Nm(p,t)){p.preventDefault();let g=n!==void 0?n:bs(m)===bs(h),x=()=>u(e,{replace:g,mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c});d?P.startTransition(()=>x()):x()}},[m,u,h,n,r,a,t,e,i,o,l,c,d])}function Ym(e){dt(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=P.useRef(ka(e)),n=P.useRef(!1),r=Se(),a=P.useMemo(()=>Sm(r.search,n.current?null:t.current),[r.search]),i=ke(),o=P.useCallback((l,c)=>{const d=ka(typeof l=="function"?l(new URLSearchParams(a)):l);n.current=!0,i("?"+d,c)},[i,a]);return[a,o]}var Hm=0,Km=()=>`__${String(++Hm)}__`;function Qm(){let{router:e}=ac("useSubmit"),{basename:t}=P.useContext(mt),n=mm(),r=e.fetch,a=e.navigate;return P.useCallback(async(i,o={})=>{let{action:l,method:c,encType:d,formData:u,body:m}=Am(i,t);if(o.navigate===!1){let h=o.fetcherKey||Km();await r(h,n,o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:u,body:m,formMethod:o.method||c,formEncType:o.encType||d,flushSync:o.flushSync})}else await a(o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:u,body:m,formMethod:o.method||c,formEncType:o.encType||d,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[r,a,t,n])}function Jm(e,{relative:t}={}){let{basename:n}=P.useContext(mt),r=P.useContext(gt);Ee(r,"useFormAction must be used inside a RouteContext");let[a]=r.matches.slice(-1),i={...Vr(e||".",{relative:t})},o=Se();if(e==null){i.search=o.search;let l=new URLSearchParams(i.search),c=l.getAll("index");if(c.some(u=>u==="")){l.delete("index"),c.filter(m=>m).forEach(m=>l.append("index",m));let u=l.toString();i.search=u?`?${u}`:""}}return(!e||e===".")&&a.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(i.pathname=i.pathname==="/"?n:Ct([n,i.pathname])),bs(i)}function Gm(e,{relative:t}={}){let n=P.useContext(Kl);Ee(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=ac("useViewTransitionState"),a=Vr(e,{relative:t});if(!n.isTransitioning)return!1;let i=Gt(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Gt(n.nextLocation.pathname,r)||n.nextLocation.pathname;return vs(a.pathname,o)!=null||vs(a.pathname,i)!=null}var pr=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(){}},Nn,sn,Kn,Pl,Xm=(Pl=class extends pr{constructor(){super();ee(this,Nn);ee(this,sn);ee(this,Kn);U(this,Kn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){w(this,sn)||this.setEventListener(w(this,Kn))}onUnsubscribe(){var t;this.hasListeners()||((t=w(this,sn))==null||t.call(this),U(this,sn,void 0))}setEventListener(t){var n;U(this,Kn,t),(n=w(this,sn))==null||n.call(this),U(this,sn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){w(this,Nn)!==t&&(U(this,Nn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof w(this,Nn)=="boolean"?w(this,Nn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Nn=new WeakMap,sn=new WeakMap,Kn=new WeakMap,Pl),pi=new Xm,eh={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Tt,Sn,El,th=(El=class{constructor(){ee(this,Tt,eh);ee(this,Sn,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&w(this,Sn)&&e!==w(this,Tt)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:w(this,Tt),provider:e}),U(this,Tt,e),process.env.NODE_ENV!=="production"&&U(this,Sn,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&U(this,Sn,!0),w(this,Tt).setTimeout(e,t)}clearTimeout(e){w(this,Tt).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&U(this,Sn,!0),w(this,Tt).setInterval(e,t)}clearInterval(e){w(this,Tt).clearInterval(e)}},Tt=new WeakMap,Sn=new WeakMap,El),jn=new th;function nh(e){setTimeout(e,0)}var rh=typeof window>"u"||"Deno"in globalThis;function tt(){}function sh(e,t){return typeof e=="function"?e(t):e}function Ca(e){return typeof e=="number"&&e>=0&&e!==1/0}function ic(e,t){return Math.max(e+(t||0)-Date.now(),0)}function pn(e,t){return typeof e=="function"?e(t):e}function lt(e,t){return typeof e=="function"?e(t):e}function go(e,t){const{type:n="all",exact:r,fetchStatus:a,predicate:i,queryKey:o,stale:l}=e;if(o){if(r){if(t.queryHash!==xi(o,t.options))return!1}else if(!_r(t.queryKey,o))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||a&&a!==t.state.fetchStatus||i&&!i(t))}function yo(e,t){const{exact:n,status:r,predicate:a,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Dn(t.options.mutationKey)!==Dn(i))return!1}else if(!_r(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||a&&!a(t))}function xi(e,t){return((t==null?void 0:t.queryKeyHashFn)||Dn)(e)}function Dn(e){return JSON.stringify(e,(t,n)=>Pa(n)?Object.keys(n).sort().reduce((r,a)=>(r[a]=n[a],r),{}):n)}function _r(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>_r(e[n],t[n])):!1}var ah=Object.prototype.hasOwnProperty;function Aa(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=bo(e)&&bo(t);if(!r&&!(Pa(e)&&Pa(t)))return t;const i=(r?e:Object.keys(e)).length,o=r?t:Object.keys(t),l=o.length,c=r?new Array(l):{};let d=0;for(let u=0;u<l;u++){const m=r?u:o[u],h=e[m],p=t[m];if(h===p){c[m]=h,(r?u<i:ah.call(e,m))&&d++;continue}if(h===null||p===null||typeof h!="object"||typeof p!="object"){c[m]=p;continue}const g=Aa(h,p,n+1);c[m]=g,g===h&&d++}return i===l&&d===i?e:c}function ws(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function bo(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Pa(e){if(!vo(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!vo(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function vo(e){return Object.prototype.toString.call(e)==="[object Object]"}function ih(e){return new Promise(t=>{jn.setTimeout(t,e)})}function Ea(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Aa(e,t)}catch(r){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. [${n.queryHash}]: ${r}`),r}return Aa(e,t)}return t}function oh(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function lh(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Ns=Symbol();function oc(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Ns&&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===Ns?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function gi(e,t){return typeof e=="function"?e(...t):!!e}function ch(e,t,n){let r=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),r||(r=!0,a.aborted?n():a.addEventListener("abort",n,{once:!0})),a)}),e}var Dr=(()=>{let e=()=>rh;return{isServer(){return e()},setIsServer(t){e=t}}})();function Ia(){let e,t;const n=new Promise((a,i)=>{e=a,t=i});n.status="pending",n.catch(()=>{});function r(a){Object.assign(n,a),delete n.resolve,delete n.reject}return n.resolve=a=>{r({status:"fulfilled",value:a}),e(a)},n.reject=a=>{r({status:"rejected",reason:a}),t(a)},n}var uh=nh;function dh(){let e=[],t=0,n=l=>{l()},r=l=>{l()},a=uh;const i=l=>{t?e.push(l):a(()=>{n(l)})},o=()=>{const l=e;e=[],l.length&&a(()=>{r(()=>{l.forEach(c=>{n(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=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{a=l}}}var ze=dh(),Qn,an,Jn,Il,mh=(Il=class extends pr{constructor(){super();ee(this,Qn,!0);ee(this,an);ee(this,Jn);U(this,Jn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){w(this,an)||this.setEventListener(w(this,Jn))}onUnsubscribe(){var t;this.hasListeners()||((t=w(this,an))==null||t.call(this),U(this,an,void 0))}setEventListener(t){var n;U(this,Jn,t),(n=w(this,an))==null||n.call(this),U(this,an,t(this.setOnline.bind(this)))}setOnline(t){w(this,Qn)!==t&&(U(this,Qn,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return w(this,Qn)}},Qn=new WeakMap,an=new WeakMap,Jn=new WeakMap,Il),Ss=new mh;function hh(e){return Math.min(1e3*2**e,3e4)}function lc(e){return(e??"online")==="online"?Ss.isOnline():!0}var Ta=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function cc(e){let t=!1,n=0,r;const a=Ia(),i=()=>a.status!=="pending",o=x=>{var b;if(!i()){const y=new Ta(x);h(y),(b=e.onCancel)==null||b.call(e,y)}},l=()=>{t=!0},c=()=>{t=!1},d=()=>pi.isFocused()&&(e.networkMode==="always"||Ss.isOnline())&&e.canRun(),u=()=>lc(e.networkMode)&&e.canRun(),m=x=>{i()||(r==null||r(),a.resolve(x))},h=x=>{i()||(r==null||r(),a.reject(x))},p=()=>new Promise(x=>{var b;r=y=>{(i()||d())&&x(y)},(b=e.onPause)==null||b.call(e)}).then(()=>{var x;r=void 0,i()||(x=e.onContinue)==null||x.call(e)}),g=()=>{if(i())return;let x;const b=n===0?e.initialPromise:void 0;try{x=b??e.fn()}catch(y){x=Promise.reject(y)}Promise.resolve(x).then(m).catch(y=>{var R;if(i())return;const C=e.retry??(Dr.isServer()?0:3),j=e.retryDelay??hh,S=typeof j=="function"?j(n,y):j,I=C===!0||typeof C=="number"&&n<C||typeof C=="function"&&C(n,y);if(t||!I){h(y);return}n++,(R=e.onFail)==null||R.call(e,n,y),ih(S).then(()=>d()?void 0:p()).then(()=>{t?h(y):g()})})};return{promise:a,status:()=>a.status,cancel:o,continue:()=>(r==null||r(),a),cancelRetry:l,continueRetry:c,canStart:u,start:()=>(u()?g():p().then(g),a)}}var kn,Tl,uc=(Tl=class{constructor(){ee(this,kn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ca(this.gcTime)&&U(this,kn,jn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Dr.isServer()?1/0:300*1e3))}clearGcTimeout(){w(this,kn)!==void 0&&(jn.clearTimeout(w(this,kn)),U(this,kn,void 0))}},kn=new WeakMap,Tl);function fh(e){return{onFetch:(t,n)=>{var u,m,h,p,g;const r=t.options,a=(h=(m=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:m.fetchMore)==null?void 0:h.direction,i=((p=t.state.data)==null?void 0:p.pages)||[],o=((g=t.state.data)==null?void 0:g.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const d=async()=>{let x=!1;const b=j=>{ch(j,()=>t.signal,()=>x=!0)},y=oc(t.options,t.fetchOptions),C=async(j,S,I)=>{if(x)return Promise.reject(t.signal.reason);if(S==null&&j.pages.length)return Promise.resolve(j);const E=(()=>{const K={client:t.client,queryKey:t.queryKey,pageParam:S,direction:I?"backward":"forward",meta:t.options.meta};return b(K),K})(),T=await y(E),{maxPages:L}=t.options,B=I?lh:oh;return{pages:B(j.pages,T,L),pageParams:B(j.pageParams,S,L)}};if(a&&i.length){const j=a==="backward",S=j?ph:jo,I={pages:i,pageParams:o},R=S(r,I);l=await C(I,R,j)}else{const j=e??i.length;do{const S=c===0?o[0]??r.initialPageParam:jo(r,l);if(c>0&&S==null)break;l=await C(l,S),c++}while(c<j)}return l};t.options.persister?t.fetchFn=()=>{var x,b;return(b=(x=t.options).persister)==null?void 0:b.call(x,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=d}}}function jo(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function ph(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var Gn,Cn,Xn,xt,An,qe,$r,Pn,ot,dc,Zt,_l,xh=(_l=class extends uc{constructor(t){super();ee(this,ot);ee(this,Gn);ee(this,Cn);ee(this,Xn);ee(this,xt);ee(this,An);ee(this,qe);ee(this,$r);ee(this,Pn);U(this,Pn,!1),U(this,$r,t.defaultOptions),this.setOptions(t.options),this.observers=[],U(this,An,t.client),U(this,xt,w(this,An).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,U(this,Cn,No(this.options)),this.state=t.state??w(this,Cn),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return w(this,Gn)}get promise(){var t;return(t=w(this,qe))==null?void 0:t.promise}setOptions(t){if(this.options={...w(this,$r),...t},t!=null&&t._type&&U(this,Gn,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=No(this.options);n.data!==void 0&&(this.setState(wo(n.data,n.dataUpdatedAt)),U(this,Cn,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&w(this,xt).remove(this)}setData(t,n){const r=Ea(this.state.data,t,this.options);return oe(this,ot,Zt).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t){oe(this,ot,Zt).call(this,{type:"setState",state:t})}cancel(t){var r,a;const n=(r=w(this,qe))==null?void 0:r.promise;return(a=w(this,qe))==null||a.cancel(t),n?n.then(tt).catch(tt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return w(this,Cn)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>lt(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ns||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>pn(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:!ic(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=w(this,qe))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=w(this,qe))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),w(this,xt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(w(this,qe)&&(w(this,Pn)||oe(this,ot,dc).call(this)?w(this,qe).cancel({revert:!0}):w(this,qe).cancelRetry()),this.scheduleGc()),w(this,xt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||oe(this,ot,Zt).call(this,{type:"invalidate"})}async fetch(t,n){var d,u,m,h,p,g,x,b,y,C,j;if(this.state.fetchStatus!=="idle"&&((d=w(this,qe))==null?void 0:d.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(w(this,qe))return w(this,qe).continueRetry(),w(this,qe).promise}if(t&&this.setOptions(t),!this.options.queryFn){const S=this.observers.find(I=>I.options.queryFn);S&&this.setOptions(S.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 r=new AbortController,a=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(U(this,Pn,!0),r.signal)})},i=()=>{const S=oc(this.options,n),R=(()=>{const E={client:w(this,An),queryKey:this.queryKey,meta:this.meta};return a(E),E})();return U(this,Pn,!1),this.options.persister?this.options.persister(S,R,this):S(R)},l=(()=>{const S={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:w(this,An),state:this.state,fetchFn:i};return a(S),S})(),c=w(this,Gn)==="infinite"?fh(this.options.pages):this.options.behavior;c==null||c.onFetch(l,this),U(this,Xn,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=l.fetchOptions)==null?void 0:u.meta))&&oe(this,ot,Zt).call(this,{type:"fetch",meta:(m=l.fetchOptions)==null?void 0:m.meta}),U(this,qe,cc({initialPromise:n==null?void 0:n.initialPromise,fn:l.fetchFn,onCancel:S=>{S instanceof Ta&&S.revert&&this.setState({...w(this,Xn),fetchStatus:"idle"}),r.abort()},onFail:(S,I)=>{oe(this,ot,Zt).call(this,{type:"failed",failureCount:S,error:I})},onPause:()=>{oe(this,ot,Zt).call(this,{type:"pause"})},onContinue:()=>{oe(this,ot,Zt).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const S=await w(this,qe).start();if(S===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(S),(p=(h=w(this,xt).config).onSuccess)==null||p.call(h,S,this),(x=(g=w(this,xt).config).onSettled)==null||x.call(g,S,this.state.error,this),S}catch(S){if(S instanceof Ta){if(S.silent)return w(this,qe).promise;if(S.revert){if(this.state.data===void 0)throw S;return this.state.data}}throw oe(this,ot,Zt).call(this,{type:"error",error:S}),(y=(b=w(this,xt).config).onError)==null||y.call(b,S,this),(j=(C=w(this,xt).config).onSettled)==null||j.call(C,this.state.data,S,this),S}finally{this.scheduleGc()}}},Gn=new WeakMap,Cn=new WeakMap,Xn=new WeakMap,xt=new WeakMap,An=new WeakMap,qe=new WeakMap,$r=new WeakMap,Pn=new WeakMap,ot=new WeakSet,dc=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Zt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...mc(r.data,this.options),fetchMeta:t.meta??null};case"success":const a={...r,...wo(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return U(this,Xn,t.manual?a:void 0),a;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),ze.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),w(this,xt).notify({query:this,type:"updated",action:t})})},_l);function mc(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:lc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function wo(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function No(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var st,me,Lr,et,En,er,Wt,on,Or,tr,nr,In,Tn,ln,rr,ye,Ar,_a,Da,Fa,Ra,$a,La,Oa,hc,Dl,gh=(Dl=class extends pr{constructor(t,n){super();ee(this,ye);ee(this,st);ee(this,me);ee(this,Lr);ee(this,et);ee(this,En);ee(this,er);ee(this,Wt);ee(this,on);ee(this,Or);ee(this,tr);ee(this,nr);ee(this,In);ee(this,Tn);ee(this,ln);ee(this,rr,new Set);this.options=n,U(this,st,t),U(this,on,null),U(this,Wt,Ia()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(w(this,me).addObserver(this),So(w(this,me),this.options)?oe(this,ye,Ar).call(this):this.updateResult(),oe(this,ye,Ra).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return za(w(this,me),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return za(w(this,me),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,oe(this,ye,$a).call(this),oe(this,ye,La).call(this),w(this,me).removeObserver(this)}setOptions(t){const n=this.options,r=w(this,me);if(this.options=w(this,st).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof lt(this.options.enabled,w(this,me))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");oe(this,ye,Oa).call(this),w(this,me).setOptions(this.options),n._defaulted&&!ws(this.options,n)&&w(this,st).getQueryCache().notify({type:"observerOptionsUpdated",query:w(this,me),observer:this});const a=this.hasListeners();a&&ko(w(this,me),r,this.options,n)&&oe(this,ye,Ar).call(this),this.updateResult(),a&&(w(this,me)!==r||lt(this.options.enabled,w(this,me))!==lt(n.enabled,w(this,me))||pn(this.options.staleTime,w(this,me))!==pn(n.staleTime,w(this,me)))&&oe(this,ye,_a).call(this);const i=oe(this,ye,Da).call(this);a&&(w(this,me)!==r||lt(this.options.enabled,w(this,me))!==lt(n.enabled,w(this,me))||i!==w(this,ln))&&oe(this,ye,Fa).call(this,i)}getOptimisticResult(t){const n=w(this,st).getQueryCache().build(w(this,st),t),r=this.createResult(n,t);return bh(this,r)&&(U(this,et,r),U(this,er,this.options),U(this,En,w(this,me).state)),r}getCurrentResult(){return w(this,et)}trackResult(t,n){return new Proxy(t,{get:(r,a)=>(this.trackProp(a),n==null||n(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&w(this,Wt).status==="pending"&&w(this,Wt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,a))})}trackProp(t){w(this,rr).add(t)}getCurrentQuery(){return w(this,me)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=w(this,st).defaultQueryOptions(t),r=w(this,st).getQueryCache().build(w(this,st),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return oe(this,ye,Ar).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),w(this,et)))}createResult(t,n){var L;const r=w(this,me),a=this.options,i=w(this,et),o=w(this,En),l=w(this,er),d=t!==r?t.state:w(this,Lr),{state:u}=t;let m={...u},h=!1,p;if(n._optimisticResults){const B=this.hasListeners(),K=!B&&So(t,n),X=B&&ko(t,r,n,a);(K||X)&&(m={...m,...mc(u.data,t.options)}),n._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:g,errorUpdatedAt:x,status:b}=m;p=m.data;let y=!1;if(n.placeholderData!==void 0&&p===void 0&&b==="pending"){let B;i!=null&&i.isPlaceholderData&&n.placeholderData===(l==null?void 0:l.placeholderData)?(B=i.data,y=!0):B=typeof n.placeholderData=="function"?n.placeholderData((L=w(this,nr))==null?void 0:L.state.data,w(this,nr)):n.placeholderData,B!==void 0&&(b="success",p=Ea(i==null?void 0:i.data,B,n),h=!0)}if(n.select&&p!==void 0&&!y)if(i&&p===(o==null?void 0:o.data)&&n.select===w(this,Or))p=w(this,tr);else try{U(this,Or,n.select),p=n.select(p),p=Ea(i==null?void 0:i.data,p,n),U(this,tr,p),U(this,on,null)}catch(B){U(this,on,B)}w(this,on)&&(g=w(this,on),p=w(this,tr),x=Date.now(),b="error");const C=m.fetchStatus==="fetching",j=b==="pending",S=b==="error",I=j&&C,R=p!==void 0,T={status:b,fetchStatus:m.fetchStatus,isPending:j,isSuccess:b==="success",isError:S,isInitialLoading:I,isLoading:I,data:p,dataUpdatedAt:m.dataUpdatedAt,error:g,errorUpdatedAt:x,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:m.dataUpdateCount>d.dataUpdateCount||m.errorUpdateCount>d.errorUpdateCount,isFetching:C,isRefetching:C&&!j,isLoadingError:S&&!R,isPaused:m.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:S&&R,isStale:yi(t,n),refetch:this.refetch,promise:w(this,Wt),isEnabled:lt(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const B=T.data!==void 0,K=T.status==="error"&&!B,X=Z=>{K?Z.reject(T.error):B&&Z.resolve(T.data)},Y=()=>{const Z=U(this,Wt,T.promise=Ia());X(Z)},V=w(this,Wt);switch(V.status){case"pending":t.queryHash===r.queryHash&&X(V);break;case"fulfilled":(K||T.data!==V.value)&&Y();break;case"rejected":(!K||T.error!==V.reason)&&Y();break}}return T}updateResult(){const t=w(this,et),n=this.createResult(w(this,me),this.options);if(U(this,En,w(this,me).state),U(this,er,this.options),w(this,En).data!==void 0&&U(this,nr,w(this,me)),ws(n,t))return;U(this,et,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!w(this,rr).size)return!0;const o=new Set(i??w(this,rr));return this.options.throwOnError&&o.add("error"),Object.keys(w(this,et)).some(l=>{const c=l;return w(this,et)[c]!==t[c]&&o.has(c)})};oe(this,ye,hc).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&oe(this,ye,Ra).call(this)}},st=new WeakMap,me=new WeakMap,Lr=new WeakMap,et=new WeakMap,En=new WeakMap,er=new WeakMap,Wt=new WeakMap,on=new WeakMap,Or=new WeakMap,tr=new WeakMap,nr=new WeakMap,In=new WeakMap,Tn=new WeakMap,ln=new WeakMap,rr=new WeakMap,ye=new WeakSet,Ar=function(t){oe(this,ye,Oa).call(this);let n=w(this,me).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(tt)),n},_a=function(){oe(this,ye,$a).call(this);const t=pn(this.options.staleTime,w(this,me));if(Dr.isServer()||w(this,et).isStale||!Ca(t))return;const r=ic(w(this,et).dataUpdatedAt,t)+1;U(this,In,jn.setTimeout(()=>{w(this,et).isStale||this.updateResult()},r))},Da=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(w(this,me)):this.options.refetchInterval)??!1},Fa=function(t){oe(this,ye,La).call(this),U(this,ln,t),!(Dr.isServer()||lt(this.options.enabled,w(this,me))===!1||!Ca(w(this,ln))||w(this,ln)===0)&&U(this,Tn,jn.setInterval(()=>{(this.options.refetchIntervalInBackground||pi.isFocused())&&oe(this,ye,Ar).call(this)},w(this,ln)))},Ra=function(){oe(this,ye,_a).call(this),oe(this,ye,Fa).call(this,oe(this,ye,Da).call(this))},$a=function(){w(this,In)!==void 0&&(jn.clearTimeout(w(this,In)),U(this,In,void 0))},La=function(){w(this,Tn)!==void 0&&(jn.clearInterval(w(this,Tn)),U(this,Tn,void 0))},Oa=function(){const t=w(this,st).getQueryCache().build(w(this,st),this.options);if(t===w(this,me))return;const n=w(this,me);U(this,me,t),U(this,Lr,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},hc=function(t){ze.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(w(this,et))}),w(this,st).getQueryCache().notify({query:w(this,me),type:"observerResultsUpdated"})})},Dl);function yh(e,t){return lt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&lt(t.retryOnMount,e)===!1)}function So(e,t){return yh(e,t)||e.state.data!==void 0&&za(e,t,t.refetchOnMount)}function za(e,t,n){if(lt(t.enabled,e)!==!1&&pn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&yi(e,t)}return!1}function ko(e,t,n,r){return(e!==t||lt(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&yi(e,n)}function yi(e,t){return lt(t.enabled,e)!==!1&&e.isStaleByTime(pn(t.staleTime,e))}function bh(e,t){return!ws(e.getCurrentResult(),t)}var zr,_t,He,_n,Dt,tn,Fl,vh=(Fl=class extends uc{constructor(t){super();ee(this,Dt);ee(this,zr);ee(this,_t);ee(this,He);ee(this,_n);U(this,zr,t.client),this.mutationId=t.mutationId,U(this,He,t.mutationCache),U(this,_t,[]),this.state=t.state||fc(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){w(this,_t).includes(t)||(w(this,_t).push(t),this.clearGcTimeout(),w(this,He).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){U(this,_t,w(this,_t).filter(n=>n!==t)),this.scheduleGc(),w(this,He).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){w(this,_t).length||(this.state.status==="pending"?this.scheduleGc():w(this,He).remove(this))}continue(){var t;return((t=w(this,_n))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,c,d,u,m,h,p,g,x,b,y,C,j,S,I,R,E;const n=()=>{oe(this,Dt,tn).call(this,{type:"continue"})},r={client:w(this,zr),meta:this.options.meta,mutationKey:this.options.mutationKey};U(this,_n,cc({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(T,L)=>{oe(this,Dt,tn).call(this,{type:"failed",failureCount:T,error:L})},onPause:()=>{oe(this,Dt,tn).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>w(this,He).canRun(this)}));const a=this.state.status==="pending",i=!w(this,_n).canStart();try{if(a)n();else{oe(this,Dt,tn).call(this,{type:"pending",variables:t,isPaused:i}),w(this,He).config.onMutate&&await w(this,He).config.onMutate(t,this,r);const L=await((l=(o=this.options).onMutate)==null?void 0:l.call(o,t,r));L!==this.state.context&&oe(this,Dt,tn).call(this,{type:"pending",context:L,variables:t,isPaused:i})}const T=await w(this,_n).start();return await((d=(c=w(this,He).config).onSuccess)==null?void 0:d.call(c,T,t,this.state.context,this,r)),await((m=(u=this.options).onSuccess)==null?void 0:m.call(u,T,t,this.state.context,r)),await((p=(h=w(this,He).config).onSettled)==null?void 0:p.call(h,T,null,this.state.variables,this.state.context,this,r)),await((x=(g=this.options).onSettled)==null?void 0:x.call(g,T,null,t,this.state.context,r)),oe(this,Dt,tn).call(this,{type:"success",data:T}),T}catch(T){try{await((y=(b=w(this,He).config).onError)==null?void 0:y.call(b,T,t,this.state.context,this,r))}catch(L){Promise.reject(L)}try{await((j=(C=this.options).onError)==null?void 0:j.call(C,T,t,this.state.context,r))}catch(L){Promise.reject(L)}try{await((I=(S=w(this,He).config).onSettled)==null?void 0:I.call(S,void 0,T,this.state.variables,this.state.context,this,r))}catch(L){Promise.reject(L)}try{await((E=(R=this.options).onSettled)==null?void 0:E.call(R,void 0,T,t,this.state.context,r))}catch(L){Promise.reject(L)}throw oe(this,Dt,tn).call(this,{type:"error",error:T}),T}finally{w(this,He).runNext(this)}}},zr=new WeakMap,_t=new WeakMap,He=new WeakMap,_n=new WeakMap,Dt=new WeakSet,tn=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,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{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),ze.batch(()=>{w(this,_t).forEach(r=>{r.onMutationUpdate(t)}),w(this,He).notify({mutation:this,type:"updated",action:t})})},Fl);function fc(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Yt,St,Mr,Rl,jh=(Rl=class extends pr{constructor(t={}){super();ee(this,Yt);ee(this,St);ee(this,Mr);this.config=t,U(this,Yt,new Set),U(this,St,new Map),U(this,Mr,0)}build(t,n,r){const a=new vh({client:t,mutationCache:this,mutationId:++es(this,Mr)._,options:t.defaultMutationOptions(n),state:r});return this.add(a),a}add(t){w(this,Yt).add(t);const n=ns(t);if(typeof n=="string"){const r=w(this,St).get(n);r?r.push(t):w(this,St).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(w(this,Yt).delete(t)){const n=ns(t);if(typeof n=="string"){const r=w(this,St).get(n);if(r)if(r.length>1){const a=r.indexOf(t);a!==-1&&r.splice(a,1)}else r[0]===t&&w(this,St).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=ns(t);if(typeof n=="string"){const r=w(this,St).get(n),a=r==null?void 0:r.find(i=>i.state.status==="pending");return!a||a===t}else return!0}runNext(t){var r;const n=ns(t);if(typeof n=="string"){const a=(r=w(this,St).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ze.batch(()=>{w(this,Yt).forEach(t=>{this.notify({type:"removed",mutation:t})}),w(this,Yt).clear(),w(this,St).clear()})}getAll(){return Array.from(w(this,Yt))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>yo(n,r))}findAll(t={}){return this.getAll().filter(n=>yo(t,n))}notify(t){ze.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return ze.batch(()=>Promise.all(t.map(n=>n.continue().catch(tt))))}},Yt=new WeakMap,St=new WeakMap,Mr=new WeakMap,Rl);function ns(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Ht,cn,at,Kt,Jt,xs,Ma,$l,wh=($l=class extends pr{constructor(t,n){super();ee(this,Jt);ee(this,Ht);ee(this,cn);ee(this,at);ee(this,Kt);U(this,Ht,t),this.setOptions(n),this.bindMethods(),oe(this,Jt,xs).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const n=this.options;this.options=w(this,Ht).defaultMutationOptions(t),ws(this.options,n)||w(this,Ht).getMutationCache().notify({type:"observerOptionsUpdated",mutation:w(this,at),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Dn(n.mutationKey)!==Dn(this.options.mutationKey)?this.reset():((r=w(this,at))==null?void 0:r.state.status)==="pending"&&w(this,at).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=w(this,at))==null||t.removeObserver(this)}onMutationUpdate(t){oe(this,Jt,xs).call(this),oe(this,Jt,Ma).call(this,t)}getCurrentResult(){return w(this,cn)}reset(){var t;(t=w(this,at))==null||t.removeObserver(this),U(this,at,void 0),oe(this,Jt,xs).call(this),oe(this,Jt,Ma).call(this)}mutate(t,n){var r;return U(this,Kt,n),(r=w(this,at))==null||r.removeObserver(this),U(this,at,w(this,Ht).getMutationCache().build(w(this,Ht),this.options)),w(this,at).addObserver(this),w(this,at).execute(t)}},Ht=new WeakMap,cn=new WeakMap,at=new WeakMap,Kt=new WeakMap,Jt=new WeakSet,xs=function(){var n;const t=((n=w(this,at))==null?void 0:n.state)??fc();U(this,cn,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Ma=function(t){ze.batch(()=>{var n,r,a,i,o,l,c,d;if(w(this,Kt)&&this.hasListeners()){const u=w(this,cn).variables,m=w(this,cn).context,h={client:w(this,Ht),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(r=(n=w(this,Kt)).onSuccess)==null||r.call(n,t.data,u,m,h)}catch(p){Promise.reject(p)}try{(i=(a=w(this,Kt)).onSettled)==null||i.call(a,t.data,null,u,m,h)}catch(p){Promise.reject(p)}}else if((t==null?void 0:t.type)==="error"){try{(l=(o=w(this,Kt)).onError)==null||l.call(o,t.error,u,m,h)}catch(p){Promise.reject(p)}try{(d=(c=w(this,Kt)).onSettled)==null||d.call(c,void 0,t.error,u,m,h)}catch(p){Promise.reject(p)}}}this.listeners.forEach(u=>{u(w(this,cn))})})},$l),Ft,Ll,Nh=(Ll=class extends pr{constructor(t={}){super();ee(this,Ft);this.config=t,U(this,Ft,new Map)}build(t,n,r){const a=n.queryKey,i=n.queryHash??xi(a,n);let o=this.get(i);return o||(o=new xh({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(a)}),this.add(o)),o}add(t){w(this,Ft).has(t.queryHash)||(w(this,Ft).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=w(this,Ft).get(t.queryHash);n&&(t.destroy(),n===t&&w(this,Ft).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ze.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return w(this,Ft).get(t)}getAll(){return[...w(this,Ft).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>go(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>go(t,r)):n}notify(t){ze.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){ze.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ze.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ft=new WeakMap,Ll),De,un,dn,sr,ar,mn,ir,or,Ol,Sh=(Ol=class{constructor(e={}){ee(this,De);ee(this,un);ee(this,dn);ee(this,sr);ee(this,ar);ee(this,mn);ee(this,ir);ee(this,or);U(this,De,e.queryCache||new Nh),U(this,un,e.mutationCache||new jh),U(this,dn,e.defaultOptions||{}),U(this,sr,new Map),U(this,ar,new Map),U(this,mn,0)}mount(){es(this,mn)._++,w(this,mn)===1&&(U(this,ir,pi.subscribe(async e=>{e&&(await this.resumePausedMutations(),w(this,De).onFocus())})),U(this,or,Ss.subscribe(async e=>{e&&(await this.resumePausedMutations(),w(this,De).onOnline())})))}unmount(){var e,t;es(this,mn)._--,w(this,mn)===0&&((e=w(this,ir))==null||e.call(this),U(this,ir,void 0),(t=w(this,or))==null||t.call(this),U(this,or,void 0))}isFetching(e){return w(this,De).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return w(this,un).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=w(this,De).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=w(this,De).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(pn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return w(this,De).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),a=w(this,De).get(r.queryHash),i=a==null?void 0:a.state.data,o=sh(t,i);if(o!==void 0)return w(this,De).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return ze.batch(()=>w(this,De).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=w(this,De).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=w(this,De);ze.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=w(this,De);return ze.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=ze.batch(()=>w(this,De).findAll(e).map(a=>a.cancel(n)));return Promise.all(r).then(tt).catch(tt)}invalidateQueries(e,t={}){return ze.batch(()=>(w(this,De).findAll(e).forEach(n=>{n.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 n={...t,cancelRefetch:t.cancelRefetch??!0},r=ze.batch(()=>w(this,De).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,n);return n.throwOnError||(i=i.catch(tt)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(tt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=w(this,De).build(this,t);return n.isStaleByTime(pn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(tt).catch(tt)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(tt).catch(tt)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return Ss.isOnline()?w(this,un).resumePausedMutations():Promise.resolve()}getQueryCache(){return w(this,De)}getMutationCache(){return w(this,un)}getDefaultOptions(){return w(this,dn)}setDefaultOptions(e){U(this,dn,e)}setQueryDefaults(e,t){w(this,sr).set(Dn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...w(this,sr).values()],n={};return t.forEach(r=>{_r(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){w(this,ar).set(Dn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...w(this,ar).values()],n={};return t.forEach(r=>{_r(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...w(this,dn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=xi(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===Ns&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...w(this,dn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){w(this,De).clear(),w(this,un).clear()}},De=new WeakMap,un=new WeakMap,dn=new WeakMap,sr=new WeakMap,ar=new WeakMap,mn=new WeakMap,ir=new WeakMap,or=new WeakMap,Ol),pc=P.createContext(void 0),ft=e=>{const t=P.useContext(pc);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},kh=({client:e,children:t})=>(P.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(pc.Provider,{value:e,children:t})),xc=P.createContext(!1),Ch=()=>P.useContext(xc);xc.Provider;function Ah(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Ph=P.createContext(Ah()),Eh=()=>P.useContext(Ph),Ih=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?gi(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Th=e=>{P.useEffect(()=>{e.clearReset()},[e])},_h=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(a&&e.data===void 0||gi(n,[e.error,r])),Dh=e=>{if(e.suspense){const n=a=>a==="static"?a:Math.max(a??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...a)=>n(r(...a)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Fh=(e,t)=>e.isLoading&&e.isFetching&&!t,Rh=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Co=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function $h(e,t,n){var p,g,x,b;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 r=Ch(),a=Eh(),i=ft(),o=i.defaultQueryOptions(e);(g=(p=i.getDefaultOptions().queries)==null?void 0:p._experimental_beforeQuery)==null||g.call(p,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=r?"isRestoring":c?"optimistic":void 0,Dh(o),Ih(o,a,l),Th(a);const d=!i.getQueryCache().get(o.queryHash),[u]=P.useState(()=>new t(i,o)),m=u.getOptimisticResult(o),h=!r&&c;if(P.useSyncExternalStore(P.useCallback(y=>{const C=h?u.subscribe(ze.batchCalls(y)):tt;return u.updateResult(),C},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),P.useEffect(()=>{u.setOptions(o)},[o,u]),Rh(o,m))throw Co(o,u,a);if(_h({result:m,errorResetBoundary:a,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw m.error;if((b=(x=i.getDefaultOptions().queries)==null?void 0:x._experimental_afterQuery)==null||b.call(x,o,m),o.experimental_prefetchInRender&&!Dr.isServer()&&Fh(m,r)){const y=d?Co(o,u,a):l==null?void 0:l.promise;y==null||y.catch(tt).finally(()=>{u.updateResult()})}return o.notifyOnChangeProps?m:u.trackResult(m)}function ge(e,t){return $h(e,gh)}function Lh(e,t){const n=ft(),[r]=P.useState(()=>new wh(n,e));P.useEffect(()=>{r.setOptions(e)},[r,e]);const a=P.useSyncExternalStore(P.useCallback(o=>r.subscribe(ze.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=P.useCallback((o,l)=>{r.mutate(o,l).catch(tt)},[r]);if(a.error&&gi(r.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}function gc(e){return e.trim().replace(/\/+$/,"")}const Bs=new Map;function yc(e,t){Bs.set(e,t)}function Oh(e){return Bs.get(e)}function zh(e){Bs.delete(e)}function Mh(e){for(const[t,n]of Bs)if(n.accessToken===e)return t}let qa=null;function bc(e){qa=gc(e)}let vc=null;function qh(e){vc=e}function Bh(){return vc}let jc=null;function Vh(e){jc=e.trim()}function Uh(){return jc}function Zh(){return qa!==null?qa:gc("")}const Ao={get apiBaseUrl(){return Zh()},apiVersion:"v1"};function Wh(e){const t=e.startsWith("/")?e:`/${e}`;return`${Ao.apiBaseUrl}/api/${Ao.apiVersion}${t}`}const wc="auth:session-expired";function Yh(){window.dispatchEvent(new CustomEvent(wc))}function Nc(e){return`${wc}:${e}`}const Hh=v.createContext(null);function Kh({instanceId:e,accessToken:t,onSessionExpired:n,children:r}){const a=Oh(e);return a&&yc(e,{...a,accessToken:t}),qh(t),v.useEffect(()=>{if(!n)return;const i=Nc(e),o=()=>n();return window.addEventListener(i,o),()=>window.removeEventListener(i,o)},[e,n]),s.jsx(Hh.Provider,{value:{accessToken:t},children:r})}class xr extends Error{constructor(n,r,a,i,o){super(a??r);jr(this,"status");jr(this,"title");jr(this,"details");jr(this,"extensions");this.name="ApiError",this.status=n,this.title=r,this.details=i,this.extensions=o}}const Sc="tax-remittance.auth";function Qh(){var t;const e=localStorage.getItem(Sc);if(!e)return null;try{const n=JSON.parse(e);return!n.accessToken||!((t=n.user)!=null&&t.userId)?null:new Date(n.user.expiresAt)<=new Date?(Ba(),null):n}catch{return Ba(),null}}function Ba(){localStorage.removeItem(Sc)}function Jh(){var e;return((e=Qh())==null?void 0:e.accessToken)??null}async function Gh(e){let t=null;try{t=await e.json()}catch{}const n=(t==null?void 0:t.title)??"Request failed",r=t==null?void 0:t.detail,a=t==null?void 0:t.errors;return new xr(e.status,n,r,a,t??void 0)}async function Ur(e,t={}){const{body:n,auth:r=!0,headers:a,responseType:i="json",...o}=t,l=new Headers(a);i==="blob"?l.set("Accept","application/pdf"):i==="text"?l.set("Accept","text/html"):l.set("Accept","application/json"),n!==void 0&&l.set("Content-Type","application/json");let c=null;if(r){const m=Bh()??Jh();m&&(c=m,l.set("Authorization",`Bearer ${m}`))}const d=Uh();d&&l.set("X-Client-ID",d);const u=await fetch(Wh(e),{...o,headers:l,body:n!==void 0?JSON.stringify(n):void 0});if(!u.ok){const m=await Gh(u);if(r&&m.status===401){Ba();const h=c?Mh(c):void 0;h?window.dispatchEvent(new CustomEvent(Nc(h))):Yh()}throw m}if(u.status!==204)return i==="blob"?await u.blob():i==="text"?await u.text():await u.json()}async function de(e,t={}){return(await Ur(e,t)).data}const it=10;function bi({search:e,pageNumber:t=1,pageSize:n=it}={}){const r=new URLSearchParams({pageNumber:String(t),pageSize:String(n)});return e!=null&&e.trim()&&r.set("search",e.trim()),de(`/portal/entities/mine?${r}`)}function Xh(e){return de("/portal/entities",{method:"POST",body:e})}function ef(e,t){return de(`/portal/entities/${e}`,{method:"PATCH",body:t})}const kc=v.createContext(null);function tf({onOrganizationCreated:e,enabledPayments:t=["federal","state"],onPaymentRequired:n,children:r}){var x;const[a,i]=v.useState(null),{data:o=[],isLoading:l,isError:c,refetch:d}=ge({queryKey:["entities","mine"],queryFn:async()=>(await bi({pageNumber:1,pageSize:100})).items}),u=v.useRef(new Set),m=v.useRef(!1);v.useEffect(()=>{if(l)return;if(!m.current){o.forEach(y=>u.current.add(y.entityId)),m.current=!0;return}o.filter(y=>!u.current.has(y.entityId)).forEach(y=>{u.current.add(y.entityId),e==null||e(y)})},[o,l,e]);const h=a!==null&&o.some(b=>b.entityId===a)?a:((x=o[0])==null?void 0:x.entityId)??null,p=o.find(b=>b.entityId===h)??null,g=async()=>{await d()};return s.jsx(kc.Provider,{value:{entities:o,isLoading:l,isError:c,selectedEntity:p,setSelectedEntityId:i,refetchEntities:g,enabledPayments:t,onPaymentRequired:n},children:r})}function zn(){const e=v.useContext(kc);if(!e)throw new Error("useEmbeddedContext must be used inside EmbeddedContextProvider");return e}const nf=v.createContext(null);function rf({theme:e,children:t}){const n={},r=n,a=(e==null?void 0:e.primaryColor)??"#2563eb";r["--embedded-primary"]=a,r["--embedded-primary-dark"]=`color-mix(in srgb, ${a} 82%, black)`,r["--embedded-primary-light"]=`color-mix(in srgb, ${a} 15%, white)`;const i=(e==null?void 0:e.secondaryColor)??"#0891b2";r["--embedded-secondary"]=i,r["--embedded-secondary-dark"]=`color-mix(in srgb, ${i} 82%, black)`,r["--embedded-secondary-light"]=`color-mix(in srgb, ${i} 15%, white)`;const o=(e==null?void 0:e.tertiaryColor)??"#7c3aed";return r["--embedded-tertiary"]=o,r["--embedded-tertiary-dark"]=`color-mix(in srgb, ${o} 82%, black)`,r["--embedded-tertiary-light"]=`color-mix(in srgb, ${o} 15%, white)`,e!=null&&e.borderRadius&&(r["--embedded-radius"]=e.borderRadius),e!=null&&e.fontFamily&&(n.fontFamily=e.fontFamily),r.minHeight="100%",s.jsx("div",{className:"tax-remittance-embedded",style:n,children:t})}const Cc=v.createContext(null),sf=6e3;function af(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function of({toast:e,onDismiss:t}){const n=e.variant==="success";return s.jsxs("div",{role:"alert",className:`w-full max-w-md overflow-hidden rounded-xl border shadow-lg ${n?"border-emerald-700 bg-[#E8F7C8]":"border-red-300 bg-[#FCE8EA]"}`,children:[s.jsxs("div",{className:"flex items-start justify-between gap-3 px-5 py-4",children:[s.jsx("p",{className:"text-base font-bold text-slate-900",children:e.title}),s.jsx("button",{type:"button","aria-label":"Dismiss notification",onClick:()=>t(e.id),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full border transition hover:opacity-80 ${n?"border-emerald-800 text-emerald-900":"border-red-400 text-red-700"}`,children:s.jsx(lf,{})})]}),s.jsx("div",{className:`mx-5 border-t ${n?"border-emerald-700":"border-red-300"}`}),s.jsx("p",{className:"px-5 py-4 text-sm text-slate-700",children:e.message})]})}function lf(){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:"M6 18L18 6M6 6l12 12"})})}function cf({children:e}){const[t,n]=v.useState([]),r=v.useCallback(o=>{n(l=>l.filter(c=>c.id!==o))},[]),a=v.useCallback((o,l,c)=>{const d=af();n(u=>[...u,{id:d,variant:o,title:l,message:c}]),window.setTimeout(()=>{r(d)},sf)},[r]),i=v.useMemo(()=>({showSuccess:(o,l)=>a("success",o,l),showError:(o,l)=>a("error",o,l)}),[a]);return s.jsxs(Cc.Provider,{value:i,children:[e,qr.createPortal(s.jsx("div",{className:"pointer-events-none fixed right-4 top-4 z-[200] flex w-[min(100vw-2rem,28rem)] flex-col gap-3",children:t.map(o=>s.jsx("div",{className:"pointer-events-auto",children:s.jsx(of,{toast:o,onDismiss:r})},o.id))}),document.body)]})}function Vs(){const e=v.useContext(Cc);if(!e)throw new Error("useToast must be used within ToastProvider");return e}class uf extends v.Component{constructor(t){super(t),this.state={hasError:!1,message:""}}static getDerivedStateFromError(t){return{hasError:!0,message:t instanceof Error?t.message:"Unexpected error"}}render(){return this.state.hasError?s.jsxs("div",{className:"flex min-h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[s.jsx("p",{className:"text-sm font-medium text-red-600",children:"Something went wrong loading this widget."}),s.jsx("p",{className:"text-xs text-slate-400",children:this.state.message}),s.jsx("button",{type:"button",className:"rounded-md bg-slate-100 px-4 py-2 text-sm text-slate-600 hover:bg-slate-200",onClick:()=>this.setState({hasError:!1,message:""}),children:"Try again"})]}):this.props.children}}function df(e){return e.startsWith("/dashboard")?"dashboard":e.startsWith("/payments")?"payments":e.startsWith("/tax-forms")?"tax-forms":e.startsWith("/settings")?"settings":e.startsWith("/create-entity/form")?"create-entity-form":e.startsWith("/create-entity")?"create-entity":"other"}function mf({navigateFnRef:e,onNavigate:t}){const n=ke(),r=Se();return v.useEffect(()=>(e.current=n,()=>{e.current=null}),[n,e]),v.useEffect(()=>{t==null||t(df(r.pathname),r.pathname)},[r.pathname,t]),null}function hf({selectEntityFnRef:e}){const{setSelectedEntityId:t}=zn();return v.useEffect(()=>(e.current=t,()=>{e.current=null}),[t,e]),null}function vi({appKey:e,accessToken:t,apiBaseUrl:n,theme:r,onSessionExpired:a,onOrganizationCreated:i,onNavigate:o,onPaymentRequired:l,navigateFnRef:c,selectEntityFnRef:d,enabledPayments:u,children:m}){const[h]=v.useState(()=>crypto.randomUUID());yc(h,{apiBaseUrl:n.trim().replace(/\/+$/,""),clientId:e.trim(),accessToken:t}),bc(n),Vh(e),v.useEffect(()=>()=>{zh(h)},[h]);const[p]=v.useState(()=>new Sh({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}));return s.jsx(nf.Provider,{value:h,children:s.jsx(rf,{theme:r,children:s.jsx(kh,{client:p,children:s.jsx(cf,{children:s.jsx(Kh,{instanceId:h,accessToken:t,onSessionExpired:a,children:s.jsx(xm,{children:s.jsxs(tf,{onOrganizationCreated:i,enabledPayments:u,onPaymentRequired:l,children:[s.jsx(mf,{navigateFnRef:c,onNavigate:o}),s.jsx(hf,{selectEntityFnRef:d}),s.jsx(uf,{children:m})]})})})})})})})}function ji(){const{entities:e,isLoading:t,isError:n,refetchEntities:r}=zn(),a=ke();return v.useEffect(()=>{t||n||a(e.length===0?"/create-entity":"/dashboard",{replace:!0})},[t,n,e,a]),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"})}):n?s.jsxs("div",{className:"flex min-h-[200px] flex-col items-center justify-center gap-3 px-4 text-center",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-red-50",children:s.jsx("svg",{className:"h-5 w-5 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})})}),s.jsx("p",{className:"text-sm font-medium text-slate-700",children:"Unable to load your account"}),s.jsx("p",{className:"text-xs text-slate-500",children:"Check your connection and try again."}),s.jsx("button",{type:"button",onClick:r,className:"mt-1 rounded-md bg-slate-100 px-4 py-1.5 text-xs font-medium text-slate-600 hover:bg-slate-200",children:"Retry"})]}):null}function wi(){const{entities:e,selectedEntity:t,setSelectedEntityId:n}=zn(),r=ke(),i=Se().pathname.split("/").filter(Boolean).length>1;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:[i&&s.jsxs("button",{type:"button",onClick:()=>r(-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(ff,{}),"Back"]}),s.jsx("div",{className:"flex-1"})]}),s.jsx("main",{className:"flex-1 p-5",children:s.jsx(gm,{context:{entities:e,selectedEntity:t,setSelectedEntityId:n}})})]})}function ff(){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 pf=["Entity name & EIN","Business type & primary state","Automatic dashboard access","Start managing tax payments"];function xf({onCreateClick:e}){return s.jsxs("div",{className:"mx-auto w-full max-w-[528px]",children:[s.jsxs("div",{className:"overflow-hidden rounded-[20px] border border-[#f3f4f6] bg-white shadow-[0_20px_25px_-5px_rgba(0,0,0,0.1),0_8px_10px_-6px_rgba(0,0,0,0.1)] sm:rounded-[24px]",children:[s.jsxs("div",{className:"bg-[#bccadb] px-5 pb-6 pt-6 text-center sm:px-8 sm:pb-8 sm:pt-8",children:[s.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-2xl bg-white/20 sm:h-16 sm:w-16",children:s.jsx(Po,{className:"h-6 w-6 text-white sm:h-8 sm:w-8"})}),s.jsx("h2",{className:"mt-3 text-xl font-black tracking-tight text-[#1e2939] sm:mt-4 sm:text-2xl",children:"Add Your Entity"}),s.jsx("p",{className:"mt-1 text-sm text-[#1e2939]/80",children:"Get set up in under 1 minute"})]}),s.jsxs("div",{className:"bg-white px-5 py-5 sm:px-8 sm:py-6",children:[s.jsx("ul",{className:"space-y-2.5 sm:space-y-3",children:pf.map(t=>s.jsxs("li",{className:"flex items-center gap-3 text-sm text-[#4a5565]",children:[s.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-[#dfeeff] text-[#156bd5]",children:s.jsx(rs,{})}),t]},t))}),s.jsxs("button",{type:"button",onClick:e,className:"mt-5 flex h-12 w-full items-center justify-center gap-2 rounded-2xl bg-[#156bd5] text-sm font-black text-white transition hover:bg-[#125bb8] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#156bd5] focus-visible:ring-offset-2 sm:mt-6 sm:h-14 sm:text-base",children:[s.jsx(Po,{className:"h-4 w-4 sm:h-[18px] sm:w-[18px]"}),"Add Entity",s.jsx(gf,{})]})]})]}),s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-x-3 gap-y-2 text-xs text-[#99a1af] sm:mt-5 sm:gap-x-4",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(rs,{className:"h-3 w-3 text-emerald-500"}),"SOC 2 Certified"]}),s.jsx("span",{className:"hidden h-3 w-px bg-[#e5e7eb] sm:block","aria-hidden":!0}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(rs,{className:"h-3 w-3 text-emerald-500"}),"Bank-grade encryption"]}),s.jsx("span",{className:"hidden h-3 w-px bg-[#e5e7eb] sm:block","aria-hidden":!0}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(rs,{className:"h-3 w-3 text-emerald-500"}),"Free to start"]})]})]})}function Po({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 rs({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 gf(){return s.jsx("svg",{className:"h-4 w-4 sm:h-[18px] sm:w-[18px]",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 Ni(){const e=ke(),t=()=>{e("/create-entity/form",{state:{from:"/create-entity"}})};return s.jsx("div",{className:"flex items-center justify-center bg-transparent px-0 py-0",children:s.jsx(xf,{onCreateClick:t})})}var Zr=e=>e.type==="checkbox",hn=e=>e instanceof Date,Ze=e=>e==null;const Si=e=>typeof e=="object";var Pe=e=>!Ze(e)&&!Array.isArray(e)&&Si(e)&&!hn(e),Va=e=>Pe(e)&&e.target?Zr(e.target)?e.target.checked:e.target.value:e,Ac=(e,t)=>t.split(".").some((n,r,a)=>!isNaN(Number(n))&&e.has(a.slice(0,r).join("."))),Pc=e=>{const t=e.constructor&&e.constructor.prototype;return Pe(t)&&t.hasOwnProperty("isPrototypeOf")},Us=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function _e(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Us&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(Pe(e)&&Pc(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=_e(e[a]));return r}const nn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},kt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Nt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Ec="root",ki=["__proto__","constructor","prototype"],yf=/^\w*$/;var Wr=e=>yf.test(e),je=e=>e===void 0;const bf=/[.[\]'"]/;var Zs=e=>e.split(bf).filter(Boolean),q=(e,t,n)=>{if(!t||!Pe(e))return n;const r=Wr(t)?[t]:Zs(t);if(r.some(i=>ki.includes(i)))return n;const a=r.reduce((i,o)=>Ze(i)?void 0:i[o],e);return je(a)||a===e?je(e[t])?n:e[t]:a},ct=e=>typeof e=="boolean",Ke=e=>typeof e=="function",xe=(e,t,n)=>{let r=-1;const a=Wr(t)?[t]:Zs(t),i=a.length,o=i-1;for(;++r<i;){const l=a[r];let c=n;if(r!==o){const d=e[l];c=Pe(d)||Array.isArray(d)?d:isNaN(+a[r+1])?{}:[]}if(ki.includes(l))return;e[l]=c,e=e[l]}};const Ic=v.createContext(null);Ic.displayName="HookFormControlContext";const Ci=()=>v.useContext(Ic);var Tc=(e,t,n,r=!0)=>{const a={};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return t._proxyFormState[o]!==kt.all&&(t._proxyFormState[o]=!r||kt.all),n&&(n[o]=!0),e[o]}});return a};const Ai=Us?v.useLayoutEffect:v.useEffect;function vf(e){const t=Ci(),{control:n=t,disabled:r,name:a,exact:i}=e||{},[o,l]=v.useState(()=>({...n._formState,defaultValues:n._defaultValues})),c=v.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Ai(()=>n._subscribe({name:a,formState:c.current,exact:i,callback:d=>{!r&&l({...n._formState,...d,defaultValues:n._defaultValues})}}),[a,r,i]),v.useEffect(()=>{c.current.isValid&&n._setValid(!0)},[n]),v.useMemo(()=>Tc(o,n,c.current,!1),[o,n])}var Qe=e=>typeof e=="string",Ua=(e,t,n,r,a)=>Qe(e)?(r&&t.watch.add(e),q(n,e,a)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),q(n,i))):(r&&(t.watchAll=!0),n),Za=e=>Ze(e)||!Si(e);const Eo=(e,t)=>t.length===0&&!Array.isArray(e)&&!Pc(e);function ut(e,t,n=new WeakMap){if(e===t)return!0;if(Za(e)||Za(t))return Object.is(e,t);if(hn(e)&&hn(t))return Object.is(e.getTime(),t.getTime());const r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;if(Eo(e,r)||Eo(t,a))return Object.is(e,t);if(!r.length&&Array.isArray(e)!==Array.isArray(t))return!1;const i=n.get(e);if(i&&i.has(t))return!0;if(i)i.add(t);else{const o=new WeakSet;o.add(t),n.set(e,o)}for(const o of r){const l=e[o];if(!(o in t))return!1;if(o!=="ref"){const c=t[o];if(hn(l)&&hn(c)||(Pe(l)||Array.isArray(l))&&(Pe(c)||Array.isArray(c))?!ut(l,c,n):!Object.is(l,c))return!1}}return!0}function jf(e){const t=Ci(),{control:n=t,name:r,defaultValue:a,disabled:i,exact:o,compute:l}=e||{},c=v.useRef(a),d=v.useRef(l),u=v.useRef(void 0),m=v.useRef(n),h=v.useRef(r);d.current=l;const[p,g]=v.useState(()=>{const S=n._getWatch(r,c.current);return d.current?d.current(S):S}),x=v.useCallback(S=>{const I=Ua(r,n._names,S||n._formValues,!1,c.current);return d.current?d.current(I):I},[n._formValues,n._names,r]),b=v.useCallback(S=>{if(!i){const I=Ua(r,n._names,S||n._formValues,!1,c.current);if(d.current){const R=d.current(I);ut(R,u.current)||(g(R),u.current=R)}else g(I)}},[n._formValues,n._names,i,r]);Ai(()=>((m.current!==n||!ut(h.current,r))&&(m.current=n,h.current=r,b()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:S=>{b(S.values)}})),[n,o,r,b]),v.useEffect(()=>n._removeUnmounted());const y=m.current!==n,C=h.current,j=v.useMemo(()=>{if(i)return null;const S=!y&&!ut(C,r);return y||S?x():null},[i,y,r,C,x]);return j!==null?j:p}function wf(e){const t=Ci(),{name:n,disabled:r,control:a=t,shouldUnregister:i,defaultValue:o,exact:l=!0}=e,c=Ac(a._names.array,n),d=v.useMemo(()=>q(a._formValues,n,q(a._defaultValues,n,o)),[a,n,o]),u=jf({control:a,name:n,defaultValue:d,exact:l}),m=vf({control:a,name:n,exact:l}),h=v.useRef(e),p=v.useRef(null),g=v.useRef(a.register(n,{...e.rules,value:u,...ct(e.disabled)?{disabled:e.disabled}:{}}));h.current=e;const x=v.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!q(m.errors,n)},isDirty:{enumerable:!0,get:()=>!!q(m.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!q(m.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!q(m.validatingFields,n)},error:{enumerable:!0,get:()=>q(m.errors,n)}}),[m,n]),b=v.useCallback(S=>{const I=Va(S);return q(a._fields,n)||(g.current=a.register(n,{...h.current.rules,value:I})),g.current.onChange({target:{value:Va(S),name:n},type:nn.CHANGE})},[n,a]),y=v.useCallback(()=>g.current.onBlur({target:{value:q(a._formValues,n),name:n},type:nn.BLUR}),[n,a._formValues]),C=v.useCallback(S=>{S&&(p.current={focus:()=>Ke(S.focus)&&S.focus(),select:()=>Ke(S.select)&&S.select(),setCustomValidity:R=>Ke(S.setCustomValidity)&&S.setCustomValidity(R),reportValidity:()=>Ke(S.reportValidity)&&S.reportValidity()});const I=q(a._fields,n);I&&I._f&&S&&(I._f.ref=p.current)},[a._fields,n]),j=v.useMemo(()=>({name:n,value:u,...ct(r)||m.disabled?{disabled:m.disabled||r}:{},onChange:b,onBlur:y,ref:C}),[n,r,m.disabled,b,y,C,u]);return v.useEffect(()=>{const S=a._options.shouldUnregister||i;a.register(n,{...h.current.rules,...ct(h.current.disabled)?{disabled:h.current.disabled}:{}});const I=(R,E)=>{const T=q(a._fields,R);T&&T._f&&(T._f.mount=E)};if(I(n,!0),S){const R=_e(q(i?a._defaultValues:a._options.values||a._defaultValues,n,q(a._options.defaultValues,n,h.current.defaultValue)));xe(a._defaultValues,n,R),je(q(a._formValues,n))&&xe(a._formValues,n,R)}if(!c&&a.register(n),p.current){const R=q(a._fields,n);R&&R._f&&(R._f.ref=p.current)}return()=>{(c?S&&!a._state.action:S)?a.unregister(n):I(n,!1)}},[n,a,c,i]),v.useEffect(()=>{a._setDisabledField({disabled:r,name:n})},[r,n,a]),v.useMemo(()=>({field:j,formState:m,fieldState:x}),[j,m,x])}const Ne=e=>e.render(wf(e)),_c=e=>{const t={};for(const n of Object.keys(e))if(Si(e[n])&&e[n]!==null&&!hn(e[n])){const r=_c(e[n]);for(const a of Object.keys(r))t[`${n}.${a}`]=r[a]}else t[n]=e[n];return t},Nf=v.createContext(null);Nf.displayName="HookFormContext";var Pi=(e,t,n,r,a)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:a||!0}}:{},Dc=e=>Array.isArray(e)?e.filter(Boolean):[],gs=e=>Array.isArray(e)?e:[e],Io=()=>{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 Fc(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const a=e[r],i=t[r];if(a&&Pe(a)&&i){const o=Fc(a,i);Pe(o)&&(n[r]=o)}else e[r]&&(n[r]=i)}return n}var Ue=e=>Pe(e)&&!Object.keys(e).length,Ei=e=>e.type==="file",ks=e=>{if(!Us)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Rc=e=>e.type==="select-multiple",Ii=e=>e.type==="radio",Sf=e=>Ii(e)||Zr(e),la=e=>ks(e)&&e.isConnected;function kf(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;){if(Ze(e)){e=void 0;break}e=e[t[r]],r++}return e}function Cf(e){for(const t in e)if(e.hasOwnProperty(t)&&!je(e[t]))return!1;return!0}function Le(e,t){if(Qe(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;const n=Array.isArray(t)?t:Wr(t)?[t]:Zs(t);if(n.some(o=>ki.includes(String(o))))return e;const r=n.length===1?e:kf(e,n),a=n.length-1,i=n[a];return r&&delete r[i],a!==0&&(Pe(r)&&Ue(r)||Array.isArray(r)&&Cf(r))&&Le(e,n.slice(0,-1)),e}var Af=e=>{for(const t in e)if(Ke(e[t]))return!0;return!1};function $c(e){return Array.isArray(e)||Pe(e)&&!Af(e)}function Wa(e,t={}){for(const n in e){const r=e[n];$c(r)?(t[n]=Array.isArray(r)?[]:{},Wa(r,t[n])):je(r)||(t[n]=!0)}return t}function Ya(e){if(e!==!1){if(e===!0)return!0;if(Array.isArray(e)){const t=e.map(n=>Ya(n));return t.some(n=>n!==void 0)?t:void 0}if(Pe(e)){const t={};for(const n in e){const r=Ya(e[n]);je(r)||(t[n]=r)}return Object.keys(t).length?t:void 0}}}function vn(e,t,n){n||(n=Wa(t));for(const r in e){const a=e[r];if($c(a))je(t)||Za(n[r])?n[r]=Wa(a,Array.isArray(a)?[]:{}):vn(a,Ze(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!ut(a,i)}}return Ya(n)||{}}const To={value:!1,isValid:!1},_o={value:!0,isValid:!0};var Lc=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!je(e[0].attributes.value)?je(e[0].value)||e[0].value===""?_o:{value:e[0].value,isValid:!0}:_o:To}return To},Oc=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>je(e)?e:t?e===""?NaN:e&&+e:n&&Qe(e)?new Date(e):r?r(e):e;const Do={isValid:!1,value:null};var zc=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Do):Do;function Fo(e){const t=e.ref;return Ei(t)?t.files:Ii(t)?zc(e.refs).value:Rc(t)?[...t.selectedOptions].map(({value:n})=>n):Zr(t)?Lc(e.refs).value:Oc(je(t.value)?e.ref.value:t.value,e)}var Pf=(e,t,n,r)=>{const a={};for(const i of e){const o=q(t,i);o&&xe(a,i,o._f)}return{criteriaMode:n,names:[...e],fields:a,shouldUseNativeValidation:r}},Cs=e=>e instanceof RegExp,Nr=e=>je(e)?e:Cs(e)?e.source:Pe(e)?Cs(e.value)?e.value.source:e.value:e,ss=e=>({isOnSubmit:!e||e===kt.onSubmit,isOnBlur:e===kt.onBlur,isOnChange:e===kt.onChange,isOnAll:e===kt.all,isOnTouch:e===kt.onTouched});const Ro="AsyncFunction";var Ef=e=>{if(!e||!e.validate)return!1;if(Ke(e.validate))return e.validate.constructor.name===Ro;if(Pe(e.validate)){for(const t in e.validate)if(e.validate[t].constructor.name===Ro)return!0}return!1},If=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),ca=(e,t,n)=>{if(n)return!1;if(t.watchAll||t.watch.has(e))return!0;for(const r of t.watch)if(e.startsWith(r)&&e.charAt(r.length)===".")return!0;return!1};const Ir=(e,t,n,r)=>{for(const a of n||Object.keys(e)){const i=q(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],a)&&!r)return!0;if(o.ref&&t(o.ref,o.name)&&!r)return!0;if(Ir(l,t))break}else if(Pe(l)&&Ir(l,t))break}}};function $o(e,t,n){const r=q(e,n);if(r||Wr(n))return{error:r,name:n};const a=n.split(".");for(;a.length;){const i=a.join("."),o=q(t,i),l=q(e,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};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:n}}var Tf=(e,t,n,r)=>{n(e);const{name:a,...i}=e,o=Object.keys(i);return!o.length||r&&o.length>=Object.keys(t).length||o.find(l=>t[l]===(!r||kt.all))},_f=(e,t,n)=>!e||!t||e===t||gs(e).some(r=>r&&(n?r===t||r.startsWith(t+"."):r.startsWith(t)||t.startsWith(r))),Df=(e,t,n,r,a)=>a.isOnAll?!1:!n&&a.isOnTouch?!(t||e):(n?r.isOnBlur:a.isOnBlur)?!e:(n?r.isOnChange:a.isOnChange)?e:!0,Ff=(e,t)=>!Dc(q(e,t)).length&&Le(e,t),Lo=(e,t,n)=>{const r=q(e,n),a=Array.isArray(r)?r:[];return xe(a,Ec,t[n]),xe(e,n,a),e};function Oo(e,t,n="validate"){if(Qe(e)||Array.isArray(e)&&e.every(Qe)||ct(e)&&!e)return{type:n,message:Qe(e)?e:"",ref:t}}var Bn=e=>Pe(e)&&!Cs(e)?e:{value:e,message:""},zo=async(e,t,n,r,a,i)=>{const{ref:o,refs:l,required:c,maxLength:d,minLength:u,min:m,max:h,pattern:p,validate:g,name:x,valueAsNumber:b,mount:y}=e._f,C=q(n,x);if(!y||t.has(x))return{};const j=l?l[0]:o,S=X=>{if(a&&j.reportValidity){const Y=ct(X)?"":X||"";l?l.forEach(V=>V.setCustomValidity(Y)):j.setCustomValidity(Y),j.reportValidity()}},I={},R=Ii(o),E=Zr(o),T=R||E,L=(b||Ei(o))&&je(o.value)&&je(C)||ks(o)&&o.value===""||C===""||Array.isArray(C)&&!C.length,B=Pi.bind(null,x,r,I),K=(X,Y,V,Z=Nt.maxLength,ie=Nt.minLength)=>{const G=X?Y:V;I[x]={type:X?Z:ie,message:G,ref:o,...B(X?Z:ie,G)}};if(i?!Array.isArray(C)||!C.length:c&&(!T&&(L||Ze(C))||ct(C)&&!C||E&&!Lc(l).isValid||R&&!zc(l).isValid)){const{value:X,message:Y}=Qe(c)?{value:!!c,message:c}:Bn(c);if(X&&(I[x]={type:Nt.required,message:Y,ref:j,...B(Nt.required,Y)},!r))return S(Y),I}if(!L&&(!Ze(m)||!Ze(h))){let X,Y;const V=Bn(h),Z=Bn(m);if(!Ze(C)&&!isNaN(C)){const ie=o.valueAsNumber||C&&+C;Ze(V.value)||(X=ie>V.value),Ze(Z.value)||(Y=ie<Z.value)}else{const ie=o.valueAsDate||new Date(C),G=Ae=>new Date(new Date().toDateString()+" "+Ae),Q=o.type=="time",we=o.type=="week";Qe(V.value)&&C&&(X=Q?G(C)>G(V.value):we?C>V.value:ie>new Date(V.value)),Qe(Z.value)&&C&&(Y=Q?G(C)<G(Z.value):we?C<Z.value:ie<new Date(Z.value))}if((X||Y)&&(K(!!X,V.message,Z.message,Nt.max,Nt.min),!r))return S(I[x].message),I}if((d||u)&&!L&&(Qe(C)||i&&Array.isArray(C))){const X=Bn(d),Y=Bn(u),V=!Ze(X.value)&&C.length>+X.value,Z=!Ze(Y.value)&&C.length<+Y.value;if((V||Z)&&(K(V,X.message,Y.message),!r))return S(I[x].message),I}if(p&&!L&&Qe(C)){const{value:X,message:Y}=Bn(p);if(Cs(X)&&!C.match(X)&&(I[x]={type:Nt.pattern,message:Y,ref:o,...B(Nt.pattern,Y)},!r))return S(Y),I}if(g){if(Ke(g)){const X=await g(C,n),Y=Oo(X,j);if(Y&&(I[x]={...Y,...B(Nt.validate,Y.message)},!r))return S(Y.message),I}else if(Pe(g)){let X={};for(const Y in g){if(!Ue(X)&&!r)break;const V=Oo(await g[Y](C,n),j,Y);V&&(X={...V,...B(Y,V.message)},S(V.message),r&&(I[x]=X))}if(!Ue(X)&&(I[x]={ref:j,...X},!r))return I}}return S(!0),I};const Rf={mode:kt.onSubmit,reValidateMode:kt.onChange,shouldFocusError:!0},ua="form",Mc={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function $f(e={}){let t={...Rf,...e},n={..._e(Mc),isLoading:Ke(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},r={},a=Pe(t.defaultValues)||Pe(t.values)?_e(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:_e(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,d=0,u=0,m=ss(t.mode),h=ss(t.reValidateMode);const p={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},g={...p};let x={...g};const b={array:Io(),state:Io()},y=t.criteriaMode===kt.all,C=f=>N=>{clearTimeout(d),d=setTimeout(f,N)},j=async f=>{if(!o.keepIsValid&&!t.disabled&&(g.isValid||x.isValid||f)){let N;t.resolver?(N=Ue((await Y()).errors),S()):N=await ie({fields:r,onlyCheckValid:!0,eventType:nn.VALID}),N!==n.isValid&&b.state.next({isValid:N})}},S=(f,N)=>{!t.disabled&&(g.isValidating||g.validatingFields||x.isValidating||x.validatingFields)&&((f||Array.from(l.mount)).forEach(A=>{A&&(N?xe(n.validatingFields,A,N):Le(n.validatingFields,A))}),b.state.next({validatingFields:n.validatingFields,isValidating:!Ue(n.validatingFields)}))},I=()=>{n.dirtyFields=vn(a,i)},R=(f,N=[],A,k,_=!0,W=!0)=>{if(k&&A&&!t.disabled){if(o.action=!0,W&&Array.isArray(q(r,f))){const z=A(q(r,f),k.argA,k.argB);_&&xe(r,f,z)}if(W&&Array.isArray(q(n.errors,f))){const z=A(q(n.errors,f),k.argA,k.argB);_&&xe(n.errors,f,z),Ff(n.errors,f)}if((g.touchedFields||x.touchedFields)&&W&&Array.isArray(q(n.touchedFields,f))){const z=A(q(n.touchedFields,f),k.argA,k.argB);_&&xe(n.touchedFields,f,z)}(g.dirtyFields||x.dirtyFields)&&I(),b.state.next({name:f,isDirty:Q(f,N),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else xe(i,f,N)},E=(f,N)=>{xe(n.errors,f,N),n.errors={...n.errors},b.state.next({errors:n.errors})},T=f=>{n.errors=f,b.state.next({errors:n.errors,isValid:!1})},L=f=>{const N=Wr(f)?[f]:Zs(f);let A=i,k=a;for(let _=0;_<N.length-1;_++){const W=N[_];if(A=Ze(A)?A:A[W],k=Ze(k)?k:k[W],A===null&&k!==null)return!0}return!1},B=(f,N,A,k)=>{const _=q(r,f);if(_){if(L(f))return;const W=je(q(i,f)),z=q(i,f,je(A)?q(a,f):A);je(z)||k&&k.defaultChecked||N?xe(i,f,N?z:Fo(_._f)):$e(f,z),o.mount&&!o.action&&(j(),W&&n.isDirty&&(g.isDirty||x.isDirty)&&(Q()||(n.isDirty=!1,b.state.next({...n}))),e.shouldUnregister&&W&&!je(q(i,f))&&ca(f,l)&&(o.watch=!0))}},K=(f,N,A,k,_)=>{let W=!1,z=!1;const H={name:f};if(!t.disabled){if(!A||k){const M=ut(q(a,f),N);(g.isDirty||x.isDirty)&&(z=n.isDirty,n.isDirty=H.isDirty=!M||Q(),W=z!==H.isDirty),z=!!q(n.dirtyFields,f),M!==n.isDirty?n.dirtyFields=vn(a,i):M?Le(n.dirtyFields,f):xe(n.dirtyFields,f,!0),H.dirtyFields=n.dirtyFields,W=W||(g.dirtyFields||x.dirtyFields)&&z!==!M}if(A){const M=q(n.touchedFields,f);M||(xe(n.touchedFields,f,A),H.touchedFields=n.touchedFields,W=W||(g.touchedFields||x.touchedFields)&&M!==A)}W&&_&&b.state.next(H)}return W?H:{}},X=(f,N,A,k)=>{const _=q(n.errors,f),W=(g.isValid||x.isValid)&&ct(N)&&n.isValid!==N;if(t.delayError&&A?(c=C(()=>E(f,A)),c(t.delayError)):(clearTimeout(d),c=null,A?xe(n.errors,f,A):Le(n.errors,f),n.errors={...n.errors}),(A?!ut(_,A):_)||!Ue(k)||W){const z={...k,...W&&ct(N)?{isValid:N}:{},errors:n.errors,name:f};n={...n,...z},b.state.next(z)}},Y=async f=>(S(f,!0),await t.resolver(i,t.context,Pf(f||l.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),V=async f=>{const{errors:N}=await Y(f);if(S(f),f){for(const A of f){const k=q(N,A);k?l.array.has(A)&&Pe(k)&&!Object.keys(k).some(_=>!Number.isNaN(Number(_)))?Lo(n.errors,{[A]:k},A):xe(n.errors,A,k):Le(n.errors,A)}n.errors={...n.errors}}else n.errors=N;return N},Z=async({name:f,eventType:N})=>{if(e.validate){const A=await e.validate({formValues:i,formState:n,name:f,eventType:N});if(Pe(A))for(const k in A){const _=A[k];_&&be(`${ua}.${k}`,{message:Qe(_.message)?_.message:"",type:_.type||Nt.validate})}else Qe(A)||!A?be(ua,{message:A||"",type:Nt.validate}):le(ua);return A}return!0},ie=async({fields:f,onlyCheckValid:N,name:A,eventType:k,context:_={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(_.runRootValidation=!0,!await Z({name:A,eventType:k})&&(_.valid=!1,N)))return _.valid;for(const W in f){const z=f[W];if(z){const{_f:H,...M}=z;if(H){const ae=l.array.has(H.name),Me=z._f&&Ef(z._f),Vt=g.validatingFields||g.isValidating||x.validatingFields||x.isValidating;Me&&Vt&&S([H.name],!0);const Ut=await zo(z,l.disabled,i,y,t.shouldUseNativeValidation&&!N,ae);if(Me&&Vt&&S([H.name]),Ut[H.name]&&(_.valid=!1,N)||(!N&&(q(Ut,H.name)?ae?Lo(n.errors,Ut,H.name):xe(n.errors,H.name,Ut[H.name]):Le(n.errors,H.name)),e.shouldUseNativeValidation&&Ut[H.name]))break}!Ue(M)&&await ie({context:_,onlyCheckValid:N,fields:M,name:W,eventType:k})}}return _.valid},G=()=>{for(const f of l.unMount){const N=q(r,f);N&&(N._f.refs?N._f.refs.every(A=>!la(A)):!la(N._f.ref))&&rt(f)}l.unMount=new Set},Q=(f,N)=>!t.disabled&&(f&&N&&xe(i,f,N),!ut(o.mount?i:a,a)),we=(f,N,A)=>Ua(f,l,{...o.mount?i:je(N)?a:Qe(f)?{[f]:N}:N},A,N),Ae=f=>Dc(q(o.mount?i:a,f,t.shouldUnregister?q(a,f,[]):[])),$e=(f,N,A={},k=!1,_=!1)=>{const W=q(r,f);let z=N;if(W){const H=W._f;H&&(!H.disabled&&xe(i,f,Oc(N,H)),z=ks(H.ref)&&Ze(N)?"":N,Rc(H.ref)?[...H.ref.options].forEach(M=>M.selected=z.includes(M.value)):H.refs?Zr(H.ref)?H.refs.forEach(M=>{(!M.defaultChecked||!M.disabled)&&(Array.isArray(z)?M.checked=!!z.find(ae=>ae===M.value):M.checked=z===M.value||!!z)}):H.refs.forEach(M=>M.checked=M.value===z):Ei(H.ref)?H.ref.value="":(H.ref.value=z,!H.ref.type&&!_&&b.state.next({name:f,values:k?i:_e(i)})))}(A.shouldDirty||A.shouldTouch)&&K(f,z,A.shouldTouch,A.shouldDirty,!_),A.shouldValidate&&Te(f)},ce=(f,N,A,k=!1,_=!1)=>{for(const W in N){if(!N.hasOwnProperty(W))return;const z=N[W],H=f+"."+W,M=q(r,H);(l.array.has(f)||Pe(z)||M&&!M._f)&&!hn(z)?ce(H,z,A,k,_):$e(H,z,A,k,_)}},pe=(f,N,A,k,_=!1)=>{const W=q(r,f),z=l.array.has(f),H=k?N:_e(N),M=q(i,f),ae=ut(M,H);if(ae||xe(i,f,H),z)b.array.next({name:f,values:k?i:_e(i)}),(g.isDirty||g.dirtyFields||x.isDirty||x.dirtyFields)&&A.shouldDirty&&(I(),_||b.state.next({name:f,dirtyFields:n.dirtyFields,isDirty:Q(f,H)}));else{const Me=Array.isArray(H)&&!H.length||Ue(H);!W||W._f||Ze(H)||Me?$e(f,H,A,k,_):ce(f,H,A,k,_)}if(!ae&&!_){const Me=ca(f,l),Vt=k?i:_e(i);b.state.next({...Me&&n,name:o.mount||Me?f:void 0,values:Vt})}},$=(f,N,A={})=>pe(f,N,A,!1),fe=(f,N={})=>{const A=Ke(f)?f(i):f;if(!ut(i,A)){i={...i,...A};const k=_c(A);for(const _ of l.mount)_ in k&&pe(_,k[_],N,!0,!0);b.state.next({...n,name:void 0,type:void 0,...u?{values:i}:{}}),N.shouldValidate&&j()}},O=async f=>{o.mount=!0;const N=f.target;let A=N.name,k=!0;const _=q(r,A),W=z=>{k=Number.isNaN(z)||hn(z)&&isNaN(z.getTime())||ut(z,q(i,A,z))};if(_){let z,H;const M=N.type?Fo(_._f):Va(f),ae=f.type===nn.BLUR||f.type===nn.FOCUS_OUT,Me=!If(_._f)&&!e.validate&&!t.resolver&&!q(n.errors,A)&&!_._f.deps,Vt=Me||Df(ae,q(n.touchedFields,A),n.isSubmitted,h,m),Ut=ca(A,l,ae);xe(i,A,M),ae?(!N||!N.readOnly)&&(_._f.onBlur&&_._f.onBlur(f),c&&c(0)):_._f.onChange&&_._f.onChange(f);const vr=K(A,M,ae),hd=!Ue(vr)||Ut;if(!ae&&b.state.next({name:A,type:f.type,...u?{values:_e(i)}:{}}),Vt)return(!Me||!n.isValid)&&(g.isValid||x.isValid)&&(t.mode==="onBlur"?ae&&j():ae||j()),hd&&b.state.next({name:A,...Ut?{}:vr});if(!t.resolver&&e.validate&&await Z({name:A,eventType:f.type}),!ae&&Ut&&b.state.next({...n}),t.resolver){const{errors:lo}=await Y([A]);if(S([A]),W(M),!k){!Ue(vr)&&b.state.next(vr);return}const fd=$o(n.errors,r,A),co=$o(lo,r,fd.name||A);z=co.error,A=co.name,H=Ue(lo)}else S([A],!0),z=(await zo(_,l.disabled,i,y,t.shouldUseNativeValidation))[A],S([A]),W(M),k&&(z?H=!1:(g.isValid||x.isValid)&&(H=await ie({fields:r,onlyCheckValid:!0,name:A,eventType:f.type})));k&&(_._f.deps&&(!Array.isArray(_._f.deps)||_._f.deps.length>0)&&Te(_._f.deps),X(A,H,z,vr))}},ue=(f,N)=>{if(q(n.errors,N)&&f.focus)return f.focus(),1},Te=async(f,N={})=>{let A,k;const _=gs(f);if(t.resolver){const W=await V(je(f)?f:_);A=Ue(W),k=f?!_.some(z=>q(W,z)):A}else f?(k=(await Promise.all(_.map(async W=>{const z=q(r,W);return await ie({fields:z&&z._f?{[W]:z}:z,eventType:nn.TRIGGER})}))).every(Boolean),!(!k&&!n.isValid)&&j()):k=A=await ie({fields:r,name:f,eventType:nn.TRIGGER});return b.state.next({...!Qe(f)||(g.isValid||x.isValid)&&A!==n.isValid?{}:{name:f},...t.resolver||!f?{isValid:A}:{},errors:n.errors}),N.shouldFocus&&!k&&Ir(r,ue,f?_:l.mount),k},Ge=(f,N)=>{let A={...o.mount?i:a};return N&&(A=Fc(N.dirtyFields?n.dirtyFields:n.touchedFields,A)),je(f)?A:Qe(f)?q(A,f):f.map(k=>q(A,k))},Oe=(f,N)=>({invalid:!!q((N||n).errors,f),isDirty:!!q((N||n).dirtyFields,f),error:q((N||n).errors,f),isValidating:!!q(n.validatingFields,f),isTouched:!!q((N||n).touchedFields,f)}),le=f=>{const N=f?gs(f):void 0;N==null||N.forEach(A=>Le(n.errors,A)),N?N.forEach(A=>{b.state.next({name:A,errors:n.errors})}):b.state.next({errors:{}})},be=(f,N,A)=>{const k=(q(r,f,{_f:{}})._f||{}).ref,_=q(n.errors,f)||{},{ref:W,message:z,type:H,...M}=_;xe(n.errors,f,{...M,...N,ref:k}),b.state.next({name:f,errors:n.errors,isValid:!1}),A&&A.shouldFocus&&k&&k.focus&&k.focus()},Ye=(f,N)=>{if(Ke(f)){u++;const{unsubscribe:A}=b.state.subscribe({next:_=>"values"in _&&f(_.values||we(void 0,N),_)});let k=!1;return{unsubscribe:()=>{k||(k=!0,u--,A())}}}return we(f,N,!0)},re=f=>{var N;const A=!!(!((N=f.formState)===null||N===void 0)&&N.values);A&&u++;const{unsubscribe:k}=b.state.subscribe({next:W=>{if(_f(f.name,W.name,f.exact)&&Tf(W,f.formState||g,It,f.reRenderRoot)){const z={...i};f.callback({values:z,...n,...W,defaultValues:a})}}});if(!A)return k;let _=!1;return()=>{_||(_=!0,u--,k())}},Ve=f=>(o.mount=!0,x={...x,...f.formState},re({...f,formState:{...p,...f.formState}})),rt=(f,N={})=>{for(const A of f?gs(f):l.mount)l.mount.delete(A),l.array.delete(A),N.keepValue||(Le(r,A),Le(i,A)),!N.keepError&&Le(n.errors,A),!N.keepDirty&&Le(n.dirtyFields,A),!N.keepTouched&&Le(n.touchedFields,A),!N.keepIsValidating&&Le(n.validatingFields,A),!t.shouldUnregister&&!N.keepDefaultValue&&Le(a,A);b.state.next({values:_e(i)}),b.state.next({...n,...N.keepDirty?{isDirty:Q()}:{}}),!N.keepIsValid&&j()},bt=({disabled:f,name:N})=>{if(ct(f)&&o.mount||f||l.disabled.has(N)){const _=l.disabled.has(N)!==!!f;f?l.disabled.add(N):l.disabled.delete(N),_&&o.mount&&!o.action&&j()}},pt=(f,N={})=>{let A=q(r,f);const k=ct(N.disabled)||ct(t.disabled),_=!l.registerName.has(f)&&A&&A._f&&!A._f.mount;return xe(r,f,{...A||{},_f:{...A&&A._f?A._f:{ref:{name:f}},name:f,mount:!0,...N}}),l.mount.add(f),A&&!_?bt({disabled:ct(N.disabled)?N.disabled:t.disabled,name:f}):B(f,!0,N.value),{...k?{disabled:N.disabled||t.disabled}:{},...t.progressive?{required:!!N.required,min:Nr(N.min),max:Nr(N.max),minLength:Nr(N.minLength),maxLength:Nr(N.maxLength),pattern:Nr(N.pattern)}:{},name:f,onChange:O,onBlur:O,ref:W=>{if(W){l.registerName.add(f),pt(f,N),l.registerName.delete(f),A=q(r,f);const z=je(W.value)&&W.querySelectorAll&&W.querySelectorAll("input,select,textarea")[0]||W,H=Sf(z),M=A._f.refs||[];if(H?M.find(ae=>ae===z):z===A._f.ref)return;xe(r,f,{_f:{...A._f,...H?{refs:[...M.filter(la),z,...Array.isArray(q(a,f))?[{}]:[]],ref:{type:z.type,name:f}}:{ref:z}}}),B(f,!1,void 0,z)}else A=q(r,f,{}),A._f&&(A._f.mount=!1),(t.shouldUnregister||N.shouldUnregister)&&!(Ac(l.array,f)&&o.action)&&l.unMount.add(f)}}},vt=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&Ir(r,ue,l.mount),zt=f=>{ct(f)&&(b.state.next({disabled:f}),Ir(r,(N,A)=>{const k=q(r,A);k&&(N.disabled=k._f.disabled||f,Array.isArray(k._f.refs)&&k._f.refs.forEach(_=>{_.disabled=k._f.disabled||f}))},0,!1))},jt=(f,N)=>async A=>{let k;A&&(A.preventDefault&&A.preventDefault(),A.persist&&A.persist());let _=_e(i);if(b.state.next({isSubmitting:!0}),t.resolver){const{errors:W,values:z}=await Y();S(),n.errors=W,_=_e(z)}else await ie({fields:r,eventType:nn.SUBMIT});if(l.disabled.size)for(const W of l.disabled)Le(_,W);if(Le(n.errors,Ec),Ue(n.errors)){b.state.next({errors:{}});try{await f(_,A)}catch(W){k=W}}else N&&await N({...n.errors},A),vt(),setTimeout(vt);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Ue(n.errors)&&!k,submitCount:n.submitCount+1,errors:n.errors}),k)throw k},Mt=(f,N={})=>{q(r,f)&&(je(N.defaultValue)?$(f,_e(q(a,f))):($(f,N.defaultValue),xe(a,f,_e(N.defaultValue))),N.keepTouched||Le(n.touchedFields,f),N.keepDirty||(Le(n.dirtyFields,f),n.isDirty=N.defaultValue?Q(f,_e(q(a,f))):Q()),N.keepError||(Le(n.errors,f),g.isValid&&j()),b.state.next({...n}))},At=(f,N={})=>{const A=f?_e(f):a,k=_e(A),_=Ue(f),W=k;if(N.keepDefaultValues||(a=A),!N.keepValues){if(N.keepDirtyValues){const z=new Set([...l.mount,...Object.keys(vn(a,i))]);for(const H of Array.from(z)){const M=q(n.dirtyFields,H),ae=q(i,H),Me=q(W,H);M&&!je(ae)?xe(W,H,ae):!M&&!je(Me)&&$(H,Me)}}else{if(Us&&je(f))for(const z of l.mount){const H=q(r,z);if(H&&H._f){const M=Array.isArray(H._f.refs)?H._f.refs[0]:H._f.ref;if(ks(M)){const ae=M.closest("form");if(ae){ae.reset();break}}}}if(N.keepFieldsRef)for(const z of l.mount)$(z,q(W,z));else r={}}if(t.shouldUnregister){if(i=N.keepDefaultValues?_e(a):{},N.keepFieldsRef)for(const z of l.mount)xe(i,z,q(W,z))}else i=_e(W);b.array.next({values:{...W}}),b.state.next({name:void 0,type:void 0,values:{...W}})}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=!g.isValid||!!N.keepIsValid||!!N.keepDirtyValues||!t.shouldUnregister&&!Ue(W),o.watch=!!t.shouldUnregister,o.keepIsValid=!!N.keepIsValid,o.action=!1,N.keepErrors||(n.errors={}),b.state.next({submitCount:N.keepSubmitCount?n.submitCount:0,isDirty:_?!1:N.keepDirty?n.isDirty:N.keepValues?Q():!!(N.keepDefaultValues&&!ut(f,a)),isSubmitted:N.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:_?{}:N.keepDirtyValues?N.keepDefaultValues&&i?vn(a,i):n.dirtyFields:N.keepDefaultValues&&f?vn(a,f):N.keepDirty?n.dirtyFields:{},touchedFields:N.keepTouched?n.touchedFields:{},errors:N.keepErrors?n.errors:{},isSubmitSuccessful:N.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},Pt=(f,N)=>At(Ke(f)?f(i):f,{...t.resetOptions,...N}),Et=(f,N={})=>{const A=q(r,f),k=A&&A._f;if(k){const _=k.refs?k.refs[0]:k.ref;_.focus&&setTimeout(()=>{_.focus(),N.shouldSelect&&Ke(_.select)&&_.select()})}},It=f=>{const{name:N,type:A,values:k,..._}=f;n={...n,..._}},wt={control:{register:pt,unregister:rt,getFieldState:Oe,handleSubmit:jt,setError:be,_subscribe:re,_runSchema:Y,_updateIsValidating:S,_focusError:vt,_getWatch:we,_getDirty:Q,_setValid:j,_setFieldArray:R,_setDisabledField:bt,_setErrors:T,_getFieldArray:Ae,_reset:At,_resetDefaultValues:()=>Ke(t.defaultValues)&&t.defaultValues().then(f=>{Pt(f,t.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:G,_disableForm:zt,_subjects:b,_proxyFormState:g,get _fields(){return r},get _formValues(){return i},get _state(){return o},set _state(f){o=f},get _defaultValues(){return a},get _names(){return l},set _names(f){l=f},get _formState(){return n},get _options(){return t},set _options(f){t={...t,...f},m=ss(t.mode),h=ss(t.reValidateMode)}},subscribe:Ve,trigger:Te,register:pt,handleSubmit:jt,watch:Ye,setValue:$,setValues:fe,getValues:Ge,reset:Pt,resetField:Mt,resetDefaultValues:(f,N={})=>{if(a=_e(f),!N.keepDirty){const A=vn(a,i);n.dirtyFields=A,n.isDirty=!Ue(A)}N.keepIsValid||j(),b.state.next({...n,defaultValues:a})},clearErrors:le,unregister:rt,setError:be,setFocus:Et,getFieldState:Oe};return{...wt,formControl:wt}}function Rt(e={}){const t=v.useRef(void 0),n=v.useRef(void 0),r=v.useRef(e.formControl),[a,i]=v.useState(()=>({..._e(Mc),isLoading:Ke(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Ke(e.defaultValues)?void 0:e.defaultValues}));if(!t.current||e.formControl&&r.current!==e.formControl)if(r.current=e.formControl,e.formControl)t.current={...e.formControl,formState:a},e.defaultValues&&!Ke(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...c}=$f(e);t.current={...c,formState:a}}const o=t.current.control;return o._options=e,Ai(()=>{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]),v.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),v.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),v.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),v.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),v.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==a.isDirty&&o._subjects.state.next({isDirty:l})}},[o,a.isDirty]),v.useEffect(()=>{var l;e.values&&!ut(e.values,n.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((l=o._options.resetOptions)===null||l===void 0)&&l.keepIsValid||o._setValid(),n.current=e.values,i(c=>({...c}))):o._resetDefaultValues()},[o,e.values]),v.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=v.useMemo(()=>Tc(a,o),[o,a]),t.current}const Mo=(e,t,n)=>{if(e&&"reportValidity"in e){const r=q(n,t);e.setCustomValidity(r&&r.message||""),e.reportValidity()}},Ha=(e,t)=>{for(const n in t.fields){const r=t.fields[n];r&&r.ref&&"reportValidity"in r.ref?Mo(r.ref,n,e):r&&r.refs&&r.refs.forEach(a=>Mo(a,n,e))}},qo=(e,t)=>{t.shouldUseNativeValidation&&Ha(e,t);const n={};for(const r in e){const a=q(t.fields,r),i=Object.assign(e[r]||{},{ref:a&&a.ref});if(Lf(t.names||Object.keys(e),r)){const o=Object.assign({},q(n,r));xe(o,"root",i),xe(n,r,o)}else xe(n,r,i)}return n},Lf=(e,t)=>{const n=Bo(t).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(r=>Bo(r).match(`^${n}\\.\\d+`))};function Bo(e){return e.replace(/[\[\]]/g,"")}var Vo;function F(e,t,n){function r(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 d=o.prototype,u=Object.keys(d);for(let m=0;m<u.length;m++){const h=u[m];h in l||(l[h]=d[h].bind(l))}}const a=(n==null?void 0:n.Parent)??Object;class i extends a{}Object.defineProperty(i,"name",{value:e});function o(l){var c;const d=n!=null&&n.Parent?new i:this;r(d,l),(c=d._zod).deferred??(c.deferred=[]);for(const u of d._zod.deferred)u();return d}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:l=>{var c,d;return n!=null&&n.Parent&&l instanceof n.Parent?!0:(d=(c=l==null?void 0:l._zod)==null?void 0:c.traits)==null?void 0:d.has(e)}}),Object.defineProperty(o,"name",{value:e}),o}class Zn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class qc extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Vo=globalThis).__zod_globalConfig??(Vo.__zod_globalConfig={});const Ti=globalThis.__zod_globalConfig;function Fn(e){return Ti}function Bc(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,a])=>t.indexOf(+r)===-1).map(([r,a])=>a)}function Ka(e,t){return typeof t=="bigint"?t.toString():t}function _i(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Di(e){return e==null}function Fi(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const Uo=Symbol("evaluating");function ve(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Uo)return r===void 0&&(r=Uo,r=n()),r},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function Mn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function gn(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Zo(e){return JSON.stringify(e)}function Of(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Vc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function As(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const zf=_i(()=>{var e;if(Ti.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 Fr(e){if(As(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(As(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Uc(e){return Fr(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Mf=new Set(["string","number","symbol"]);function lr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yn(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function se(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 qf(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function Bf(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=gn(e._zod.def,{get shape(){const o={};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(o[l]=n.shape[l])}return Mn(this,"shape",o),o},checks:[]});return yn(e,i)}function Vf(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=gn(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete o[l]}return Mn(this,"shape",o),o},checks:[]});return yn(e,i)}function Uf(e,t){if(!Fr(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.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=gn(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Mn(this,"shape",i),i}});return yn(e,a)}function Zf(e,t){if(!Fr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=gn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Mn(this,"shape",r),r}});return yn(e,n)}function Wf(e,t){var r;if((r=e._zod.def.checks)!=null&&r.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=gn(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Mn(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return yn(e,n)}function Yf(e,t,n){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=gn(t._zod.def,{get shape(){const l=t._zod.def.shape,c={...l};if(n)for(const d in n){if(!(d in l))throw new Error(`Unrecognized key: "${d}"`);n[d]&&(c[d]=e?new e({type:"optional",innerType:l[d]}):l[d])}else for(const d in l)c[d]=e?new e({type:"optional",innerType:l[d]}):l[d];return Mn(this,"shape",c),c},checks:[]});return yn(t,o)}function Hf(e,t,n){const r=gn(t._zod.def,{get shape(){const a=t._zod.def.shape,i={...a};if(n)for(const o in n){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);n[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 Mn(this,"shape",i),i}});return yn(t,r)}function Vn(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function Kf(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0;return!1}function Zc(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function as(e){return typeof e=="string"?e:e==null?void 0:e.message}function Rn(e,t,n){var c,d,u,m,h,p;const r=e.message?e.message:as((u=(d=(c=e.inst)==null?void 0:c._zod.def)==null?void 0:d.error)==null?void 0:u.call(d,e))??as((m=t==null?void 0:t.error)==null?void 0:m.call(t,e))??as((h=n.customError)==null?void 0:h.call(n,e))??as((p=n.localeError)==null?void 0:p.call(n,e))??"Invalid input",{inst:a,continue:i,input:o,...l}=e;return l.path??(l.path=[]),l.message=r,t!=null&&t.reportInput&&(l.input=o),l}function Ri(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Rr(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Wc=(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,Ka,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},$i=F("$ZodError",Wc),Ws=F("$ZodError",Wc,{Parent:Error});function Qf(e,t=n=>n.message){const n={},r=[];for(const a of e.issues)a.path.length>0?(n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(t(a))):r.push(t(a));return{formErrors:r,fieldErrors:n}}function Jf(e,t=n=>n.message){const n={_errors:[]},r=(a,i=[])=>{for(const o of a.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(l=>r({issues:l},[...i,...o.path]));else if(o.code==="invalid_key")r({issues:o.issues},[...i,...o.path]);else if(o.code==="invalid_element")r({issues:o.issues},[...i,...o.path]);else{const l=[...i,...o.path];if(l.length===0)n._errors.push(t(o));else{let c=n,d=0;for(;d<l.length;){const u=l[d];d===l.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(o))):c[u]=c[u]||{_errors:[]},c=c[u],d++}}}};return r(e),n}const Ys=e=>(t,n,r,a)=>{const i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new Zn;if(o.issues.length){const l=new((a==null?void 0:a.Err)??e)(o.issues.map(c=>Rn(c,i,Fn())));throw Vc(l,a==null?void 0:a.callee),l}return o.value},Gf=Ys(Ws),Hs=e=>async(t,n,r,a)=>{const i=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,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=>Rn(c,i,Fn())));throw Vc(l,a==null?void 0:a.callee),l}return o.value},Xf=Hs(Ws),Ks=e=>(t,n,r)=>{const a=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},a);if(i instanceof Promise)throw new Zn;return i.issues.length?{success:!1,error:new(e??$i)(i.issues.map(o=>Rn(o,a,Fn())))}:{success:!0,data:i.value}},ep=Ks(Ws),Qs=e=>async(t,n,r)=>{const a=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},a);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(o=>Rn(o,a,Fn())))}:{success:!0,data:i.value}},tp=Qs(Ws),np=e=>(t,n,r)=>{const a=r?{...r,direction:"backward"}:{direction:"backward"};return Ys(e)(t,n,a)},rp=e=>(t,n,r)=>Ys(e)(t,n,r),sp=e=>async(t,n,r)=>{const a=r?{...r,direction:"backward"}:{direction:"backward"};return Hs(e)(t,n,a)},ap=e=>async(t,n,r)=>Hs(e)(t,n,r),ip=e=>(t,n,r)=>{const a=r?{...r,direction:"backward"}:{direction:"backward"};return Ks(e)(t,n,a)},op=e=>(t,n,r)=>Ks(e)(t,n,r),lp=e=>async(t,n,r)=>{const a=r?{...r,direction:"backward"}:{direction:"backward"};return Qs(e)(t,n,a)},cp=e=>async(t,n,r)=>Qs(e)(t,n,r),up=/^[cC][0-9a-z]{6,}$/,dp=/^[0-9a-z]+$/,mp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,hp=/^[0-9a-vA-V]{20}$/,fp=/^[A-Za-z0-9]{27}$/,pp=/^[a-zA-Z0-9_-]{21}$/,xp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,gp=/^([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})$/,Wo=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)$/,yp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,bp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function vp(){return new RegExp(bp,"u")}const jp=/^(?:(?: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])$/,wp=/^(([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}|:))$/,Np=/^((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])$/,Sp=/^(([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])$/,kp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Yc=/^[A-Za-z0-9_-]*$/,Cp=/^https?$/,Ap=/^\+[1-9]\d{6,14}$/,Hc="(?:(?:\\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])))",Pp=new RegExp(`^${Hc}$`);function Kc(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 Ep(e){return new RegExp(`^${Kc(e)}$`)}function Ip(e){const t=Kc({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Hc}T(?:${r})$`)}const Tp=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}$`)},_p=/^(?:true|false)$/i,Dp=/^[^A-Z]*$/,Fp=/^[^a-z]*$/,$t=F("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Rp=F("$ZodCheckMaxLength",(e,t)=>{var n;$t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!Di(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const a=r.value;if(a.length<=t.maximum)return;const o=Ri(a);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),$p=F("$ZodCheckMinLength",(e,t)=>{var n;$t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!Di(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const a=r.value;if(a.length>=t.minimum)return;const o=Ri(a);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),Lp=F("$ZodCheckLengthEquals",(e,t)=>{var n;$t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!Di(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=r=>{const a=r.value,i=a.length;if(i===t.length)return;const o=Ri(a),l=i>t.length;r.issues.push({origin:o,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Js=F("$ZodCheckStringFormat",(e,t)=>{var n,r;$t.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?(n=e._zod).check??(n.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})}):(r=e._zod).check??(r.check=()=>{})}),Op=F("$ZodCheckRegex",(e,t)=>{Js.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),zp=F("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Dp),Js.init(e,t)}),Mp=F("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Fp),Js.init(e,t)}),qp=F("$ZodCheckIncludes",(e,t)=>{$t.init(e,t);const n=lr(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),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})}}),Bp=F("$ZodCheckStartsWith",(e,t)=>{$t.init(e,t);const n=new RegExp(`^${lr(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const a=r._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Vp=F("$ZodCheckEndsWith",(e,t)=>{$t.init(e,t);const n=new RegExp(`.*${lr(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const a=r._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Up=F("$ZodCheckOverwrite",(e,t)=>{$t.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Zp{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 r=t.split(`
13
13
  `).filter(o=>o),a=Math.min(...r.map(o=>o.length-o.trimStart().length)),i=r.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,n=this==null?void 0:this.args,a=[...((this==null?void 0:this.content)??[""]).map(i=>` ${i}`)];return new t(...n,a.join(`
14
- `))}}const Up={major:4,minor:4,patch:3},De=D("$ZodType",(e,t)=>{var a;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Up;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const i of r)for(const o of i._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(a=e._zod.deferred)==null||a.push(()=>{e._zod.run=e._zod.parse});else{const i=(l,c,d)=>{let u=Un(l),m;for(const h of c){if(h._zod.def.when){if(Yf(l)||!h._zod.def.when(l))continue}else if(u)continue;const p=l.issues.length,y=h._zod.check(l);if(y instanceof Promise&&(d==null?void 0:d.async)===!1)throw new Wn;if(m||y instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await y,l.issues.length!==p&&(u||(u=Un(l,p)))});else{if(l.issues.length===p)continue;u||(u=Un(l,p))}}return m?m.then(()=>l):l},o=(l,c,d)=>{if(Un(l))return l.aborted=!0,l;const u=i(c,r,d);if(u instanceof Promise){if(d.async===!1)throw new Wn;return u.then(m=>e._zod.parse(m,d))}return e._zod.parse(u,d)};e._zod.run=(l,c)=>{if(c.skipChecks)return e._zod.parse(l,c);if(c.direction==="backward"){const u=e._zod.parse({value:l.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(m=>o(m,l,c)):o(u,l,c)}const d=e._zod.parse(l,c);if(d instanceof Promise){if(c.async===!1)throw new Wn;return d.then(u=>i(u,r,c))}return i(d,r,c)}}be(e,"~standard",()=>({validate:i=>{var o;try{const l=Gf(e,i);return l.success?{value:l.data}:{issues:(o=l.error)==null?void 0:o.issues}}catch{return Xf(e,i).then(c=>{var d;return c.success?{value:c.data}:{issues:(d=c.error)==null?void 0:d.issues}})}},vendor:"zod",version:1}))}),Li=D("$ZodString",(e,t)=>{var n;De.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??Ep(e._zod.bag),e._zod.parse=(r,a)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Ce=D("$ZodStringFormat",(e,t)=>{Js.init(e,t),Li.init(e,t)}),Zp=D("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=pp),Ce.init(e,t)}),Wp=D("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Zo(r))}else t.pattern??(t.pattern=Zo());Ce.init(e,t)}),Yp=D("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=xp),Ce.init(e,t)}),Hp=D("$ZodURL",(e,t)=>{Ce.init(e,t),e._zod.check=n=>{var r;try{const a=n.value.trim();if(!t.normalize&&((r=t.protocol)==null?void 0:r.source)===Sp.source&&!/^https?:\/\//i.test(a)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const i=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.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)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Kp=D("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=yp()),Ce.init(e,t)}),Qp=D("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=hp),Ce.init(e,t)}),Jp=D("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=lp),Ce.init(e,t)}),Gp=D("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=cp),Ce.init(e,t)}),Xp=D("$ZodULID",(e,t)=>{t.pattern??(t.pattern=up),Ce.init(e,t)}),ex=D("$ZodXID",(e,t)=>{t.pattern??(t.pattern=dp),Ce.init(e,t)}),tx=D("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=mp),Ce.init(e,t)}),nx=D("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Pp(t)),Ce.init(e,t)}),rx=D("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Cp),Ce.init(e,t)}),sx=D("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ap(t)),Ce.init(e,t)}),ax=D("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=fp),Ce.init(e,t)}),ix=D("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=bp),Ce.init(e,t),e._zod.bag.format="ipv4"}),ox=D("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=vp),Ce.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),lx=D("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=jp),Ce.init(e,t)}),cx=D("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=wp),Ce.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[a,i]=r;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{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Hc(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const ux=D("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Np),Ce.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Hc(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function dx(e){if(!Zc.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Hc(n)}const mx=D("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Zc),Ce.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{dx(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),hx=D("$ZodE164",(e,t)=>{t.pattern??(t.pattern=kp),Ce.init(e,t)});function fx(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const a=JSON.parse(atob(r));return!("typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||t&&(!("alg"in a)||a.alg!==t))}catch{return!1}}const px=D("$ZodJWT",(e,t)=>{Ce.init(e,t),e._zod.check=n=>{fx(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),xx=D("$ZodBoolean",(e,t)=>{De.init(e,t),e._zod.pattern=Ip,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const a=n.value;return typeof a=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:a,inst:e}),n}}),gx=D("$ZodUnknown",(e,t)=>{De.init(e,t),e._zod.parse=n=>n}),yx=D("$ZodNever",(e,t)=>{De.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Wo(e,t,n){e.issues.length&&t.issues.push(...Vc(n,e.issues)),t.value[n]=e.value}const bx=D("$ZodArray",(e,t)=>{De.init(e,t),e._zod.parse=(n,r)=>{const a=n.value;if(!Array.isArray(a))return n.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),n;n.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:[]},r);c instanceof Promise?i.push(c.then(d=>Wo(d,n,o))):Wo(c,n,o)}return i.length?Promise.all(i).then(()=>n):n}});function Ps(e,t,n,r,a,i){const o=n in r;if(e.issues.length){if(a&&i&&!o)return;t.issues.push(...Vc(n,e.issues))}if(!o&&!a){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Kc(e){var r,a,i,o;const t=Object.keys(e.shape);for(const l of t)if(!((o=(i=(a=(r=e.shape)==null?void 0:r[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 n=zf(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Qc(e,t,n,r,a,i){const o=[],l=a.keySet,c=a.catchall._zod,d=c.def.type,u=c.optin==="optional",m=c.optout==="optional";for(const h in t){if(h==="__proto__"||l.has(h))continue;if(d==="never"){o.push(h);continue}const p=c.run({value:t[h],issues:[]},r);p instanceof Promise?e.push(p.then(y=>Ps(y,n,h,t,u,m))):Ps(p,n,h,t,u,m)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const vx=D("$ZodObject",(e,t)=>{De.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...l};return Object.defineProperty(t,"shape",{value:c}),c}})}const r=_i(()=>Kc(t));be(e._zod,"propValues",()=>{const l=t.shape,c={};for(const d in l){const u=l[d]._zod;if(u.values){c[d]??(c[d]=new Set);for(const m of u.values)c[d].add(m)}}return c});const a=As,i=t.catchall;let o;e._zod.parse=(l,c)=>{o??(o=r.value);const d=l.value;if(!a(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value={};const u=[],m=o.shape;for(const h of o.keys){const p=m[h],y=p._zod.optin==="optional",x=p._zod.optout==="optional",j=p._zod.run({value:d[h],issues:[]},c);j instanceof Promise?u.push(j.then(g=>Ps(g,l,h,d,y,x))):Ps(j,l,h,d,y,x)}return i?Qc(u,d,l,c,r.value,e):u.length?Promise.all(u).then(()=>l):l}}),jx=D("$ZodObjectJIT",(e,t)=>{vx.init(e,t);const n=e._zod.parse,r=_i(()=>Kc(t)),a=h=>{var b,S;const p=new Vp(["shape","payload","ctx"]),y=r.value,x=I=>{const R=Uo(I);return`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`};p.write("const input = payload.value;");const j=Object.create(null);let g=0;for(const I of y.keys)j[I]=`key_${g++}`;p.write("const newResult = {};");for(const I of y.keys){const R=j[I],E=Uo(I),T=h[I],L=((b=T==null?void 0:T._zod)==null?void 0:b.optin)==="optional",B=((S=T==null?void 0:T._zod)==null?void 0:S.optout)==="optional";p.write(`const ${R} = ${x(I)};`),L&&B?p.write(`
14
+ `))}}const Wp={major:4,minor:4,patch:3},Fe=F("$ZodType",(e,t)=>{var a;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Wp;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const i of r)for(const o of i._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(a=e._zod.deferred)==null||a.push(()=>{e._zod.run=e._zod.parse});else{const i=(l,c,d)=>{let u=Vn(l),m;for(const h of c){if(h._zod.def.when){if(Kf(l)||!h._zod.def.when(l))continue}else if(u)continue;const p=l.issues.length,g=h._zod.check(l);if(g instanceof Promise&&(d==null?void 0:d.async)===!1)throw new Zn;if(m||g instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await g,l.issues.length!==p&&(u||(u=Vn(l,p)))});else{if(l.issues.length===p)continue;u||(u=Vn(l,p))}}return m?m.then(()=>l):l},o=(l,c,d)=>{if(Vn(l))return l.aborted=!0,l;const u=i(c,r,d);if(u instanceof Promise){if(d.async===!1)throw new Zn;return u.then(m=>e._zod.parse(m,d))}return e._zod.parse(u,d)};e._zod.run=(l,c)=>{if(c.skipChecks)return e._zod.parse(l,c);if(c.direction==="backward"){const u=e._zod.parse({value:l.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(m=>o(m,l,c)):o(u,l,c)}const d=e._zod.parse(l,c);if(d instanceof Promise){if(c.async===!1)throw new Zn;return d.then(u=>i(u,r,c))}return i(d,r,c)}}ve(e,"~standard",()=>({validate:i=>{var o;try{const l=ep(e,i);return l.success?{value:l.data}:{issues:(o=l.error)==null?void 0:o.issues}}catch{return tp(e,i).then(c=>{var d;return c.success?{value:c.data}:{issues:(d=c.error)==null?void 0:d.issues}})}},vendor:"zod",version:1}))}),Li=F("$ZodString",(e,t)=>{var n;Fe.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??Tp(e._zod.bag),e._zod.parse=(r,a)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Ce=F("$ZodStringFormat",(e,t)=>{Js.init(e,t),Li.init(e,t)}),Yp=F("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=gp),Ce.init(e,t)}),Hp=F("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Wo(r))}else t.pattern??(t.pattern=Wo());Ce.init(e,t)}),Kp=F("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=yp),Ce.init(e,t)}),Qp=F("$ZodURL",(e,t)=>{Ce.init(e,t),e._zod.check=n=>{var r;try{const a=n.value.trim();if(!t.normalize&&((r=t.protocol)==null?void 0:r.source)===Cp.source&&!/^https?:\/\//i.test(a)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const i=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.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)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Jp=F("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=vp()),Ce.init(e,t)}),Gp=F("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=pp),Ce.init(e,t)}),Xp=F("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=up),Ce.init(e,t)}),ex=F("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=dp),Ce.init(e,t)}),tx=F("$ZodULID",(e,t)=>{t.pattern??(t.pattern=mp),Ce.init(e,t)}),nx=F("$ZodXID",(e,t)=>{t.pattern??(t.pattern=hp),Ce.init(e,t)}),rx=F("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=fp),Ce.init(e,t)}),sx=F("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ip(t)),Ce.init(e,t)}),ax=F("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Pp),Ce.init(e,t)}),ix=F("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ep(t)),Ce.init(e,t)}),ox=F("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=xp),Ce.init(e,t)}),lx=F("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=jp),Ce.init(e,t),e._zod.bag.format="ipv4"}),cx=F("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=wp),Ce.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),ux=F("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Np),Ce.init(e,t)}),dx=F("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Sp),Ce.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[a,i]=r;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{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Qc(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const mx=F("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=kp),Ce.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Qc(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function hx(e){if(!Yc.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Qc(n)}const fx=F("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Yc),Ce.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{hx(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),px=F("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ap),Ce.init(e,t)});function xx(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const a=JSON.parse(atob(r));return!("typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||t&&(!("alg"in a)||a.alg!==t))}catch{return!1}}const gx=F("$ZodJWT",(e,t)=>{Ce.init(e,t),e._zod.check=n=>{xx(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),yx=F("$ZodBoolean",(e,t)=>{Fe.init(e,t),e._zod.pattern=_p,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const a=n.value;return typeof a=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:a,inst:e}),n}}),bx=F("$ZodUnknown",(e,t)=>{Fe.init(e,t),e._zod.parse=n=>n}),vx=F("$ZodNever",(e,t)=>{Fe.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Yo(e,t,n){e.issues.length&&t.issues.push(...Zc(n,e.issues)),t.value[n]=e.value}const jx=F("$ZodArray",(e,t)=>{Fe.init(e,t),e._zod.parse=(n,r)=>{const a=n.value;if(!Array.isArray(a))return n.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),n;n.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:[]},r);c instanceof Promise?i.push(c.then(d=>Yo(d,n,o))):Yo(c,n,o)}return i.length?Promise.all(i).then(()=>n):n}});function Ps(e,t,n,r,a,i){const o=n in r;if(e.issues.length){if(a&&i&&!o)return;t.issues.push(...Zc(n,e.issues))}if(!o&&!a){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Jc(e){var r,a,i,o;const t=Object.keys(e.shape);for(const l of t)if(!((o=(i=(a=(r=e.shape)==null?void 0:r[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 n=qf(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Gc(e,t,n,r,a,i){const o=[],l=a.keySet,c=a.catchall._zod,d=c.def.type,u=c.optin==="optional",m=c.optout==="optional";for(const h in t){if(h==="__proto__"||l.has(h))continue;if(d==="never"){o.push(h);continue}const p=c.run({value:t[h],issues:[]},r);p instanceof Promise?e.push(p.then(g=>Ps(g,n,h,t,u,m))):Ps(p,n,h,t,u,m)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const wx=F("$ZodObject",(e,t)=>{Fe.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...l};return Object.defineProperty(t,"shape",{value:c}),c}})}const r=_i(()=>Jc(t));ve(e._zod,"propValues",()=>{const l=t.shape,c={};for(const d in l){const u=l[d]._zod;if(u.values){c[d]??(c[d]=new Set);for(const m of u.values)c[d].add(m)}}return c});const a=As,i=t.catchall;let o;e._zod.parse=(l,c)=>{o??(o=r.value);const d=l.value;if(!a(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value={};const u=[],m=o.shape;for(const h of o.keys){const p=m[h],g=p._zod.optin==="optional",x=p._zod.optout==="optional",b=p._zod.run({value:d[h],issues:[]},c);b instanceof Promise?u.push(b.then(y=>Ps(y,l,h,d,g,x))):Ps(b,l,h,d,g,x)}return i?Gc(u,d,l,c,r.value,e):u.length?Promise.all(u).then(()=>l):l}}),Nx=F("$ZodObjectJIT",(e,t)=>{wx.init(e,t);const n=e._zod.parse,r=_i(()=>Jc(t)),a=h=>{var j,S;const p=new Zp(["shape","payload","ctx"]),g=r.value,x=I=>{const R=Zo(I);return`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`};p.write("const input = payload.value;");const b=Object.create(null);let y=0;for(const I of g.keys)b[I]=`key_${y++}`;p.write("const newResult = {};");for(const I of g.keys){const R=b[I],E=Zo(I),T=h[I],L=((j=T==null?void 0:T._zod)==null?void 0:j.optin)==="optional",B=((S=T==null?void 0:T._zod)==null?void 0:S.optout)==="optional";p.write(`const ${R} = ${x(I)};`),L&&B?p.write(`
15
15
  if (${R}.issues.length) {
16
16
  if (${E} in input) {
17
17
  payload.issues = payload.issues.concat(${R}.issues.map(iss => ({
@@ -70,7 +70,7 @@ Please change the parent <Route path="${g}"> to <Route path="${g==="/"?"*":`${g}
70
70
  }
71
71
  }
72
72
 
73
- `)}p.write("payload.value = newResult;"),p.write("return payload;");const C=p.compile();return(I,R)=>C(h,I,R)};let i;const o=As,l=!Ti.jitless,d=l&&Lf.value,u=t.catchall;let m;e._zod.parse=(h,p)=>{m??(m=r.value);const y=h.value;return o(y)?l&&d&&(p==null?void 0:p.async)===!1&&p.jitless!==!0?(i||(i=a(t.shape)),h=i(h,p),u?Qc([],y,h,p,m,e):h):n(h,p):(h.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),h)}});function Yo(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const a=e.filter(i=>!Un(i));return a.length===1?(t.value=a[0].value,a[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(o=>Rn(o,r,Dn())))}),t)}const wx=D("$ZodUnion",(e,t)=>{De.init(e,t),be(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),be(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),be(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),be(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${r.map(a=>Di(a.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,a)=>{if(n)return n(r,a);let i=!1;const o=[];for(const l of t.options){const c=l._zod.run({value:r.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=>Yo(l,r,e,a)):Yo(o,r,e,a)}}),Nx=D("$ZodIntersection",(e,t)=>{De.init(e,t),e._zod.parse=(n,r)=>{const a=n.value,i=t.left._zod.run({value:a,issues:[]},r),o=t.right._zod.run({value:a,issues:[]},r);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,d])=>Ho(n,c,d)):Ho(n,i,o)}});function Qa(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(Rr(e)&&Rr(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),a={...e,...t};for(const i of r){const o=Qa(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 n=[];for(let r=0;r<e.length;r++){const a=e[r],i=t[r],o=Qa(a,i);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ho(e,t,n){const r=new Map;let a;for(const l of t.issues)if(l.code==="unrecognized_keys"){a??(a=l);for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(l);for(const l of n.issues)if(l.code==="unrecognized_keys")for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(l);const i=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(i.length&&a&&e.issues.push({...a,keys:i}),Un(e))return e;const o=Qa(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const Sx=D("$ZodEnum",(e,t)=>{De.init(e,t);const n=Mc(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(a=>Of.has(typeof a)).map(a=>typeof a=="string"?cr(a):a.toString()).join("|")})$`),e._zod.parse=(a,i)=>{const o=a.value;return r.has(o)||a.issues.push({code:"invalid_value",values:n,input:o,inst:e}),a}}),kx=D("$ZodLiteral",(e,t)=>{if(De.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?cr(r):r?cr(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,a)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),Cx=D("$ZodTransform",(e,t)=>{De.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new zc(e.constructor.name);const a=t.transform(n.value,n);if(r.async)return(a instanceof Promise?a:Promise.resolve(a)).then(o=>(n.value=o,n.fallback=!0,n));if(a instanceof Promise)throw new Wn;return n.value=a,n.fallback=!0,n}});function Ko(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Jc=D("$ZodOptional",(e,t)=>{De.init(e,t),e._zod.optin="optional",e._zod.optout="optional",be(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),be(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Di(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const a=n.value,i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>Ko(o,a)):Ko(i,a)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Ax=D("$ZodExactOptional",(e,t)=>{Jc.init(e,t),be(e._zod,"values",()=>t.innerType._zod.values),be(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Px=D("$ZodNullable",(e,t)=>{De.init(e,t),be(e._zod,"optin",()=>t.innerType._zod.optin),be(e._zod,"optout",()=>t.innerType._zod.optout),be(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Di(n.source)}|null)$`):void 0}),be(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Ex=D("$ZodDefault",(e,t)=>{De.init(e,t),e._zod.optin="optional",be(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(i=>Qo(i,t)):Qo(a,t)}});function Qo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Ix=D("$ZodPrefault",(e,t)=>{De.init(e,t),e._zod.optin="optional",be(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Tx=D("$ZodNonOptional",(e,t)=>{De.init(e,t),be(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(i=>Jo(i,e)):Jo(a,e)}});function Jo(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 _x=D("$ZodCatch",(e,t)=>{De.init(e,t),e._zod.optin="optional",be(e._zod,"optout",()=>t.innerType._zod.optout),be(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>Rn(o,r,Dn()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=a.value,a.issues.length&&(n.value=t.catchValue({...n,error:{issues:a.issues.map(i=>Rn(i,r,Dn()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),Fx=D("$ZodPipe",(e,t)=>{De.init(e,t),be(e._zod,"values",()=>t.in._zod.values),be(e._zod,"optin",()=>t.in._zod.optin),be(e._zod,"optout",()=>t.out._zod.optout),be(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(o=>is(o,t.in,r)):is(i,t.in,r)}const a=t.in._zod.run(n,r);return a instanceof Promise?a.then(i=>is(i,t.out,r)):is(a,t.out,r)}});function is(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const Dx=D("$ZodReadonly",(e,t)=>{De.init(e,t),be(e._zod,"propValues",()=>t.innerType._zod.propValues),be(e._zod,"values",()=>t.innerType._zod.values),be(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),be(e._zod,"optout",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(Go):Go(a)}});function Go(e){return e.value=Object.freeze(e.value),e}const Rx=D("$ZodCustom",(e,t)=>{$t.init(e,t),De.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,a=t.fn(r);if(a instanceof Promise)return a.then(i=>Xo(i,n,r,e));Xo(a,n,r,e)}});function Xo(e,t,n,r){if(!e){const a={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(a.params=r._zod.def.params),t.issues.push($r(a))}}var el;class $x{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const a={...r,...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 Lx(){return new $x}(el=globalThis).__zod_globalRegistry??(el.__zod_globalRegistry=Lx());const Er=globalThis.__zod_globalRegistry;function Ox(e,t){return new e({type:"string",...se(t)})}function Gc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...se(t)})}function tl(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...se(t)})}function zx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...se(t)})}function Mx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...se(t)})}function qx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...se(t)})}function Bx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...se(t)})}function Vx(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...se(t)})}function Ux(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...se(t)})}function Zx(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...se(t)})}function Wx(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...se(t)})}function Yx(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...se(t)})}function Hx(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...se(t)})}function Kx(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...se(t)})}function Qx(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...se(t)})}function Jx(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...se(t)})}function Gx(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...se(t)})}function Xx(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...se(t)})}function eg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...se(t)})}function tg(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...se(t)})}function ng(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...se(t)})}function rg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...se(t)})}function sg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...se(t)})}function ag(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...se(t)})}function ig(e,t){return new e({type:"string",format:"date",check:"string_format",...se(t)})}function og(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...se(t)})}function lg(e,t){return new e({type:"string",format:"duration",check:"string_format",...se(t)})}function cg(e,t){return new e({type:"boolean",...se(t)})}function ug(e){return new e({type:"unknown"})}function dg(e,t){return new e({type:"never",...se(t)})}function Xc(e,t){return new Fp({check:"max_length",...se(t),maximum:e})}function Es(e,t){return new Dp({check:"min_length",...se(t),minimum:e})}function eu(e,t){return new Rp({check:"length_equals",...se(t),length:e})}function mg(e,t){return new $p({check:"string_format",format:"regex",...se(t),pattern:e})}function hg(e){return new Lp({check:"string_format",format:"lowercase",...se(e)})}function fg(e){return new Op({check:"string_format",format:"uppercase",...se(e)})}function pg(e,t){return new zp({check:"string_format",format:"includes",...se(t),includes:e})}function xg(e,t){return new Mp({check:"string_format",format:"starts_with",...se(t),prefix:e})}function gg(e,t){return new qp({check:"string_format",format:"ends_with",...se(t),suffix:e})}function yr(e){return new Bp({check:"overwrite",tx:e})}function yg(e){return yr(t=>t.normalize(e))}function bg(){return yr(e=>e.trim())}function vg(){return yr(e=>e.toLowerCase())}function jg(){return yr(e=>e.toUpperCase())}function wg(){return yr(e=>$f(e))}function Ng(e,t,n){return new e({type:"array",element:t,...se(n)})}function Sg(e,t,n){return new e({type:"custom",check:"custom",fn:t,...se(n)})}function kg(e,t){const n=Cg(r=>(r.addIssue=a=>{if(typeof a=="string")r.issues.push($r(a,r.value,n._zod.def));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push($r(i))}},e(r.value,r)),t);return n}function Cg(e,t){const n=new $t({check:"custom",...se(t)});return n._zod.check=e,n}function tu(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)??Er,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 Ze(e,t,n={path:[],schemaPath:[]}){var u,m;var r;const a=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);const l=(m=(u=e._zod).toJSONSchema)==null?void 0:m.call(u);if(l)o.schema=l;else{const h={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,h);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,h)}const p=e._zod.parent;p&&(o.ref||(o.ref=p),Ze(p,t,h),t.seen.get(p).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io==="input"&&Ge(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function nu(e,t){var o,l,c,d;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const u of e.seen.entries()){const m=(o=e.metadataRegistry.get(u[0]))==null?void 0:o.id;if(m){const h=r.get(m);if(h&&h!==u[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(m,u[0])}}const a=u=>{var x;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const j=(x=e.external.registry.get(u[0]))==null?void 0:x.id,g=e.external.uri??(b=>b);if(j)return{ref:g(j)};const C=u[1].defId??u[1].schema.id??`schema${e.counter++}`;return u[1].defId=C,{defId:C,ref:`${g("__shared")}#/${m}/${C}`}}if(u[1]===n)return{ref:"#"};const p=`#/${m}/`,y=u[1].schema.id??`__schema${e.counter++}`;return{defId:y,ref:p+y}},i=u=>{if(u[1].schema.$ref)return;const m=u[1],{ref:h,defId:p}=a(u);m.def={...m.schema},p&&(m.defId=p);const y=m.schema;for(const x in y)delete y[x];y.$ref=h};if(e.cycles==="throw")for(const u of e.seen.entries()){const m=u[1];if(m.cycle)throw new Error(`Cycle detected: #/${(l=m.cycle)==null?void 0:l.join("/")}/<root>
73
+ `)}p.write("payload.value = newResult;"),p.write("return payload;");const C=p.compile();return(I,R)=>C(h,I,R)};let i;const o=As,l=!Ti.jitless,d=l&&zf.value,u=t.catchall;let m;e._zod.parse=(h,p)=>{m??(m=r.value);const g=h.value;return o(g)?l&&d&&(p==null?void 0:p.async)===!1&&p.jitless!==!0?(i||(i=a(t.shape)),h=i(h,p),u?Gc([],g,h,p,m,e):h):n(h,p):(h.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),h)}});function Ho(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const a=e.filter(i=>!Vn(i));return a.length===1?(t.value=a[0].value,a[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(o=>Rn(o,r,Fn())))}),t)}const Sx=F("$ZodUnion",(e,t)=>{Fe.init(e,t),ve(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),ve(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),ve(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),ve(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${r.map(a=>Fi(a.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,a)=>{if(n)return n(r,a);let i=!1;const o=[];for(const l of t.options){const c=l._zod.run({value:r.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,r,e,a)):Ho(o,r,e,a)}}),kx=F("$ZodIntersection",(e,t)=>{Fe.init(e,t),e._zod.parse=(n,r)=>{const a=n.value,i=t.left._zod.run({value:a,issues:[]},r),o=t.right._zod.run({value:a,issues:[]},r);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,d])=>Ko(n,c,d)):Ko(n,i,o)}});function Qa(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(Fr(e)&&Fr(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),a={...e,...t};for(const i of r){const o=Qa(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 n=[];for(let r=0;r<e.length;r++){const a=e[r],i=t[r],o=Qa(a,i);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ko(e,t,n){const r=new Map;let a;for(const l of t.issues)if(l.code==="unrecognized_keys"){a??(a=l);for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(l);for(const l of n.issues)if(l.code==="unrecognized_keys")for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(l);const i=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(i.length&&a&&e.issues.push({...a,keys:i}),Vn(e))return e;const o=Qa(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const Cx=F("$ZodEnum",(e,t)=>{Fe.init(e,t);const n=Bc(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(a=>Mf.has(typeof a)).map(a=>typeof a=="string"?lr(a):a.toString()).join("|")})$`),e._zod.parse=(a,i)=>{const o=a.value;return r.has(o)||a.issues.push({code:"invalid_value",values:n,input:o,inst:e}),a}}),Ax=F("$ZodLiteral",(e,t)=>{if(Fe.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?lr(r):r?lr(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,a)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),Px=F("$ZodTransform",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new qc(e.constructor.name);const a=t.transform(n.value,n);if(r.async)return(a instanceof Promise?a:Promise.resolve(a)).then(o=>(n.value=o,n.fallback=!0,n));if(a instanceof Promise)throw new Zn;return n.value=a,n.fallback=!0,n}});function Qo(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Xc=F("$ZodOptional",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ve(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ve(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Fi(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const a=n.value,i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>Qo(o,a)):Qo(i,a)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Ex=F("$ZodExactOptional",(e,t)=>{Xc.init(e,t),ve(e._zod,"values",()=>t.innerType._zod.values),ve(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Ix=F("$ZodNullable",(e,t)=>{Fe.init(e,t),ve(e._zod,"optin",()=>t.innerType._zod.optin),ve(e._zod,"optout",()=>t.innerType._zod.optout),ve(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Fi(n.source)}|null)$`):void 0}),ve(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Tx=F("$ZodDefault",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",ve(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(i=>Jo(i,t)):Jo(a,t)}});function Jo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const _x=F("$ZodPrefault",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",ve(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Dx=F("$ZodNonOptional",(e,t)=>{Fe.init(e,t),ve(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(i=>Go(i,e)):Go(a,e)}});function Go(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 Fx=F("$ZodCatch",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",ve(e._zod,"optout",()=>t.innerType._zod.optout),ve(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>Rn(o,r,Fn()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=a.value,a.issues.length&&(n.value=t.catchValue({...n,error:{issues:a.issues.map(i=>Rn(i,r,Fn()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),Rx=F("$ZodPipe",(e,t)=>{Fe.init(e,t),ve(e._zod,"values",()=>t.in._zod.values),ve(e._zod,"optin",()=>t.in._zod.optin),ve(e._zod,"optout",()=>t.out._zod.optout),ve(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(o=>is(o,t.in,r)):is(i,t.in,r)}const a=t.in._zod.run(n,r);return a instanceof Promise?a.then(i=>is(i,t.out,r)):is(a,t.out,r)}});function is(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const $x=F("$ZodReadonly",(e,t)=>{Fe.init(e,t),ve(e._zod,"propValues",()=>t.innerType._zod.propValues),ve(e._zod,"values",()=>t.innerType._zod.values),ve(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),ve(e._zod,"optout",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(Xo):Xo(a)}});function Xo(e){return e.value=Object.freeze(e.value),e}const Lx=F("$ZodCustom",(e,t)=>{$t.init(e,t),Fe.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,a=t.fn(r);if(a instanceof Promise)return a.then(i=>el(i,n,r,e));el(a,n,r,e)}});function el(e,t,n,r){if(!e){const a={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(a.params=r._zod.def.params),t.issues.push(Rr(a))}}var tl;class Ox{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const a={...r,...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 zx(){return new Ox}(tl=globalThis).__zod_globalRegistry??(tl.__zod_globalRegistry=zx());const Pr=globalThis.__zod_globalRegistry;function Mx(e,t){return new e({type:"string",...se(t)})}function eu(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...se(t)})}function nl(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...se(t)})}function qx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...se(t)})}function Bx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...se(t)})}function Vx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...se(t)})}function Ux(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...se(t)})}function Zx(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...se(t)})}function Wx(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...se(t)})}function Yx(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...se(t)})}function Hx(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...se(t)})}function Kx(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...se(t)})}function Qx(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...se(t)})}function Jx(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...se(t)})}function Gx(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...se(t)})}function Xx(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...se(t)})}function eg(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...se(t)})}function tg(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...se(t)})}function ng(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...se(t)})}function rg(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...se(t)})}function sg(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...se(t)})}function ag(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...se(t)})}function ig(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...se(t)})}function og(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...se(t)})}function lg(e,t){return new e({type:"string",format:"date",check:"string_format",...se(t)})}function cg(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...se(t)})}function ug(e,t){return new e({type:"string",format:"duration",check:"string_format",...se(t)})}function dg(e,t){return new e({type:"boolean",...se(t)})}function mg(e){return new e({type:"unknown"})}function hg(e,t){return new e({type:"never",...se(t)})}function tu(e,t){return new Rp({check:"max_length",...se(t),maximum:e})}function Es(e,t){return new $p({check:"min_length",...se(t),minimum:e})}function nu(e,t){return new Lp({check:"length_equals",...se(t),length:e})}function fg(e,t){return new Op({check:"string_format",format:"regex",...se(t),pattern:e})}function pg(e){return new zp({check:"string_format",format:"lowercase",...se(e)})}function xg(e){return new Mp({check:"string_format",format:"uppercase",...se(e)})}function gg(e,t){return new qp({check:"string_format",format:"includes",...se(t),includes:e})}function yg(e,t){return new Bp({check:"string_format",format:"starts_with",...se(t),prefix:e})}function bg(e,t){return new Vp({check:"string_format",format:"ends_with",...se(t),suffix:e})}function gr(e){return new Up({check:"overwrite",tx:e})}function vg(e){return gr(t=>t.normalize(e))}function jg(){return gr(e=>e.trim())}function wg(){return gr(e=>e.toLowerCase())}function Ng(){return gr(e=>e.toUpperCase())}function Sg(){return gr(e=>Of(e))}function kg(e,t,n){return new e({type:"array",element:t,...se(n)})}function Cg(e,t,n){return new e({type:"custom",check:"custom",fn:t,...se(n)})}function Ag(e,t){const n=Pg(r=>(r.addIssue=a=>{if(typeof a=="string")r.issues.push(Rr(a,r.value,n._zod.def));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(Rr(i))}},e(r.value,r)),t);return n}function Pg(e,t){const n=new $t({check:"custom",...se(t)});return n._zod.check=e,n}function ru(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)??Pr,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 We(e,t,n={path:[],schemaPath:[]}){var u,m;var r;const a=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);const l=(m=(u=e._zod).toJSONSchema)==null?void 0:m.call(u);if(l)o.schema=l;else{const h={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,h);else{const g=o.schema,x=t.processors[a.type];if(!x)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);x(e,t,g,h)}const p=e._zod.parent;p&&(o.ref||(o.ref=p),We(p,t,h),t.seen.get(p).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io==="input"&&Xe(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function su(e,t){var o,l,c,d;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const u of e.seen.entries()){const m=(o=e.metadataRegistry.get(u[0]))==null?void 0:o.id;if(m){const h=r.get(m);if(h&&h!==u[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(m,u[0])}}const a=u=>{var x;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const b=(x=e.external.registry.get(u[0]))==null?void 0:x.id,y=e.external.uri??(j=>j);if(b)return{ref:y(b)};const C=u[1].defId??u[1].schema.id??`schema${e.counter++}`;return u[1].defId=C,{defId:C,ref:`${y("__shared")}#/${m}/${C}`}}if(u[1]===n)return{ref:"#"};const p=`#/${m}/`,g=u[1].schema.id??`__schema${e.counter++}`;return{defId:g,ref:p+g}},i=u=>{if(u[1].schema.$ref)return;const m=u[1],{ref:h,defId:p}=a(u);m.def={...m.schema},p&&(m.defId=p);const g=m.schema;for(const x in g)delete g[x];g.$ref=h};if(e.cycles==="throw")for(const u of e.seen.entries()){const m=u[1];if(m.cycle)throw new Error(`Cycle detected: #/${(l=m.cycle)==null?void 0:l.join("/")}/<root>
74
74
 
75
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const u of e.seen.entries()){const m=u[1];if(t===u[0]){i(u);continue}if(e.external){const p=(c=e.external.registry.get(u[0]))==null?void 0:c.id;if(t!==u[0]&&p){i(u);continue}}if((d=e.metadataRegistry.get(u[0]))==null?void 0:d.id){i(u);continue}if(m.cycle){i(u);continue}if(m.count>1&&e.reused==="ref"){i(u);continue}}}function ru(e,t){var l,c,d,u;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=m=>{const h=e.seen.get(m);if(h.ref===null)return;const p=h.def??h.schema,y={...p},x=h.ref;if(h.ref=null,x){r(x);const g=e.seen.get(x),C=g.schema;if(C.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(C)):Object.assign(p,C),Object.assign(p,y),m._zod.parent===x)for(const S in p)S==="$ref"||S==="allOf"||S in y||delete p[S];if(C.$ref&&g.def)for(const S in p)S==="$ref"||S==="allOf"||S in g.def&&JSON.stringify(p[S])===JSON.stringify(g.def[S])&&delete p[S]}const j=m._zod.parent;if(j&&j!==x){r(j);const g=e.seen.get(j);if(g!=null&&g.schema.$ref&&(p.$ref=g.schema.$ref,g.def))for(const C in p)C==="$ref"||C==="allOf"||C in g.def&&JSON.stringify(p[C])===JSON.stringify(g.def[C])&&delete p[C]}e.override({zodSchema:m,jsonSchema:p,path:h.path??[]})};for(const m of[...e.seen.entries()].reverse())r(m[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 m=(c=e.external.registry.get(t))==null?void 0:c.id;if(!m)throw new Error("Schema is missing an `id` property");a.$id=e.external.uri(m)}Object.assign(a,n.def??n.schema);const i=(d=e.metadataRegistry.get(t))==null?void 0:d.id;i!==void 0&&a.id===i&&delete a.id;const o=((u=e.external)==null?void 0:u.defs)??{};for(const m of e.seen.entries()){const h=m[1];h.def&&h.defId&&(h.def.id===h.defId&&delete h.def.id,o[h.defId]=h.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?a.$defs=o:a.definitions=o);try{const m=JSON.parse(JSON.stringify(a));return Object.defineProperty(m,"~standard",{value:{...t["~standard"],jsonSchema:{input:Is(t,"input",e.processors),output:Is(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function Ge(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Ge(r.element,n);if(r.type==="set")return Ge(r.valueType,n);if(r.type==="lazy")return Ge(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Ge(r.innerType,n);if(r.type==="intersection")return Ge(r.left,n)||Ge(r.right,n);if(r.type==="record"||r.type==="map")return Ge(r.keyType,n)||Ge(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Ge(r.in,n)||Ge(r.out,n);if(r.type==="object"){for(const a in r.shape)if(Ge(r.shape[a],n))return!0;return!1}if(r.type==="union"){for(const a of r.options)if(Ge(a,n))return!0;return!1}if(r.type==="tuple"){for(const a of r.items)if(Ge(a,n))return!0;return!!(r.rest&&Ge(r.rest,n))}return!1}const Ag=(e,t={})=>n=>{const r=tu({...n,processors:t});return Ze(e,r),nu(r,e),ru(r,e)},Is=(e,t,n={})=>r=>{const{libraryOptions:a,target:i}=r??{},o=tu({...a??{},target:i,io:t,processors:n});return Ze(e,o),nu(o,e),ru(o,e)},Pg={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Eg=(e,t,n,r)=>{const a=n;a.type="string";const{minimum:i,maximum:o,format:l,patterns:c,contentEncoding:d}=e._zod.bag;if(typeof i=="number"&&(a.minLength=i),typeof o=="number"&&(a.maxLength=o),l&&(a.format=Pg[l]??l,a.format===""&&delete a.format,l==="time"&&delete a.format),d&&(a.contentEncoding=d),c&&c.size>0){const u=[...c];u.length===1?a.pattern=u[0].source:u.length>1&&(a.allOf=[...u.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},Ig=(e,t,n,r)=>{n.type="boolean"},Tg=(e,t,n,r)=>{n.not={}},_g=(e,t,n,r)=>{},Fg=(e,t,n,r)=>{const a=e._zod.def,i=Mc(a.entries);i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.enum=i},Dg=(e,t,n,r)=>{const a=e._zod.def,i=[];for(const o of a.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){const o=i[0];n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[o]:n.const=o}else i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),i.every(o=>typeof o=="boolean")&&(n.type="boolean"),i.every(o=>o===null)&&(n.type="null"),n.enum=i},Rg=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},$g=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Lg=(e,t,n,r)=>{const a=n,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=Ze(i.element,t,{...r,path:[...r.path,"items"]})},Og=(e,t,n,r)=>{var d;const a=n,i=e._zod.def;a.type="object",a.properties={};const o=i.shape;for(const u in o)a.properties[u]=Ze(o[u],t,{...r,path:[...r.path,"properties",u]});const l=new Set(Object.keys(o)),c=new Set([...l].filter(u=>{const m=i.shape[u]._zod;return t.io==="input"?m.optin===void 0:m.optout===void 0}));c.size>0&&(a.required=Array.from(c)),((d=i.catchall)==null?void 0:d._zod.def.type)==="never"?a.additionalProperties=!1:i.catchall?i.catchall&&(a.additionalProperties=Ze(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(a.additionalProperties=!1)},zg=(e,t,n,r)=>{const a=e._zod.def,i=a.inclusive===!1,o=a.options.map((l,c)=>Ze(l,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=o:n.anyOf=o},Mg=(e,t,n,r)=>{const a=e._zod.def,i=Ze(a.left,t,{...r,path:[...r.path,"allOf",0]}),o=Ze(a.right,t,{...r,path:[...r.path,"allOf",1]}),l=d=>"allOf"in d&&Object.keys(d).length===1,c=[...l(i)?i.allOf:[i],...l(o)?o.allOf:[o]];n.allOf=c},qg=(e,t,n,r)=>{const a=e._zod.def,i=Ze(a.innerType,t,r),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=a.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},Bg=(e,t,n,r)=>{const a=e._zod.def;Ze(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType},Vg=(e,t,n,r)=>{const a=e._zod.def;Ze(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType,n.default=JSON.parse(JSON.stringify(a.defaultValue))},Ug=(e,t,n,r)=>{const a=e._zod.def;Ze(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(a.defaultValue)))},Zg=(e,t,n,r)=>{const a=e._zod.def;Ze(a.innerType,t,r);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")}n.default=o},Wg=(e,t,n,r)=>{const a=e._zod.def,i=a.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?i?a.out:a.in:a.out;Ze(o,t,r);const l=t.seen.get(e);l.ref=o},Yg=(e,t,n,r)=>{const a=e._zod.def;Ze(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType,n.readOnly=!0},su=(e,t,n,r)=>{const a=e._zod.def;Ze(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType};function Ja(){return Ja=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ja.apply(null,arguments)}function nl(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function Hg(e,t){for(var n={};e.length;){var r=e[0],a=r.code,i=r.message,o=r.path.join(".");if(!n[o])if("unionErrors"in r){var l=r.unionErrors[0].errors[0];n[o]={message:l.message,type:l.code}}else n[o]={message:i,type:a};if("unionErrors"in r&&r.unionErrors.forEach(function(u){return u.errors.forEach(function(m){return e.push(m)})}),t){var c=n[o].types,d=c&&c[r.code];n[o]=Pi(o,t,n,a,d?[].concat(d,r.message):r.message)}e.shift()}return n}function Kg(e,t){for(var n={},r=function(){var a=e[0],i=a.code,o=a.message,l=a.path.join(".");if(!n[l])if(a.code==="invalid_union"&&a.errors.length>0){var c=a.errors[0][0];n[l]={message:c.message,type:c.code}}else n[l]={message:o,type:i};if(a.code==="invalid_union"&&a.errors.forEach(function(m){return m.forEach(function(h){return e.push(Ja({},h,{path:[].concat(a.path,h.path)}))})}),t){var d=n[l].types,u=d&&d[a.code];n[l]=Pi(l,t,n,i,u?[].concat(u,a.message):a.message)}e.shift()};e.length;)r();return n}function Lt(e,t,n){if(n===void 0&&(n={}),(function(r){return"_def"in r&&typeof r._def=="object"&&"typeName"in r._def})(e))return function(r,a,i){try{return Promise.resolve(nl(function(){return Promise.resolve(e[n.mode==="sync"?"parse":"parseAsync"](r,t)).then(function(o){return i.shouldUseNativeValidation&&Ha({},i),{errors:{},values:n.raw?Object.assign({},r):o}})},function(o){if((function(l){return Array.isArray(l==null?void 0:l.issues)})(o))return{values:{},errors:Mo(Hg(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};if((function(r){return"_zod"in r&&typeof r._zod=="object"})(e))return function(r,a,i){try{return Promise.resolve(nl(function(){return Promise.resolve((n.mode==="sync"?Qf:Jf)(e,r,t)).then(function(o){return i.shouldUseNativeValidation&&Ha({},i),{errors:{},values:n.raw?Object.assign({},r):o}})},function(o){if((function(l){return l instanceof $i})(o))return{values:{},errors:Mo(Kg(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")}function Hr({label:e,required:t=!1,htmlFor:n,tooltip:r}){return s.jsxs("label",{htmlFor:n,className:"mb-1.5 flex items-center text-sm text-slate-600",children:[e,t?s.jsx("span",{className:"text-red-500",children:" *"}):null,r?s.jsx(Qg,{text:r}):null]})}function Qg({text:e}){return s.jsxs("span",{className:"group relative ml-1.5 inline-flex items-center",children:[s.jsxs("svg",{className:"h-4 w-4 cursor-help text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 16v-4M12 8h.01"})]}),s.jsx("span",{role:"tooltip",className:"pointer-events-none absolute bottom-full left-1/2 z-20 mb-1.5 w-max max-w-xs -translate-x-1/2 rounded-md bg-slate-800 px-2.5 py-1.5 text-xs font-normal leading-snug text-white opacity-0 shadow-lg transition-opacity duration-150 group-hover:opacity-100",children:e})]})}const he=v.forwardRef(function({label:t,required:n=!1,error:r,tooltip:a,id:i,className:o="",...l},c){const d=i??l.name;return s.jsxs("div",{children:[s.jsx(Hr,{label:t,required:n,htmlFor:d,tooltip:a}),s.jsx("input",{ref:c,id:d,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 ${r?"border-red-300":"border-slate-200"} ${o}`,...l}),r?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:r}):null]})}),xn=v.forwardRef(function({label:t,required:n=!1,error:r,id:a,className:i="",children:o,...l},c){const d=a??l.name;return s.jsxs("div",{children:[s.jsx(Hr,{label:t,required:n,htmlFor:d}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{ref:c,id:d,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 ${r?"border-red-300":"border-slate-200"} ${i}`,...l,children:o}),s.jsx(Jg,{})]}),r?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:r}):null]})});function au({step:e,title:t,muted:n=!1,children:r}){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 ${n?"text-slate-400":"text-gov-700"}`,children:t})]}),r]})}function Jg(){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 Ts({title:e,subtitle:t,step:n,children:r,className:a=""}){return s.jsxs("section",{className:`rounded-xl border border-slate-200 bg-white ${a}`,children:[s.jsxs("div",{className:"flex items-center gap-3 border-b border-slate-100 px-6 py-4",children:[n?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:n}):null,s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-slate-900",children:e}),t?s.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:t}):null]})]}),s.jsx("div",{className:"space-y-5 p-6",children:r})]})}function iu({label:e,required:t=!1,options:n,value:r,onChange:a}){const i=v.useId(),o=v.useRef([]),l=n.findIndex(u=>u.value===r),c=u=>{var h;const m=(u+n.length)%n.length;a(n[m].value),(h=o.current[m])==null||h.focus()},d=u=>{u.key==="ArrowRight"||u.key==="ArrowDown"?(u.preventDefault(),c(l+1)):(u.key==="ArrowLeft"||u.key==="ArrowUp")&&(u.preventDefault(),c(l-1))};return s.jsxs("div",{children:[s.jsx(Hr,{label:e,required:t,htmlFor:i}),s.jsx("div",{id:i,role:"radiogroup","aria-label":e,onKeyDown:d,className:"grid gap-3",style:{gridTemplateColumns:`repeat(${n.length}, minmax(0, 1fr))`},children:n.map((u,m)=>{const h=u.value===r;return s.jsxs("button",{ref:p=>{o.current[m]=p},type:"button",role:"radio","aria-checked":h,tabIndex:h?0:-1,onClick:()=>a(u.value),className:`flex items-center justify-center gap-2 rounded-lg border px-4 py-3 text-sm font-semibold transition focus:outline-none focus-visible:ring-2 focus-visible:ring-gov-500 focus-visible:ring-offset-1 sm:text-base ${h?"border-gov-400 bg-gov-50 text-gov-700 shadow-sm ring-1 ring-gov-200":"border-slate-200 bg-white text-slate-600 hover:border-slate-300 hover:bg-slate-50"}`,children:[u.icon?s.jsx("span",{className:h?"text-gov-600":"text-slate-400",children:u.icon}):null,u.label,h?s.jsx(Gg,{}):null]},u.value)})})]})}function Gg(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"3",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}function ou({label:e="Phone Number",required:t=!1,error:n,countryCodeSelectProps:r,phoneInputProps:a}){const i=a.id??a.name,o=n&&i?`${i}-error`:void 0;return s.jsxs("div",{children:[s.jsx(Hr,{label:e,required:t,htmlFor:i}),s.jsxs("div",{className:`flex overflow-hidden rounded-lg border bg-white transition focus-within:ring-2 focus-within:ring-gov-200 ${n?"border-red-300":"border-slate-200 focus-within:border-gov-400"}`,children:[s.jsxs("select",{"aria-label":"Country code",...r,className:"shrink-0 border-r border-slate-200 bg-slate-50 px-3 py-2.5 text-sm text-slate-900 focus:outline-none",children:[s.jsx("option",{value:"+1",children:"+1"}),s.jsx("option",{value:"+91",children:"+91"})]}),s.jsx("input",{type:"tel",inputMode:"numeric","aria-invalid":n?!0:void 0,"aria-describedby":o,...a,id:i,className:"block w-full border-0 px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none focus:ring-0"})]}),n?s.jsx("p",{id:o,className:"mt-1 text-xs text-red-600",children:n}):null]})}function lu({onCancel:e,isSubmitting:t,submitLabel:n,submittingLabel:r,cancelLabel:a="Cancel",className:i=""}){return s.jsxs("div",{className:`sticky bottom-0 flex flex-col-reverse gap-3 border-t border-slate-200 bg-white py-4 sm:flex-row sm:items-center ${i}`,children:[s.jsx("button",{type:"button",onClick:e,disabled:t,className:"inline-flex h-11 w-full 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 sm:w-auto",children:a}),s.jsx("button",{type:"submit",disabled:t,className:"inline-flex h-11 w-full 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 sm:w-auto",children:t?r:n})]})}function Ot({variant:e="error",title:t,message:n}){const r=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 ${r}`,role:"alert",children:[t?s.jsx("p",{className:"font-medium",children:t}):null,s.jsx("p",{className:t?"mt-1":void 0,children:n})]})}function tt(e,t){var n;if(e instanceof gr){if(e.details){const r=(n=Object.values(e.details)[0])==null?void 0:n[0];if(r)return r}return e.message||t}return e instanceof Error&&e.message?e.message:t}const Xg=D("ZodISODateTime",(e,t)=>{nx.init(e,t),Ie.init(e,t)});function ey(e){return ag(Xg,e)}const ty=D("ZodISODate",(e,t)=>{rx.init(e,t),Ie.init(e,t)});function ny(e){return ig(ty,e)}const ry=D("ZodISOTime",(e,t)=>{sx.init(e,t),Ie.init(e,t)});function sy(e){return og(ry,e)}const ay=D("ZodISODuration",(e,t)=>{ax.init(e,t),Ie.init(e,t)});function iy(e){return lg(ay,e)}const oy=(e,t)=>{$i.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Kf(e,n)},flatten:{value:n=>Hf(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Ka,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Ka,2)}},isEmpty:{get(){return e.issues.length===0}}})},yt=D("ZodError",oy,{Parent:Error}),ly=Ys(yt),cy=Hs(yt),uy=Ks(yt),dy=Qs(yt),my=ep(yt),hy=tp(yt),fy=np(yt),py=rp(yt),xy=sp(yt),gy=ap(yt),yy=ip(yt),by=op(yt),rl=new WeakMap;function Gs(e,t,n){const r=Object.getPrototypeOf(e);let a=rl.get(r);if(a||(a=new Set,rl.set(r,a)),!a.has(t)){a.add(t);for(const i in n){const o=n[i];Object.defineProperty(r,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 Re=D("ZodType",(e,t)=>(De.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Is(e,"input"),output:Is(e,"output")}}),e.toJSONSchema=Ag(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>ly(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>uy(e,n,r),e.parseAsync=async(n,r)=>cy(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>dy(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>my(e,n,r),e.decode=(n,r)=>hy(e,n,r),e.encodeAsync=async(n,r)=>fy(e,n,r),e.decodeAsync=async(n,r)=>py(e,n,r),e.safeEncode=(n,r)=>xy(e,n,r),e.safeDecode=(n,r)=>gy(e,n,r),e.safeEncodeAsync=async(n,r)=>yy(e,n,r),e.safeDecodeAsync=async(n,r)=>by(e,n,r),Gs(e,"ZodType",{check(...n){const r=this.def;return this.clone(gn(r,{checks:[...r.checks??[],...n.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return yn(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(db(n,r))},superRefine(n,r){return this.check(mb(n,r))},overwrite(n){return this.check(yr(n))},optional(){return il(this)},exactOptional(){return Gy(this)},nullable(){return ol(this)},nullish(){return il(ol(this))},nonoptional(n){return sb(this,n)},array(){return Vy(this)},or(n){return du([this,n])},and(n){return Yy(this,n)},transform(n){return ll(this,Qy(n))},default(n){return tb(this,n)},prefault(n){return rb(this,n)},catch(n){return ib(this,n)},pipe(n){return ll(this,n)},readonly(){return cb(this)},describe(n){const r=this.clone();return Er.add(r,{description:n}),r},meta(...n){if(n.length===0)return Er.get(this);const r=this.clone();return Er.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){var n;return(n=Er.get(e))==null?void 0:n.description},configurable:!0}),e)),cu=D("_ZodString",(e,t)=>{Li.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(r,a,i)=>Eg(e,r,a);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Gs(e,"_ZodString",{regex(...r){return this.check(mg(...r))},includes(...r){return this.check(pg(...r))},startsWith(...r){return this.check(xg(...r))},endsWith(...r){return this.check(gg(...r))},min(...r){return this.check(Es(...r))},max(...r){return this.check(Xc(...r))},length(...r){return this.check(eu(...r))},nonempty(...r){return this.check(Es(1,...r))},lowercase(r){return this.check(hg(r))},uppercase(r){return this.check(fg(r))},trim(){return this.check(bg())},normalize(...r){return this.check(yg(...r))},toLowerCase(){return this.check(vg())},toUpperCase(){return this.check(jg())},slugify(){return this.check(wg())}})}),vy=D("ZodString",(e,t)=>{Li.init(e,t),cu.init(e,t),e.email=n=>e.check(Gc(uu,n)),e.url=n=>e.check(Vx(wy,n)),e.jwt=n=>e.check(sg(Ly,n)),e.emoji=n=>e.check(Ux(Ny,n)),e.guid=n=>e.check(tl(sl,n)),e.uuid=n=>e.check(zx(os,n)),e.uuidv4=n=>e.check(Mx(os,n)),e.uuidv6=n=>e.check(qx(os,n)),e.uuidv7=n=>e.check(Bx(os,n)),e.nanoid=n=>e.check(Zx(Sy,n)),e.guid=n=>e.check(tl(sl,n)),e.cuid=n=>e.check(Wx(ky,n)),e.cuid2=n=>e.check(Yx(Cy,n)),e.ulid=n=>e.check(Hx(Ay,n)),e.base64=n=>e.check(tg(Dy,n)),e.base64url=n=>e.check(ng(Ry,n)),e.xid=n=>e.check(Kx(Py,n)),e.ksuid=n=>e.check(Qx(Ey,n)),e.ipv4=n=>e.check(Jx(Iy,n)),e.ipv6=n=>e.check(Gx(Ty,n)),e.cidrv4=n=>e.check(Xx(_y,n)),e.cidrv6=n=>e.check(eg(Fy,n)),e.e164=n=>e.check(rg($y,n)),e.datetime=n=>e.check(ey(n)),e.date=n=>e.check(ny(n)),e.time=n=>e.check(sy(n)),e.duration=n=>e.check(iy(n))});function F(e){return Ox(vy,e)}const Ie=D("ZodStringFormat",(e,t)=>{Ce.init(e,t),cu.init(e,t)}),uu=D("ZodEmail",(e,t)=>{Yp.init(e,t),Ie.init(e,t)});function jy(e){return Gc(uu,e)}const sl=D("ZodGUID",(e,t)=>{Zp.init(e,t),Ie.init(e,t)}),os=D("ZodUUID",(e,t)=>{Wp.init(e,t),Ie.init(e,t)}),wy=D("ZodURL",(e,t)=>{Hp.init(e,t),Ie.init(e,t)}),Ny=D("ZodEmoji",(e,t)=>{Kp.init(e,t),Ie.init(e,t)}),Sy=D("ZodNanoID",(e,t)=>{Qp.init(e,t),Ie.init(e,t)}),ky=D("ZodCUID",(e,t)=>{Jp.init(e,t),Ie.init(e,t)}),Cy=D("ZodCUID2",(e,t)=>{Gp.init(e,t),Ie.init(e,t)}),Ay=D("ZodULID",(e,t)=>{Xp.init(e,t),Ie.init(e,t)}),Py=D("ZodXID",(e,t)=>{ex.init(e,t),Ie.init(e,t)}),Ey=D("ZodKSUID",(e,t)=>{tx.init(e,t),Ie.init(e,t)}),Iy=D("ZodIPv4",(e,t)=>{ix.init(e,t),Ie.init(e,t)}),Ty=D("ZodIPv6",(e,t)=>{ox.init(e,t),Ie.init(e,t)}),_y=D("ZodCIDRv4",(e,t)=>{lx.init(e,t),Ie.init(e,t)}),Fy=D("ZodCIDRv6",(e,t)=>{cx.init(e,t),Ie.init(e,t)}),Dy=D("ZodBase64",(e,t)=>{ux.init(e,t),Ie.init(e,t)}),Ry=D("ZodBase64URL",(e,t)=>{mx.init(e,t),Ie.init(e,t)}),$y=D("ZodE164",(e,t)=>{hx.init(e,t),Ie.init(e,t)}),Ly=D("ZodJWT",(e,t)=>{px.init(e,t),Ie.init(e,t)}),Oy=D("ZodBoolean",(e,t)=>{xx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Ig(e,n,r)});function Yn(e){return cg(Oy,e)}const zy=D("ZodUnknown",(e,t)=>{gx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>_g()});function al(){return ug(zy)}const My=D("ZodNever",(e,t)=>{yx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Tg(e,n,r)});function qy(e){return dg(My,e)}const By=D("ZodArray",(e,t)=>{bx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Lg(e,n,r,a),e.element=t.element,Gs(e,"ZodArray",{min(n,r){return this.check(Es(n,r))},nonempty(n){return this.check(Es(1,n))},max(n,r){return this.check(Xc(n,r))},length(n,r){return this.check(eu(n,r))},unwrap(){return this.element}})});function Vy(e,t){return Ng(By,e,t)}const Uy=D("ZodObject",(e,t)=>{jx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Og(e,n,r,a),be(e,"shape",()=>t.shape),Gs(e,"ZodObject",{keyof(){return Xs(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:al()})},loose(){return this.clone({...this._zod.def,catchall:al()})},strict(){return this.clone({...this._zod.def,catchall:qy()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return Bf(this,n)},safeExtend(n){return Vf(this,n)},merge(n){return Uf(this,n)},pick(n){return Mf(this,n)},omit(n){return qf(this,n)},partial(...n){return Zf(mu,this,n[0])},required(...n){return Wf(hu,this,n[0])}})});function Xt(e,t){const n={type:"object",shape:e??{},...se(t)};return new Uy(n)}const Zy=D("ZodUnion",(e,t)=>{wx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>zg(e,n,r,a),e.options=t.options});function du(e,t){return new Zy({type:"union",options:e,...se(t)})}const Wy=D("ZodIntersection",(e,t)=>{Nx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Mg(e,n,r,a)});function Yy(e,t){return new Wy({type:"intersection",left:e,right:t})}const Ga=D("ZodEnum",(e,t)=>{Sx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(r,a,i)=>Fg(e,r,a),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,a)=>{const i={};for(const o of r)if(n.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Ga({...t,checks:[],...se(a),entries:i})},e.exclude=(r,a)=>{const i={...t.entries};for(const o of r)if(n.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new Ga({...t,checks:[],...se(a),entries:i})}});function Xs(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Ga({type:"enum",entries:n,...se(t)})}const Hy=D("ZodLiteral",(e,t)=>{kx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Dg(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function da(e,t){return new Hy({type:"literal",values:Array.isArray(e)?e:[e],...se(t)})}const Ky=D("ZodTransform",(e,t)=>{Cx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>$g(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new zc(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push($r(i,n.value,t));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=e),n.issues.push($r(o))}};const a=t.transform(n.value,n);return a instanceof Promise?a.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=a,n.fallback=!0,n)}});function Qy(e){return new Ky({type:"transform",transform:e})}const mu=D("ZodOptional",(e,t)=>{Jc.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>su(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function il(e){return new mu({type:"optional",innerType:e})}const Jy=D("ZodExactOptional",(e,t)=>{Ax.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>su(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function Gy(e){return new Jy({type:"optional",innerType:e})}const Xy=D("ZodNullable",(e,t)=>{Px.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>qg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function ol(e){return new Xy({type:"nullable",innerType:e})}const eb=D("ZodDefault",(e,t)=>{Ex.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Vg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function tb(e,t){return new eb({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Bc(t)}})}const nb=D("ZodPrefault",(e,t)=>{Ix.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Ug(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function rb(e,t){return new nb({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Bc(t)}})}const hu=D("ZodNonOptional",(e,t)=>{Tx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Bg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function sb(e,t){return new hu({type:"nonoptional",innerType:e,...se(t)})}const ab=D("ZodCatch",(e,t)=>{_x.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Zg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ib(e,t){return new ab({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const ob=D("ZodPipe",(e,t)=>{Fx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Wg(e,n,r,a),e.in=t.in,e.out=t.out});function ll(e,t){return new ob({type:"pipe",in:e,out:t})}const lb=D("ZodReadonly",(e,t)=>{Dx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Yg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function cb(e){return new lb({type:"readonly",innerType:e})}const ub=D("ZodCustom",(e,t)=>{Rx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Rg(e,n)});function db(e,t={}){return Sg(ub,e,t)}function mb(e,t){return kg(e,t)}const Qt={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function Oi(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 en(e){return e.tradeName.trim()?e.tradeName:e.accountType==="Business"?(e.lastName||e.firstName).trim():`${e.firstName} ${e.lastName}`.trim()}function qn(e){const t=e.replace(/\D/g,"");return t.length!==9?e:`${t.slice(0,2)}-${t.slice(2)}`}function hb(e){const t=e.replace(/\D/g,"");return t.length!==9?e:`${t.slice(0,3)}-${t.slice(3,5)}-${t.slice(5)}`}function fb(e,t){return t==="Individual"?hb(e):qn(e)}function cl(e,t){const n=e.replace(/\D/g,"").slice(0,9);return t==="Individual"?n.length<=3?n:n.length<=5?`${n.slice(0,3)}-${n.slice(3)}`:`${n.slice(0,3)}-${n.slice(3,5)}-${n.slice(5)}`:n.length<=2?n:`${n.slice(0,2)}-${n.slice(2)}`}function $n(e){const t=e.replace(/\D/g,""),n=t.length===11&&t.startsWith("1")?t.slice(1):t;return n.length!==10?e:`+1 (${n.slice(0,3)}) ${n.slice(3,6)}-${n.slice(6)}`}const fu=["LLP","LLC","Corporation","S-Corp","Partnership"],pu=["Sole Proprietorship"],pb=/^[A-Za-z][A-Za-z\s'.-]*$/,Xa=10,xu=/^\d{5}(-\d{4})?$/,xb=/^[A-Za-z]\d[A-Za-z][ -]?\d[A-Za-z]\d$/;function zi(e){const t=e.replace(/\D/g,"").slice(0,9);return t.length<=5?t:`${t.slice(0,5)}-${t.slice(5)}`}function gu(e){const t=e.toUpperCase().replace(/[^A-Z0-9]/g,"").slice(0,6);return t.length<=3?t:`${t.slice(0,3)} ${t.slice(3)}`}const yu=Xt({accountType:Xs(["Business","Individual"]),firstName:F(),lastName:F(),tradeName:F(),ein:F(),entityType:F().min(1,"Entity type is required"),email:jy("Enter a valid email"),countryCode:F().min(1),phoneNumber:F().min(1,"Phone number is required").refine(e=>e.replace(/\D/g,"").length===Xa,`Phone number must be ${Xa} 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")}).superRefine((e,t)=>{pb.test(e.city.trim())||t.addIssue({code:"custom",path:["city"],message:"City can only contain letters, spaces, apostrophes, and hyphens"}),e.country==="United States"&&!xu.test(e.zipCode.trim())?t.addIssue({code:"custom",path:["zipCode"],message:"Enter a 5-digit ZIP or ZIP+4 (e.g. 12345 or 12345-6789)"}):e.country==="Canada"&&!xb.test(e.zipCode.trim())&&t.addIssue({code:"custom",path:["zipCode"],message:"Enter a valid postal code (e.g. A1A 1A1)"});const n=e.accountType==="Individual"?"SSN":"EIN",r=e.ein.replace(/\D/g,"");if(r?r.length!==9&&t.addIssue({code:"custom",path:["ein"],message:`${n} must be 9 digits`}):t.addIssue({code:"custom",path:["ein"],message:`${n} is required`}),e.accountType==="Business"){e.lastName.trim()||t.addIssue({code:"custom",path:["lastName"],message:"Business name is required"});return}e.firstName.trim()||t.addIssue({code:"custom",path:["firstName"],message:"First name is required"}),e.lastName.trim()||t.addIssue({code:"custom",path:["lastName"],message:"Last name is required"})});function gb(e){const t=e.replace(/\D/g,"");return t.length===11&&t.startsWith("1")?{countryCode:"+1",national:t.slice(1)}:t.length===10?{countryCode:"+1",national:t}:{countryCode:"+1",national:t.slice(-Xa)}}function ul(e){const{countryCode:t,national:n}=gb(e.phoneNumber),r=e.accountType==="Individual",a=(e.lastName||e.firstName||"").trim();return{accountType:r?"Individual":"Business",firstName:r?e.firstName??"":"",lastName:r?e.lastName??"":a,tradeName:r?"":e.tradeName??"",ein:qn(e.idNumber),entityType:e.entityType,email:e.email,countryCode:t,phoneNumber:n,address1:e.address1,address2:e.address2??"",city:e.city,state:e.state,zipCode:e.zipCode,country:e.country}}function bu(e,t,n,r){if(e!==t){if(e==="Business"&&t==="Individual"){n("firstName",""),n("lastName",r),n("tradeName","");return}e==="Individual"&&t==="Business"&&(n("firstName",""),n("lastName",r))}}function vu(e){const t=e.lastName.trim();return e.accountType==="Business"?{accountType:e.accountType,firstName:"",lastName:t,idNumber:e.ein.replace(/\D/g,""),entityType:e.entityType,tradeName:e.tradeName.trim(),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}:{accountType:e.accountType,firstName:e.firstName.trim(),lastName:t,idNumber:e.ein.replace(/\D/g,""),entityType:e.entityType,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 yb(e){const{idNumber:t,...n}=vu(e);return n}function bb(e){return de(`/portal/reference/states?country=${encodeURIComponent(e)}`)}function Mi(e){const{data:t}=ge({queryKey:["reference","states",e],queryFn:()=>bb(e),enabled:!!e,staleTime:1/0});return t??[]}function ur(e,t,n){const r=e.find(o=>o.code===t);if(!r||r.zipRanges.length===0)return!0;const a=n.replace(/\D/g,"");if(a.length<5)return!0;const i=Number(a.slice(0,3));return r.zipRanges.some(o=>i>=o.from&&i<=o.to)}function Bn(e,t){const n=e==null?void 0:e.from;return n&&n.startsWith("/")&&!n.startsWith("//")?n:t}function vb(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 21h18M5 21V6a1 1 0 011-1h4a1 1 0 011 1v15m0 0V3a1 1 0 011-1h4a1 1 0 011 1v18M9 9h.01M9 12h.01M9 15h.01"})})}function jb(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",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 wb(){var Ae,$e,ce,pe,$,fe,O,ue,Te,Je,oe,ve,Oe,We;const e=ke(),t=Se(),n=ft(),{data:r=[]}=ge({queryKey:["entities","mine"],queryFn:async()=>(await bi({pageNumber:1,pageSize:100})).items}),[a,i]=v.useState(null),[o,l]=v.useState(!1),c=r.length===0,d=c?"/create-entity":"/dashboard",u=Bn(t.state,d),m=()=>{e(u)},{register:h,handleSubmit:p,watch:y,setValue:x,getValues:j,formState:{errors:g}}=Rt({resolver:Lt(yu),shouldUnregister:!1,defaultValues:{accountType:"Business",firstName:"",lastName:"",tradeName:"",ein:"",entityType:"LLP",email:"",countryCode:"+1",phoneNumber:"",address1:"",address2:"",city:"",state:"",zipCode:"",country:"United States"}}),C=y("accountType"),b=y("entityType"),S=C==="Individual"?pu:fu,I=C==="Individual",R=I?"SSN":"EIN",E=I?"***-**-****":"**-*******",T=I?11:10,L=y("country"),B=y("state"),K=y("zipCode"),X=L==="United States",Y=Mi(L),V=B.length>0&&K.trim().length>0&&!ur(Y,B,K),Z=h("ein"),ie=h("phoneNumber"),G=h("zipCode");v.useEffect(()=>{B&&Y.length>0&&!Y.some(re=>re.code===B)&&x("state","")},[L,Y]);const Q=re=>{const nt=j("accountType");if(nt===re)return;const rt=j("lastName");bu(nt,re,x,rt),x("accountType",re),x("ein",cl(j("ein"),re)),queueMicrotask(()=>{x("lastName",rt),x("firstName",""),nt==="Business"&&re==="Individual"&&x("tradeName","")})};v.useEffect(()=>{S.includes(b)||x("entityType",C==="Individual"?"Sole Proprietorship":"LLP")},[C,b,S,x]);const we=p(async re=>{if(i(null),!ur(Y,re.state,re.zipCode)){i(`ZIP code does not match the selected state (${re.state}).`);return}l(!0);try{await Jh(vu(re)),await n.invalidateQueries({queryKey:["entities","mine"]}),e(c?"/dashboard":u,{replace:!0})}catch(nt){i(tt(nt,"Unable to save entity. Please try again."))}finally{l(!1)}});return s.jsxs("form",{onSubmit:we,noValidate:!0,className:"w-full max-w-4xl space-y-6 lg:max-w-5xl xl:max-w-6xl",children:[a?s.jsx(Ot,{message:a}):null,s.jsxs(Ts,{step:1,title:"Basic Information",subtitle:"Enter the primary details for this entity.",children:[s.jsx(iu,{label:"Account Type",required:!0,value:C,onChange:Q,options:[{label:"Business",value:"Business",icon:s.jsx(vb,{})},{label:"Individual",value:"Individual",icon:s.jsx(jb,{})}]}),s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:C==="Individual"?s.jsxs(s.Fragment,{children:[s.jsx(he,{label:"First name",required:!0,maxLength:100,placeholder:"Enter first name",error:(Ae=g.firstName)==null?void 0:Ae.message,...h("firstName")},"entity-first-name"),s.jsx(he,{label:"Last name",required:!0,maxLength:100,placeholder:"Enter last name",error:($e=g.lastName)==null?void 0:$e.message,...h("lastName")},"entity-last-name")]}):s.jsxs(s.Fragment,{children:[s.jsx(he,{label:"Business Name",required:!0,maxLength:150,placeholder:"Enter business name",error:(ce=g.lastName)==null?void 0:ce.message,...h("lastName")},"entity-business-name"),s.jsx(he,{label:"Trade Name, if any",maxLength:150,placeholder:"Enter trade name (optional)",error:(pe=g.tradeName)==null?void 0:pe.message,...h("tradeName")},"entity-trade-name")]})}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:R,required:!0,inputMode:"numeric",placeholder:E,maxLength:T,error:($=g.ein)==null?void 0:$.message,...Z,onChange:re=>{re.target.value=cl(re.target.value,C),Z.onChange(re)}}),s.jsx(xn,{label:"Entity Type",required:!0,error:(fe=g.entityType)==null?void 0:fe.message,...h("entityType"),children:S.map(re=>s.jsx("option",{value:re,children:re},re))})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:"Email ID",required:!0,type:"email",maxLength:254,placeholder:"sample@mail.com",error:(O=g.email)==null?void 0:O.message,...h("email")}),s.jsx(ou,{required:!0,error:(ue=g.phoneNumber)==null?void 0:ue.message,countryCodeSelectProps:h("countryCode"),phoneInputProps:{placeholder:"Enter 10-digit phone number",maxLength:10,...ie,onChange:re=>{re.target.value=re.target.value.replace(/\D/g,"").slice(0,10),ie.onChange(re)}}})]})]}),s.jsxs(Ts,{step:2,title:"Address Information",subtitle:"Enter the registered address.",children:[s.jsx(he,{label:"Address Line 1",required:!0,maxLength:200,placeholder:"Enter address line 1",error:(Te=g.address1)==null?void 0:Te.message,...h("address1")}),s.jsx(he,{label:"Address Line 2",maxLength:200,placeholder:"Enter address line 2 (optional)",error:(Je=g.address2)==null?void 0:Je.message,...h("address2")}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:"City",required:!0,maxLength:100,placeholder:"Enter city",error:(oe=g.city)==null?void 0:oe.message,...h("city")}),s.jsxs(xn,{label:X?"State":"Province",required:!0,error:(ve=g.state)==null?void 0:ve.message,...h("state"),children:[s.jsx("option",{value:"",children:X?"Select state":"Select province"}),Y.map(re=>s.jsx("option",{value:re.code,children:re.name},re.code))]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:X?"ZIP Code":"Postal Code",required:!0,maxLength:10,placeholder:X?"12345 or 12345-6789":"A1A 1A1",error:((Oe=g.zipCode)==null?void 0:Oe.message)??(V?`ZIP code does not match the selected state (${B}).`:void 0),...G,onChange:re=>{re.target.value=X?zi(re.target.value):gu(re.target.value),G.onChange(re)}}),s.jsxs(xn,{label:"Country",required:!0,error:(We=g.country)==null?void 0:We.message,...h("country"),children:[s.jsx("option",{value:"United States",children:"United States"}),s.jsx("option",{value:"Canada",children:"Canada"})]})]})]}),s.jsx(lu,{onCancel:m,isSubmitting:o,submitLabel:"Create Entity",submittingLabel:"Creating…"})]})}function qi(){const e=ke(),t=Se(),n=Bn(t.state,"/create-entity");return s.jsx("div",{className:"min-h-full bg-slate-50 px-4 py-6 sm:px-8 sm:py-8",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl lg:max-w-5xl xl:max-w-6xl",children:[s.jsxs("button",{type:"button",onClick:()=>e(n),className:"inline-flex items-center gap-1.5 rounded-lg py-1 text-sm font-medium text-slate-600 transition hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-500",children:[s.jsx(Nb,{}),"Back"]}),s.jsxs("div",{className:"mb-6 mt-4",children:[s.jsx("h1",{className:"text-2xl font-bold text-slate-900",children:"Create Entity"}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Add the business or individual responsible for tax accounts and payments."})]}),s.jsx(wb,{})]})})}function Nb(){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"})})}function Sb(e,t){const n=new URLSearchParams({entityId:String(e)});return t!==void 0&&n.set("taxYear",String(t)),de(`/portal/dashboard?${n}`)}function kb(e,t,n){const r=new URLSearchParams({entityId:String(e),category:t,taxYear:String(n)});return de(`/portal/dashboard/summary?${r}`)}function Cb(e,t,n){const r=new URLSearchParams({entityId:String(e),month:String(t)});return n!==void 0&&r.set("year",String(n)),de(`/portal/dashboard/monthly-overview?${r}`)}function Ab({entityId:e,search:t,taxYear:n,status:r,page:a=1,pageSize:i=it}){const o=new URLSearchParams({entityId:String(e),page:String(a),pageSize:String(i)});return t&&o.set("search",t),n&&o.set("taxYear",n),r&&r!=="all"&&o.set("status",r),de(`/portal/dashboard/payments?${o}`)}function dl({entityCount:e,showPaymentActions:t=!0}){const n=ke(),{enabledPayments:r}=zn();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:[t&&r.includes("federal")&&s.jsxs("button",{type:"button",onClick:()=>n("/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(ma,{}),"Add Federal Payments"]}),t&&r.includes("state")&&s.jsxs("button",{type:"button",onClick:()=>n("/payments/state/new",{state:{from:"/",resetDraft:!0}}),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(ma,{}),"Add State Payment"]}),t&&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(ma,{}),"Add Local Payment",s.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs("button",{type:"button",onClick:()=>n("/entities"),className:"inline-flex items-center gap-1.5 rounded-[14px] border border-solid border-[#e5e7eb] bg-[#f9fafb] px-[15px] py-[9px] text-xs font-bold text-[#364153] transition hover:bg-slate-100",title:"View Entities",children:[s.jsx(Pb,{}),"Entities (",e,")"]}),s.jsxs("button",{type:"button",onClick:()=>n("/create-entity/form",{state:{from:"/dashboard"}}),className:"inline-flex items-center gap-1.5 rounded-[14px] border-[1.5px] border-dashed border-[#16a34a] bg-[#f0fdf4] px-[15.5px] py-[9.5px] text-xs font-bold text-[#16a34a] transition hover:bg-green-50",children:[s.jsx(Eb,{}),"Add Entity"]})]})]})}function ma(){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 Pb(){return s.jsx("svg",{className:"h-[13px] w-[13px] shrink-0 text-[#364153]",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 Eb(){return s.jsx("svg",{className:"h-[13px] w-[13px] shrink-0 text-[#16a34a]",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 Ib({title:e,description:t,buttonLabel:n,onAdd:r,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:r,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(Tb,{}),n]})]})}function Tb(){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 br({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(_b,{}),s.jsx("span",{children:e})]})})}function _b(){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 Fb={Draft:"Draft"};function Db(e){switch((e??Fb.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 Kr(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:e%1===0?0:2,maximumFractionDigits:2}).format(e)}function Rb(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 Bi="drafts";function Qe(){return ea(Bi)}function ea(e){return`/payments?tab=${e}`}function ju(e){return e==="failed"?"rejected":e}function $b(e,t){return e==="draft"||t.trim().toLowerCase()==="draft"?Bi:ju(e)}const Lb=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ob({entityId:e,initialOverview:t,isDashboardLoading:n=!1}){const r=ke(),a=(t==null?void 0:t.year)??new Date().getFullYear(),[i,o]=v.useState(null);v.useEffect(()=>{o(null)},[e]);const l=i??(t==null?void 0:t.month)??new Date().getMonth()+1,c=i===null,{data:d,isFetching:u}=ge({queryKey:["dashboard","monthly-overview",e,i,a],queryFn:()=>Cb(e,i,a),enabled:e!==null&&i!==null,placeholderData:x=>x}),m={submitted:0,paid:0,scheduled:0,failed:0},h=c?t??m:d??m,p=n||u&&!c,y=[{key:"submitted",label:"Submitted to Fed/State",amount:h.submitted,icon:Mb,iconClassName:"rounded-xl bg-orange-50 text-orange-500",amountClassName:"text-orange-500"},{key:"paid",label:"Paid",amount:h.paid,icon:qb,iconClassName:"rounded-full bg-emerald-50 text-emerald-600",amountClassName:"text-emerald-600"},{key:"scheduled",label:"Scheduled",amount:h.scheduled,icon:Bb,iconClassName:"rounded-xl bg-amber-50 text-amber-500",amountClassName:"text-amber-500"},{key:"failed",label:"Rejected",amount:h.failed,icon:Vb,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:[p?s.jsx(br,{}):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:p,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:Lb.map((x,j)=>s.jsx("option",{value:j+1,children:x},x))}),s.jsx(zb,{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 lg:grid-cols-4",children:y.map(x=>{const j=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(j,{})}),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:Kr(x.amount)}),s.jsx("button",{type:"button",onClick:()=>r(ea(ju(x.key))),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 zb({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 Mb(){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 qb(){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 Bb(){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 Vb(){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 ml(e){return{count:e.count,submitted:e.submitted,paid:e.paid,scheduled:e.scheduled,failed:e.failed,percentDone:e.percentDone}}function Ub(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 hl(){return{count:0,submitted:0,paid:0,scheduled:0,failed:0,percentDone:0}}const Zb={primary:"bg-brand-600 text-white hover:bg-brand-700 focus-visible:ring-brand-500 disabled:bg-brand-600/60",secondary:"border border-slate-300 bg-white text-slate-700 hover:bg-slate-50 focus-visible:ring-slate-400",ghost:"text-slate-600 hover:bg-slate-100 focus-visible:ring-slate-400"};function Wb({variant:e="primary",isLoading:t=!1,className:n="",children:r,disabled:a,...i}){return s.jsx("button",{type:"button",className:`inline-flex h-10 items-center justify-center rounded-lg px-4 text-sm font-medium transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed ${Zb[e]} ${n}`,disabled:a||t,...i,children:t?"Please wait…":r})}const Yb=[10,20,50,100];function Hb(e,t){const n=e.trim();if(!/^\d+$/.test(n))return null;const r=Number(n);return!Number.isInteger(r)||r<1||r>t?null:r}function Kb(){return s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:s.jsx("path",{d:"M12.5 4.5 7 10l5.5 5.5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function Qb(){return s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:s.jsx("path",{d:"M7.5 4.5 13 10l-5.5 5.5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function Qr({page:e,pageSize:t,totalCount:n,onPageChange:r,onPageSizeChange:a,pageSizeOptions:i=Yb,disabled:o=!1,className:l=""}){const c=t>0?Math.max(1,Math.ceil(n/t)):1,d=n===0?0:c,u=e>1,m=d>0&&e<d,h=n===0?0:(e-1)*t+1,p=Math.min(e*t,n),[y,x]=v.useState(String(e)),j=v.useRef(y);j.current=y,v.useEffect(()=>{x(String(e))},[e]);function g(b=j.current){if(o||d===0){x(String(e));return}const S=Hb(b,d);if(S===null){x(String(e));return}if(S===e){x(String(e));return}r(S)}function C(b){b.key==="Enter"&&(b.preventDefault(),g(b.currentTarget.value))}return n===0?null:s.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 border-t border-slate-200 bg-white px-6 py-3 ${l}`,children:[s.jsxs("p",{className:"text-sm text-slate-500",children:["Showing ",s.jsx("span",{className:"font-medium text-slate-700",children:h}),"–",s.jsx("span",{className:"font-medium text-slate-700",children:p})," of ",s.jsx("span",{className:"font-medium text-slate-700",children:n})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a?s.jsxs("label",{className:"flex items-center gap-2 text-sm text-slate-600",children:[s.jsx("span",{className:"whitespace-nowrap",children:"Rows per page"}),s.jsx("select",{value:t,disabled:o,onChange:b=>a(Number(b.target.value)),className:"rounded-lg border border-slate-200 bg-white px-2 py-1.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:i.map(b=>s.jsx("option",{value:b,children:b},b))})]}):null,s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{type:"button",disabled:o||!u,onClick:()=>r(e-1),"aria-label":"Previous page",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-slate-700 transition hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-200 disabled:cursor-not-allowed disabled:text-slate-300 disabled:hover:bg-transparent",children:s.jsx(Kb,{})}),s.jsx("span",{className:"min-w-[5.5rem] text-center text-sm text-slate-600",children:d===0?"—":`Page ${e} of ${d}`}),s.jsx("button",{type:"button",disabled:o||!m,onClick:()=>r(e+1),"aria-label":"Next page",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-slate-700 transition hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-200 disabled:cursor-not-allowed disabled:text-slate-300 disabled:hover:bg-transparent",children:s.jsx(Qb,{})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{htmlFor:"pagination-go-to-page",className:"whitespace-nowrap text-sm text-slate-600",children:"Go to page"}),s.jsx("input",{id:"pagination-go-to-page",type:"text",inputMode:"numeric",pattern:"[0-9]*",value:y,disabled:o||d===0,onChange:b=>x(b.target.value),onKeyDown:C,"aria-label":"Go to page number",className:"h-9 w-14 rounded-lg border border-slate-200 bg-white px-2 text-center text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60"}),s.jsx(Wb,{type:"button",variant:"secondary",disabled:o||d===0,className:"h-9 px-3",onMouseDown:b=>{b.preventDefault()},onClick:()=>g(),children:"Go"})]})]})]})}const Jb=[{value:"all",label:"All"},{value:"draft",label:"Draft"},{value:"scheduled",label:"Scheduled"},{value:"paid",label:"Completed"},{value:"submitted",label:"Submitted"},{value:"failed",label:"Rejected"}],fl={total:0,page:1,pageSize:it,items:[]};function Gb({label:e,status:t}){const n={draft:"bg-slate-100 text-slate-600",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 ${n[t]}`,children:e})}function Xb({entityId:e,initialPayments:t,isDashboardLoading:n=!1}){const r=ke(),[a,i]=v.useState(""),[o,l]=v.useState(""),[c,d]=v.useState(""),[u,m]=v.useState("all"),[h,p]=v.useState(1),[y,x]=v.useState(it);v.useEffect(()=>{const T=window.setTimeout(()=>l(a),300);return()=>window.clearTimeout(T)},[a]),v.useEffect(()=>{p(1)},[o,c,u,e,y]);const j=!!o||!!c||u!=="all",g=e!==null&&(j||h>1||y!==it),{data:C,isFetching:b}=ge({queryKey:["dashboard","payments",e,o,c,u,h,y],queryFn:()=>Ab({entityId:e,search:o||void 0,taxYear:c||void 0,status:u,page:h,pageSize:y}),enabled:g,placeholderData:T=>T}),S=v.useMemo(()=>g?C??fl:t&&h===1&&y===it?t:fl,[g,C,t,h,y]),I=v.useMemo(()=>S.items.map(Ub),[S.items]),R=v.useMemo(()=>{const T=new Date().getFullYear();return[T,T-1,T-2].map(String)},[]),E=n||g&&b;return s.jsxs("section",{className:"relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[E?s.jsx(br,{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(t0,{})}),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:[S.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 Jurisdiction/Form Type"}),s.jsxs("div",{className:"relative",children:[s.jsx(e0,{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:a,onChange:T=>i(T.target.value),placeholder:"All",disabled:n,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:c,onChange:T=>d(T.target.value),disabled:n,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"}),R.map(T=>s.jsx("option",{value:T,children:T},T))]}),s.jsx(pl,{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:T=>m(T.target.value),disabled:n,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:Jb.map(T=>s.jsx("option",{value:T.value,children:T.label},T.value))}),s.jsx(pl,{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:!E&&I.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-slate-500",children:j?"No payments match your filters.":"No payments yet."})}):I.map(T=>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:["#",T.id]}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:T.jurisdiction}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:T.period}),s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Kr(T.amount)}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:T.paymentDate}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(Gb,{label:T.statusLabel,status:T.status})}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:T.formType}),s.jsx("td",{className:"px-6 py-4",children:s.jsx("button",{type:"button",onClick:()=>r(ea($b(T.status,T.statusLabel))),className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"})})]},`${T.category}-${T.id}`))})]})}),s.jsx(Qr,{page:h,pageSize:y,totalCount:S.total,onPageChange:p,onPageSizeChange:x,disabled:E||e===null})]})}function e0({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 pl({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 t0(){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 ha({entityId:e,category:t,title:n,subtitlePrefix:r,defaultTaxYear:a,taxYearOptions:i,initialSummary:o,isDashboardLoading:l=!1,stats:c,comingSoon:d=!1}){const[u,m]=v.useState(a);if(v.useEffect(()=>{m(a)},[e,a]),d)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:n}),s.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:r})]}),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 h=u===a,{data:p,isFetching:y}=ge({queryKey:["dashboard","summary",e,t,u],queryFn:()=>kb(e,t,u),enabled:e!==null&&!h,placeholderData:C=>C}),x=h?o?ml(o):hl():p?ml(p):hl(),j=Rb(x),g=l||y&&!h;return s.jsxs("article",{className:"relative flex flex-col rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[g?s.jsx(br,{}):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:n}),s.jsxs("p",{className:"mt-0.5 text-xs text-slate-500",children:[r," (",x.count,")"]})]}),s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("select",{value:u,onChange:C=>m(Number(C.target.value)),disabled:g,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(C=>s.jsxs("option",{value:C,children:["TY ",C]},C))}),s.jsx(n0,{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(C=>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 ${C.dotClassName}`}),s.jsx("span",{className:"text-xs text-slate-500",children:C.label})]}),s.jsx("p",{className:"mt-1 text-sm font-semibold text-slate-900",children:Kr(x[C.key])})]},C.label))}),s.jsxs("div",{className:"mt-5",children:[s.jsx("div",{className:"flex h-2 overflow-hidden rounded-full bg-slate-100",children:j.map((C,b)=>C.width>0?s.jsx("span",{className:`${C.color} h-full`,style:{width:`${C.width}%`}},b):null)}),s.jsxs("p",{className:"mt-2 text-xs font-medium text-slate-600",children:[x.percentDone,"% done"]})]})]})}function n0({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 r0={federal:"Schedule federal tax deposits directly to the IRS — EFTPS payments, 941, 940, and more.",state:"Submit state tax remittances to the relevant state authority on time, every time.",local:"Local tax payment support is coming soon. Stay tuned for updates."},s0=[{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"}],rn=new Date().getFullYear(),fa=[rn,rn-1,rn-2],a0=[{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:"Rejected",key:"failed",dotClassName:"bg-red-400"}],i0=[{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:"Rejected",key:"failed",dotClassName:"bg-red-400"}],o0=[{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:"Rejected",key:"failed",dotClassName:"bg-red-400"}];function Vi(){const e=ke(),{entities:t,selectedEntity:n,enabledPayments:r}=zn(),a=(n==null?void 0:n.entityId)??null,{data:i,isLoading:o}=ge({queryKey:["dashboard",a,rn],queryFn:()=>Sb(a,rn),enabled:a!==null});return!o&&i&&!i.hasPayments?s.jsxs("div",{className:"space-y-6",children:[s.jsx(dl,{entityCount:t.length,showPaymentActions:!1}),s.jsx("div",{className:"grid gap-6 sm:grid-cols-2 xl:grid-cols-3",children:s0.filter(l=>l.key==="local"||r.includes(l.key)).map(l=>s.jsx(Ib,{title:l.title,description:r0[l.key],buttonLabel:l.buttonLabel,onAdd:l.key==="federal"?()=>e("/payments/federal/new",{state:{from:"/dashboard"}}):l.key==="state"?()=>e("/payments/state/new",{state:{from:"/dashboard",resetDraft:!0}}):void 0,comingSoon:l.key==="local"},l.key))})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsx(dl,{entityCount:t.length}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2 xl:grid-cols-3",children:[r.includes("federal")&&s.jsx(ha,{entityId:a,category:"federal",title:"Federal Payments",subtitlePrefix:"IRS & Federal agencies",defaultTaxYear:rn,taxYearOptions:fa,initialSummary:i==null?void 0:i.federal,isDashboardLoading:o,stats:a0}),r.includes("state")&&s.jsx(ha,{entityId:a,category:"state",title:"All State Payments",subtitlePrefix:"State tax authorities",defaultTaxYear:rn,taxYearOptions:fa,initialSummary:i==null?void 0:i.state,isDashboardLoading:o,stats:i0}),s.jsx(ha,{entityId:a,category:"local",title:"Local Payments",subtitlePrefix:"Local tax authorities",defaultTaxYear:rn,taxYearOptions:fa,initialSummary:i==null?void 0:i.local,isDashboardLoading:o,stats:o0,comingSoon:!0})]}),s.jsx(Ob,{entityId:a,initialOverview:i==null?void 0:i.monthlyOverview,isDashboardLoading:o}),s.jsx(Xb,{entityId:a,initialPayments:i==null?void 0:i.payments,isDashboardLoading:o})]})}const xl=160,l0=48,ls=8;function c0({entity:e,onEdit:t}){const n=v.useRef(null),r=v.useRef(null),[a,i]=v.useState(!1),[o,l]=v.useState({}),c=()=>{var y;const d=n.current;if(!d)return;const u=d.getBoundingClientRect(),m=((y=r.current)==null?void 0:y.offsetHeight)??l0,p=window.innerHeight-u.bottom<m+ls;l({position:"fixed",top:p?u.top-m-ls:u.bottom+ls,left:Math.max(ls,u.right-xl),width:xl,zIndex:50})};return v.useLayoutEffect(()=>{a&&(c(),requestAnimationFrame(c))},[a]),v.useEffect(()=>{if(!a)return;const d=m=>{var p,y;const h=m.target;(p=n.current)!=null&&p.contains(h)||(y=r.current)!=null&&y.contains(h)||i(!1)},u=()=>c();return document.addEventListener("mousedown",d),window.addEventListener("resize",u),window.addEventListener("scroll",u,!0),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0)}},[a]),s.jsxs("div",{className:"inline-block text-left",children:[s.jsxs("button",{ref:n,type:"button",onClick:()=>i(d=>!d),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(u0,{})]}),a?Br.createPortal(s.jsx("div",{ref:r,style:o,className:"overflow-hidden rounded-lg border border-slate-200 bg-white py-1 shadow-lg",children:s.jsx("button",{type:"button",onClick:()=>{i(!1),t(e)},className:"block w-full px-4 py-2 text-left text-sm text-slate-700 hover:bg-slate-50",children:"Edit"})}),document.body):null]})}function u0(){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 d0(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 21h18M5 21V6a1 1 0 011-1h4a1 1 0 011 1v15m0 0V3a1 1 0 011-1h4a1 1 0 011 1v18M9 9h.01M9 12h.01M9 15h.01"})})}function m0(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",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 wu({open:e,entity:t,onClose:n}){var Y,V,Z,ie,G,Q,we,Ae,$e,ce,pe,$,fe;const r=ft(),[a,i]=v.useState(null),[o,l]=v.useState(!1),{register:c,handleSubmit:d,watch:u,reset:m,setValue:h,getValues:p,formState:{errors:y}}=Rt({resolver:Lt(yu),defaultValues:ul(t),shouldUnregister:!1}),x=u("accountType"),j=u("entityType"),g=x==="Individual"?pu:fu,C=x==="Individual"?"SSN":"EIN",b=u("country"),S=u("state"),I=u("zipCode"),R=b==="United States",E=Mi(b),T=S.length>0&&I.trim().length>0&&!ur(E,S,I),L=c("phoneNumber"),B=c("zipCode");v.useEffect(()=>{S&&E.length>0&&!E.some(O=>O.code===S)&&h("state","")},[b,E]);const K=O=>{const ue=p("accountType");if(ue===O)return;const Te=p("lastName");bu(ue,O,h,Te),h("accountType",O),queueMicrotask(()=>{h("lastName",Te),h("firstName",""),ue==="Business"&&O==="Individual"&&h("tradeName","")})};v.useEffect(()=>{if(e){const O=ul(t);m(O),i(null)}},[t,e,m]),v.useEffect(()=>{if(!e)return;const O=ue=>{ue.key==="Escape"&&n()};return document.addEventListener("keydown",O),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",O),document.body.style.overflow=""}},[e,n]),v.useEffect(()=>{g.includes(j)||h("entityType",x==="Individual"?"Sole Proprietorship":"LLP")},[x,j,g,h]);const X=d(async O=>{if(i(null),!ur(E,O.state,O.zipCode)){i(`ZIP code does not match the selected state (${O.state}).`);return}l(!0);try{await Gh(t.entityId,yb(O)),await r.invalidateQueries({queryKey:["entities","mine"]}),n()}catch(ue){i(tt(ue,"Unable to update entity. Please try again."))}finally{l(!1)}});return e?Br.createPortal(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:n}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"edit-entity-title",className:"relative z-10 flex max-h-[90vh] w-full max-w-4xl flex-col overflow-hidden rounded-2xl bg-white shadow-xl",children:[s.jsxs("div",{className:"border-b border-slate-200 px-6 py-5",children:[s.jsx("h2",{id:"edit-entity-title",className:"text-lg font-bold text-slate-900",children:"Edit Entity"}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Update your entity profile details."})]}),s.jsxs("form",{onSubmit:X,noValidate:!0,className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"overflow-y-auto px-6 py-6",children:[a?s.jsx("div",{className:"mb-5",children:s.jsx(Ot,{message:a})}):null,s.jsx("input",{type:"hidden",...c("ein")}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Ts,{step:1,title:"Basic Information",subtitle:"Enter the primary details for this entity.",children:[s.jsx(iu,{label:"Account Type",required:!0,value:x,onChange:K,options:[{label:"Business",value:"Business",icon:s.jsx(d0,{})},{label:"Individual",value:"Individual",icon:s.jsx(m0,{})}]}),s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:x==="Individual"?s.jsxs(s.Fragment,{children:[s.jsx(he,{label:"First name",required:!0,maxLength:100,placeholder:"Enter first name",error:(Y=y.firstName)==null?void 0:Y.message,...c("firstName")},"entity-first-name"),s.jsx(he,{label:"Last name",required:!0,maxLength:100,placeholder:"Enter last name",error:(V=y.lastName)==null?void 0:V.message,...c("lastName")},"entity-last-name")]}):s.jsxs(s.Fragment,{children:[s.jsx(he,{label:"Business Name",required:!0,maxLength:150,placeholder:"Enter business name",error:(Z=y.lastName)==null?void 0:Z.message,...c("lastName")},"entity-business-name"),s.jsx(he,{label:"Trade Name, if any",maxLength:150,placeholder:"Enter trade name (optional)",error:(ie=y.tradeName)==null?void 0:ie.message,...c("tradeName")},"entity-trade-name")]})}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:C,required:!0,readOnly:!0,value:fb(t.idNumber,x),className:"cursor-default bg-[#F9FAFB] text-slate-700"}),s.jsx(xn,{label:"Entity Type",required:!0,error:(G=y.entityType)==null?void 0:G.message,...c("entityType"),children:g.map(O=>s.jsx("option",{value:O,children:O},O))})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:"Email ID",required:!0,type:"email",maxLength:254,placeholder:"sample@mail.com",error:(Q=y.email)==null?void 0:Q.message,...c("email")}),s.jsx(ou,{required:!0,error:(we=y.phoneNumber)==null?void 0:we.message,countryCodeSelectProps:c("countryCode"),phoneInputProps:{placeholder:"Enter 10-digit phone number",maxLength:10,...L,onChange:O=>{O.target.value=O.target.value.replace(/\D/g,"").slice(0,10),L.onChange(O)}}})]})]}),s.jsxs(Ts,{step:2,title:"Address Information",subtitle:"Enter the registered address.",children:[s.jsx(he,{label:"Address Line 1",required:!0,maxLength:200,placeholder:"Enter address line 1",error:(Ae=y.address1)==null?void 0:Ae.message,...c("address1")}),s.jsx(he,{label:"Address Line 2",maxLength:200,placeholder:"Enter address line 2 (optional)",error:($e=y.address2)==null?void 0:$e.message,...c("address2")}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:"City",required:!0,maxLength:100,placeholder:"Enter city",error:(ce=y.city)==null?void 0:ce.message,...c("city")}),s.jsxs(xn,{label:R?"State":"Province",required:!0,error:(pe=y.state)==null?void 0:pe.message,...c("state"),children:[s.jsx("option",{value:"",children:R?"Select state":"Select province"}),E.map(O=>s.jsx("option",{value:O.code,children:O.name},O.code))]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:R?"ZIP Code":"Postal Code",required:!0,maxLength:10,placeholder:R?"12345 or 12345-6789":"A1A 1A1",error:(($=y.zipCode)==null?void 0:$.message)??(T?`ZIP code does not match the selected state (${S}).`:void 0),...B,onChange:O=>{O.target.value=R?zi(O.target.value):gu(O.target.value),B.onChange(O)}}),s.jsxs(xn,{label:"Country",required:!0,error:(fe=y.country)==null?void 0:fe.message,...c("country"),children:[s.jsx("option",{value:"United States",children:"United States"}),s.jsx("option",{value:"Canada",children:"Canada"})]})]})]})]})]}),s.jsx(lu,{className:"px-6",onCancel:n,isSubmitting:o,submitLabel:"Save Changes",submittingLabel:"Saving…"})]})]})]}),document.body):null}function Ui(){const{selectedEntity:e}=zn(),t=ke(),[n,r]=v.useState(""),[a,i]=v.useState(""),[o,l]=v.useState(1),[c,d]=v.useState(it),[u,m]=v.useState(null);v.useEffect(()=>{const b=window.setTimeout(()=>i(n.trim()),300);return()=>window.clearTimeout(b)},[n]),v.useEffect(()=>{l(1)},[a,c]);const{data:h,isLoading:p,isFetching:y,isError:x}=ge({queryKey:["entities","mine","paged",a,o,c],queryFn:()=>bi({search:a||void 0,pageNumber:o,pageSize:c}),placeholderData:b=>b}),j=(h==null?void 0:h.items)??[],g=(h==null?void 0:h.totalCount)??0,C=y;return s.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[s.jsxs("button",{type:"button",onClick:()=>t("/dashboard"),className:"inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm font-medium text-slate-600 transition hover:bg-white hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#156bd5]",children:[s.jsx(f0,{}),"Back"]}),s.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>t("/create-entity/form",{state:{from:"/entities"}}),className:"inline-flex shrink-0 items-center gap-2 rounded-[14px] bg-[#156bd5] px-4 py-2 text-sm font-semibold text-white transition hover:bg-[#1260be]",children:[s.jsx(p0,{}),"Add Entity"]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-[11px] font-semibold text-[#6a7282]",children:"Search by Entity Name/Email/EIN"}),s.jsx("input",{type:"search",value:n,onChange:b=>r(b.target.value),placeholder:"All",className:"h-9.5 w-55 rounded-lg border-2 border-slate-400 bg-[#f9fafb] px-3 text-sm text-slate-700 placeholder-[#99a1af] focus:border-[#156bd5] focus:outline-none"})]})]}),u?s.jsx(wu,{open:!0,entity:u,onClose:()=>m(null)}):null,s.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-black/[0.12] bg-white",children:[C?s.jsx(br,{label:"Loading organizations…"}):null,s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"min-w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#f8f9fb]",children:[s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Entity Name"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"EIN / SSN"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Email"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Phone"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Business Type"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Status"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Joined Date"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Action"})]})}),s.jsx("tbody",{children:p&&!h?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:"Loading organizations…"})}):x?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:"Unable to load organizations."})}):j.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:a?"No organizations match your search.":"No organizations yet."})}):j.map(b=>s.jsx(h0,{entity:b,isSelected:b.entityId===(e==null?void 0:e.entityId),onEdit:m},b.entityId))})]})}),s.jsx(Qr,{page:o,pageSize:c,totalCount:g,onPageChange:l,onPageSizeChange:d,disabled:p||y})]})]})}function h0({entity:e,isSelected:t,onEdit:n}){var l;const r=en(e),a=Oi(r),i=((l=e.status)==null?void 0:l.toLowerCase())==="active",o=e.createdAt?new Date(e.createdAt).toISOString().slice(0,10):"—";return s.jsxs("tr",{className:["border-b border-[#e0e0e0] last:border-b-0 transition-colors",t?"bg-[#f0f7ff]":"hover:bg-slate-50"].join(" "),children:[s.jsx("td",{className:"px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-[10px] bg-[#156bd5] text-[11px] font-bold text-white",children:a}),s.jsx("span",{className:"font-semibold text-[#1e2939] text-[13px]",children:r})]})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"font-mono text-[12px] text-[#374151]",children:qn(e.idNumber)})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"text-[12px] text-[#374151]",children:e.email||"—"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"text-[12px] text-[#374151]",children:e.phoneNumber||"—"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"text-[12px] text-[#374151]",children:e.entityType||"—"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:["inline-flex items-center rounded-full px-2 py-0.5 text-[11px]",i?"bg-[#e1f6da] text-[#010d1d]":"bg-[#feeceb] text-[#010d1d]"].join(" "),children:i?"Active":"In-active"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"text-[12px] text-[#374151]",children:o})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx(c0,{entity:e,onEdit:n})})]})}function f0(){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"})})}function p0(){return s.jsx("svg",{className:"h-[15px] w-[15px]",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 Zi(e){return de(`/portal/federal-payments/${e}`)}function x0(e){return de(`/portal/federal-payments/form-types?entityId=${e}`)}function g0(e){const t=new URLSearchParams({formType:e});return de(`/portal/federal-payments/tax-type-codes?${t.toString()}`)}function Wi(e){return de("/portal/federal-payments",{method:"POST",body:e})}function Yi(e,t){return de(`/portal/federal-payments/${e}`,{method:"PATCH",body:t})}function y0(e){return de(`/portal/federal-payments/${e}/submit`,{method:"POST"})}function b0(e){return Zr(`/portal/federal-payments/${e}/pdf`,{responseType:"blob"})}function v0(e){return Zr(`/portal/state-payments/${e}/pdf`,{responseType:"blob"})}function j0(e){return Zr(`/portal/federal-payments/${e}/pdf-html`,{responseType:"text"})}function w0(e){return Zr(`/portal/state-payments/${e}/pdf-html`,{responseType:"text"})}function N0({entityId:e,status:t,category:n="all",pageNumber:r=1,pageSize:a=it}){const i=new URLSearchParams({entityId:String(e),pageNumber:String(r),pageSize:String(a)});return t&&i.set("status",t),n&&n!=="all"?i.set("category",n):n==="all"&&i.set("category","all"),de(`/portal/remittance-payments?${i}`)}function S0(e,t="all"){const n=new URLSearchParams({entityId:String(e)});return t&&n.set("category",t),de(`/portal/remittance-payments/status-counts?${n}`)}function k0(e){return de("/portal/state-payments/states",{signal:e})}function C0(e,t,n){const r=new URLSearchParams({entityId:String(e),state:t});return de(`/portal/state-payments/payment-reasons?${r}`,{signal:n})}function A0(e,t,n,r){const a=new URLSearchParams({entityId:String(e),state:t,reason:n});return de(`/portal/state-payments/validation-metadata?${a}`,{signal:r})}function P0(e,t,n,r){const a=new URLSearchParams({entityId:String(e),state:t,reason:n});return de(`/portal/state-payments/form-references?${a}`,{signal:r})}function Nu(e){return de(`/portal/state-payments/${e}`)}function E0(e){return de("/portal/state-payments",{method:"POST",body:e})}function I0(e,t){return de(`/portal/state-payments/${e}`,{method:"PATCH",body:t})}function T0(e){return de(`/portal/state-payments/${e}/submit`,{method:"POST"})}function _0({open:e,title:t,html:n,isLoading:r=!1,error:a=null,downloadFileName:i="payment.pdf",onDownload:o,onClose:l}){const[c,d]=v.useState(!1);v.useEffect(()=>{if(!e)return;const m=h=>{h.key==="Escape"&&l()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[e,l]);const u=async()=>{if(!(!o||c)){d(!0);try{const m=await o(),h=URL.createObjectURL(m),p=document.createElement("a");p.href=h,p.download=i,document.body.appendChild(p),p.click(),document.body.removeChild(p),setTimeout(()=>URL.revokeObjectURL(h),1e3)}finally{d(!1)}}};return e?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:l}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"payment-pdf-title",className:"relative flex h-[90vh] w-full max-w-5xl flex-col overflow-hidden rounded-2xl bg-white shadow-xl",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-slate-200 px-5 py-4",children:[s.jsx("h2",{id:"payment-pdf-title",className:"text-base font-semibold text-slate-900",children:t}),s.jsxs("div",{className:"flex items-center gap-2",children:[o?s.jsx("button",{type:"button",onClick:()=>void u(),disabled:c||r||!!a,className:"rounded-lg border border-gov-200 bg-gov-50 px-3 py-1.5 text-sm font-medium text-gov-600 hover:bg-gov-100 disabled:opacity-60",children:c?"Downloading…":"Download"}):null,s.jsx("button",{type:"button",onClick:l,className:"rounded-lg border border-slate-200 px-3 py-1.5 text-sm font-medium text-slate-600 hover:bg-slate-50",children:"Close"})]})]}),s.jsx("div",{className:"flex-1 overflow-hidden bg-white",children:r?s.jsx("div",{className:"flex h-full items-center justify-center text-sm text-slate-500",children:"Loading…"}):a?s.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-red-600",children:a}):n?s.jsx("iframe",{title:t,srcDoc:n,sandbox:"",className:"h-full w-full border-0 bg-white"}):s.jsx("div",{className:"flex h-full items-center justify-center text-sm text-slate-500",children:"No content available."})})]})]}):null}function pa({onViewPdf:e,isViewPdfLoading:t}){return s.jsx("button",{type:"button",onClick:e,disabled:t,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 disabled:opacity-60",children:t?"Loading…":"View PDF"})}function F0({actionType:e,onView:t,onViewPdf:n,onEdit:r,onSubmit:a,isSubmitting:i=!1,isViewPdfLoading:o=!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:a,disabled:i,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:i?"Submitting…":"Submit"})]}):e==="view-pdf"?s.jsx(pa,{onViewPdf:n,isViewPdfLoading:o}):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(pa,{onViewPdf:n,isViewPdfLoading:o}),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.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(pa,{onViewPdf:n,isViewPdfLoading:o})]})}function D0(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 n=e.slice(0,4),r=Number.parseInt(e.slice(4,6),10);return Number.isNaN(r)||r<1||r>12?e:`Q${Math.ceil(r/3)} ${n}`}function R0(e){return{id:e.id,category:e.category,referenceNo:e.referenceNumber??"—",jurisdiction:e.jurisdiction,period:D0(e.taxPeriod),amount:e.amount,paymentDate:e.paymentDate,status:e.status,reason:e.reason,tab:Db(e.status)}}function $0({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 L0({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 O0({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 z0({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 M0({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 Su=[{key:"drafts",label:"DRAFTS",Icon:$0,iconClassName:"text-gray-500"},{key:"scheduled",label:"SCHEDULED",Icon:L0,iconClassName:"text-yellow-500"},{key:"submitted",label:"SUBMITTED TO FED/STATE",Icon:O0,iconClassName:"text-[#FF733D]"},{key:"rejected",label:"REJECTED",Icon:z0,iconClassName:"text-red-500"},{key:"paid",label:"PAID",Icon:M0,iconClassName:"text-green-500"}],q0={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","Rejected 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"}};function gl(e){return e!==null&&Su.some(t=>t.key===e)}function Hi({paymentsMode:e="all"}){var pe;const t=ke(),n=ft(),[r]=Zm(),{selectedEntity:a}=ht(),{onPaymentRequired:i}=zn(),o=(a==null?void 0:a.entityId)??null,l=r.get("tab"),[c,d]=v.useState(gl(l)?l:Bi),[u,m]=v.useState(e==="all"?"all":e),h=e!=="all"?e:u,[p,y]=v.useState(1),[x,j]=v.useState(it),[g,C]=v.useState(null),[b,S]=v.useState(null),[I,R]=v.useState(null);v.useEffect(()=>{gl(l)&&d(l)},[l]),v.useEffect(()=>{y(1),j(it)},[c,o,u]),v.useEffect(()=>{y(1)},[x]);const E=q0[c],T=ge({queryKey:["remittance-payments","list",o,c,h,p,x],queryFn:()=>N0({entityId:o,status:c,category:h,pageNumber:p,pageSize:x}),enabled:o!==null,placeholderData:$=>$}),L=ge({queryKey:["remittance-payments","status-counts",o,h],queryFn:()=>S0(o,h),enabled:o!==null}),B=T.isLoading,K=T.isFetching,X=o!==null&&K,Y=v.useMemo(()=>{var $,fe,O,ue,Te;return{drafts:(($=L.data)==null?void 0:$.drafts)??0,scheduled:((fe=L.data)==null?void 0:fe.scheduled)??0,submitted:((O=L.data)==null?void 0:O.submitted)??0,rejected:((ue=L.data)==null?void 0:ue.rejected)??0,paid:((Te=L.data)==null?void 0:Te.paid)??0}},[L.data]),V=v.useMemo(()=>{var $;return((($=T.data)==null?void 0:$.items)??[]).map(R0)},[T.data]),Z=((pe=T.data)==null?void 0:pe.totalCount)??0,ie=Rh({mutationFn:async $=>{try{$.category==="federal"?await y0($.id):await T0($.id)}catch(fe){if(fe instanceof gr&&fe.status===402&&i){const O=fe.extensions,ue={paymentType:(O==null?void 0:O.paymentType)??$.category,paymentId:(O==null?void 0:O.paymentId)??$.id,expectedAmount:(O==null?void 0:O.expectedAmount)??"0.00",currency:(O==null?void 0:O.currency)??"USD",federalRecordCount:(O==null?void 0:O.federalRecordCount)??0,stateRecordCount:(O==null?void 0:O.stateRecordCount)??0,feePerFederal:(O==null?void 0:O.feePerFederal)??null,feePerState:(O==null?void 0:O.feePerState)??null};i(ue);return}throw fe}},onSuccess:async()=>{await n.invalidateQueries({queryKey:["remittance-payments"]}),await n.invalidateQueries({queryKey:["dashboard"]}),await n.invalidateQueries({queryKey:["federal-payments"]}),await n.invalidateQueries({queryKey:["state-payments"]})},onError:()=>C(null),onSettled:()=>C(null)});v.useEffect(()=>{const $=async()=>{await n.invalidateQueries({queryKey:["remittance-payments"]}),await n.invalidateQueries({queryKey:["dashboard"]}),await n.invalidateQueries({queryKey:["federal-payments"]}),await n.invalidateQueries({queryKey:["state-payments"]})};return window.addEventListener(ai,$),()=>window.removeEventListener(ai,$)},[n]);const G=$=>{C(`${$.category}-${$.id}`),ie.mutate($)},Q=$=>{$.category==="federal"?t(`/payments/federal/${$.id}/view`):t(`/payments/state/${$.id}/view`)},we=$=>{$.category==="federal"?t(`/payments/federal/${$.id}/edit`):t(`/payments/state/${$.id}/edit`)},Ae=async $=>{const fe=`${$.category}-${$.id}`,O=`payment-${$.referenceNo}.pdf`;S(fe),R({title:`Payment PDF — ${$.referenceNo}`,html:null,category:$.category,paymentId:$.id,downloadFileName:O,isLoading:!0,error:null});try{const ue=$.category==="federal"?await j0($.id):await w0($.id);R({title:`Payment PDF — ${$.referenceNo}`,html:ue,category:$.category,paymentId:$.id,downloadFileName:O,isLoading:!1,error:null})}catch(ue){R({title:`Payment PDF — ${$.referenceNo}`,html:null,category:$.category,paymentId:$.id,downloadFileName:O,isLoading:!1,error:tt(ue,"Unable to load payment PDF.")})}finally{S(null)}},$e=async()=>{if(!I)throw new Error("No payment selected");return I.category==="federal"?b0(I.paymentId):v0(I.paymentId)},ce=()=>R(null);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(xa,{}),"Add Federal Payment"]}),e!=="federal"&&s.jsxs("button",{type:"button",onClick:()=>t("/payments/state/new",{state:{from:"/payments",resetDraft:!0}}),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(xa,{}),"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(xa,{}),"Add Local Payments",s.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),s.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[X?s.jsx(br,{label:"Loading payments…"}):null,s.jsx("div",{className:"flex flex-wrap gap-1 border-b border-slate-200 px-4 pt-4",children:Su.map($=>{const fe=c===$.key,O=$.Icon;return s.jsxs("button",{type:"button",onClick:()=>{d($.key),t(ea($.key),{replace:!0})},className:`mb-[-1px] flex items-center gap-2 border-b-2 px-4 py-3 text-xs font-semibold tracking-wide transition ${fe?"border-gov-600 text-gov-600":"border-transparent text-slate-500 hover:text-slate-700"}`,children:[s.jsx(O,{className:`shrink-0 ${$.iconClassName}`}),$.label," (",Y[$.key],")"]},$.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:$=>m($.target.value),disabled:e!=="all",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 disabled:opacity-60",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:E.columns.map($=>s.jsx("th",{className:"px-6 py-3",children:$},$))})}),s.jsx("tbody",{children:B&&!T.data?s.jsx("tr",{children:s.jsx("td",{colSpan:E.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:E.columns.length,className:"px-6 py-12 text-center text-slate-500",children:E.emptyMessage})}):V.map($=>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:c==="drafts"?`#${$.id}`:$.referenceNo}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:$.jurisdiction}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:$.period}),s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Kr($.amount)}),c!=="paid"?s.jsx("td",{className:"px-6 py-4 text-slate-700",children:$.paymentDate}):null,c==="rejected"?s.jsx("td",{className:"px-6 py-4 text-slate-700",children:$.reason??"—"}):null,s.jsx("td",{className:"px-6 py-4",children:s.jsx(F0,{actionType:E.actionType,onView:()=>Q($),onViewPdf:()=>Ae($),onEdit:()=>we($),onSubmit:()=>G($),isSubmitting:g===`${$.category}-${$.id}`,isViewPdfLoading:b===`${$.category}-${$.id}`})})]},`${$.category}-${$.id}`))})]})}),s.jsx(Qr,{page:p,pageSize:x,totalCount:Z,onPageChange:y,onPageSizeChange:j,disabled:B||o===null||K})]}),s.jsx(_0,{open:I!==null,title:(I==null?void 0:I.title)??"Payment PDF",html:(I==null?void 0:I.html)??null,downloadFileName:I==null?void 0:I.downloadFileName,isLoading:(I==null?void 0:I.isLoading)??!1,error:(I==null?void 0:I.error)??null,onDownload:I&&!I.error?$e:void 0,onClose:ce})]})}function xa(){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 Jr({entityId:e,pageNumber:t=1,pageSize:n=it}){const r=new URLSearchParams({entityId:String(e),pageNumber:String(t),pageSize:String(n)});return de(`/portal/bank-accounts?${r}`)}function B0(e){return de("/portal/bank-accounts",{method:"POST",body:e})}function ku(e,t){return de(`/portal/bank-accounts/${e}`,{method:"PATCH",body:t})}function wn({title:e,children:t,isFirst:n=!1,headerAction:r}){return s.jsxs("section",{className:n?"":"mt-8 border-t border-slate-100 pt-8",children:[s.jsxs("div",{className:"mb-5 flex flex-wrap items-center justify-between gap-3",children:[s.jsx("h3",{className:"text-base font-semibold text-gov-600",children:e}),r]}),t]})}const dr=17,Cu=9;function Hn(e,t){return e.replace(/\D/g,"").slice(0,t)}const Au=["Checking","Savings"],V0=Xt({accountNumber:F().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${dr} digits`),confirmAccountNumber:F().min(1,"Please confirm the account number").regex(/^\d{1,17}$/,`Account number must be 1 to ${dr} digits`),routingNumber:F().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Xs(Au,{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 U0({entityId:e,onCancel:t,onSuccess:n}){const r=ft(),{showSuccess:a,showError:i}=Vs(),[o,l]=v.useState(null),[c,d]=v.useState(!1),{control:u,handleSubmit:m,formState:{errors:h}}=Rt({resolver:Lt(V0),defaultValues:{accountNumber:"",confirmAccountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}}),p=m(async y=>{l(null),d(!0);try{const x=await B0({entityId:e,bankName:y.bankName.trim(),accountNumber:y.accountNumber,routingNumber:y.routingNumber,accountType:y.accountType});await r.invalidateQueries({queryKey:["bank-accounts",e]}),a("Bank Account Added","Bank account added successfully."),n(x.bankAccountDetailId)}catch(x){const j=tt(x,"Unable to save bank account.");l(j),i("Action Not Completed",j)}finally{d(!1)}});return s.jsxs("form",{noValidate:!0,onSubmit:y=>{y.preventDefault(),y.stopPropagation(),p(y)},className:"space-y-6",children:[s.jsxs(au,{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(Ne,{name:"accountNumber",control:u,render:({field:y})=>{var x;return s.jsx(he,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:y.value,onChange:j=>y.onChange(Hn(j.target.value,dr)),onBlur:y.onBlur,error:(x=h.accountNumber)==null?void 0:x.message})}}),s.jsx(Ne,{name:"confirmAccountNumber",control:u,render:({field:y})=>{var x;return s.jsx(he,{label:"Confirm Account Number",required:!0,placeholder:"Re-enter account number",inputMode:"numeric",autoComplete:"off",value:y.value,onChange:j=>y.onChange(Hn(j.target.value,dr)),onBlur:y.onBlur,error:(x=h.confirmAccountNumber)==null?void 0:x.message})}}),s.jsx(Ne,{name:"routingNumber",control:u,render:({field:y})=>{var x;return s.jsx(he,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:y.value,onChange:j=>y.onChange(Hn(j.target.value,Cu)),onBlur:y.onBlur,error:(x=h.routingNumber)==null?void 0:x.message})}}),s.jsx(Ne,{name:"accountType",control:u,render:({field:y})=>{var x;return s.jsx(xn,{label:"Account Type",required:!0,value:y.value,onChange:y.onChange,onBlur:y.onBlur,error:(x=h.accountType)==null?void 0:x.message,children:Au.map(j=>s.jsx("option",{value:j,children:j},j))})}})]}),s.jsx(Ne,{name:"bankName",control:u,render:({field:y})=>{var x;return s.jsx(he,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:y.value,onChange:y.onChange,onBlur:y.onBlur,error:(x=h.bankName)==null?void 0:x.message})}})]}),o?s.jsx(Ot,{message:o}):null,s.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.jsx("button",{type:"button",onClick:t,disabled:c,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:"button",disabled:c,onClick:()=>void p(),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:c?"Saving…":"Save"})]})]})}function Pu({open:e,entityId:t,onClose:n,onAccountAdded:r}){const[a,i]=v.useState("choose");if(v.useEffect(()=>{e||i("choose")},[e]),v.useEffect(()=>{if(!e)return;const l=c=>{c.key==="Escape"&&n()};return document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l)}},[e,n]),!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:n}),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(U0,{entityId:t,onCancel:()=>i("choose"),onSuccess:l=>{r==null||r(l),n()}}):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(Z0,{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(W0,{className:"h-6 w-6"})}),s.jsx("span",{className:"text-base font-medium text-slate-400",children:"Connect with Plaid"})]})]})]})})]})}function Z0({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 W0({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 Y0=12,H0=["January","February","March","April","May","June","July","August","September","October","November","December"];function fn(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${r}`}function _s(e){const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;const n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10)-1,a=Number.parseInt(t[3],10),i=new Date(n,r,a);return i.getFullYear()!==n||i.getMonth()!==r||i.getDate()!==a?null:i}function Eu(e=new Date){const t=new Date(e);return e.getHours()>=Y0&&t.setDate(t.getDate()+1),t.setHours(0,0,0,0),fn(t)}function Iu(e=new Date){const t=new Date(e);return t.setFullYear(t.getFullYear()+1),t.setHours(0,0,0,0),fn(t)}function K0(e=18,t=new Date){const n=new Date(t);return n.setFullYear(n.getFullYear()-e),n.setHours(0,0,0,0),fn(n)}function Q0(e,t,n=new Date){const r=_s(e);if(!r)return!1;const a=new Date(n);return a.setFullYear(a.getFullYear()-t),a.setHours(0,0,0,0),r.setHours(0,0,0,0),r<=a}function J0(e){const t=e.getDay();return t!==0&&t!==6}function ei(e,t=new Date){if(!J0(e))return!1;const n=fn(e);return n>=Eu(t)&&n<=Iu(t)}function ta(e,t=new Date){const n=_s(e);return n?ei(n,t):!1}function G0(e,t){return`${H0[t]} ${e}`}function X0(e,t){const n=new Date(e,t,1),r=new Date(e,t+1,0).getDate(),a=n.getDay(),i=[];for(let o=0;o<a;o+=1)i.push(null);for(let o=1;o<=r;o+=1)i.push(new Date(e,t,o));return i}function yl(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function Gr(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 Tu({label:e,required:t=!1,htmlFor:n,info:r}){return s.jsxs("label",{htmlFor:n,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]}),r?s.jsxs("span",{className:"group relative inline-flex items-center",children:[s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 cursor-help items-center justify-center rounded-full border border-slate-300 text-[10px] font-semibold leading-none text-slate-400","aria-label":r,role:"img",children:"i"}),s.jsx("span",{role:"tooltip",className:"pointer-events-none absolute bottom-full left-1/2 z-20 mb-1.5 w-max max-w-xs -translate-x-1/2 rounded-md bg-slate-800 px-2.5 py-1.5 text-xs font-normal leading-snug text-white opacity-0 shadow-lg transition-opacity duration-150 group-hover:opacity-100",children:r})]}):null]})}function J({label:e,required:t,error:n,info:r,children:a}){return s.jsxs("div",{children:[s.jsx(Tu,{label:e,required:t,info:r}),a,n?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:n}):null]})}const _u=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 ne(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]"}`:_u(e)}function Kn(e){return`${_u(e)} appearance-none`}function Zn({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 _r({children:e}){return s.jsx("div",{className:"relative",children:e})}function Fu({value:e,onChange:t,entityId:n,entityType:r="",bankAccounts:a,isLoading:i=!1,disabled:o=!1,error:l,label:c="Bank Account Number",info:d}){const[u,m]=v.useState(!1),[h,p]=v.useState(!1),y=v.useRef(null),x=a.find(g=>String(g.bankAccountDetailId)===e);v.useEffect(()=>{if(!u)return;const g=C=>{var b;(b=y.current)!=null&&b.contains(C.target)||m(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[u]);const j=g=>{t(String(g)),p(!1),m(!1)};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{ref:y,className:"relative",children:[s.jsx(Tu,{label:c,required:!0,info:d}),s.jsxs("button",{type:"button",disabled:o||!n,onClick:()=>m(g=>!g),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:x?"text-slate-900":"text-slate-400",children:i?"Loading accounts…":x?yl(x.accountNumber):"Bank account number"}),s.jsx(tv,{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:()=>{m(!1),p(!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(ev,{}),"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(g=>{const C=String(g.bankAccountDetailId)===e;return s.jsxs("button",{type:"button",onClick:()=>{t(String(g.bankAccountDetailId)),m(!1)},className:`flex w-full items-center gap-3 px-4 py-3 text-left transition hover:bg-slate-50 ${C?"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:Oi(g.bankName)}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate text-sm font-semibold text-slate-900",children:g.bankName}),s.jsxs("span",{className:"block truncate text-xs text-slate-500",children:[yl(g.accountNumber),r?` · ${r}`:` · ${g.accountType}`]})]})]},g.bankAccountDetailId)})})]}):null]}),s.jsx(Pu,{open:h,entityId:n,onClose:()=>p(!1),onAccountAdded:j})]})}function ev(){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 tv({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 nv(e){const t=e.address2?`, ${e.address2}`:"";return`${e.address1}${t}, ${e.city}, ${e.state} ${e.zipCode}`}function Xr({entity:e,remittanceAmount:t="—",className:n=""}){if(!e)return s.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${n}`,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 r=en(e);return s.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${n}`,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(kr,{label:"Entity Name",value:r}),s.jsx(kr,{label:"Tax ID",value:qn(e.idNumber)}),s.jsx(kr,{label:"Email ID",value:e.email}),s.jsx(kr,{label:"Phone Number",value:$n(e.phoneNumber)}),s.jsx(kr,{label:"Address",value:nv(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 kr({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 rv=[0,1,3,4,6,7,9,10],sv=[0,1,2,3,4,5,6,7,8,9,10],av=[0,1,2,3,4,5,6,8,9,10,11],iv=[0,1,2,3,4,5,6,7,9,10,11],ov=["720","941"],lv=["706-GS (D)","706-GS (T)","926","940","943","944","945","1042","2438","3520","6069","8752","CT-1"],cv=["7200D"],uv=["8963"];function Du(e){return ov.includes(e)?rv:lv.includes(e)?sv:cv.includes(e)?av:uv.includes(e)?iv:[]}function dv(e){return e.length!==6?"":`${e.slice(0,4)}-${e.slice(4,6)}`}function Fs(e){if(e.length!==6)return null;const t=Number.parseInt(e.slice(0,4),10),n=Number.parseInt(e.slice(4,6),10);return Number.isNaN(t)||Number.isNaN(n)||n<1||n>12?null:{year:t,month:n-1}}function mv(e,t){return`${e}${String(t+1).padStart(2,"0")}`}function Ru(){const e=new Date().getFullYear();return{minYear:e-2,maxYear:e}}const Ds={941:"94105",944:"94405","CT-1":"10005"},Cr={socialSecurity:"Social Security",medicare:"Medicare",withheld:"Withheld",tier1:"Tier 1(FICA)",tier2:"Tier 2 (Industry)"},Rs={regex:/^(?!0+(?:\.0+)?$)(?:100000000(?:\.00?)?|(?:\d{1,8}|\d{1,7}\d)(?:\.\d{1,2})?)$/,errorMessage:"Payment amount must be a number greater than 0, can include up to 2 decimal places, and must not exceed 100,000,000 (one hundred million)."};function Ki(e,t){return!e||!t?!1:Ds[e]===t}function na(e,t){return e==="CT-1"&&t===Ds["CT-1"]}function hv(e,t){return e==="941"&&t===Ds[941]||e==="944"&&t===Ds[944]}function fv(e){return e==="CT-1"?{code1:Cr.tier1,code2:Cr.tier2,code3:""}:{code1:Cr.socialSecurity,code2:Cr.medicare,code3:Cr.withheld}}function $s(e){return Rs.regex.test(e)}const pv=/^(?:\d{0,8}(?:\.\d{0,2})?|100000000(?:\.\d{0,2})?)$/,cs=1e8;function xv(e){if(!e)return"";let t="",n=!1;for(const c of e)c>="0"&&c<="9"?t+=c:c==="."&&!n&&(t+=c,n=!0);const r=t.indexOf(".");let a=r===-1?t:t.slice(0,r);const i=r===-1?"":t.slice(r+1,r+3),o=r!==-1&&t.endsWith(".");if(a.length>9&&(a=a.slice(0,9)),a.length===9&&a!=="100000000"&&(a=a.slice(0,8)),a.length>0&&!o&&i===""){const c=Number.parseInt(a,10);!Number.isNaN(c)&&c>cs&&(a=String(cs))}let l=r===-1?a:`${a}.${i}`;if(o&&(l=`${a}.`),pv.test(l)){if(!l.endsWith(".")&&l!==""){const c=Number.parseFloat(l);if(!Number.isNaN(c)&&c>cs)return String(cs)}return l}return""}function $u(e){return $s(e)?Number.parseFloat(e):null}function gv(e,t,n,r){const a=[e,t];return r&&a.push(n),a.reduce((i,o)=>{const l=$u(o);return l===null?i:i+l},0)}function yv(e,t){return Math.abs(e-t)<.005}function bv(e,t,n,r,a){if(!Ki(e,t))return{subcategoryCode1:null,subcategoryCode2:null,subcategoryCode3:null};const i=na(e,t);return{subcategoryCode1:n.trim()?"1":null,subcategoryCode2:r.trim()?"2":null,subcategoryCode3:!i&&a.trim()?"3":null}}const vv=["Su","Mo","Tu","We","Th","Fr","Sa"];function jv(){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 Lu({value:e,onChange:t,disabled:n=!1,hasError:r=!1}){const a=_s(e),i=Eu(),o=Iu(),[l,c]=v.useState(!1),[d,u]=v.useState(()=>a??_s(i)??new Date),m=v.useRef(null),h=v.useId();v.useEffect(()=>{a&&u(a)},[e]),v.useEffect(()=>{if(!l)return;const g=C=>{var b;(b=m.current)!=null&&b.contains(C.target)||c(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[l]);const p=v.useMemo(()=>X0(d.getFullYear(),d.getMonth()),[d]),y=v.useMemo(()=>{const g=new Date(d.getFullYear(),d.getMonth()-1,1),C=new Date(g.getFullYear(),g.getMonth()+1,0);return fn(C)>=i},[d,i]),x=v.useMemo(()=>{const g=new Date(d.getFullYear(),d.getMonth()+1,1);return fn(g)<=o},[d,o]),j=g=>{ei(g)&&(t(fn(g)),c(!1))};return s.jsxs("div",{ref:m,className:"relative",children:[s.jsxs("div",{className:`flex items-center gap-2 rounded-lg border bg-white px-3 py-2.5 transition ${r?"border-red-300":"border-slate-200 focus-within:border-gov-400 focus-within:ring-2 focus-within:ring-gov-200"} ${n?"cursor-not-allowed bg-[#F9FAFB] opacity-60":""}`,children:[s.jsx("input",{id:h,type:"text",readOnly:!0,disabled:n,value:e,placeholder:"YYYY-MM-DD",onClick:()=>!n&&c(g=>!g),className:"w-full cursor-pointer border-0 bg-transparent p-0 text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none focus:ring-0 disabled:cursor-not-allowed"}),s.jsx("button",{type:"button",disabled:n,onClick:()=>c(g=>!g),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(jv,{})})]}),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:()=>u(g=>new Date(g.getFullYear(),g.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:G0(d.getFullYear(),d.getMonth())}),s.jsx("button",{type:"button",disabled:!x,onClick:()=>u(g=>new Date(g.getFullYear(),g.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:vv.map(g=>s.jsx("div",{className:"py-1",children:g},g))}),s.jsx("div",{className:"grid grid-cols-7 gap-1 p-3 pt-1",children:p.map((g,C)=>{if(!g)return s.jsx("div",{},`empty-${C}`);const b=fn(g),S=e===b,I=!ei(g);return s.jsx("button",{type:"button","aria-disabled":I,onClick:()=>j(g),className:`rounded-lg px-1 py-2 text-sm transition ${I?"cursor-not-allowed text-slate-300 hover:bg-sky-50":S?"bg-sky-100 font-semibold text-slate-900":"font-medium text-slate-800 hover:bg-slate-50"}`,children:g.getDate()},b)})})]}):null]})}function Ir({value:e,onChange:t,onBlur:n,name:r,disabled:a=!1,readOnly:i=!1,placeholder:o="0.00",hasError:l=!1}){return s.jsx("input",{type:"text",inputMode:"decimal",autoComplete:"off",name:r,value:e,disabled:a,readOnly:i,placeholder:o,className:ne(l,i),onChange:c=>t(xv(c.target.value)),onBlur:n})}const wv=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Nv(){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 Sv({value:e,onChange:t,disabled:n=!1,hasError:r=!1,disabledMonths:a=[]}){const{minYear:i,maxYear:o}=Ru(),l=Fs(e),[c,d]=v.useState(!1),[u,m]=v.useState((l==null?void 0:l.year)??o),h=v.useRef(null),p=v.useId();v.useEffect(()=>{l&&m(l.year)},[e]),v.useEffect(()=>{if(!c)return;const b=S=>{var I;(I=h.current)!=null&&I.contains(S.target)||d(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[c]);const y=dv(e),x=b=>!!a.includes(b),j=b=>{x(b)||(t(mv(u,b)),d(!1))},g=u>i,C=u<o;return s.jsxs("div",{ref:h,className:"relative",children:[s.jsxs("div",{className:`flex items-center gap-2 rounded-lg border bg-white px-3 py-2.5 transition ${r?"border-red-300":"border-slate-200 focus-within:border-gov-400 focus-within:ring-2 focus-within:ring-gov-200"} ${n?"cursor-not-allowed bg-[#F9FAFB] opacity-60":""}`,children:[s.jsx("input",{id:p,type:"text",readOnly:!0,disabled:n,value:y,placeholder:"YYYY-MM",onClick:()=>!n&&d(b=>!b),className:"w-full cursor-pointer border-0 bg-transparent p-0 text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none focus:ring-0 disabled:cursor-not-allowed"}),s.jsx("button",{type:"button",disabled:n,onClick:()=>d(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(Nv,{})})]}),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:!g,onClick:()=>m(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:u}),s.jsx("button",{type:"button",disabled:!C,onClick:()=>m(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:wv.map((b,S)=>{const I=(l==null?void 0:l.year)===u&&l.month===S&&e.length===6,R=x(S);return s.jsx("button",{type:"button","aria-disabled":R,onClick:()=>j(S),className:`rounded-lg px-2 py-2.5 text-sm transition ${R?"cursor-not-allowed text-slate-300 hover:bg-sky-50":I?"bg-sky-100 font-semibold text-slate-900":"font-medium text-slate-800 hover:bg-slate-50"}`,children:b},b)})})]}):null]})}const Ou="Active",kv="Inactive";function vr(e){return(e.status??Ou).trim().toLowerCase()==="active"}function Cv(e){return vr(e)?kv:Ou}function Av(e){return vr(e)?"Deactivate":"Activate"}function Qi(e){var t;return((t=e==null?void 0:e.accountType)==null?void 0:t.trim().toLowerCase())==="individual"}function Pv(e){return Qi(e)?"/payments/federal/individual-enrollment":"/payments/federal/authorization"}function zu(e){const t=bv(e.taxFormType,e.taxTypeCode,e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??""),n=na(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:!n&&e.subcategoryAmount3?Number.parseFloat(e.subcategoryAmount3):null}}function Ji(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),...zu(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),...zu(e)}}const Xi="federal-payment-draft";function eo(e){sessionStorage.setItem(Xi,JSON.stringify(e))}function ra(){const e=sessionStorage.getItem(Xi);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function to(){sessionStorage.removeItem(Xi)}function Ev(e,t={}){return{federalPaymentId:e.federalPaymentId,enrollmentId:e.enrollmentId,taxpayerPin:e.taxpayerPin??"",secondaryTin:e.secondaryTin??"",bankAccountDetailId:e.bankAccountDetailId?String(e.bankAccountDetailId):"",routingNumber:t.routingNumber??"",accountNumber:t.accountNumber??"",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 Iv=Xt({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=Fs(e);if(!t)return!1;const{minYear:n,maxYear:r}=Ru();return t.year>=n&&t.year<=r},"Tax period must be within the last 3 years"),settlementDate:F().min(1,"This field is required").refine(e=>ta(e),"Settlement date must be a weekday within the allowed range"),paymentAmount:F().min(1,"This field is required").refine(e=>$s(e),Rs.errorMessage),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=Fs(e.taxPeriod);c&&Du(e.taxFormType).includes(c.month)&&t.addIssue({code:Qt.custom,message:"Tax period must be a valid month for the selected tax form",path:["taxPeriod"]})}if(!Ki(e.taxFormType,e.taxTypeCode))return;const n=na(e.taxFormType,e.taxTypeCode),r=hv(e.taxFormType,e.taxTypeCode),a=(c,d,u)=>{if(!(c!=null&&c.trim())){u&&t.addIssue({code:Qt.custom,message:"This field is required",path:[d]});return}$s(c)||t.addIssue({code:Qt.custom,message:Rs.errorMessage,path:[d]})};a(e.subcategoryAmount1,"subcategoryAmount1",!0),a(e.subcategoryAmount2,"subcategoryAmount2",!0),a(e.subcategoryAmount3,"subcategoryAmount3",r);const i=$u(e.paymentAmount),o=gv(e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??"",r);i!==null&&!yv(i,o)&&t.addIssue({code:Qt.custom,message:"Payment amount must equal the sum of subcategory amounts",path:["paymentAmount"]}),n&&((l=e.subcategoryAmount3)!=null&&l.trim())&&t.addIssue({code:Qt.custom,message:"Subcategory amount 3 is not used for CT-1 payments",path:["subcategoryAmount3"]})}),us="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function ga(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 Tv={taxpayerPin:"",secondaryTin:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:"",taxFormType:"",taxTypeCode:"",taxPeriod:"",settlementDate:"",paymentAmount:"",subcategoryCode1:"",subcategoryAmount1:"",subcategoryCode2:"",subcategoryAmount2:"",subcategoryCode3:"",subcategoryAmount3:""};function _v(e,t,n){if(e)return ga(e);if(t!=null&&t.paymentDraft)return ga(t.paymentDraft);const r=ra();return r&&r.entityId===n?ga(r):Tv}function Mu({entity:e,initialDraft:t,readonly:n=!1,onCancel:r}){var bt,pt,vt,zt,jt,Mt,At,Pt,Et,It,qt,Bt,wt;const a=ke(),i=Se(),o=ft(),l=Bn(i.state,Qe()),c=i.state,d=ra(),u=t??(c==null?void 0:c.paymentDraft)??(d&&d.entityId===(e==null?void 0:e.entityId)?d:null),m=v.useRef(u==null?void 0:u.federalPaymentId),h=v.useRef(u==null?void 0:u.enrollmentId),[p,y]=v.useState(null),[x,j]=v.useState(!1),g=v.useMemo(()=>_v(t,c,e==null?void 0:e.entityId),[t,c==null?void 0:c.paymentDraft,e==null?void 0:e.entityId,i.key]);v.useEffect(()=>{u!=null&&u.federalPaymentId&&(m.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:C=[],isLoading:b}=ge({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Jr({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:e!==null}),S=v.useMemo(()=>C.filter(vr),[C]),{data:I=[],isLoading:R}=ge({queryKey:["federal-form-types",e==null?void 0:e.entityId],queryFn:()=>x0(e.entityId),enabled:e!==null}),{register:E,control:T,handleSubmit:L,watch:B,setValue:K,getValues:X,trigger:Y,formState:{errors:V}}=Rt({resolver:Lt(Iv),defaultValues:g}),Z=B("bankAccountDetailId"),ie=B("paymentAmount"),G=B("taxFormType"),Q=B("taxTypeCode"),we=B("taxPeriod"),Ae=B("settlementDate"),$e=B("subcategoryAmount1"),ce=B("subcategoryAmount2"),pe=B("subcategoryAmount3"),$=v.useRef(G),fe=v.useMemo(()=>G?Du(G):[],[G]),O=v.useMemo(()=>Ki(G,Q),[G,Q]),ue=v.useMemo(()=>na(G,Q),[G,Q]),{data:Te=[],isLoading:Je}=ge({queryKey:["federal-tax-type-codes",G],queryFn:()=>g0(G),enabled:!!G});v.useEffect(()=>{$.current&&$.current!==G&&K("taxTypeCode",""),$.current=G},[G,K]),v.useEffect(()=>{if(!we||!G)return;const f=Fs(we);f&&fe.includes(f.month)&&K("taxPeriod","")},[G,we,fe,K]),v.useEffect(()=>{Ae&&(ta(Ae)||K("settlementDate",""))},[Ae,K]),v.useEffect(()=>{if(!O){K("subcategoryCode1",""),K("subcategoryCode2",""),K("subcategoryCode3",""),K("subcategoryAmount1",""),K("subcategoryAmount2",""),K("subcategoryAmount3","");return}const f=fv(G);K("subcategoryCode1",f.code1),K("subcategoryCode2",f.code2),K("subcategoryCode3",ue?"":f.code3),ue&&K("subcategoryAmount3","")},[O,G,ue,K]),v.useEffect(()=>{O&&(Y("paymentAmount"),Y("subcategoryAmount1"),Y("subcategoryAmount2"),Y("subcategoryAmount3"))},[$e,ce,pe,O,Y]),v.useEffect(()=>{if(b)return;const f=S.find(N=>String(N.bankAccountDetailId)===Z);if(!f){Z&&(K("bankAccountDetailId",""),K("routingNumber",""),K("accountType",""),K("bankName",""));return}K("routingNumber",f.routingNumber),K("accountType",f.accountType),K("bankName",f.bankName)},[S,Z,b,K]);const oe=f=>{const N=S.find(A=>String(A.bankAccountDetailId)===f.bankAccountDetailId);return{federalPaymentId:m.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:f.taxpayerPin??"",secondaryTin:f.secondaryTin??"",bankAccountDetailId:f.bankAccountDetailId,routingNumber:f.routingNumber??(N==null?void 0:N.routingNumber)??"",accountNumber:(N==null?void 0:N.accountNumber)??"",accountType:f.accountType??(N==null?void 0:N.accountType)??"",bankName:f.bankName??(N==null?void 0:N.bankName)??"",taxFormType:f.taxFormType,taxTypeCode:f.taxTypeCode,taxPeriod:f.taxPeriod,settlementDate:f.settlementDate,paymentAmount:f.paymentAmount,subcategoryCode1:f.subcategoryCode1,subcategoryAmount1:f.subcategoryAmount1,subcategoryCode2:f.subcategoryCode2,subcategoryAmount2:f.subcategoryAmount2,subcategoryCode3:f.subcategoryCode3,subcategoryAmount3:f.subcategoryAmount3}},ve=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]}),m.current&&o.removeQueries({queryKey:["federal-payment",m.current],exact:!0})},Oe=async f=>{if(!e)return null;if(f.federalPaymentId){const A=await Yi(f.federalPaymentId,Gi(f));return m.current=A.federalPaymentId,h.current=A.enrollmentId,A}const N=await Wi(Ji(e.entityId,f));return m.current=N.federalPaymentId,h.current=N.enrollmentId,N},We=L(async f=>{if(!(n||!e)){y(null),j(!0);try{const N=oe(f),A=await Oe(N);if(!A)return;const k={...N,entityId:e.entityId,federalPaymentId:A.federalPaymentId,enrollmentId:A.enrollmentId};await ve(),eo(k),a(Pv(e),{state:{from:l,paymentDraft:k}})}catch(N){y(tt(N,"Failed to save payment details."))}finally{j(!1)}}}),re=async()=>{if(!(!e||n)){y(null),j(!0);try{const f=oe(X());await Oe(f),await ve(),to(),a(Qe())}catch(f){y(tt(f,"Failed to save draft."))}finally{j(!1)}}},nt=()=>{if(r){r();return}a(l)},rt=e?en(e):"Entity";return s.jsxs("form",{onSubmit:We,noValidate:!0,className:"w-full space-y-6",children:[p?s.jsx(Ot,{message:p}):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:rt}),s.jsx(Xr,{entity:e,remittanceAmount:Gr(ie),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(wn,{title:"Enrolment Details",isFirst:!0,children:s.jsxs("div",{className:us,children:[s.jsx(J,{label:"Taxpayer PIN",required:!0,info:"The 4-digit PIN assigned by the IRS for EFTPS enrollment.",error:(bt=V.taxpayerPin)==null?void 0:bt.message,children:s.jsx("input",{placeholder:"Taxpayer PIN",className:ne(!!V.taxpayerPin),maxLength:4,disabled:n,...E("taxpayerPin")})}),s.jsx(J,{label:"Secondary TIN",info:"An additional Taxpayer Identification Number, if the payment requires one.",error:(pt=V.secondaryTin)==null?void 0:pt.message,children:s.jsx("input",{placeholder:"Secondary TIN",className:ne(!!V.secondaryTin),maxLength:9,disabled:n,...E("secondaryTin")})}),s.jsx(Ne,{name:"bankAccountDetailId",control:T,render:({field:f})=>{var N;return s.jsx(Fu,{value:f.value,onChange:f.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:S,isLoading:b,disabled:!e||n,info:"Select the bank account to debit for this payment, or add a new one.",error:(N=V.bankAccountDetailId)==null?void 0:N.message})}}),s.jsx(J,{label:"Routing Number",required:!0,info:"The 9-digit bank routing number, auto-filled from the selected bank account.",error:(vt=V.routingNumber)==null?void 0:vt.message,children:s.jsx("input",{readOnly:!0,placeholder:"Routing Number",className:ne(!!V.routingNumber,!0),...E("routingNumber")})}),s.jsx(J,{label:"Account Type",required:!0,info:"The bank account type (checking or savings), auto-filled from the selected bank account.",error:(zt=V.accountType)==null?void 0:zt.message,children:s.jsx("input",{readOnly:!0,placeholder:"Account Type",className:ne(!!V.accountType,!0),...E("accountType")})}),s.jsx(J,{label:"Bank Name",required:!0,info:"The name of the bank, auto-filled from the selected bank account.",error:(jt=V.bankName)==null?void 0:jt.message,children:s.jsx("input",{readOnly:!0,placeholder:"Bank Name",className:ne(!!V.bankName,!0),...E("bankName")})})]})}),s.jsx(wn,{title:"Federal Payment",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:us,children:[s.jsx(J,{label:"Tax Form Type",required:!0,info:"The federal tax form this payment applies to (e.g. 941, 944, CT-1).",error:(Mt=V.taxFormType)==null?void 0:Mt.message,children:s.jsxs(_r,{children:[s.jsx(Ne,{name:"taxFormType",control:T,render:({field:f})=>s.jsxs("select",{className:Kn(!!V.taxFormType),disabled:R||!e||n,...f,children:[s.jsx("option",{value:"",children:R?"Loading form types…":"Select form type"}),I.map(N=>s.jsx("option",{value:N.value,children:N.value},N.value))]})}),s.jsx(Zn,{})]})}),s.jsx(J,{label:"Payment Type",required:!0,info:"The type of payment for the selected tax form.",error:(At=V.taxTypeCode)==null?void 0:At.message,children:s.jsxs(_r,{children:[s.jsx(Ne,{name:"taxTypeCode",control:T,render:({field:f})=>s.jsxs("select",{className:Kn(!!V.taxTypeCode),disabled:!G||Je||n,...f,children:[s.jsx("option",{value:"",children:G?Je?"Loading payment types…":"Select payment type":"Select tax form first"}),Te.map(N=>s.jsxs("option",{value:N.code,children:[N.code," - ",N.codeName]},N.code))]})}),s.jsx(Zn,{})]})}),s.jsx(J,{label:"Tax Period",required:!0,info:"The tax period (month and year) this payment covers.",error:(Pt=V.taxPeriod)==null?void 0:Pt.message,children:s.jsx(Ne,{name:"taxPeriod",control:T,render:({field:f})=>s.jsx(Sv,{value:f.value,onChange:f.onChange,hasError:!!V.taxPeriod,disabled:!G||n,disabledMonths:fe})})})]}),s.jsxs("div",{className:"grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx(J,{label:"Settlement Date",required:!0,info:"The weekday the payment will be withdrawn and settled with the IRS.",error:(Et=V.settlementDate)==null?void 0:Et.message,children:s.jsx(Ne,{name:"settlementDate",control:T,render:({field:f})=>s.jsx(Lu,{value:f.value,onChange:f.onChange,hasError:!!V.settlementDate,disabled:n})})}),s.jsx(J,{label:"Payment Amount",required:!0,info:"The total amount to remit. Must equal the sum of subcategory amounts when applicable.",error:(It=V.paymentAmount)==null?void 0:It.message,children:s.jsx(Ne,{name:"paymentAmount",control:T,render:({field:f})=>s.jsx(Ir,{name:f.name,value:f.value,onChange:f.onChange,onBlur:f.onBlur,disabled:n,hasError:!!V.paymentAmount})})})]}),O?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:us,children:[s.jsx(J,{label:"Subcategory Code 1",info:"The first subcategory code for the selected tax form, set automatically.",children:s.jsx("input",{readOnly:!0,className:ne(!1,!0),...E("subcategoryCode1")})}),s.jsx(J,{label:"Subcategory Code 2",info:"The second subcategory code for the selected tax form, set automatically.",children:s.jsx("input",{readOnly:!0,className:ne(!1,!0),...E("subcategoryCode2")})}),ue?null:s.jsx(J,{label:"Subcategory Code 3",info:"The third subcategory code for the selected tax form, set automatically.",children:s.jsx("input",{readOnly:!0,className:ne(!1,!0),...E("subcategoryCode3")})})]}),s.jsxs("div",{className:us,children:[s.jsx(J,{label:"Subcategory Amount 1",required:!0,info:"The amount allocated to Subcategory Code 1.",error:(qt=V.subcategoryAmount1)==null?void 0:qt.message,children:s.jsx(Ne,{name:"subcategoryAmount1",control:T,render:({field:f})=>s.jsx(Ir,{name:f.name,value:f.value??"",onChange:f.onChange,onBlur:f.onBlur,disabled:n,placeholder:"Enter amount",hasError:!!V.subcategoryAmount1})})}),s.jsx(J,{label:"Subcategory Amount 2",required:!0,info:"The amount allocated to Subcategory Code 2.",error:(Bt=V.subcategoryAmount2)==null?void 0:Bt.message,children:s.jsx(Ne,{name:"subcategoryAmount2",control:T,render:({field:f})=>s.jsx(Ir,{name:f.name,value:f.value??"",onChange:f.onChange,onBlur:f.onBlur,disabled:n,placeholder:"Enter amount",hasError:!!V.subcategoryAmount2})})}),ue?null:s.jsx(J,{label:"Subcategory Amount 3",required:!0,info:"The amount allocated to Subcategory Code 3.",error:(wt=V.subcategoryAmount3)==null?void 0:wt.message,children:s.jsx(Ne,{name:"subcategoryAmount3",control:T,render:({field:f})=>s.jsx(Ir,{name:f.name,value:f.value??"",onChange:f.onChange,onBlur:f.onBlur,disabled:n,placeholder:"Enter amount",hasError:!!V.subcategoryAmount3})})})]})]}):null]})})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[s.jsx("button",{type:"button",onClick:nt,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:n?"Back":"Cancel"}),n?null:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:re,disabled:!e||x,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:x?"Saving…":"Save as Draft"}),s.jsx("button",{type:"submit",disabled:!e||x,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:x?"Saving…":"Next"})]})]})]},i.key)}function qu(){const{selectedEntity:e}=ht();return s.jsx(Mu,{entity:e})}function Bu({mode:e}){var m;const t=ke(),{federalPaymentId:n}=zs(),{selectedEntity:r}=ht(),a=Number.parseInt(n??"",10),{data:i,isLoading:o,isError:l}=ge({queryKey:["federal-payment",a],queryFn:()=>Zi(a),enabled:Number.isFinite(a)}),{data:c=[]}=ge({queryKey:["bank-accounts",r==null?void 0:r.entityId],queryFn:async()=>(await Jr({entityId:r.entityId,pageNumber:1,pageSize:100})).items,enabled:r!==null&&i!==void 0}),d=v.useMemo(()=>{if(!i)return null;const h=c.find(p=>p.bankAccountDetailId===i.bankAccountDetailId);return Ev(i,{routingNumber:h==null?void 0:h.routingNumber,accountNumber:h==null?void 0:h.accountNumber,accountType:h==null?void 0:h.accountType,bankName:h==null?void 0:h.bankName})},[i,c]);if(!Number.isFinite(a))return s.jsx(Be,{to:Qe(),replace:!0});if(o)return s.jsx("p",{className:"text-sm text-slate-600",children:"Loading federal payment…"});if(l||!i||!d)return s.jsx(Be,{to:Qe(),replace:!0});if(!r||i.entityId!==r.entityId)return s.jsx(Be,{to:Qe(),replace:!0});const u=e==="view"||((m=i.status)==null?void 0:m.toLowerCase())!=="draft";return s.jsx(Mu,{entity:r,initialDraft:d,readonly:u,onCancel:()=>t(Qe())})}function Vu(){return ht(),s.jsx(Bu,{mode:"edit"})}function Uu(){return ht(),s.jsx(Bu,{mode:"view"})}function Fv(e){const t=[];return e.includes("\\d")&&t.push("0-9"),/[A-Z]/.test(e)&&t.push("A-Z"),e.includes("-")&&t.push("\\-"),e.includes(" ")&&t.push(" "),e.includes("/")&&t.push("/"),t.length?t.join(""):null}function Dv(e,t){const n=e.toUpperCase();if(!t)return n;const r=Fv(t);return r?n.replace(new RegExp(`[^${r}]`,"g"),""):n}function Rv(e){if(!e)return null;const t=[];let n=0;try{for(;n<e.length;){if(e.startsWith("(?:",n))return null;const r=e[n];if(r==="-"||r===" "||r==="/"){t.push({type:"separator",char:r}),n+=1;continue}let a;if(r==="\\")a=e[n+1]==="d"?"digit":"letter",n+=2;else if(r==="["){const o=e.indexOf("]",n);if(o===-1)return null;a="letter",n=o+1}else a=r>="0"&&r<="9"?"digit":"letter",n+=1;const i=$v(e,n);if(i===null)return null;for(let o=0;o<i.count;o+=1)t.push({type:"slot",kind:a});n=i.nextIndex}}catch{return null}return t}function $v(e,t){if(e[t]!=="{")return{count:1,nextIndex:t};const n=e.indexOf("}",t);if(n===-1)throw new Error("Unterminated quantifier");const r=e.slice(t+1,n);if(r.includes(","))return null;const a=Number.parseInt(r,10);if(Number.isNaN(a))throw new Error("Bad quantifier");return{count:a,nextIndex:n+1}}function Lv(e,t){const n=e.toUpperCase().replace(/[^0-9A-Z]/g,"").split("");let r="",a=0;for(const i of t){if(a>=n.length)break;if(i.type==="separator"){r+=i.char;continue}for(;a<n.length;){const o=n[a];a+=1;const l=o>="0"&&o<="9";if(i.kind==="digit"?l:!l){r+=o;break}}}return r}function Ov(e){if(e)try{const t=Zu(e,0);return t.index===e.length?t.length:void 0}catch{return}}function Zu(e,t){let n=t,r=0;for(;;){const a=zv(e,n);if(r=Math.max(r,a.length),n=a.index,e[n]==="|"){n+=1;continue}return{length:r,index:n}}}function zv(e,t){let n=t,r=0;for(;n<e.length&&e[n]!=="|"&&e[n]!==")";){const a=Mv(e,n);r+=a.length,n=a.index}return{length:r,index:n}}function Mv(e,t){let n=t,r;if(e.startsWith("(?:",n)){const a=Zu(e,n+3);if(e[a.index]!==")")throw new Error("Unbalanced group");r=a.length,n=a.index+1}else if(e[n]==="\\")r=1,n+=2;else if(e[n]==="["){const a=e.indexOf("]",n);if(a===-1)throw new Error("Unterminated class");r=1,n=a+1}else r=1,n+=1;if(e[n]==="{"){const a=e.indexOf("}",n);if(a===-1)throw new Error("Unterminated quantifier");const i=e.slice(n+1,a).split(","),o=i.length===2?i[1]:i[0],l=Number.parseInt(o,10);if(Number.isNaN(l))throw new Error("Bad quantifier");r*=l,n=a+1}return{length:r,index:n}}const no="state-payment-draft";function ti(e){sessionStorage.setItem(no,JSON.stringify(e))}function ni(){const e=sessionStorage.getItem(no);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Wu(){sessionStorage.removeItem(no)}function qv(e,t){var n;return{entityId:e,state:t.state,reasonForPayment:t.reasonForPayment,stateAccountId:t.stateAccountId,accountId:t.accountId,letterId:(n=t.letterId)!=null&&n.trim()?t.letterId.trim():null,taxYear:t.taxYear,taxPeriod:t.taxPeriod,taxAmount:Number.parseFloat(t.taxAmount),paymentDate:t.paymentDate,bankAccountDetailId:Number.parseInt(t.bankAccountDetailId,10)}}function Bv(e){var t;return{state:e.state,reasonForPayment:e.reasonForPayment,stateAccountId:e.stateAccountId,accountId:e.accountId,letterId:(t=e.letterId)!=null&&t.trim()?e.letterId.trim():null,taxYear:e.taxYear,taxPeriod:e.taxPeriod,taxAmount:Number.parseFloat(e.taxAmount),paymentDate:e.paymentDate,bankAccountDetailId:Number.parseInt(e.bankAccountDetailId,10)}}function Vv(e){return Xt({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").refine(t=>/^\d{10,12}$/.test(t.trim()),"Account ID must be 10 to 12 digits"),letterId:F().optional().refine(t=>!t||/^[A-Za-z0-9]+$/.test(t),"Letter ID must be alphanumeric"),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(t=>$s(t),Rs.errorMessage),paymentDate:F().min(1,"Payment date is required").refine(t=>ta(t),"Payment date must be a weekday within the allowed range"),bankAccountDetailId:F().min(1,"Bank account is required"),routingNumber:F().optional(),accountType:F().optional(),bankName:F().optional()}).superRefine((t,n)=>{const r=e(),a=r==null?void 0:r.stateId.pattern;if(a)try{new RegExp(`^(?:${a})$`).test(t.stateAccountId.trim().toUpperCase())||n.addIssue({code:Qt.custom,path:["stateAccountId"],message:r.stateId.message})}catch{n.addIssue({code:Qt.custom,path:["stateAccountId"],message:"State ID validation is temporarily unavailable"})}})}const ya="grid gap-x-6 gap-y-5 sm:grid-cols-3",bl="grid gap-x-6 gap-y-5 sm:grid-cols-2",vl="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",jl={state:"",reasonForPayment:"",stateAccountId:"",accountId:"",letterId:"",taxYear:"",taxPeriod:"",taxAmount:"",paymentDate:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:""};function ba(e){return{state:e.state,reasonForPayment:Uv(e.reasonForPayment),stateAccountId:e.stateAccountId,accountId:e.accountId,letterId:e.letterId??"",taxYear:e.taxYear,taxPeriod:e.taxPeriod,taxAmount:e.taxAmount,paymentDate:e.paymentDate,bankAccountDetailId:e.bankAccountDetailId,routingNumber:e.routingNumber??"",accountType:e.accountType??"",bankName:e.bankName??""}}function Uv(e){return e.trim().toUpperCase().replaceAll(" ","_")}function Yu({entity:e,initialDraft:t,readonly:n=!1,onCancel:r}){var Et,It,qt,Bt,wt,f,N,A;const a=ke(),i=Se(),o=Bn(i.state,Qe()),l=i.state,c=v.useMemo(()=>t??(l==null?void 0:l.paymentDraft)??ni()??null,[t,l==null?void 0:l.paymentDraft]),d=v.useRef(c==null?void 0:c.statePaymentDetailId),u=v.useMemo(()=>{if(t)return ba(t);if(l!=null&&l.paymentDraft)return ba(l.paymentDraft);if(l!=null&&l.resetDraft)return Wu(),jl;const k=ni();return k?ba(k):jl},[t,l==null?void 0:l.paymentDraft,l==null?void 0:l.resetDraft,i.key]),{data:m=[],isLoading:h,isError:p}=ge({queryKey:["state-payment-states"],queryFn:({signal:k})=>k0(k)}),{data:y=[],isLoading:x}=ge({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Jr({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:e!==null}),j=v.useMemo(()=>y.filter(vr),[y]),g=v.useRef(null),C=v.useMemo(()=>Vv(()=>g.current),[]),{register:b,control:S,handleSubmit:I,watch:R,setValue:E,clearErrors:T,formState:{errors:L}}=Rt({resolver:Lt(C),defaultValues:u}),B=R("state"),K=R("reasonForPayment"),X=R("taxAmount"),Y=R("paymentDate"),V=R("bankAccountDetailId"),{data:Z=[],isLoading:ie,isError:G}=ge({queryKey:["state-payment-reasons",e==null?void 0:e.entityId,B],queryFn:({signal:k})=>C0(e.entityId,B,k),enabled:e!==null&&!!B}),{data:Q,isLoading:we,isError:Ae}=ge({queryKey:["state-payment-validation-metadata",e==null?void 0:e.entityId,B,K],queryFn:({signal:k})=>A0(e.entityId,B,K,k),enabled:e!==null&&!!(B&&K)});ge({queryKey:["state-payment-form-references",e==null?void 0:e.entityId,B,K],queryFn:({signal:k})=>P0(e.entityId,B,K,k),enabled:e!==null&&!!(B&&K)}),g.current=Q??null;const $e=(Q==null?void 0:Q.taxYearOptions)??[],ce=(Q==null?void 0:Q.taxPeriodOptions)??[],pe=!!(Q&&B&&K),$=(Q==null?void 0:Q.stateId.pattern)??null,fe=Ov($),O=v.useMemo(()=>Rv($),[$]),ue=b("stateAccountId"),Te=b("accountId"),Je=b("letterId"),[oe,ve]=v.useState(!1),[Oe,We]=v.useState(""),re=v.useRef(null),nt=(Et=m.find(k=>k.code===B))==null?void 0:Et.name,rt=v.useMemo(()=>{const k=Oe.trim().toLowerCase();return k?m.filter(_=>_.name.toLowerCase().includes(k)||_.code.toLowerCase().includes(k)):m},[Oe,m]),bt=["stateAccountId","accountId","letterId","taxYear","taxPeriod","taxAmount","paymentDate"],pt=()=>{bt.forEach(k=>E(k,"")),T([...bt,"bankAccountDetailId"])},vt=k=>{E("state",k,{shouldValidate:!0}),E("reasonForPayment",""),T("reasonForPayment"),pt(),We(""),ve(!1)},zt=k=>{k!==K&&(E("reasonForPayment",k,{shouldValidate:!0}),pt())};v.useEffect(()=>{c!=null&&c.statePaymentDetailId&&(d.current=c.statePaymentDetailId)},[c==null?void 0:c.statePaymentDetailId]),v.useEffect(()=>{var k;oe&&((k=re.current)==null||k.focus())},[oe]),v.useEffect(()=>{!K||ie||G||Z.some(k=>k.code===K)||E("reasonForPayment","")},[ie,G,Z,K,E]);const jt=v.useRef(!1);v.useEffect(()=>{if(!n){if(!jt.current){jt.current=!0;return}Y&&!ta(Y)&&E("paymentDate","")}},[Y,E,n]),v.useEffect(()=>{if(n||x)return;const k=j.find(_=>String(_.bankAccountDetailId)===V);if(!k){V&&(E("bankAccountDetailId",""),E("routingNumber",""),E("accountType",""),E("bankName",""));return}E("routingNumber",k.routingNumber),E("accountType",k.accountType),E("bankName",k.bankName)},[j,V,E,n,x]);const Mt=I(k=>{if(n||!Q)return;const _={statePaymentDetailId:d.current,state:k.state,reasonForPayment:k.reasonForPayment,stateAccountId:k.stateAccountId.trim().toUpperCase(),accountId:k.accountId.trim(),letterId:k.letterId,taxYear:k.taxYear,taxPeriod:k.taxPeriod,taxAmount:k.taxAmount,paymentDate:k.paymentDate,bankAccountDetailId:k.bankAccountDetailId,routingNumber:k.routingNumber,accountType:k.accountType,bankName:k.bankName};ti(_),a("/payments/state/authorization",{state:{from:o,paymentDraft:_}})}),At=()=>{if(r){r();return}a(o)},Pt=e?en(e):"Entity";return s.jsx("form",{onSubmit:Mt,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:Pt}),s.jsx(Xr,{entity:e,remittanceAmount:Gr(X),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:vl,children:[s.jsx(wl,{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",disabled:n||h||p,onClick:()=>{We(""),ve(k=>!k)},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 disabled:cursor-not-allowed disabled:opacity-70",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(Zv,{})}),s.jsxs("span",{children:[s.jsx("span",{className:"block text-sm font-semibold text-slate-900",children:h?"Loading states…":nt??"Choose a state"}),s.jsx("span",{className:"block text-xs text-slate-500",children:"Tap to select the tax jurisdiction"})]})]}),s.jsx(Zn,{className:`h-4 w-4 text-slate-400 transition ${oe?"rotate-180":""}`})]}),oe?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:"border-b border-slate-100 p-2",children:s.jsx("input",{ref:re,type:"search",value:Oe,onChange:k=>We(k.target.value),onKeyDown:k=>{k.key==="Escape"?ve(!1):k.key==="Enter"&&k.preventDefault()},placeholder:"Search by state name or code","aria-label":"Search states",className:"w-full rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-900 outline-none transition placeholder:text-slate-400 focus:border-gov-400 focus:bg-white focus:ring-2 focus:ring-gov-100"})}),s.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[rt.map(k=>s.jsxs("button",{type:"button",onClick:()=>vt(k.code),className:`flex w-full items-center justify-between px-4 py-3 text-left text-sm transition hover:bg-slate-50 ${B===k.code?"bg-gov-50 text-gov-700":"text-slate-700"}`,children:[s.jsx("span",{children:k.name}),s.jsx("span",{className:"text-xs font-medium text-slate-400",children:k.code})]},k.code)),rt.length===0?s.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No states found."}):null]})]}):null,L.state?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:L.state.message}):null,p?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:"Unable to load states."}):null]}),s.jsx(J,{label:"Reason for Payment",required:!0,info:"The reason for this state tax payment, filtered by the selected state and entity.",error:(It=L.reasonForPayment)==null?void 0:It.message,children:s.jsxs(_r,{children:[s.jsxs("select",{disabled:n||!B||ie||G,className:Kn(!!L.reasonForPayment),value:K,onChange:k=>zt(k.target.value),children:[s.jsx("option",{value:"",children:ie?"Loading reasons…":"Select reason"}),Z.map(k=>s.jsx("option",{value:k.code,children:k.label},k.code))]}),s.jsx(Zn,{})]})}),G?s.jsx("p",{className:"text-xs text-red-600",children:"Unable to load payment reasons."}):null,B&&!ie&&!G&&Z.length===0?s.jsx("p",{className:"text-xs text-slate-500",children:"No supported payment reasons are available for this entity and state."}):null]})]}),s.jsxs("section",{className:`${vl} transition ${pe?"":"opacity-60"}`,children:[s.jsx(wl,{step:2,title:"Payment Form",className:"mb-5"}),s.jsxs("fieldset",{disabled:!pe||n,className:"min-w-0 border-0 p-0",children:[s.jsx(va,{title:"Payment Details",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:ya,children:[s.jsx(J,{label:"State ID",required:(Q==null?void 0:Q.stateId.required)??!0,info:"Your state-issued tax account identifier for the selected state.",error:(qt=L.stateAccountId)==null?void 0:qt.message,children:s.jsx("input",{placeholder:(Q==null?void 0:Q.stateId.example)??"Enter ID",maxLength:fe,className:ne(!!L.stateAccountId),...ue,onChange:k=>{k.target.value=O?Lv(k.target.value,O):Dv(k.target.value,$),ue.onChange(k)}})}),s.jsx(J,{label:"Account ID",required:(Q==null?void 0:Q.accountIdRequired)??!0,info:"Your 10 to 12 digit state tax account number.",error:(Bt=L.accountId)==null?void 0:Bt.message,children:s.jsx("input",{inputMode:"numeric",placeholder:"10–12 digits",maxLength:12,className:ne(!!L.accountId),...Te,onChange:k=>{k.target.value=k.target.value.replace(/\D/g,"").slice(0,12),Te.onChange(k)}})}),s.jsx(J,{label:"Letter ID",required:(Q==null?void 0:Q.letterIdRequired)??!1,info:"The alphanumeric ID from a notice or letter received from the state, if applicable.",children:s.jsx("input",{placeholder:"Alphanumeric",maxLength:50,className:ne(),...Je,onChange:k=>{k.target.value=k.target.value.replace(/[^A-Za-z0-9]/g,"").slice(0,50),Je.onChange(k)}})})]}),s.jsxs("div",{className:bl,children:[s.jsx(J,{label:"Tax Year",required:!0,info:"The tax year this payment applies to.",error:(wt=L.taxYear)==null?void 0:wt.message,children:s.jsxs(_r,{children:[s.jsx(Ne,{name:"taxYear",control:S,render:({field:k})=>s.jsxs("select",{className:Kn(!!L.taxYear),...k,children:[s.jsx("option",{value:"",children:"Select TY"}),$e.map(_=>s.jsxs("option",{value:String(_),children:["TY ",_]},_))]})}),s.jsx(Zn,{})]})}),s.jsx(J,{label:(Q==null?void 0:Q.periodMode)==="account-assigned"?"Deposit Frequency":"Tax Period",required:!0,info:(Q==null?void 0:Q.periodMode)==="account-assigned"?"The deposit frequency assigned to your state tax account.":"The tax period this payment covers.",error:(f=L.taxPeriod)==null?void 0:f.message,children:s.jsxs(_r,{children:[s.jsx(Ne,{name:"taxPeriod",control:S,render:({field:k})=>s.jsxs("select",{className:Kn(!!L.taxPeriod),...k,children:[s.jsx("option",{value:"",children:"Select"}),ce.map(_=>s.jsx("option",{value:_.value,children:_.label},_.value))]})}),s.jsx(Zn,{})]})})]})]})}),s.jsx(va,{title:"Amount Info",children:s.jsxs("div",{className:bl,children:[s.jsx(J,{label:"Tax Amount",required:!0,info:"The total amount to remit to the state.",error:(N=L.taxAmount)==null?void 0:N.message,children:s.jsx(Ne,{name:"taxAmount",control:S,render:({field:k})=>s.jsx(Ir,{name:k.name,value:k.value,onChange:k.onChange,onBlur:k.onBlur,disabled:n,hasError:!!L.taxAmount})})}),s.jsx(J,{label:"Payment Date",required:!0,info:"The weekday the payment will be withdrawn and settled with the state.",error:(A=L.paymentDate)==null?void 0:A.message,children:s.jsx(Ne,{name:"paymentDate",control:S,render:({field:k})=>s.jsx(Lu,{value:k.value,onChange:k.onChange,hasError:!!L.paymentDate,disabled:n})})})]})}),s.jsx(va,{title:"Bank Account",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:ya,children:[s.jsx(Ne,{name:"bankAccountDetailId",control:S,render:({field:k})=>{var _;return s.jsx(Fu,{value:k.value,onChange:k.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:j,isLoading:x,disabled:!e||!pe||n,error:(_=L.bankAccountDetailId)==null?void 0:_.message,label:"Account Number",info:"Select the bank account to debit for this payment, or add a new one."})}}),s.jsx(J,{label:"Routing Number",required:!0,info:"The 9-digit bank routing number, auto-filled from the selected bank account.",children:s.jsx("input",{readOnly:!0,placeholder:"9-digit",className:ne(!1,!0),...b("routingNumber")})}),s.jsx(J,{label:"Account Type",required:!0,info:"The bank account type (checking or savings), auto-filled from the selected bank account.",children:s.jsx("input",{readOnly:!0,placeholder:"Select",className:ne(!1,!0),...b("accountType")})})]}),s.jsx("div",{className:ya,children:s.jsx(J,{label:"Bank Name",info:"The name of the bank, auto-filled from the selected bank account.",children:s.jsx("input",{readOnly:!0,placeholder:"e.g. Chase Bank",className:ne(!1,!0),...b("bankName")})})})]})}),Q!=null&&Q.notes.length?s.jsx("div",{className:"mt-5 rounded-lg bg-amber-50 px-4 py-3 text-xs text-amber-800",children:Q.notes.map(k=>s.jsx("p",{children:k},k))}):null]}),pe?null:s.jsx("p",{className:"mt-4 text-sm text-slate-500",children:we?"Loading payment requirements…":Ae?"Unable to load payment requirements.":"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:At,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:n?"Back":"Cancel"}),n?null:s.jsxs("button",{type:"submit",disabled:!e||!pe,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(Wv,{})]})]})]})})]})},i.key)}function wl({step:e,title:t,className:n=""}){return s.jsxs("div",{className:`flex items-center gap-3 ${n}`,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 va({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 Zv(){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 Wv(){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 Hu(){const{selectedEntity:e}=ht();return s.jsx(Yu,{entity:e})}function Ku(){var l;const{statePaymentId:e}=zs(),{selectedEntity:t}=ht(),n=Number.parseInt(e??"",10),{data:r,isLoading:a,isError:i}=ge({queryKey:["state-payments",n],queryFn:()=>Nu(n),enabled:t!==null&&Number.isFinite(n)}),o=v.useMemo(()=>r?{statePaymentDetailId:r.statePaymentDetailId,state:r.state,reasonForPayment:r.reasonForPayment??"",stateAccountId:r.stateAccountId??"",accountId:r.accountId??"",letterId:r.letterId??"",taxYear:r.taxYear??"",taxPeriod:r.taxPeriod??"",taxAmount:String(r.taxAmount),paymentDate:r.paymentDate,bankAccountDetailId:r.bankAccountDetailId?String(r.bankAccountDetailId):""}:null,[r]);return Number.isFinite(n)?a?s.jsx("p",{className:"px-6 py-12 text-sm text-slate-500",children:"Loading state payment…"}):i||!r||!o?s.jsx(Be,{to:Qe(),replace:!0}):!t||r.entityId!==t.entityId?s.jsx(Be,{to:Qe(),replace:!0}):((l=r.status)==null?void 0:l.toLowerCase())!=="draft"?s.jsx(Be,{to:`/payments/state/${n}/view`,replace:!0}):s.jsx(Yu,{entity:t,initialDraft:o}):s.jsx(Be,{to:Qe(),replace:!0})}function Qu(){var l,c;const{statePaymentId:e}=zs(),t=ke(),{selectedEntity:n}=ht(),r=Number.parseInt(e??"",10),{data:a,isLoading:i,isError:o}=ge({queryKey:["state-payments",r],queryFn:()=>Nu(r),enabled:n!==null&&Number.isFinite(r)});return Number.isFinite(r)?i?s.jsx("p",{className:"px-6 py-12 text-sm text-slate-500",children:"Loading state payment…"}):o||!a?s.jsx(Be,{to:"/payments",replace:!0}):!n||a.entityId!==n.entityId?s.jsx(Be,{to:"/payments",replace:!0}):s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>t("/payments"),className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm font-medium text-slate-600 transition hover:bg-slate-50",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.75 19.5L8.25 12l7.5-7.5"})}),"Back to Payments"]}),s.jsxs("h1",{className:"text-lg font-semibold text-slate-900",children:["State Payment ST-",a.statePaymentDetailId]})]}),s.jsx("div",{className:"w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",children:s.jsxs("dl",{className:"grid gap-x-8 gap-y-5 sm:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"State"}),s.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:a.state})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Tax Period"}),s.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:a.taxPeriod})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Amount"}),s.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:Kr(a.taxAmount)})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Payment Date"}),s.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:a.paymentDate})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Status"}),s.jsx("dd",{className:"mt-1",children:s.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold ${((l=a.status)==null?void 0:l.toLowerCase())==="paid"?"bg-green-100 text-green-800":((c=a.status)==null?void 0:c.toLowerCase())==="rejected"?"bg-red-100 text-red-800":"bg-slate-100 text-slate-700"}`,children:a.status??"—"})})]}),a.reason&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Rejection Reason"}),s.jsx("dd",{className:"mt-1 text-sm text-slate-700",children:a.reason})]})]})})]}):s.jsx(Be,{to:"/payments",replace:!0})}const Yv="By proceeding, you authorize the payment to the selected tax authority and acknowledge that you are responsible for the accuracy of the information provided.",Hv="I have reviewed the details and authorize this payment.",Ju=/^[a-zA-Z\s]+$/;function Gu(e){return e.replace(/[^a-zA-Z\s]/g,"")}const ro=F().min(1,"Signature is required").regex(Ju,"Signature must contain only letters").refine(e=>e.trim().length>0,{message:"Signature is required"}),Kv=F().optional().refine(e=>!e||!e.trim()||Ju.test(e),{message:"Signature must contain only letters"}),Qv=Xt({agreementDate:F().min(1,"Date is required"),agreementAccepted:Yn().refine(e=>e,{message:"You must accept the authorization agreement"}),authorizationPersonName:F().min(1,"Name of authorization person is required"),signature:ro,title:F().min(1,"Title is required")}),Jv="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",ds="rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 text-center";function Gv(e){const[t,n,r]=e.split("-");return!t||!n||!r?e:`${n}/${r}/${t}`}function Xv(){return{agreementDate:new Date().toISOString().slice(0,10),agreementAccepted:!1,authorizationPersonName:"",signature:"",title:""}}function ej({entity:e,paymentDraft:t}){const n=ke(),r=Se(),a=ft(),i=Bn(r.state,Qe()),[o,l]=v.useState(null),[c,d]=v.useState(!1),u=v.useMemo(()=>Xv(),[]),m=Gr(t.taxAmount),{register:h,handleSubmit:p,watch:y,formState:{errors:x}}=Rt({resolver:Lt(Qv),defaultValues:u}),j=y("agreementDate"),g=y("signature"),C=!!(g!=null&&g.trim()),b=h("signature"),S=async L=>{await a.invalidateQueries({queryKey:["dashboard"]}),await a.invalidateQueries({queryKey:["state-payments"]}),await a.invalidateQueries({queryKey:["remittance-payments"]}),L&&a.removeQueries({queryKey:["state-payments",L],exact:!0})},I=async()=>{if(!e)return null;if(t.statePaymentDetailId){const B=await I0(t.statePaymentDetailId,Bv(t));return await S(B.statePaymentDetailId),B}const L=await E0(qv(e.entityId,t));return ti({...t,statePaymentDetailId:L.statePaymentDetailId}),await S(L.statePaymentDetailId),L},R=async()=>{e&&(await I(),Wu(),n(Qe()))},E=p(async()=>{if(e){l(null),d(!0);try{await R()}catch(L){l(tt(L,"Failed to save state payment."))}finally{d(!1)}}}),T=p(async()=>{if(e){l(null),d(!0);try{await R()}catch(L){l(tt(L,"Failed to save draft."))}finally{d(!1)}}});return s.jsx("form",{onSubmit:E,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(Xr,{entity:e,remittanceAmount:m,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:Jv,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:`${ds} 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:Gv(j)}),s.jsx("input",{type:"hidden",...h("agreementDate")})]})]}),s.jsx("p",{className:"mt-5 text-sm leading-relaxed text-slate-600",children:Yv}),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",...h("agreementAccepted")}),s.jsx("span",{className:"text-sm font-semibold leading-6 text-slate-800",children:Hv})]}),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:`${ds} py-7`,children:[s.jsx("input",{placeholder:"Enter name",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...h("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:`${ds} 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 ${C?"min-h-[52px] 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,name:b.name,ref:b.ref,onBlur:b.onBlur,onChange:L=>{const B=Gu(L.target.value);L.target.value=B,b.onChange(L)}}),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:`${ds} py-7`,children:[s.jsx("input",{placeholder:"Enter title",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...h("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(Ot,{message:o})}):null,s.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[s.jsx("button",{type:"button",onClick:()=>{ti(t),n("/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:T,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 Xu(){const{selectedEntity:e}=ht(),t=Se(),{paymentDraft:n}=t.state??{},r=n??ni();return r?s.jsx(ej,{entity:e,paymentDraft:r}):s.jsx(Be,{to:"/payments/state/new",replace:!0})}const so="/portal/federal-payments/form-8655-authorizations";function tj(e){return de(so,{method:"POST",body:e})}function nj(e){return de(`${so}/by-enrolment/${e}`)}function rj(e,t){return de(`${so}/${e}`,{method:"PATCH",body:t})}async function ed(e){try{return await nj(e)}catch(t){if(t instanceof gr&&t.status===404)return null;throw t}}const ri=["720","940","941","943","944","945","990-PF","990-T","1041","1042","1120","CT-1","Other"];function sj(e){const t=e.trim();return ri.includes(t)?t:"Other"}const aj="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.",ij="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 oj(e){const[t,n,r]=e.split("-");return!t||!n||!r?e:`${n}/${r}/${t}`}function si({label:e,required:t=!1,signature:n,title:r,date:a,signatureValue:i,dateValue:o="",dateReadOnly:l=!0,errors:c,signatureCaption:d="Signature of taxpayer"}){const u=!!(i!=null&&i.trim()),{onChange:m,onBlur:h,name:p,ref:y}=n;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",{ref:y,name:p,placeholder:"Sign here",autoComplete:"off",spellCheck:!1,className:`w-full border-0 bg-transparent text-center focus:outline-none ${u?"text-4xl leading-tight tracking-wide text-slate-800":"text-sm text-slate-400 placeholder:text-slate-400"}`,style:u?{fontFamily:"'Great Vibes', 'Segoe Script', cursive"}:void 0,onBlur:h,onChange:x=>{const j=Gu(x.target.value);x.target.value=j,m(x)}}),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:d})]}),c!=null&&c.signature?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.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:"Enter title",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...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:"Title"})]}),c!=null&&c.title?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.title}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-8",children:[l?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-center text-sm text-slate-700",children:oj(o)}),s.jsx("input",{type:"hidden",...a})]}):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"})]}),c!=null&&c.date?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.date}):null]})]})]})}function lj(e){return e.replace(/\D/g,"")}function td(e,t){var n,r;return{enrollmentId:e,taxpayerName:t.taxpayerName.trim(),tradeName:t.tradeName.trim(),ein:lj(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:((n=t.otherIdentificationNumber)==null?void 0:n.trim())||null,contactPerson:t.contactPerson.trim(),daytimePhone:t.daytimePhone.trim(),faxNumber:t.faxNumber.trim(),authorizedTaxForm:t.authorizedTaxForm,authorizationStartMonth:((r=t.authorizationMonth)==null?void 0:r.trim())||null,agreementAccepted:t.agreementAccepted,taxpayerSignature:t.signature.trim()||null,taxpayerTitle:t.title.trim(),signatureDate:t.signatureDate}}function cj(e){const{enrollmentId:t,...n}=td(0,e);return n}function uj(e){return{taxpayerName:e.taxpayerName,tradeName:e.tradeName,ein:qn(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:$n(e.daytimePhone),faxNumber:e.faxNumber,authorizedTaxForm:e.authorizedTaxForm,authorizationMonth:e.authorizationStartMonth??"",agreementAccepted:e.agreementAccepted,signature:e.taxpayerSignature??"",title:e.taxpayerTitle,signatureDate:e.signatureDate}}const dj=Xt({taxpayerName:F().min(1,"Taxpayer name is required"),tradeName:F().optional(),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:Yn(),otherIdentificationNumber:F().optional(),contactPerson:F().optional(),daytimePhone:F().min(1,"Daytime telephone number is required"),faxNumber:F().default(""),authorizedTaxForm:F().min(1,"Select a tax form"),authorizationMonth:F().optional(),agreementAccepted:Yn().refine(e=>e,{message:"You must accept the authorization agreement"}),signature:ro,title:F().min(1,"Title is required"),signatureDate:F().min(1,"Date is required")}),ja="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function mj(e,t){const n=new Date().toISOString().slice(0,10);return{taxpayerName:e?en(e):"",tradeName:(e==null?void 0:e.tradeName)??"",ein:e?qn(e.idNumber):"",address:[e==null?void 0:e.address1,e==null?void 0:e.address2].filter(Boolean).join(", "),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:"",daytimePhone:e?$n(e.phoneNumber):"",faxNumber:"",authorizedTaxForm:sj(t.taxFormType),authorizationMonth:"",agreementAccepted:!1,signature:"",title:"",signatureDate:n}}function hj({entity:e,paymentDraft:t,initialAuthorization:n=null,readonly:r=!1}){var ie,G,Q,we,Ae,$e,ce,pe,$,fe,O,ue,Te,Je;const a=ke(),i=Se(),o=ft(),l=Bn(i.state,Qe()),c=Gr(t.paymentAmount),[d,u]=v.useState(null),[m,h]=v.useState(!1),p=v.useMemo(()=>n?uj(n):mj(e,t),[e,n,t]),{register:y,handleSubmit:x,watch:j,setValue:g,reset:C,formState:{errors:b}}=Rt({resolver:Lt(dj),defaultValues:p});v.useEffect(()=>{C(p)},[p,C]);const S=j("authorizedTaxForm"),I=j("signature"),R=j("signatureDate"),E=e?en(e):"Entity",T=!0,L=!0,B=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},K=async()=>{if(!e)return null;if(t.federalPaymentId){const ve=await Yi(t.federalPaymentId,Gi(t));return await B(),ve}const oe=await Wi(Ji(e.entityId,t));return eo({...t,federalPaymentId:oe.federalPaymentId,enrollmentId:oe.enrollmentId}),await B(),oe},X=async(oe,ve)=>{var re;const Oe=t.form8655AuthorizationId??((re=await ed(oe))==null?void 0:re.form8655AuthorizationId),We=ve;return Oe?rj(Oe,cj(We)):tj(td(oe,We))},Y=async oe=>{if(!e)return;const ve=await K();ve&&(await X(ve.enrollmentId,oe),await o.invalidateQueries({queryKey:["form-8655",ve.enrollmentId]}),to(),a(Qe()))},V=x(async oe=>{if(!(!e||r)){u(null),h(!0);try{await Y(oe)}catch(ve){u(tt(ve,"Failed to save federal payment draft."))}finally{h(!1)}}}),Z=x(async oe=>{if(!(!e||r)){u(null),h(!0);try{await Y(oe)}catch(ve){u(tt(ve,"Failed to save draft."))}finally{h(!1)}}});return s.jsxs("form",{onSubmit:V,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:E}),s.jsx(Xr,{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:r,className:"min-w-0 border-0 p-0",children:[s.jsxs("section",{children:[s.jsxs("div",{className:ja,children:[s.jsx(J,{label:"1. a) Name of the Taxpayer",required:!0,error:(ie=b.taxpayerName)==null?void 0:ie.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:T,className:ne(!!b.taxpayerName,T),...y("taxpayerName")})}),s.jsx(J,{label:"1. b) Trade Name, if any",error:(G=b.tradeName)==null?void 0:G.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:T,className:ne(!!b.tradeName,T),...y("tradeName")})}),s.jsx(J,{label:"2. Employer Identification Number (EIN)",required:!0,error:(Q=b.ein)==null?void 0:Q.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:T,className:ne(!!b.ein,T),...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(J,{label:"3. a) Address (Number, Street, and Room/Suite No)",required:!0,error:(we=b.address)==null?void 0:we.message,children:s.jsx("input",{placeholder:"Enter",readOnly:T,className:ne(!!b.address,T),...y("address")})})}),s.jsx(J,{label:"3. b) City or Town",required:!0,error:(Ae=b.city)==null?void 0:Ae.message,children:s.jsx("input",{placeholder:"Enter",readOnly:T,className:ne(!!b.city,T),...y("city")})})]}),s.jsxs("div",{className:`mt-5 ${ja}`,children:[s.jsx(J,{label:"3. c) State",required:!0,error:($e=b.state)==null?void 0:$e.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:T,className:ne(!!b.state,T),...y("state")})}),s.jsx(J,{label:"3. d) ZIP Code",required:!0,error:(ce=b.zipCode)==null?void 0:ce.message,children:s.jsx("input",{placeholder:"Enter",readOnly:T,className:ne(!!b.zipCode,T),...y("zipCode")})}),s.jsx(J,{label:"3. e) Country",required:!0,error:(pe=b.country)==null?void 0:pe.message,children:s.jsx("input",{placeholder:"Enter",readOnly:T,className:ne(!!b.country,T),...y("country")})})]}),s.jsxs("div",{className:`mt-5 ${ja}`,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(J,{label:"5. Other Identification Number (Optional)",children:s.jsx("input",{placeholder:"Enter name",readOnly:T,className:ne(!1,T),...y("otherIdentificationNumber")})}),s.jsx(J,{label:"6. Contact Person",error:($=b.contactPerson)==null?void 0:$.message,children:s.jsx("input",{placeholder:"Enter name",className:ne(!!b.contactPerson),...y("contactPerson")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2",children:[s.jsx(J,{label:"7. Daytime Telephone Number",required:!0,error:(fe=b.daytimePhone)==null?void 0:fe.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:T,className:ne(!!b.daytimePhone,T),...y("daytimePhone")})}),s.jsx(J,{label:"8. Fax Number",error:(O=b.faxNumber)==null?void 0:O.message,children:s.jsx("input",{placeholder:"Enter number",className:ne(!!b.faxNumber),...y("faxNumber")})})]})]}),s.jsxs(wn,{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:ri.slice(0,6).map(oe=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:oe,checked:S===oe,disabled:L,onChange:()=>g("authorizedTaxForm",oe,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),oe]},oe))}),s.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:ri.slice(6).map(oe=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:oe,checked:S===oe,disabled:L,onChange:()=>g("authorizedTaxForm",oe,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),oe]},oe))})]}),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:aj})," ",ij]})]}),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(si,{label:"Taxpayer's Signature",required:!0,signature:y("signature"),title:y("title"),date:y("signatureDate"),signatureValue:I,dateValue:R,errors:{signature:(ue=b.signature)==null?void 0:ue.message,title:(Te=b.title)==null?void 0:Te.message,date:(Je=b.signatureDate)==null?void 0:Je.message}})})]})})]}),d?s.jsx("div",{className:"lg:mr-[324px]",children:s.jsx(Ot,{message:d})}):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:m,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:m||!e||r,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:m||!e||r,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 nd(){const{selectedEntity:e}=ht(),t=Se(),{paymentDraft:n}=t.state??{},r=n??ra(),{data:a,isLoading:i}=ge({queryKey:["federal-payment",r==null?void 0:r.federalPaymentId],queryFn:()=>Zi(r.federalPaymentId),enabled:(r==null?void 0:r.federalPaymentId)!=null&&r.enrollmentId==null}),o=(r==null?void 0:r.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=ge({queryKey:["form-8655",o],queryFn:()=>ed(o),enabled:o!=null}),d=v.useMemo(()=>r?{...r,enrollmentId:o??r.enrollmentId,form8655AuthorizationId:r.form8655AuthorizationId??(l==null?void 0:l.form8655AuthorizationId)}:null,[r,o,l]);return r?Qi(e)?s.jsx(Be,{to:"/payments/federal/individual-enrollment",replace:!0,state:t.state}):r.federalPaymentId!=null&&r.enrollmentId==null&&i||o!=null&&c?s.jsx("p",{className:"text-sm text-slate-600",children:"Loading authorization form…"}):s.jsx(hj,{entity:e,paymentDraft:d??r,initialAuthorization:l}):s.jsx(Be,{to:"/payments/federal/new",replace:!0})}const ao="/portal/federal-payments/form-9783-enrollments";function fj(e){return de(ao,{method:"POST",body:e})}function pj(e){return de(`${ao}/by-enrolment/${e}`)}function xj(e,t){return de(`${ao}/${e}`,{method:"PATCH",body:t})}async function rd(e){try{return await pj(e)}catch(t){if(t instanceof gr&&t.status===404)return null;throw t}}const gj="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.",yj="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.",bj="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.",wa=new Date().getFullYear(),vj=[String(wa-1),String(wa-2),String(wa-3)];function ms(e){return e.replace(/\D/g,"")}function sd(e,t){var n,r,a,i;return{enrollmentId:e,primarySsn:ms(t.primarySsn),jointFilerSsn:t.jointFilerSsn?ms(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:((n=t.internationalAddress)==null?void 0:n.trim())||null,primaryPhone:t.primaryPhone.trim(),primaryContactName:t.primaryContactName.trim(),primaryContactAddress:t.primaryContactAddress.trim(),contactCity:t.contactCity.trim(),contactState:t.contactState.trim(),contactZipCode:t.contactZipCode.trim(),contactCountry:t.contactCountry.trim(),contactPhone:t.contactPhone.trim(),contactInternationalAddress:((r=t.contactInternationalAddress)==null?void 0:r.trim())||null,primaryTaxpayerPin:t.primaryTaxpayerPin.trim()||null,dateOfBirth:t.dateOfBirth||null,priorYearAgi:t.priorYearAgi.trim()?Number(t.priorYearAgi):null,agiTaxYear:t.agiTaxYear.trim()||null,financialPrimarySsn:ms(t.financialPrimarySsn),routingTransitNumber:ms(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:((a=t.jointFilerSignature)==null?void 0:a.trim())||null,jointFilerTitle:((i=t.jointFilerTitle)==null?void 0:i.trim())||null,jointFilerSignatureDate:t.jointFilerSignatureDate||null}}function jj(e){const{enrollmentId:t,...n}=sd(0,e);return n}function wj(e){var n;const t=((n=e.accountType)==null?void 0:n.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:$n(e.primaryPhone),primaryContactName:e.primaryContactName,primaryContactAddress:e.primaryContactAddress,contactCity:e.contactCity,contactState:e.contactState,contactZipCode:e.contactZipCode,contactCountry:e.contactCountry,contactPhone:$n(e.contactPhone),contactInternationalAddress:e.contactInternationalAddress??"",primaryTaxpayerPin:e.primaryTaxpayerPin??"",dateOfBirth:e.dateOfBirth??"",priorYearAgi:e.priorYearAgi!==null&&e.priorYearAgi!==void 0?String(e.priorYearAgi):"",agiTaxYear:e.agiTaxYear??"",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 Nj=Xt({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"),contactState:F().min(1,"Contact state is required"),contactZipCode:F().min(1,"Contact ZIP code is required"),contactCountry:F().min(1,"Contact country is required"),contactPhone:F().min(1,"Contact phone number is required"),contactInternationalAddress:F().optional(),primaryTaxpayerPin:F().min(1,"Primary taxpayer PIN is required").regex(/^\d{5}$/,"Primary taxpayer PIN must be exactly 5 digits"),dateOfBirth:F().min(1,"Date of birth is required").refine(e=>Q0(e,ad),{message:"You must be at least 18 years old"}),priorYearAgi:F().min(1,"Prior year adjusted gross income is required").refine(e=>!Number.isNaN(Number(e))&&Number(e)>=0,{message:"Enter a valid amount"}),agiTaxYear:F().min(1,"Prior tax year 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:du([da("Checking"),da("Savings"),da("")]).refine(e=>e==="Checking"||e==="Savings",{message:"Account type is required"}),disclosureAgreementOne:Yn().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),disclosureAgreementTwo:Yn().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),authorityAgreement:Yn().refine(e=>e,{message:"You must accept the authority agreement"}),taxpayerSignature:ro,taxpayerTitle:F().min(1,"Title is required"),taxpayerSignatureDate:F().min(1,"Date is required"),jointFilerSignature:Kv,jointFilerTitle:F().optional(),jointFilerSignatureDate:F().optional()}),bn="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",Sj="grid gap-x-6 gap-y-5 sm:grid-cols-2 lg:grid-cols-4",kj=5,ad=18;function id(e){return e?e.toLowerCase()==="savings"?"Savings":"Checking":""}function od(e,t){return{financialPrimarySsn:(e==null?void 0:e.idNumber)??"",routingTransitNumber:t.routingNumber??"",accountNumber:t.accountNumber??"",accountType:id(t.accountType)}}function Cj(e,t){const n=new Date().toISOString().slice(0,10),r=e?en(e):"";return{primarySsn:(e==null?void 0:e.idNumber)??"",jointFilerSsn:"",taxpayerNames:r,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)??"US",internationalAddress:"",primaryPhone:e?$n(e.phoneNumber):"",primaryContactName:"",primaryContactAddress:"",contactCity:"",contactState:"",contactZipCode:"",contactCountry:"",contactPhone:"",contactInternationalAddress:"",...od(e,t),primaryTaxpayerPin:"",dateOfBirth:"",priorYearAgi:"",agiTaxYear:"",disclosureAgreementOne:!1,disclosureAgreementTwo:!1,authorityAgreement:!1,taxpayerSignature:"",taxpayerTitle:"",taxpayerSignatureDate:n,jointFilerSignature:"",jointFilerTitle:"",jointFilerSignatureDate:n}}function Aj({entity:e,paymentDraft:t,initialEnrollment:n=null,readonly:r=!1}){var We,re,nt,rt,bt,pt,vt,zt,jt,Mt,At,Pt,Et,It,qt,Bt,wt,f,N,A,k,_,W,z,H;const a=ke(),i=Se(),o=ft(),l=Bn(i.state,Qe()),c=Gr(t.paymentAmount),[d,u]=v.useState(null),[m,h]=v.useState(!1),[p,y]=v.useState(!1),{data:x=[]}=ge({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Jr({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:(e==null?void 0:e.entityId)!=null}),j=v.useMemo(()=>{if(n)return wj(n);const M=x.find(Me=>String(Me.bankAccountDetailId)===t.bankAccountDetailId),ae=od(e,t);return{...Cj(e,t),financialPrimarySsn:ae.financialPrimarySsn,routingTransitNumber:ae.routingTransitNumber||(M==null?void 0:M.routingNumber)||"",accountNumber:ae.accountNumber||(M==null?void 0:M.accountNumber)||"",accountType:id(t.accountType||(M==null?void 0:M.accountType))}},[e,n,t,x]),{register:g,handleSubmit:C,watch:b,setValue:S,reset:I,control:R,formState:{errors:E}}=Rt({resolver:Lt(Nj),defaultValues:j});v.useEffect(()=>{I(j)},[j,I]);const T=b("taxpayerSignature"),L=b("jointFilerSignature"),B=b("taxpayerSignatureDate"),K=b("jointFilerSignatureDate"),X=b("accountType"),Y=b("taxpayerNames"),V=b("primaryAddress"),Z=b("city"),ie=b("state"),G=b("zipCode"),Q=b("country"),we=b("primaryPhone"),Ae=b("internationalAddress"),$e=e?en(e):"Entity",ce=!0,pe=!0,$=v.useMemo(()=>K0(ad),[]),fe=()=>{S("primaryContactName",Y,{shouldValidate:!0}),S("primaryContactAddress",V,{shouldValidate:!0}),S("contactCity",Z,{shouldValidate:!0}),S("contactState",ie,{shouldValidate:!0}),S("contactZipCode",G,{shouldValidate:!0}),S("contactCountry",Q,{shouldValidate:!0}),S("contactPhone",we,{shouldValidate:!0}),S("contactInternationalAddress",Ae??"",{shouldValidate:!0})},O=()=>{S("primaryContactName","",{shouldValidate:!0}),S("primaryContactAddress","",{shouldValidate:!0}),S("contactCity","",{shouldValidate:!0}),S("contactState","",{shouldValidate:!0}),S("contactZipCode","",{shouldValidate:!0}),S("contactCountry","",{shouldValidate:!0}),S("contactPhone","",{shouldValidate:!0}),S("contactInternationalAddress","",{shouldValidate:!0})};v.useEffect(()=>{p&&fe()},[p,Y,V,Z,ie,G,Q,we,Ae]);const ue=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},Te=async()=>{if(!e)return null;if(t.federalPaymentId){const ae=await Yi(t.federalPaymentId,Gi(t));return await ue(),ae}const M=await Wi(Ji(e.entityId,t));return eo({...t,federalPaymentId:M.federalPaymentId,enrollmentId:M.enrollmentId}),await ue(),M},Je=async(M,ae)=>{var Vt;const Me=t.form9783EnrollmentId??((Vt=await rd(M))==null?void 0:Vt.form9783EnrollmentId);return Me?xj(Me,jj(ae)):fj(sd(M,ae))},oe=async M=>{if(!e)return;const ae=await Te();ae&&(await Je(ae.enrollmentId,M),await o.invalidateQueries({queryKey:["form-9783",ae.enrollmentId]}),to(),a(Qe()))},ve=C(async M=>{if(!(!e||r)){u(null),h(!0);try{await oe(M)}catch(ae){u(tt(ae,"Failed to save federal payment draft."))}finally{h(!1)}}}),Oe=C(async M=>{if(!(!e||r)){u(null),h(!0);try{await oe(M)}catch(ae){u(tt(ae,"Failed to save draft."))}finally{h(!1)}}});return s.jsxs("form",{onSubmit:ve,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:$e}),s.jsx(Xr,{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:r,className:"min-w-0 border-0 p-0",children:[s.jsxs(wn,{title:"1. Taxpayer Information",isFirst:!0,children:[s.jsxs("div",{className:bn,children:[s.jsx(J,{label:"1. a) Primary Social Security Number (SSN)",required:!0,error:(We=E.primarySsn)==null?void 0:We.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:ce,className:ne(!!E.primarySsn,ce),...g("primarySsn")})}),s.jsx(J,{label:"1. b) Joint filer's taxpayer ID No (SSN)",children:s.jsx("input",{placeholder:"Other Identification number (optional)",readOnly:ce,className:ne(!1,ce),...g("jointFilerSsn")})}),s.jsx(J,{label:"2. Taxpayer(S) name(S)",required:!0,error:(re=E.taxpayerNames)==null?void 0:re.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:ce,className:ne(!!E.taxpayerNames,ce),...g("taxpayerNames")})})]}),s.jsxs("div",{className:`mt-5 ${bn}`,children:[s.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:s.jsx(J,{label:"3. a) Primary taxpayer address",required:!0,error:(nt=E.primaryAddress)==null?void 0:nt.message,children:s.jsx("input",{placeholder:"Enter",readOnly:ce,className:ne(!!E.primaryAddress,ce),...g("primaryAddress")})})}),s.jsx(J,{label:"3. b) City or Town",required:!0,error:(rt=E.city)==null?void 0:rt.message,children:s.jsx("input",{placeholder:"Enter",readOnly:ce,className:ne(!!E.city,ce),...g("city")})})]}),s.jsxs("div",{className:`mt-5 ${bn}`,children:[s.jsx(J,{label:"3. c) State",required:!0,error:(bt=E.state)==null?void 0:bt.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:ce,className:ne(!!E.state,ce),...g("state")})}),s.jsx(J,{label:"3. d) ZIP code",required:!0,error:(pt=E.zipCode)==null?void 0:pt.message,children:s.jsx("input",{placeholder:"Enter",readOnly:ce,className:ne(!!E.zipCode,ce),...g("zipCode")})}),s.jsx(J,{label:"3. e) Country",required:!0,error:(vt=E.country)==null?void 0:vt.message,children:s.jsx("input",{placeholder:"Enter",readOnly:ce,className:ne(!!E.country,ce),...g("country")})})]}),s.jsxs("div",{className:`mt-5 ${bn}`,children:[s.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:s.jsx(J,{label:"3. f) International address",children:s.jsx("input",{placeholder:"phone number (International number)",readOnly:ce,className:ne(!1,ce),...g("internationalAddress")})})}),s.jsx(J,{label:"4. Primary taxpayer phone number",required:!0,error:(zt=E.primaryPhone)==null?void 0:zt.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:ce,className:ne(!!E.primaryPhone,ce),...g("primaryPhone")})})]})]}),s.jsxs(wn,{title:"2. Contact Information",headerAction:s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"checkbox",checked:p,disabled:r,onChange:M=>{const ae=M.target.checked;y(ae),ae?fe():O()},className:"h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200"}),"Same as Taxpayer Information"]}),children:[s.jsxs("div",{className:bn,children:[s.jsx(J,{label:"5. Primary contact name",required:!0,error:(jt=E.primaryContactName)==null?void 0:jt.message,children:s.jsx("input",{placeholder:"Payer Name",readOnly:p,className:ne(!!E.primaryContactName,p),...g("primaryContactName")})}),s.jsx(J,{label:"6. a) Primary contact address",required:!0,error:(Mt=E.primaryContactAddress)==null?void 0:Mt.message,children:s.jsx("input",{placeholder:"Payer Address",readOnly:p,className:ne(!!E.primaryContactAddress,p),...g("primaryContactAddress")})}),s.jsx(J,{label:"6. b) City or Town",required:!0,error:(At=E.contactCity)==null?void 0:At.message,children:s.jsx("input",{placeholder:"City",readOnly:p,className:ne(!!E.contactCity,p),...g("contactCity")})})]}),s.jsxs("div",{className:`mt-5 ${bn}`,children:[s.jsx(J,{label:"6. c) State",required:!0,error:(Pt=E.contactState)==null?void 0:Pt.message,children:s.jsx("input",{placeholder:"Payer State",readOnly:p,className:ne(!!E.contactState,p),...g("contactState")})}),s.jsx(J,{label:"6. d) ZIP code",required:!0,error:(Et=E.contactZipCode)==null?void 0:Et.message,children:s.jsx("input",{placeholder:"ZIP code",readOnly:p,className:ne(!!E.contactZipCode,p),...g("contactZipCode")})}),s.jsx(J,{label:"6. f) Country",required:!0,error:(It=E.contactCountry)==null?void 0:It.message,children:s.jsx("input",{placeholder:"Country",readOnly:p,className:ne(!!E.contactCountry,p),...g("contactCountry")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-3",children:[s.jsx(J,{label:"7. Primary taxpayer phone number",required:!0,error:(qt=E.contactPhone)==null?void 0:qt.message,children:s.jsx("input",{placeholder:"Payer Phone",readOnly:p,className:ne(!!E.contactPhone,p),...g("contactPhone")})}),s.jsx("div",{className:"sm:col-span-2",children:s.jsx(J,{label:"8. International address",children:s.jsx("input",{placeholder:"Phone Number (International number)",readOnly:p,className:ne(!1,p),...g("contactInternationalAddress")})})})]})]}),s.jsx(wn,{title:"Taxpayer Details *",children:s.jsxs("div",{className:Sj,children:[s.jsx(J,{label:"1. Primary Taxpayer Pin",required:!0,error:(Bt=E.primaryTaxpayerPin)==null?void 0:Bt.message,children:s.jsx(Ne,{name:"primaryTaxpayerPin",control:R,render:({field:M})=>s.jsx("input",{placeholder:"Primary Taxpayer Pin",inputMode:"numeric",className:ne(!!E.primaryTaxpayerPin),value:M.value,onChange:ae=>M.onChange(Hn(ae.target.value,kj)),onBlur:M.onBlur})})}),s.jsx(J,{label:"2. Date of Birth",required:!0,error:(wt=E.dateOfBirth)==null?void 0:wt.message,children:s.jsx("input",{type:"date",max:$,className:ne(!!E.dateOfBirth),...g("dateOfBirth")})}),s.jsx(J,{label:"3. Prior year adjusted gross income",required:!0,error:(f=E.priorYearAgi)==null?void 0:f.message,children:s.jsx("input",{placeholder:"Prior Year Adjusted Gross Income",inputMode:"decimal",className:ne(!!E.priorYearAgi),...g("priorYearAgi")})}),s.jsx(J,{label:"4. Prior Tax Year",required:!0,error:(N=E.agiTaxYear)==null?void 0:N.message,children:s.jsxs("select",{className:Kn(!!E.agiTaxYear),...g("agiTaxYear"),children:[s.jsx("option",{value:"",disabled:!0,children:"AGI Tax Year"}),vj.map(M=>s.jsx("option",{value:M,children:M},M))]})})]})}),s.jsxs(wn,{title:"3. Social Security Number and Financial Institution Information",children:[s.jsxs("div",{className:bn,children:[s.jsx(J,{label:"9. Primary SSN",required:!0,error:(A=E.financialPrimarySsn)==null?void 0:A.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:pe,className:ne(!!E.financialPrimarySsn,pe),...g("financialPrimarySsn")})}),s.jsx(J,{label:"10. Routing Transit Number (RTN)",required:!0,error:(k=E.routingTransitNumber)==null?void 0:k.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:pe,className:ne(!!E.routingTransitNumber,pe),...g("routingTransitNumber")})}),s.jsx(J,{label:"11. Account Number",required:!0,error:(_=E.accountNumber)==null?void 0:_.message,children:s.jsx("input",{placeholder:"Enter",readOnly:pe,className:ne(!!E.accountNumber,pe),...g("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(M=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:M,checked:X===M,disabled:pe,onChange:()=>S("accountType",M,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),M]},M))}),E.accountType?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:E.accountType.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.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",...g("disclosureAgreementOne")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:gj})]}),E.disclosureAgreementOne?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:E.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",...g("disclosureAgreementTwo")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:yj})]}),E.disclosureAgreementTwo?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:E.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",...g("authorityAgreement")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:bj})]}),E.authorityAgreement?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:E.authorityAgreement.message}):null]})]})]}),s.jsxs("section",{className:"mt-8 space-y-8 border-t border-slate-100 pt-8",children:[s.jsx(si,{label:"Taxpayer's Signature",required:!0,signature:g("taxpayerSignature"),title:g("taxpayerTitle"),date:g("taxpayerSignatureDate"),signatureValue:T,dateValue:B,errors:{signature:(W=E.taxpayerSignature)==null?void 0:W.message,title:(z=E.taxpayerTitle)==null?void 0:z.message,date:(H=E.taxpayerSignatureDate)==null?void 0:H.message}}),s.jsx(si,{label:"Joint filer(s) Signature (Optional)",signature:g("jointFilerSignature"),title:g("jointFilerTitle"),date:g("jointFilerSignatureDate"),signatureValue:L??"",dateValue:K??"",signatureCaption:"Signature of joint filer"})]})]})})]}),d?s.jsx("div",{className:"lg:mr-[324px]",children:s.jsx(Ot,{message:d})}):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:m,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:Oe,disabled:m||!e||r,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:m||!e||r,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 ld(){const{selectedEntity:e}=ht(),t=Se(),{paymentDraft:n}=t.state??{},r=n??ra(),{data:a,isLoading:i}=ge({queryKey:["federal-payment",r==null?void 0:r.federalPaymentId],queryFn:()=>Zi(r.federalPaymentId),enabled:(r==null?void 0:r.federalPaymentId)!=null&&r.enrollmentId==null}),o=(r==null?void 0:r.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=ge({queryKey:["form-9783",o],queryFn:()=>rd(o),enabled:o!=null}),d=v.useMemo(()=>r?{...r,enrollmentId:o??r.enrollmentId,form9783EnrollmentId:r.form9783EnrollmentId??(l==null?void 0:l.form9783EnrollmentId)}:null,[r,o,l]);return r?e&&!Qi(e)?s.jsx(Be,{to:"/payments/federal/authorization",replace:!0,state:t.state}):r.federalPaymentId!=null&&r.enrollmentId==null&&i||o!=null&&c?s.jsx("p",{className:"text-sm text-slate-600",children:"Loading enrollment form…"}):s.jsx(Aj,{entity:e,paymentDraft:d??r,initialEnrollment:l}):s.jsx(Be,{to:"/payments/federal/new",replace:!0})}function Pj(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function Ej({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 Ij({status:e}){const t=e.toLowerCase();let n="bg-slate-100 text-slate-600";return t.includes("submitted to state")||t.includes("submitted to fed")?n="bg-orange-50 text-orange-700":t.includes("irs accepted")?n="bg-emerald-50 text-emerald-700":t.includes("irs rejected")?n="bg-red-50 text-red-600":t.includes("pending")&&(n="bg-amber-50 text-amber-700"),s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${n}`,children:e})}function Tj({forms:e=[],isLoading:t=!1,isError:n=!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…"})}):n?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(r=>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(_j,{className:"h-4 w-4"})}),r.fileName]})}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(Ej,{type:r.type})}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:r.client}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(Ij,{status:r.status})}),s.jsx("td",{className:"px-6 py-4 text-slate-600",children:Pj(r.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"}),r.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]})})]},r.taxFormId))})]})})})}function _j({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 Fj(){return s.jsx(Tj,{})}const Nl=160,Dj=88,hs=8;function Rj({account:e,entityId:t,onEdit:n}){const r=ft(),{showSuccess:a,showError:i}=Vs(),o=v.useRef(null),l=v.useRef(null),[c,d]=v.useState(!1),[u,m]=v.useState(!1),[h,p]=v.useState({}),y=()=>{var I;const j=o.current;if(!j)return;const g=j.getBoundingClientRect(),C=((I=l.current)==null?void 0:I.offsetHeight)??Dj,S=window.innerHeight-g.bottom<C+hs;p({position:"fixed",top:S?g.top-C-hs:g.bottom+hs,left:Math.max(hs,g.right-Nl),width:Nl,zIndex:50})};v.useLayoutEffect(()=>{c&&(y(),requestAnimationFrame(y))},[c]),v.useEffect(()=>{if(!c)return;const j=C=>{var S,I;const b=C.target;(S=o.current)!=null&&S.contains(b)||(I=l.current)!=null&&I.contains(b)||d(!1)},g=()=>y();return document.addEventListener("mousedown",j),window.addEventListener("resize",g),window.addEventListener("scroll",g,!0),()=>{document.removeEventListener("mousedown",j),window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0)}},[c]);const x=async()=>{const j=vr(e);m(!0);try{await ku(e.bankAccountDetailId,{status:Cv(e)}),await r.invalidateQueries({queryKey:["bank-accounts",t]}),d(!1),j?a("Bank Account Deactivated","Bank account deactivated successfully."):a("Bank Account Activated","Bank account activated successfully.")}catch(g){i("Action Not Completed",tt(g,"Cannot deactivate this bank account because it is linked to a payment that has not been accepted yet."))}finally{m(!1)}};return s.jsxs("div",{className:"inline-block text-left",children:[s.jsxs("button",{ref:o,type:"button",disabled:u,onClick:()=>d(j=>!j),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 disabled:cursor-not-allowed disabled:opacity-60",children:["Actions",s.jsx($j,{})]}),c?Br.createPortal(s.jsxs("div",{ref:l,style:h,className:"overflow-hidden rounded-lg border border-slate-200 bg-white py-1 shadow-lg",children:[s.jsx("button",{type:"button",onClick:()=>{d(!1),n(e)},className:"block w-full px-4 py-2 text-left text-sm text-slate-700 hover:bg-slate-50",children:"Edit"}),s.jsx("button",{type:"button",disabled:u,onClick:()=>void x(),className:"block w-full px-4 py-2 text-left text-sm text-slate-700 hover:bg-slate-50 disabled:opacity-60",children:Av(e)})]}),document.body):null]})}function $j(){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"})})}const cd=["Checking","Savings"],Lj=Xt({accountNumber:F().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${dr} digits`),routingNumber:F().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Xs(cd,{message:"Account type is required"}),bankName:F().min(1,"Bank name is required")});function Oj({open:e,account:t,onClose:n}){const r=ft(),{showSuccess:a,showError:i}=Vs(),[o,l]=v.useState(null),[c,d]=v.useState(!1),{control:u,handleSubmit:m,reset:h,formState:{errors:p}}=Rt({resolver:Lt(Lj),defaultValues:{accountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}});v.useEffect(()=>{!e||!t||(h({accountNumber:t.accountNumber,routingNumber:t.routingNumber,accountType:t.accountType==="Savings"?"Savings":"Checking",bankName:t.bankName}),l(null))},[t,e,h]),v.useEffect(()=>{if(!e)return;const x=j=>{j.key==="Escape"&&n()};return document.addEventListener("keydown",x),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",x),document.body.style.overflow=""}},[e,n]);const y=m(async x=>{if(t){l(null),d(!0);try{await ku(t.bankAccountDetailId,{bankName:x.bankName.trim(),accountNumber:x.accountNumber,routingNumber:x.routingNumber,accountType:x.accountType}),await r.invalidateQueries({queryKey:["bank-accounts",t.entityId]}),a("Bank Account Updated","Bank account updated successfully."),n()}catch(j){const g=tt(j,"Unable to update bank account.");l(g),i("Action Not Completed",g)}finally{d(!1)}}});return!e||!t?null:Br.createPortal(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:n}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"edit-bank-account-title",className:"relative z-10 flex max-h-[90vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl bg-white shadow-xl",children:[s.jsxs("div",{className:"border-b border-slate-200 px-6 py-5",children:[s.jsx("h2",{id:"edit-bank-account-title",className:"text-lg font-bold text-slate-900",children:"Edit Bank Account"}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Update bank account details."})]}),s.jsxs("form",{noValidate:!0,onSubmit:x=>{x.preventDefault(),y(x)},className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"overflow-y-auto px-6 py-6",children:[o?s.jsx("div",{className:"mb-5",children:s.jsx(Ot,{message:o})}):null,s.jsxs(au,{title:"Bank Account",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsx(Ne,{name:"accountNumber",control:u,render:({field:x})=>{var j;return s.jsx(he,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:x.value,onChange:g=>x.onChange(Hn(g.target.value,dr)),onBlur:x.onBlur,error:(j=p.accountNumber)==null?void 0:j.message})}}),s.jsx(Ne,{name:"routingNumber",control:u,render:({field:x})=>{var j;return s.jsx(he,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:x.value,onChange:g=>x.onChange(Hn(g.target.value,Cu)),onBlur:x.onBlur,error:(j=p.routingNumber)==null?void 0:j.message})}}),s.jsx(Ne,{name:"accountType",control:u,render:({field:x})=>{var j;return s.jsx(xn,{label:"Account Type",required:!0,value:x.value,onChange:x.onChange,onBlur:x.onBlur,error:(j=p.accountType)==null?void 0:j.message,children:cd.map(g=>s.jsx("option",{value:g,children:g},g))})}})]}),s.jsx(Ne,{name:"bankName",control:u,render:({field:x})=>{var j;return s.jsx(he,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:x.value,onChange:x.onChange,onBlur:x.onBlur,error:(j=p.bankName)==null?void 0:j.message})}})]})]}),s.jsxs("div",{className:"flex items-center justify-end gap-3 border-t border-slate-200 px-6 py-4",children:[s.jsx("button",{type:"button",onClick:n,disabled:c,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:c,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:c?"Saving…":"Save Changes"})]})]})]})]}),document.body)}const Ln=[{id:"bank-accounts",title:"Bank Accounts",subtitle:"Connected bank accounts",icon:zj},{id:"tax-accounts",title:"Tax Accounts",subtitle:"IRS & state tax accounts",icon:Mj},{id:"payment-history",title:"Payment History",subtitle:"Past payment transactions",icon:qj},{id:"entity-details",title:"Entity Details",subtitle:"Your account details",icon:Bj}];function zj({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 Mj({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 qj({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 Bj({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 mr({title:e,subtitle:t,icon:n,action:r}){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(n,{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})]})]}),r]})}function Vj(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function Uj({status:e}){const t=vr({status:e});return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${t?"bg-emerald-50 text-emerald-700":"bg-red-50 text-red-600"}`,children:t?"Active":"In-active"})}function Zj({entityId:e}){const[t,n]=v.useState(!1),[r,a]=v.useState(null),[i,o]=v.useState(1),[l,c]=v.useState(it),d=Ln.find(C=>C.id==="bank-accounts"),u=d.icon;v.useEffect(()=>{o(1)},[e,l]);const{data:m,isLoading:h,isError:p,isFetching:y}=ge({queryKey:["bank-accounts",e,i,l],queryFn:()=>Jr({entityId:e,pageNumber:i,pageSize:l}),enabled:e!==null,placeholderData:C=>C}),x=(m==null?void 0:m.items)??[],j=(m==null?void 0:m.totalCount)??0,g=e!==null&&y;return s.jsxs("div",{children:[s.jsx(mr,{title:d.title,subtitle:d.subtitle,icon:u,action:s.jsxs("button",{type:"button",disabled:!e,onClick:()=>n(!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(Wj,{}),"Add Bank Account"]})}),s.jsx(Pu,{open:t,entityId:e,onClose:()=>n(!1)}),s.jsx(Oj,{open:r!==null,account:r,onClose:()=>a(null)}),s.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-slate-200",children:[g?s.jsx(br,{label:"Loading bank accounts…"}):null,s.jsx("div",{className:"overflow-x-auto",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:h&&!m?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading bank accounts…"})}):p?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?x.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."})}):x.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:Vj(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(Uj,{status:C.status})}),s.jsx("td",{className:"px-5 py-4 text-right",children:s.jsx(Rj,{account:C,entityId:e,onEdit:a})})]},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."})})})]})}),e!==null?s.jsx(Qr,{page:i,pageSize:l,totalCount:j,onPageChange:o,onPageSizeChange:c,disabled:h||y}):null]})]})}function Wj(){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 Yj({icon:e}){const t="h-5 w-5 text-gov-600";return e==="phone"?s.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 6.75c0 8.284 6.716 15 15 15h2.25a2.25 2.25 0 002.25-2.25v-1.372c0-.516-.351-.966-.852-1.091l-4.423-1.106c-.44-.11-.902.055-1.173.417l-.97 1.293c-.282.376-.769.542-1.21.38a12.035 12.035 0 01-7.143-7.143c-.162-.441.004-.928.38-1.21l1.293-.97c.363-.271.527-.734.417-1.173L6.963 3.102a1.125 1.125 0 00-1.091-.852H4.5A2.25 2.25 0 002.25 4.5v2.25z"})}):e==="account"?s.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",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"})}):s.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})})}function Ar({label:e,value:t,icon:n}){return s.jsx("div",{className:"rounded-xl border border-slate-200 bg-[#F9FAFB] px-4 py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-gov-50",children:s.jsx(Yj,{icon:n})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-xs text-slate-500",children:e}),s.jsx("p",{className:"mt-1 break-words text-sm font-semibold text-slate-900",children:t||"—"})]})]})})}function Hj(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"—"}function Kj({entity:e}){const[t,n]=v.useState(!1),r=Ln.find(c=>c.id==="entity-details"),a=r.icon;if(!e)return s.jsxs("div",{children:[s.jsx(mr,{title:r.title,subtitle:r.subtitle,icon:a}),s.jsx("div",{className:"rounded-xl border border-dashed border-slate-200 bg-slate-50/50 px-6 py-16 text-center",children:s.jsx("p",{className:"text-sm text-slate-500",children:"Select an entity to view its details."})})]});const i=en(e),o=e.accountType==="Business"?i:`${e.firstName} ${e.lastName}`.trim()||i,l=Oi(o);return s.jsxs("div",{children:[s.jsx(mr,{title:r.title,subtitle:r.subtitle,icon:a,action:s.jsx("button",{type:"button",onClick:()=>n(!0),className:"inline-flex items-center rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:"Edit"})}),s.jsxs("div",{className:"mb-8 flex items-center gap-4 border-b border-slate-100 pb-8",children:[s.jsx("span",{className:"flex h-16 w-16 shrink-0 items-center justify-center rounded-full bg-gov-600 text-xl font-semibold text-white",children:l}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-xl font-bold text-slate-900",children:o}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:e.email})]})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx(Ar,{label:"Entity Name",value:i,icon:"entity"}),s.jsx(Ar,{label:"Tax ID",value:qn(e.idNumber),icon:"tax"}),s.jsx(Ar,{label:"Email Address",value:e.email,icon:"email"}),s.jsx(Ar,{label:"Phone Number",value:$n(e.phoneNumber),icon:"phone"}),s.jsx(Ar,{label:"Account Type",value:Hj(e.accountType),icon:"account"})]}),s.jsx(wu,{open:t,entity:e,onClose:()=>n(!1)})]})}function ud({activeSection:e,onSectionChange:t,items:n}){return s.jsx("nav",{className:"space-y-2",children:n.map(r=>{const a=e===r.id,i=r.icon;return s.jsxs("button",{type:"button",onClick:()=>t(r.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:r.title}),s.jsx("span",{className:"block truncate text-xs text-slate-500",children:r.subtitle})]}),s.jsx(Qj,{className:`h-4 w-4 shrink-0 ${a?"text-gov-600":"text-slate-300"}`})]},r.id)})})}function Qj({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 Jj({entityId:e}){const t=Ln.find(r=>r.id==="payment-history"),n=t.icon;return s.jsxs("div",{children:[s.jsx(mr,{title:t.title,subtitle:t.subtitle,icon:n,action:s.jsxs("button",{type:"button",disabled:!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(Gj,{}),"Export to Excel"]})}),s.jsx("div",{className:"relative overflow-hidden rounded-xl border border-slate-200",children:s.jsx("div",{className:"overflow-x-auto",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:e?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."})}):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 Gj(){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 Xj({entityId:e,pageNumber:t=1,pageSize:n=it}){const r=new URLSearchParams({entityId:String(e),pageNumber:String(t),pageSize:String(n)});return de(`/portal/tax-accounts?${r}`)}function e1(e){return de(`/portal/tax-accounts/${e}`)}function t1(e){return de("/portal/tax-accounts",{method:"POST",body:e})}function n1(e,t){return de(`/portal/tax-accounts/${e}`,{method:"PATCH",body:t})}function r1({entityId:e}){const t=ke(),n=Ln.find(p=>p.id==="tax-accounts"),r=n.icon,[a,i]=v.useState(1),[o,l]=v.useState(it);v.useEffect(()=>{i(1)},[e,o]);const{data:c,isLoading:d,isError:u}=ge({queryKey:["tax-accounts",e,a,o],queryFn:()=>Xj({entityId:e,pageNumber:a,pageSize:o}),enabled:e!==null}),m=(c==null?void 0:c.items)??[],h=(c==null?void 0:c.totalCount)??0;return s.jsxs("div",{children:[s.jsx(mr,{title:n.title,subtitle:n.subtitle,icon:r,action:s.jsxs("button",{type:"button",disabled:!e,onClick:()=>t("/settings/tax-accounts/new"),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(s1,{}),"Add Tax Account"]})}),s.jsxs("div",{className:"overflow-hidden rounded-xl border border-slate-200",children:[s.jsx("div",{className:"overflow-x-auto",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:"Actions"})]})}),s.jsx("tbody",{children:e===null?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."})}):d?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Loading tax accounts…"})}):u?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."})}):h===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."})}):m.map(p=>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:p.state}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:p.taxAccountDetailId}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:p.status}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:p.state}),s.jsx("td",{className:"px-5 py-4",children:s.jsx("button",{type:"button",onClick:()=>t(`/settings/tax-accounts/${p.taxAccountDetailId}/edit`),className:"rounded-md px-2.5 py-1.5 text-sm font-medium text-gov-600 transition hover:bg-gov-50 hover:text-gov-700",children:"Edit"})})]},p.taxAccountDetailId))})]})}),e!==null?s.jsx(Qr,{page:a,pageSize:o,totalCount:h,onPageChange:i,onPageSizeChange:l,disabled:d}):null]})]})}function s1(){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 Sl="rounded-2xl border border-slate-200 bg-white shadow-sm";function a1(e){return e==="bank-accounts"||e==="tax-accounts"||e==="payment-history"||e==="entity-details"}function io(){const{selectedEntity:e}=ht(),n=Se().state,[r,a]=v.useState(a1(n==null?void 0:n.section)?n.section:"bank-accounts");return s.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[s.jsx("div",{className:`${Sl} p-3`,children:s.jsx(ud,{items:Ln,activeSection:r,onSectionChange:a})}),s.jsx("div",{className:`${Sl} p-6 lg:p-8`,children:r==="bank-accounts"?s.jsx(Zj,{entityId:(e==null?void 0:e.entityId)??null}):r==="tax-accounts"?s.jsx(r1,{entityId:(e==null?void 0:e.entityId)??null}):r==="payment-history"?s.jsx(Jj,{entityId:(e==null?void 0:e.entityId)??null}):s.jsx(Kj,{entity:e})})]})}function i1({label:e,value:t,onChange:n,options:r,required:a=!1,disabled:i=!1,error:o,placeholder:l="Select a state"}){var C;const[c,d]=v.useState(!1),[u,m]=v.useState(""),h=v.useRef(null),p=v.useRef(null),y=v.useId(),x=(C=r.find(b=>b.code===t))==null?void 0:C.name,j=v.useMemo(()=>{const b=u.trim().toLowerCase();return b?r.filter(S=>S.name.toLowerCase().includes(b)||S.code.toLowerCase().includes(b)):r},[u,r]);v.useEffect(()=>{var b;c&&((b=p.current)==null||b.focus())},[c]),v.useEffect(()=>{if(!c)return;const b=S=>{var I;(I=h.current)!=null&&I.contains(S.target)||d(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[c]);const g=b=>{n(b),m(""),d(!1)};return s.jsxs("div",{ref:h,className:"relative",children:[s.jsx(Hr,{label:e,required:a,htmlFor:y}),s.jsxs("button",{id:y,type:"button",disabled:i,onClick:()=>{m(""),d(b=>!b)},className:`flex w-full items-center justify-between rounded-lg border bg-white px-3 py-2.5 text-left text-sm transition focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:cursor-not-allowed disabled:opacity-60 ${o?"border-red-300":"border-slate-200 focus:border-gov-400"}`,children:[s.jsx("span",{className:x?"text-slate-900":"text-slate-400",children:x??l}),s.jsx(o1,{open:c})]}),c?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:"border-b border-slate-100 p-2",children:s.jsx("input",{ref:p,type:"search",value:u,onChange:b=>m(b.target.value),onKeyDown:b=>{b.key==="Escape"?d(!1):b.key==="Enter"&&b.preventDefault()},placeholder:"Search by state name or code","aria-label":"Search states",className:"w-full rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-900 outline-none transition placeholder:text-slate-400 focus:border-gov-400 focus:bg-white focus:ring-2 focus:ring-gov-100"})}),s.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[j.map(b=>s.jsxs("button",{type:"button",onClick:()=>g(b.code),className:`flex w-full items-center justify-between px-4 py-3 text-left text-sm transition hover:bg-slate-50 ${t===b.code?"bg-gov-50 text-gov-700":"text-slate-700"}`,children:[s.jsx("span",{children:b.name}),s.jsx("span",{className:"text-xs font-medium text-slate-400",children:b.code})]},b.code)),j.length===0?s.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No states found."}):null]})]}):null,o?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:o}):null]})}function o1({open:e}){return s.jsx("svg",{className:`h-4 w-4 shrink-0 text-slate-400 transition ${e?"rotate-180":""}`,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 kl({title:e,subtitle:t,children:n,className:r=""}){return s.jsxs("section",{className:`rounded-xl border border-slate-200 bg-white ${r}`,children:[s.jsxs("div",{className:"border-b border-slate-100 px-5 py-4",children:[s.jsx("h3",{className:"text-sm font-semibold text-slate-900",children:e}),t?s.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:t}):null]}),s.jsx("div",{className:"space-y-5 p-5",children:n})]})}const l1=[{title:"Business Registration",fields:[{name:"virginiaTaxAccountId",label:"Virginia Tax Account ID",required:!0,placeholder:"e.g. 30123456789"},{name:"businessLocationCode",label:"Business Location Code",required:!0,placeholder:"e.g. 001"},{name:"virginiaDepartmentOfTaxationClientNumber",label:"Virginia Department of Taxation Client Number",required:!0,placeholder:"e.g. 12345678"}]},{title:"Payroll / Withholding",fields:[{name:"virginiaWithholdingAccountingId",label:"Virginia Withholding Accounting ID",required:!0,placeholder:"e.g. 30123456789-WTH"},{name:"unemploymentTaxAccountId",label:"Unemployment Tax Account ID",required:!0,placeholder:"e.g. 1234567"}]},{title:"Sales and Franchise Tax",fields:[{name:"franchiseTaxAccount",label:"Franchise Tax Account",required:!0,placeholder:"e.g. 30123456789-FRN"},{name:"transientOccupancyTaxAccountId",label:"Transient Occupancy Tax Account ID",required:!1,placeholder:"e.g. 30123456789-TOT"}]},{title:"Other Registrations",fields:[{name:"certificateOfAuthorityNumber",label:"Certificate of Authority Number (Foreign Entities)",required:!1,placeholder:"e.g. F123456789"},{name:"licensedProfessionalEmployerEntityNumber",label:"Licensed Professional Employer (POE) Entity Number",required:!1,placeholder:"e.g. POE-00123"}]}],c1={VA:l1},u1="United States",d1=Xt({state:F().min(1,"State is required"),city:F().min(1,"City is required"),zipCode:F().min(1,"ZIP code is required"),address1:F().min(1,"Address Line 1 is required"),address2:F().optional(),virginiaTaxAccountId:F().optional(),virginiaWithholdingAccountingId:F().optional(),unemploymentTaxAccountId:F().optional(),virginiaDepartmentOfTaxationClientNumber:F().optional(),businessLocationCode:F().optional(),franchiseTaxAccount:F().optional(),transientOccupancyTaxAccountId:F().optional(),certificateOfAuthorityNumber:F().optional(),licensedProfessionalEmployerEntityNumber:F().optional()}),m1=d1.superRefine((e,t)=>{if(xu.test(e.zipCode.trim())||t.addIssue({code:Qt.custom,message:"Enter a 5-digit ZIP or ZIP+4 (e.g. 12345 or 12345-6789)",path:["zipCode"]}),e.state!=="VA")return;const n=[{key:"virginiaTaxAccountId",label:"Virginia Tax Account ID"},{key:"virginiaWithholdingAccountingId",label:"Virginia Withholding Accounting ID"},{key:"unemploymentTaxAccountId",label:"Unemployment Tax Account ID"},{key:"virginiaDepartmentOfTaxationClientNumber",label:"Virginia Department of Taxation Client Number"},{key:"businessLocationCode",label:"Business Location Code"},{key:"franchiseTaxAccount",label:"Franchise Tax Account"}];for(const r of n){const a=e[r.key];(typeof a!="string"||!a.trim())&&t.addIssue({code:Qt.custom,message:`${r.label} is required`,path:[r.key]})}}),h1={state:"VA",city:"",zipCode:"",address1:"",address2:"",virginiaTaxAccountId:"",virginiaWithholdingAccountingId:"",unemploymentTaxAccountId:"",virginiaDepartmentOfTaxationClientNumber:"",businessLocationCode:"",franchiseTaxAccount:"",transientOccupancyTaxAccountId:"",certificateOfAuthorityNumber:"",licensedProfessionalEmployerEntityNumber:""};function f1(e){const t=e.virginia;return{state:e.state,city:e.city,zipCode:e.zipCode,address1:e.address1,address2:e.address2??"",virginiaTaxAccountId:(t==null?void 0:t.virginiaTaxAccountId)??"",virginiaWithholdingAccountingId:(t==null?void 0:t.virginiaWithholdingAccountingId)??"",unemploymentTaxAccountId:(t==null?void 0:t.unemploymentTaxAccountId)??"",virginiaDepartmentOfTaxationClientNumber:(t==null?void 0:t.virginiaDepartmentOfTaxationClientNumber)??"",businessLocationCode:(t==null?void 0:t.businessLocationCode)??"",franchiseTaxAccount:(t==null?void 0:t.franchiseTaxAccount)??"",transientOccupancyTaxAccountId:(t==null?void 0:t.transientOccupancyTaxAccountId)??"",certificateOfAuthorityNumber:(t==null?void 0:t.certificateOfAuthorityNumber)??"",licensedProfessionalEmployerEntityNumber:(t==null?void 0:t.licensedProfessionalEmployerEntityNumber)??""}}const ys=e=>{const t=e==null?void 0:e.trim();return t||null};function p1(e){var t,n,r,a,i,o;if(e.state==="VA")return{virginiaTaxAccountId:((t=e.virginiaTaxAccountId)==null?void 0:t.trim())??"",virginiaWithholdingAccountingId:((n=e.virginiaWithholdingAccountingId)==null?void 0:n.trim())??"",unemploymentTaxAccountId:((r=e.unemploymentTaxAccountId)==null?void 0:r.trim())??"",virginiaDepartmentOfTaxationClientNumber:((a=e.virginiaDepartmentOfTaxationClientNumber)==null?void 0:a.trim())??"",businessLocationCode:((i=e.businessLocationCode)==null?void 0:i.trim())??"",franchiseTaxAccount:((o=e.franchiseTaxAccount)==null?void 0:o.trim())??"",transientOccupancyTaxAccountId:ys(e.transientOccupancyTaxAccountId),certificateOfAuthorityNumber:ys(e.certificateOfAuthorityNumber),licensedProfessionalEmployerEntityNumber:ys(e.licensedProfessionalEmployerEntityNumber)}}function x1({entityId:e,taxAccountDetailId:t,initialValues:n,onCancel:r,onSuccess:a}){var L,B,K,X,Y,V;const{showSuccess:i}=Vs(),o=ft(),l=t!=null,[c,d]=v.useState(null),[u,m]=v.useState(!1),{register:h,handleSubmit:p,watch:y,setValue:x,formState:{errors:j}}=Rt({resolver:Lt(m1),defaultValues:n??h1}),g=h("zipCode"),C=y("state"),b=y("zipCode"),S=Mi(u1),I=c1[C],R=((L=S.find(Z=>Z.code===C))==null?void 0:L.name)??C,E=C.length>0&&b.trim().length>0&&!ur(S,C,b),T=p(async Z=>{if(d(null),!ur(S,Z.state,Z.zipCode)){d(`ZIP code does not match the selected state (${Z.state}).`);return}m(!0);try{const ie={state:Z.state,city:Z.city.trim(),zipCode:Z.zipCode.trim(),address1:Z.address1.trim(),address2:ys(Z.address2),virginia:p1(Z)};if(l)await n1(t,ie);else{const G={entityId:e,...ie};await t1(G)}await o.invalidateQueries({queryKey:["tax-accounts",e]}),i(l?"Tax Account Updated":"Tax Account Added",l?"Tax account details were updated successfully.":"Tax account was created successfully."),a==null||a()}catch(ie){d(tt(ie,"Unable to save tax account. Please try again."))}finally{m(!1)}});return s.jsxs("form",{onSubmit:T,noValidate:!0,className:"max-w-4xl space-y-6",children:[c?s.jsx(Ot,{message:c}):null,s.jsxs("div",{children:[s.jsx("p",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Tax jurisdiction"}),s.jsx("div",{className:"max-w-xs",children:s.jsx(i1,{label:"State",required:!0,value:C,onChange:Z=>x("state",Z,{shouldValidate:!0}),options:S.map(Z=>({code:Z.code,name:Z.name})),error:(B=j.state)==null?void 0:B.message})})]}),s.jsxs(kl,{title:"Common Information",subtitle:"Applies to every state this entity is registered in.",children:[s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:"City",required:!0,placeholder:"e.g. Richmond",error:(K=j.city)==null?void 0:K.message,...h("city")}),s.jsx(he,{label:"Zip Code",required:!0,maxLength:10,placeholder:"12345 or 12345-6789",error:((X=j.zipCode)==null?void 0:X.message)??(E?`ZIP code does not match the selected state (${C}).`:void 0),...g,onChange:Z=>{Z.target.value=zi(Z.target.value),g.onChange(Z)}})]}),s.jsx(he,{label:"Address Line 1",required:!0,placeholder:"e.g. 123 Main Street",error:(Y=j.address1)==null?void 0:Y.message,...h("address1")}),s.jsx(he,{label:"Address Line 2",placeholder:"Suite, unit, etc. (optional)",error:(V=j.address2)==null?void 0:V.message,...h("address2")})]}),I?s.jsx(kl,{title:`${R} Tax Registration`,children:I.map((Z,ie)=>s.jsxs("div",{className:ie>0?"border-t border-slate-100 pt-5":"",children:[s.jsx("h4",{className:"mb-3 text-xs font-semibold uppercase tracking-wide text-gov-700",children:Z.title}),s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:Z.fields.map(G=>{var Q;return s.jsx(he,{label:G.label,required:G.required,placeholder:G.placeholder??"Enter",error:(Q=j[G.name])==null?void 0:Q.message,...h(G.name)},G.name)})})]},Z.title))}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-t border-slate-200 pt-6",children:[s.jsx("button",{type:"button",onClick:r,disabled:u,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:opacity-60",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:u,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:opacity-60",children:u?"Saving…":"Save"})]})]})}const Na="rounded-2xl border border-slate-200 bg-white shadow-sm";function hr(){const e=ke(),{selectedEntity:t}=ht(),n=zs(),r=n.taxAccountDetailId?Number(n.taxAccountDetailId):void 0,a=r!=null,i=Ln.find(m=>m.id==="tax-accounts"),o=i.icon,l=(m="tax-accounts")=>{e("/settings",{state:{section:m}})},{data:c,isLoading:d,isError:u}=ge({queryKey:["tax-account",r],queryFn:()=>e1(r),enabled:a});return t?s.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[s.jsx("div",{className:`${Na} p-3`,children:s.jsx(ud,{items:Ln,activeSection:"tax-accounts",onSectionChange:l})}),s.jsxs("div",{className:`${Na} p-6 lg:p-8`,children:[s.jsx(mr,{title:a?"Edit Tax Account":i.title,subtitle:i.subtitle,icon:o}),a&&d?s.jsx("p",{className:"text-sm text-slate-500",children:"Loading tax account…"}):a&&(u||!c)?s.jsx(Ot,{message:"Unable to load this tax account. Please try again."}):s.jsx(x1,{entityId:t.entityId,taxAccountDetailId:r,initialValues:c?f1(c):void 0,onCancel:()=>l("tax-accounts"),onSuccess:()=>l("tax-accounts")})]})]}):s.jsx("div",{className:Na+" p-6 lg:p-8",children:s.jsx("p",{className:"text-sm text-slate-500",children:"Select an entity to add a tax account."})})}function g1({paymentsMode:e="all"}){return s.jsxs(di,{children:[s.jsx(te,{index:!0,element:s.jsx(ji,{})}),s.jsx(te,{path:"create-entity",element:s.jsx(Ni,{})}),s.jsx(te,{path:"create-entity/form",element:s.jsx(qi,{})}),s.jsxs(te,{element:s.jsx(wi,{}),children:[s.jsx(te,{path:"entities",element:s.jsx(Ui,{})}),s.jsx(te,{path:"dashboard",element:s.jsx(Vi,{})}),s.jsx(te,{path:"payments",element:s.jsx(Hi,{paymentsMode:e})}),s.jsx(te,{path:"payments/federal/new",element:s.jsx(qu,{})}),s.jsx(te,{path:"payments/federal/:federalPaymentId/edit",element:s.jsx(Vu,{})}),s.jsx(te,{path:"payments/federal/:federalPaymentId/view",element:s.jsx(Uu,{})}),s.jsx(te,{path:"payments/state/new",element:s.jsx(Hu,{})}),s.jsx(te,{path:"payments/state/:statePaymentId/edit",element:s.jsx(Ku,{})}),s.jsx(te,{path:"payments/state/:statePaymentId/view",element:s.jsx(Qu,{})}),s.jsx(te,{path:"payments/state/authorization",element:s.jsx(Xu,{})}),s.jsx(te,{path:"payments/federal/authorization",element:s.jsx(nd,{})}),s.jsx(te,{path:"payments/federal/individual-enrollment",element:s.jsx(ld,{})}),s.jsx(te,{path:"tax-forms",element:s.jsx(Fj,{})}),s.jsx(te,{path:"settings",element:s.jsx(io,{})}),s.jsx(te,{path:"settings/tax-accounts/new",element:s.jsx(hr,{})}),s.jsx(te,{path:"settings/tax-accounts/:taxAccountDetailId/edit",element:s.jsx(hr,{})})]}),s.jsx(te,{path:"*",element:s.jsx(Be,{to:"/",replace:!0})})]})}const ai="tax-remittance:payment-complete",y1=v.forwardRef(function(t,n){const r=v.useRef(null),a=v.useRef(null);return v.useImperativeHandle(n,()=>({navigate:i=>{var o;return(o=r.current)==null?void 0:o.call(r,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)},notifyPaymentComplete:i=>{window.dispatchEvent(new CustomEvent(ai,{detail:{paymentId:i}}))}})),s.jsx(vi,{...t,navigateFnRef:r,selectEntityFnRef:a,onPaymentRequired:t.onPaymentRequired,children:s.jsx(g1,{paymentsMode:"all"})})}),b1=v.forwardRef(function(t,n){const r=v.useRef(null),a=v.useRef(null);return v.useImperativeHandle(n,()=>({navigate:i=>{var o;return(o=r.current)==null?void 0:o.call(r,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)},notifyPaymentComplete:i=>{window.dispatchEvent(new CustomEvent("tax-remittance:payment-complete",{detail:{paymentId:i}}))}})),s.jsx(vi,{...t,navigateFnRef:r,selectEntityFnRef:a,enabledPayments:["federal"],children:s.jsxs(di,{children:[s.jsx(te,{index:!0,element:s.jsx(ji,{})}),s.jsx(te,{path:"create-entity",element:s.jsx(Ni,{})}),s.jsx(te,{path:"create-entity/form",element:s.jsx(qi,{})}),s.jsxs(te,{element:s.jsx(wi,{}),children:[s.jsx(te,{path:"entities",element:s.jsx(Ui,{})}),s.jsx(te,{path:"dashboard",element:s.jsx(Vi,{})}),s.jsx(te,{path:"payments",element:s.jsx(Hi,{paymentsMode:"federal"})}),s.jsx(te,{path:"payments/federal/new",element:s.jsx(qu,{})}),s.jsx(te,{path:"payments/federal/:federalPaymentId/edit",element:s.jsx(Vu,{})}),s.jsx(te,{path:"payments/federal/:federalPaymentId/view",element:s.jsx(Uu,{})}),s.jsx(te,{path:"payments/federal/authorization",element:s.jsx(nd,{})}),s.jsx(te,{path:"payments/federal/individual-enrollment",element:s.jsx(ld,{})}),s.jsx(te,{path:"settings",element:s.jsx(io,{})}),s.jsx(te,{path:"settings/tax-accounts/new",element:s.jsx(hr,{})}),s.jsx(te,{path:"settings/tax-accounts/:taxAccountDetailId/edit",element:s.jsx(hr,{})})]}),s.jsx(te,{path:"*",element:s.jsx(Be,{to:"/",replace:!0})})]})})}),v1=v.forwardRef(function(t,n){const r=v.useRef(null),a=v.useRef(null);return v.useImperativeHandle(n,()=>({navigate:i=>{var o;return(o=r.current)==null?void 0:o.call(r,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)},notifyPaymentComplete:i=>{window.dispatchEvent(new CustomEvent("tax-remittance:payment-complete",{detail:{paymentId:i}}))}})),s.jsx(vi,{...t,navigateFnRef:r,selectEntityFnRef:a,enabledPayments:["state"],children:s.jsxs(di,{children:[s.jsx(te,{index:!0,element:s.jsx(ji,{})}),s.jsx(te,{path:"create-entity",element:s.jsx(Ni,{})}),s.jsx(te,{path:"create-entity/form",element:s.jsx(qi,{})}),s.jsxs(te,{element:s.jsx(wi,{}),children:[s.jsx(te,{path:"entities",element:s.jsx(Ui,{})}),s.jsx(te,{path:"dashboard",element:s.jsx(Vi,{})}),s.jsx(te,{path:"payments",element:s.jsx(Hi,{paymentsMode:"state"})}),s.jsx(te,{path:"payments/state/new",element:s.jsx(Hu,{})}),s.jsx(te,{path:"payments/state/:statePaymentId/edit",element:s.jsx(Ku,{})}),s.jsx(te,{path:"payments/state/:statePaymentId/view",element:s.jsx(Qu,{})}),s.jsx(te,{path:"payments/state/authorization",element:s.jsx(Xu,{})}),s.jsx(te,{path:"settings",element:s.jsx(io,{})}),s.jsx(te,{path:"settings/tax-accounts/new",element:s.jsx(hr,{})}),s.jsx(te,{path:"settings/tax-accounts/:taxAccountDetailId/edit",element:s.jsx(hr,{})})]}),s.jsx(te,{path:"*",element:s.jsx(Be,{to:"/",replace:!0})})]})})});exports.ApiError=gr;exports.FederalPaymentWidget=b1;exports.StatePaymentWidget=v1;exports.TaxRemittanceEmbedded=y1;exports.setRuntimeApiBaseUrl=gc;
75
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const u of e.seen.entries()){const m=u[1];if(t===u[0]){i(u);continue}if(e.external){const p=(c=e.external.registry.get(u[0]))==null?void 0:c.id;if(t!==u[0]&&p){i(u);continue}}if((d=e.metadataRegistry.get(u[0]))==null?void 0:d.id){i(u);continue}if(m.cycle){i(u);continue}if(m.count>1&&e.reused==="ref"){i(u);continue}}}function au(e,t){var l,c,d,u;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=m=>{const h=e.seen.get(m);if(h.ref===null)return;const p=h.def??h.schema,g={...p},x=h.ref;if(h.ref=null,x){r(x);const y=e.seen.get(x),C=y.schema;if(C.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(C)):Object.assign(p,C),Object.assign(p,g),m._zod.parent===x)for(const S in p)S==="$ref"||S==="allOf"||S in g||delete p[S];if(C.$ref&&y.def)for(const S in p)S==="$ref"||S==="allOf"||S in y.def&&JSON.stringify(p[S])===JSON.stringify(y.def[S])&&delete p[S]}const b=m._zod.parent;if(b&&b!==x){r(b);const y=e.seen.get(b);if(y!=null&&y.schema.$ref&&(p.$ref=y.schema.$ref,y.def))for(const C in p)C==="$ref"||C==="allOf"||C in y.def&&JSON.stringify(p[C])===JSON.stringify(y.def[C])&&delete p[C]}e.override({zodSchema:m,jsonSchema:p,path:h.path??[]})};for(const m of[...e.seen.entries()].reverse())r(m[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 m=(c=e.external.registry.get(t))==null?void 0:c.id;if(!m)throw new Error("Schema is missing an `id` property");a.$id=e.external.uri(m)}Object.assign(a,n.def??n.schema);const i=(d=e.metadataRegistry.get(t))==null?void 0:d.id;i!==void 0&&a.id===i&&delete a.id;const o=((u=e.external)==null?void 0:u.defs)??{};for(const m of e.seen.entries()){const h=m[1];h.def&&h.defId&&(h.def.id===h.defId&&delete h.def.id,o[h.defId]=h.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?a.$defs=o:a.definitions=o);try{const m=JSON.parse(JSON.stringify(a));return Object.defineProperty(m,"~standard",{value:{...t["~standard"],jsonSchema:{input:Is(t,"input",e.processors),output:Is(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function Xe(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Xe(r.element,n);if(r.type==="set")return Xe(r.valueType,n);if(r.type==="lazy")return Xe(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Xe(r.innerType,n);if(r.type==="intersection")return Xe(r.left,n)||Xe(r.right,n);if(r.type==="record"||r.type==="map")return Xe(r.keyType,n)||Xe(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Xe(r.in,n)||Xe(r.out,n);if(r.type==="object"){for(const a in r.shape)if(Xe(r.shape[a],n))return!0;return!1}if(r.type==="union"){for(const a of r.options)if(Xe(a,n))return!0;return!1}if(r.type==="tuple"){for(const a of r.items)if(Xe(a,n))return!0;return!!(r.rest&&Xe(r.rest,n))}return!1}const Eg=(e,t={})=>n=>{const r=ru({...n,processors:t});return We(e,r),su(r,e),au(r,e)},Is=(e,t,n={})=>r=>{const{libraryOptions:a,target:i}=r??{},o=ru({...a??{},target:i,io:t,processors:n});return We(e,o),su(o,e),au(o,e)},Ig={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Tg=(e,t,n,r)=>{const a=n;a.type="string";const{minimum:i,maximum:o,format:l,patterns:c,contentEncoding:d}=e._zod.bag;if(typeof i=="number"&&(a.minLength=i),typeof o=="number"&&(a.maxLength=o),l&&(a.format=Ig[l]??l,a.format===""&&delete a.format,l==="time"&&delete a.format),d&&(a.contentEncoding=d),c&&c.size>0){const u=[...c];u.length===1?a.pattern=u[0].source:u.length>1&&(a.allOf=[...u.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},_g=(e,t,n,r)=>{n.type="boolean"},Dg=(e,t,n,r)=>{n.not={}},Fg=(e,t,n,r)=>{},Rg=(e,t,n,r)=>{const a=e._zod.def,i=Bc(a.entries);i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.enum=i},$g=(e,t,n,r)=>{const a=e._zod.def,i=[];for(const o of a.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){const o=i[0];n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[o]:n.const=o}else i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),i.every(o=>typeof o=="boolean")&&(n.type="boolean"),i.every(o=>o===null)&&(n.type="null"),n.enum=i},Lg=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Og=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},zg=(e,t,n,r)=>{const a=n,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=We(i.element,t,{...r,path:[...r.path,"items"]})},Mg=(e,t,n,r)=>{var d;const a=n,i=e._zod.def;a.type="object",a.properties={};const o=i.shape;for(const u in o)a.properties[u]=We(o[u],t,{...r,path:[...r.path,"properties",u]});const l=new Set(Object.keys(o)),c=new Set([...l].filter(u=>{const m=i.shape[u]._zod;return t.io==="input"?m.optin===void 0:m.optout===void 0}));c.size>0&&(a.required=Array.from(c)),((d=i.catchall)==null?void 0:d._zod.def.type)==="never"?a.additionalProperties=!1:i.catchall?i.catchall&&(a.additionalProperties=We(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(a.additionalProperties=!1)},qg=(e,t,n,r)=>{const a=e._zod.def,i=a.inclusive===!1,o=a.options.map((l,c)=>We(l,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=o:n.anyOf=o},Bg=(e,t,n,r)=>{const a=e._zod.def,i=We(a.left,t,{...r,path:[...r.path,"allOf",0]}),o=We(a.right,t,{...r,path:[...r.path,"allOf",1]}),l=d=>"allOf"in d&&Object.keys(d).length===1,c=[...l(i)?i.allOf:[i],...l(o)?o.allOf:[o]];n.allOf=c},Vg=(e,t,n,r)=>{const a=e._zod.def,i=We(a.innerType,t,r),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=a.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},Ug=(e,t,n,r)=>{const a=e._zod.def;We(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType},Zg=(e,t,n,r)=>{const a=e._zod.def;We(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType,n.default=JSON.parse(JSON.stringify(a.defaultValue))},Wg=(e,t,n,r)=>{const a=e._zod.def;We(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(a.defaultValue)))},Yg=(e,t,n,r)=>{const a=e._zod.def;We(a.innerType,t,r);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")}n.default=o},Hg=(e,t,n,r)=>{const a=e._zod.def,i=a.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?i?a.out:a.in:a.out;We(o,t,r);const l=t.seen.get(e);l.ref=o},Kg=(e,t,n,r)=>{const a=e._zod.def;We(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType,n.readOnly=!0},iu=(e,t,n,r)=>{const a=e._zod.def;We(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType};function Ja(){return Ja=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ja.apply(null,arguments)}function rl(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function Qg(e,t){for(var n={};e.length;){var r=e[0],a=r.code,i=r.message,o=r.path.join(".");if(!n[o])if("unionErrors"in r){var l=r.unionErrors[0].errors[0];n[o]={message:l.message,type:l.code}}else n[o]={message:i,type:a};if("unionErrors"in r&&r.unionErrors.forEach(function(u){return u.errors.forEach(function(m){return e.push(m)})}),t){var c=n[o].types,d=c&&c[r.code];n[o]=Pi(o,t,n,a,d?[].concat(d,r.message):r.message)}e.shift()}return n}function Jg(e,t){for(var n={},r=function(){var a=e[0],i=a.code,o=a.message,l=a.path.join(".");if(!n[l])if(a.code==="invalid_union"&&a.errors.length>0){var c=a.errors[0][0];n[l]={message:c.message,type:c.code}}else n[l]={message:o,type:i};if(a.code==="invalid_union"&&a.errors.forEach(function(m){return m.forEach(function(h){return e.push(Ja({},h,{path:[].concat(a.path,h.path)}))})}),t){var d=n[l].types,u=d&&d[a.code];n[l]=Pi(l,t,n,i,u?[].concat(u,a.message):a.message)}e.shift()};e.length;)r();return n}function Lt(e,t,n){if(n===void 0&&(n={}),(function(r){return"_def"in r&&typeof r._def=="object"&&"typeName"in r._def})(e))return function(r,a,i){try{return Promise.resolve(rl(function(){return Promise.resolve(e[n.mode==="sync"?"parse":"parseAsync"](r,t)).then(function(o){return i.shouldUseNativeValidation&&Ha({},i),{errors:{},values:n.raw?Object.assign({},r):o}})},function(o){if((function(l){return Array.isArray(l==null?void 0:l.issues)})(o))return{values:{},errors:qo(Qg(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};if((function(r){return"_zod"in r&&typeof r._zod=="object"})(e))return function(r,a,i){try{return Promise.resolve(rl(function(){return Promise.resolve((n.mode==="sync"?Gf:Xf)(e,r,t)).then(function(o){return i.shouldUseNativeValidation&&Ha({},i),{errors:{},values:n.raw?Object.assign({},r):o}})},function(o){if((function(l){return l instanceof $i})(o))return{values:{},errors:qo(Jg(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")}function Yr({label:e,required:t=!1,htmlFor:n,tooltip:r}){return s.jsxs("label",{htmlFor:n,className:"mb-1.5 flex items-center text-sm text-slate-600",children:[e,t?s.jsx("span",{className:"text-red-500",children:" *"}):null,r?s.jsx(Gg,{text:r}):null]})}function Gg({text:e}){return s.jsxs("span",{className:"group relative ml-1.5 inline-flex items-center",children:[s.jsxs("svg",{className:"h-4 w-4 cursor-help text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 16v-4M12 8h.01"})]}),s.jsx("span",{role:"tooltip",className:"pointer-events-none absolute bottom-full left-1/2 z-20 mb-1.5 w-max max-w-xs -translate-x-1/2 rounded-md bg-slate-800 px-2.5 py-1.5 text-xs font-normal leading-snug text-white opacity-0 shadow-lg transition-opacity duration-150 group-hover:opacity-100",children:e})]})}const he=v.forwardRef(function({label:t,required:n=!1,error:r,tooltip:a,id:i,className:o="",...l},c){const d=i??l.name;return s.jsxs("div",{children:[s.jsx(Yr,{label:t,required:n,htmlFor:d,tooltip:a}),s.jsx("input",{ref:c,id:d,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 ${r?"border-red-300":"border-slate-200"} ${o}`,...l}),r?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:r}):null]})}),xn=v.forwardRef(function({label:t,required:n=!1,error:r,id:a,className:i="",children:o,...l},c){const d=a??l.name;return s.jsxs("div",{children:[s.jsx(Yr,{label:t,required:n,htmlFor:d}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{ref:c,id:d,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 ${r?"border-red-300":"border-slate-200"} ${i}`,...l,children:o}),s.jsx(Xg,{})]}),r?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:r}):null]})});function ou({step:e,title:t,muted:n=!1,children:r}){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 ${n?"text-slate-400":"text-gov-700"}`,children:t})]}),r]})}function Xg(){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 Ts({title:e,subtitle:t,step:n,children:r,className:a=""}){return s.jsxs("section",{className:`rounded-xl border border-slate-200 bg-white ${a}`,children:[s.jsxs("div",{className:"flex items-center gap-3 border-b border-slate-100 px-6 py-4",children:[n?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:n}):null,s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-slate-900",children:e}),t?s.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:t}):null]})]}),s.jsx("div",{className:"space-y-5 p-6",children:r})]})}function lu({label:e,required:t=!1,options:n,value:r,onChange:a}){const i=v.useId(),o=v.useRef([]),l=n.findIndex(u=>u.value===r),c=u=>{var h;const m=(u+n.length)%n.length;a(n[m].value),(h=o.current[m])==null||h.focus()},d=u=>{u.key==="ArrowRight"||u.key==="ArrowDown"?(u.preventDefault(),c(l+1)):(u.key==="ArrowLeft"||u.key==="ArrowUp")&&(u.preventDefault(),c(l-1))};return s.jsxs("div",{children:[s.jsx(Yr,{label:e,required:t,htmlFor:i}),s.jsx("div",{id:i,role:"radiogroup","aria-label":e,onKeyDown:d,className:"grid gap-3",style:{gridTemplateColumns:`repeat(${n.length}, minmax(0, 1fr))`},children:n.map((u,m)=>{const h=u.value===r;return s.jsxs("button",{ref:p=>{o.current[m]=p},type:"button",role:"radio","aria-checked":h,tabIndex:h?0:-1,onClick:()=>a(u.value),className:`flex items-center justify-center gap-2 rounded-lg border px-4 py-3 text-sm font-semibold transition focus:outline-none focus-visible:ring-2 focus-visible:ring-gov-500 focus-visible:ring-offset-1 sm:text-base ${h?"border-gov-400 bg-gov-50 text-gov-700 shadow-sm ring-1 ring-gov-200":"border-slate-200 bg-white text-slate-600 hover:border-slate-300 hover:bg-slate-50"}`,children:[u.icon?s.jsx("span",{className:h?"text-gov-600":"text-slate-400",children:u.icon}):null,u.label,h?s.jsx(ey,{}):null]},u.value)})})]})}function ey(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"3",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}function cu({label:e="Phone Number",required:t=!1,error:n,countryCodeSelectProps:r,phoneInputProps:a}){const i=a.id??a.name,o=n&&i?`${i}-error`:void 0;return s.jsxs("div",{children:[s.jsx(Yr,{label:e,required:t,htmlFor:i}),s.jsxs("div",{className:`flex overflow-hidden rounded-lg border bg-white transition focus-within:ring-2 focus-within:ring-gov-200 ${n?"border-red-300":"border-slate-200 focus-within:border-gov-400"}`,children:[s.jsx("select",{"aria-label":"Country code",...r,className:"shrink-0 border-r border-slate-200 bg-slate-50 px-3 py-2.5 text-sm text-slate-900 focus:outline-none",children:s.jsx("option",{value:"+1",children:"+1"})}),s.jsx("input",{type:"tel",inputMode:"numeric","aria-invalid":n?!0:void 0,"aria-describedby":o,...a,id:i,className:"block w-full border-0 px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none focus:ring-0"})]}),n?s.jsx("p",{id:o,className:"mt-1 text-xs text-red-600",children:n}):null]})}function uu({onCancel:e,isSubmitting:t,submitLabel:n,submittingLabel:r,cancelLabel:a="Cancel",className:i=""}){return s.jsxs("div",{className:`sticky bottom-0 flex flex-col-reverse gap-3 border-t border-slate-200 bg-white py-4 sm:flex-row sm:items-center ${i}`,children:[s.jsx("button",{type:"button",onClick:e,disabled:t,className:"inline-flex h-11 w-full 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 sm:w-auto",children:a}),s.jsx("button",{type:"submit",disabled:t,className:"inline-flex h-11 w-full 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 sm:w-auto",children:t?r:n})]})}function Ot({variant:e="error",title:t,message:n}){const r=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 ${r}`,role:"alert",children:[t?s.jsx("p",{className:"font-medium",children:t}):null,s.jsx("p",{className:t?"mt-1":void 0,children:n})]})}function nt(e,t){var n;if(e instanceof xr){if(e.details){const r=(n=Object.values(e.details)[0])==null?void 0:n[0];if(r)return r}return e.message||t}return e instanceof Error&&e.message?e.message:t}const ty=F("ZodISODateTime",(e,t)=>{sx.init(e,t),Ie.init(e,t)});function ny(e){return og(ty,e)}const ry=F("ZodISODate",(e,t)=>{ax.init(e,t),Ie.init(e,t)});function sy(e){return lg(ry,e)}const ay=F("ZodISOTime",(e,t)=>{ix.init(e,t),Ie.init(e,t)});function iy(e){return cg(ay,e)}const oy=F("ZodISODuration",(e,t)=>{ox.init(e,t),Ie.init(e,t)});function ly(e){return ug(oy,e)}const cy=(e,t)=>{$i.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Jf(e,n)},flatten:{value:n=>Qf(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Ka,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Ka,2)}},isEmpty:{get(){return e.issues.length===0}}})},yt=F("ZodError",cy,{Parent:Error}),uy=Ys(yt),dy=Hs(yt),my=Ks(yt),hy=Qs(yt),fy=np(yt),py=rp(yt),xy=sp(yt),gy=ap(yt),yy=ip(yt),by=op(yt),vy=lp(yt),jy=cp(yt),sl=new WeakMap;function Gs(e,t,n){const r=Object.getPrototypeOf(e);let a=sl.get(r);if(a||(a=new Set,sl.set(r,a)),!a.has(t)){a.add(t);for(const i in n){const o=n[i];Object.defineProperty(r,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 Re=F("ZodType",(e,t)=>(Fe.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Is(e,"input"),output:Is(e,"output")}}),e.toJSONSchema=Eg(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>uy(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>my(e,n,r),e.parseAsync=async(n,r)=>dy(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>hy(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>fy(e,n,r),e.decode=(n,r)=>py(e,n,r),e.encodeAsync=async(n,r)=>xy(e,n,r),e.decodeAsync=async(n,r)=>gy(e,n,r),e.safeEncode=(n,r)=>yy(e,n,r),e.safeDecode=(n,r)=>by(e,n,r),e.safeEncodeAsync=async(n,r)=>vy(e,n,r),e.safeDecodeAsync=async(n,r)=>jy(e,n,r),Gs(e,"ZodType",{check(...n){const r=this.def;return this.clone(gn(r,{checks:[...r.checks??[],...n.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return yn(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(hb(n,r))},superRefine(n,r){return this.check(fb(n,r))},overwrite(n){return this.check(gr(n))},optional(){return ol(this)},exactOptional(){return eb(this)},nullable(){return ll(this)},nullish(){return ol(ll(this))},nonoptional(n){return ib(this,n)},array(){return Zy(this)},or(n){return hu([this,n])},and(n){return Ky(this,n)},transform(n){return cl(this,Gy(n))},default(n){return rb(this,n)},prefault(n){return ab(this,n)},catch(n){return lb(this,n)},pipe(n){return cl(this,n)},readonly(){return db(this)},describe(n){const r=this.clone();return Pr.add(r,{description:n}),r},meta(...n){if(n.length===0)return Pr.get(this);const r=this.clone();return Pr.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){var n;return(n=Pr.get(e))==null?void 0:n.description},configurable:!0}),e)),du=F("_ZodString",(e,t)=>{Li.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(r,a,i)=>Tg(e,r,a);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Gs(e,"_ZodString",{regex(...r){return this.check(fg(...r))},includes(...r){return this.check(gg(...r))},startsWith(...r){return this.check(yg(...r))},endsWith(...r){return this.check(bg(...r))},min(...r){return this.check(Es(...r))},max(...r){return this.check(tu(...r))},length(...r){return this.check(nu(...r))},nonempty(...r){return this.check(Es(1,...r))},lowercase(r){return this.check(pg(r))},uppercase(r){return this.check(xg(r))},trim(){return this.check(jg())},normalize(...r){return this.check(vg(...r))},toLowerCase(){return this.check(wg())},toUpperCase(){return this.check(Ng())},slugify(){return this.check(Sg())}})}),wy=F("ZodString",(e,t)=>{Li.init(e,t),du.init(e,t),e.email=n=>e.check(eu(mu,n)),e.url=n=>e.check(Zx(Sy,n)),e.jwt=n=>e.check(ig(zy,n)),e.emoji=n=>e.check(Wx(ky,n)),e.guid=n=>e.check(nl(al,n)),e.uuid=n=>e.check(qx(os,n)),e.uuidv4=n=>e.check(Bx(os,n)),e.uuidv6=n=>e.check(Vx(os,n)),e.uuidv7=n=>e.check(Ux(os,n)),e.nanoid=n=>e.check(Yx(Cy,n)),e.guid=n=>e.check(nl(al,n)),e.cuid=n=>e.check(Hx(Ay,n)),e.cuid2=n=>e.check(Kx(Py,n)),e.ulid=n=>e.check(Qx(Ey,n)),e.base64=n=>e.check(rg($y,n)),e.base64url=n=>e.check(sg(Ly,n)),e.xid=n=>e.check(Jx(Iy,n)),e.ksuid=n=>e.check(Gx(Ty,n)),e.ipv4=n=>e.check(Xx(_y,n)),e.ipv6=n=>e.check(eg(Dy,n)),e.cidrv4=n=>e.check(tg(Fy,n)),e.cidrv6=n=>e.check(ng(Ry,n)),e.e164=n=>e.check(ag(Oy,n)),e.datetime=n=>e.check(ny(n)),e.date=n=>e.check(sy(n)),e.time=n=>e.check(iy(n)),e.duration=n=>e.check(ly(n))});function D(e){return Mx(wy,e)}const Ie=F("ZodStringFormat",(e,t)=>{Ce.init(e,t),du.init(e,t)}),mu=F("ZodEmail",(e,t)=>{Kp.init(e,t),Ie.init(e,t)});function Ny(e){return eu(mu,e)}const al=F("ZodGUID",(e,t)=>{Yp.init(e,t),Ie.init(e,t)}),os=F("ZodUUID",(e,t)=>{Hp.init(e,t),Ie.init(e,t)}),Sy=F("ZodURL",(e,t)=>{Qp.init(e,t),Ie.init(e,t)}),ky=F("ZodEmoji",(e,t)=>{Jp.init(e,t),Ie.init(e,t)}),Cy=F("ZodNanoID",(e,t)=>{Gp.init(e,t),Ie.init(e,t)}),Ay=F("ZodCUID",(e,t)=>{Xp.init(e,t),Ie.init(e,t)}),Py=F("ZodCUID2",(e,t)=>{ex.init(e,t),Ie.init(e,t)}),Ey=F("ZodULID",(e,t)=>{tx.init(e,t),Ie.init(e,t)}),Iy=F("ZodXID",(e,t)=>{nx.init(e,t),Ie.init(e,t)}),Ty=F("ZodKSUID",(e,t)=>{rx.init(e,t),Ie.init(e,t)}),_y=F("ZodIPv4",(e,t)=>{lx.init(e,t),Ie.init(e,t)}),Dy=F("ZodIPv6",(e,t)=>{cx.init(e,t),Ie.init(e,t)}),Fy=F("ZodCIDRv4",(e,t)=>{ux.init(e,t),Ie.init(e,t)}),Ry=F("ZodCIDRv6",(e,t)=>{dx.init(e,t),Ie.init(e,t)}),$y=F("ZodBase64",(e,t)=>{mx.init(e,t),Ie.init(e,t)}),Ly=F("ZodBase64URL",(e,t)=>{fx.init(e,t),Ie.init(e,t)}),Oy=F("ZodE164",(e,t)=>{px.init(e,t),Ie.init(e,t)}),zy=F("ZodJWT",(e,t)=>{gx.init(e,t),Ie.init(e,t)}),My=F("ZodBoolean",(e,t)=>{yx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>_g(e,n,r)});function Wn(e){return dg(My,e)}const qy=F("ZodUnknown",(e,t)=>{bx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Fg()});function il(){return mg(qy)}const By=F("ZodNever",(e,t)=>{vx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Dg(e,n,r)});function Vy(e){return hg(By,e)}const Uy=F("ZodArray",(e,t)=>{jx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>zg(e,n,r,a),e.element=t.element,Gs(e,"ZodArray",{min(n,r){return this.check(Es(n,r))},nonempty(n){return this.check(Es(1,n))},max(n,r){return this.check(tu(n,r))},length(n,r){return this.check(nu(n,r))},unwrap(){return this.element}})});function Zy(e,t){return kg(Uy,e,t)}const Wy=F("ZodObject",(e,t)=>{Nx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Mg(e,n,r,a),ve(e,"shape",()=>t.shape),Gs(e,"ZodObject",{keyof(){return Xs(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:il()})},loose(){return this.clone({...this._zod.def,catchall:il()})},strict(){return this.clone({...this._zod.def,catchall:Vy()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return Uf(this,n)},safeExtend(n){return Zf(this,n)},merge(n){return Wf(this,n)},pick(n){return Bf(this,n)},omit(n){return Vf(this,n)},partial(...n){return Yf(fu,this,n[0])},required(...n){return Hf(pu,this,n[0])}})});function Xt(e,t){const n={type:"object",shape:e??{},...se(t)};return new Wy(n)}const Yy=F("ZodUnion",(e,t)=>{Sx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>qg(e,n,r,a),e.options=t.options});function hu(e,t){return new Yy({type:"union",options:e,...se(t)})}const Hy=F("ZodIntersection",(e,t)=>{kx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Bg(e,n,r,a)});function Ky(e,t){return new Hy({type:"intersection",left:e,right:t})}const Ga=F("ZodEnum",(e,t)=>{Cx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(r,a,i)=>Rg(e,r,a),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,a)=>{const i={};for(const o of r)if(n.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Ga({...t,checks:[],...se(a),entries:i})},e.exclude=(r,a)=>{const i={...t.entries};for(const o of r)if(n.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new Ga({...t,checks:[],...se(a),entries:i})}});function Xs(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Ga({type:"enum",entries:n,...se(t)})}const Qy=F("ZodLiteral",(e,t)=>{Ax.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>$g(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function da(e,t){return new Qy({type:"literal",values:Array.isArray(e)?e:[e],...se(t)})}const Jy=F("ZodTransform",(e,t)=>{Px.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Og(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new qc(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Rr(i,n.value,t));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=e),n.issues.push(Rr(o))}};const a=t.transform(n.value,n);return a instanceof Promise?a.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=a,n.fallback=!0,n)}});function Gy(e){return new Jy({type:"transform",transform:e})}const fu=F("ZodOptional",(e,t)=>{Xc.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>iu(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function ol(e){return new fu({type:"optional",innerType:e})}const Xy=F("ZodExactOptional",(e,t)=>{Ex.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>iu(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function eb(e){return new Xy({type:"optional",innerType:e})}const tb=F("ZodNullable",(e,t)=>{Ix.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Vg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function ll(e){return new tb({type:"nullable",innerType:e})}const nb=F("ZodDefault",(e,t)=>{Tx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Zg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function rb(e,t){return new nb({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Uc(t)}})}const sb=F("ZodPrefault",(e,t)=>{_x.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Wg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function ab(e,t){return new sb({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Uc(t)}})}const pu=F("ZodNonOptional",(e,t)=>{Dx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Ug(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function ib(e,t){return new pu({type:"nonoptional",innerType:e,...se(t)})}const ob=F("ZodCatch",(e,t)=>{Fx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Yg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function lb(e,t){return new ob({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const cb=F("ZodPipe",(e,t)=>{Rx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Hg(e,n,r,a),e.in=t.in,e.out=t.out});function cl(e,t){return new cb({type:"pipe",in:e,out:t})}const ub=F("ZodReadonly",(e,t)=>{$x.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Kg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function db(e){return new ub({type:"readonly",innerType:e})}const mb=F("ZodCustom",(e,t)=>{Lx.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Lg(e,n)});function hb(e,t={}){return Cg(mb,e,t)}function fb(e,t){return Ag(e,t)}const Qt={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function Oi(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 en(e){return e.tradeName.trim()?e.tradeName:e.accountType==="Business"?(e.lastName||e.firstName).trim():`${e.firstName} ${e.lastName}`.trim()}function zi(e){const t=e.replace(/\D/g,"");return t.length!==9?e:`${t.slice(0,2)}-${t.slice(2)}`}function pb(e){const t=e.replace(/\D/g,"");return t.length!==9?e:`${t.slice(0,3)}-${t.slice(3,5)}-${t.slice(5)}`}function Hr(e,t){return t==="Individual"?pb(e):zi(e)}function ul(e,t){const n=e.replace(/\D/g,"").slice(0,9);return t==="Individual"?n.length<=3?n:n.length<=5?`${n.slice(0,3)}-${n.slice(3)}`:`${n.slice(0,3)}-${n.slice(3,5)}-${n.slice(5)}`:n.length<=2?n:`${n.slice(0,2)}-${n.slice(2)}`}function $n(e){const t=e.replace(/\D/g,""),n=t.length===11&&t.startsWith("1")?t.slice(1):t;return n.length!==10?e:`+1 (${n.slice(0,3)}) ${n.slice(3,6)}-${n.slice(6)}`}const xu=["LLP","LLC","Corporation","S-Corp","Partnership"],gu=["Sole Proprietorship"],xb=/^[A-Za-z][A-Za-z\s'.-]*$/,dl=/^[A-Za-z0-9][A-Za-z0-9\s,.'#/&-]*$/,Xa=10,yu=/^\d{5}(-\d{4})?$/,gb=/^[A-Za-z]\d[A-Za-z][ -]?\d[A-Za-z]\d$/;function Mi(e){const t=e.replace(/\D/g,"").slice(0,9);return t.length<=5?t:`${t.slice(0,5)}-${t.slice(5)}`}function bu(e){const t=e.toUpperCase().replace(/[^A-Z0-9]/g,"").slice(0,6);return t.length<=3?t:`${t.slice(0,3)} ${t.slice(3)}`}const vu=Xt({accountType:Xs(["Business","Individual"]),firstName:D(),lastName:D(),tradeName:D(),ein:D(),entityType:D().min(1,"Entity type is required"),email:Ny("Enter a valid email"),countryCode:D().min(1),phoneNumber:D().min(1,"Phone number is required").refine(e=>e.replace(/\D/g,"").length===Xa,`Phone number must be ${Xa} digits`),address1:D().min(1,"Address is required"),address2:D(),city:D().min(1,"City is required"),state:D().min(1,"State is required"),zipCode:D().min(1,"ZIP code is required"),country:D().min(1,"Country is required")}).superRefine((e,t)=>{xb.test(e.city.trim())||t.addIssue({code:"custom",path:["city"],message:"City can only contain letters, spaces, apostrophes, and hyphens"}),dl.test(e.address1.trim())||t.addIssue({code:"custom",path:["address1"],message:"Address can only contain letters, numbers, spaces, and , . ' # / & -"}),e.address2.trim()&&!dl.test(e.address2.trim())&&t.addIssue({code:"custom",path:["address2"],message:"Address can only contain letters, numbers, spaces, and , . ' # / & -"}),e.country==="United States"&&!yu.test(e.zipCode.trim())?t.addIssue({code:"custom",path:["zipCode"],message:"Enter a 5-digit ZIP or ZIP+4 (e.g. 12345 or 12345-6789)"}):e.country==="Canada"&&!gb.test(e.zipCode.trim())&&t.addIssue({code:"custom",path:["zipCode"],message:"Enter a valid postal code (e.g. A1A 1A1)"});const n=e.accountType==="Individual"?"SSN":"EIN",r=e.ein.replace(/\D/g,"");if(r?r.length!==9&&t.addIssue({code:"custom",path:["ein"],message:`${n} must be 9 digits`}):t.addIssue({code:"custom",path:["ein"],message:`${n} is required`}),e.accountType==="Business"){e.lastName.trim()||t.addIssue({code:"custom",path:["lastName"],message:"Business name is required"});return}e.firstName.trim()||t.addIssue({code:"custom",path:["firstName"],message:"First name is required"}),e.lastName.trim()||t.addIssue({code:"custom",path:["lastName"],message:"Last name is required"})});function yb(e){const t=e.replace(/\D/g,"");return t.length===11&&t.startsWith("1")?{countryCode:"+1",national:t.slice(1)}:t.length===10?{countryCode:"+1",national:t}:{countryCode:"+1",national:t.slice(-Xa)}}function ml(e){const{countryCode:t,national:n}=yb(e.phoneNumber),r=e.accountType==="Individual",a=(e.lastName||e.firstName||"").trim();return{accountType:r?"Individual":"Business",firstName:r?e.firstName??"":"",lastName:r?e.lastName??"":a,tradeName:r?"":e.tradeName??"",ein:Hr(e.idNumber,e.accountType),entityType:e.entityType,email:e.email,countryCode:t,phoneNumber:n,address1:e.address1,address2:e.address2??"",city:e.city,state:e.state,zipCode:e.zipCode,country:e.country}}function ju(e,t,n,r){if(e!==t){if(e==="Business"&&t==="Individual"){n("firstName",""),n("lastName",r),n("tradeName","");return}e==="Individual"&&t==="Business"&&(n("firstName",""),n("lastName",r))}}function wu(e){const t=e.lastName.trim();return e.accountType==="Business"?{accountType:e.accountType,firstName:"",lastName:t,idNumber:e.ein.replace(/\D/g,""),entityType:e.entityType,tradeName:e.tradeName.trim(),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}:{accountType:e.accountType,firstName:e.firstName.trim(),lastName:t,idNumber:e.ein.replace(/\D/g,""),entityType:e.entityType,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 bb(e){const{idNumber:t,...n}=wu(e);return n}function vb(e){return de(`/portal/reference/states?country=${encodeURIComponent(e)}`)}function qi(e){const{data:t}=ge({queryKey:["reference","states",e],queryFn:()=>vb(e),enabled:!!e,staleTime:1/0});return t??[]}function cr(e,t,n){const r=e.find(o=>o.code===t);if(!r||r.zipRanges.length===0)return!0;const a=n.replace(/\D/g,"");if(a.length<5)return!0;const i=Number(a.slice(0,3));return r.zipRanges.some(o=>i>=o.from&&i<=o.to)}function qn(e,t){const n=e==null?void 0:e.from;return n&&n.startsWith("/")&&!n.startsWith("//")?n:t}function jb(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 21h18M5 21V6a1 1 0 011-1h4a1 1 0 011 1v15m0 0V3a1 1 0 011-1h4a1 1 0 011 1v18M9 9h.01M9 12h.01M9 15h.01"})})}function wb(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",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 Nb(){var Ae,$e,ce,pe,$,fe,O,ue,Te,Ge,Oe,le,be,Ye;const e=ke(),t=Se(),n=ft(),{data:r=[]}=ge({queryKey:["entities","mine"],queryFn:async()=>(await bi({pageNumber:1,pageSize:100})).items}),[a,i]=v.useState(null),[o,l]=v.useState(!1),c=r.length===0,d=c?"/create-entity":"/dashboard",u=qn(t.state,d),m=()=>{e(u)},{register:h,handleSubmit:p,watch:g,setValue:x,getValues:b,formState:{errors:y}}=Rt({resolver:Lt(vu),shouldUnregister:!1,defaultValues:{accountType:"Business",firstName:"",lastName:"",tradeName:"",ein:"",entityType:"LLP",email:"",countryCode:"+1",phoneNumber:"",address1:"",address2:"",city:"",state:"",zipCode:"",country:"United States"}}),C=g("accountType"),j=g("entityType"),S=C==="Individual"?gu:xu,I=C==="Individual",R=I?"SSN":"EIN",E=I?"***-**-****":"**-*******",T=I?11:10,L=g("country"),B=g("state"),K=g("zipCode"),X=L==="United States",Y=qi(L),V=B.length>0&&K.trim().length>0&&!cr(Y,B,K),Z=h("ein"),ie=h("phoneNumber"),G=h("zipCode");v.useEffect(()=>{B&&Y.length>0&&!Y.some(re=>re.code===B)&&x("state","")},[L,Y]);const Q=re=>{const Ve=b("accountType");if(Ve===re)return;const rt=b("lastName");ju(Ve,re,x,rt),x("accountType",re),x("ein",ul(b("ein"),re)),queueMicrotask(()=>{x("lastName",rt),x("firstName",""),Ve==="Business"&&re==="Individual"&&x("tradeName","")})};v.useEffect(()=>{S.includes(j)||x("entityType",C==="Individual"?"Sole Proprietorship":"LLP")},[C,j,S,x]);const we=p(async re=>{if(i(null),!cr(Y,re.state,re.zipCode)){i(`ZIP code does not match the selected state (${re.state}).`);return}l(!0);try{await Xh(wu(re)),await n.invalidateQueries({queryKey:["entities","mine"]}),e(c?"/dashboard":u,{replace:!0})}catch(Ve){i(nt(Ve,"Unable to save entity. Please try again."))}finally{l(!1)}});return s.jsxs("form",{onSubmit:we,noValidate:!0,className:"w-full max-w-4xl space-y-6 lg:max-w-5xl xl:max-w-6xl",children:[a?s.jsx(Ot,{message:a}):null,s.jsxs(Ts,{step:1,title:"Basic Information",subtitle:"Enter the primary details for this entity.",children:[s.jsx(lu,{label:"Account Type",required:!0,value:C,onChange:Q,options:[{label:"Business",value:"Business",icon:s.jsx(jb,{})},{label:"Individual",value:"Individual",icon:s.jsx(wb,{})}]}),s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:C==="Individual"?s.jsxs(s.Fragment,{children:[s.jsx(he,{label:"First name",required:!0,maxLength:100,placeholder:"Enter first name",error:(Ae=y.firstName)==null?void 0:Ae.message,...h("firstName")},"entity-first-name"),s.jsx(he,{label:"Last name",required:!0,maxLength:100,placeholder:"Enter last name",error:($e=y.lastName)==null?void 0:$e.message,...h("lastName")},"entity-last-name")]}):s.jsxs(s.Fragment,{children:[s.jsx(he,{label:"Business Name",required:!0,maxLength:150,placeholder:"Enter business name",error:(ce=y.lastName)==null?void 0:ce.message,...h("lastName")},"entity-business-name"),s.jsx(he,{label:"Trade Name, if any",maxLength:150,placeholder:"Enter trade name (optional)",error:(pe=y.tradeName)==null?void 0:pe.message,...h("tradeName")},"entity-trade-name")]})}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:R,required:!0,inputMode:"numeric",placeholder:E,maxLength:T,error:($=y.ein)==null?void 0:$.message,...Z,onChange:re=>{re.target.value=ul(re.target.value,C),Z.onChange(re)}}),s.jsx(xn,{label:"Entity Type",required:!0,error:(fe=y.entityType)==null?void 0:fe.message,...h("entityType"),children:S.map(re=>s.jsx("option",{value:re,children:re},re))})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:"Email ID",required:!0,type:"email",maxLength:254,placeholder:"sample@mail.com",error:(O=y.email)==null?void 0:O.message,...h("email")}),s.jsx(cu,{required:!0,error:(ue=y.phoneNumber)==null?void 0:ue.message,countryCodeSelectProps:h("countryCode"),phoneInputProps:{placeholder:"Enter 10-digit phone number",maxLength:10,...ie,onChange:re=>{re.target.value=re.target.value.replace(/\D/g,"").slice(0,10),ie.onChange(re)}}})]})]}),s.jsxs(Ts,{step:2,title:"Address Information",subtitle:"Enter the registered address.",children:[s.jsx(he,{label:"Address Line 1",required:!0,maxLength:200,placeholder:"Enter address line 1",error:(Te=y.address1)==null?void 0:Te.message,...h("address1")}),s.jsx(he,{label:"Address Line 2",maxLength:200,placeholder:"Enter address line 2 (optional)",error:(Ge=y.address2)==null?void 0:Ge.message,...h("address2")}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:"City",required:!0,maxLength:100,placeholder:"Enter city",error:(Oe=y.city)==null?void 0:Oe.message,...h("city")}),s.jsxs(xn,{label:X?"State":"Province",required:!0,error:(le=y.state)==null?void 0:le.message,...h("state"),children:[s.jsx("option",{value:"",children:X?"Select state":"Select province"}),Y.map(re=>s.jsx("option",{value:re.code,children:re.name},re.code))]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:X?"ZIP Code":"Postal Code",required:!0,maxLength:10,placeholder:X?"12345 or 12345-6789":"A1A 1A1",error:((be=y.zipCode)==null?void 0:be.message)??(V?`ZIP code does not match the selected state (${B}).`:void 0),...G,onChange:re=>{re.target.value=X?Mi(re.target.value):bu(re.target.value),G.onChange(re)}}),s.jsxs(xn,{label:"Country",required:!0,error:(Ye=y.country)==null?void 0:Ye.message,...h("country"),children:[s.jsx("option",{value:"United States",children:"United States"}),s.jsx("option",{value:"Canada",children:"Canada"})]})]})]}),s.jsx(uu,{onCancel:m,isSubmitting:o,submitLabel:"Add Entity",submittingLabel:"Creating…"})]})}function Bi(){const e=ke(),t=Se(),n=qn(t.state,"/create-entity");return s.jsx("div",{className:"min-h-full bg-slate-50 px-4 py-6 sm:px-8 sm:py-8",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl lg:max-w-5xl xl:max-w-6xl",children:[s.jsxs("button",{type:"button",onClick:()=>e(n),className:"inline-flex items-center gap-1.5 rounded-lg py-1 text-sm font-medium text-slate-600 transition hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-500",children:[s.jsx(Sb,{}),"Back"]}),s.jsxs("div",{className:"mb-6 mt-4",children:[s.jsx("h1",{className:"text-2xl font-bold text-slate-900",children:"Add Entity"}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Add the business or individual responsible for tax accounts and payments."})]}),s.jsx(Nb,{})]})})}function Sb(){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"})})}function kb(e,t){const n=new URLSearchParams({entityId:String(e)});return t!==void 0&&n.set("taxYear",String(t)),de(`/portal/dashboard?${n}`)}function Cb(e,t,n){const r=new URLSearchParams({entityId:String(e),category:t,taxYear:String(n)});return de(`/portal/dashboard/summary?${r}`)}function Ab(e,t,n){const r=new URLSearchParams({entityId:String(e),month:String(t)});return n!==void 0&&r.set("year",String(n)),de(`/portal/dashboard/monthly-overview?${r}`)}function Pb({entityId:e,search:t,taxYear:n,status:r,page:a=1,pageSize:i=it}){const o=new URLSearchParams({entityId:String(e),page:String(a),pageSize:String(i)});return t&&o.set("search",t),n&&o.set("taxYear",n),r&&r!=="all"&&o.set("status",r),de(`/portal/dashboard/payments?${o}`)}function hl({entityCount:e,showPaymentActions:t=!0}){const n=ke(),{enabledPayments:r}=zn();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:[t&&r.includes("federal")&&s.jsxs("button",{type:"button",onClick:()=>n("/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(ma,{}),"Add Federal Payments"]}),t&&r.includes("state")&&s.jsxs("button",{type:"button",onClick:()=>n("/payments/state/new",{state:{from:"/",resetDraft:!0}}),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(ma,{}),"Add State Payment"]}),t&&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(ma,{}),"Add Local Payment",s.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs("button",{type:"button",onClick:()=>n("/entities"),className:"inline-flex items-center gap-1.5 rounded-[14px] border border-solid border-[#e5e7eb] bg-[#f9fafb] px-[15px] py-[9px] text-xs font-bold text-[#364153] transition hover:bg-slate-100",title:"View Entities",children:[s.jsx(Eb,{}),"Entities (",e,")"]}),s.jsxs("button",{type:"button",onClick:()=>n("/create-entity/form",{state:{from:"/dashboard"}}),className:"inline-flex items-center gap-1.5 rounded-[14px] border-[1.5px] border-dashed border-[#16a34a] bg-[#f0fdf4] px-[15.5px] py-[9.5px] text-xs font-bold text-[#16a34a] transition hover:bg-green-50",children:[s.jsx(Ib,{}),"Add Entity"]})]})]})}function ma(){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 Eb(){return s.jsx("svg",{className:"h-[13px] w-[13px] shrink-0 text-[#364153]",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 Ib(){return s.jsx("svg",{className:"h-[13px] w-[13px] shrink-0 text-[#16a34a]",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 Tb({title:e,description:t,buttonLabel:n,onAdd:r,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:r,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(_b,{}),n]})]})}function _b(){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 yr({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(Db,{}),s.jsx("span",{children:e})]})})}function Db(){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 Fb={Draft:"Draft"};function Rb(e){switch((e??Fb.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 Kr(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:e%1===0?0:2,maximumFractionDigits:2}).format(e)}function $b(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 Vi="drafts";function Je(){return ea(Vi)}function ea(e){return`/payments?tab=${e}`}function Nu(e){return e==="failed"?"rejected":e}function Lb(e,t){return e==="draft"||t.trim().toLowerCase()==="draft"?Vi:Nu(e)}const Ob=["January","February","March","April","May","June","July","August","September","October","November","December"];function zb({entityId:e,initialOverview:t,isDashboardLoading:n=!1}){const r=ke(),a=(t==null?void 0:t.year)??new Date().getFullYear(),[i,o]=v.useState(null);v.useEffect(()=>{o(null)},[e]);const l=i??(t==null?void 0:t.month)??new Date().getMonth()+1,c=i===null,{data:d,isFetching:u}=ge({queryKey:["dashboard","monthly-overview",e,i,a],queryFn:()=>Ab(e,i,a),enabled:e!==null&&i!==null,placeholderData:x=>x}),m={submitted:0,paid:0,scheduled:0,failed:0},h=c?t??m:d??m,p=n||u&&!c,g=[{key:"submitted",label:"Submitted to Fed/State",amount:h.submitted,icon:qb,iconClassName:"rounded-xl bg-orange-50 text-orange-500",amountClassName:"text-orange-500"},{key:"paid",label:"Paid",amount:h.paid,icon:Bb,iconClassName:"rounded-full bg-emerald-50 text-emerald-600",amountClassName:"text-emerald-600"},{key:"scheduled",label:"Scheduled",amount:h.scheduled,icon:Vb,iconClassName:"rounded-xl bg-amber-50 text-amber-500",amountClassName:"text-amber-500"},{key:"failed",label:"Rejected",amount:h.failed,icon:Ub,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:[p?s.jsx(yr,{}):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:p,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:Ob.map((x,b)=>s.jsx("option",{value:b+1,children:x},x))}),s.jsx(Mb,{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 lg:grid-cols-4",children:g.map(x=>{const b=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(b,{})}),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:Kr(x.amount)}),s.jsx("button",{type:"button",onClick:()=>r(ea(Nu(x.key))),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 Mb({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 qb(){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 Bb(){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 Vb(){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 Ub(){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 fl(e){return{count:e.count,submitted:e.submitted,paid:e.paid,scheduled:e.scheduled,failed:e.failed,percentDone:e.percentDone}}function Zb(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 pl(){return{count:0,submitted:0,paid:0,scheduled:0,failed:0,percentDone:0}}const Wb={primary:"bg-brand-600 text-white hover:bg-brand-700 focus-visible:ring-brand-500 disabled:bg-brand-600/60",secondary:"border border-slate-300 bg-white text-slate-700 hover:bg-slate-50 focus-visible:ring-slate-400",ghost:"text-slate-600 hover:bg-slate-100 focus-visible:ring-slate-400"};function Yb({variant:e="primary",isLoading:t=!1,className:n="",children:r,disabled:a,...i}){return s.jsx("button",{type:"button",className:`inline-flex h-10 items-center justify-center rounded-lg px-4 text-sm font-medium transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed ${Wb[e]} ${n}`,disabled:a||t,...i,children:t?"Please wait…":r})}const Hb=[10,20,50,100];function Kb(e,t){const n=e.trim();if(!/^\d+$/.test(n))return null;const r=Number(n);return!Number.isInteger(r)||r<1||r>t?null:r}function Qb(){return s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:s.jsx("path",{d:"M12.5 4.5 7 10l5.5 5.5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function Jb(){return s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:s.jsx("path",{d:"M7.5 4.5 13 10l-5.5 5.5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function Qr({page:e,pageSize:t,totalCount:n,onPageChange:r,onPageSizeChange:a,pageSizeOptions:i=Hb,disabled:o=!1,className:l=""}){const c=t>0?Math.max(1,Math.ceil(n/t)):1,d=n===0?0:c,u=e>1,m=d>0&&e<d,h=n===0?0:(e-1)*t+1,p=Math.min(e*t,n),[g,x]=v.useState(String(e)),b=v.useRef(g);b.current=g,v.useEffect(()=>{x(String(e))},[e]);function y(j=b.current){if(o||d===0){x(String(e));return}const S=Kb(j,d);if(S===null){x(String(e));return}if(S===e){x(String(e));return}r(S)}function C(j){j.key==="Enter"&&(j.preventDefault(),y(j.currentTarget.value))}return n===0?null:s.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 border-t border-slate-200 bg-white px-6 py-3 ${l}`,children:[s.jsxs("p",{className:"text-sm text-slate-500",children:["Showing ",s.jsx("span",{className:"font-medium text-slate-700",children:h}),"–",s.jsx("span",{className:"font-medium text-slate-700",children:p})," of ",s.jsx("span",{className:"font-medium text-slate-700",children:n})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a?s.jsxs("label",{className:"flex items-center gap-2 text-sm text-slate-600",children:[s.jsx("span",{className:"whitespace-nowrap",children:"Rows per page"}),s.jsx("select",{value:t,disabled:o,onChange:j=>a(Number(j.target.value)),className:"rounded-lg border border-slate-200 bg-white px-2 py-1.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:i.map(j=>s.jsx("option",{value:j,children:j},j))})]}):null,s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{type:"button",disabled:o||!u,onClick:()=>r(e-1),"aria-label":"Previous page",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-slate-700 transition hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-200 disabled:cursor-not-allowed disabled:text-slate-300 disabled:hover:bg-transparent",children:s.jsx(Qb,{})}),s.jsx("span",{className:"min-w-[5.5rem] text-center text-sm text-slate-600",children:d===0?"—":`Page ${e} of ${d}`}),s.jsx("button",{type:"button",disabled:o||!m,onClick:()=>r(e+1),"aria-label":"Next page",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-slate-700 transition hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-200 disabled:cursor-not-allowed disabled:text-slate-300 disabled:hover:bg-transparent",children:s.jsx(Jb,{})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{htmlFor:"pagination-go-to-page",className:"whitespace-nowrap text-sm text-slate-600",children:"Go to page"}),s.jsx("input",{id:"pagination-go-to-page",type:"text",inputMode:"numeric",pattern:"[0-9]*",value:g,disabled:o||d===0,onChange:j=>x(j.target.value),onKeyDown:C,"aria-label":"Go to page number",className:"h-9 w-14 rounded-lg border border-slate-200 bg-white px-2 text-center text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60"}),s.jsx(Yb,{type:"button",variant:"secondary",disabled:o||d===0,className:"h-9 px-3",onMouseDown:j=>{j.preventDefault()},onClick:()=>y(),children:"Go"})]})]})]})}const Gb=[{value:"all",label:"All"},{value:"draft",label:"Draft"},{value:"scheduled",label:"Scheduled"},{value:"paid",label:"Completed"},{value:"submitted",label:"Submitted"},{value:"failed",label:"Rejected"}],xl={total:0,page:1,pageSize:it,items:[]};function Xb({label:e,status:t}){const n={draft:"bg-slate-100 text-slate-600",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 ${n[t]}`,children:e})}function e0({entityId:e,initialPayments:t,isDashboardLoading:n=!1}){const r=ke(),[a,i]=v.useState(""),[o,l]=v.useState(""),[c,d]=v.useState(""),[u,m]=v.useState("all"),[h,p]=v.useState(1),[g,x]=v.useState(it);v.useEffect(()=>{const T=window.setTimeout(()=>l(a),300);return()=>window.clearTimeout(T)},[a]),v.useEffect(()=>{p(1)},[o,c,u,e,g]);const b=!!o||!!c||u!=="all",y=e!==null&&(b||h>1||g!==it),{data:C,isFetching:j}=ge({queryKey:["dashboard","payments",e,o,c,u,h,g],queryFn:()=>Pb({entityId:e,search:o||void 0,taxYear:c||void 0,status:u,page:h,pageSize:g}),enabled:y,placeholderData:T=>T}),S=v.useMemo(()=>y?C??xl:t&&h===1&&g===it?t:xl,[y,C,t,h,g]),I=v.useMemo(()=>S.items.map(Zb),[S.items]),R=v.useMemo(()=>{const T=new Date().getFullYear();return[T,T-1,T-2].map(String)},[]),E=n||y&&j;return s.jsxs("section",{className:"relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[E?s.jsx(yr,{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(n0,{})}),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:[S.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 Jurisdiction/Form Type"}),s.jsxs("div",{className:"relative",children:[s.jsx(t0,{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:a,onChange:T=>i(T.target.value),placeholder:"All",disabled:n,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:c,onChange:T=>d(T.target.value),disabled:n,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"}),R.map(T=>s.jsx("option",{value:T,children:T},T))]}),s.jsx(gl,{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:T=>m(T.target.value),disabled:n,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:Gb.map(T=>s.jsx("option",{value:T.value,children:T.label},T.value))}),s.jsx(gl,{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:!E&&I.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-slate-500",children:b?"No payments match your filters.":"No payments yet."})}):I.map(T=>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:["#",T.id]}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:T.jurisdiction}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:T.period}),s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Kr(T.amount)}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:T.paymentDate}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(Xb,{label:T.statusLabel,status:T.status})}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:T.formType}),s.jsx("td",{className:"px-6 py-4",children:s.jsx("button",{type:"button",onClick:()=>r(ea(Lb(T.status,T.statusLabel))),className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"})})]},`${T.category}-${T.id}`))})]})}),s.jsx(Qr,{page:h,pageSize:g,totalCount:S.total,onPageChange:p,onPageSizeChange:x,disabled:E||e===null})]})}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:"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 gl({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 n0(){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 ha({entityId:e,category:t,title:n,subtitlePrefix:r,defaultTaxYear:a,taxYearOptions:i,initialSummary:o,isDashboardLoading:l=!1,stats:c,comingSoon:d=!1}){const[u,m]=v.useState(a);if(v.useEffect(()=>{m(a)},[e,a]),d)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:n}),s.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:r})]}),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 h=u===a,{data:p,isFetching:g}=ge({queryKey:["dashboard","summary",e,t,u],queryFn:()=>Cb(e,t,u),enabled:e!==null&&!h,placeholderData:C=>C}),x=h?o?fl(o):pl():p?fl(p):pl(),b=$b(x),y=l||g&&!h;return s.jsxs("article",{className:"relative flex flex-col rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[y?s.jsx(yr,{}):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:n}),s.jsxs("p",{className:"mt-0.5 text-xs text-slate-500",children:[r," (",x.count,")"]})]}),s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("select",{value:u,onChange:C=>m(Number(C.target.value)),disabled:y,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(C=>s.jsxs("option",{value:C,children:["TY ",C]},C))}),s.jsx(r0,{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(C=>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 ${C.dotClassName}`}),s.jsx("span",{className:"text-xs text-slate-500",children:C.label})]}),s.jsx("p",{className:"mt-1 text-sm font-semibold text-slate-900",children:Kr(x[C.key])})]},C.label))}),s.jsxs("div",{className:"mt-5",children:[s.jsx("div",{className:"flex h-2 overflow-hidden rounded-full bg-slate-100",children:b.map((C,j)=>C.width>0?s.jsx("span",{className:`${C.color} h-full`,style:{width:`${C.width}%`}},j):null)}),s.jsxs("p",{className:"mt-2 text-xs font-medium text-slate-600",children:[x.percentDone,"% done"]})]})]})}function r0({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 s0={federal:"Schedule federal tax deposits directly to the IRS — EFTPS payments, 941, 940, and more.",state:"Submit state tax remittances to the relevant state authority on time, every time.",local:"Local tax payment support is coming soon. Stay tuned for updates."},a0=[{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"}],rn=new Date().getFullYear(),fa=[rn,rn-1,rn-2],i0=[{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:"Rejected",key:"failed",dotClassName:"bg-red-400"}],o0=[{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:"Rejected",key:"failed",dotClassName:"bg-red-400"}],l0=[{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:"Rejected",key:"failed",dotClassName:"bg-red-400"}];function Ui(){const e=ke(),{entities:t,selectedEntity:n,enabledPayments:r}=zn(),a=(n==null?void 0:n.entityId)??null,{data:i,isLoading:o}=ge({queryKey:["dashboard",a,rn],queryFn:()=>kb(a,rn),enabled:a!==null});return!o&&i&&!i.hasPayments?s.jsxs("div",{className:"space-y-6",children:[s.jsx(hl,{entityCount:t.length,showPaymentActions:!1}),s.jsx("div",{className:"grid gap-6 sm:grid-cols-2 xl:grid-cols-3",children:a0.filter(l=>l.key==="local"||r.includes(l.key)).map(l=>s.jsx(Tb,{title:l.title,description:s0[l.key],buttonLabel:l.buttonLabel,onAdd:l.key==="federal"?()=>e("/payments/federal/new",{state:{from:"/dashboard"}}):l.key==="state"?()=>e("/payments/state/new",{state:{from:"/dashboard",resetDraft:!0}}):void 0,comingSoon:l.key==="local"},l.key))})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsx(hl,{entityCount:t.length}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2 xl:grid-cols-3",children:[r.includes("federal")&&s.jsx(ha,{entityId:a,category:"federal",title:"Federal Payments",subtitlePrefix:"IRS & Federal agencies",defaultTaxYear:rn,taxYearOptions:fa,initialSummary:i==null?void 0:i.federal,isDashboardLoading:o,stats:i0}),r.includes("state")&&s.jsx(ha,{entityId:a,category:"state",title:"All State Payments",subtitlePrefix:"State tax authorities",defaultTaxYear:rn,taxYearOptions:fa,initialSummary:i==null?void 0:i.state,isDashboardLoading:o,stats:o0}),s.jsx(ha,{entityId:a,category:"local",title:"Local Payments",subtitlePrefix:"Local tax authorities",defaultTaxYear:rn,taxYearOptions:fa,initialSummary:i==null?void 0:i.local,isDashboardLoading:o,stats:l0,comingSoon:!0})]}),s.jsx(zb,{entityId:a,initialOverview:i==null?void 0:i.monthlyOverview,isDashboardLoading:o}),s.jsx(e0,{entityId:a,initialPayments:i==null?void 0:i.payments,isDashboardLoading:o})]})}const yl=160,c0=48,ls=8;function u0({entity:e,onEdit:t}){const n=v.useRef(null),r=v.useRef(null),[a,i]=v.useState(!1),[o,l]=v.useState({}),c=()=>{var g;const d=n.current;if(!d)return;const u=d.getBoundingClientRect(),m=((g=r.current)==null?void 0:g.offsetHeight)??c0,p=window.innerHeight-u.bottom<m+ls;l({position:"fixed",top:p?u.top-m-ls:u.bottom+ls,left:Math.max(ls,u.right-yl),width:yl,zIndex:50})};return v.useLayoutEffect(()=>{a&&(c(),requestAnimationFrame(c))},[a]),v.useEffect(()=>{if(!a)return;const d=m=>{var p,g;const h=m.target;(p=n.current)!=null&&p.contains(h)||(g=r.current)!=null&&g.contains(h)||i(!1)},u=()=>c();return document.addEventListener("mousedown",d),window.addEventListener("resize",u),window.addEventListener("scroll",u,!0),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0)}},[a]),s.jsxs("div",{className:"inline-block text-left",children:[s.jsxs("button",{ref:n,type:"button",onClick:()=>i(d=>!d),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(d0,{})]}),a?qr.createPortal(s.jsx("div",{ref:r,style:o,className:"overflow-hidden rounded-lg border border-slate-200 bg-white py-1 shadow-lg",children:s.jsx("button",{type:"button",onClick:()=>{i(!1),t(e)},className:"block w-full px-4 py-2 text-left text-sm text-slate-700 hover:bg-slate-50",children:"Edit"})}),document.body):null]})}function d0(){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 m0(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 21h18M5 21V6a1 1 0 011-1h4a1 1 0 011 1v15m0 0V3a1 1 0 011-1h4a1 1 0 011 1v18M9 9h.01M9 12h.01M9 15h.01"})})}function h0(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",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 Su({open:e,entity:t,onClose:n}){var Y,V,Z,ie,G,Q,we,Ae,$e,ce,pe,$,fe;const r=ft(),[a,i]=v.useState(null),[o,l]=v.useState(!1),{register:c,handleSubmit:d,watch:u,reset:m,setValue:h,getValues:p,formState:{errors:g}}=Rt({resolver:Lt(vu),defaultValues:ml(t),shouldUnregister:!1}),x=u("accountType"),b=u("entityType"),y=x==="Individual"?gu:xu,C=x==="Individual"?"SSN":"EIN",j=u("country"),S=u("state"),I=u("zipCode"),R=j==="United States",E=qi(j),T=S.length>0&&I.trim().length>0&&!cr(E,S,I),L=c("phoneNumber"),B=c("zipCode");v.useEffect(()=>{S&&E.length>0&&!E.some(O=>O.code===S)&&h("state","")},[j,E]);const K=O=>{const ue=p("accountType");if(ue===O)return;const Te=p("lastName");ju(ue,O,h,Te),h("accountType",O),queueMicrotask(()=>{h("lastName",Te),h("firstName",""),ue==="Business"&&O==="Individual"&&h("tradeName","")})};v.useEffect(()=>{if(e){const O=ml(t);m(O),i(null)}},[t,e,m]),v.useEffect(()=>{if(!e)return;const O=ue=>{ue.key==="Escape"&&n()};return document.addEventListener("keydown",O),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",O),document.body.style.overflow=""}},[e,n]),v.useEffect(()=>{y.includes(b)||h("entityType",x==="Individual"?"Sole Proprietorship":"LLP")},[x,b,y,h]);const X=d(async O=>{if(i(null),!cr(E,O.state,O.zipCode)){i(`ZIP code does not match the selected state (${O.state}).`);return}l(!0);try{await ef(t.entityId,bb(O)),await r.invalidateQueries({queryKey:["entities","mine"]}),n()}catch(ue){i(nt(ue,"Unable to update entity. Please try again."))}finally{l(!1)}});return e?qr.createPortal(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:n}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"edit-entity-title",className:"relative z-10 flex max-h-[90vh] w-full max-w-4xl flex-col overflow-hidden rounded-2xl bg-white shadow-xl",children:[s.jsxs("div",{className:"border-b border-slate-200 px-6 py-5",children:[s.jsx("h2",{id:"edit-entity-title",className:"text-lg font-bold text-slate-900",children:"Edit Entity"}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Update your entity profile details."})]}),s.jsxs("form",{onSubmit:X,noValidate:!0,className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"overflow-y-auto px-6 py-6",children:[a?s.jsx("div",{className:"mb-5",children:s.jsx(Ot,{message:a})}):null,s.jsx("input",{type:"hidden",...c("ein")}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Ts,{step:1,title:"Basic Information",subtitle:"Enter the primary details for this entity.",children:[s.jsx(lu,{label:"Account Type",required:!0,value:x,onChange:K,options:[{label:"Business",value:"Business",icon:s.jsx(m0,{})},{label:"Individual",value:"Individual",icon:s.jsx(h0,{})}]}),s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:x==="Individual"?s.jsxs(s.Fragment,{children:[s.jsx(he,{label:"First name",required:!0,maxLength:100,placeholder:"Enter first name",error:(Y=g.firstName)==null?void 0:Y.message,...c("firstName")},"entity-first-name"),s.jsx(he,{label:"Last name",required:!0,maxLength:100,placeholder:"Enter last name",error:(V=g.lastName)==null?void 0:V.message,...c("lastName")},"entity-last-name")]}):s.jsxs(s.Fragment,{children:[s.jsx(he,{label:"Business Name",required:!0,maxLength:150,placeholder:"Enter business name",error:(Z=g.lastName)==null?void 0:Z.message,...c("lastName")},"entity-business-name"),s.jsx(he,{label:"Trade Name, if any",maxLength:150,placeholder:"Enter trade name (optional)",error:(ie=g.tradeName)==null?void 0:ie.message,...c("tradeName")},"entity-trade-name")]})}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:C,required:!0,readOnly:!0,value:Hr(t.idNumber,x),className:"cursor-default bg-[#F9FAFB] text-slate-700"}),s.jsx(xn,{label:"Entity Type",required:!0,error:(G=g.entityType)==null?void 0:G.message,...c("entityType"),children:y.map(O=>s.jsx("option",{value:O,children:O},O))})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:"Email ID",required:!0,type:"email",maxLength:254,placeholder:"sample@mail.com",error:(Q=g.email)==null?void 0:Q.message,...c("email")}),s.jsx(cu,{required:!0,error:(we=g.phoneNumber)==null?void 0:we.message,countryCodeSelectProps:c("countryCode"),phoneInputProps:{placeholder:"Enter 10-digit phone number",maxLength:10,...L,onChange:O=>{O.target.value=O.target.value.replace(/\D/g,"").slice(0,10),L.onChange(O)}}})]})]}),s.jsxs(Ts,{step:2,title:"Address Information",subtitle:"Enter the registered address.",children:[s.jsx(he,{label:"Address Line 1",required:!0,maxLength:200,placeholder:"Enter address line 1",error:(Ae=g.address1)==null?void 0:Ae.message,...c("address1")}),s.jsx(he,{label:"Address Line 2",maxLength:200,placeholder:"Enter address line 2 (optional)",error:($e=g.address2)==null?void 0:$e.message,...c("address2")}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:"City",required:!0,maxLength:100,placeholder:"Enter city",error:(ce=g.city)==null?void 0:ce.message,...c("city")}),s.jsxs(xn,{label:R?"State":"Province",required:!0,error:(pe=g.state)==null?void 0:pe.message,...c("state"),children:[s.jsx("option",{value:"",children:R?"Select state":"Select province"}),E.map(O=>s.jsx("option",{value:O.code,children:O.name},O.code))]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:R?"ZIP Code":"Postal Code",required:!0,maxLength:10,placeholder:R?"12345 or 12345-6789":"A1A 1A1",error:(($=g.zipCode)==null?void 0:$.message)??(T?`ZIP code does not match the selected state (${S}).`:void 0),...B,onChange:O=>{O.target.value=R?Mi(O.target.value):bu(O.target.value),B.onChange(O)}}),s.jsxs(xn,{label:"Country",required:!0,error:(fe=g.country)==null?void 0:fe.message,...c("country"),children:[s.jsx("option",{value:"United States",children:"United States"}),s.jsx("option",{value:"Canada",children:"Canada"})]})]})]})]})]}),s.jsx(uu,{className:"px-6",onCancel:n,isSubmitting:o,submitLabel:"Save Changes",submittingLabel:"Saving…"})]})]})]}),document.body):null}function Zi(){const{selectedEntity:e}=zn(),t=ke(),[n,r]=v.useState(""),[a,i]=v.useState(""),[o,l]=v.useState(1),[c,d]=v.useState(it),[u,m]=v.useState(null);v.useEffect(()=>{const j=window.setTimeout(()=>i(n.trim()),300);return()=>window.clearTimeout(j)},[n]),v.useEffect(()=>{l(1)},[a,c]);const{data:h,isLoading:p,isFetching:g,isError:x}=ge({queryKey:["entities","mine","paged",a,o,c],queryFn:()=>bi({search:a||void 0,pageNumber:o,pageSize:c}),placeholderData:j=>j}),b=(h==null?void 0:h.items)??[],y=(h==null?void 0:h.totalCount)??0,C=g;return s.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[s.jsxs("button",{type:"button",onClick:()=>t("/dashboard"),className:"inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm font-medium text-slate-600 transition hover:bg-white hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#156bd5]",children:[s.jsx(p0,{}),"Back"]}),s.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>t("/create-entity/form",{state:{from:"/entities"}}),className:"inline-flex shrink-0 items-center gap-2 rounded-[14px] bg-[#156bd5] px-4 py-2 text-sm font-semibold text-white transition hover:bg-[#1260be]",children:[s.jsx(x0,{}),"Add Entity"]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-[11px] font-semibold text-[#6a7282]",children:"Search by Entity Name/Email/EIN"}),s.jsx("input",{type:"search",value:n,onChange:j=>r(j.target.value),placeholder:"All",className:"h-9.5 w-55 rounded-lg border-2 border-slate-400 bg-[#f9fafb] px-3 text-sm text-slate-700 placeholder-[#99a1af] focus:border-[#156bd5] focus:outline-none"})]})]}),u?s.jsx(Su,{open:!0,entity:u,onClose:()=>m(null)}):null,s.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-black/[0.12] bg-white",children:[C?s.jsx(yr,{label:"Loading organizations…"}):null,s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"min-w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#f8f9fb]",children:[s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Entity Name"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"EIN / SSN"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Email"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Phone"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Business Type"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Status"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Joined Date"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Action"})]})}),s.jsx("tbody",{children:p&&!h?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:"Loading organizations…"})}):x?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:"Unable to load organizations."})}):b.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:a?"No organizations match your search.":"No organizations yet."})}):b.map(j=>s.jsx(f0,{entity:j,isSelected:j.entityId===(e==null?void 0:e.entityId),onEdit:m},j.entityId))})]})}),s.jsx(Qr,{page:o,pageSize:c,totalCount:y,onPageChange:l,onPageSizeChange:d,disabled:p||g})]})]})}function f0({entity:e,isSelected:t,onEdit:n}){var l;const r=en(e),a=Oi(r),i=((l=e.status)==null?void 0:l.toLowerCase())==="active",o=e.createdAt?new Date(e.createdAt).toISOString().slice(0,10):"—";return s.jsxs("tr",{className:["border-b border-[#e0e0e0] last:border-b-0 transition-colors",t?"bg-[#f0f7ff]":"hover:bg-slate-50"].join(" "),children:[s.jsx("td",{className:"px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-[10px] bg-[#156bd5] text-[11px] font-bold text-white",children:a}),s.jsx("span",{className:"font-semibold text-[#1e2939] text-[13px]",children:r})]})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"font-mono text-[12px] text-[#374151]",children:Hr(e.idNumber,e.accountType)})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"text-[12px] text-[#374151]",children:e.email||"—"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"text-[12px] text-[#374151]",children:e.phoneNumber||"—"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"text-[12px] text-[#374151]",children:e.entityType||"—"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:["inline-flex items-center rounded-full px-2 py-0.5 text-[11px]",i?"bg-[#e1f6da] text-[#010d1d]":"bg-[#feeceb] text-[#010d1d]"].join(" "),children:i?"Active":"In-active"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"text-[12px] text-[#374151]",children:o})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx(u0,{entity:e,onEdit:n})})]})}function p0(){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"})})}function x0(){return s.jsx("svg",{className:"h-[15px] w-[15px]",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 Wi(e){return de(`/portal/federal-payments/${e}`)}function g0(e){return de(`/portal/federal-payments/form-types?entityId=${e}`)}function y0(e){const t=new URLSearchParams({formType:e});return de(`/portal/federal-payments/tax-type-codes?${t.toString()}`)}function Yi(e){return de("/portal/federal-payments",{method:"POST",body:e})}function Hi(e,t){return de(`/portal/federal-payments/${e}`,{method:"PATCH",body:t})}function b0(e){return de(`/portal/federal-payments/${e}/submit`,{method:"POST"})}function v0(e){return Ur(`/portal/federal-payments/${e}/pdf`,{responseType:"blob"})}function j0(e){return Ur(`/portal/state-payments/${e}/pdf`,{responseType:"blob"})}function w0(e){return Ur(`/portal/federal-payments/${e}/pdf-html`,{responseType:"text"})}function N0(e){return Ur(`/portal/state-payments/${e}/pdf-html`,{responseType:"text"})}function S0({entityId:e,status:t,category:n="all",pageNumber:r=1,pageSize:a=it}){const i=new URLSearchParams({entityId:String(e),pageNumber:String(r),pageSize:String(a)});return t&&i.set("status",t),n&&n!=="all"?i.set("category",n):n==="all"&&i.set("category","all"),de(`/portal/remittance-payments?${i}`)}function k0(e,t="all"){const n=new URLSearchParams({entityId:String(e)});return t&&n.set("category",t),de(`/portal/remittance-payments/status-counts?${n}`)}function C0(e){return de("/portal/state-payments/states",{signal:e})}function A0(e,t,n){const r=new URLSearchParams({entityId:String(e),state:t});return de(`/portal/state-payments/payment-reasons?${r}`,{signal:n})}function P0(e,t,n,r){const a=new URLSearchParams({entityId:String(e),state:t,reason:n});return de(`/portal/state-payments/validation-metadata?${a}`,{signal:r})}function E0(e,t,n,r){const a=new URLSearchParams({entityId:String(e),state:t,reason:n});return de(`/portal/state-payments/form-references?${a}`,{signal:r})}function ku(e){return de(`/portal/state-payments/${e}`)}function I0(e){return de("/portal/state-payments",{method:"POST",body:e})}function T0(e,t){return de(`/portal/state-payments/${e}`,{method:"PATCH",body:t})}function _0(e){return de(`/portal/state-payments/${e}/submit`,{method:"POST"})}function D0({open:e,title:t,html:n,isLoading:r=!1,error:a=null,downloadFileName:i="payment.pdf",onDownload:o,onClose:l}){const[c,d]=v.useState(!1);v.useEffect(()=>{if(!e)return;const m=h=>{h.key==="Escape"&&l()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[e,l]);const u=async()=>{if(!(!o||c)){d(!0);try{const m=await o(),h=URL.createObjectURL(m),p=document.createElement("a");p.href=h,p.download=i,document.body.appendChild(p),p.click(),document.body.removeChild(p),setTimeout(()=>URL.revokeObjectURL(h),1e3)}finally{d(!1)}}};return e?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:l}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"payment-pdf-title",className:"relative flex h-[90vh] w-full max-w-5xl flex-col overflow-hidden rounded-2xl bg-white shadow-xl",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-slate-200 px-5 py-4",children:[s.jsx("h2",{id:"payment-pdf-title",className:"text-base font-semibold text-slate-900",children:t}),s.jsxs("div",{className:"flex items-center gap-2",children:[o?s.jsx("button",{type:"button",onClick:()=>void u(),disabled:c||r||!!a,className:"rounded-lg border border-gov-200 bg-gov-50 px-3 py-1.5 text-sm font-medium text-gov-600 hover:bg-gov-100 disabled:opacity-60",children:c?"Downloading…":"Download"}):null,s.jsx("button",{type:"button",onClick:l,className:"rounded-lg border border-slate-200 px-3 py-1.5 text-sm font-medium text-slate-600 hover:bg-slate-50",children:"Close"})]})]}),s.jsx("div",{className:"flex-1 overflow-hidden bg-white",children:r?s.jsx("div",{className:"flex h-full items-center justify-center text-sm text-slate-500",children:"Loading…"}):a?s.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-red-600",children:a}):n?s.jsx("iframe",{title:t,srcDoc:n,sandbox:"",className:"h-full w-full border-0 bg-white"}):s.jsx("div",{className:"flex h-full items-center justify-center text-sm text-slate-500",children:"No content available."})})]})]}):null}function pa({onViewPdf:e,isViewPdfLoading:t}){return s.jsx("button",{type:"button",onClick:e,disabled:t,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 disabled:opacity-60",children:t?"Loading…":"View PDF"})}function F0({actionType:e,onView:t,onViewPdf:n,onEdit:r,onSubmit:a,isSubmitting:i=!1,isViewPdfLoading:o=!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:a,disabled:i,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:i?"Submitting…":"Submit"})]}):e==="view-pdf"?s.jsx(pa,{onViewPdf:n,isViewPdfLoading:o}):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(pa,{onViewPdf:n,isViewPdfLoading:o}),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.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(pa,{onViewPdf:n,isViewPdfLoading:o})]})}function R0(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 n=e.slice(0,4),r=Number.parseInt(e.slice(4,6),10);return Number.isNaN(r)||r<1||r>12?e:`Q${Math.ceil(r/3)} ${n}`}function $0(e){return{id:e.id,category:e.category,referenceNo:e.referenceNumber??"—",jurisdiction:e.jurisdiction,period:R0(e.taxPeriod),amount:e.amount,paymentDate:e.paymentDate,status:e.status,reason:e.reason,tab:Rb(e.status)}}function L0({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 O0({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 z0({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 M0({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 q0({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 Cu=[{key:"drafts",label:"DRAFTS",Icon:L0,iconClassName:"text-gray-500"},{key:"scheduled",label:"SCHEDULED",Icon:O0,iconClassName:"text-yellow-500"},{key:"submitted",label:"SUBMITTED TO FED/STATE",Icon:z0,iconClassName:"text-[#FF733D]"},{key:"rejected",label:"REJECTED",Icon:M0,iconClassName:"text-red-500"},{key:"paid",label:"PAID",Icon:q0,iconClassName:"text-green-500"}],B0={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","Rejected 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"}};function bl(e){return e!==null&&Cu.some(t=>t.key===e)}function Ki({paymentsMode:e="all"}){var pe;const t=ke(),n=ft(),[r]=Ym(),{selectedEntity:a}=ht(),{onPaymentRequired:i}=zn(),o=(a==null?void 0:a.entityId)??null,l=r.get("tab"),[c,d]=v.useState(bl(l)?l:Vi),[u,m]=v.useState(e==="all"?"all":e),h=e!=="all"?e:u,[p,g]=v.useState(1),[x,b]=v.useState(it),[y,C]=v.useState(null),[j,S]=v.useState(null),[I,R]=v.useState(null);v.useEffect(()=>{bl(l)&&d(l)},[l]),v.useEffect(()=>{g(1),b(it)},[c,o,u]),v.useEffect(()=>{g(1)},[x]);const E=B0[c],T=ge({queryKey:["remittance-payments","list",o,c,h,p,x],queryFn:()=>S0({entityId:o,status:c,category:h,pageNumber:p,pageSize:x}),enabled:o!==null,placeholderData:$=>$}),L=ge({queryKey:["remittance-payments","status-counts",o,h],queryFn:()=>k0(o,h),enabled:o!==null}),B=T.isLoading,K=T.isFetching,X=o!==null&&K,Y=v.useMemo(()=>{var $,fe,O,ue,Te;return{drafts:(($=L.data)==null?void 0:$.drafts)??0,scheduled:((fe=L.data)==null?void 0:fe.scheduled)??0,submitted:((O=L.data)==null?void 0:O.submitted)??0,rejected:((ue=L.data)==null?void 0:ue.rejected)??0,paid:((Te=L.data)==null?void 0:Te.paid)??0}},[L.data]),V=v.useMemo(()=>{var $;return((($=T.data)==null?void 0:$.items)??[]).map($0)},[T.data]),Z=((pe=T.data)==null?void 0:pe.totalCount)??0,ie=Lh({mutationFn:async $=>{try{$.category==="federal"?await b0($.id):await _0($.id)}catch(fe){if(fe instanceof xr&&fe.status===402&&i){const O=fe.extensions,ue={paymentType:(O==null?void 0:O.paymentType)??$.category,paymentId:(O==null?void 0:O.paymentId)??$.id,expectedAmount:(O==null?void 0:O.expectedAmount)??"0.00",currency:(O==null?void 0:O.currency)??"USD",federalRecordCount:(O==null?void 0:O.federalRecordCount)??0,stateRecordCount:(O==null?void 0:O.stateRecordCount)??0,feePerFederal:(O==null?void 0:O.feePerFederal)??null,feePerState:(O==null?void 0:O.feePerState)??null};i(ue);return}throw fe}},onSuccess:async()=>{await n.invalidateQueries({queryKey:["remittance-payments"]}),await n.invalidateQueries({queryKey:["dashboard"]}),await n.invalidateQueries({queryKey:["federal-payments"]}),await n.invalidateQueries({queryKey:["state-payments"]})},onError:()=>C(null),onSettled:()=>C(null)});v.useEffect(()=>{const $=async()=>{await n.invalidateQueries({queryKey:["remittance-payments"]}),await n.invalidateQueries({queryKey:["dashboard"]}),await n.invalidateQueries({queryKey:["federal-payments"]}),await n.invalidateQueries({queryKey:["state-payments"]})};return window.addEventListener(ai,$),()=>window.removeEventListener(ai,$)},[n]);const G=$=>{C(`${$.category}-${$.id}`),ie.mutate($)},Q=$=>{$.category==="federal"?t(`/payments/federal/${$.id}/view`):t(`/payments/state/${$.id}/view`)},we=$=>{$.category==="federal"?t(`/payments/federal/${$.id}/edit`):t(`/payments/state/${$.id}/edit`)},Ae=async $=>{const fe=`${$.category}-${$.id}`,O=`payment-${$.referenceNo}.pdf`;S(fe),R({title:`Payment PDF — ${$.referenceNo}`,html:null,category:$.category,paymentId:$.id,downloadFileName:O,isLoading:!0,error:null});try{const ue=$.category==="federal"?await w0($.id):await N0($.id);R({title:`Payment PDF — ${$.referenceNo}`,html:ue,category:$.category,paymentId:$.id,downloadFileName:O,isLoading:!1,error:null})}catch(ue){R({title:`Payment PDF — ${$.referenceNo}`,html:null,category:$.category,paymentId:$.id,downloadFileName:O,isLoading:!1,error:nt(ue,"Unable to load payment PDF.")})}finally{S(null)}},$e=async()=>{if(!I)throw new Error("No payment selected");return I.category==="federal"?v0(I.paymentId):j0(I.paymentId)},ce=()=>R(null);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(xa,{}),"Add Federal Payment"]}),e!=="federal"&&s.jsxs("button",{type:"button",onClick:()=>t("/payments/state/new",{state:{from:"/payments",resetDraft:!0}}),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(xa,{}),"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(xa,{}),"Add Local Payments",s.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),s.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[X?s.jsx(yr,{label:"Loading payments…"}):null,s.jsx("div",{className:"flex flex-wrap gap-1 border-b border-slate-200 px-4 pt-4",children:Cu.map($=>{const fe=c===$.key,O=$.Icon;return s.jsxs("button",{type:"button",onClick:()=>{d($.key),t(ea($.key),{replace:!0})},className:`mb-[-1px] flex items-center gap-2 border-b-2 px-4 py-3 text-xs font-semibold tracking-wide transition ${fe?"border-gov-600 text-gov-600":"border-transparent text-slate-500 hover:text-slate-700"}`,children:[s.jsx(O,{className:`shrink-0 ${$.iconClassName}`}),$.label," (",Y[$.key],")"]},$.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:$=>m($.target.value),disabled:e!=="all",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 disabled:opacity-60",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:E.columns.map($=>s.jsx("th",{className:"px-6 py-3",children:$},$))})}),s.jsx("tbody",{children:B&&!T.data?s.jsx("tr",{children:s.jsx("td",{colSpan:E.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:E.columns.length,className:"px-6 py-12 text-center text-slate-500",children:E.emptyMessage})}):V.map($=>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:c==="drafts"?`#${$.id}`:$.referenceNo}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:$.jurisdiction}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:$.period}),s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Kr($.amount)}),c!=="paid"?s.jsx("td",{className:"px-6 py-4 text-slate-700",children:$.paymentDate}):null,c==="rejected"?s.jsx("td",{className:"px-6 py-4 text-slate-700",children:$.reason??"—"}):null,s.jsx("td",{className:"px-6 py-4",children:s.jsx(F0,{actionType:E.actionType,onView:()=>Q($),onViewPdf:()=>Ae($),onEdit:()=>we($),onSubmit:()=>G($),isSubmitting:y===`${$.category}-${$.id}`,isViewPdfLoading:j===`${$.category}-${$.id}`})})]},`${$.category}-${$.id}`))})]})}),s.jsx(Qr,{page:p,pageSize:x,totalCount:Z,onPageChange:g,onPageSizeChange:b,disabled:B||o===null||K})]}),s.jsx(D0,{open:I!==null,title:(I==null?void 0:I.title)??"Payment PDF",html:(I==null?void 0:I.html)??null,downloadFileName:I==null?void 0:I.downloadFileName,isLoading:(I==null?void 0:I.isLoading)??!1,error:(I==null?void 0:I.error)??null,onDownload:I&&!I.error?$e:void 0,onClose:ce})]})}function xa(){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 Jr({entityId:e,pageNumber:t=1,pageSize:n=it}){const r=new URLSearchParams({entityId:String(e),pageNumber:String(t),pageSize:String(n)});return de(`/portal/bank-accounts?${r}`)}function V0(e){return de("/portal/bank-accounts",{method:"POST",body:e})}function Au(e,t){return de(`/portal/bank-accounts/${e}`,{method:"PATCH",body:t})}function wn({title:e,children:t,isFirst:n=!1,headerAction:r}){return s.jsxs("section",{className:n?"":"mt-8 border-t border-slate-100 pt-8",children:[s.jsxs("div",{className:"mb-5 flex flex-wrap items-center justify-between gap-3",children:[s.jsx("h3",{className:"text-base font-semibold text-gov-600",children:e}),r]}),t]})}const ur=17,Pu=9;function Yn(e,t){return e.replace(/\D/g,"").slice(0,t)}const Eu=["Checking","Savings"],U0=Xt({accountNumber:D().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${ur} digits`),confirmAccountNumber:D().min(1,"Please confirm the account number").regex(/^\d{1,17}$/,`Account number must be 1 to ${ur} digits`),routingNumber:D().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Xs(Eu,{message:"Account type is required"}),bankName:D().min(1,"Bank name is required")}).refine(e=>e.accountNumber===e.confirmAccountNumber,{message:"Account numbers do not match",path:["confirmAccountNumber"]});function Z0({entityId:e,onCancel:t,onSuccess:n}){const r=ft(),{showSuccess:a,showError:i}=Vs(),[o,l]=v.useState(null),[c,d]=v.useState(!1),{control:u,handleSubmit:m,formState:{errors:h}}=Rt({resolver:Lt(U0),defaultValues:{accountNumber:"",confirmAccountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}}),p=m(async g=>{l(null),d(!0);try{const x=await V0({entityId:e,bankName:g.bankName.trim(),accountNumber:g.accountNumber,routingNumber:g.routingNumber,accountType:g.accountType});await r.invalidateQueries({queryKey:["bank-accounts",e]}),a("Bank Account Added","Bank account added successfully."),n(x.bankAccountDetailId)}catch(x){const b=nt(x,"Unable to save bank account.");l(b),i("Action Not Completed",b)}finally{d(!1)}});return s.jsxs("form",{noValidate:!0,onSubmit:g=>{g.preventDefault(),g.stopPropagation(),p(g)},className:"space-y-6",children:[s.jsxs(ou,{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(Ne,{name:"accountNumber",control:u,render:({field:g})=>{var x;return s.jsx(he,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:g.value,onChange:b=>g.onChange(Yn(b.target.value,ur)),onBlur:g.onBlur,error:(x=h.accountNumber)==null?void 0:x.message})}}),s.jsx(Ne,{name:"confirmAccountNumber",control:u,render:({field:g})=>{var x;return s.jsx(he,{label:"Confirm Account Number",required:!0,placeholder:"Re-enter account number",inputMode:"numeric",autoComplete:"off",value:g.value,onChange:b=>g.onChange(Yn(b.target.value,ur)),onBlur:g.onBlur,error:(x=h.confirmAccountNumber)==null?void 0:x.message})}}),s.jsx(Ne,{name:"routingNumber",control:u,render:({field:g})=>{var x;return s.jsx(he,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:g.value,onChange:b=>g.onChange(Yn(b.target.value,Pu)),onBlur:g.onBlur,error:(x=h.routingNumber)==null?void 0:x.message})}}),s.jsx(Ne,{name:"accountType",control:u,render:({field:g})=>{var x;return s.jsx(xn,{label:"Account Type",required:!0,value:g.value,onChange:g.onChange,onBlur:g.onBlur,error:(x=h.accountType)==null?void 0:x.message,children:Eu.map(b=>s.jsx("option",{value:b,children:b},b))})}})]}),s.jsx(Ne,{name:"bankName",control:u,render:({field:g})=>{var x;return s.jsx(he,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:g.value,onChange:g.onChange,onBlur:g.onBlur,error:(x=h.bankName)==null?void 0:x.message})}})]}),o?s.jsx(Ot,{message:o}):null,s.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.jsx("button",{type:"button",onClick:t,disabled:c,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:"button",disabled:c,onClick:()=>void p(),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:c?"Saving…":"Save"})]})]})}function Iu({open:e,entityId:t,onClose:n,onAccountAdded:r}){const[a,i]=v.useState("choose");if(v.useEffect(()=>{e||i("choose")},[e]),v.useEffect(()=>{if(!e)return;const l=c=>{c.key==="Escape"&&n()};return document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l)}},[e,n]),!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:n}),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(Z0,{entityId:t,onCancel:()=>i("choose"),onSuccess:l=>{r==null||r(l),n()}}):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(W0,{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(Y0,{className:"h-6 w-6"})}),s.jsx("span",{className:"text-base font-medium text-slate-400",children:"Connect with Plaid"})]})]})]})})]})}function W0({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 Y0({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 H0=12,K0=["January","February","March","April","May","June","July","August","September","October","November","December"];function fn(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${r}`}function _s(e){const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;const n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10)-1,a=Number.parseInt(t[3],10),i=new Date(n,r,a);return i.getFullYear()!==n||i.getMonth()!==r||i.getDate()!==a?null:i}function Tu(e=new Date){const t=new Date(e);return e.getHours()>=H0&&t.setDate(t.getDate()+1),t.setHours(0,0,0,0),fn(t)}function _u(e=new Date){const t=new Date(e);return t.setFullYear(t.getFullYear()+1),t.setHours(0,0,0,0),fn(t)}function Q0(e=18,t=new Date){const n=new Date(t);return n.setFullYear(n.getFullYear()-e),n.setHours(0,0,0,0),fn(n)}function J0(e,t,n=new Date){const r=_s(e);if(!r)return!1;const a=new Date(n);return a.setFullYear(a.getFullYear()-t),a.setHours(0,0,0,0),r.setHours(0,0,0,0),r<=a}function G0(e){const t=e.getDay();return t!==0&&t!==6}function ei(e,t=new Date){if(!G0(e))return!1;const n=fn(e);return n>=Tu(t)&&n<=_u(t)}function ta(e,t=new Date){const n=_s(e);return n?ei(n,t):!1}function X0(e,t){return`${K0[t]} ${e}`}function ev(e,t){const n=new Date(e,t,1),r=new Date(e,t+1,0).getDate(),a=n.getDay(),i=[];for(let o=0;o<a;o+=1)i.push(null);for(let o=1;o<=r;o+=1)i.push(new Date(e,t,o));return i}function vl(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function Gr(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 Du({label:e,required:t=!1,htmlFor:n,info:r}){return s.jsxs("label",{htmlFor:n,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]}),r?s.jsxs("span",{className:"group relative inline-flex items-center",children:[s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 cursor-help items-center justify-center rounded-full border border-slate-300 text-[10px] font-semibold leading-none text-slate-400","aria-label":r,role:"img",children:"i"}),s.jsx("span",{role:"tooltip",className:"pointer-events-none absolute bottom-full left-1/2 z-20 mb-1.5 w-max max-w-xs -translate-x-1/2 rounded-md bg-slate-800 px-2.5 py-1.5 text-xs font-normal leading-snug text-white opacity-0 shadow-lg transition-opacity duration-150 group-hover:opacity-100",children:r})]}):null]})}function J({label:e,required:t,error:n,info:r,children:a}){return s.jsxs("div",{children:[s.jsx(Du,{label:e,required:t,info:r}),a,n?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:n}):null]})}const Fu=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 ne(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]"}`:Fu(e)}function Hn(e){return`${Fu(e)} appearance-none`}function Un({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 Tr({children:e}){return s.jsx("div",{className:"relative",children:e})}function Ru({value:e,onChange:t,entityId:n,bankAccounts:r,isLoading:a=!1,disabled:i=!1,error:o,label:l="Bank Account Number",info:c}){const[d,u]=v.useState(!1),[m,h]=v.useState(!1),p=v.useRef(null),g=r.find(b=>String(b.bankAccountDetailId)===e);v.useEffect(()=>{if(!d)return;const b=y=>{var C;(C=p.current)!=null&&C.contains(y.target)||u(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[d]);const x=b=>{t(String(b)),h(!1),u(!1)};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{ref:p,className:"relative",children:[s.jsx(Du,{label:l,required:!0,info:c}),s.jsxs("button",{type:"button",disabled:i||!n,onClick:()=>u(b=>!b),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 ${o?"border-red-300":"border-slate-200"}`,children:[s.jsx("span",{className:g?"text-slate-900":"text-slate-400",children:a?"Loading accounts…":g?vl(g.accountNumber):"Bank account number"}),s.jsx(nv,{className:`shrink-0 text-slate-400 transition ${d?"rotate-180":""}`})]}),o?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:o}):null,d?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:()=>{u(!1),h(!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(tv,{}),"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:r.length===0?s.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No bank accounts yet."}):r.map(b=>{const y=String(b.bankAccountDetailId)===e;return s.jsxs("button",{type:"button",onClick:()=>{t(String(b.bankAccountDetailId)),u(!1)},className:`flex w-full items-center gap-3 px-4 py-3 text-left transition hover:bg-slate-50 ${y?"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:Oi(b.bankName)}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate text-sm font-semibold text-slate-900",children:b.bankName}),s.jsxs("span",{className:"block truncate text-xs text-slate-500",children:[vl(b.accountNumber)," · ",b.accountType]})]})]},b.bankAccountDetailId)})})]}):null]}),s.jsx(Iu,{open:m,entityId:n,onClose:()=>h(!1),onAccountAdded:x})]})}function tv(){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 nv({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 rv(e){const t=e.address2?`, ${e.address2}`:"";return`${e.address1}${t}, ${e.city}, ${e.state} ${e.zipCode}`}function Xr({entity:e,remittanceAmount:t="—",className:n=""}){if(!e)return s.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${n}`,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 r=en(e);return s.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${n}`,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(Sr,{label:"Entity Name",value:r}),s.jsx(Sr,{label:e.accountType==="Individual"?"SSN":"Tax ID",value:Hr(e.idNumber,e.accountType)}),s.jsx(Sr,{label:"Email ID",value:e.email}),s.jsx(Sr,{label:"Phone Number",value:$n(e.phoneNumber)}),s.jsx(Sr,{label:"Address",value:rv(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 Sr({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 sv=[0,1,3,4,6,7,9,10],av=[0,1,2,3,4,5,6,7,8,9,10],iv=[0,1,2,3,4,5,6,8,9,10,11],ov=[0,1,2,3,4,5,6,7,9,10,11],lv=["720","941"],cv=["706-GS (D)","706-GS (T)","926","940","943","944","945","1042","2438","3520","6069","8752","CT-1"],uv=["7200D"],dv=["8963"];function $u(e){return lv.includes(e)?sv:cv.includes(e)?av:uv.includes(e)?iv:dv.includes(e)?ov:[]}function mv(e){return e.length!==6?"":`${e.slice(0,4)}-${e.slice(4,6)}`}function Ds(e){if(e.length!==6)return null;const t=Number.parseInt(e.slice(0,4),10),n=Number.parseInt(e.slice(4,6),10);return Number.isNaN(t)||Number.isNaN(n)||n<1||n>12?null:{year:t,month:n-1}}function hv(e,t){return`${e}${String(t+1).padStart(2,"0")}`}function Lu(){const e=new Date().getFullYear();return{minYear:e-2,maxYear:e}}const Fs={941:"94105",944:"94405","CT-1":"10005"},kr={socialSecurity:"Social Security",medicare:"Medicare",withheld:"Withheld",tier1:"Tier 1(FICA)",tier2:"Tier 2 (Industry)"},Rs={regex:/^(?!0+(?:\.0+)?$)(?:100000000(?:\.00?)?|(?:\d{1,8}|\d{1,7}\d)(?:\.\d{1,2})?)$/,errorMessage:"Payment amount must be a number greater than 0, can include up to 2 decimal places, and must not exceed 100,000,000 (one hundred million)."};function Qi(e,t){return!e||!t?!1:Fs[e]===t}function na(e,t){return e==="CT-1"&&t===Fs["CT-1"]}function fv(e,t){return e==="941"&&t===Fs[941]||e==="944"&&t===Fs[944]}function pv(e){return e==="CT-1"?{code1:kr.tier1,code2:kr.tier2,code3:""}:{code1:kr.socialSecurity,code2:kr.medicare,code3:kr.withheld}}function $s(e){return Rs.regex.test(e)}const xv=/^(?:\d{0,8}(?:\.\d{0,2})?|100000000(?:\.\d{0,2})?)$/,cs=1e8;function gv(e){if(!e)return"";let t="",n=!1;for(const c of e)c>="0"&&c<="9"?t+=c:c==="."&&!n&&(t+=c,n=!0);const r=t.indexOf(".");let a=r===-1?t:t.slice(0,r);const i=r===-1?"":t.slice(r+1,r+3),o=r!==-1&&t.endsWith(".");if(a.length>9&&(a=a.slice(0,9)),a.length===9&&a!=="100000000"&&(a=a.slice(0,8)),a.length>0&&!o&&i===""){const c=Number.parseInt(a,10);!Number.isNaN(c)&&c>cs&&(a=String(cs))}let l=r===-1?a:`${a}.${i}`;if(o&&(l=`${a}.`),xv.test(l)){if(!l.endsWith(".")&&l!==""){const c=Number.parseFloat(l);if(!Number.isNaN(c)&&c>cs)return String(cs)}return l}return""}function Ou(e){return $s(e)?Number.parseFloat(e):null}function yv(e,t,n,r){const a=[e,t];return r&&a.push(n),a.reduce((i,o)=>{const l=Ou(o);return l===null?i:i+l},0)}function bv(e,t){return Math.abs(e-t)<.005}function vv(e,t,n,r,a){if(!Qi(e,t))return{subcategoryCode1:null,subcategoryCode2:null,subcategoryCode3:null};const i=na(e,t);return{subcategoryCode1:n.trim()?"1":null,subcategoryCode2:r.trim()?"2":null,subcategoryCode3:!i&&a.trim()?"3":null}}const jv=["Su","Mo","Tu","We","Th","Fr","Sa"];function wv(){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 zu({value:e,onChange:t,disabled:n=!1,hasError:r=!1}){const a=_s(e),i=Tu(),o=_u(),[l,c]=v.useState(!1),[d,u]=v.useState(()=>a??_s(i)??new Date),m=v.useRef(null),h=v.useId();v.useEffect(()=>{a&&u(a)},[e]),v.useEffect(()=>{if(!l)return;const y=C=>{var j;(j=m.current)!=null&&j.contains(C.target)||c(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[l]);const p=v.useMemo(()=>ev(d.getFullYear(),d.getMonth()),[d]),g=v.useMemo(()=>{const y=new Date(d.getFullYear(),d.getMonth()-1,1),C=new Date(y.getFullYear(),y.getMonth()+1,0);return fn(C)>=i},[d,i]),x=v.useMemo(()=>{const y=new Date(d.getFullYear(),d.getMonth()+1,1);return fn(y)<=o},[d,o]),b=y=>{ei(y)&&(t(fn(y)),c(!1))};return s.jsxs("div",{ref:m,className:"relative",children:[s.jsxs("div",{className:`flex items-center gap-2 rounded-lg border bg-white px-3 py-2.5 transition ${r?"border-red-300":"border-slate-200 focus-within:border-gov-400 focus-within:ring-2 focus-within:ring-gov-200"} ${n?"cursor-not-allowed bg-[#F9FAFB] opacity-60":""}`,children:[s.jsx("input",{id:h,type:"text",readOnly:!0,disabled:n,value:e,placeholder:"YYYY-MM-DD",onClick:()=>!n&&c(y=>!y),className:"w-full cursor-pointer border-0 bg-transparent p-0 text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none focus:ring-0 disabled:cursor-not-allowed"}),s.jsx("button",{type:"button",disabled:n,onClick:()=>c(y=>!y),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(wv,{})})]}),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:!g,onClick:()=>u(y=>new Date(y.getFullYear(),y.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:X0(d.getFullYear(),d.getMonth())}),s.jsx("button",{type:"button",disabled:!x,onClick:()=>u(y=>new Date(y.getFullYear(),y.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:jv.map(y=>s.jsx("div",{className:"py-1",children:y},y))}),s.jsx("div",{className:"grid grid-cols-7 gap-1 p-3 pt-1",children:p.map((y,C)=>{if(!y)return s.jsx("div",{},`empty-${C}`);const j=fn(y),S=e===j,I=!ei(y);return s.jsx("button",{type:"button","aria-disabled":I,onClick:()=>b(y),className:`rounded-lg px-1 py-2 text-sm transition ${I?"cursor-not-allowed text-slate-300 hover:bg-sky-50":S?"bg-sky-100 font-semibold text-slate-900":"font-medium text-slate-800 hover:bg-slate-50"}`,children:y.getDate()},j)})})]}):null]})}function Er({value:e,onChange:t,onBlur:n,name:r,disabled:a=!1,readOnly:i=!1,placeholder:o="0.00",hasError:l=!1}){return s.jsx("input",{type:"text",inputMode:"decimal",autoComplete:"off",name:r,value:e,disabled:a,readOnly:i,placeholder:o,className:ne(l,i),onChange:c=>t(gv(c.target.value)),onBlur:n})}const Nv=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Sv(){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 kv({value:e,onChange:t,disabled:n=!1,hasError:r=!1,disabledMonths:a=[]}){const{minYear:i,maxYear:o}=Lu(),l=Ds(e),[c,d]=v.useState(!1),[u,m]=v.useState((l==null?void 0:l.year)??o),h=v.useRef(null),p=v.useId();v.useEffect(()=>{l&&m(l.year)},[e]),v.useEffect(()=>{if(!c)return;const j=S=>{var I;(I=h.current)!=null&&I.contains(S.target)||d(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[c]);const g=mv(e),x=j=>!!a.includes(j),b=j=>{x(j)||(t(hv(u,j)),d(!1))},y=u>i,C=u<o;return s.jsxs("div",{ref:h,className:"relative",children:[s.jsxs("div",{className:`flex items-center gap-2 rounded-lg border bg-white px-3 py-2.5 transition ${r?"border-red-300":"border-slate-200 focus-within:border-gov-400 focus-within:ring-2 focus-within:ring-gov-200"} ${n?"cursor-not-allowed bg-[#F9FAFB] opacity-60":""}`,children:[s.jsx("input",{id:p,type:"text",readOnly:!0,disabled:n,value:g,placeholder:"YYYY-MM",onClick:()=>!n&&d(j=>!j),className:"w-full cursor-pointer border-0 bg-transparent p-0 text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none focus:ring-0 disabled:cursor-not-allowed"}),s.jsx("button",{type:"button",disabled:n,onClick:()=>d(j=>!j),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(Sv,{})})]}),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:!y,onClick:()=>m(j=>j-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:u}),s.jsx("button",{type:"button",disabled:!C,onClick:()=>m(j=>j+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:Nv.map((j,S)=>{const I=(l==null?void 0:l.year)===u&&l.month===S&&e.length===6,R=x(S);return s.jsx("button",{type:"button","aria-disabled":R,onClick:()=>b(S),className:`rounded-lg px-2 py-2.5 text-sm transition ${R?"cursor-not-allowed text-slate-300 hover:bg-sky-50":I?"bg-sky-100 font-semibold text-slate-900":"font-medium text-slate-800 hover:bg-slate-50"}`,children:j},j)})})]}):null]})}const Mu="Active",Cv="Inactive";function br(e){return(e.status??Mu).trim().toLowerCase()==="active"}function Av(e){return br(e)?Cv:Mu}function Pv(e){return br(e)?"Deactivate":"Activate"}function Ji(e){var t;return((t=e==null?void 0:e.accountType)==null?void 0:t.trim().toLowerCase())==="individual"}function Ev(e){return Ji(e)?"/payments/federal/individual-enrollment":"/payments/federal/authorization"}function qu(e){const t=vv(e.taxFormType,e.taxTypeCode,e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??""),n=na(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:!n&&e.subcategoryAmount3?Number.parseFloat(e.subcategoryAmount3):null}}function Gi(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),...qu(t)}}function Xi(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),...qu(e)}}const eo="federal-payment-draft";function to(e){sessionStorage.setItem(eo,JSON.stringify(e))}function ra(){const e=sessionStorage.getItem(eo);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function no(){sessionStorage.removeItem(eo)}function Iv(e,t={}){return{federalPaymentId:e.federalPaymentId,enrollmentId:e.enrollmentId,taxpayerPin:e.taxpayerPin??"",secondaryTin:e.secondaryTin??"",bankAccountDetailId:e.bankAccountDetailId?String(e.bankAccountDetailId):"",routingNumber:t.routingNumber??"",accountNumber:t.accountNumber??"",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 Tv=Xt({taxpayerPin:D().max(4,"Taxpayer PIN must not exceed 4 characters").optional(),secondaryTin:D().max(9,"Secondary TIN must not exceed 9 characters").optional(),bankAccountDetailId:D().min(1,"Bank account is required"),routingNumber:D().optional(),accountType:D().optional(),bankName:D().optional(),taxFormType:D().min(1,"Tax form type is required"),taxTypeCode:D().min(1,"Payment type is required"),taxPeriod:D().min(1,"This field is required").regex(/^\d{6}$/,"Tax period must be in YYYY-MM format").refine(e=>{const t=Ds(e);if(!t)return!1;const{minYear:n,maxYear:r}=Lu();return t.year>=n&&t.year<=r},"Tax period must be within the last 3 years"),settlementDate:D().min(1,"This field is required").refine(e=>ta(e),"Settlement date must be a weekday within the allowed range"),paymentAmount:D().min(1,"This field is required").refine(e=>$s(e),Rs.errorMessage),subcategoryCode1:D().optional(),subcategoryAmount1:D().optional(),subcategoryCode2:D().optional(),subcategoryAmount2:D().optional(),subcategoryCode3:D().optional(),subcategoryAmount3:D().optional()}).superRefine((e,t)=>{var l;if(e.taxPeriod&&e.taxFormType){const c=Ds(e.taxPeriod);c&&$u(e.taxFormType).includes(c.month)&&t.addIssue({code:Qt.custom,message:"Tax period must be a valid month for the selected tax form",path:["taxPeriod"]})}if(!Qi(e.taxFormType,e.taxTypeCode))return;const n=na(e.taxFormType,e.taxTypeCode),r=fv(e.taxFormType,e.taxTypeCode),a=(c,d,u)=>{if(!(c!=null&&c.trim())){u&&t.addIssue({code:Qt.custom,message:"This field is required",path:[d]});return}$s(c)||t.addIssue({code:Qt.custom,message:Rs.errorMessage,path:[d]})};a(e.subcategoryAmount1,"subcategoryAmount1",!0),a(e.subcategoryAmount2,"subcategoryAmount2",!0),a(e.subcategoryAmount3,"subcategoryAmount3",r);const i=Ou(e.paymentAmount),o=yv(e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??"",r);i!==null&&!bv(i,o)&&t.addIssue({code:Qt.custom,message:"Payment amount must equal the sum of subcategory amounts",path:["paymentAmount"]}),n&&((l=e.subcategoryAmount3)!=null&&l.trim())&&t.addIssue({code:Qt.custom,message:"Subcategory amount 3 is not used for CT-1 payments",path:["subcategoryAmount3"]})}),us="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function ga(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 _v={taxpayerPin:"",secondaryTin:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:"",taxFormType:"",taxTypeCode:"",taxPeriod:"",settlementDate:"",paymentAmount:"",subcategoryCode1:"",subcategoryAmount1:"",subcategoryCode2:"",subcategoryAmount2:"",subcategoryCode3:"",subcategoryAmount3:""};function Dv(e,t,n){if(e)return ga(e);if(t!=null&&t.paymentDraft)return ga(t.paymentDraft);const r=ra();return r&&r.entityId===n?ga(r):_v}function Bu({entity:e,initialDraft:t,readonly:n=!1,onCancel:r}){var bt,pt,vt,zt,jt,Mt,At,Pt,Et,It,qt,Bt,wt;const a=ke(),i=Se(),o=ft(),l=qn(i.state,Je()),c=i.state,d=ra(),u=t??(c==null?void 0:c.paymentDraft)??(d&&d.entityId===(e==null?void 0:e.entityId)?d:null),m=v.useRef(u==null?void 0:u.federalPaymentId),h=v.useRef(u==null?void 0:u.enrollmentId),[p,g]=v.useState(null),[x,b]=v.useState(!1),y=v.useMemo(()=>Dv(t,c,e==null?void 0:e.entityId),[t,c==null?void 0:c.paymentDraft,e==null?void 0:e.entityId,i.key]);v.useEffect(()=>{u!=null&&u.federalPaymentId&&(m.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:C=[],isLoading:j}=ge({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Jr({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:e!==null}),S=v.useMemo(()=>C.filter(br),[C]),{data:I=[],isLoading:R}=ge({queryKey:["federal-form-types",e==null?void 0:e.entityId],queryFn:()=>g0(e.entityId),enabled:e!==null}),{register:E,control:T,handleSubmit:L,watch:B,setValue:K,getValues:X,trigger:Y,formState:{errors:V}}=Rt({resolver:Lt(Tv),defaultValues:y}),Z=B("bankAccountDetailId"),ie=B("paymentAmount"),G=B("taxFormType"),Q=B("taxTypeCode"),we=B("taxPeriod"),Ae=B("settlementDate"),$e=B("subcategoryAmount1"),ce=B("subcategoryAmount2"),pe=B("subcategoryAmount3"),$=v.useRef(G),fe=v.useMemo(()=>G?$u(G):[],[G]),O=v.useMemo(()=>Qi(G,Q),[G,Q]),ue=v.useMemo(()=>na(G,Q),[G,Q]),{data:Te=[],isLoading:Ge}=ge({queryKey:["federal-tax-type-codes",G],queryFn:()=>y0(G),enabled:!!G});v.useEffect(()=>{$.current&&$.current!==G&&K("taxTypeCode",""),$.current=G},[G,K]),v.useEffect(()=>{if(!we||!G)return;const f=Ds(we);f&&fe.includes(f.month)&&K("taxPeriod","")},[G,we,fe,K]),v.useEffect(()=>{Ae&&(ta(Ae)||K("settlementDate",""))},[Ae,K]),v.useEffect(()=>{if(!O){K("subcategoryCode1",""),K("subcategoryCode2",""),K("subcategoryCode3",""),K("subcategoryAmount1",""),K("subcategoryAmount2",""),K("subcategoryAmount3","");return}const f=pv(G);K("subcategoryCode1",f.code1),K("subcategoryCode2",f.code2),K("subcategoryCode3",ue?"":f.code3),ue&&K("subcategoryAmount3","")},[O,G,ue,K]),v.useEffect(()=>{O&&(Y("paymentAmount"),Y("subcategoryAmount1"),Y("subcategoryAmount2"),Y("subcategoryAmount3"))},[$e,ce,pe,O,Y]),v.useEffect(()=>{if(j)return;const f=S.find(N=>String(N.bankAccountDetailId)===Z);if(!f){Z&&(K("bankAccountDetailId",""),K("routingNumber",""),K("accountType",""),K("bankName",""));return}K("routingNumber",f.routingNumber),K("accountType",f.accountType),K("bankName",f.bankName)},[S,Z,j,K]);const Oe=f=>{const N=S.find(A=>String(A.bankAccountDetailId)===f.bankAccountDetailId);return{federalPaymentId:m.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:f.taxpayerPin??"",secondaryTin:f.secondaryTin??"",bankAccountDetailId:f.bankAccountDetailId,routingNumber:f.routingNumber??(N==null?void 0:N.routingNumber)??"",accountNumber:(N==null?void 0:N.accountNumber)??"",accountType:f.accountType??(N==null?void 0:N.accountType)??"",bankName:f.bankName??(N==null?void 0:N.bankName)??"",taxFormType:f.taxFormType,taxTypeCode:f.taxTypeCode,taxPeriod:f.taxPeriod,settlementDate:f.settlementDate,paymentAmount:f.paymentAmount,subcategoryCode1:f.subcategoryCode1,subcategoryAmount1:f.subcategoryAmount1,subcategoryCode2:f.subcategoryCode2,subcategoryAmount2:f.subcategoryAmount2,subcategoryCode3:f.subcategoryCode3,subcategoryAmount3:f.subcategoryAmount3}},le=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]}),m.current&&o.removeQueries({queryKey:["federal-payment",m.current],exact:!0})},be=async f=>{if(!e)return null;if(f.federalPaymentId){const A=await Hi(f.federalPaymentId,Xi(f));return m.current=A.federalPaymentId,h.current=A.enrollmentId,A}const N=await Yi(Gi(e.entityId,f));return m.current=N.federalPaymentId,h.current=N.enrollmentId,N},Ye=L(async f=>{if(!(n||!e)){g(null),b(!0);try{const N=Oe(f),A=await be(N);if(!A)return;const k={...N,entityId:e.entityId,federalPaymentId:A.federalPaymentId,enrollmentId:A.enrollmentId};await le(),to(k),a(Ev(e),{state:{from:l,paymentDraft:k}})}catch(N){g(nt(N,"Failed to save payment details."))}finally{b(!1)}}}),re=async()=>{if(!(!e||n)){g(null),b(!0);try{const f=Oe(X());await be(f),await le(),no(),a(Je())}catch(f){g(nt(f,"Failed to save draft."))}finally{b(!1)}}},Ve=()=>{if(r){r();return}a(l)},rt=e?en(e):"Entity";return s.jsxs("form",{onSubmit:Ye,noValidate:!0,className:"w-full space-y-6",children:[p?s.jsx(Ot,{message:p}):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:rt}),s.jsx(Xr,{entity:e,remittanceAmount:Gr(ie),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(wn,{title:"Enrolment Details",isFirst:!0,children:s.jsxs("div",{className:us,children:[s.jsx(J,{label:"Taxpayer PIN",required:!0,info:"The 4-digit PIN assigned by the IRS for EFTPS enrollment.",error:(bt=V.taxpayerPin)==null?void 0:bt.message,children:s.jsx("input",{placeholder:"Taxpayer PIN",className:ne(!!V.taxpayerPin),maxLength:4,disabled:n,...E("taxpayerPin")})}),s.jsx(J,{label:"Secondary TIN",info:"An additional Taxpayer Identification Number, if the payment requires one.",error:(pt=V.secondaryTin)==null?void 0:pt.message,children:s.jsx("input",{placeholder:"Secondary TIN",className:ne(!!V.secondaryTin),maxLength:9,disabled:n,...E("secondaryTin")})}),s.jsx(Ne,{name:"bankAccountDetailId",control:T,render:({field:f})=>{var N;return s.jsx(Ru,{value:f.value,onChange:f.onChange,entityId:(e==null?void 0:e.entityId)??null,bankAccounts:S,isLoading:j,disabled:!e||n,info:"Select the bank account to debit for this payment, or add a new one.",error:(N=V.bankAccountDetailId)==null?void 0:N.message})}}),s.jsx(J,{label:"Routing Number",required:!0,info:"The 9-digit bank routing number, auto-filled from the selected bank account.",error:(vt=V.routingNumber)==null?void 0:vt.message,children:s.jsx("input",{readOnly:!0,placeholder:"Routing Number",className:ne(!!V.routingNumber,!0),...E("routingNumber")})}),s.jsx(J,{label:"Account Type",required:!0,info:"The bank account type (checking or savings), auto-filled from the selected bank account.",error:(zt=V.accountType)==null?void 0:zt.message,children:s.jsx("input",{readOnly:!0,placeholder:"Account Type",className:ne(!!V.accountType,!0),...E("accountType")})}),s.jsx(J,{label:"Bank Name",required:!0,info:"The name of the bank, auto-filled from the selected bank account.",error:(jt=V.bankName)==null?void 0:jt.message,children:s.jsx("input",{readOnly:!0,placeholder:"Bank Name",className:ne(!!V.bankName,!0),...E("bankName")})})]})}),s.jsx(wn,{title:"Federal Payment",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:us,children:[s.jsx(J,{label:"Tax Form Type",required:!0,info:"The federal tax form this payment applies to (e.g. 941, 944, CT-1).",error:(Mt=V.taxFormType)==null?void 0:Mt.message,children:s.jsxs(Tr,{children:[s.jsx(Ne,{name:"taxFormType",control:T,render:({field:f})=>s.jsxs("select",{className:Hn(!!V.taxFormType),disabled:R||!e||n,...f,children:[s.jsx("option",{value:"",children:R?"Loading form types…":"Select form type"}),I.map(N=>s.jsx("option",{value:N.value,children:N.value},N.value))]})}),s.jsx(Un,{})]})}),s.jsx(J,{label:"Payment Type",required:!0,info:"The type of payment for the selected tax form.",error:(At=V.taxTypeCode)==null?void 0:At.message,children:s.jsxs(Tr,{children:[s.jsx(Ne,{name:"taxTypeCode",control:T,render:({field:f})=>s.jsxs("select",{className:Hn(!!V.taxTypeCode),disabled:!G||Ge||n,...f,children:[s.jsx("option",{value:"",children:G?Ge?"Loading payment types…":"Select payment type":"Select tax form first"}),Te.map(N=>s.jsxs("option",{value:N.code,children:[N.code," - ",N.codeName]},N.code))]})}),s.jsx(Un,{})]})}),s.jsx(J,{label:"Tax Period",required:!0,info:"The tax period (month and year) this payment covers.",error:(Pt=V.taxPeriod)==null?void 0:Pt.message,children:s.jsx(Ne,{name:"taxPeriod",control:T,render:({field:f})=>s.jsx(kv,{value:f.value,onChange:f.onChange,hasError:!!V.taxPeriod,disabled:!G||n,disabledMonths:fe})})})]}),s.jsxs("div",{className:"grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx(J,{label:"Settlement Date",required:!0,info:"The weekday the payment will be withdrawn and settled with the IRS.",error:(Et=V.settlementDate)==null?void 0:Et.message,children:s.jsx(Ne,{name:"settlementDate",control:T,render:({field:f})=>s.jsx(zu,{value:f.value,onChange:f.onChange,hasError:!!V.settlementDate,disabled:n})})}),s.jsx(J,{label:"Payment Amount",required:!0,info:"The total amount to remit. Must equal the sum of subcategory amounts when applicable.",error:(It=V.paymentAmount)==null?void 0:It.message,children:s.jsx(Ne,{name:"paymentAmount",control:T,render:({field:f})=>s.jsx(Er,{name:f.name,value:f.value,onChange:f.onChange,onBlur:f.onBlur,disabled:n,hasError:!!V.paymentAmount})})})]}),O?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:us,children:[s.jsx(J,{label:"Subcategory Code 1",info:"The first subcategory code for the selected tax form, set automatically.",children:s.jsx("input",{readOnly:!0,className:ne(!1,!0),...E("subcategoryCode1")})}),s.jsx(J,{label:"Subcategory Code 2",info:"The second subcategory code for the selected tax form, set automatically.",children:s.jsx("input",{readOnly:!0,className:ne(!1,!0),...E("subcategoryCode2")})}),ue?null:s.jsx(J,{label:"Subcategory Code 3",info:"The third subcategory code for the selected tax form, set automatically.",children:s.jsx("input",{readOnly:!0,className:ne(!1,!0),...E("subcategoryCode3")})})]}),s.jsxs("div",{className:us,children:[s.jsx(J,{label:"Subcategory Amount 1",required:!0,info:"The amount allocated to Subcategory Code 1.",error:(qt=V.subcategoryAmount1)==null?void 0:qt.message,children:s.jsx(Ne,{name:"subcategoryAmount1",control:T,render:({field:f})=>s.jsx(Er,{name:f.name,value:f.value??"",onChange:f.onChange,onBlur:f.onBlur,disabled:n,placeholder:"Enter amount",hasError:!!V.subcategoryAmount1})})}),s.jsx(J,{label:"Subcategory Amount 2",required:!0,info:"The amount allocated to Subcategory Code 2.",error:(Bt=V.subcategoryAmount2)==null?void 0:Bt.message,children:s.jsx(Ne,{name:"subcategoryAmount2",control:T,render:({field:f})=>s.jsx(Er,{name:f.name,value:f.value??"",onChange:f.onChange,onBlur:f.onBlur,disabled:n,placeholder:"Enter amount",hasError:!!V.subcategoryAmount2})})}),ue?null:s.jsx(J,{label:"Subcategory Amount 3",required:!0,info:"The amount allocated to Subcategory Code 3.",error:(wt=V.subcategoryAmount3)==null?void 0:wt.message,children:s.jsx(Ne,{name:"subcategoryAmount3",control:T,render:({field:f})=>s.jsx(Er,{name:f.name,value:f.value??"",onChange:f.onChange,onBlur:f.onBlur,disabled:n,placeholder:"Enter amount",hasError:!!V.subcategoryAmount3})})})]})]}):null]})})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[s.jsx("button",{type:"button",onClick:Ve,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:n?"Back":"Cancel"}),n?null:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:re,disabled:!e||x,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:x?"Saving…":"Save as Draft"}),s.jsx("button",{type:"submit",disabled:!e||x,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:x?"Saving…":"Next"})]})]})]},i.key)}function Vu(){const{selectedEntity:e}=ht();return s.jsx(Bu,{entity:e})}function Uu({mode:e}){var m;const t=ke(),{federalPaymentId:n}=zs(),{selectedEntity:r}=ht(),a=Number.parseInt(n??"",10),{data:i,isLoading:o,isError:l}=ge({queryKey:["federal-payment",a],queryFn:()=>Wi(a),enabled:Number.isFinite(a)}),{data:c=[]}=ge({queryKey:["bank-accounts",r==null?void 0:r.entityId],queryFn:async()=>(await Jr({entityId:r.entityId,pageNumber:1,pageSize:100})).items,enabled:r!==null&&i!==void 0}),d=v.useMemo(()=>{if(!i)return null;const h=c.find(p=>p.bankAccountDetailId===i.bankAccountDetailId);return Iv(i,{routingNumber:h==null?void 0:h.routingNumber,accountNumber:h==null?void 0:h.accountNumber,accountType:h==null?void 0:h.accountType,bankName:h==null?void 0:h.bankName})},[i,c]);if(!Number.isFinite(a))return s.jsx(Be,{to:Je(),replace:!0});if(o)return s.jsx("p",{className:"text-sm text-slate-600",children:"Loading federal payment…"});if(l||!i||!d)return s.jsx(Be,{to:Je(),replace:!0});if(!r||i.entityId!==r.entityId)return s.jsx(Be,{to:Je(),replace:!0});const u=e==="view"||((m=i.status)==null?void 0:m.toLowerCase())!=="draft";return s.jsx(Bu,{entity:r,initialDraft:d,readonly:u,onCancel:()=>t(Je())})}function Zu(){return ht(),s.jsx(Uu,{mode:"edit"})}function Wu(){return ht(),s.jsx(Uu,{mode:"view"})}function Fv(e){const t=[];return e.includes("\\d")&&t.push("0-9"),/[A-Z]/.test(e)&&t.push("A-Z"),e.includes("-")&&t.push("\\-"),e.includes(" ")&&t.push(" "),e.includes("/")&&t.push("/"),t.length?t.join(""):null}function Rv(e,t){const n=e.toUpperCase();if(!t)return n;const r=Fv(t);return r?n.replace(new RegExp(`[^${r}]`,"g"),""):n}function $v(e){if(!e)return null;const t=[];let n=0;try{for(;n<e.length;){if(e.startsWith("(?:",n))return null;const r=e[n];if(r==="-"||r===" "||r==="/"){t.push({type:"separator",char:r}),n+=1;continue}let a;if(r==="\\")a=e[n+1]==="d"?"digit":"letter",n+=2;else if(r==="["){const o=e.indexOf("]",n);if(o===-1)return null;a="letter",n=o+1}else a=r>="0"&&r<="9"?"digit":"letter",n+=1;const i=Lv(e,n);if(i===null)return null;for(let o=0;o<i.count;o+=1)t.push({type:"slot",kind:a});n=i.nextIndex}}catch{return null}return t}function Lv(e,t){if(e[t]!=="{")return{count:1,nextIndex:t};const n=e.indexOf("}",t);if(n===-1)throw new Error("Unterminated quantifier");const r=e.slice(t+1,n);if(r.includes(","))return null;const a=Number.parseInt(r,10);if(Number.isNaN(a))throw new Error("Bad quantifier");return{count:a,nextIndex:n+1}}function Ov(e,t){const n=e.toUpperCase().replace(/[^0-9A-Z]/g,"").split("");let r="",a=0;for(const i of t){if(a>=n.length)break;if(i.type==="separator"){r+=i.char;continue}for(;a<n.length;){const o=n[a];a+=1;const l=o>="0"&&o<="9";if(i.kind==="digit"?l:!l){r+=o;break}}}return r}function zv(e){if(e)try{const t=Yu(e,0);return t.index===e.length?t.length:void 0}catch{return}}function Yu(e,t){let n=t,r=0;for(;;){const a=Mv(e,n);if(r=Math.max(r,a.length),n=a.index,e[n]==="|"){n+=1;continue}return{length:r,index:n}}}function Mv(e,t){let n=t,r=0;for(;n<e.length&&e[n]!=="|"&&e[n]!==")";){const a=qv(e,n);r+=a.length,n=a.index}return{length:r,index:n}}function qv(e,t){let n=t,r;if(e.startsWith("(?:",n)){const a=Yu(e,n+3);if(e[a.index]!==")")throw new Error("Unbalanced group");r=a.length,n=a.index+1}else if(e[n]==="\\")r=1,n+=2;else if(e[n]==="["){const a=e.indexOf("]",n);if(a===-1)throw new Error("Unterminated class");r=1,n=a+1}else r=1,n+=1;if(e[n]==="{"){const a=e.indexOf("}",n);if(a===-1)throw new Error("Unterminated quantifier");const i=e.slice(n+1,a).split(","),o=i.length===2?i[1]:i[0],l=Number.parseInt(o,10);if(Number.isNaN(l))throw new Error("Bad quantifier");r*=l,n=a+1}return{length:r,index:n}}const ro="state-payment-draft";function ti(e){sessionStorage.setItem(ro,JSON.stringify(e))}function ni(){const e=sessionStorage.getItem(ro);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Hu(){sessionStorage.removeItem(ro)}function Bv(e,t){var n;return{entityId:e,state:t.state,reasonForPayment:t.reasonForPayment,stateAccountId:t.stateAccountId,accountId:t.accountId,letterId:(n=t.letterId)!=null&&n.trim()?t.letterId.trim():null,taxYear:t.taxYear,taxPeriod:t.taxPeriod,taxAmount:Number.parseFloat(t.taxAmount),paymentDate:t.paymentDate,bankAccountDetailId:Number.parseInt(t.bankAccountDetailId,10)}}function Vv(e){var t;return{state:e.state,reasonForPayment:e.reasonForPayment,stateAccountId:e.stateAccountId,accountId:e.accountId,letterId:(t=e.letterId)!=null&&t.trim()?e.letterId.trim():null,taxYear:e.taxYear,taxPeriod:e.taxPeriod,taxAmount:Number.parseFloat(e.taxAmount),paymentDate:e.paymentDate,bankAccountDetailId:Number.parseInt(e.bankAccountDetailId,10)}}function Uv(e){return Xt({state:D().min(1,"State is required"),reasonForPayment:D().min(1,"Reason for payment is required"),stateAccountId:D().min(1,"State ID is required"),accountId:D().min(1,"Account ID is required").refine(t=>/^\d{10,12}$/.test(t.trim()),"Account ID must be 10 to 12 digits"),letterId:D().optional().refine(t=>!t||/^[A-Za-z0-9]+$/.test(t),"Letter ID must be alphanumeric"),taxYear:D().min(1,"Tax year is required"),taxPeriod:D().min(1,"Tax period is required"),taxAmount:D().min(1,"Tax amount is required").refine(t=>$s(t),Rs.errorMessage),paymentDate:D().min(1,"Payment date is required").refine(t=>ta(t),"Payment date must be a weekday within the allowed range"),bankAccountDetailId:D().min(1,"Bank account is required"),routingNumber:D().optional(),accountType:D().optional(),bankName:D().optional()}).superRefine((t,n)=>{const r=e(),a=r==null?void 0:r.stateId.pattern;if(a)try{new RegExp(`^(?:${a})$`).test(t.stateAccountId.trim().toUpperCase())||n.addIssue({code:Qt.custom,path:["stateAccountId"],message:r.stateId.message})}catch{n.addIssue({code:Qt.custom,path:["stateAccountId"],message:"State ID validation is temporarily unavailable"})}})}const ya="grid gap-x-6 gap-y-5 sm:grid-cols-3",jl="grid gap-x-6 gap-y-5 sm:grid-cols-2",wl="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",Nl={state:"",reasonForPayment:"",stateAccountId:"",accountId:"",letterId:"",taxYear:"",taxPeriod:"",taxAmount:"",paymentDate:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:""};function ba(e){return{state:e.state,reasonForPayment:Zv(e.reasonForPayment),stateAccountId:e.stateAccountId,accountId:e.accountId,letterId:e.letterId??"",taxYear:e.taxYear,taxPeriod:e.taxPeriod,taxAmount:e.taxAmount,paymentDate:e.paymentDate,bankAccountDetailId:e.bankAccountDetailId,routingNumber:e.routingNumber??"",accountType:e.accountType??"",bankName:e.bankName??""}}function Zv(e){return e.trim().toUpperCase().replaceAll(" ","_")}function Ku({entity:e,initialDraft:t,readonly:n=!1,onCancel:r}){var Et,It,qt,Bt,wt,f,N,A;const a=ke(),i=Se(),o=qn(i.state,Je()),l=i.state,c=v.useMemo(()=>t??(l==null?void 0:l.paymentDraft)??ni()??null,[t,l==null?void 0:l.paymentDraft]),d=v.useRef(c==null?void 0:c.statePaymentDetailId),u=v.useMemo(()=>{if(t)return ba(t);if(l!=null&&l.paymentDraft)return ba(l.paymentDraft);if(l!=null&&l.resetDraft)return Hu(),Nl;const k=ni();return k?ba(k):Nl},[t,l==null?void 0:l.paymentDraft,l==null?void 0:l.resetDraft,i.key]),{data:m=[],isLoading:h,isError:p}=ge({queryKey:["state-payment-states"],queryFn:({signal:k})=>C0(k)}),{data:g=[],isLoading:x}=ge({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Jr({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:e!==null}),b=v.useMemo(()=>g.filter(br),[g]),y=v.useRef(null),C=v.useMemo(()=>Uv(()=>y.current),[]),{register:j,control:S,handleSubmit:I,watch:R,setValue:E,clearErrors:T,formState:{errors:L}}=Rt({resolver:Lt(C),defaultValues:u}),B=R("state"),K=R("reasonForPayment"),X=R("taxAmount"),Y=R("paymentDate"),V=R("bankAccountDetailId"),{data:Z=[],isLoading:ie,isError:G}=ge({queryKey:["state-payment-reasons",e==null?void 0:e.entityId,B],queryFn:({signal:k})=>A0(e.entityId,B,k),enabled:e!==null&&!!B}),{data:Q,isLoading:we,isError:Ae}=ge({queryKey:["state-payment-validation-metadata",e==null?void 0:e.entityId,B,K],queryFn:({signal:k})=>P0(e.entityId,B,K,k),enabled:e!==null&&!!(B&&K)});ge({queryKey:["state-payment-form-references",e==null?void 0:e.entityId,B,K],queryFn:({signal:k})=>E0(e.entityId,B,K,k),enabled:e!==null&&!!(B&&K)}),y.current=Q??null;const $e=(Q==null?void 0:Q.taxYearOptions)??[],ce=(Q==null?void 0:Q.taxPeriodOptions)??[],pe=!!(Q&&B&&K),$=(Q==null?void 0:Q.stateId.pattern)??null,fe=zv($),O=v.useMemo(()=>$v($),[$]),ue=j("stateAccountId"),Te=j("accountId"),Ge=j("letterId"),[Oe,le]=v.useState(!1),[be,Ye]=v.useState(""),re=v.useRef(null),Ve=(Et=m.find(k=>k.code===B))==null?void 0:Et.name,rt=v.useMemo(()=>{const k=be.trim().toLowerCase();return k?m.filter(_=>_.name.toLowerCase().includes(k)||_.code.toLowerCase().includes(k)):m},[be,m]),bt=["stateAccountId","accountId","letterId","taxYear","taxPeriod","taxAmount","paymentDate"],pt=()=>{bt.forEach(k=>E(k,"")),T([...bt,"bankAccountDetailId"])},vt=k=>{E("state",k,{shouldValidate:!0}),E("reasonForPayment",""),T("reasonForPayment"),pt(),Ye(""),le(!1)},zt=k=>{k!==K&&(E("reasonForPayment",k,{shouldValidate:!0}),pt())};v.useEffect(()=>{c!=null&&c.statePaymentDetailId&&(d.current=c.statePaymentDetailId)},[c==null?void 0:c.statePaymentDetailId]),v.useEffect(()=>{var k;Oe&&((k=re.current)==null||k.focus())},[Oe]),v.useEffect(()=>{!K||ie||G||Z.some(k=>k.code===K)||E("reasonForPayment","")},[ie,G,Z,K,E]);const jt=v.useRef(!1);v.useEffect(()=>{if(!n){if(!jt.current){jt.current=!0;return}Y&&!ta(Y)&&E("paymentDate","")}},[Y,E,n]),v.useEffect(()=>{if(n||x)return;const k=b.find(_=>String(_.bankAccountDetailId)===V);if(!k){V&&(E("bankAccountDetailId",""),E("routingNumber",""),E("accountType",""),E("bankName",""));return}E("routingNumber",k.routingNumber),E("accountType",k.accountType),E("bankName",k.bankName)},[b,V,E,n,x]);const Mt=I(k=>{if(n||!Q)return;const _={statePaymentDetailId:d.current,state:k.state,reasonForPayment:k.reasonForPayment,stateAccountId:k.stateAccountId.trim().toUpperCase(),accountId:k.accountId.trim(),letterId:k.letterId,taxYear:k.taxYear,taxPeriod:k.taxPeriod,taxAmount:k.taxAmount,paymentDate:k.paymentDate,bankAccountDetailId:k.bankAccountDetailId,routingNumber:k.routingNumber,accountType:k.accountType,bankName:k.bankName};ti(_),a("/payments/state/authorization",{state:{from:o,paymentDraft:_}})}),At=()=>{if(r){r();return}a(o)},Pt=e?en(e):"Entity";return s.jsx("form",{onSubmit:Mt,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:Pt}),s.jsx(Xr,{entity:e,remittanceAmount:Gr(X),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:wl,children:[s.jsx(Sl,{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",disabled:n||h||p,onClick:()=>{Ye(""),le(k=>!k)},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 disabled:cursor-not-allowed disabled:opacity-70",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(Wv,{})}),s.jsxs("span",{children:[s.jsx("span",{className:"block text-sm font-semibold text-slate-900",children:h?"Loading states…":Ve??"Choose a state"}),s.jsx("span",{className:"block text-xs text-slate-500",children:"Tap to select the tax jurisdiction"})]})]}),s.jsx(Un,{className:`h-4 w-4 text-slate-400 transition ${Oe?"rotate-180":""}`})]}),Oe?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:"border-b border-slate-100 p-2",children:s.jsx("input",{ref:re,type:"search",value:be,onChange:k=>Ye(k.target.value),onKeyDown:k=>{k.key==="Escape"?le(!1):k.key==="Enter"&&k.preventDefault()},placeholder:"Search by state name or code","aria-label":"Search states",className:"w-full rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-900 outline-none transition placeholder:text-slate-400 focus:border-gov-400 focus:bg-white focus:ring-2 focus:ring-gov-100"})}),s.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[rt.map(k=>s.jsxs("button",{type:"button",onClick:()=>vt(k.code),className:`flex w-full items-center justify-between px-4 py-3 text-left text-sm transition hover:bg-slate-50 ${B===k.code?"bg-gov-50 text-gov-700":"text-slate-700"}`,children:[s.jsx("span",{children:k.name}),s.jsx("span",{className:"text-xs font-medium text-slate-400",children:k.code})]},k.code)),rt.length===0?s.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No states found."}):null]})]}):null,L.state?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:L.state.message}):null,p?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:"Unable to load states."}):null]}),s.jsx(J,{label:"Reason for Payment",required:!0,info:"The reason for this state tax payment, filtered by the selected state and entity.",error:(It=L.reasonForPayment)==null?void 0:It.message,children:s.jsxs(Tr,{children:[s.jsxs("select",{disabled:n||!B||ie||G,className:Hn(!!L.reasonForPayment),value:K,onChange:k=>zt(k.target.value),children:[s.jsx("option",{value:"",children:ie?"Loading reasons…":"Select reason"}),Z.map(k=>s.jsx("option",{value:k.code,children:k.label},k.code))]}),s.jsx(Un,{})]})}),G?s.jsx("p",{className:"text-xs text-red-600",children:"Unable to load payment reasons."}):null,B&&!ie&&!G&&Z.length===0?s.jsx("p",{className:"text-xs text-slate-500",children:"No supported payment reasons are available for this entity and state."}):null]})]}),s.jsxs("section",{className:`${wl} transition ${pe?"":"opacity-60"}`,children:[s.jsx(Sl,{step:2,title:"Payment Form",className:"mb-5"}),s.jsxs("fieldset",{disabled:!pe||n,className:"min-w-0 border-0 p-0",children:[s.jsx(va,{title:"Payment Details",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:ya,children:[s.jsx(J,{label:"State ID",required:(Q==null?void 0:Q.stateId.required)??!0,info:"Your state-issued tax account identifier for the selected state.",error:(qt=L.stateAccountId)==null?void 0:qt.message,children:s.jsx("input",{placeholder:(Q==null?void 0:Q.stateId.example)??"Enter ID",maxLength:fe,className:ne(!!L.stateAccountId),...ue,onChange:k=>{k.target.value=O?Ov(k.target.value,O):Rv(k.target.value,$),ue.onChange(k)}})}),s.jsx(J,{label:"Account ID",required:(Q==null?void 0:Q.accountIdRequired)??!0,info:"Your 10 to 12 digit state tax account number.",error:(Bt=L.accountId)==null?void 0:Bt.message,children:s.jsx("input",{inputMode:"numeric",placeholder:"10–12 digits",maxLength:12,className:ne(!!L.accountId),...Te,onChange:k=>{k.target.value=k.target.value.replace(/\D/g,"").slice(0,12),Te.onChange(k)}})}),s.jsx(J,{label:"Letter ID",required:(Q==null?void 0:Q.letterIdRequired)??!1,info:"The alphanumeric ID from a notice or letter received from the state, if applicable.",children:s.jsx("input",{placeholder:"Alphanumeric",maxLength:50,className:ne(),...Ge,onChange:k=>{k.target.value=k.target.value.replace(/[^A-Za-z0-9]/g,"").slice(0,50),Ge.onChange(k)}})})]}),s.jsxs("div",{className:jl,children:[s.jsx(J,{label:"Tax Year",required:!0,info:"The tax year this payment applies to.",error:(wt=L.taxYear)==null?void 0:wt.message,children:s.jsxs(Tr,{children:[s.jsx(Ne,{name:"taxYear",control:S,render:({field:k})=>s.jsxs("select",{className:Hn(!!L.taxYear),...k,children:[s.jsx("option",{value:"",children:"Select TY"}),$e.map(_=>s.jsxs("option",{value:String(_),children:["TY ",_]},_))]})}),s.jsx(Un,{})]})}),s.jsx(J,{label:(Q==null?void 0:Q.periodMode)==="account-assigned"?"Deposit Frequency":"Tax Period",required:!0,info:(Q==null?void 0:Q.periodMode)==="account-assigned"?"The deposit frequency assigned to your state tax account.":"The tax period this payment covers.",error:(f=L.taxPeriod)==null?void 0:f.message,children:s.jsxs(Tr,{children:[s.jsx(Ne,{name:"taxPeriod",control:S,render:({field:k})=>s.jsxs("select",{className:Hn(!!L.taxPeriod),...k,children:[s.jsx("option",{value:"",children:"Select"}),ce.map(_=>s.jsx("option",{value:_.value,children:_.label},_.value))]})}),s.jsx(Un,{})]})})]})]})}),s.jsx(va,{title:"Amount Info",children:s.jsxs("div",{className:jl,children:[s.jsx(J,{label:"Tax Amount",required:!0,info:"The total amount to remit to the state.",error:(N=L.taxAmount)==null?void 0:N.message,children:s.jsx(Ne,{name:"taxAmount",control:S,render:({field:k})=>s.jsx(Er,{name:k.name,value:k.value,onChange:k.onChange,onBlur:k.onBlur,disabled:n,hasError:!!L.taxAmount})})}),s.jsx(J,{label:"Payment Date",required:!0,info:"The weekday the payment will be withdrawn and settled with the state.",error:(A=L.paymentDate)==null?void 0:A.message,children:s.jsx(Ne,{name:"paymentDate",control:S,render:({field:k})=>s.jsx(zu,{value:k.value,onChange:k.onChange,hasError:!!L.paymentDate,disabled:n})})})]})}),s.jsx(va,{title:"Bank Account",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:ya,children:[s.jsx(Ne,{name:"bankAccountDetailId",control:S,render:({field:k})=>{var _;return s.jsx(Ru,{value:k.value,onChange:k.onChange,entityId:(e==null?void 0:e.entityId)??null,bankAccounts:b,isLoading:x,disabled:!e||!pe||n,error:(_=L.bankAccountDetailId)==null?void 0:_.message,label:"Account Number",info:"Select the bank account to debit for this payment, or add a new one."})}}),s.jsx(J,{label:"Routing Number",required:!0,info:"The 9-digit bank routing number, auto-filled from the selected bank account.",children:s.jsx("input",{readOnly:!0,placeholder:"9-digit",className:ne(!1,!0),...j("routingNumber")})}),s.jsx(J,{label:"Account Type",required:!0,info:"The bank account type (checking or savings), auto-filled from the selected bank account.",children:s.jsx("input",{readOnly:!0,placeholder:"Select",className:ne(!1,!0),...j("accountType")})})]}),s.jsx("div",{className:ya,children:s.jsx(J,{label:"Bank Name",info:"The name of the bank, auto-filled from the selected bank account.",children:s.jsx("input",{readOnly:!0,placeholder:"e.g. Chase Bank",className:ne(!1,!0),...j("bankName")})})})]})}),Q!=null&&Q.notes.length?s.jsx("div",{className:"mt-5 rounded-lg bg-amber-50 px-4 py-3 text-xs text-amber-800",children:Q.notes.map(k=>s.jsx("p",{children:k},k))}):null]}),pe?null:s.jsx("p",{className:"mt-4 text-sm text-slate-500",children:we?"Loading payment requirements…":Ae?"Unable to load payment requirements.":"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:At,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:n?"Back":"Cancel"}),n?null:s.jsxs("button",{type:"submit",disabled:!e||!pe,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(Yv,{})]})]})]})})]})},i.key)}function Sl({step:e,title:t,className:n=""}){return s.jsxs("div",{className:`flex items-center gap-3 ${n}`,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 va({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 Wv(){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 Yv(){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 Qu(){const{selectedEntity:e}=ht();return s.jsx(Ku,{entity:e})}function Ju(){var l;const{statePaymentId:e}=zs(),{selectedEntity:t}=ht(),n=Number.parseInt(e??"",10),{data:r,isLoading:a,isError:i}=ge({queryKey:["state-payments",n],queryFn:()=>ku(n),enabled:t!==null&&Number.isFinite(n)}),o=v.useMemo(()=>r?{statePaymentDetailId:r.statePaymentDetailId,state:r.state,reasonForPayment:r.reasonForPayment??"",stateAccountId:r.stateAccountId??"",accountId:r.accountId??"",letterId:r.letterId??"",taxYear:r.taxYear??"",taxPeriod:r.taxPeriod??"",taxAmount:String(r.taxAmount),paymentDate:r.paymentDate,bankAccountDetailId:r.bankAccountDetailId?String(r.bankAccountDetailId):""}:null,[r]);return Number.isFinite(n)?a?s.jsx("p",{className:"px-6 py-12 text-sm text-slate-500",children:"Loading state payment…"}):i||!r||!o?s.jsx(Be,{to:Je(),replace:!0}):!t||r.entityId!==t.entityId?s.jsx(Be,{to:Je(),replace:!0}):((l=r.status)==null?void 0:l.toLowerCase())!=="draft"?s.jsx(Be,{to:`/payments/state/${n}/view`,replace:!0}):s.jsx(Ku,{entity:t,initialDraft:o}):s.jsx(Be,{to:Je(),replace:!0})}function Gu(){var l,c;const{statePaymentId:e}=zs(),t=ke(),{selectedEntity:n}=ht(),r=Number.parseInt(e??"",10),{data:a,isLoading:i,isError:o}=ge({queryKey:["state-payments",r],queryFn:()=>ku(r),enabled:n!==null&&Number.isFinite(r)});return Number.isFinite(r)?i?s.jsx("p",{className:"px-6 py-12 text-sm text-slate-500",children:"Loading state payment…"}):o||!a?s.jsx(Be,{to:"/payments",replace:!0}):!n||a.entityId!==n.entityId?s.jsx(Be,{to:"/payments",replace:!0}):s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>t("/payments"),className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm font-medium text-slate-600 transition hover:bg-slate-50",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.75 19.5L8.25 12l7.5-7.5"})}),"Back to Payments"]}),s.jsxs("h1",{className:"text-lg font-semibold text-slate-900",children:["State Payment ST-",a.statePaymentDetailId]})]}),s.jsx("div",{className:"w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",children:s.jsxs("dl",{className:"grid gap-x-8 gap-y-5 sm:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"State"}),s.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:a.state})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Tax Period"}),s.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:a.taxPeriod})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Amount"}),s.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:Kr(a.taxAmount)})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Payment Date"}),s.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:a.paymentDate})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Status"}),s.jsx("dd",{className:"mt-1",children:s.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold ${((l=a.status)==null?void 0:l.toLowerCase())==="paid"?"bg-green-100 text-green-800":((c=a.status)==null?void 0:c.toLowerCase())==="rejected"?"bg-red-100 text-red-800":"bg-slate-100 text-slate-700"}`,children:a.status??"—"})})]}),a.reason&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Rejection Reason"}),s.jsx("dd",{className:"mt-1 text-sm text-slate-700",children:a.reason})]})]})})]}):s.jsx(Be,{to:"/payments",replace:!0})}const Hv="By proceeding, you authorize the payment to the selected tax authority and acknowledge that you are responsible for the accuracy of the information provided.",Kv="I have reviewed the details and authorize this payment.",Xu=/^[a-zA-Z\s]+$/;function ed(e){return e.replace(/[^a-zA-Z\s]/g,"")}const so=D().min(1,"Signature is required").regex(Xu,"Signature must contain only letters").refine(e=>e.trim().length>0,{message:"Signature is required"}),Qv=D().optional().refine(e=>!e||!e.trim()||Xu.test(e),{message:"Signature must contain only letters"}),Jv=Xt({agreementDate:D().min(1,"Date is required"),agreementAccepted:Wn().refine(e=>e,{message:"You must accept the authorization agreement"}),authorizationPersonName:D().min(1,"Name of authorization person is required"),signature:so,title:D().min(1,"Title is required")}),Gv="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",ds="rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 text-center";function Xv(e){const[t,n,r]=e.split("-");return!t||!n||!r?e:`${n}/${r}/${t}`}function ej(){return{agreementDate:new Date().toISOString().slice(0,10),agreementAccepted:!1,authorizationPersonName:"",signature:"",title:""}}function tj({entity:e,paymentDraft:t}){const n=ke(),r=Se(),a=ft(),i=qn(r.state,Je()),[o,l]=v.useState(null),[c,d]=v.useState(!1),u=v.useMemo(()=>ej(),[]),m=Gr(t.taxAmount),{register:h,handleSubmit:p,watch:g,formState:{errors:x}}=Rt({resolver:Lt(Jv),defaultValues:u}),b=g("agreementDate"),y=g("signature"),C=!!(y!=null&&y.trim()),j=h("signature"),S=async L=>{await a.invalidateQueries({queryKey:["dashboard"]}),await a.invalidateQueries({queryKey:["state-payments"]}),await a.invalidateQueries({queryKey:["remittance-payments"]}),L&&a.removeQueries({queryKey:["state-payments",L],exact:!0})},I=async()=>{if(!e)return null;if(t.statePaymentDetailId){const B=await T0(t.statePaymentDetailId,Vv(t));return await S(B.statePaymentDetailId),B}const L=await I0(Bv(e.entityId,t));return ti({...t,statePaymentDetailId:L.statePaymentDetailId}),await S(L.statePaymentDetailId),L},R=async()=>{e&&(await I(),Hu(),n(Je()))},E=p(async()=>{if(e){l(null),d(!0);try{await R()}catch(L){l(nt(L,"Failed to save state payment."))}finally{d(!1)}}}),T=p(async()=>{if(e){l(null),d(!0);try{await R()}catch(L){l(nt(L,"Failed to save draft."))}finally{d(!1)}}});return s.jsx("form",{onSubmit:E,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(Xr,{entity:e,remittanceAmount:m,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:Gv,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:`${ds} 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:Xv(b)}),s.jsx("input",{type:"hidden",...h("agreementDate")})]})]}),s.jsx("p",{className:"mt-5 text-sm leading-relaxed text-slate-600",children:Hv}),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",...h("agreementAccepted")}),s.jsx("span",{className:"text-sm font-semibold leading-6 text-slate-800",children:Kv})]}),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:`${ds} py-7`,children:[s.jsx("input",{placeholder:"Enter name",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...h("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:`${ds} 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 ${C?"min-h-[52px] 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,name:j.name,ref:j.ref,onBlur:j.onBlur,onChange:L=>{const B=ed(L.target.value);L.target.value=B,j.onChange(L)}}),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:`${ds} py-7`,children:[s.jsx("input",{placeholder:"Enter title",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...h("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(Ot,{message:o})}):null,s.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[s.jsx("button",{type:"button",onClick:()=>{ti(t),n("/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:T,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 td(){const{selectedEntity:e}=ht(),t=Se(),{paymentDraft:n}=t.state??{},r=n??ni();return r?s.jsx(tj,{entity:e,paymentDraft:r}):s.jsx(Be,{to:"/payments/state/new",replace:!0})}const ao="/portal/federal-payments/form-8655-authorizations";function nj(e){return de(ao,{method:"POST",body:e})}function rj(e){return de(`${ao}/by-enrolment/${e}`)}function sj(e,t){return de(`${ao}/${e}`,{method:"PATCH",body:t})}async function nd(e){try{return await rj(e)}catch(t){if(t instanceof xr&&t.status===404)return null;throw t}}const ri=["720","940","941","943","944","945","990-PF","990-T","1041","1042","1120","CT-1"];function aj(e){const t=e.trim();return ri.includes(t)?t:""}const ij="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.",oj="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 lj(e){const[t,n,r]=e.split("-");return!t||!n||!r?e:`${n}/${r}/${t}`}function si({label:e,required:t=!1,signature:n,title:r,date:a,signatureValue:i,dateValue:o="",dateReadOnly:l=!0,errors:c,signatureCaption:d="Signature of taxpayer"}){const u=!!(i!=null&&i.trim()),{onChange:m,onBlur:h,name:p,ref:g}=n;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",{ref:g,name:p,placeholder:"Sign here",autoComplete:"off",spellCheck:!1,className:`w-full border-0 bg-transparent text-center focus:outline-none ${u?"text-4xl leading-tight tracking-wide text-slate-800":"text-sm text-slate-400 placeholder:text-slate-400"}`,style:u?{fontFamily:"'Great Vibes', 'Segoe Script', cursive"}:void 0,onBlur:h,onChange:x=>{const b=ed(x.target.value);x.target.value=b,m(x)}}),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:d})]}),c!=null&&c.signature?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.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:"Enter title",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...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:"Title"})]}),c!=null&&c.title?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.title}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-8",children:[l?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-center text-sm text-slate-700",children:lj(o)}),s.jsx("input",{type:"hidden",...a})]}):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"})]}),c!=null&&c.date?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.date}):null]})]})]})}function cj(e){return e.replace(/\D/g,"")}function rd(e,t){var n,r;return{enrollmentId:e,taxpayerName:t.taxpayerName.trim(),tradeName:t.tradeName.trim(),ein:cj(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:((n=t.otherIdentificationNumber)==null?void 0:n.trim())||null,contactPerson:t.contactPerson.trim(),daytimePhone:t.daytimePhone.trim(),faxNumber:t.faxNumber.trim(),authorizedTaxForm:t.authorizedTaxForm,authorizationStartMonth:((r=t.authorizationMonth)==null?void 0:r.trim())||null,agreementAccepted:t.agreementAccepted,taxpayerSignature:t.signature.trim()||null,taxpayerTitle:t.title.trim(),signatureDate:t.signatureDate}}function uj(e){const{enrollmentId:t,...n}=rd(0,e);return n}function dj(e){return{taxpayerName:e.taxpayerName,tradeName:e.tradeName,ein:zi(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:$n(e.daytimePhone),faxNumber:e.faxNumber,authorizedTaxForm:e.authorizedTaxForm,authorizationMonth:e.authorizationStartMonth??"",agreementAccepted:e.agreementAccepted,signature:e.taxpayerSignature??"",title:e.taxpayerTitle,signatureDate:e.signatureDate}}const mj=Xt({taxpayerName:D().min(1,"Taxpayer name is required"),tradeName:D().optional(),ein:D().min(1,"EIN is required"),address:D().min(1,"Address is required"),city:D().min(1,"City is required"),state:D().min(1,"State is required"),zipCode:D().min(1,"ZIP code is required"),country:D().min(1,"Country is required"),isSeasonalEmployer:Wn(),otherIdentificationNumber:D().optional(),contactPerson:D().optional(),daytimePhone:D().min(1,"Daytime telephone number is required"),faxNumber:D().default(""),authorizedTaxForm:D().min(1,"Select a tax form"),authorizationMonth:D().optional().refine(e=>!e||/^\d{4}\/(0[1-9]|1[0-2])$/.test(e),"Enter the month as YYYY/MM (e.g. 2024/08)"),agreementAccepted:Wn().refine(e=>e,{message:"You must accept the authorization agreement"}),signature:so,title:D().min(1,"Title is required"),signatureDate:D().min(1,"Date is required")}),ja="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function hj(e,t){const n=new Date().toISOString().slice(0,10);return{taxpayerName:e?en(e):"",tradeName:(e==null?void 0:e.tradeName)??"",ein:e?zi(e.idNumber):"",address:[e==null?void 0:e.address1,e==null?void 0:e.address2].filter(Boolean).join(", "),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:"",daytimePhone:e?$n(e.phoneNumber):"",faxNumber:"",authorizedTaxForm:aj(t.taxFormType),authorizationMonth:"",agreementAccepted:!1,signature:"",title:"",signatureDate:n}}function fj({entity:e,paymentDraft:t,initialAuthorization:n=null,readonly:r=!1}){var ie,G,Q,we,Ae,$e,ce,pe,$,fe,O,ue,Te,Ge,Oe;const a=ke(),i=Se(),o=ft(),l=qn(i.state,Je()),c=Gr(t.paymentAmount),[d,u]=v.useState(null),[m,h]=v.useState(!1),p=v.useMemo(()=>n?dj(n):hj(e,t),[e,n,t]),{register:g,handleSubmit:x,watch:b,setValue:y,reset:C,formState:{errors:j}}=Rt({resolver:Lt(mj),defaultValues:p});v.useEffect(()=>{C(p)},[p,C]);const S=b("authorizedTaxForm"),I=b("signature"),R=b("signatureDate"),E=e?en(e):"Entity",T=!0,L=!0,B=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},K=async()=>{if(!e)return null;if(t.federalPaymentId){const be=await Hi(t.federalPaymentId,Xi(t));return await B(),be}const le=await Yi(Gi(e.entityId,t));return to({...t,federalPaymentId:le.federalPaymentId,enrollmentId:le.enrollmentId}),await B(),le},X=async(le,be)=>{var Ve;const Ye=t.form8655AuthorizationId??((Ve=await nd(le))==null?void 0:Ve.form8655AuthorizationId),re=be;return Ye?sj(Ye,uj(re)):nj(rd(le,re))},Y=async le=>{if(!e)return;const be=await K();be&&(await X(be.enrollmentId,le),await o.invalidateQueries({queryKey:["form-8655",be.enrollmentId]}),no(),a(Je()))},V=x(async le=>{if(!(!e||r)){u(null),h(!0);try{await Y(le)}catch(be){u(nt(be,"Failed to save federal payment draft."))}finally{h(!1)}}}),Z=x(async le=>{if(!(!e||r)){u(null),h(!0);try{await Y(le)}catch(be){u(nt(be,"Failed to save draft."))}finally{h(!1)}}});return s.jsxs("form",{onSubmit:V,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:E}),s.jsx(Xr,{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:r,className:"min-w-0 border-0 p-0",children:[s.jsxs("section",{children:[s.jsxs("div",{className:ja,children:[s.jsx(J,{label:"1. a) Name of the Taxpayer",required:!0,error:(ie=j.taxpayerName)==null?void 0:ie.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:T,className:ne(!!j.taxpayerName,T),...g("taxpayerName")})}),s.jsx(J,{label:"1. b) Trade Name, if any",error:(G=j.tradeName)==null?void 0:G.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:T,className:ne(!!j.tradeName,T),...g("tradeName")})}),s.jsx(J,{label:"2. Employer Identification Number (EIN)",required:!0,error:(Q=j.ein)==null?void 0:Q.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:T,className:ne(!!j.ein,T),...g("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(J,{label:"3. a) Address (Number, Street, and Room/Suite No)",required:!0,error:(we=j.address)==null?void 0:we.message,children:s.jsx("input",{placeholder:"Enter",readOnly:T,className:ne(!!j.address,T),...g("address")})})}),s.jsx(J,{label:"3. b) City or Town",required:!0,error:(Ae=j.city)==null?void 0:Ae.message,children:s.jsx("input",{placeholder:"Enter",readOnly:T,className:ne(!!j.city,T),...g("city")})})]}),s.jsxs("div",{className:`mt-5 ${ja}`,children:[s.jsx(J,{label:"3. c) State",required:!0,error:($e=j.state)==null?void 0:$e.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:T,className:ne(!!j.state,T),...g("state")})}),s.jsx(J,{label:"3. d) ZIP Code",required:!0,error:(ce=j.zipCode)==null?void 0:ce.message,children:s.jsx("input",{placeholder:"Enter",readOnly:T,className:ne(!!j.zipCode,T),...g("zipCode")})}),s.jsx(J,{label:"3. e) Country",required:!0,error:(pe=j.country)==null?void 0:pe.message,children:s.jsx("input",{placeholder:"Enter",readOnly:T,className:ne(!!j.country,T),...g("country")})})]}),s.jsxs("div",{className:`mt-5 ${ja}`,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",...g("isSeasonalEmployer")}),s.jsx("span",{children:"4. If you are a Seasonal Employer"})]})}),s.jsx(J,{label:"5. Other Identification Number (Optional)",children:s.jsx("input",{placeholder:"Enter name",readOnly:T,className:ne(!1,T),...g("otherIdentificationNumber")})}),s.jsx(J,{label:"6. Contact Person",error:($=j.contactPerson)==null?void 0:$.message,children:s.jsx("input",{placeholder:"Enter name",className:ne(!!j.contactPerson),...g("contactPerson")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2",children:[s.jsx(J,{label:"7. Daytime Telephone Number",required:!0,error:(fe=j.daytimePhone)==null?void 0:fe.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:T,className:ne(!!j.daytimePhone,T),...g("daytimePhone")})}),s.jsx(J,{label:"8. Fax Number",error:(O=j.faxNumber)==null?void 0:O.message,children:s.jsx("input",{placeholder:"Enter number",className:ne(!!j.faxNumber),...g("faxNumber")})})]})]}),s.jsxs(wn,{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:ri.slice(0,6).map(le=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:le,checked:S===le,disabled:L,onChange:()=>y("authorizedTaxForm",le,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),le]},le))}),s.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:ri.slice(6).map(le=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:le,checked:S===le,disabled:L,onChange:()=>y("authorizedTaxForm",le,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),le]},le))})]}),j.authorizedTaxForm?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:j.authorizedTaxForm.message}):null,s.jsx("div",{className:"mt-5 max-w-xs",children:s.jsx(J,{label:"Authorization begins (YYYY/MM)",error:(ue=j.authorizationMonth)==null?void 0:ue.message,children:s.jsx("input",{placeholder:"2024/08",className:ne(!!j.authorizationMonth,!1),...g("authorizationMonth")})})})]}),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",...g("agreementAccepted")}),s.jsxs("span",{className:"text-sm leading-6 text-slate-700",children:[s.jsx("span",{className:"font-semibold text-slate-900",children:ij})," ",oj]})]}),j.agreementAccepted?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:j.agreementAccepted.message}):null]})]}),s.jsx("section",{className:"mt-8 border-t border-slate-100 pt-8",children:s.jsx(si,{label:"Taxpayer's Signature",required:!0,signature:g("signature"),title:g("title"),date:g("signatureDate"),signatureValue:I,dateValue:R,errors:{signature:(Te=j.signature)==null?void 0:Te.message,title:(Ge=j.title)==null?void 0:Ge.message,date:(Oe=j.signatureDate)==null?void 0:Oe.message}})})]})})]}),d?s.jsx("div",{className:"lg:mr-[324px]",children:s.jsx(Ot,{message:d})}):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:m,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:m||!e||r,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:m||!e||r,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 sd(){const{selectedEntity:e}=ht(),t=Se(),{paymentDraft:n}=t.state??{},r=n??ra(),{data:a,isLoading:i}=ge({queryKey:["federal-payment",r==null?void 0:r.federalPaymentId],queryFn:()=>Wi(r.federalPaymentId),enabled:(r==null?void 0:r.federalPaymentId)!=null&&r.enrollmentId==null}),o=(r==null?void 0:r.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=ge({queryKey:["form-8655",o],queryFn:()=>nd(o),enabled:o!=null}),d=v.useMemo(()=>r?{...r,enrollmentId:o??r.enrollmentId,form8655AuthorizationId:r.form8655AuthorizationId??(l==null?void 0:l.form8655AuthorizationId)}:null,[r,o,l]);return r?Ji(e)?s.jsx(Be,{to:"/payments/federal/individual-enrollment",replace:!0,state:t.state}):r.federalPaymentId!=null&&r.enrollmentId==null&&i||o!=null&&c?s.jsx("p",{className:"text-sm text-slate-600",children:"Loading authorization form…"}):s.jsx(fj,{entity:e,paymentDraft:d??r,initialAuthorization:l}):s.jsx(Be,{to:"/payments/federal/new",replace:!0})}const io="/portal/federal-payments/form-9783-enrollments";function pj(e){return de(io,{method:"POST",body:e})}function xj(e){return de(`${io}/by-enrolment/${e}`)}function gj(e,t){return de(`${io}/${e}`,{method:"PATCH",body:t})}async function ad(e){try{return await xj(e)}catch(t){if(t instanceof xr&&t.status===404)return null;throw t}}const yj="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.",bj="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.",vj="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.",wa=new Date().getFullYear(),jj=[String(wa-1),String(wa-2),String(wa-3)];function ms(e){return e.replace(/\D/g,"")}function id(e,t){var n,r,a,i;return{enrollmentId:e,primarySsn:ms(t.primarySsn),jointFilerSsn:t.jointFilerSsn?ms(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:((n=t.internationalAddress)==null?void 0:n.trim())||null,primaryPhone:t.primaryPhone.trim(),primaryContactName:t.primaryContactName.trim(),primaryContactAddress:t.primaryContactAddress.trim(),contactCity:t.contactCity.trim(),contactState:t.contactState.trim(),contactZipCode:t.contactZipCode.trim(),contactCountry:t.contactCountry.trim(),contactPhone:t.contactPhone.trim(),contactInternationalAddress:((r=t.contactInternationalAddress)==null?void 0:r.trim())||null,primaryTaxpayerPin:t.primaryTaxpayerPin.trim()||null,dateOfBirth:t.dateOfBirth||null,priorYearAgi:t.priorYearAgi.trim()?Number(t.priorYearAgi):null,agiTaxYear:t.agiTaxYear.trim()||null,financialPrimarySsn:ms(t.financialPrimarySsn),routingTransitNumber:ms(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:((a=t.jointFilerSignature)==null?void 0:a.trim())||null,jointFilerTitle:((i=t.jointFilerTitle)==null?void 0:i.trim())||null,jointFilerSignatureDate:t.jointFilerSignatureDate||null}}function wj(e){const{enrollmentId:t,...n}=id(0,e);return n}function Nj(e){var n;const t=((n=e.accountType)==null?void 0:n.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:$n(e.primaryPhone),primaryContactName:e.primaryContactName,primaryContactAddress:e.primaryContactAddress,contactCity:e.contactCity,contactState:e.contactState,contactZipCode:e.contactZipCode,contactCountry:e.contactCountry,contactPhone:$n(e.contactPhone),contactInternationalAddress:e.contactInternationalAddress??"",primaryTaxpayerPin:e.primaryTaxpayerPin??"",dateOfBirth:e.dateOfBirth??"",priorYearAgi:e.priorYearAgi!==null&&e.priorYearAgi!==void 0?String(e.priorYearAgi):"",agiTaxYear:e.agiTaxYear??"",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 Sj=Xt({primarySsn:D().min(1,"Primary SSN is required"),jointFilerSsn:D().optional(),taxpayerNames:D().min(1,"Taxpayer name is required"),primaryAddress:D().min(1,"Primary address is required"),city:D().min(1,"City is required"),state:D().min(1,"State is required"),zipCode:D().min(1,"ZIP code is required"),country:D().min(1,"Country is required"),internationalAddress:D().optional(),primaryPhone:D().min(1,"Primary phone number is required"),primaryContactName:D().min(1,"Primary contact name is required"),primaryContactAddress:D().min(1,"Primary contact address is required"),contactCity:D().min(1,"Contact city is required"),contactState:D().min(1,"Contact state is required"),contactZipCode:D().min(1,"Contact ZIP code is required"),contactCountry:D().min(1,"Contact country is required"),contactPhone:D().min(1,"Contact phone number is required"),contactInternationalAddress:D().optional(),primaryTaxpayerPin:D().min(1,"Primary taxpayer PIN is required").regex(/^\d{5}$/,"Primary taxpayer PIN must be exactly 5 digits"),dateOfBirth:D().min(1,"Date of birth is required").refine(e=>J0(e,od),{message:"You must be at least 18 years old"}),priorYearAgi:D().min(1,"Prior year adjusted gross income is required").refine(e=>!Number.isNaN(Number(e))&&Number(e)>=0,{message:"Enter a valid amount"}),agiTaxYear:D().min(1,"Prior tax year is required"),financialPrimarySsn:D().min(1,"Primary SSN is required"),routingTransitNumber:D().min(1,"Routing transit number is required"),accountNumber:D().min(1,"Account number is required"),accountType:hu([da("Checking"),da("Savings"),da("")]).refine(e=>e==="Checking"||e==="Savings",{message:"Account type is required"}),disclosureAgreementOne:Wn().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),disclosureAgreementTwo:Wn().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),authorityAgreement:Wn().refine(e=>e,{message:"You must accept the authority agreement"}),taxpayerSignature:so,taxpayerTitle:D().min(1,"Title is required"),taxpayerSignatureDate:D().min(1,"Date is required"),jointFilerSignature:Qv,jointFilerTitle:D().optional(),jointFilerSignatureDate:D().optional()}),bn="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",kj="grid gap-x-6 gap-y-5 sm:grid-cols-2 lg:grid-cols-4",Cj=5,od=18;function ld(e){return e?e.toLowerCase()==="savings"?"Savings":"Checking":""}function cd(e,t){return{financialPrimarySsn:(e==null?void 0:e.idNumber)??"",routingTransitNumber:t.routingNumber??"",accountNumber:t.accountNumber??"",accountType:ld(t.accountType)}}function Aj(e,t){const n=new Date().toISOString().slice(0,10),r=e?en(e):"";return{primarySsn:(e==null?void 0:e.idNumber)??"",jointFilerSsn:"",taxpayerNames:r,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)??"US",internationalAddress:"",primaryPhone:e?$n(e.phoneNumber):"",primaryContactName:"",primaryContactAddress:"",contactCity:"",contactState:"",contactZipCode:"",contactCountry:"",contactPhone:"",contactInternationalAddress:"",...cd(e,t),primaryTaxpayerPin:"",dateOfBirth:"",priorYearAgi:"",agiTaxYear:"",disclosureAgreementOne:!1,disclosureAgreementTwo:!1,authorityAgreement:!1,taxpayerSignature:"",taxpayerTitle:"",taxpayerSignatureDate:n,jointFilerSignature:"",jointFilerTitle:"",jointFilerSignatureDate:n}}function Pj({entity:e,paymentDraft:t,initialEnrollment:n=null,readonly:r=!1}){var Ye,re,Ve,rt,bt,pt,vt,zt,jt,Mt,At,Pt,Et,It,qt,Bt,wt,f,N,A,k,_,W,z,H;const a=ke(),i=Se(),o=ft(),l=qn(i.state,Je()),c=Gr(t.paymentAmount),[d,u]=v.useState(null),[m,h]=v.useState(!1),[p,g]=v.useState(!1),{data:x=[]}=ge({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Jr({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:(e==null?void 0:e.entityId)!=null}),b=v.useMemo(()=>{if(n)return Nj(n);const M=x.find(Me=>String(Me.bankAccountDetailId)===t.bankAccountDetailId),ae=cd(e,t);return{...Aj(e,t),financialPrimarySsn:ae.financialPrimarySsn,routingTransitNumber:ae.routingTransitNumber||(M==null?void 0:M.routingNumber)||"",accountNumber:ae.accountNumber||(M==null?void 0:M.accountNumber)||"",accountType:ld(t.accountType||(M==null?void 0:M.accountType))}},[e,n,t,x]),{register:y,handleSubmit:C,watch:j,setValue:S,reset:I,control:R,formState:{errors:E}}=Rt({resolver:Lt(Sj),defaultValues:b});v.useEffect(()=>{I(b)},[b,I]);const T=j("taxpayerSignature"),L=j("jointFilerSignature"),B=j("taxpayerSignatureDate"),K=j("jointFilerSignatureDate"),X=j("accountType"),Y=j("taxpayerNames"),V=j("primaryAddress"),Z=j("city"),ie=j("state"),G=j("zipCode"),Q=j("country"),we=j("primaryPhone"),Ae=j("internationalAddress"),$e=e?en(e):"Entity",ce=!0,pe=!0,$=v.useMemo(()=>Q0(od),[]),fe=()=>{S("primaryContactName",Y,{shouldValidate:!0}),S("primaryContactAddress",V,{shouldValidate:!0}),S("contactCity",Z,{shouldValidate:!0}),S("contactState",ie,{shouldValidate:!0}),S("contactZipCode",G,{shouldValidate:!0}),S("contactCountry",Q,{shouldValidate:!0}),S("contactPhone",we,{shouldValidate:!0}),S("contactInternationalAddress",Ae??"",{shouldValidate:!0})},O=()=>{S("primaryContactName","",{shouldValidate:!0}),S("primaryContactAddress","",{shouldValidate:!0}),S("contactCity","",{shouldValidate:!0}),S("contactState","",{shouldValidate:!0}),S("contactZipCode","",{shouldValidate:!0}),S("contactCountry","",{shouldValidate:!0}),S("contactPhone","",{shouldValidate:!0}),S("contactInternationalAddress","",{shouldValidate:!0})};v.useEffect(()=>{p&&fe()},[p,Y,V,Z,ie,G,Q,we,Ae]);const ue=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},Te=async()=>{if(!e)return null;if(t.federalPaymentId){const ae=await Hi(t.federalPaymentId,Xi(t));return await ue(),ae}const M=await Yi(Gi(e.entityId,t));return to({...t,federalPaymentId:M.federalPaymentId,enrollmentId:M.enrollmentId}),await ue(),M},Ge=async(M,ae)=>{var Vt;const Me=t.form9783EnrollmentId??((Vt=await ad(M))==null?void 0:Vt.form9783EnrollmentId);return Me?gj(Me,wj(ae)):pj(id(M,ae))},Oe=async M=>{if(!e)return;const ae=await Te();ae&&(await Ge(ae.enrollmentId,M),await o.invalidateQueries({queryKey:["form-9783",ae.enrollmentId]}),no(),a(Je()))},le=C(async M=>{if(!(!e||r)){u(null),h(!0);try{await Oe(M)}catch(ae){u(nt(ae,"Failed to save federal payment draft."))}finally{h(!1)}}}),be=C(async M=>{if(!(!e||r)){u(null),h(!0);try{await Oe(M)}catch(ae){u(nt(ae,"Failed to save draft."))}finally{h(!1)}}});return s.jsxs("form",{onSubmit:le,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:$e}),s.jsx(Xr,{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:r,className:"min-w-0 border-0 p-0",children:[s.jsxs(wn,{title:"1. Taxpayer Information",isFirst:!0,children:[s.jsxs("div",{className:bn,children:[s.jsx(J,{label:"1. a) Primary Social Security Number (SSN)",required:!0,error:(Ye=E.primarySsn)==null?void 0:Ye.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:ce,className:ne(!!E.primarySsn,ce),...y("primarySsn")})}),s.jsx(J,{label:"1. b) Joint filer's taxpayer ID No (SSN)",children:s.jsx("input",{placeholder:"Other Identification number (optional)",readOnly:ce,className:ne(!1,ce),...y("jointFilerSsn")})}),s.jsx(J,{label:"2. Taxpayer(S) name(S)",required:!0,error:(re=E.taxpayerNames)==null?void 0:re.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:ce,className:ne(!!E.taxpayerNames,ce),...y("taxpayerNames")})})]}),s.jsxs("div",{className:`mt-5 ${bn}`,children:[s.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:s.jsx(J,{label:"3. a) Primary taxpayer address",required:!0,error:(Ve=E.primaryAddress)==null?void 0:Ve.message,children:s.jsx("input",{placeholder:"Enter",readOnly:ce,className:ne(!!E.primaryAddress,ce),...y("primaryAddress")})})}),s.jsx(J,{label:"3. b) City or Town",required:!0,error:(rt=E.city)==null?void 0:rt.message,children:s.jsx("input",{placeholder:"Enter",readOnly:ce,className:ne(!!E.city,ce),...y("city")})})]}),s.jsxs("div",{className:`mt-5 ${bn}`,children:[s.jsx(J,{label:"3. c) State",required:!0,error:(bt=E.state)==null?void 0:bt.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:ce,className:ne(!!E.state,ce),...y("state")})}),s.jsx(J,{label:"3. d) ZIP code",required:!0,error:(pt=E.zipCode)==null?void 0:pt.message,children:s.jsx("input",{placeholder:"Enter",readOnly:ce,className:ne(!!E.zipCode,ce),...y("zipCode")})}),s.jsx(J,{label:"3. e) Country",required:!0,error:(vt=E.country)==null?void 0:vt.message,children:s.jsx("input",{placeholder:"Enter",readOnly:ce,className:ne(!!E.country,ce),...y("country")})})]}),s.jsxs("div",{className:`mt-5 ${bn}`,children:[s.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:s.jsx(J,{label:"3. f) International address",children:s.jsx("input",{placeholder:"phone number (International number)",readOnly:ce,className:ne(!1,ce),...y("internationalAddress")})})}),s.jsx(J,{label:"4. Primary taxpayer phone number",required:!0,error:(zt=E.primaryPhone)==null?void 0:zt.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:ce,className:ne(!!E.primaryPhone,ce),...y("primaryPhone")})})]})]}),s.jsxs(wn,{title:"2. Contact Information",headerAction:s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"checkbox",checked:p,disabled:r,onChange:M=>{const ae=M.target.checked;g(ae),ae?fe():O()},className:"h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200"}),"Same as Taxpayer Information"]}),children:[s.jsxs("div",{className:bn,children:[s.jsx(J,{label:"5. Primary contact name",required:!0,error:(jt=E.primaryContactName)==null?void 0:jt.message,children:s.jsx("input",{placeholder:"Payer Name",readOnly:p,className:ne(!!E.primaryContactName,p),...y("primaryContactName")})}),s.jsx(J,{label:"6. a) Primary contact address",required:!0,error:(Mt=E.primaryContactAddress)==null?void 0:Mt.message,children:s.jsx("input",{placeholder:"Payer Address",readOnly:p,className:ne(!!E.primaryContactAddress,p),...y("primaryContactAddress")})}),s.jsx(J,{label:"6. b) City or Town",required:!0,error:(At=E.contactCity)==null?void 0:At.message,children:s.jsx("input",{placeholder:"City",readOnly:p,className:ne(!!E.contactCity,p),...y("contactCity")})})]}),s.jsxs("div",{className:`mt-5 ${bn}`,children:[s.jsx(J,{label:"6. c) State",required:!0,error:(Pt=E.contactState)==null?void 0:Pt.message,children:s.jsx("input",{placeholder:"Payer State",readOnly:p,className:ne(!!E.contactState,p),...y("contactState")})}),s.jsx(J,{label:"6. d) ZIP code",required:!0,error:(Et=E.contactZipCode)==null?void 0:Et.message,children:s.jsx("input",{placeholder:"ZIP code",readOnly:p,className:ne(!!E.contactZipCode,p),...y("contactZipCode")})}),s.jsx(J,{label:"6. f) Country",required:!0,error:(It=E.contactCountry)==null?void 0:It.message,children:s.jsx("input",{placeholder:"Country",readOnly:p,className:ne(!!E.contactCountry,p),...y("contactCountry")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-3",children:[s.jsx(J,{label:"7. Primary taxpayer phone number",required:!0,error:(qt=E.contactPhone)==null?void 0:qt.message,children:s.jsx("input",{placeholder:"Payer Phone",readOnly:p,className:ne(!!E.contactPhone,p),...y("contactPhone")})}),s.jsx("div",{className:"sm:col-span-2",children:s.jsx(J,{label:"8. International address",children:s.jsx("input",{placeholder:"Phone Number (International number)",readOnly:p,className:ne(!1,p),...y("contactInternationalAddress")})})})]})]}),s.jsx(wn,{title:"Taxpayer Details *",children:s.jsxs("div",{className:kj,children:[s.jsx(J,{label:"1. Primary Taxpayer Pin",required:!0,error:(Bt=E.primaryTaxpayerPin)==null?void 0:Bt.message,children:s.jsx(Ne,{name:"primaryTaxpayerPin",control:R,render:({field:M})=>s.jsx("input",{placeholder:"Primary Taxpayer Pin",inputMode:"numeric",className:ne(!!E.primaryTaxpayerPin),value:M.value,onChange:ae=>M.onChange(Yn(ae.target.value,Cj)),onBlur:M.onBlur})})}),s.jsx(J,{label:"2. Date of Birth",required:!0,error:(wt=E.dateOfBirth)==null?void 0:wt.message,children:s.jsx("input",{type:"date",max:$,className:ne(!!E.dateOfBirth),...y("dateOfBirth")})}),s.jsx(J,{label:"3. Prior year adjusted gross income",required:!0,error:(f=E.priorYearAgi)==null?void 0:f.message,children:s.jsx("input",{placeholder:"Prior Year Adjusted Gross Income",inputMode:"decimal",className:ne(!!E.priorYearAgi),...y("priorYearAgi")})}),s.jsx(J,{label:"4. Prior Tax Year",required:!0,error:(N=E.agiTaxYear)==null?void 0:N.message,children:s.jsxs("select",{className:Hn(!!E.agiTaxYear),...y("agiTaxYear"),children:[s.jsx("option",{value:"",disabled:!0,children:"AGI Tax Year"}),jj.map(M=>s.jsx("option",{value:M,children:M},M))]})})]})}),s.jsxs(wn,{title:"3. Social Security Number and Financial Institution Information",children:[s.jsxs("div",{className:bn,children:[s.jsx(J,{label:"9. Primary SSN",required:!0,error:(A=E.financialPrimarySsn)==null?void 0:A.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:pe,className:ne(!!E.financialPrimarySsn,pe),...y("financialPrimarySsn")})}),s.jsx(J,{label:"10. Routing Transit Number (RTN)",required:!0,error:(k=E.routingTransitNumber)==null?void 0:k.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:pe,className:ne(!!E.routingTransitNumber,pe),...y("routingTransitNumber")})}),s.jsx(J,{label:"11. Account Number",required:!0,error:(_=E.accountNumber)==null?void 0:_.message,children:s.jsx("input",{placeholder:"Enter",readOnly:pe,className:ne(!!E.accountNumber,pe),...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(M=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:M,checked:X===M,disabled:pe,onChange:()=>S("accountType",M,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),M]},M))}),E.accountType?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:E.accountType.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.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:yj})]}),E.disclosureAgreementOne?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:E.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:bj})]}),E.disclosureAgreementTwo?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:E.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:vj})]}),E.authorityAgreement?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:E.authorityAgreement.message}):null]})]})]}),s.jsxs("section",{className:"mt-8 space-y-8 border-t border-slate-100 pt-8",children:[s.jsx(si,{label:"Taxpayer's Signature",required:!0,signature:y("taxpayerSignature"),title:y("taxpayerTitle"),date:y("taxpayerSignatureDate"),signatureValue:T,dateValue:B,errors:{signature:(W=E.taxpayerSignature)==null?void 0:W.message,title:(z=E.taxpayerTitle)==null?void 0:z.message,date:(H=E.taxpayerSignatureDate)==null?void 0:H.message}}),s.jsx(si,{label:"Joint filer(s) Signature (Optional)",signature:y("jointFilerSignature"),title:y("jointFilerTitle"),date:y("jointFilerSignatureDate"),signatureValue:L??"",dateValue:K??"",signatureCaption:"Signature of joint filer"})]})]})})]}),d?s.jsx("div",{className:"lg:mr-[324px]",children:s.jsx(Ot,{message:d})}):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:m,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:be,disabled:m||!e||r,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:m||!e||r,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 ud(){const{selectedEntity:e}=ht(),t=Se(),{paymentDraft:n}=t.state??{},r=n??ra(),{data:a,isLoading:i}=ge({queryKey:["federal-payment",r==null?void 0:r.federalPaymentId],queryFn:()=>Wi(r.federalPaymentId),enabled:(r==null?void 0:r.federalPaymentId)!=null&&r.enrollmentId==null}),o=(r==null?void 0:r.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=ge({queryKey:["form-9783",o],queryFn:()=>ad(o),enabled:o!=null}),d=v.useMemo(()=>r?{...r,enrollmentId:o??r.enrollmentId,form9783EnrollmentId:r.form9783EnrollmentId??(l==null?void 0:l.form9783EnrollmentId)}:null,[r,o,l]);return r?e&&!Ji(e)?s.jsx(Be,{to:"/payments/federal/authorization",replace:!0,state:t.state}):r.federalPaymentId!=null&&r.enrollmentId==null&&i||o!=null&&c?s.jsx("p",{className:"text-sm text-slate-600",children:"Loading enrollment form…"}):s.jsx(Pj,{entity:e,paymentDraft:d??r,initialEnrollment:l}):s.jsx(Be,{to:"/payments/federal/new",replace:!0})}function Ej(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function Ij({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 Tj({status:e}){const t=e.toLowerCase();let n="bg-slate-100 text-slate-600";return t.includes("submitted to state")||t.includes("submitted to fed")?n="bg-orange-50 text-orange-700":t.includes("irs accepted")?n="bg-emerald-50 text-emerald-700":t.includes("irs rejected")?n="bg-red-50 text-red-600":t.includes("pending")&&(n="bg-amber-50 text-amber-700"),s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${n}`,children:e})}function _j({forms:e=[],isLoading:t=!1,isError:n=!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…"})}):n?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(r=>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(Dj,{className:"h-4 w-4"})}),r.fileName]})}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(Ij,{type:r.type})}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:r.client}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(Tj,{status:r.status})}),s.jsx("td",{className:"px-6 py-4 text-slate-600",children:Ej(r.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"}),r.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]})})]},r.taxFormId))})]})})})}function Dj({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 Fj(){return s.jsx(_j,{})}const kl=160,Rj=88,hs=8;function $j({account:e,entityId:t,onEdit:n}){const r=ft(),{showSuccess:a,showError:i}=Vs(),o=v.useRef(null),l=v.useRef(null),[c,d]=v.useState(!1),[u,m]=v.useState(!1),[h,p]=v.useState({}),g=()=>{var I;const b=o.current;if(!b)return;const y=b.getBoundingClientRect(),C=((I=l.current)==null?void 0:I.offsetHeight)??Rj,S=window.innerHeight-y.bottom<C+hs;p({position:"fixed",top:S?y.top-C-hs:y.bottom+hs,left:Math.max(hs,y.right-kl),width:kl,zIndex:50})};v.useLayoutEffect(()=>{c&&(g(),requestAnimationFrame(g))},[c]),v.useEffect(()=>{if(!c)return;const b=C=>{var S,I;const j=C.target;(S=o.current)!=null&&S.contains(j)||(I=l.current)!=null&&I.contains(j)||d(!1)},y=()=>g();return document.addEventListener("mousedown",b),window.addEventListener("resize",y),window.addEventListener("scroll",y,!0),()=>{document.removeEventListener("mousedown",b),window.removeEventListener("resize",y),window.removeEventListener("scroll",y,!0)}},[c]);const x=async()=>{const b=br(e);m(!0);try{await Au(e.bankAccountDetailId,{status:Av(e)}),await r.invalidateQueries({queryKey:["bank-accounts",t]}),d(!1),b?a("Bank Account Deactivated","Bank account deactivated successfully."):a("Bank Account Activated","Bank account activated successfully.")}catch(y){i("Action Not Completed",nt(y,"Cannot deactivate this bank account because it is linked to a payment that has not been accepted yet."))}finally{m(!1)}};return s.jsxs("div",{className:"inline-block text-left",children:[s.jsxs("button",{ref:o,type:"button",disabled:u,onClick:()=>d(b=>!b),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 disabled:cursor-not-allowed disabled:opacity-60",children:["Actions",s.jsx(Lj,{})]}),c?qr.createPortal(s.jsxs("div",{ref:l,style:h,className:"overflow-hidden rounded-lg border border-slate-200 bg-white py-1 shadow-lg",children:[s.jsx("button",{type:"button",onClick:()=>{d(!1),n(e)},className:"block w-full px-4 py-2 text-left text-sm text-slate-700 hover:bg-slate-50",children:"Edit"}),s.jsx("button",{type:"button",disabled:u,onClick:()=>void x(),className:"block w-full px-4 py-2 text-left text-sm text-slate-700 hover:bg-slate-50 disabled:opacity-60",children:Pv(e)})]}),document.body):null]})}function Lj(){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"})})}const dd=["Checking","Savings"],Oj=Xt({accountNumber:D().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${ur} digits`),routingNumber:D().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Xs(dd,{message:"Account type is required"}),bankName:D().min(1,"Bank name is required")});function zj({open:e,account:t,onClose:n}){const r=ft(),{showSuccess:a,showError:i}=Vs(),[o,l]=v.useState(null),[c,d]=v.useState(!1),{control:u,handleSubmit:m,reset:h,formState:{errors:p}}=Rt({resolver:Lt(Oj),defaultValues:{accountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}});v.useEffect(()=>{!e||!t||(h({accountNumber:t.accountNumber,routingNumber:t.routingNumber,accountType:t.accountType==="Savings"?"Savings":"Checking",bankName:t.bankName}),l(null))},[t,e,h]),v.useEffect(()=>{if(!e)return;const x=b=>{b.key==="Escape"&&n()};return document.addEventListener("keydown",x),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",x),document.body.style.overflow=""}},[e,n]);const g=m(async x=>{if(t){l(null),d(!0);try{await Au(t.bankAccountDetailId,{bankName:x.bankName.trim(),accountNumber:x.accountNumber,routingNumber:x.routingNumber,accountType:x.accountType}),await r.invalidateQueries({queryKey:["bank-accounts",t.entityId]}),a("Bank Account Updated","Bank account updated successfully."),n()}catch(b){const y=nt(b,"Unable to update bank account.");l(y),i("Action Not Completed",y)}finally{d(!1)}}});return!e||!t?null:qr.createPortal(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:n}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"edit-bank-account-title",className:"relative z-10 flex max-h-[90vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl bg-white shadow-xl",children:[s.jsxs("div",{className:"border-b border-slate-200 px-6 py-5",children:[s.jsx("h2",{id:"edit-bank-account-title",className:"text-lg font-bold text-slate-900",children:"Edit Bank Account"}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Update bank account details."})]}),s.jsxs("form",{noValidate:!0,onSubmit:x=>{x.preventDefault(),g(x)},className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"overflow-y-auto px-6 py-6",children:[o?s.jsx("div",{className:"mb-5",children:s.jsx(Ot,{message:o})}):null,s.jsxs(ou,{title:"Bank Account",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsx(Ne,{name:"accountNumber",control:u,render:({field:x})=>{var b;return s.jsx(he,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:x.value,onChange:y=>x.onChange(Yn(y.target.value,ur)),onBlur:x.onBlur,error:(b=p.accountNumber)==null?void 0:b.message})}}),s.jsx(Ne,{name:"routingNumber",control:u,render:({field:x})=>{var b;return s.jsx(he,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:x.value,onChange:y=>x.onChange(Yn(y.target.value,Pu)),onBlur:x.onBlur,error:(b=p.routingNumber)==null?void 0:b.message})}}),s.jsx(Ne,{name:"accountType",control:u,render:({field:x})=>{var b;return s.jsx(xn,{label:"Account Type",required:!0,value:x.value,onChange:x.onChange,onBlur:x.onBlur,error:(b=p.accountType)==null?void 0:b.message,children:dd.map(y=>s.jsx("option",{value:y,children:y},y))})}})]}),s.jsx(Ne,{name:"bankName",control:u,render:({field:x})=>{var b;return s.jsx(he,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:x.value,onChange:x.onChange,onBlur:x.onBlur,error:(b=p.bankName)==null?void 0:b.message})}})]})]}),s.jsxs("div",{className:"flex items-center justify-end gap-3 border-t border-slate-200 px-6 py-4",children:[s.jsx("button",{type:"button",onClick:n,disabled:c,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:c,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:c?"Saving…":"Save Changes"})]})]})]})]}),document.body)}const Ln=[{id:"bank-accounts",title:"Bank Accounts",subtitle:"Connected bank accounts",icon:Mj},{id:"tax-accounts",title:"Tax Accounts",subtitle:"IRS & state tax accounts",icon:qj},{id:"payment-history",title:"Payment History",subtitle:"Past payment transactions",icon:Bj},{id:"entity-details",title:"Entity Details",subtitle:"Your account details",icon:Vj}];function Mj({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 qj({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 Bj({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 Vj({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 dr({title:e,subtitle:t,icon:n,action:r}){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(n,{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})]})]}),r]})}function Uj(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function Zj({status:e}){const t=br({status:e});return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${t?"bg-emerald-50 text-emerald-700":"bg-red-50 text-red-600"}`,children:t?"Active":"In-active"})}function Wj({entityId:e}){const[t,n]=v.useState(!1),[r,a]=v.useState(null),[i,o]=v.useState(1),[l,c]=v.useState(it),d=Ln.find(C=>C.id==="bank-accounts"),u=d.icon;v.useEffect(()=>{o(1)},[e,l]);const{data:m,isLoading:h,isError:p,isFetching:g}=ge({queryKey:["bank-accounts",e,i,l],queryFn:()=>Jr({entityId:e,pageNumber:i,pageSize:l}),enabled:e!==null,placeholderData:C=>C}),x=(m==null?void 0:m.items)??[],b=(m==null?void 0:m.totalCount)??0,y=e!==null&&g;return s.jsxs("div",{children:[s.jsx(dr,{title:d.title,subtitle:d.subtitle,icon:u,action:s.jsxs("button",{type:"button",disabled:!e,onClick:()=>n(!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(Yj,{}),"Add Bank Account"]})}),s.jsx(Iu,{open:t,entityId:e,onClose:()=>n(!1)}),s.jsx(zj,{open:r!==null,account:r,onClose:()=>a(null)}),s.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-slate-200",children:[y?s.jsx(yr,{label:"Loading bank accounts…"}):null,s.jsx("div",{className:"overflow-x-auto",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:h&&!m?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading bank accounts…"})}):p?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?x.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."})}):x.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:Uj(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(Zj,{status:C.status})}),s.jsx("td",{className:"px-5 py-4 text-right",children:s.jsx($j,{account:C,entityId:e,onEdit:a})})]},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."})})})]})}),e!==null?s.jsx(Qr,{page:i,pageSize:l,totalCount:b,onPageChange:o,onPageSizeChange:c,disabled:h||g}):null]})]})}function Yj(){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 Hj({icon:e}){const t="h-5 w-5 text-gov-600";return e==="phone"?s.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 6.75c0 8.284 6.716 15 15 15h2.25a2.25 2.25 0 002.25-2.25v-1.372c0-.516-.351-.966-.852-1.091l-4.423-1.106c-.44-.11-.902.055-1.173.417l-.97 1.293c-.282.376-.769.542-1.21.38a12.035 12.035 0 01-7.143-7.143c-.162-.441.004-.928.38-1.21l1.293-.97c.363-.271.527-.734.417-1.173L6.963 3.102a1.125 1.125 0 00-1.091-.852H4.5A2.25 2.25 0 002.25 4.5v2.25z"})}):e==="account"?s.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",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"})}):s.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})})}function Cr({label:e,value:t,icon:n}){return s.jsx("div",{className:"rounded-xl border border-slate-200 bg-[#F9FAFB] px-4 py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-gov-50",children:s.jsx(Hj,{icon:n})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-xs text-slate-500",children:e}),s.jsx("p",{className:"mt-1 break-words text-sm font-semibold text-slate-900",children:t||"—"})]})]})})}function Kj(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"—"}function Qj({entity:e}){const[t,n]=v.useState(!1),r=Ln.find(c=>c.id==="entity-details"),a=r.icon;if(!e)return s.jsxs("div",{children:[s.jsx(dr,{title:r.title,subtitle:r.subtitle,icon:a}),s.jsx("div",{className:"rounded-xl border border-dashed border-slate-200 bg-slate-50/50 px-6 py-16 text-center",children:s.jsx("p",{className:"text-sm text-slate-500",children:"Select an entity to view its details."})})]});const i=en(e),o=e.accountType==="Business"?i:`${e.firstName} ${e.lastName}`.trim()||i,l=Oi(o);return s.jsxs("div",{children:[s.jsx(dr,{title:r.title,subtitle:r.subtitle,icon:a,action:s.jsx("button",{type:"button",onClick:()=>n(!0),className:"inline-flex items-center rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:"Edit"})}),s.jsxs("div",{className:"mb-8 flex items-center gap-4 border-b border-slate-100 pb-8",children:[s.jsx("span",{className:"flex h-16 w-16 shrink-0 items-center justify-center rounded-full bg-gov-600 text-xl font-semibold text-white",children:l}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-xl font-bold text-slate-900",children:o}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:e.email})]})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx(Cr,{label:"Entity Name",value:i,icon:"entity"}),s.jsx(Cr,{label:e.accountType==="Individual"?"SSN":"Tax ID",value:Hr(e.idNumber,e.accountType),icon:"tax"}),s.jsx(Cr,{label:"Email Address",value:e.email,icon:"email"}),s.jsx(Cr,{label:"Phone Number",value:$n(e.phoneNumber),icon:"phone"}),s.jsx(Cr,{label:"Account Type",value:Kj(e.accountType),icon:"account"})]}),s.jsx(Su,{open:t,entity:e,onClose:()=>n(!1)})]})}function md({activeSection:e,onSectionChange:t,items:n}){return s.jsx("nav",{className:"space-y-2",children:n.map(r=>{const a=e===r.id,i=r.icon;return s.jsxs("button",{type:"button",onClick:()=>t(r.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:r.title}),s.jsx("span",{className:"block truncate text-xs text-slate-500",children:r.subtitle})]}),s.jsx(Jj,{className:`h-4 w-4 shrink-0 ${a?"text-gov-600":"text-slate-300"}`})]},r.id)})})}function Jj({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 Gj({entityId:e}){const t=Ln.find(r=>r.id==="payment-history"),n=t.icon;return s.jsxs("div",{children:[s.jsx(dr,{title:t.title,subtitle:t.subtitle,icon:n,action:s.jsxs("button",{type:"button",disabled:!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(Xj,{}),"Export to Excel"]})}),s.jsx("div",{className:"relative overflow-hidden rounded-xl border border-slate-200",children:s.jsx("div",{className:"overflow-x-auto",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:e?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."})}):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 Xj(){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 e1({entityId:e,pageNumber:t=1,pageSize:n=it}){const r=new URLSearchParams({entityId:String(e),pageNumber:String(t),pageSize:String(n)});return de(`/portal/tax-accounts?${r}`)}function t1(e){return de(`/portal/tax-accounts/${e}`)}function n1(e){return de("/portal/tax-accounts",{method:"POST",body:e})}function r1(e,t){return de(`/portal/tax-accounts/${e}`,{method:"PATCH",body:t})}function s1({entityId:e}){const t=ke(),n=Ln.find(p=>p.id==="tax-accounts"),r=n.icon,[a,i]=v.useState(1),[o,l]=v.useState(it);v.useEffect(()=>{i(1)},[e,o]);const{data:c,isLoading:d,isError:u}=ge({queryKey:["tax-accounts",e,a,o],queryFn:()=>e1({entityId:e,pageNumber:a,pageSize:o}),enabled:e!==null}),m=(c==null?void 0:c.items)??[],h=(c==null?void 0:c.totalCount)??0;return s.jsxs("div",{children:[s.jsx(dr,{title:n.title,subtitle:n.subtitle,icon:r,action:s.jsxs("button",{type:"button",disabled:!e,onClick:()=>t("/settings/tax-accounts/new"),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(a1,{}),"Add Tax Account"]})}),s.jsxs("div",{className:"overflow-hidden rounded-xl border border-slate-200",children:[s.jsx("div",{className:"overflow-x-auto",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:"Actions"})]})}),s.jsx("tbody",{children:e===null?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."})}):d?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Loading tax accounts…"})}):u?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."})}):h===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."})}):m.map(p=>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:p.state}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:p.taxAccountDetailId}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:p.status}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:p.state}),s.jsx("td",{className:"px-5 py-4",children:s.jsx("button",{type:"button",onClick:()=>t(`/settings/tax-accounts/${p.taxAccountDetailId}/edit`),className:"rounded-md px-2.5 py-1.5 text-sm font-medium text-gov-600 transition hover:bg-gov-50 hover:text-gov-700",children:"Edit"})})]},p.taxAccountDetailId))})]})}),e!==null?s.jsx(Qr,{page:a,pageSize:o,totalCount:h,onPageChange:i,onPageSizeChange:l,disabled:d}):null]})]})}function a1(){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 Cl="rounded-2xl border border-slate-200 bg-white shadow-sm";function i1(e){return e==="bank-accounts"||e==="tax-accounts"||e==="payment-history"||e==="entity-details"}function oo(){const{selectedEntity:e}=ht(),n=Se().state,[r,a]=v.useState(i1(n==null?void 0:n.section)?n.section:"bank-accounts");return s.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[s.jsx("div",{className:`${Cl} p-3`,children:s.jsx(md,{items:Ln,activeSection:r,onSectionChange:a})}),s.jsx("div",{className:`${Cl} p-6 lg:p-8`,children:r==="bank-accounts"?s.jsx(Wj,{entityId:(e==null?void 0:e.entityId)??null}):r==="tax-accounts"?s.jsx(s1,{entityId:(e==null?void 0:e.entityId)??null}):r==="payment-history"?s.jsx(Gj,{entityId:(e==null?void 0:e.entityId)??null}):s.jsx(Qj,{entity:e})})]})}function o1({label:e,value:t,onChange:n,options:r,required:a=!1,disabled:i=!1,error:o,placeholder:l="Select a state"}){var C;const[c,d]=v.useState(!1),[u,m]=v.useState(""),h=v.useRef(null),p=v.useRef(null),g=v.useId(),x=(C=r.find(j=>j.code===t))==null?void 0:C.name,b=v.useMemo(()=>{const j=u.trim().toLowerCase();return j?r.filter(S=>S.name.toLowerCase().includes(j)||S.code.toLowerCase().includes(j)):r},[u,r]);v.useEffect(()=>{var j;c&&((j=p.current)==null||j.focus())},[c]),v.useEffect(()=>{if(!c)return;const j=S=>{var I;(I=h.current)!=null&&I.contains(S.target)||d(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[c]);const y=j=>{n(j),m(""),d(!1)};return s.jsxs("div",{ref:h,className:"relative",children:[s.jsx(Yr,{label:e,required:a,htmlFor:g}),s.jsxs("button",{id:g,type:"button",disabled:i,onClick:()=>{m(""),d(j=>!j)},className:`flex w-full items-center justify-between rounded-lg border bg-white px-3 py-2.5 text-left text-sm transition focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:cursor-not-allowed disabled:opacity-60 ${o?"border-red-300":"border-slate-200 focus:border-gov-400"}`,children:[s.jsx("span",{className:x?"text-slate-900":"text-slate-400",children:x??l}),s.jsx(l1,{open:c})]}),c?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:"border-b border-slate-100 p-2",children:s.jsx("input",{ref:p,type:"search",value:u,onChange:j=>m(j.target.value),onKeyDown:j=>{j.key==="Escape"?d(!1):j.key==="Enter"&&j.preventDefault()},placeholder:"Search by state name or code","aria-label":"Search states",className:"w-full rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-900 outline-none transition placeholder:text-slate-400 focus:border-gov-400 focus:bg-white focus:ring-2 focus:ring-gov-100"})}),s.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[b.map(j=>s.jsxs("button",{type:"button",onClick:()=>y(j.code),className:`flex w-full items-center justify-between px-4 py-3 text-left text-sm transition hover:bg-slate-50 ${t===j.code?"bg-gov-50 text-gov-700":"text-slate-700"}`,children:[s.jsx("span",{children:j.name}),s.jsx("span",{className:"text-xs font-medium text-slate-400",children:j.code})]},j.code)),b.length===0?s.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No states found."}):null]})]}):null,o?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:o}):null]})}function l1({open:e}){return s.jsx("svg",{className:`h-4 w-4 shrink-0 text-slate-400 transition ${e?"rotate-180":""}`,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 Al({title:e,subtitle:t,children:n,className:r=""}){return s.jsxs("section",{className:`rounded-xl border border-slate-200 bg-white ${r}`,children:[s.jsxs("div",{className:"border-b border-slate-100 px-5 py-4",children:[s.jsx("h3",{className:"text-sm font-semibold text-slate-900",children:e}),t?s.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:t}):null]}),s.jsx("div",{className:"space-y-5 p-5",children:n})]})}const c1=[{title:"Business Registration",fields:[{name:"virginiaTaxAccountId",label:"Virginia Tax Account ID",required:!0,placeholder:"e.g. 30123456789"},{name:"businessLocationCode",label:"Business Location Code",required:!0,placeholder:"e.g. 001"},{name:"virginiaDepartmentOfTaxationClientNumber",label:"Virginia Department of Taxation Client Number",required:!0,placeholder:"e.g. 12345678"}]},{title:"Payroll / Withholding",fields:[{name:"virginiaWithholdingAccountingId",label:"Virginia Withholding Accounting ID",required:!0,placeholder:"e.g. 30123456789-WTH"},{name:"unemploymentTaxAccountId",label:"Unemployment Tax Account ID",required:!0,placeholder:"e.g. 1234567"}]},{title:"Sales and Franchise Tax",fields:[{name:"franchiseTaxAccount",label:"Franchise Tax Account",required:!0,placeholder:"e.g. 30123456789-FRN"},{name:"transientOccupancyTaxAccountId",label:"Transient Occupancy Tax Account ID",required:!1,placeholder:"e.g. 30123456789-TOT"}]},{title:"Other Registrations",fields:[{name:"certificateOfAuthorityNumber",label:"Certificate of Authority Number (Foreign Entities)",required:!1,placeholder:"e.g. F123456789"},{name:"licensedProfessionalEmployerEntityNumber",label:"Licensed Professional Employer (POE) Entity Number",required:!1,placeholder:"e.g. POE-00123"}]}],u1={VA:c1},d1="United States",m1=Xt({state:D().min(1,"State is required"),city:D().min(1,"City is required"),zipCode:D().min(1,"ZIP code is required"),address1:D().min(1,"Address Line 1 is required"),address2:D().optional(),virginiaTaxAccountId:D().optional(),virginiaWithholdingAccountingId:D().optional(),unemploymentTaxAccountId:D().optional(),virginiaDepartmentOfTaxationClientNumber:D().optional(),businessLocationCode:D().optional(),franchiseTaxAccount:D().optional(),transientOccupancyTaxAccountId:D().optional(),certificateOfAuthorityNumber:D().optional(),licensedProfessionalEmployerEntityNumber:D().optional()}),h1=m1.superRefine((e,t)=>{if(yu.test(e.zipCode.trim())||t.addIssue({code:Qt.custom,message:"Enter a 5-digit ZIP or ZIP+4 (e.g. 12345 or 12345-6789)",path:["zipCode"]}),e.state!=="VA")return;const n=[{key:"virginiaTaxAccountId",label:"Virginia Tax Account ID"},{key:"virginiaWithholdingAccountingId",label:"Virginia Withholding Accounting ID"},{key:"unemploymentTaxAccountId",label:"Unemployment Tax Account ID"},{key:"virginiaDepartmentOfTaxationClientNumber",label:"Virginia Department of Taxation Client Number"},{key:"businessLocationCode",label:"Business Location Code"},{key:"franchiseTaxAccount",label:"Franchise Tax Account"}];for(const r of n){const a=e[r.key];(typeof a!="string"||!a.trim())&&t.addIssue({code:Qt.custom,message:`${r.label} is required`,path:[r.key]})}}),f1={state:"VA",city:"",zipCode:"",address1:"",address2:"",virginiaTaxAccountId:"",virginiaWithholdingAccountingId:"",unemploymentTaxAccountId:"",virginiaDepartmentOfTaxationClientNumber:"",businessLocationCode:"",franchiseTaxAccount:"",transientOccupancyTaxAccountId:"",certificateOfAuthorityNumber:"",licensedProfessionalEmployerEntityNumber:""};function p1(e){const t=e.virginia;return{state:e.state,city:e.city,zipCode:e.zipCode,address1:e.address1,address2:e.address2??"",virginiaTaxAccountId:(t==null?void 0:t.virginiaTaxAccountId)??"",virginiaWithholdingAccountingId:(t==null?void 0:t.virginiaWithholdingAccountingId)??"",unemploymentTaxAccountId:(t==null?void 0:t.unemploymentTaxAccountId)??"",virginiaDepartmentOfTaxationClientNumber:(t==null?void 0:t.virginiaDepartmentOfTaxationClientNumber)??"",businessLocationCode:(t==null?void 0:t.businessLocationCode)??"",franchiseTaxAccount:(t==null?void 0:t.franchiseTaxAccount)??"",transientOccupancyTaxAccountId:(t==null?void 0:t.transientOccupancyTaxAccountId)??"",certificateOfAuthorityNumber:(t==null?void 0:t.certificateOfAuthorityNumber)??"",licensedProfessionalEmployerEntityNumber:(t==null?void 0:t.licensedProfessionalEmployerEntityNumber)??""}}const ys=e=>{const t=e==null?void 0:e.trim();return t||null};function x1(e){var t,n,r,a,i,o;if(e.state==="VA")return{virginiaTaxAccountId:((t=e.virginiaTaxAccountId)==null?void 0:t.trim())??"",virginiaWithholdingAccountingId:((n=e.virginiaWithholdingAccountingId)==null?void 0:n.trim())??"",unemploymentTaxAccountId:((r=e.unemploymentTaxAccountId)==null?void 0:r.trim())??"",virginiaDepartmentOfTaxationClientNumber:((a=e.virginiaDepartmentOfTaxationClientNumber)==null?void 0:a.trim())??"",businessLocationCode:((i=e.businessLocationCode)==null?void 0:i.trim())??"",franchiseTaxAccount:((o=e.franchiseTaxAccount)==null?void 0:o.trim())??"",transientOccupancyTaxAccountId:ys(e.transientOccupancyTaxAccountId),certificateOfAuthorityNumber:ys(e.certificateOfAuthorityNumber),licensedProfessionalEmployerEntityNumber:ys(e.licensedProfessionalEmployerEntityNumber)}}function g1({entityId:e,taxAccountDetailId:t,initialValues:n,onCancel:r,onSuccess:a}){var L,B,K,X,Y,V;const{showSuccess:i}=Vs(),o=ft(),l=t!=null,[c,d]=v.useState(null),[u,m]=v.useState(!1),{register:h,handleSubmit:p,watch:g,setValue:x,formState:{errors:b}}=Rt({resolver:Lt(h1),defaultValues:n??f1}),y=h("zipCode"),C=g("state"),j=g("zipCode"),S=qi(d1),I=u1[C],R=((L=S.find(Z=>Z.code===C))==null?void 0:L.name)??C,E=C.length>0&&j.trim().length>0&&!cr(S,C,j),T=p(async Z=>{if(d(null),!cr(S,Z.state,Z.zipCode)){d(`ZIP code does not match the selected state (${Z.state}).`);return}m(!0);try{const ie={state:Z.state,city:Z.city.trim(),zipCode:Z.zipCode.trim(),address1:Z.address1.trim(),address2:ys(Z.address2),virginia:x1(Z)};if(l)await r1(t,ie);else{const G={entityId:e,...ie};await n1(G)}await o.invalidateQueries({queryKey:["tax-accounts",e]}),i(l?"Tax Account Updated":"Tax Account Added",l?"Tax account details were updated successfully.":"Tax account was created successfully."),a==null||a()}catch(ie){d(nt(ie,"Unable to save tax account. Please try again."))}finally{m(!1)}});return s.jsxs("form",{onSubmit:T,noValidate:!0,className:"max-w-4xl space-y-6",children:[c?s.jsx(Ot,{message:c}):null,s.jsxs("div",{children:[s.jsx("p",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Tax jurisdiction"}),s.jsx("div",{className:"max-w-xs",children:s.jsx(o1,{label:"State",required:!0,value:C,onChange:Z=>x("state",Z,{shouldValidate:!0}),options:S.map(Z=>({code:Z.code,name:Z.name})),error:(B=b.state)==null?void 0:B.message})})]}),s.jsxs(Al,{title:"Common Information",subtitle:"Applies to every state this entity is registered in.",children:[s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(he,{label:"City",required:!0,placeholder:"e.g. Richmond",error:(K=b.city)==null?void 0:K.message,...h("city")}),s.jsx(he,{label:"Zip Code",required:!0,maxLength:10,placeholder:"12345 or 12345-6789",error:((X=b.zipCode)==null?void 0:X.message)??(E?`ZIP code does not match the selected state (${C}).`:void 0),...y,onChange:Z=>{Z.target.value=Mi(Z.target.value),y.onChange(Z)}})]}),s.jsx(he,{label:"Address Line 1",required:!0,placeholder:"e.g. 123 Main Street",error:(Y=b.address1)==null?void 0:Y.message,...h("address1")}),s.jsx(he,{label:"Address Line 2",placeholder:"Suite, unit, etc. (optional)",error:(V=b.address2)==null?void 0:V.message,...h("address2")})]}),I?s.jsx(Al,{title:`${R} Tax Registration`,children:I.map((Z,ie)=>s.jsxs("div",{className:ie>0?"border-t border-slate-100 pt-5":"",children:[s.jsx("h4",{className:"mb-3 text-xs font-semibold uppercase tracking-wide text-gov-700",children:Z.title}),s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:Z.fields.map(G=>{var Q;return s.jsx(he,{label:G.label,required:G.required,placeholder:G.placeholder??"Enter",error:(Q=b[G.name])==null?void 0:Q.message,...h(G.name)},G.name)})})]},Z.title))}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-t border-slate-200 pt-6",children:[s.jsx("button",{type:"button",onClick:r,disabled:u,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:opacity-60",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:u,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:opacity-60",children:u?"Saving…":"Save"})]})]})}const Na="rounded-2xl border border-slate-200 bg-white shadow-sm";function mr(){const e=ke(),{selectedEntity:t}=ht(),n=zs(),r=n.taxAccountDetailId?Number(n.taxAccountDetailId):void 0,a=r!=null,i=Ln.find(m=>m.id==="tax-accounts"),o=i.icon,l=(m="tax-accounts")=>{e("/settings",{state:{section:m}})},{data:c,isLoading:d,isError:u}=ge({queryKey:["tax-account",r],queryFn:()=>t1(r),enabled:a});return t?s.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[s.jsx("div",{className:`${Na} p-3`,children:s.jsx(md,{items:Ln,activeSection:"tax-accounts",onSectionChange:l})}),s.jsxs("div",{className:`${Na} p-6 lg:p-8`,children:[s.jsx(dr,{title:a?"Edit Tax Account":i.title,subtitle:i.subtitle,icon:o}),a&&d?s.jsx("p",{className:"text-sm text-slate-500",children:"Loading tax account…"}):a&&(u||!c)?s.jsx(Ot,{message:"Unable to load this tax account. Please try again."}):s.jsx(g1,{entityId:t.entityId,taxAccountDetailId:r,initialValues:c?p1(c):void 0,onCancel:()=>l("tax-accounts"),onSuccess:()=>l("tax-accounts")})]})]}):s.jsx("div",{className:Na+" p-6 lg:p-8",children:s.jsx("p",{className:"text-sm text-slate-500",children:"Select an entity to add a tax account."})})}function y1({paymentsMode:e="all"}){return s.jsxs(di,{children:[s.jsx(te,{index:!0,element:s.jsx(ji,{})}),s.jsx(te,{path:"create-entity",element:s.jsx(Ni,{})}),s.jsx(te,{path:"create-entity/form",element:s.jsx(Bi,{})}),s.jsxs(te,{element:s.jsx(wi,{}),children:[s.jsx(te,{path:"entities",element:s.jsx(Zi,{})}),s.jsx(te,{path:"dashboard",element:s.jsx(Ui,{})}),s.jsx(te,{path:"payments",element:s.jsx(Ki,{paymentsMode:e})}),s.jsx(te,{path:"payments/federal/new",element:s.jsx(Vu,{})}),s.jsx(te,{path:"payments/federal/:federalPaymentId/edit",element:s.jsx(Zu,{})}),s.jsx(te,{path:"payments/federal/:federalPaymentId/view",element:s.jsx(Wu,{})}),s.jsx(te,{path:"payments/state/new",element:s.jsx(Qu,{})}),s.jsx(te,{path:"payments/state/:statePaymentId/edit",element:s.jsx(Ju,{})}),s.jsx(te,{path:"payments/state/:statePaymentId/view",element:s.jsx(Gu,{})}),s.jsx(te,{path:"payments/state/authorization",element:s.jsx(td,{})}),s.jsx(te,{path:"payments/federal/authorization",element:s.jsx(sd,{})}),s.jsx(te,{path:"payments/federal/individual-enrollment",element:s.jsx(ud,{})}),s.jsx(te,{path:"tax-forms",element:s.jsx(Fj,{})}),s.jsx(te,{path:"settings",element:s.jsx(oo,{})}),s.jsx(te,{path:"settings/tax-accounts/new",element:s.jsx(mr,{})}),s.jsx(te,{path:"settings/tax-accounts/:taxAccountDetailId/edit",element:s.jsx(mr,{})})]}),s.jsx(te,{path:"*",element:s.jsx(Be,{to:"/",replace:!0})})]})}const ai="tax-remittance:payment-complete",b1=v.forwardRef(function(t,n){const r=v.useRef(null),a=v.useRef(null);return v.useImperativeHandle(n,()=>({navigate:i=>{var o;return(o=r.current)==null?void 0:o.call(r,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)},notifyPaymentComplete:i=>{window.dispatchEvent(new CustomEvent(ai,{detail:{paymentId:i}}))}})),s.jsx(vi,{...t,navigateFnRef:r,selectEntityFnRef:a,onPaymentRequired:t.onPaymentRequired,children:s.jsx(y1,{paymentsMode:"all"})})}),v1=v.forwardRef(function(t,n){const r=v.useRef(null),a=v.useRef(null);return v.useImperativeHandle(n,()=>({navigate:i=>{var o;return(o=r.current)==null?void 0:o.call(r,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)},notifyPaymentComplete:i=>{window.dispatchEvent(new CustomEvent("tax-remittance:payment-complete",{detail:{paymentId:i}}))}})),s.jsx(vi,{...t,navigateFnRef:r,selectEntityFnRef:a,enabledPayments:["federal"],children:s.jsxs(di,{children:[s.jsx(te,{index:!0,element:s.jsx(ji,{})}),s.jsx(te,{path:"create-entity",element:s.jsx(Ni,{})}),s.jsx(te,{path:"create-entity/form",element:s.jsx(Bi,{})}),s.jsxs(te,{element:s.jsx(wi,{}),children:[s.jsx(te,{path:"entities",element:s.jsx(Zi,{})}),s.jsx(te,{path:"dashboard",element:s.jsx(Ui,{})}),s.jsx(te,{path:"payments",element:s.jsx(Ki,{paymentsMode:"federal"})}),s.jsx(te,{path:"payments/federal/new",element:s.jsx(Vu,{})}),s.jsx(te,{path:"payments/federal/:federalPaymentId/edit",element:s.jsx(Zu,{})}),s.jsx(te,{path:"payments/federal/:federalPaymentId/view",element:s.jsx(Wu,{})}),s.jsx(te,{path:"payments/federal/authorization",element:s.jsx(sd,{})}),s.jsx(te,{path:"payments/federal/individual-enrollment",element:s.jsx(ud,{})}),s.jsx(te,{path:"settings",element:s.jsx(oo,{})}),s.jsx(te,{path:"settings/tax-accounts/new",element:s.jsx(mr,{})}),s.jsx(te,{path:"settings/tax-accounts/:taxAccountDetailId/edit",element:s.jsx(mr,{})})]}),s.jsx(te,{path:"*",element:s.jsx(Be,{to:"/",replace:!0})})]})})}),j1=v.forwardRef(function(t,n){const r=v.useRef(null),a=v.useRef(null);return v.useImperativeHandle(n,()=>({navigate:i=>{var o;return(o=r.current)==null?void 0:o.call(r,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)},notifyPaymentComplete:i=>{window.dispatchEvent(new CustomEvent("tax-remittance:payment-complete",{detail:{paymentId:i}}))}})),s.jsx(vi,{...t,navigateFnRef:r,selectEntityFnRef:a,enabledPayments:["state"],children:s.jsxs(di,{children:[s.jsx(te,{index:!0,element:s.jsx(ji,{})}),s.jsx(te,{path:"create-entity",element:s.jsx(Ni,{})}),s.jsx(te,{path:"create-entity/form",element:s.jsx(Bi,{})}),s.jsxs(te,{element:s.jsx(wi,{}),children:[s.jsx(te,{path:"entities",element:s.jsx(Zi,{})}),s.jsx(te,{path:"dashboard",element:s.jsx(Ui,{})}),s.jsx(te,{path:"payments",element:s.jsx(Ki,{paymentsMode:"state"})}),s.jsx(te,{path:"payments/state/new",element:s.jsx(Qu,{})}),s.jsx(te,{path:"payments/state/:statePaymentId/edit",element:s.jsx(Ju,{})}),s.jsx(te,{path:"payments/state/:statePaymentId/view",element:s.jsx(Gu,{})}),s.jsx(te,{path:"payments/state/authorization",element:s.jsx(td,{})}),s.jsx(te,{path:"settings",element:s.jsx(oo,{})}),s.jsx(te,{path:"settings/tax-accounts/new",element:s.jsx(mr,{})}),s.jsx(te,{path:"settings/tax-accounts/:taxAccountDetailId/edit",element:s.jsx(mr,{})})]}),s.jsx(te,{path:"*",element:s.jsx(Be,{to:"/",replace:!0})})]})})});exports.ApiError=xr;exports.FederalPaymentWidget=v1;exports.StatePaymentWidget=j1;exports.TaxRemittanceEmbedded=b1;exports.setRuntimeApiBaseUrl=bc;
76
76
  //# sourceMappingURL=index.cjs.map