@techlabi/kycrazy-ui-kit 0.35.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(b,D){typeof exports=="object"&&typeof module<"u"?module.exports=D(require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["react/jsx-runtime","react","react-dom"],D):(b=typeof globalThis<"u"?globalThis:b||self,b.KycrazyUIKit=D(b.jsxRuntime,b.React,b.ReactDOM))})(this,function(b,D,yt){"use strict";var pz=Object.defineProperty;var J_=b=>{throw TypeError(b)};var vz=(b,D,yt)=>D in b?pz(b,D,{enumerable:!0,configurable:!0,writable:!0,value:yt}):b[D]=yt;var km=(b,D,yt)=>vz(b,typeof D!="symbol"?D+"":D,yt),Pm=(b,D,yt)=>D.has(b)||J_("Cannot "+yt);var W=(b,D,yt)=>(Pm(b,D,"read from private field"),yt?yt.call(b):D.get(b)),Ie=(b,D,yt)=>D.has(b)?J_("Cannot add the same private member more than once"):D instanceof WeakSet?D.add(b):D.set(b,yt),ge=(b,D,yt,ya)=>(Pm(b,D,"write to private field"),ya?ya.call(b,yt):D.set(b,yt),yt),He=(b,D,yt)=>(Pm(b,D,"access private method"),yt);var wd=(b,D,yt,ya)=>({set _(_d){ge(b,D,_d,yt)},get _(){return W(b,D,ya)}});var Yr,Ka,W_,Ya,aa,ds,V_,fs,ia,hs,j_,Xa,U_,Za,ps,Jn,Qa,Zt,zu,Ja,yr,$o,z_,An,Qe,Hu,xn,ei,vs,wo,sa,Gu,ms,gs,ti,ni,ua,ys,ut,Yu,Im,Am,Tm,Om,Dm,Mm,Fm,e4,H_,qu,Xr,wn,ri,Zr,ga,G_,Co,br,Ku,q_,_o,ca,Tn,Eo,So,Cd,Rm,K_,Qr,Y_,Pt,la,da,bs,xs,fa,ws,Cs,X_;function ya(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,r.get?r:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}function _d(n,t){for(var e=0;e<t.length;e++){const r=t[e];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in n)){const a=Object.getOwnPropertyDescriptor(r,o);a&&Object.defineProperty(n,o,a.get?a:{enumerable:!0,get:()=>r[o]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}const k=ya(D),Es=ya(yt),t4=1,n4=1e6;let Ed=0;function r4(){return Ed=(Ed+1)%Number.MAX_SAFE_INTEGER,Ed.toString()}const Sd=new Map,Lm=n=>{if(Sd.has(n))return;const t=setTimeout(()=>{Sd.delete(n),Ss({type:"REMOVE_TOAST",toastId:n})},n4);Sd.set(n,t)},o4=(n,t)=>{switch(t.type){case"ADD_TOAST":return{...n,toasts:[t.toast,...n.toasts].slice(0,t4)};case"UPDATE_TOAST":return{...n,toasts:n.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{const{toastId:e}=t;return e?Lm(e):n.toasts.forEach(r=>{Lm(r.id)}),{...n,toasts:n.toasts.map(r=>r.id===e||e===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...n,toasts:[]}:{...n,toasts:n.toasts.filter(e=>e.id!==t.toastId)}}},Xu=[];let Zu={toasts:[]};function Ss(n){Zu=o4(Zu,n),Xu.forEach(t=>{t(Zu)})}function a4({...n}){const t=r4(),e=o=>Ss({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Ss({type:"DISMISS_TOAST",toastId:t});return Ss({type:"ADD_TOAST",toast:{...n,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:e}}function Qu(){const[n,t]=k.useState(Zu);return k.useEffect(()=>(Xu.push(t),()=>{const e=Xu.indexOf(t);e>-1&&Xu.splice(e,1)}),[n]),{...n,toast:a4,dismiss:e=>Ss({type:"DISMISS_TOAST",toastId:e})}}function je(n,t,{checkForDefaultPrevented:e=!0}={}){return function(o){if(n==null||n(o),e===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Bm(n,t){if(typeof n=="function")return n(t);n!=null&&(n.current=t)}function Wm(...n){return t=>{let e=!1;const r=n.map(o=>{const a=Bm(o,t);return!e&&typeof a=="function"&&(e=!0),a});if(e)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():Bm(n[o],null)}}}}function mt(...n){return k.useCallback(Wm(...n),n)}function ba(n,t=[]){let e=[];function r(a,i){const s=k.createContext(i),u=e.length;e=[...e,i];const c=d=>{var g;const{scope:f,children:h,...m}=d,p=((g=f==null?void 0:f[n])==null?void 0:g[u])||s,v=k.useMemo(()=>m,Object.values(m));return b.jsx(p.Provider,{value:v,children:h})};c.displayName=a+"Provider";function l(d,f){var p;const h=((p=f==null?void 0:f[n])==null?void 0:p[u])||s,m=k.useContext(h);if(m)return m;if(i!==void 0)return i;throw new Error(`\`${d}\` must be used within \`${a}\``)}return[c,l]}const o=()=>{const a=e.map(i=>k.createContext(i));return function(s){const u=(s==null?void 0:s[n])||a;return k.useMemo(()=>({[`__scope${n}`]:{...s,[n]:u}}),[s,u])}};return o.scopeName=n,[r,i4(o,...t)]}function i4(...n){const t=n[0];if(n.length===1)return t;const e=()=>{const r=n.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=r.reduce((s,{useScope:u,scopeName:c})=>{const d=u(a)[`__scope${c}`];return{...s,...d}},{});return k.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return e.scopeName=t.scopeName,e}function ai(n){const t=s4(n),e=k.forwardRef((r,o)=>{const{children:a,...i}=r,s=k.Children.toArray(a),u=s.find(c4);if(u){const c=u.props.children,l=s.map(d=>d===u?k.Children.count(c)>1?k.Children.only(null):k.isValidElement(c)?c.props.children:null:d);return b.jsx(t,{...i,ref:o,children:k.isValidElement(c)?k.cloneElement(c,void 0,l):null})}return b.jsx(t,{...i,ref:o,children:a})});return e.displayName=`${n}.Slot`,e}var Vm=ai("Slot");function s4(n){const t=k.forwardRef((e,r)=>{const{children:o,...a}=e;if(k.isValidElement(o)){const i=d4(o),s=l4(a,o.props);return o.type!==k.Fragment&&(s.ref=r?Wm(r,i):i),k.cloneElement(o,s)}return k.Children.count(o)>1?k.Children.only(null):null});return t.displayName=`${n}.SlotClone`,t}var jm=Symbol("radix.slottable");function u4(n){const t=({children:e})=>b.jsx(b.Fragment,{children:e});return t.displayName=`${n}.Slottable`,t.__radixId=jm,t}function c4(n){return k.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===jm}function l4(n,t){const e={...t};for(const r in t){const o=n[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?e[r]=(...s)=>{const u=a(...s);return o(...s),u}:o&&(e[r]=o):r==="style"?e[r]={...o,...a}:r==="className"&&(e[r]=[o,a].filter(Boolean).join(" "))}return{...n,...e}}function d4(n){var r,o;let t=(r=Object.getOwnPropertyDescriptor(n.props,"ref"))==null?void 0:r.get,e=t&&"isReactWarning"in t&&t.isReactWarning;return e?n.ref:(t=(o=Object.getOwnPropertyDescriptor(n,"ref"))==null?void 0:o.get,e=t&&"isReactWarning"in t&&t.isReactWarning,e?n.props.ref:n.props.ref||n.ref)}function Um(n){const t=n+"CollectionProvider",[e,r]=ba(t),[o,a]=e(t,{collectionRef:{current:null},itemMap:new Map}),i=p=>{const{scope:v,children:g}=p,y=D.useRef(null),w=D.useRef(new Map).current;return b.jsx(o,{scope:v,itemMap:w,collectionRef:y,children:g})};i.displayName=t;const s=n+"CollectionSlot",u=ai(s),c=D.forwardRef((p,v)=>{const{scope:g,children:y}=p,w=a(s,g),x=mt(v,w.collectionRef);return b.jsx(u,{ref:x,children:y})});c.displayName=s;const l=n+"CollectionItemSlot",d="data-radix-collection-item",f=ai(l),h=D.forwardRef((p,v)=>{const{scope:g,children:y,...w}=p,x=D.useRef(null),C=mt(v,x),_=a(l,g);return D.useEffect(()=>(_.itemMap.set(x,{ref:x,...w}),()=>void _.itemMap.delete(x))),b.jsx(f,{[d]:"",ref:C,children:y})});h.displayName=l;function m(p){const v=a(n+"CollectionConsumer",p);return D.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const w=Array.from(y.querySelectorAll(`[${d}]`));return Array.from(v.itemMap.values()).sort((_,E)=>w.indexOf(_.ref.current)-w.indexOf(E.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:c,ItemSlot:h},m,r]}var f4=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],et=f4.reduce((n,t)=>{const e=ai(`Primitive.${t}`),r=k.forwardRef((o,a)=>{const{asChild:i,...s}=o,u=i?e:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),b.jsx(u,{...s,ref:a})});return r.displayName=`Primitive.${t}`,{...n,[t]:r}},{});function zm(n,t){n&&Es.flushSync(()=>n.dispatchEvent(t))}function tr(n){const t=k.useRef(n);return k.useEffect(()=>{t.current=n}),k.useMemo(()=>(...e)=>{var r;return(r=t.current)==null?void 0:r.call(t,...e)},[])}function h4(n,t=globalThis==null?void 0:globalThis.document){const e=tr(n);k.useEffect(()=>{const r=o=>{o.key==="Escape"&&e(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[e,t])}var p4="DismissableLayer",Nd="dismissableLayer.update",v4="dismissableLayer.pointerDownOutside",m4="dismissableLayer.focusOutside",Hm,Gm=k.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ns=k.forwardRef((n,t)=>{const{disableOutsidePointerEvents:e=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:s,...u}=n,c=k.useContext(Gm),[l,d]=k.useState(null),f=(l==null?void 0:l.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,h]=k.useState({}),m=mt(t,E=>d(E)),p=Array.from(c.layers),[v]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),g=p.indexOf(v),y=l?p.indexOf(l):-1,w=c.layersWithOutsidePointerEventsDisabled.size>0,x=y>=g,C=y4(E=>{const S=E.target,N=[...c.branches].some($=>$.contains(S));!x||N||(o==null||o(E),i==null||i(E),E.defaultPrevented||s==null||s())},f),_=b4(E=>{const S=E.target;[...c.branches].some($=>$.contains(S))||(a==null||a(E),i==null||i(E),E.defaultPrevented||s==null||s())},f);return h4(E=>{y===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&s&&(E.preventDefault(),s()))},f),k.useEffect(()=>{if(l)return e&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Hm=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(l)),c.layers.add(l),Km(),()=>{e&&c.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Hm)}},[l,f,e,c]),k.useEffect(()=>()=>{l&&(c.layers.delete(l),c.layersWithOutsidePointerEventsDisabled.delete(l),Km())},[l,c]),k.useEffect(()=>{const E=()=>h({});return document.addEventListener(Nd,E),()=>document.removeEventListener(Nd,E)},[]),b.jsx(et.div,{...u,ref:m,style:{pointerEvents:w?x?"auto":"none":void 0,...n.style},onFocusCapture:je(n.onFocusCapture,_.onFocusCapture),onBlurCapture:je(n.onBlurCapture,_.onBlurCapture),onPointerDownCapture:je(n.onPointerDownCapture,C.onPointerDownCapture)})});Ns.displayName=p4;var g4="DismissableLayerBranch",qm=k.forwardRef((n,t)=>{const e=k.useContext(Gm),r=k.useRef(null),o=mt(t,r);return k.useEffect(()=>{const a=r.current;if(a)return e.branches.add(a),()=>{e.branches.delete(a)}},[e.branches]),b.jsx(et.div,{...n,ref:o})});qm.displayName=g4;function y4(n,t=globalThis==null?void 0:globalThis.document){const e=tr(n),r=k.useRef(!1),o=k.useRef(()=>{});return k.useEffect(()=>{const a=s=>{if(s.target&&!r.current){let u=function(){Ym(v4,e,c,{discrete:!0})};const c={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=u,t.addEventListener("click",o.current,{once:!0})):u()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,e]),{onPointerDownCapture:()=>r.current=!0}}function b4(n,t=globalThis==null?void 0:globalThis.document){const e=tr(n),r=k.useRef(!1);return k.useEffect(()=>{const o=a=>{a.target&&!r.current&&Ym(m4,e,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,e]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Km(){const n=new CustomEvent(Nd);document.dispatchEvent(n)}function Ym(n,t,e,{discrete:r}){const o=e.originalEvent.target,a=new CustomEvent(n,{bubbles:!1,cancelable:!0,detail:e});t&&o.addEventListener(n,t,{once:!0}),r?zm(o,a):o.dispatchEvent(a)}var x4=Ns,w4=qm,Jt=globalThis!=null&&globalThis.document?k.useLayoutEffect:()=>{},C4="Portal",Ju=k.forwardRef((n,t)=>{var s;const{container:e,...r}=n,[o,a]=k.useState(!1);Jt(()=>a(!0),[]);const i=e||o&&((s=globalThis==null?void 0:globalThis.document)==null?void 0:s.body);return i?yt.createPortal(b.jsx(et.div,{...r,ref:t}),i):null});Ju.displayName=C4;function _4(n,t){return k.useReducer((e,r)=>t[e][r]??e,n)}var $s=n=>{const{present:t,children:e}=n,r=E4(t),o=typeof e=="function"?e({present:r.isPresent}):k.Children.only(e),a=mt(r.ref,S4(o));return typeof e=="function"||r.isPresent?k.cloneElement(o,{ref:a}):null};$s.displayName="Presence";function E4(n){const[t,e]=k.useState(),r=k.useRef(null),o=k.useRef(n),a=k.useRef("none"),i=n?"mounted":"unmounted",[s,u]=_4(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return k.useEffect(()=>{const c=ec(r.current);a.current=s==="mounted"?c:"none"},[s]),Jt(()=>{const c=r.current,l=o.current;if(l!==n){const f=a.current,h=ec(c);n?u("MOUNT"):h==="none"||(c==null?void 0:c.display)==="none"?u("UNMOUNT"):u(l&&f!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=n}},[n,u]),Jt(()=>{if(t){let c;const l=t.ownerDocument.defaultView??window,d=h=>{const p=ec(r.current).includes(CSS.escape(h.animationName));if(h.target===t&&p&&(u("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",c=l.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},f=h=>{h.target===t&&(a.current=ec(r.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{l.clearTimeout(c),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:k.useCallback(c=>{r.current=c?getComputedStyle(c):null,e(c)},[])}}function ec(n){return(n==null?void 0:n.animationName)||"none"}function S4(n){var r,o;let t=(r=Object.getOwnPropertyDescriptor(n.props,"ref"))==null?void 0:r.get,e=t&&"isReactWarning"in t&&t.isReactWarning;return e?n.ref:(t=(o=Object.getOwnPropertyDescriptor(n,"ref"))==null?void 0:o.get,e=t&&"isReactWarning"in t&&t.isReactWarning,e?n.props.ref:n.props.ref||n.ref)}var N4=k[" useInsertionEffect ".trim().toString()]||Jt;function tc({prop:n,defaultProp:t,onChange:e=()=>{},caller:r}){const[o,a,i]=$4({defaultProp:t,onChange:e}),s=n!==void 0,u=s?n:o;{const l=k.useRef(n!==void 0);k.useEffect(()=>{const d=l.current;d!==s&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),l.current=s},[s,r])}const c=k.useCallback(l=>{var d;if(s){const f=k4(l)?l(n):l;f!==n&&((d=i.current)==null||d.call(i,f))}else a(l)},[s,n,a,i]);return[u,c]}function $4({defaultProp:n,onChange:t}){const[e,r]=k.useState(n),o=k.useRef(e),a=k.useRef(t);return N4(()=>{a.current=t},[t]),k.useEffect(()=>{var i;o.current!==e&&((i=a.current)==null||i.call(a,e),o.current=e)},[e,o]),[e,r,a]}function k4(n){return typeof n=="function"}var Xm=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),P4="VisuallyHidden",nc=k.forwardRef((n,t)=>b.jsx(et.span,{...n,ref:t,style:{...Xm,...n.style}}));nc.displayName=P4;var I4=nc,$d="ToastProvider",[kd,A4,T4]=Um("Toast"),[Zm]=ba("Toast",[T4]),[O4,rc]=Zm($d),Qm=n=>{const{__scopeToast:t,label:e="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:a=50,children:i}=n,[s,u]=k.useState(null),[c,l]=k.useState(0),d=k.useRef(!1),f=k.useRef(!1);return e.trim()||console.error(`Invalid prop \`label\` supplied to \`${$d}\`. Expected non-empty \`string\`.`),b.jsx(kd.Provider,{scope:t,children:b.jsx(O4,{scope:t,label:e,duration:r,swipeDirection:o,swipeThreshold:a,toastCount:c,viewport:s,onViewportChange:u,onToastAdd:k.useCallback(()=>l(h=>h+1),[]),onToastRemove:k.useCallback(()=>l(h=>h-1),[]),isFocusedToastEscapeKeyDownRef:d,isClosePausedRef:f,children:i})})};Qm.displayName=$d;var Jm="ToastViewport",D4=["F8"],Pd="toast.viewportPause",Id="toast.viewportResume",eg=k.forwardRef((n,t)=>{const{__scopeToast:e,hotkey:r=D4,label:o="Notifications ({hotkey})",...a}=n,i=rc(Jm,e),s=A4(e),u=k.useRef(null),c=k.useRef(null),l=k.useRef(null),d=k.useRef(null),f=mt(t,d,i.onViewportChange),h=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),m=i.toastCount>0;k.useEffect(()=>{const v=g=>{var w;r.length!==0&&r.every(x=>g[x]||g.code===x)&&((w=d.current)==null||w.focus())};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[r]),k.useEffect(()=>{const v=u.current,g=d.current;if(m&&v&&g){const y=()=>{if(!i.isClosePausedRef.current){const _=new CustomEvent(Pd);g.dispatchEvent(_),i.isClosePausedRef.current=!0}},w=()=>{if(i.isClosePausedRef.current){const _=new CustomEvent(Id);g.dispatchEvent(_),i.isClosePausedRef.current=!1}},x=_=>{!v.contains(_.relatedTarget)&&w()},C=()=>{v.contains(document.activeElement)||w()};return v.addEventListener("focusin",y),v.addEventListener("focusout",x),v.addEventListener("pointermove",y),v.addEventListener("pointerleave",C),window.addEventListener("blur",y),window.addEventListener("focus",w),()=>{v.removeEventListener("focusin",y),v.removeEventListener("focusout",x),v.removeEventListener("pointermove",y),v.removeEventListener("pointerleave",C),window.removeEventListener("blur",y),window.removeEventListener("focus",w)}}},[m,i.isClosePausedRef]);const p=k.useCallback(({tabbingDirection:v})=>{const y=s().map(w=>{const x=w.ref.current,C=[x,...q4(x)];return v==="forwards"?C:C.reverse()});return(v==="forwards"?y.reverse():y).flat()},[s]);return k.useEffect(()=>{const v=d.current;if(v){const g=y=>{var C,_,E;const w=y.altKey||y.ctrlKey||y.metaKey;if(y.key==="Tab"&&!w){const S=document.activeElement,N=y.shiftKey;if(y.target===v&&N){(C=c.current)==null||C.focus();return}const P=p({tabbingDirection:N?"backwards":"forwards"}),j=P.findIndex(B=>B===S);Od(P.slice(j+1))?y.preventDefault():N?(_=c.current)==null||_.focus():(E=l.current)==null||E.focus()}};return v.addEventListener("keydown",g),()=>v.removeEventListener("keydown",g)}},[s,p]),b.jsxs(w4,{ref:u,role:"region","aria-label":o.replace("{hotkey}",h),tabIndex:-1,style:{pointerEvents:m?void 0:"none"},children:[m&&b.jsx(Ad,{ref:c,onFocusFromOutsideViewport:()=>{const v=p({tabbingDirection:"forwards"});Od(v)}}),b.jsx(kd.Slot,{scope:e,children:b.jsx(et.ol,{tabIndex:-1,...a,ref:f})}),m&&b.jsx(Ad,{ref:l,onFocusFromOutsideViewport:()=>{const v=p({tabbingDirection:"backwards"});Od(v)}})]})});eg.displayName=Jm;var tg="ToastFocusProxy",Ad=k.forwardRef((n,t)=>{const{__scopeToast:e,onFocusFromOutsideViewport:r,...o}=n,a=rc(tg,e);return b.jsx(nc,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const s=i.relatedTarget;!((c=a.viewport)!=null&&c.contains(s))&&r()}})});Ad.displayName=tg;var ks="Toast",M4="toast.swipeStart",F4="toast.swipeMove",R4="toast.swipeCancel",L4="toast.swipeEnd",ng=k.forwardRef((n,t)=>{const{forceMount:e,open:r,defaultOpen:o,onOpenChange:a,...i}=n,[s,u]=tc({prop:r,defaultProp:o??!0,onChange:a,caller:ks});return b.jsx($s,{present:e||s,children:b.jsx(V4,{open:s,...i,ref:t,onClose:()=>u(!1),onPause:tr(n.onPause),onResume:tr(n.onResume),onSwipeStart:je(n.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:je(n.onSwipeMove,c=>{const{x:l,y:d}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${l}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${d}px`)}),onSwipeCancel:je(n.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:je(n.onSwipeEnd,c=>{const{x:l,y:d}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${l}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${d}px`),u(!1)})})})});ng.displayName=ks;var[B4,W4]=Zm(ks,{onClose(){}}),V4=k.forwardRef((n,t)=>{const{__scopeToast:e,type:r="foreground",duration:o,open:a,onClose:i,onEscapeKeyDown:s,onPause:u,onResume:c,onSwipeStart:l,onSwipeMove:d,onSwipeCancel:f,onSwipeEnd:h,...m}=n,p=rc(ks,e),[v,g]=k.useState(null),y=mt(t,B=>g(B)),w=k.useRef(null),x=k.useRef(null),C=o||p.duration,_=k.useRef(0),E=k.useRef(C),S=k.useRef(0),{onToastAdd:N,onToastRemove:$}=p,A=tr(()=>{var z;(v==null?void 0:v.contains(document.activeElement))&&((z=p.viewport)==null||z.focus()),i()}),P=k.useCallback(B=>{!B||B===1/0||(window.clearTimeout(S.current),_.current=new Date().getTime(),S.current=window.setTimeout(A,B))},[A]);k.useEffect(()=>{const B=p.viewport;if(B){const z=()=>{P(E.current),c==null||c()},H=()=>{const F=new Date().getTime()-_.current;E.current=E.current-F,window.clearTimeout(S.current),u==null||u()};return B.addEventListener(Pd,H),B.addEventListener(Id,z),()=>{B.removeEventListener(Pd,H),B.removeEventListener(Id,z)}}},[p.viewport,C,u,c,P]),k.useEffect(()=>{a&&!p.isClosePausedRef.current&&P(C)},[a,C,p.isClosePausedRef,P]),k.useEffect(()=>(N(),()=>$()),[N,$]);const j=k.useMemo(()=>v?cg(v):null,[v]);return p.viewport?b.jsxs(b.Fragment,{children:[j&&b.jsx(j4,{__scopeToast:e,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:j}),b.jsx(B4,{scope:e,onClose:A,children:Es.createPortal(b.jsx(kd.ItemSlot,{scope:e,children:b.jsx(x4,{asChild:!0,onEscapeKeyDown:je(s,()=>{p.isFocusedToastEscapeKeyDownRef.current||A(),p.isFocusedToastEscapeKeyDownRef.current=!1}),children:b.jsx(et.li,{tabIndex:0,"data-state":a?"open":"closed","data-swipe-direction":p.swipeDirection,...m,ref:y,style:{userSelect:"none",touchAction:"none",...n.style},onKeyDown:je(n.onKeyDown,B=>{B.key==="Escape"&&(s==null||s(B.nativeEvent),B.nativeEvent.defaultPrevented||(p.isFocusedToastEscapeKeyDownRef.current=!0,A()))}),onPointerDown:je(n.onPointerDown,B=>{B.button===0&&(w.current={x:B.clientX,y:B.clientY})}),onPointerMove:je(n.onPointerMove,B=>{if(!w.current)return;const z=B.clientX-w.current.x,H=B.clientY-w.current.y,F=!!x.current,M=["left","right"].includes(p.swipeDirection),O=["left","up"].includes(p.swipeDirection)?Math.min:Math.max,I=M?O(0,z):0,L=M?0:O(0,H),K=B.pointerType==="touch"?10:2,q={x:I,y:L},Z={originalEvent:B,delta:q};F?(x.current=q,oc(F4,d,Z,{discrete:!1})):lg(q,p.swipeDirection,K)?(x.current=q,oc(M4,l,Z,{discrete:!1}),B.target.setPointerCapture(B.pointerId)):(Math.abs(z)>K||Math.abs(H)>K)&&(w.current=null)}),onPointerUp:je(n.onPointerUp,B=>{const z=x.current,H=B.target;if(H.hasPointerCapture(B.pointerId)&&H.releasePointerCapture(B.pointerId),x.current=null,w.current=null,z){const F=B.currentTarget,M={originalEvent:B,delta:z};lg(z,p.swipeDirection,p.swipeThreshold)?oc(L4,h,M,{discrete:!0}):oc(R4,f,M,{discrete:!0}),F.addEventListener("click",O=>O.preventDefault(),{once:!0})}})})})}),p.viewport)})]}):null}),j4=n=>{const{__scopeToast:t,children:e,...r}=n,o=rc(ks,t),[a,i]=k.useState(!1),[s,u]=k.useState(!1);return H4(()=>i(!0)),k.useEffect(()=>{const c=window.setTimeout(()=>u(!0),1e3);return()=>window.clearTimeout(c)},[]),s?null:b.jsx(Ju,{asChild:!0,children:b.jsx(nc,{...r,children:a&&b.jsxs(b.Fragment,{children:[o.label," ",e]})})})},U4="ToastTitle",rg=k.forwardRef((n,t)=>{const{__scopeToast:e,...r}=n;return b.jsx(et.div,{...r,ref:t})});rg.displayName=U4;var z4="ToastDescription",og=k.forwardRef((n,t)=>{const{__scopeToast:e,...r}=n;return b.jsx(et.div,{...r,ref:t})});og.displayName=z4;var ag="ToastAction",ig=k.forwardRef((n,t)=>{const{altText:e,...r}=n;return e.trim()?b.jsx(ug,{altText:e,asChild:!0,children:b.jsx(Td,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${ag}\`. Expected non-empty \`string\`.`),null)});ig.displayName=ag;var sg="ToastClose",Td=k.forwardRef((n,t)=>{const{__scopeToast:e,...r}=n,o=W4(sg,e);return b.jsx(ug,{asChild:!0,children:b.jsx(et.button,{type:"button",...r,ref:t,onClick:je(n.onClick,o.onClose)})})});Td.displayName=sg;var ug=k.forwardRef((n,t)=>{const{__scopeToast:e,altText:r,...o}=n;return b.jsx(et.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function cg(n){const t=[];return Array.from(n.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),G4(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",a=r.dataset.radixToastAnnounceExclude==="";if(!o)if(a){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...cg(r))}}),t}function oc(n,t,e,{discrete:r}){const o=e.originalEvent.currentTarget,a=new CustomEvent(n,{bubbles:!0,cancelable:!0,detail:e});t&&o.addEventListener(n,t,{once:!0}),r?zm(o,a):o.dispatchEvent(a)}var lg=(n,t,e=0)=>{const r=Math.abs(n.x),o=Math.abs(n.y),a=r>o;return t==="left"||t==="right"?a&&r>e:!a&&o>e};function H4(n=()=>{}){const t=tr(n);Jt(()=>{let e=0,r=0;return e=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(e),window.cancelAnimationFrame(r)}},[t])}function G4(n){return n.nodeType===n.ELEMENT_NODE}function q4(n){const t=[],e=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;e.nextNode();)t.push(e.currentNode);return t}function Od(n){const t=document.activeElement;return n.some(e=>e===t?!0:(e.focus(),document.activeElement!==t))}var K4=Qm,dg=eg,fg=ng,hg=rg,pg=og,vg=ig,mg=Td;function gg(n){var t,e,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var o=n.length;for(t=0;t<o;t++)n[t]&&(e=gg(n[t]))&&(r&&(r+=" "),r+=e)}else for(e in n)n[e]&&(r&&(r+=" "),r+=e);return r}function yg(){for(var n,t,e=0,r="",o=arguments.length;e<o;e++)(n=arguments[e])&&(t=gg(n))&&(r&&(r+=" "),r+=t);return r}const bg=n=>typeof n=="boolean"?`${n}`:n===0?"0":n,xg=yg,Dd=(n,t)=>e=>{var r;if((t==null?void 0:t.variants)==null)return xg(n,e==null?void 0:e.class,e==null?void 0:e.className);const{variants:o,defaultVariants:a}=t,i=Object.keys(o).map(c=>{const l=e==null?void 0:e[c],d=a==null?void 0:a[c];if(l===null)return null;const f=bg(l)||bg(d);return o[c][f]}),s=e&&Object.entries(e).reduce((c,l)=>{let[d,f]=l;return f===void 0||(c[d]=f),c},{}),u=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,l)=>{let{class:d,className:f,...h}=l;return Object.entries(h).every(m=>{let[p,v]=m;return Array.isArray(v)?v.includes({...a,...s}[p]):{...a,...s}[p]===v})?[...c,d,f]:c},[]);return xg(n,i,u,e==null?void 0:e.class,e==null?void 0:e.className)};/**
|
|
1
|
+
(function(b,D){typeof exports=="object"&&typeof module<"u"?module.exports=D(require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["react/jsx-runtime","react","react-dom"],D):(b=typeof globalThis<"u"?globalThis:b||self,b.KycrazyUIKit=D(b.jsxRuntime,b.React,b.ReactDOM))})(this,function(b,D,yt){"use strict";var vz=Object.defineProperty;var J_=b=>{throw TypeError(b)};var mz=(b,D,yt)=>D in b?vz(b,D,{enumerable:!0,configurable:!0,writable:!0,value:yt}):b[D]=yt;var km=(b,D,yt)=>mz(b,typeof D!="symbol"?D+"":D,yt),Pm=(b,D,yt)=>D.has(b)||J_("Cannot "+yt);var W=(b,D,yt)=>(Pm(b,D,"read from private field"),yt?yt.call(b):D.get(b)),Ie=(b,D,yt)=>D.has(b)?J_("Cannot add the same private member more than once"):D instanceof WeakSet?D.add(b):D.set(b,yt),ge=(b,D,yt,ya)=>(Pm(b,D,"write to private field"),ya?ya.call(b,yt):D.set(b,yt),yt),He=(b,D,yt)=>(Pm(b,D,"access private method"),yt);var wd=(b,D,yt,ya)=>({set _(_d){ge(b,D,_d,yt)},get _(){return W(b,D,ya)}});var Yr,Ka,W_,Ya,aa,ds,V_,fs,ia,hs,j_,Xa,U_,Za,ps,Jn,Qa,Zt,zu,Ja,yr,$o,z_,An,Qe,Hu,xn,ei,vs,wo,sa,Gu,ms,gs,ti,ni,ua,ys,ut,Yu,Im,Am,Tm,Om,Dm,Mm,Fm,e4,H_,qu,Xr,wn,ri,Zr,ga,G_,Co,br,Ku,q_,_o,ca,Tn,Eo,So,Cd,Rm,K_,Qr,Y_,Pt,la,da,bs,xs,fa,ws,Cs,X_;function ya(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,r.get?r:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}function _d(n,t){for(var e=0;e<t.length;e++){const r=t[e];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in n)){const a=Object.getOwnPropertyDescriptor(r,o);a&&Object.defineProperty(n,o,a.get?a:{enumerable:!0,get:()=>r[o]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}const k=ya(D),Es=ya(yt),t4=1,n4=1e6;let Ed=0;function r4(){return Ed=(Ed+1)%Number.MAX_SAFE_INTEGER,Ed.toString()}const Sd=new Map,Lm=n=>{if(Sd.has(n))return;const t=setTimeout(()=>{Sd.delete(n),Ss({type:"REMOVE_TOAST",toastId:n})},n4);Sd.set(n,t)},o4=(n,t)=>{switch(t.type){case"ADD_TOAST":return{...n,toasts:[t.toast,...n.toasts].slice(0,t4)};case"UPDATE_TOAST":return{...n,toasts:n.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{const{toastId:e}=t;return e?Lm(e):n.toasts.forEach(r=>{Lm(r.id)}),{...n,toasts:n.toasts.map(r=>r.id===e||e===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...n,toasts:[]}:{...n,toasts:n.toasts.filter(e=>e.id!==t.toastId)}}},Xu=[];let Zu={toasts:[]};function Ss(n){Zu=o4(Zu,n),Xu.forEach(t=>{t(Zu)})}function a4({...n}){const t=r4(),e=o=>Ss({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Ss({type:"DISMISS_TOAST",toastId:t});return Ss({type:"ADD_TOAST",toast:{...n,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:e}}function Qu(){const[n,t]=k.useState(Zu);return k.useEffect(()=>(Xu.push(t),()=>{const e=Xu.indexOf(t);e>-1&&Xu.splice(e,1)}),[n]),{...n,toast:a4,dismiss:e=>Ss({type:"DISMISS_TOAST",toastId:e})}}function je(n,t,{checkForDefaultPrevented:e=!0}={}){return function(o){if(n==null||n(o),e===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Bm(n,t){if(typeof n=="function")return n(t);n!=null&&(n.current=t)}function Wm(...n){return t=>{let e=!1;const r=n.map(o=>{const a=Bm(o,t);return!e&&typeof a=="function"&&(e=!0),a});if(e)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():Bm(n[o],null)}}}}function mt(...n){return k.useCallback(Wm(...n),n)}function ba(n,t=[]){let e=[];function r(a,i){const s=k.createContext(i),u=e.length;e=[...e,i];const c=d=>{var g;const{scope:f,children:h,...m}=d,p=((g=f==null?void 0:f[n])==null?void 0:g[u])||s,v=k.useMemo(()=>m,Object.values(m));return b.jsx(p.Provider,{value:v,children:h})};c.displayName=a+"Provider";function l(d,f){var p;const h=((p=f==null?void 0:f[n])==null?void 0:p[u])||s,m=k.useContext(h);if(m)return m;if(i!==void 0)return i;throw new Error(`\`${d}\` must be used within \`${a}\``)}return[c,l]}const o=()=>{const a=e.map(i=>k.createContext(i));return function(s){const u=(s==null?void 0:s[n])||a;return k.useMemo(()=>({[`__scope${n}`]:{...s,[n]:u}}),[s,u])}};return o.scopeName=n,[r,i4(o,...t)]}function i4(...n){const t=n[0];if(n.length===1)return t;const e=()=>{const r=n.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=r.reduce((s,{useScope:u,scopeName:c})=>{const d=u(a)[`__scope${c}`];return{...s,...d}},{});return k.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return e.scopeName=t.scopeName,e}function ai(n){const t=s4(n),e=k.forwardRef((r,o)=>{const{children:a,...i}=r,s=k.Children.toArray(a),u=s.find(c4);if(u){const c=u.props.children,l=s.map(d=>d===u?k.Children.count(c)>1?k.Children.only(null):k.isValidElement(c)?c.props.children:null:d);return b.jsx(t,{...i,ref:o,children:k.isValidElement(c)?k.cloneElement(c,void 0,l):null})}return b.jsx(t,{...i,ref:o,children:a})});return e.displayName=`${n}.Slot`,e}var Vm=ai("Slot");function s4(n){const t=k.forwardRef((e,r)=>{const{children:o,...a}=e;if(k.isValidElement(o)){const i=d4(o),s=l4(a,o.props);return o.type!==k.Fragment&&(s.ref=r?Wm(r,i):i),k.cloneElement(o,s)}return k.Children.count(o)>1?k.Children.only(null):null});return t.displayName=`${n}.SlotClone`,t}var jm=Symbol("radix.slottable");function u4(n){const t=({children:e})=>b.jsx(b.Fragment,{children:e});return t.displayName=`${n}.Slottable`,t.__radixId=jm,t}function c4(n){return k.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===jm}function l4(n,t){const e={...t};for(const r in t){const o=n[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?e[r]=(...s)=>{const u=a(...s);return o(...s),u}:o&&(e[r]=o):r==="style"?e[r]={...o,...a}:r==="className"&&(e[r]=[o,a].filter(Boolean).join(" "))}return{...n,...e}}function d4(n){var r,o;let t=(r=Object.getOwnPropertyDescriptor(n.props,"ref"))==null?void 0:r.get,e=t&&"isReactWarning"in t&&t.isReactWarning;return e?n.ref:(t=(o=Object.getOwnPropertyDescriptor(n,"ref"))==null?void 0:o.get,e=t&&"isReactWarning"in t&&t.isReactWarning,e?n.props.ref:n.props.ref||n.ref)}function Um(n){const t=n+"CollectionProvider",[e,r]=ba(t),[o,a]=e(t,{collectionRef:{current:null},itemMap:new Map}),i=p=>{const{scope:v,children:g}=p,y=D.useRef(null),w=D.useRef(new Map).current;return b.jsx(o,{scope:v,itemMap:w,collectionRef:y,children:g})};i.displayName=t;const s=n+"CollectionSlot",u=ai(s),c=D.forwardRef((p,v)=>{const{scope:g,children:y}=p,w=a(s,g),x=mt(v,w.collectionRef);return b.jsx(u,{ref:x,children:y})});c.displayName=s;const l=n+"CollectionItemSlot",d="data-radix-collection-item",f=ai(l),h=D.forwardRef((p,v)=>{const{scope:g,children:y,...w}=p,x=D.useRef(null),C=mt(v,x),_=a(l,g);return D.useEffect(()=>(_.itemMap.set(x,{ref:x,...w}),()=>void _.itemMap.delete(x))),b.jsx(f,{[d]:"",ref:C,children:y})});h.displayName=l;function m(p){const v=a(n+"CollectionConsumer",p);return D.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const w=Array.from(y.querySelectorAll(`[${d}]`));return Array.from(v.itemMap.values()).sort((_,E)=>w.indexOf(_.ref.current)-w.indexOf(E.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:c,ItemSlot:h},m,r]}var f4=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],et=f4.reduce((n,t)=>{const e=ai(`Primitive.${t}`),r=k.forwardRef((o,a)=>{const{asChild:i,...s}=o,u=i?e:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),b.jsx(u,{...s,ref:a})});return r.displayName=`Primitive.${t}`,{...n,[t]:r}},{});function zm(n,t){n&&Es.flushSync(()=>n.dispatchEvent(t))}function tr(n){const t=k.useRef(n);return k.useEffect(()=>{t.current=n}),k.useMemo(()=>(...e)=>{var r;return(r=t.current)==null?void 0:r.call(t,...e)},[])}function h4(n,t=globalThis==null?void 0:globalThis.document){const e=tr(n);k.useEffect(()=>{const r=o=>{o.key==="Escape"&&e(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[e,t])}var p4="DismissableLayer",Nd="dismissableLayer.update",v4="dismissableLayer.pointerDownOutside",m4="dismissableLayer.focusOutside",Hm,Gm=k.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ns=k.forwardRef((n,t)=>{const{disableOutsidePointerEvents:e=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:s,...u}=n,c=k.useContext(Gm),[l,d]=k.useState(null),f=(l==null?void 0:l.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,h]=k.useState({}),m=mt(t,E=>d(E)),p=Array.from(c.layers),[v]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),g=p.indexOf(v),y=l?p.indexOf(l):-1,w=c.layersWithOutsidePointerEventsDisabled.size>0,x=y>=g,C=y4(E=>{const S=E.target,N=[...c.branches].some($=>$.contains(S));!x||N||(o==null||o(E),i==null||i(E),E.defaultPrevented||s==null||s())},f),_=b4(E=>{const S=E.target;[...c.branches].some($=>$.contains(S))||(a==null||a(E),i==null||i(E),E.defaultPrevented||s==null||s())},f);return h4(E=>{y===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&s&&(E.preventDefault(),s()))},f),k.useEffect(()=>{if(l)return e&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Hm=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(l)),c.layers.add(l),Km(),()=>{e&&c.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Hm)}},[l,f,e,c]),k.useEffect(()=>()=>{l&&(c.layers.delete(l),c.layersWithOutsidePointerEventsDisabled.delete(l),Km())},[l,c]),k.useEffect(()=>{const E=()=>h({});return document.addEventListener(Nd,E),()=>document.removeEventListener(Nd,E)},[]),b.jsx(et.div,{...u,ref:m,style:{pointerEvents:w?x?"auto":"none":void 0,...n.style},onFocusCapture:je(n.onFocusCapture,_.onFocusCapture),onBlurCapture:je(n.onBlurCapture,_.onBlurCapture),onPointerDownCapture:je(n.onPointerDownCapture,C.onPointerDownCapture)})});Ns.displayName=p4;var g4="DismissableLayerBranch",qm=k.forwardRef((n,t)=>{const e=k.useContext(Gm),r=k.useRef(null),o=mt(t,r);return k.useEffect(()=>{const a=r.current;if(a)return e.branches.add(a),()=>{e.branches.delete(a)}},[e.branches]),b.jsx(et.div,{...n,ref:o})});qm.displayName=g4;function y4(n,t=globalThis==null?void 0:globalThis.document){const e=tr(n),r=k.useRef(!1),o=k.useRef(()=>{});return k.useEffect(()=>{const a=s=>{if(s.target&&!r.current){let u=function(){Ym(v4,e,c,{discrete:!0})};const c={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=u,t.addEventListener("click",o.current,{once:!0})):u()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,e]),{onPointerDownCapture:()=>r.current=!0}}function b4(n,t=globalThis==null?void 0:globalThis.document){const e=tr(n),r=k.useRef(!1);return k.useEffect(()=>{const o=a=>{a.target&&!r.current&&Ym(m4,e,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,e]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Km(){const n=new CustomEvent(Nd);document.dispatchEvent(n)}function Ym(n,t,e,{discrete:r}){const o=e.originalEvent.target,a=new CustomEvent(n,{bubbles:!1,cancelable:!0,detail:e});t&&o.addEventListener(n,t,{once:!0}),r?zm(o,a):o.dispatchEvent(a)}var x4=Ns,w4=qm,Jt=globalThis!=null&&globalThis.document?k.useLayoutEffect:()=>{},C4="Portal",Ju=k.forwardRef((n,t)=>{var s;const{container:e,...r}=n,[o,a]=k.useState(!1);Jt(()=>a(!0),[]);const i=e||o&&((s=globalThis==null?void 0:globalThis.document)==null?void 0:s.body);return i?yt.createPortal(b.jsx(et.div,{...r,ref:t}),i):null});Ju.displayName=C4;function _4(n,t){return k.useReducer((e,r)=>t[e][r]??e,n)}var $s=n=>{const{present:t,children:e}=n,r=E4(t),o=typeof e=="function"?e({present:r.isPresent}):k.Children.only(e),a=mt(r.ref,S4(o));return typeof e=="function"||r.isPresent?k.cloneElement(o,{ref:a}):null};$s.displayName="Presence";function E4(n){const[t,e]=k.useState(),r=k.useRef(null),o=k.useRef(n),a=k.useRef("none"),i=n?"mounted":"unmounted",[s,u]=_4(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return k.useEffect(()=>{const c=ec(r.current);a.current=s==="mounted"?c:"none"},[s]),Jt(()=>{const c=r.current,l=o.current;if(l!==n){const f=a.current,h=ec(c);n?u("MOUNT"):h==="none"||(c==null?void 0:c.display)==="none"?u("UNMOUNT"):u(l&&f!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=n}},[n,u]),Jt(()=>{if(t){let c;const l=t.ownerDocument.defaultView??window,d=h=>{const p=ec(r.current).includes(CSS.escape(h.animationName));if(h.target===t&&p&&(u("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",c=l.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},f=h=>{h.target===t&&(a.current=ec(r.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{l.clearTimeout(c),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:k.useCallback(c=>{r.current=c?getComputedStyle(c):null,e(c)},[])}}function ec(n){return(n==null?void 0:n.animationName)||"none"}function S4(n){var r,o;let t=(r=Object.getOwnPropertyDescriptor(n.props,"ref"))==null?void 0:r.get,e=t&&"isReactWarning"in t&&t.isReactWarning;return e?n.ref:(t=(o=Object.getOwnPropertyDescriptor(n,"ref"))==null?void 0:o.get,e=t&&"isReactWarning"in t&&t.isReactWarning,e?n.props.ref:n.props.ref||n.ref)}var N4=k[" useInsertionEffect ".trim().toString()]||Jt;function tc({prop:n,defaultProp:t,onChange:e=()=>{},caller:r}){const[o,a,i]=$4({defaultProp:t,onChange:e}),s=n!==void 0,u=s?n:o;{const l=k.useRef(n!==void 0);k.useEffect(()=>{const d=l.current;d!==s&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),l.current=s},[s,r])}const c=k.useCallback(l=>{var d;if(s){const f=k4(l)?l(n):l;f!==n&&((d=i.current)==null||d.call(i,f))}else a(l)},[s,n,a,i]);return[u,c]}function $4({defaultProp:n,onChange:t}){const[e,r]=k.useState(n),o=k.useRef(e),a=k.useRef(t);return N4(()=>{a.current=t},[t]),k.useEffect(()=>{var i;o.current!==e&&((i=a.current)==null||i.call(a,e),o.current=e)},[e,o]),[e,r,a]}function k4(n){return typeof n=="function"}var Xm=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),P4="VisuallyHidden",nc=k.forwardRef((n,t)=>b.jsx(et.span,{...n,ref:t,style:{...Xm,...n.style}}));nc.displayName=P4;var I4=nc,$d="ToastProvider",[kd,A4,T4]=Um("Toast"),[Zm]=ba("Toast",[T4]),[O4,rc]=Zm($d),Qm=n=>{const{__scopeToast:t,label:e="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:a=50,children:i}=n,[s,u]=k.useState(null),[c,l]=k.useState(0),d=k.useRef(!1),f=k.useRef(!1);return e.trim()||console.error(`Invalid prop \`label\` supplied to \`${$d}\`. Expected non-empty \`string\`.`),b.jsx(kd.Provider,{scope:t,children:b.jsx(O4,{scope:t,label:e,duration:r,swipeDirection:o,swipeThreshold:a,toastCount:c,viewport:s,onViewportChange:u,onToastAdd:k.useCallback(()=>l(h=>h+1),[]),onToastRemove:k.useCallback(()=>l(h=>h-1),[]),isFocusedToastEscapeKeyDownRef:d,isClosePausedRef:f,children:i})})};Qm.displayName=$d;var Jm="ToastViewport",D4=["F8"],Pd="toast.viewportPause",Id="toast.viewportResume",eg=k.forwardRef((n,t)=>{const{__scopeToast:e,hotkey:r=D4,label:o="Notifications ({hotkey})",...a}=n,i=rc(Jm,e),s=A4(e),u=k.useRef(null),c=k.useRef(null),l=k.useRef(null),d=k.useRef(null),f=mt(t,d,i.onViewportChange),h=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),m=i.toastCount>0;k.useEffect(()=>{const v=g=>{var w;r.length!==0&&r.every(x=>g[x]||g.code===x)&&((w=d.current)==null||w.focus())};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[r]),k.useEffect(()=>{const v=u.current,g=d.current;if(m&&v&&g){const y=()=>{if(!i.isClosePausedRef.current){const _=new CustomEvent(Pd);g.dispatchEvent(_),i.isClosePausedRef.current=!0}},w=()=>{if(i.isClosePausedRef.current){const _=new CustomEvent(Id);g.dispatchEvent(_),i.isClosePausedRef.current=!1}},x=_=>{!v.contains(_.relatedTarget)&&w()},C=()=>{v.contains(document.activeElement)||w()};return v.addEventListener("focusin",y),v.addEventListener("focusout",x),v.addEventListener("pointermove",y),v.addEventListener("pointerleave",C),window.addEventListener("blur",y),window.addEventListener("focus",w),()=>{v.removeEventListener("focusin",y),v.removeEventListener("focusout",x),v.removeEventListener("pointermove",y),v.removeEventListener("pointerleave",C),window.removeEventListener("blur",y),window.removeEventListener("focus",w)}}},[m,i.isClosePausedRef]);const p=k.useCallback(({tabbingDirection:v})=>{const y=s().map(w=>{const x=w.ref.current,C=[x,...q4(x)];return v==="forwards"?C:C.reverse()});return(v==="forwards"?y.reverse():y).flat()},[s]);return k.useEffect(()=>{const v=d.current;if(v){const g=y=>{var C,_,E;const w=y.altKey||y.ctrlKey||y.metaKey;if(y.key==="Tab"&&!w){const S=document.activeElement,N=y.shiftKey;if(y.target===v&&N){(C=c.current)==null||C.focus();return}const P=p({tabbingDirection:N?"backwards":"forwards"}),j=P.findIndex(B=>B===S);Od(P.slice(j+1))?y.preventDefault():N?(_=c.current)==null||_.focus():(E=l.current)==null||E.focus()}};return v.addEventListener("keydown",g),()=>v.removeEventListener("keydown",g)}},[s,p]),b.jsxs(w4,{ref:u,role:"region","aria-label":o.replace("{hotkey}",h),tabIndex:-1,style:{pointerEvents:m?void 0:"none"},children:[m&&b.jsx(Ad,{ref:c,onFocusFromOutsideViewport:()=>{const v=p({tabbingDirection:"forwards"});Od(v)}}),b.jsx(kd.Slot,{scope:e,children:b.jsx(et.ol,{tabIndex:-1,...a,ref:f})}),m&&b.jsx(Ad,{ref:l,onFocusFromOutsideViewport:()=>{const v=p({tabbingDirection:"backwards"});Od(v)}})]})});eg.displayName=Jm;var tg="ToastFocusProxy",Ad=k.forwardRef((n,t)=>{const{__scopeToast:e,onFocusFromOutsideViewport:r,...o}=n,a=rc(tg,e);return b.jsx(nc,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const s=i.relatedTarget;!((c=a.viewport)!=null&&c.contains(s))&&r()}})});Ad.displayName=tg;var ks="Toast",M4="toast.swipeStart",F4="toast.swipeMove",R4="toast.swipeCancel",L4="toast.swipeEnd",ng=k.forwardRef((n,t)=>{const{forceMount:e,open:r,defaultOpen:o,onOpenChange:a,...i}=n,[s,u]=tc({prop:r,defaultProp:o??!0,onChange:a,caller:ks});return b.jsx($s,{present:e||s,children:b.jsx(V4,{open:s,...i,ref:t,onClose:()=>u(!1),onPause:tr(n.onPause),onResume:tr(n.onResume),onSwipeStart:je(n.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:je(n.onSwipeMove,c=>{const{x:l,y:d}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${l}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${d}px`)}),onSwipeCancel:je(n.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:je(n.onSwipeEnd,c=>{const{x:l,y:d}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${l}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${d}px`),u(!1)})})})});ng.displayName=ks;var[B4,W4]=Zm(ks,{onClose(){}}),V4=k.forwardRef((n,t)=>{const{__scopeToast:e,type:r="foreground",duration:o,open:a,onClose:i,onEscapeKeyDown:s,onPause:u,onResume:c,onSwipeStart:l,onSwipeMove:d,onSwipeCancel:f,onSwipeEnd:h,...m}=n,p=rc(ks,e),[v,g]=k.useState(null),y=mt(t,B=>g(B)),w=k.useRef(null),x=k.useRef(null),C=o||p.duration,_=k.useRef(0),E=k.useRef(C),S=k.useRef(0),{onToastAdd:N,onToastRemove:$}=p,A=tr(()=>{var z;(v==null?void 0:v.contains(document.activeElement))&&((z=p.viewport)==null||z.focus()),i()}),P=k.useCallback(B=>{!B||B===1/0||(window.clearTimeout(S.current),_.current=new Date().getTime(),S.current=window.setTimeout(A,B))},[A]);k.useEffect(()=>{const B=p.viewport;if(B){const z=()=>{P(E.current),c==null||c()},H=()=>{const F=new Date().getTime()-_.current;E.current=E.current-F,window.clearTimeout(S.current),u==null||u()};return B.addEventListener(Pd,H),B.addEventListener(Id,z),()=>{B.removeEventListener(Pd,H),B.removeEventListener(Id,z)}}},[p.viewport,C,u,c,P]),k.useEffect(()=>{a&&!p.isClosePausedRef.current&&P(C)},[a,C,p.isClosePausedRef,P]),k.useEffect(()=>(N(),()=>$()),[N,$]);const j=k.useMemo(()=>v?cg(v):null,[v]);return p.viewport?b.jsxs(b.Fragment,{children:[j&&b.jsx(j4,{__scopeToast:e,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:j}),b.jsx(B4,{scope:e,onClose:A,children:Es.createPortal(b.jsx(kd.ItemSlot,{scope:e,children:b.jsx(x4,{asChild:!0,onEscapeKeyDown:je(s,()=>{p.isFocusedToastEscapeKeyDownRef.current||A(),p.isFocusedToastEscapeKeyDownRef.current=!1}),children:b.jsx(et.li,{tabIndex:0,"data-state":a?"open":"closed","data-swipe-direction":p.swipeDirection,...m,ref:y,style:{userSelect:"none",touchAction:"none",...n.style},onKeyDown:je(n.onKeyDown,B=>{B.key==="Escape"&&(s==null||s(B.nativeEvent),B.nativeEvent.defaultPrevented||(p.isFocusedToastEscapeKeyDownRef.current=!0,A()))}),onPointerDown:je(n.onPointerDown,B=>{B.button===0&&(w.current={x:B.clientX,y:B.clientY})}),onPointerMove:je(n.onPointerMove,B=>{if(!w.current)return;const z=B.clientX-w.current.x,H=B.clientY-w.current.y,F=!!x.current,M=["left","right"].includes(p.swipeDirection),O=["left","up"].includes(p.swipeDirection)?Math.min:Math.max,I=M?O(0,z):0,L=M?0:O(0,H),K=B.pointerType==="touch"?10:2,q={x:I,y:L},Z={originalEvent:B,delta:q};F?(x.current=q,oc(F4,d,Z,{discrete:!1})):lg(q,p.swipeDirection,K)?(x.current=q,oc(M4,l,Z,{discrete:!1}),B.target.setPointerCapture(B.pointerId)):(Math.abs(z)>K||Math.abs(H)>K)&&(w.current=null)}),onPointerUp:je(n.onPointerUp,B=>{const z=x.current,H=B.target;if(H.hasPointerCapture(B.pointerId)&&H.releasePointerCapture(B.pointerId),x.current=null,w.current=null,z){const F=B.currentTarget,M={originalEvent:B,delta:z};lg(z,p.swipeDirection,p.swipeThreshold)?oc(L4,h,M,{discrete:!0}):oc(R4,f,M,{discrete:!0}),F.addEventListener("click",O=>O.preventDefault(),{once:!0})}})})})}),p.viewport)})]}):null}),j4=n=>{const{__scopeToast:t,children:e,...r}=n,o=rc(ks,t),[a,i]=k.useState(!1),[s,u]=k.useState(!1);return H4(()=>i(!0)),k.useEffect(()=>{const c=window.setTimeout(()=>u(!0),1e3);return()=>window.clearTimeout(c)},[]),s?null:b.jsx(Ju,{asChild:!0,children:b.jsx(nc,{...r,children:a&&b.jsxs(b.Fragment,{children:[o.label," ",e]})})})},U4="ToastTitle",rg=k.forwardRef((n,t)=>{const{__scopeToast:e,...r}=n;return b.jsx(et.div,{...r,ref:t})});rg.displayName=U4;var z4="ToastDescription",og=k.forwardRef((n,t)=>{const{__scopeToast:e,...r}=n;return b.jsx(et.div,{...r,ref:t})});og.displayName=z4;var ag="ToastAction",ig=k.forwardRef((n,t)=>{const{altText:e,...r}=n;return e.trim()?b.jsx(ug,{altText:e,asChild:!0,children:b.jsx(Td,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${ag}\`. Expected non-empty \`string\`.`),null)});ig.displayName=ag;var sg="ToastClose",Td=k.forwardRef((n,t)=>{const{__scopeToast:e,...r}=n,o=W4(sg,e);return b.jsx(ug,{asChild:!0,children:b.jsx(et.button,{type:"button",...r,ref:t,onClick:je(n.onClick,o.onClose)})})});Td.displayName=sg;var ug=k.forwardRef((n,t)=>{const{__scopeToast:e,altText:r,...o}=n;return b.jsx(et.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function cg(n){const t=[];return Array.from(n.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),G4(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",a=r.dataset.radixToastAnnounceExclude==="";if(!o)if(a){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...cg(r))}}),t}function oc(n,t,e,{discrete:r}){const o=e.originalEvent.currentTarget,a=new CustomEvent(n,{bubbles:!0,cancelable:!0,detail:e});t&&o.addEventListener(n,t,{once:!0}),r?zm(o,a):o.dispatchEvent(a)}var lg=(n,t,e=0)=>{const r=Math.abs(n.x),o=Math.abs(n.y),a=r>o;return t==="left"||t==="right"?a&&r>e:!a&&o>e};function H4(n=()=>{}){const t=tr(n);Jt(()=>{let e=0,r=0;return e=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(e),window.cancelAnimationFrame(r)}},[t])}function G4(n){return n.nodeType===n.ELEMENT_NODE}function q4(n){const t=[],e=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;e.nextNode();)t.push(e.currentNode);return t}function Od(n){const t=document.activeElement;return n.some(e=>e===t?!0:(e.focus(),document.activeElement!==t))}var K4=Qm,dg=eg,fg=ng,hg=rg,pg=og,vg=ig,mg=Td;function gg(n){var t,e,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var o=n.length;for(t=0;t<o;t++)n[t]&&(e=gg(n[t]))&&(r&&(r+=" "),r+=e)}else for(e in n)n[e]&&(r&&(r+=" "),r+=e);return r}function yg(){for(var n,t,e=0,r="",o=arguments.length;e<o;e++)(n=arguments[e])&&(t=gg(n))&&(r&&(r+=" "),r+=t);return r}const bg=n=>typeof n=="boolean"?`${n}`:n===0?"0":n,xg=yg,Dd=(n,t)=>e=>{var r;if((t==null?void 0:t.variants)==null)return xg(n,e==null?void 0:e.class,e==null?void 0:e.className);const{variants:o,defaultVariants:a}=t,i=Object.keys(o).map(c=>{const l=e==null?void 0:e[c],d=a==null?void 0:a[c];if(l===null)return null;const f=bg(l)||bg(d);return o[c][f]}),s=e&&Object.entries(e).reduce((c,l)=>{let[d,f]=l;return f===void 0||(c[d]=f),c},{}),u=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,l)=>{let{class:d,className:f,...h}=l;return Object.entries(h).every(m=>{let[p,v]=m;return Array.isArray(v)?v.includes({...a,...s}[p]):{...a,...s}[p]===v})?[...c,d,f]:c},[]);return xg(n,i,u,e==null?void 0:e.class,e==null?void 0:e.className)};/**
|
|
2
2
|
* @license lucide-react v0.462.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
* This source code is licensed under the ISC license.
|
|
100
100
|
* See the LICENSE file in the root directory of this source tree.
|
|
101
101
|
*/const Md=an("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Fd="-",sE=n=>{const t=cE(n),{conflictingClassGroups:e,conflictingClassGroupModifiers:r}=n;return{getClassGroupId:i=>{const s=i.split(Fd);return s[0]===""&&s.length!==1&&s.shift(),Ng(s,t)||uE(i)},getConflictingClassGroupIds:(i,s)=>{const u=e[i]||[];return s&&r[i]?[...u,...r[i]]:u}}},Ng=(n,t)=>{var i;if(n.length===0)return t.classGroupId;const e=n[0],r=t.nextPart.get(e),o=r?Ng(n.slice(1),r):void 0;if(o)return o;if(t.validators.length===0)return;const a=n.join(Fd);return(i=t.validators.find(({validator:s})=>s(a)))==null?void 0:i.classGroupId},$g=/^\[(.+)\]$/,uE=n=>{if($g.test(n)){const t=$g.exec(n)[1],e=t==null?void 0:t.substring(0,t.indexOf(":"));if(e)return"arbitrary.."+e}},cE=n=>{const{theme:t,prefix:e}=n,r={nextPart:new Map,validators:[]};return dE(Object.entries(n.classGroups),e).forEach(([a,i])=>{Rd(i,r,a,t)}),r},Rd=(n,t,e,r)=>{n.forEach(o=>{if(typeof o=="string"){const a=o===""?t:kg(t,o);a.classGroupId=e;return}if(typeof o=="function"){if(lE(o)){Rd(o(r),t,e,r);return}t.validators.push({validator:o,classGroupId:e});return}Object.entries(o).forEach(([a,i])=>{Rd(i,kg(t,a),e,r)})})},kg=(n,t)=>{let e=n;return t.split(Fd).forEach(r=>{e.nextPart.has(r)||e.nextPart.set(r,{nextPart:new Map,validators:[]}),e=e.nextPart.get(r)}),e},lE=n=>n.isThemeGetter,dE=(n,t)=>t?n.map(([e,r])=>{const o=r.map(a=>typeof a=="string"?t+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([i,s])=>[t+i,s])):a);return[e,o]}):n,fE=n=>{if(n<1)return{get:()=>{},set:()=>{}};let t=0,e=new Map,r=new Map;const o=(a,i)=>{e.set(a,i),t++,t>n&&(t=0,r=e,e=new Map)};return{get(a){let i=e.get(a);if(i!==void 0)return i;if((i=r.get(a))!==void 0)return o(a,i),i},set(a,i){e.has(a)?e.set(a,i):o(a,i)}}},Pg="!",hE=n=>{const{separator:t,experimentalParseClassName:e}=n,r=t.length===1,o=t[0],a=t.length,i=s=>{const u=[];let c=0,l=0,d;for(let v=0;v<s.length;v++){let g=s[v];if(c===0){if(g===o&&(r||s.slice(v,v+a)===t)){u.push(s.slice(l,v)),l=v+a;continue}if(g==="/"){d=v;continue}}g==="["?c++:g==="]"&&c--}const f=u.length===0?s:s.substring(l),h=f.startsWith(Pg),m=h?f.substring(1):f,p=d&&d>l?d-l:void 0;return{modifiers:u,hasImportantModifier:h,baseClassName:m,maybePostfixModifierPosition:p}};return e?s=>e({className:s,parseClassName:i}):i},pE=n=>{if(n.length<=1)return n;const t=[];let e=[];return n.forEach(r=>{r[0]==="["?(t.push(...e.sort(),r),e=[]):e.push(r)}),t.push(...e.sort()),t},vE=n=>({cache:fE(n.cacheSize),parseClassName:hE(n),...sE(n)}),mE=/\s+/,gE=(n,t)=>{const{parseClassName:e,getClassGroupId:r,getConflictingClassGroupIds:o}=t,a=[],i=n.trim().split(mE);let s="";for(let u=i.length-1;u>=0;u-=1){const c=i[u],{modifiers:l,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:h}=e(c);let m=!!h,p=r(m?f.substring(0,h):f);if(!p){if(!m){s=c+(s.length>0?" "+s:s);continue}if(p=r(f),!p){s=c+(s.length>0?" "+s:s);continue}m=!1}const v=pE(l).join(":"),g=d?v+Pg:v,y=g+p;if(a.includes(y))continue;a.push(y);const w=o(p,m);for(let x=0;x<w.length;++x){const C=w[x];a.push(g+C)}s=c+(s.length>0?" "+s:s)}return s};function yE(){let n=0,t,e,r="";for(;n<arguments.length;)(t=arguments[n++])&&(e=Ig(t))&&(r&&(r+=" "),r+=e);return r}const Ig=n=>{if(typeof n=="string")return n;let t,e="";for(let r=0;r<n.length;r++)n[r]&&(t=Ig(n[r]))&&(e&&(e+=" "),e+=t);return e};function bE(n,...t){let e,r,o,a=i;function i(u){const c=t.reduce((l,d)=>d(l),n());return e=vE(c),r=e.cache.get,o=e.cache.set,a=s,s(u)}function s(u){const c=r(u);if(c)return c;const l=gE(u,e);return o(u,l),l}return function(){return a(yE.apply(null,arguments))}}const pt=n=>{const t=e=>e[n]||[];return t.isThemeGetter=!0,t},Ag=/^\[(?:([a-z-]+):)?(.+)\]$/i,xE=/^\d+\/\d+$/,wE=new Set(["px","full","screen"]),CE=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,_E=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,EE=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,SE=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,NE=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Jr=n=>ii(n)||wE.has(n)||xE.test(n),ko=n=>si(n,"length",DE),ii=n=>!!n&&!Number.isNaN(Number(n)),Ld=n=>si(n,"number",ii),Ps=n=>!!n&&Number.isInteger(Number(n)),$E=n=>n.endsWith("%")&&ii(n.slice(0,-1)),Ue=n=>Ag.test(n),Po=n=>CE.test(n),kE=new Set(["length","size","percentage"]),PE=n=>si(n,kE,Tg),IE=n=>si(n,"position",Tg),AE=new Set(["image","url"]),TE=n=>si(n,AE,FE),OE=n=>si(n,"",ME),Is=()=>!0,si=(n,t,e)=>{const r=Ag.exec(n);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):e(r[2]):!1},DE=n=>_E.test(n)&&!EE.test(n),Tg=()=>!1,ME=n=>SE.test(n),FE=n=>NE.test(n),RE=bE(()=>{const n=pt("colors"),t=pt("spacing"),e=pt("blur"),r=pt("brightness"),o=pt("borderColor"),a=pt("borderRadius"),i=pt("borderSpacing"),s=pt("borderWidth"),u=pt("contrast"),c=pt("grayscale"),l=pt("hueRotate"),d=pt("invert"),f=pt("gap"),h=pt("gradientColorStops"),m=pt("gradientColorStopPositions"),p=pt("inset"),v=pt("margin"),g=pt("opacity"),y=pt("padding"),w=pt("saturate"),x=pt("scale"),C=pt("sepia"),_=pt("skew"),E=pt("space"),S=pt("translate"),N=()=>["auto","contain","none"],$=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto",Ue,t],P=()=>[Ue,t],j=()=>["",Jr,ko],B=()=>["auto",ii,Ue],z=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],H=()=>["solid","dashed","dotted","double","none"],F=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],M=()=>["start","end","center","between","around","evenly","stretch"],O=()=>["","0",Ue],I=()=>["auto","avoid","all","avoid-page","page","left","right","column"],L=()=>[ii,Ue];return{cacheSize:500,separator:":",theme:{colors:[Is],spacing:[Jr,ko],blur:["none","",Po,Ue],brightness:L(),borderColor:[n],borderRadius:["none","","full",Po,Ue],borderSpacing:P(),borderWidth:j(),contrast:L(),grayscale:O(),hueRotate:L(),invert:O(),gap:P(),gradientColorStops:[n],gradientColorStopPositions:[$E,ko],inset:A(),margin:A(),opacity:L(),padding:P(),saturate:L(),scale:L(),sepia:O(),skew:L(),space:P(),translate:P()},classGroups:{aspect:[{aspect:["auto","square","video",Ue]}],container:["container"],columns:[{columns:[Po]}],"break-after":[{"break-after":I()}],"break-before":[{"break-before":I()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...z(),Ue]}],overflow:[{overflow:$()}],"overflow-x":[{"overflow-x":$()}],"overflow-y":[{"overflow-y":$()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[p]}],"inset-x":[{"inset-x":[p]}],"inset-y":[{"inset-y":[p]}],start:[{start:[p]}],end:[{end:[p]}],top:[{top:[p]}],right:[{right:[p]}],bottom:[{bottom:[p]}],left:[{left:[p]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Ps,Ue]}],basis:[{basis:A()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Ue]}],grow:[{grow:O()}],shrink:[{shrink:O()}],order:[{order:["first","last","none",Ps,Ue]}],"grid-cols":[{"grid-cols":[Is]}],"col-start-end":[{col:["auto",{span:["full",Ps,Ue]},Ue]}],"col-start":[{"col-start":B()}],"col-end":[{"col-end":B()}],"grid-rows":[{"grid-rows":[Is]}],"row-start-end":[{row:["auto",{span:[Ps,Ue]},Ue]}],"row-start":[{"row-start":B()}],"row-end":[{"row-end":B()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Ue]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Ue]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...M()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...M(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...M(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[y]}],px:[{px:[y]}],py:[{py:[y]}],ps:[{ps:[y]}],pe:[{pe:[y]}],pt:[{pt:[y]}],pr:[{pr:[y]}],pb:[{pb:[y]}],pl:[{pl:[y]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[E]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[E]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Ue,t]}],"min-w":[{"min-w":[Ue,t,"min","max","fit"]}],"max-w":[{"max-w":[Ue,t,"none","full","min","max","fit","prose",{screen:[Po]},Po]}],h:[{h:[Ue,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Ue,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Ue,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Ue,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Po,ko]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Ld]}],"font-family":[{font:[Is]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Ue]}],"line-clamp":[{"line-clamp":["none",ii,Ld]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Jr,Ue]}],"list-image":[{"list-image":["none",Ue]}],"list-style-type":[{list:["none","disc","decimal",Ue]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[n]}],"placeholder-opacity":[{"placeholder-opacity":[g]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[n]}],"text-opacity":[{"text-opacity":[g]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...H(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Jr,ko]}],"underline-offset":[{"underline-offset":["auto",Jr,Ue]}],"text-decoration-color":[{decoration:[n]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ue]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ue]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[g]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...z(),IE]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",PE]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},TE]}],"bg-color":[{bg:[n]}],"gradient-from-pos":[{from:[m]}],"gradient-via-pos":[{via:[m]}],"gradient-to-pos":[{to:[m]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[s]}],"border-w-x":[{"border-x":[s]}],"border-w-y":[{"border-y":[s]}],"border-w-s":[{"border-s":[s]}],"border-w-e":[{"border-e":[s]}],"border-w-t":[{"border-t":[s]}],"border-w-r":[{"border-r":[s]}],"border-w-b":[{"border-b":[s]}],"border-w-l":[{"border-l":[s]}],"border-opacity":[{"border-opacity":[g]}],"border-style":[{border:[...H(),"hidden"]}],"divide-x":[{"divide-x":[s]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[s]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[g]}],"divide-style":[{divide:H()}],"border-color":[{border:[o]}],"border-color-x":[{"border-x":[o]}],"border-color-y":[{"border-y":[o]}],"border-color-s":[{"border-s":[o]}],"border-color-e":[{"border-e":[o]}],"border-color-t":[{"border-t":[o]}],"border-color-r":[{"border-r":[o]}],"border-color-b":[{"border-b":[o]}],"border-color-l":[{"border-l":[o]}],"divide-color":[{divide:[o]}],"outline-style":[{outline:["",...H()]}],"outline-offset":[{"outline-offset":[Jr,Ue]}],"outline-w":[{outline:[Jr,ko]}],"outline-color":[{outline:[n]}],"ring-w":[{ring:j()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[n]}],"ring-opacity":[{"ring-opacity":[g]}],"ring-offset-w":[{"ring-offset":[Jr,ko]}],"ring-offset-color":[{"ring-offset":[n]}],shadow:[{shadow:["","inner","none",Po,OE]}],"shadow-color":[{shadow:[Is]}],opacity:[{opacity:[g]}],"mix-blend":[{"mix-blend":[...F(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":F()}],filter:[{filter:["","none"]}],blur:[{blur:[e]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",Po,Ue]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[l]}],invert:[{invert:[d]}],saturate:[{saturate:[w]}],sepia:[{sepia:[C]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[e]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[l]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[g]}],"backdrop-saturate":[{"backdrop-saturate":[w]}],"backdrop-sepia":[{"backdrop-sepia":[C]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Ue]}],duration:[{duration:L()}],ease:[{ease:["linear","in","out","in-out",Ue]}],delay:[{delay:L()}],animate:[{animate:["none","spin","ping","pulse","bounce",Ue]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[x]}],"scale-x":[{"scale-x":[x]}],"scale-y":[{"scale-y":[x]}],rotate:[{rotate:[Ps,Ue]}],"translate-x":[{"translate-x":[S]}],"translate-y":[{"translate-y":[S]}],"skew-x":[{"skew-x":[_]}],"skew-y":[{"skew-y":[_]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Ue]}],accent:[{accent:["auto",n]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ue]}],"caret-color":[{caret:[n]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ue]}],fill:[{fill:[n,"none"]}],"stroke-w":[{stroke:[Jr,ko,Ld]}],stroke:[{stroke:[n,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}});function Be(...n){return RE(yg(n))}const LE=K4,Og=k.forwardRef(({className:n,...t},e)=>b.jsx(dg,{ref:e,className:Be("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",n),...t}));Og.displayName=dg.displayName;const BE=Dd("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Dg=k.forwardRef(({className:n,variant:t,...e},r)=>b.jsx(fg,{ref:r,className:Be(BE({variant:t}),n),...e}));Dg.displayName=fg.displayName;const WE=k.forwardRef(({className:n,...t},e)=>b.jsx(vg,{ref:e,className:Be("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",n),...t}));WE.displayName=vg.displayName;const Mg=k.forwardRef(({className:n,...t},e)=>b.jsx(mg,{ref:e,className:Be("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",n),"toast-close":"",...t,children:b.jsx(Md,{className:"h-4 w-4"})}));Mg.displayName=mg.displayName;const Fg=k.forwardRef(({className:n,...t},e)=>b.jsx(hg,{ref:e,className:Be("text-sm font-semibold",n),...t}));Fg.displayName=hg.displayName;const Rg=k.forwardRef(({className:n,...t},e)=>b.jsx(pg,{ref:e,className:Be("text-sm opacity-90",n),...t}));Rg.displayName=pg.displayName;function VE(){const{toasts:n}=Qu();return b.jsxs(LE,{children:[n.map(function({id:t,title:e,description:r,action:o,...a}){return b.jsxs(Dg,{...a,children:[b.jsxs("div",{className:"grid gap-1",children:[e&&b.jsx(Fg,{children:e}),r&&b.jsx(Rg,{children:r})]}),o,b.jsx(Mg,{})]},t)}),b.jsx(Og,{})]})}var Lg=["light","dark"],jE="(prefers-color-scheme: dark)",UE=k.createContext(void 0),zE={setTheme:n=>{},themes:[]},HE=()=>{var n;return(n=k.useContext(UE))!=null?n:zE};k.memo(({forcedTheme:n,storageKey:t,attribute:e,enableSystem:r,enableColorScheme:o,defaultTheme:a,value:i,attrs:s,nonce:u})=>{let c=a==="system",l=e==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${s.map(m=>`'${m}'`).join(",")})`};`:`var d=document.documentElement,n='${e}',s='setAttribute';`,d=o?Lg.includes(a)&&a?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${a}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",f=(m,p=!1,v=!0)=>{let g=i?i[m]:m,y=p?m+"|| ''":`'${g}'`,w="";return o&&v&&!p&&Lg.includes(m)&&(w+=`d.style.colorScheme = '${m}';`),e==="class"?p||g?w+=`c.add(${y})`:w+="null":g&&(w+=`d[s](n,${y})`),w},h=n?`!function(){${l}${f(n)}}()`:r?`!function(){try{${l}var e=localStorage.getItem('${t}');if('system'===e||(!e&&${c})){var t='${jE}',m=window.matchMedia(t);if(m.media!==t||m.matches){${f("dark")}}else{${f("light")}}}else if(e){${i?`var x=${JSON.stringify(i)};`:""}${f(i?"x[e]":"e",!0)}}${c?"":"else{"+f(a,!1,!1)+"}"}${d}}catch(e){}}()`:`!function(){try{${l}var e=localStorage.getItem('${t}');if(e){${i?`var x=${JSON.stringify(i)};`:""}${f(i?"x[e]":"e",!0)}}else{${f(a,!1,!1)};}${d}}catch(t){}}();`;return k.createElement("script",{nonce:u,dangerouslySetInnerHTML:{__html:h}})});var GE=n=>{switch(n){case"success":return YE;case"info":return ZE;case"warning":return XE;case"error":return QE;default:return null}},qE=Array(12).fill(0),KE=({visible:n,className:t})=>D.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":n},D.createElement("div",{className:"sonner-spinner"},qE.map((e,r)=>D.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),YE=D.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},D.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),XE=D.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},D.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),ZE=D.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},D.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),QE=D.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},D.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),JE=D.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},D.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),D.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),eS=()=>{let[n,t]=D.useState(document.hidden);return D.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",e),()=>window.removeEventListener("visibilitychange",e)},[]),n},Bd=1,tS=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let e=this.subscribers.indexOf(t);this.subscribers.splice(e,1)}),this.publish=t=>{this.subscribers.forEach(e=>e(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var e;let{message:r,...o}=t,a=typeof(t==null?void 0:t.id)=="number"||((e=t.id)==null?void 0:e.length)>0?t.id:Bd++,i=this.toasts.find(u=>u.id===a),s=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),i?this.toasts=this.toasts.map(u=>u.id===a?(this.publish({...u,...t,id:a,title:r}),{...u,...t,id:a,dismissible:s,title:r}):u):this.addToast({title:r,...o,dismissible:s,id:a}),a},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(e=>{this.subscribers.forEach(r=>r({id:e.id,dismiss:!0}))}),this.subscribers.forEach(e=>e({id:t,dismiss:!0})),t),this.message=(t,e)=>this.create({...e,message:t}),this.error=(t,e)=>this.create({...e,message:t,type:"error"}),this.success=(t,e)=>this.create({...e,type:"success",message:t}),this.info=(t,e)=>this.create({...e,type:"info",message:t}),this.warning=(t,e)=>this.create({...e,type:"warning",message:t}),this.loading=(t,e)=>this.create({...e,type:"loading",message:t}),this.promise=(t,e)=>{if(!e)return;let r;e.loading!==void 0&&(r=this.create({...e,promise:t,type:"loading",message:e.loading,description:typeof e.description!="function"?e.description:void 0}));let o=t instanceof Promise?t:t(),a=r!==void 0,i,s=o.then(async c=>{if(i=["resolve",c],D.isValidElement(c))a=!1,this.create({id:r,type:"default",message:c});else if(rS(c)&&!c.ok){a=!1;let l=typeof e.error=="function"?await e.error(`HTTP error! status: ${c.status}`):e.error,d=typeof e.description=="function"?await e.description(`HTTP error! status: ${c.status}`):e.description;this.create({id:r,type:"error",message:l,description:d})}else if(e.success!==void 0){a=!1;let l=typeof e.success=="function"?await e.success(c):e.success,d=typeof e.description=="function"?await e.description(c):e.description;this.create({id:r,type:"success",message:l,description:d})}}).catch(async c=>{if(i=["reject",c],e.error!==void 0){a=!1;let l=typeof e.error=="function"?await e.error(c):e.error,d=typeof e.description=="function"?await e.description(c):e.description;this.create({id:r,type:"error",message:l,description:d})}}).finally(()=>{var c;a&&(this.dismiss(r),r=void 0),(c=e.finally)==null||c.call(e)}),u=()=>new Promise((c,l)=>s.then(()=>i[0]==="reject"?l(i[1]):c(i[1])).catch(l));return typeof r!="string"&&typeof r!="number"?{unwrap:u}:Object.assign(r,{unwrap:u})},this.custom=(t,e)=>{let r=(e==null?void 0:e.id)||Bd++;return this.create({jsx:t(r),id:r,...e}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Cn=new tS,nS=(n,t)=>{let e=(t==null?void 0:t.id)||Bd++;return Cn.addToast({title:n,...t,id:e}),e},rS=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",oS=nS,aS=()=>Cn.toasts,iS=()=>Cn.getActiveToasts();Object.assign(oS,{success:Cn.success,info:Cn.info,warning:Cn.warning,error:Cn.error,custom:Cn.custom,message:Cn.message,promise:Cn.promise,dismiss:Cn.dismiss,loading:Cn.loading},{getHistory:aS,getToasts:iS});function sS(n,{insertAt:t}={}){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r),r.styleSheet?r.styleSheet.cssText=n:r.appendChild(document.createTextNode(n))}sS(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
102
|
-
`);function sc(n){return n.label!==void 0}var uS=3,cS="32px",lS="16px",Bg=4e3,dS=356,fS=14,hS=20,pS=200;function nr(...n){return n.filter(Boolean).join(" ")}function vS(n){let[t,e]=n.split("-"),r=[];return t&&r.push(t),e&&r.push(e),r}var mS=n=>{var t,e,r,o,a,i,s,u,c,l,d;let{invert:f,toast:h,unstyled:m,interacting:p,setHeights:v,visibleToasts:g,heights:y,index:w,toasts:x,expanded:C,removeToast:_,defaultRichColors:E,closeButton:S,style:N,cancelButtonStyle:$,actionButtonStyle:A,className:P="",descriptionClassName:j="",duration:B,position:z,gap:H,loadingIcon:F,expandByDefault:M,classNames:O,icons:I,closeButtonAriaLabel:L="Close toast",pauseWhenPageIsHidden:K}=n,[q,Z]=D.useState(null),[oe,ae]=D.useState(null),[X,re]=D.useState(!1),[ce,ue]=D.useState(!1),[se,ee]=D.useState(!1),[_e,Me]=D.useState(!1),[Ye,Ze]=D.useState(!1),[Lt,on]=D.useState(0),[Ct,V]=D.useState(0),Y=D.useRef(h.duration||B||Bg),te=D.useRef(null),he=D.useRef(null),pe=w===0,le=w+1<=g,ye=h.type,We=h.dismissible!==!1,Ge=h.className||"",Qt=h.descriptionClassName||"",xr=D.useMemo(()=>y.findIndex(Ve=>Ve.toastId===h.id)||0,[y,h.id]),er=D.useMemo(()=>{var Ve;return(Ve=h.closeButton)!=null?Ve:S},[h.closeButton,S]),_s=D.useMemo(()=>h.duration||B||Bg,[h.duration,B]),wr=D.useRef(0),On=D.useRef(0),ha=D.useRef(0),No=D.useRef(null),[Nm,xd]=z.split("-"),Z_=D.useMemo(()=>y.reduce((Ve,dt,gt)=>gt>=xr?Ve:Ve+dt.height,0),[y,xr]),Q_=eS(),fz=h.invert||f,$m=ye==="loading";On.current=D.useMemo(()=>xr*H+Z_,[xr,Z_]),D.useEffect(()=>{Y.current=_s},[_s]),D.useEffect(()=>{re(!0)},[]),D.useEffect(()=>{let Ve=he.current;if(Ve){let dt=Ve.getBoundingClientRect().height;return V(dt),v(gt=>[{toastId:h.id,height:dt,position:h.position},...gt]),()=>v(gt=>gt.filter(Cr=>Cr.toastId!==h.id))}},[v,h.id]),D.useLayoutEffect(()=>{if(!X)return;let Ve=he.current,dt=Ve.style.height;Ve.style.height="auto";let gt=Ve.getBoundingClientRect().height;Ve.style.height=dt,V(gt),v(Cr=>Cr.find(_r=>_r.toastId===h.id)?Cr.map(_r=>_r.toastId===h.id?{..._r,height:gt}:_r):[{toastId:h.id,height:gt,position:h.position},...Cr])},[X,h.title,h.description,v,h.id]);let pa=D.useCallback(()=>{ue(!0),on(On.current),v(Ve=>Ve.filter(dt=>dt.toastId!==h.id)),setTimeout(()=>{_(h)},pS)},[h,_,v,On]);D.useEffect(()=>{if(h.promise&&ye==="loading"||h.duration===1/0||h.type==="loading")return;let Ve;return C||p||K&&Q_?(()=>{if(ha.current<wr.current){let dt=new Date().getTime()-wr.current;Y.current=Y.current-dt}ha.current=new Date().getTime()})():Y.current!==1/0&&(wr.current=new Date().getTime(),Ve=setTimeout(()=>{var dt;(dt=h.onAutoClose)==null||dt.call(h,h),pa()},Y.current)),()=>clearTimeout(Ve)},[C,p,h,ye,K,Q_,pa]),D.useEffect(()=>{h.delete&&pa()},[pa,h.delete]);function hz(){var Ve,dt,gt;return I!=null&&I.loading?D.createElement("div",{className:nr(O==null?void 0:O.loader,(Ve=h==null?void 0:h.classNames)==null?void 0:Ve.loader,"sonner-loader"),"data-visible":ye==="loading"},I.loading):F?D.createElement("div",{className:nr(O==null?void 0:O.loader,(dt=h==null?void 0:h.classNames)==null?void 0:dt.loader,"sonner-loader"),"data-visible":ye==="loading"},F):D.createElement(KE,{className:nr(O==null?void 0:O.loader,(gt=h==null?void 0:h.classNames)==null?void 0:gt.loader),visible:ye==="loading"})}return D.createElement("li",{tabIndex:0,ref:he,className:nr(P,Ge,O==null?void 0:O.toast,(t=h==null?void 0:h.classNames)==null?void 0:t.toast,O==null?void 0:O.default,O==null?void 0:O[ye],(e=h==null?void 0:h.classNames)==null?void 0:e[ye]),"data-sonner-toast":"","data-rich-colors":(r=h.richColors)!=null?r:E,"data-styled":!(h.jsx||h.unstyled||m),"data-mounted":X,"data-promise":!!h.promise,"data-swiped":Ye,"data-removed":ce,"data-visible":le,"data-y-position":Nm,"data-x-position":xd,"data-index":w,"data-front":pe,"data-swiping":se,"data-dismissible":We,"data-type":ye,"data-invert":fz,"data-swipe-out":_e,"data-swipe-direction":oe,"data-expanded":!!(C||M&&X),style:{"--index":w,"--toasts-before":w,"--z-index":x.length-w,"--offset":`${ce?Lt:On.current}px`,"--initial-height":M?"auto":`${Ct}px`,...N,...h.style},onDragEnd:()=>{ee(!1),Z(null),No.current=null},onPointerDown:Ve=>{$m||!We||(te.current=new Date,on(On.current),Ve.target.setPointerCapture(Ve.pointerId),Ve.target.tagName!=="BUTTON"&&(ee(!0),No.current={x:Ve.clientX,y:Ve.clientY}))},onPointerUp:()=>{var Ve,dt,gt,Cr;if(_e||!We)return;No.current=null;let _r=Number(((Ve=he.current)==null?void 0:Ve.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),va=Number(((dt=he.current)==null?void 0:dt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),oi=new Date().getTime()-((gt=te.current)==null?void 0:gt.getTime()),Er=q==="x"?_r:va,ma=Math.abs(Er)/oi;if(Math.abs(Er)>=hS||ma>.11){on(On.current),(Cr=h.onDismiss)==null||Cr.call(h,h),ae(q==="x"?_r>0?"right":"left":va>0?"down":"up"),pa(),Me(!0),Ze(!1);return}ee(!1),Z(null)},onPointerMove:Ve=>{var dt,gt,Cr,_r;if(!No.current||!We||((dt=window.getSelection())==null?void 0:dt.toString().length)>0)return;let va=Ve.clientY-No.current.y,oi=Ve.clientX-No.current.x,Er=(gt=n.swipeDirections)!=null?gt:vS(z);!q&&(Math.abs(oi)>1||Math.abs(va)>1)&&Z(Math.abs(oi)>Math.abs(va)?"x":"y");let ma={x:0,y:0};q==="y"?(Er.includes("top")||Er.includes("bottom"))&&(Er.includes("top")&&va<0||Er.includes("bottom")&&va>0)&&(ma.y=va):q==="x"&&(Er.includes("left")||Er.includes("right"))&&(Er.includes("left")&&oi<0||Er.includes("right")&&oi>0)&&(ma.x=oi),(Math.abs(ma.x)>0||Math.abs(ma.y)>0)&&Ze(!0),(Cr=he.current)==null||Cr.style.setProperty("--swipe-amount-x",`${ma.x}px`),(_r=he.current)==null||_r.style.setProperty("--swipe-amount-y",`${ma.y}px`)}},er&&!h.jsx?D.createElement("button",{"aria-label":L,"data-disabled":$m,"data-close-button":!0,onClick:$m||!We?()=>{}:()=>{var Ve;pa(),(Ve=h.onDismiss)==null||Ve.call(h,h)},className:nr(O==null?void 0:O.closeButton,(o=h==null?void 0:h.classNames)==null?void 0:o.closeButton)},(a=I==null?void 0:I.close)!=null?a:JE):null,h.jsx||D.isValidElement(h.title)?h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title:D.createElement(D.Fragment,null,ye||h.icon||h.promise?D.createElement("div",{"data-icon":"",className:nr(O==null?void 0:O.icon,(i=h==null?void 0:h.classNames)==null?void 0:i.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||hz():null,h.type!=="loading"?h.icon||(I==null?void 0:I[ye])||GE(ye):null):null,D.createElement("div",{"data-content":"",className:nr(O==null?void 0:O.content,(s=h==null?void 0:h.classNames)==null?void 0:s.content)},D.createElement("div",{"data-title":"",className:nr(O==null?void 0:O.title,(u=h==null?void 0:h.classNames)==null?void 0:u.title)},typeof h.title=="function"?h.title():h.title),h.description?D.createElement("div",{"data-description":"",className:nr(j,Qt,O==null?void 0:O.description,(c=h==null?void 0:h.classNames)==null?void 0:c.description)},typeof h.description=="function"?h.description():h.description):null),D.isValidElement(h.cancel)?h.cancel:h.cancel&&sc(h.cancel)?D.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||$,onClick:Ve=>{var dt,gt;sc(h.cancel)&&We&&((gt=(dt=h.cancel).onClick)==null||gt.call(dt,Ve),pa())},className:nr(O==null?void 0:O.cancelButton,(l=h==null?void 0:h.classNames)==null?void 0:l.cancelButton)},h.cancel.label):null,D.isValidElement(h.action)?h.action:h.action&&sc(h.action)?D.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||A,onClick:Ve=>{var dt,gt;sc(h.action)&&((gt=(dt=h.action).onClick)==null||gt.call(dt,Ve),!Ve.defaultPrevented&&pa())},className:nr(O==null?void 0:O.actionButton,(d=h==null?void 0:h.classNames)==null?void 0:d.actionButton)},h.action.label):null))};function Wg(){if(typeof window>"u"||typeof document>"u")return"ltr";let n=document.documentElement.getAttribute("dir");return n==="auto"||!n?window.getComputedStyle(document.documentElement).direction:n}function gS(n,t){let e={};return[n,t].forEach((r,o)=>{let a=o===1,i=a?"--mobile-offset":"--offset",s=a?lS:cS;function u(c){["top","right","bottom","left"].forEach(l=>{e[`${i}-${l}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?u(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?e[`${i}-${c}`]=s:e[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):u(s)}),e}var yS=D.forwardRef(function(n,t){let{invert:e,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:a,closeButton:i,className:s,offset:u,mobileOffset:c,theme:l="light",richColors:d,duration:f,style:h,visibleToasts:m=uS,toastOptions:p,dir:v=Wg(),gap:g=fS,loadingIcon:y,icons:w,containerAriaLabel:x="Notifications",pauseWhenPageIsHidden:C}=n,[_,E]=D.useState([]),S=D.useMemo(()=>Array.from(new Set([r].concat(_.filter(K=>K.position).map(K=>K.position)))),[_,r]),[N,$]=D.useState([]),[A,P]=D.useState(!1),[j,B]=D.useState(!1),[z,H]=D.useState(l!=="system"?l:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),F=D.useRef(null),M=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),O=D.useRef(null),I=D.useRef(!1),L=D.useCallback(K=>{E(q=>{var Z;return(Z=q.find(oe=>oe.id===K.id))!=null&&Z.delete||Cn.dismiss(K.id),q.filter(({id:oe})=>oe!==K.id)})},[]);return D.useEffect(()=>Cn.subscribe(K=>{if(K.dismiss){E(q=>q.map(Z=>Z.id===K.id?{...Z,delete:!0}:Z));return}setTimeout(()=>{yt.flushSync(()=>{E(q=>{let Z=q.findIndex(oe=>oe.id===K.id);return Z!==-1?[...q.slice(0,Z),{...q[Z],...K},...q.slice(Z+1)]:[K,...q]})})})}),[]),D.useEffect(()=>{if(l!=="system"){H(l);return}if(l==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?H("dark"):H("light")),typeof window>"u")return;let K=window.matchMedia("(prefers-color-scheme: dark)");try{K.addEventListener("change",({matches:q})=>{H(q?"dark":"light")})}catch{K.addListener(({matches:Z})=>{try{H(Z?"dark":"light")}catch(oe){console.error(oe)}})}},[l]),D.useEffect(()=>{_.length<=1&&P(!1)},[_]),D.useEffect(()=>{let K=q=>{var Z,oe;o.every(ae=>q[ae]||q.code===ae)&&(P(!0),(Z=F.current)==null||Z.focus()),q.code==="Escape"&&(document.activeElement===F.current||(oe=F.current)!=null&&oe.contains(document.activeElement))&&P(!1)};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[o]),D.useEffect(()=>{if(F.current)return()=>{O.current&&(O.current.focus({preventScroll:!0}),O.current=null,I.current=!1)}},[F.current]),D.createElement("section",{ref:t,"aria-label":`${x} ${M}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},S.map((K,q)=>{var Z;let[oe,ae]=K.split("-");return _.length?D.createElement("ol",{key:K,dir:v==="auto"?Wg():v,tabIndex:-1,ref:F,className:s,"data-sonner-toaster":!0,"data-theme":z,"data-y-position":oe,"data-lifted":A&&_.length>1&&!a,"data-x-position":ae,style:{"--front-toast-height":`${((Z=N[0])==null?void 0:Z.height)||0}px`,"--width":`${dS}px`,"--gap":`${g}px`,...h,...gS(u,c)},onBlur:X=>{I.current&&!X.currentTarget.contains(X.relatedTarget)&&(I.current=!1,O.current&&(O.current.focus({preventScroll:!0}),O.current=null))},onFocus:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||I.current||(I.current=!0,O.current=X.relatedTarget)},onMouseEnter:()=>P(!0),onMouseMove:()=>P(!0),onMouseLeave:()=>{j||P(!1)},onDragEnd:()=>P(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||B(!0)},onPointerUp:()=>B(!1)},_.filter(X=>!X.position&&q===0||X.position===K).map((X,re)=>{var ce,ue;return D.createElement(mS,{key:X.id,icons:w,index:re,toast:X,defaultRichColors:d,duration:(ce=p==null?void 0:p.duration)!=null?ce:f,className:p==null?void 0:p.className,descriptionClassName:p==null?void 0:p.descriptionClassName,invert:e,visibleToasts:m,closeButton:(ue=p==null?void 0:p.closeButton)!=null?ue:i,interacting:j,position:K,style:p==null?void 0:p.style,unstyled:p==null?void 0:p.unstyled,classNames:p==null?void 0:p.classNames,cancelButtonStyle:p==null?void 0:p.cancelButtonStyle,actionButtonStyle:p==null?void 0:p.actionButtonStyle,removeToast:L,toasts:_.filter(se=>se.position==X.position),heights:N.filter(se=>se.position==X.position),setHeights:$,expandByDefault:a,gap:g,loadingIcon:y,expanded:A,pauseWhenPageIsHidden:C,swipeDirections:n.swipeDirections})})):null}))});const bS=({...n})=>{const{theme:t="system"}=HE();return b.jsx(yS,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...n})};var xS=k[" useId ".trim().toString()]||(()=>{}),wS=0;function uc(n){const[t,e]=k.useState(xS());return Jt(()=>{e(r=>r??String(wS++))},[n]),t?`radix-${t}`:""}const CS=["top","right","bottom","left"],Io=Math.min,Dn=Math.max,cc=Math.round,lc=Math.floor,Sr=n=>({x:n,y:n}),_S={left:"right",right:"left",bottom:"top",top:"bottom"},ES={start:"end",end:"start"};function Wd(n,t,e){return Dn(n,Io(t,e))}function eo(n,t){return typeof n=="function"?n(t):n}function to(n){return n.split("-")[0]}function ui(n){return n.split("-")[1]}function Vd(n){return n==="x"?"y":"x"}function jd(n){return n==="y"?"height":"width"}const SS=new Set(["top","bottom"]);function Nr(n){return SS.has(to(n))?"y":"x"}function Ud(n){return Vd(Nr(n))}function NS(n,t,e){e===void 0&&(e=!1);const r=ui(n),o=Ud(n),a=jd(o);let i=o==="x"?r===(e?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=dc(i)),[i,dc(i)]}function $S(n){const t=dc(n);return[zd(n),t,zd(t)]}function zd(n){return n.replace(/start|end/g,t=>ES[t])}const Vg=["left","right"],jg=["right","left"],kS=["top","bottom"],PS=["bottom","top"];function IS(n,t,e){switch(n){case"top":case"bottom":return e?t?jg:Vg:t?Vg:jg;case"left":case"right":return t?kS:PS;default:return[]}}function AS(n,t,e,r){const o=ui(n);let a=IS(to(n),e==="start",r);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(zd)))),a}function dc(n){return n.replace(/left|right|bottom|top/g,t=>_S[t])}function TS(n){return{top:0,right:0,bottom:0,left:0,...n}}function Ug(n){return typeof n!="number"?TS(n):{top:n,right:n,bottom:n,left:n}}function fc(n){const{x:t,y:e,width:r,height:o}=n;return{width:r,height:o,top:e,left:t,right:t+r,bottom:e+o,x:t,y:e}}function zg(n,t,e){let{reference:r,floating:o}=n;const a=Nr(t),i=Ud(t),s=jd(i),u=to(t),c=a==="y",l=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,f=r[s]/2-o[s]/2;let h;switch(u){case"top":h={x:l,y:r.y-o.height};break;case"bottom":h={x:l,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-o.width,y:d};break;default:h={x:r.x,y:r.y}}switch(ui(t)){case"start":h[i]-=f*(e&&c?-1:1);break;case"end":h[i]+=f*(e&&c?-1:1);break}return h}const OS=async(n,t,e)=>{const{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:i}=e,s=a.filter(Boolean),u=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:n,floating:t,strategy:o}),{x:l,y:d}=zg(c,r,u),f=r,h={},m=0;for(let p=0;p<s.length;p++){const{name:v,fn:g}=s[p],{x:y,y:w,data:x,reset:C}=await g({x:l,y:d,initialPlacement:r,placement:f,strategy:o,middlewareData:h,rects:c,platform:i,elements:{reference:n,floating:t}});l=y??l,d=w??d,h={...h,[v]:{...h[v],...x}},C&&m<=50&&(m++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:n,floating:t,strategy:o}):C.rects),{x:l,y:d}=zg(c,f,u)),p=-1)}return{x:l,y:d,placement:f,strategy:o,middlewareData:h}};async function As(n,t){var e;t===void 0&&(t={});const{x:r,y:o,platform:a,rects:i,elements:s,strategy:u}=n,{boundary:c="clippingAncestors",rootBoundary:l="viewport",elementContext:d="floating",altBoundary:f=!1,padding:h=0}=eo(t,n),m=Ug(h),v=s[f?d==="floating"?"reference":"floating":d],g=fc(await a.getClippingRect({element:(e=await(a.isElement==null?void 0:a.isElement(v)))==null||e?v:v.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:c,rootBoundary:l,strategy:u})),y=d==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),x=await(a.isElement==null?void 0:a.isElement(w))?await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1}:{x:1,y:1},C=fc(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:y,offsetParent:w,strategy:u}):y);return{top:(g.top-C.top+m.top)/x.y,bottom:(C.bottom-g.bottom+m.bottom)/x.y,left:(g.left-C.left+m.left)/x.x,right:(C.right-g.right+m.right)/x.x}}const DS=n=>({name:"arrow",options:n,async fn(t){const{x:e,y:r,placement:o,rects:a,platform:i,elements:s,middlewareData:u}=t,{element:c,padding:l=0}=eo(n,t)||{};if(c==null)return{};const d=Ug(l),f={x:e,y:r},h=Ud(o),m=jd(h),p=await i.getDimensions(c),v=h==="y",g=v?"top":"left",y=v?"bottom":"right",w=v?"clientHeight":"clientWidth",x=a.reference[m]+a.reference[h]-f[h]-a.floating[m],C=f[h]-a.reference[h],_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=_?_[w]:0;(!E||!await(i.isElement==null?void 0:i.isElement(_)))&&(E=s.floating[w]||a.floating[m]);const S=x/2-C/2,N=E/2-p[m]/2-1,$=Io(d[g],N),A=Io(d[y],N),P=$,j=E-p[m]-A,B=E/2-p[m]/2+S,z=Wd(P,B,j),H=!u.arrow&&ui(o)!=null&&B!==z&&a.reference[m]/2-(B<P?$:A)-p[m]/2<0,F=H?B<P?B-P:B-j:0;return{[h]:f[h]+F,data:{[h]:z,centerOffset:B-z-F,...H&&{alignmentOffset:F}},reset:H}}}),MS=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(t){var e,r;const{placement:o,middlewareData:a,rects:i,initialPlacement:s,platform:u,elements:c}=t,{mainAxis:l=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:p=!0,...v}=eo(n,t);if((e=a.arrow)!=null&&e.alignmentOffset)return{};const g=to(o),y=Nr(s),w=to(s)===s,x=await(u.isRTL==null?void 0:u.isRTL(c.floating)),C=f||(w||!p?[dc(s)]:$S(s)),_=m!=="none";!f&&_&&C.push(...AS(s,p,m,x));const E=[s,...C],S=await As(t,v),N=[];let $=((r=a.flip)==null?void 0:r.overflows)||[];if(l&&N.push(S[g]),d){const B=NS(o,i,x);N.push(S[B[0]],S[B[1]])}if($=[...$,{placement:o,overflows:N}],!N.every(B=>B<=0)){var A,P;const B=(((A=a.flip)==null?void 0:A.index)||0)+1,z=E[B];if(z&&(!(d==="alignment"?y!==Nr(z):!1)||$.every(M=>Nr(M.placement)===y?M.overflows[0]>0:!0)))return{data:{index:B,overflows:$},reset:{placement:z}};let H=(P=$.filter(F=>F.overflows[0]<=0).sort((F,M)=>F.overflows[1]-M.overflows[1])[0])==null?void 0:P.placement;if(!H)switch(h){case"bestFit":{var j;const F=(j=$.filter(M=>{if(_){const O=Nr(M.placement);return O===y||O==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(O=>O>0).reduce((O,I)=>O+I,0)]).sort((M,O)=>M[1]-O[1])[0])==null?void 0:j[0];F&&(H=F);break}case"initialPlacement":H=s;break}if(o!==H)return{reset:{placement:H}}}return{}}}};function Hg(n,t){return{top:n.top-t.height,right:n.right-t.width,bottom:n.bottom-t.height,left:n.left-t.width}}function Gg(n){return CS.some(t=>n[t]>=0)}const FS=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(t){const{rects:e}=t,{strategy:r="referenceHidden",...o}=eo(n,t);switch(r){case"referenceHidden":{const a=await As(t,{...o,elementContext:"reference"}),i=Hg(a,e.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Gg(i)}}}case"escaped":{const a=await As(t,{...o,altBoundary:!0}),i=Hg(a,e.floating);return{data:{escapedOffsets:i,escaped:Gg(i)}}}default:return{}}}}},qg=new Set(["left","top"]);async function RS(n,t){const{placement:e,platform:r,elements:o}=n,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=to(e),s=ui(e),u=Nr(e)==="y",c=qg.has(i)?-1:1,l=a&&u?-1:1,d=eo(t,n);let{mainAxis:f,crossAxis:h,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m=="number"&&(h=s==="end"?m*-1:m),u?{x:h*l,y:f*c}:{x:f*c,y:h*l}}const LS=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(t){var e,r;const{x:o,y:a,placement:i,middlewareData:s}=t,u=await RS(t,n);return i===((e=s.offset)==null?void 0:e.placement)&&(r=s.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:a+u.y,data:{...u,placement:i}}}}},BS=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(t){const{x:e,y:r,placement:o}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:s={fn:v=>{let{x:g,y}=v;return{x:g,y}}},...u}=eo(n,t),c={x:e,y:r},l=await As(t,u),d=Nr(to(o)),f=Vd(d);let h=c[f],m=c[d];if(a){const v=f==="y"?"top":"left",g=f==="y"?"bottom":"right",y=h+l[v],w=h-l[g];h=Wd(y,h,w)}if(i){const v=d==="y"?"top":"left",g=d==="y"?"bottom":"right",y=m+l[v],w=m-l[g];m=Wd(y,m,w)}const p=s.fn({...t,[f]:h,[d]:m});return{...p,data:{x:p.x-e,y:p.y-r,enabled:{[f]:a,[d]:i}}}}}},WS=function(n){return n===void 0&&(n={}),{options:n,fn(t){const{x:e,y:r,placement:o,rects:a,middlewareData:i}=t,{offset:s=0,mainAxis:u=!0,crossAxis:c=!0}=eo(n,t),l={x:e,y:r},d=Nr(o),f=Vd(d);let h=l[f],m=l[d];const p=eo(s,t),v=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(u){const w=f==="y"?"height":"width",x=a.reference[f]-a.floating[w]+v.mainAxis,C=a.reference[f]+a.reference[w]-v.mainAxis;h<x?h=x:h>C&&(h=C)}if(c){var g,y;const w=f==="y"?"width":"height",x=qg.has(to(o)),C=a.reference[d]-a.floating[w]+(x&&((g=i.offset)==null?void 0:g[d])||0)+(x?0:v.crossAxis),_=a.reference[d]+a.reference[w]+(x?0:((y=i.offset)==null?void 0:y[d])||0)-(x?v.crossAxis:0);m<C?m=C:m>_&&(m=_)}return{[f]:h,[d]:m}}}},VS=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(t){var e,r;const{placement:o,rects:a,platform:i,elements:s}=t,{apply:u=()=>{},...c}=eo(n,t),l=await As(t,c),d=to(o),f=ui(o),h=Nr(o)==="y",{width:m,height:p}=a.floating;let v,g;d==="top"||d==="bottom"?(v=d,g=f===(await(i.isRTL==null?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(g=d,v=f==="end"?"top":"bottom");const y=p-l.top-l.bottom,w=m-l.left-l.right,x=Io(p-l[v],y),C=Io(m-l[g],w),_=!t.middlewareData.shift;let E=x,S=C;if((e=t.middlewareData.shift)!=null&&e.enabled.x&&(S=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=y),_&&!f){const $=Dn(l.left,0),A=Dn(l.right,0),P=Dn(l.top,0),j=Dn(l.bottom,0);h?S=m-2*($!==0||A!==0?$+A:Dn(l.left,l.right)):E=p-2*(P!==0||j!==0?P+j:Dn(l.top,l.bottom))}await u({...t,availableWidth:S,availableHeight:E});const N=await i.getDimensions(s.floating);return m!==N.width||p!==N.height?{reset:{rects:!0}}:{}}}};function hc(){return typeof window<"u"}function ci(n){return Kg(n)?(n.nodeName||"").toLowerCase():"#document"}function Mn(n){var t;return(n==null||(t=n.ownerDocument)==null?void 0:t.defaultView)||window}function $r(n){var t;return(t=(Kg(n)?n.ownerDocument:n.document)||window.document)==null?void 0:t.documentElement}function Kg(n){return hc()?n instanceof Node||n instanceof Mn(n).Node:!1}function rr(n){return hc()?n instanceof Element||n instanceof Mn(n).Element:!1}function kr(n){return hc()?n instanceof HTMLElement||n instanceof Mn(n).HTMLElement:!1}function Yg(n){return!hc()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Mn(n).ShadowRoot}const jS=new Set(["inline","contents"]);function Ts(n){const{overflow:t,overflowX:e,overflowY:r,display:o}=or(n);return/auto|scroll|overlay|hidden|clip/.test(t+r+e)&&!jS.has(o)}const US=new Set(["table","td","th"]);function zS(n){return US.has(ci(n))}const HS=[":popover-open",":modal"];function pc(n){return HS.some(t=>{try{return n.matches(t)}catch{return!1}})}const GS=["transform","translate","scale","rotate","perspective"],qS=["transform","translate","scale","rotate","perspective","filter"],KS=["paint","layout","strict","content"];function Hd(n){const t=Gd(),e=rr(n)?or(n):n;return GS.some(r=>e[r]?e[r]!=="none":!1)||(e.containerType?e.containerType!=="normal":!1)||!t&&(e.backdropFilter?e.backdropFilter!=="none":!1)||!t&&(e.filter?e.filter!=="none":!1)||qS.some(r=>(e.willChange||"").includes(r))||KS.some(r=>(e.contain||"").includes(r))}function YS(n){let t=Ao(n);for(;kr(t)&&!li(t);){if(Hd(t))return t;if(pc(t))return null;t=Ao(t)}return null}function Gd(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const XS=new Set(["html","body","#document"]);function li(n){return XS.has(ci(n))}function or(n){return Mn(n).getComputedStyle(n)}function vc(n){return rr(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function Ao(n){if(ci(n)==="html")return n;const t=n.assignedSlot||n.parentNode||Yg(n)&&n.host||$r(n);return Yg(t)?t.host:t}function Xg(n){const t=Ao(n);return li(t)?n.ownerDocument?n.ownerDocument.body:n.body:kr(t)&&Ts(t)?t:Xg(t)}function Os(n,t,e){var r;t===void 0&&(t=[]),e===void 0&&(e=!0);const o=Xg(n),a=o===((r=n.ownerDocument)==null?void 0:r.body),i=Mn(o);if(a){const s=qd(i);return t.concat(i,i.visualViewport||[],Ts(o)?o:[],s&&e?Os(s):[])}return t.concat(o,Os(o,[],e))}function qd(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function Zg(n){const t=or(n);let e=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=kr(n),a=o?n.offsetWidth:e,i=o?n.offsetHeight:r,s=cc(e)!==a||cc(r)!==i;return s&&(e=a,r=i),{width:e,height:r,$:s}}function Kd(n){return rr(n)?n:n.contextElement}function di(n){const t=Kd(n);if(!kr(t))return Sr(1);const e=t.getBoundingClientRect(),{width:r,height:o,$:a}=Zg(t);let i=(a?cc(e.width):e.width)/r,s=(a?cc(e.height):e.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!s||!Number.isFinite(s))&&(s=1),{x:i,y:s}}const ZS=Sr(0);function Qg(n){const t=Mn(n);return!Gd()||!t.visualViewport?ZS:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function QS(n,t,e){return t===void 0&&(t=!1),!e||t&&e!==Mn(n)?!1:t}function xa(n,t,e,r){t===void 0&&(t=!1),e===void 0&&(e=!1);const o=n.getBoundingClientRect(),a=Kd(n);let i=Sr(1);t&&(r?rr(r)&&(i=di(r)):i=di(n));const s=QS(a,e,r)?Qg(a):Sr(0);let u=(o.left+s.x)/i.x,c=(o.top+s.y)/i.y,l=o.width/i.x,d=o.height/i.y;if(a){const f=Mn(a),h=r&&rr(r)?Mn(r):r;let m=f,p=qd(m);for(;p&&r&&h!==m;){const v=di(p),g=p.getBoundingClientRect(),y=or(p),w=g.left+(p.clientLeft+parseFloat(y.paddingLeft))*v.x,x=g.top+(p.clientTop+parseFloat(y.paddingTop))*v.y;u*=v.x,c*=v.y,l*=v.x,d*=v.y,u+=w,c+=x,m=Mn(p),p=qd(m)}}return fc({width:l,height:d,x:u,y:c})}function mc(n,t){const e=vc(n).scrollLeft;return t?t.left+e:xa($r(n)).left+e}function Jg(n,t){const e=n.getBoundingClientRect(),r=e.left+t.scrollLeft-mc(n,e),o=e.top+t.scrollTop;return{x:r,y:o}}function JS(n){let{elements:t,rect:e,offsetParent:r,strategy:o}=n;const a=o==="fixed",i=$r(r),s=t?pc(t.floating):!1;if(r===i||s&&a)return e;let u={scrollLeft:0,scrollTop:0},c=Sr(1);const l=Sr(0),d=kr(r);if((d||!d&&!a)&&((ci(r)!=="body"||Ts(i))&&(u=vc(r)),kr(r))){const h=xa(r);c=di(r),l.x=h.x+r.clientLeft,l.y=h.y+r.clientTop}const f=i&&!d&&!a?Jg(i,u):Sr(0);return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-u.scrollLeft*c.x+l.x+f.x,y:e.y*c.y-u.scrollTop*c.y+l.y+f.y}}function eN(n){return Array.from(n.getClientRects())}function tN(n){const t=$r(n),e=vc(n),r=n.ownerDocument.body,o=Dn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Dn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-e.scrollLeft+mc(n);const s=-e.scrollTop;return or(r).direction==="rtl"&&(i+=Dn(t.clientWidth,r.clientWidth)-o),{width:o,height:a,x:i,y:s}}const e0=25;function nN(n,t){const e=Mn(n),r=$r(n),o=e.visualViewport;let a=r.clientWidth,i=r.clientHeight,s=0,u=0;if(o){a=o.width,i=o.height;const l=Gd();(!l||l&&t==="fixed")&&(s=o.offsetLeft,u=o.offsetTop)}const c=mc(r);if(c<=0){const l=r.ownerDocument,d=l.body,f=getComputedStyle(d),h=l.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(r.clientWidth-d.clientWidth-h);m<=e0&&(a-=m)}else c<=e0&&(a+=c);return{width:a,height:i,x:s,y:u}}const rN=new Set(["absolute","fixed"]);function oN(n,t){const e=xa(n,!0,t==="fixed"),r=e.top+n.clientTop,o=e.left+n.clientLeft,a=kr(n)?di(n):Sr(1),i=n.clientWidth*a.x,s=n.clientHeight*a.y,u=o*a.x,c=r*a.y;return{width:i,height:s,x:u,y:c}}function t0(n,t,e){let r;if(t==="viewport")r=nN(n,e);else if(t==="document")r=tN($r(n));else if(rr(t))r=oN(t,e);else{const o=Qg(n);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return fc(r)}function n0(n,t){const e=Ao(n);return e===t||!rr(e)||li(e)?!1:or(e).position==="fixed"||n0(e,t)}function aN(n,t){const e=t.get(n);if(e)return e;let r=Os(n,[],!1).filter(s=>rr(s)&&ci(s)!=="body"),o=null;const a=or(n).position==="fixed";let i=a?Ao(n):n;for(;rr(i)&&!li(i);){const s=or(i),u=Hd(i);!u&&s.position==="fixed"&&(o=null),(a?!u&&!o:!u&&s.position==="static"&&!!o&&rN.has(o.position)||Ts(i)&&!u&&n0(n,i))?r=r.filter(l=>l!==i):o=s,i=Ao(i)}return t.set(n,r),r}function iN(n){let{element:t,boundary:e,rootBoundary:r,strategy:o}=n;const i=[...e==="clippingAncestors"?pc(t)?[]:aN(t,this._c):[].concat(e),r],s=i[0],u=i.reduce((c,l)=>{const d=t0(t,l,o);return c.top=Dn(d.top,c.top),c.right=Io(d.right,c.right),c.bottom=Io(d.bottom,c.bottom),c.left=Dn(d.left,c.left),c},t0(t,s,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function sN(n){const{width:t,height:e}=Zg(n);return{width:t,height:e}}function uN(n,t,e){const r=kr(t),o=$r(t),a=e==="fixed",i=xa(n,!0,a,t);let s={scrollLeft:0,scrollTop:0};const u=Sr(0);function c(){u.x=mc(o)}if(r||!r&&!a)if((ci(t)!=="body"||Ts(o))&&(s=vc(t)),r){const h=xa(t,!0,a,t);u.x=h.x+t.clientLeft,u.y=h.y+t.clientTop}else o&&c();a&&!r&&o&&c();const l=o&&!r&&!a?Jg(o,s):Sr(0),d=i.left+s.scrollLeft-u.x-l.x,f=i.top+s.scrollTop-u.y-l.y;return{x:d,y:f,width:i.width,height:i.height}}function Yd(n){return or(n).position==="static"}function r0(n,t){if(!kr(n)||or(n).position==="fixed")return null;if(t)return t(n);let e=n.offsetParent;return $r(n)===e&&(e=e.ownerDocument.body),e}function o0(n,t){const e=Mn(n);if(pc(n))return e;if(!kr(n)){let o=Ao(n);for(;o&&!li(o);){if(rr(o)&&!Yd(o))return o;o=Ao(o)}return e}let r=r0(n,t);for(;r&&zS(r)&&Yd(r);)r=r0(r,t);return r&&li(r)&&Yd(r)&&!Hd(r)?e:r||YS(n)||e}const cN=async function(n){const t=this.getOffsetParent||o0,e=this.getDimensions,r=await e(n.floating);return{reference:uN(n.reference,await t(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function lN(n){return or(n).direction==="rtl"}const dN={convertOffsetParentRelativeRectToViewportRelativeRect:JS,getDocumentElement:$r,getClippingRect:iN,getOffsetParent:o0,getElementRects:cN,getClientRects:eN,getDimensions:sN,getScale:di,isElement:rr,isRTL:lN};function a0(n,t){return n.x===t.x&&n.y===t.y&&n.width===t.width&&n.height===t.height}function fN(n,t){let e=null,r;const o=$r(n);function a(){var s;clearTimeout(r),(s=e)==null||s.disconnect(),e=null}function i(s,u){s===void 0&&(s=!1),u===void 0&&(u=1),a();const c=n.getBoundingClientRect(),{left:l,top:d,width:f,height:h}=c;if(s||t(),!f||!h)return;const m=lc(d),p=lc(o.clientWidth-(l+f)),v=lc(o.clientHeight-(d+h)),g=lc(l),w={rootMargin:-m+"px "+-p+"px "+-v+"px "+-g+"px",threshold:Dn(0,Io(1,u))||1};let x=!0;function C(_){const E=_[0].intersectionRatio;if(E!==u){if(!x)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!a0(c,n.getBoundingClientRect())&&i(),x=!1}try{e=new IntersectionObserver(C,{...w,root:o.ownerDocument})}catch{e=new IntersectionObserver(C,w)}e.observe(n)}return i(!0),a}function hN(n,t,e,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,c=Kd(n),l=o||a?[...c?Os(c):[],...Os(t)]:[];l.forEach(g=>{o&&g.addEventListener("scroll",e,{passive:!0}),a&&g.addEventListener("resize",e)});const d=c&&s?fN(c,e):null;let f=-1,h=null;i&&(h=new ResizeObserver(g=>{let[y]=g;y&&y.target===c&&h&&(h.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var w;(w=h)==null||w.observe(t)})),e()}),c&&!u&&h.observe(c),h.observe(t));let m,p=u?xa(n):null;u&&v();function v(){const g=xa(n);p&&!a0(p,g)&&e(),p=g,m=requestAnimationFrame(v)}return e(),()=>{var g;l.forEach(y=>{o&&y.removeEventListener("scroll",e),a&&y.removeEventListener("resize",e)}),d==null||d(),(g=h)==null||g.disconnect(),h=null,u&&cancelAnimationFrame(m)}}const pN=LS,vN=BS,mN=MS,gN=VS,yN=FS,i0=DS,bN=WS,xN=(n,t,e)=>{const r=new Map,o={platform:dN,...e},a={...o.platform,_c:r};return OS(n,t,{...o,platform:a})};var wN=typeof document<"u",CN=function(){},gc=wN?D.useLayoutEffect:CN;function yc(n,t){if(n===t)return!0;if(typeof n!=typeof t)return!1;if(typeof n=="function"&&n.toString()===t.toString())return!0;let e,r,o;if(n&&t&&typeof n=="object"){if(Array.isArray(n)){if(e=n.length,e!==t.length)return!1;for(r=e;r--!==0;)if(!yc(n[r],t[r]))return!1;return!0}if(o=Object.keys(n),e=o.length,e!==Object.keys(t).length)return!1;for(r=e;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=e;r--!==0;){const a=o[r];if(!(a==="_owner"&&n.$$typeof)&&!yc(n[a],t[a]))return!1}return!0}return n!==n&&t!==t}function s0(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function u0(n,t){const e=s0(n);return Math.round(t*e)/e}function Xd(n){const t=k.useRef(n);return gc(()=>{t.current=n}),t}function _N(n){n===void 0&&(n={});const{placement:t="bottom",strategy:e="absolute",middleware:r=[],platform:o,elements:{reference:a,floating:i}={},transform:s=!0,whileElementsMounted:u,open:c}=n,[l,d]=k.useState({x:0,y:0,strategy:e,placement:t,middlewareData:{},isPositioned:!1}),[f,h]=k.useState(r);yc(f,r)||h(r);const[m,p]=k.useState(null),[v,g]=k.useState(null),y=k.useCallback(M=>{M!==_.current&&(_.current=M,p(M))},[]),w=k.useCallback(M=>{M!==E.current&&(E.current=M,g(M))},[]),x=a||m,C=i||v,_=k.useRef(null),E=k.useRef(null),S=k.useRef(l),N=u!=null,$=Xd(u),A=Xd(o),P=Xd(c),j=k.useCallback(()=>{if(!_.current||!E.current)return;const M={placement:t,strategy:e,middleware:f};A.current&&(M.platform=A.current),xN(_.current,E.current,M).then(O=>{const I={...O,isPositioned:P.current!==!1};B.current&&!yc(S.current,I)&&(S.current=I,Es.flushSync(()=>{d(I)}))})},[f,t,e,A,P]);gc(()=>{c===!1&&S.current.isPositioned&&(S.current.isPositioned=!1,d(M=>({...M,isPositioned:!1})))},[c]);const B=k.useRef(!1);gc(()=>(B.current=!0,()=>{B.current=!1}),[]),gc(()=>{if(x&&(_.current=x),C&&(E.current=C),x&&C){if($.current)return $.current(x,C,j);j()}},[x,C,j,$,N]);const z=k.useMemo(()=>({reference:_,floating:E,setReference:y,setFloating:w}),[y,w]),H=k.useMemo(()=>({reference:x,floating:C}),[x,C]),F=k.useMemo(()=>{const M={position:e,left:0,top:0};if(!H.floating)return M;const O=u0(H.floating,l.x),I=u0(H.floating,l.y);return s?{...M,transform:"translate("+O+"px, "+I+"px)",...s0(H.floating)>=1.5&&{willChange:"transform"}}:{position:e,left:O,top:I}},[e,s,H.floating,l.x,l.y]);return k.useMemo(()=>({...l,update:j,refs:z,elements:H,floatingStyles:F}),[l,j,z,H,F])}const EN=n=>{function t(e){return{}.hasOwnProperty.call(e,"current")}return{name:"arrow",options:n,fn(e){const{element:r,padding:o}=typeof n=="function"?n(e):n;return r&&t(r)?r.current!=null?i0({element:r.current,padding:o}).fn(e):{}:r?i0({element:r,padding:o}).fn(e):{}}}},SN=(n,t)=>({...pN(n),options:[n,t]}),NN=(n,t)=>({...vN(n),options:[n,t]}),$N=(n,t)=>({...bN(n),options:[n,t]}),kN=(n,t)=>({...mN(n),options:[n,t]}),PN=(n,t)=>({...gN(n),options:[n,t]}),IN=(n,t)=>({...yN(n),options:[n,t]}),AN=(n,t)=>({...EN(n),options:[n,t]});var TN="Arrow",c0=k.forwardRef((n,t)=>{const{children:e,width:r=10,height:o=5,...a}=n;return b.jsx(et.svg,{...a,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:n.asChild?e:b.jsx("polygon",{points:"0,0 30,0 15,10"})})});c0.displayName=TN;var ON=c0;function DN(n){const[t,e]=k.useState(void 0);return Jt(()=>{if(n){e({width:n.offsetWidth,height:n.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let i,s;if("borderBoxSize"in a){const u=a.borderBoxSize,c=Array.isArray(u)?u[0]:u;i=c.inlineSize,s=c.blockSize}else i=n.offsetWidth,s=n.offsetHeight;e({width:i,height:s})});return r.observe(n,{box:"border-box"}),()=>r.unobserve(n)}else e(void 0)},[n]),t}var Zd="Popper",[l0,fi]=ba(Zd),[MN,d0]=l0(Zd),f0=n=>{const{__scopePopper:t,children:e}=n,[r,o]=k.useState(null);return b.jsx(MN,{scope:t,anchor:r,onAnchorChange:o,children:e})};f0.displayName=Zd;var h0="PopperAnchor",p0=k.forwardRef((n,t)=>{const{__scopePopper:e,virtualRef:r,...o}=n,a=d0(h0,e),i=k.useRef(null),s=mt(t,i),u=k.useRef(null);return k.useEffect(()=>{const c=u.current;u.current=(r==null?void 0:r.current)||i.current,c!==u.current&&a.onAnchorChange(u.current)}),r?null:b.jsx(et.div,{...o,ref:s})});p0.displayName=h0;var Qd="PopperContent",[FN,RN]=l0(Qd),v0=k.forwardRef((n,t)=>{var X,re,ce,ue,se,ee;const{__scopePopper:e,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:s=0,avoidCollisions:u=!0,collisionBoundary:c=[],collisionPadding:l=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:h="optimized",onPlaced:m,...p}=n,v=d0(Qd,e),[g,y]=k.useState(null),w=mt(t,_e=>y(_e)),[x,C]=k.useState(null),_=DN(x),E=(_==null?void 0:_.width)??0,S=(_==null?void 0:_.height)??0,N=r+(a!=="center"?"-"+a:""),$=typeof l=="number"?l:{top:0,right:0,bottom:0,left:0,...l},A=Array.isArray(c)?c:[c],P=A.length>0,j={padding:$,boundary:A.filter(BN),altBoundary:P},{refs:B,floatingStyles:z,placement:H,isPositioned:F,middlewareData:M}=_N({strategy:"fixed",placement:N,whileElementsMounted:(..._e)=>hN(..._e,{animationFrame:h==="always"}),elements:{reference:v.anchor},middleware:[SN({mainAxis:o+S,alignmentAxis:i}),u&&NN({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?$N():void 0,...j}),u&&kN({...j}),PN({...j,apply:({elements:_e,rects:Me,availableWidth:Ye,availableHeight:Ze})=>{const{width:Lt,height:on}=Me.reference,Ct=_e.floating.style;Ct.setProperty("--radix-popper-available-width",`${Ye}px`),Ct.setProperty("--radix-popper-available-height",`${Ze}px`),Ct.setProperty("--radix-popper-anchor-width",`${Lt}px`),Ct.setProperty("--radix-popper-anchor-height",`${on}px`)}}),x&&AN({element:x,padding:s}),WN({arrowWidth:E,arrowHeight:S}),f&&IN({strategy:"referenceHidden",...j})]}),[O,I]=y0(H),L=tr(m);Jt(()=>{F&&(L==null||L())},[F,L]);const K=(X=M.arrow)==null?void 0:X.x,q=(re=M.arrow)==null?void 0:re.y,Z=((ce=M.arrow)==null?void 0:ce.centerOffset)!==0,[oe,ae]=k.useState();return Jt(()=>{g&&ae(window.getComputedStyle(g).zIndex)},[g]),b.jsx("div",{ref:B.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:F?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:oe,"--radix-popper-transform-origin":[(ue=M.transformOrigin)==null?void 0:ue.x,(se=M.transformOrigin)==null?void 0:se.y].join(" "),...((ee=M.hide)==null?void 0:ee.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:n.dir,children:b.jsx(FN,{scope:e,placedSide:O,onArrowChange:C,arrowX:K,arrowY:q,shouldHideArrow:Z,children:b.jsx(et.div,{"data-side":O,"data-align":I,...p,ref:w,style:{...p.style,animation:F?void 0:"none"}})})})});v0.displayName=Qd;var m0="PopperArrow",LN={top:"bottom",right:"left",bottom:"top",left:"right"},g0=k.forwardRef(function(t,e){const{__scopePopper:r,...o}=t,a=RN(m0,r),i=LN[a.placedSide];return b.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:b.jsx(ON,{...o,ref:e,style:{...o.style,display:"block"}})})});g0.displayName=m0;function BN(n){return n!==null}var WN=n=>({name:"transformOrigin",options:n,fn(t){var v,g,y;const{placement:e,rects:r,middlewareData:o}=t,i=((v=o.arrow)==null?void 0:v.centerOffset)!==0,s=i?0:n.arrowWidth,u=i?0:n.arrowHeight,[c,l]=y0(e),d={start:"0%",center:"50%",end:"100%"}[l],f=(((g=o.arrow)==null?void 0:g.x)??0)+s/2,h=(((y=o.arrow)==null?void 0:y.y)??0)+u/2;let m="",p="";return c==="bottom"?(m=i?d:`${f}px`,p=`${-u}px`):c==="top"?(m=i?d:`${f}px`,p=`${r.floating.height+u}px`):c==="right"?(m=`${-u}px`,p=i?d:`${h}px`):c==="left"&&(m=`${r.floating.width+u}px`,p=i?d:`${h}px`),{data:{x:m,y:p}}}});function y0(n){const[t,e="center"]=n.split("-");return[t,e]}var b0=f0,bc=p0,Jd=v0,ef=g0,[xc]=ba("Tooltip",[fi]),tf=fi(),x0="TooltipProvider",VN=700,w0="tooltip.open",[jN,C0]=xc(x0),_0=n=>{const{__scopeTooltip:t,delayDuration:e=VN,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:a}=n,i=k.useRef(!0),s=k.useRef(!1),u=k.useRef(0);return k.useEffect(()=>{const c=u.current;return()=>window.clearTimeout(c)},[]),b.jsx(jN,{scope:t,isOpenDelayedRef:i,delayDuration:e,onOpen:k.useCallback(()=>{window.clearTimeout(u.current),i.current=!1},[]),onClose:k.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:k.useCallback(c=>{s.current=c},[]),disableHoverableContent:o,children:a})};_0.displayName=x0;var E0="Tooltip",[gz,wc]=xc(E0),nf="TooltipTrigger",UN=k.forwardRef((n,t)=>{const{__scopeTooltip:e,...r}=n,o=wc(nf,e),a=C0(nf,e),i=tf(e),s=k.useRef(null),u=mt(t,s,o.onTriggerChange),c=k.useRef(!1),l=k.useRef(!1),d=k.useCallback(()=>c.current=!1,[]);return k.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),b.jsx(bc,{asChild:!0,...i,children:b.jsx(et.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:u,onPointerMove:je(n.onPointerMove,f=>{f.pointerType!=="touch"&&!l.current&&!a.isPointerInTransitRef.current&&(o.onTriggerEnter(),l.current=!0)}),onPointerLeave:je(n.onPointerLeave,()=>{o.onTriggerLeave(),l.current=!1}),onPointerDown:je(n.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:je(n.onFocus,()=>{c.current||o.onOpen()}),onBlur:je(n.onBlur,o.onClose),onClick:je(n.onClick,o.onClose)})})});UN.displayName=nf;var zN="TooltipPortal",[yz,HN]=xc(zN,{forceMount:void 0}),hi="TooltipContent",S0=k.forwardRef((n,t)=>{const e=HN(hi,n.__scopeTooltip),{forceMount:r=e.forceMount,side:o="top",...a}=n,i=wc(hi,n.__scopeTooltip);return b.jsx($s,{present:r||i.open,children:i.disableHoverableContent?b.jsx(N0,{side:o,...a,ref:t}):b.jsx(GN,{side:o,...a,ref:t})})}),GN=k.forwardRef((n,t)=>{const e=wc(hi,n.__scopeTooltip),r=C0(hi,n.__scopeTooltip),o=k.useRef(null),a=mt(t,o),[i,s]=k.useState(null),{trigger:u,onClose:c}=e,l=o.current,{onPointerInTransitChange:d}=r,f=k.useCallback(()=>{s(null),d(!1)},[d]),h=k.useCallback((m,p)=>{const v=m.currentTarget,g={x:m.clientX,y:m.clientY},y=ZN(g,v.getBoundingClientRect()),w=QN(g,y),x=JN(p.getBoundingClientRect()),C=t$([...w,...x]);s(C),d(!0)},[d]);return k.useEffect(()=>()=>f(),[f]),k.useEffect(()=>{if(u&&l){const m=v=>h(v,l),p=v=>h(v,u);return u.addEventListener("pointerleave",m),l.addEventListener("pointerleave",p),()=>{u.removeEventListener("pointerleave",m),l.removeEventListener("pointerleave",p)}}},[u,l,h,f]),k.useEffect(()=>{if(i){const m=p=>{const v=p.target,g={x:p.clientX,y:p.clientY},y=(u==null?void 0:u.contains(v))||(l==null?void 0:l.contains(v)),w=!e$(g,i);y?f():w&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[u,l,i,c,f]),b.jsx(N0,{...n,ref:a})}),[qN,KN]=xc(E0,{isInside:!1}),YN=u4("TooltipContent"),N0=k.forwardRef((n,t)=>{const{__scopeTooltip:e,children:r,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:i,...s}=n,u=wc(hi,e),c=tf(e),{onClose:l}=u;return k.useEffect(()=>(document.addEventListener(w0,l),()=>document.removeEventListener(w0,l)),[l]),k.useEffect(()=>{if(u.trigger){const d=f=>{const h=f.target;h!=null&&h.contains(u.trigger)&&l()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[u.trigger,l]),b.jsx(Ns,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:d=>d.preventDefault(),onDismiss:l,children:b.jsxs(Jd,{"data-state":u.stateAttribute,...c,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[b.jsx(YN,{children:r}),b.jsx(qN,{scope:e,isInside:!0,children:b.jsx(I4,{id:u.contentId,role:"tooltip",children:o||r})})]})})});S0.displayName=hi;var $0="TooltipArrow",XN=k.forwardRef((n,t)=>{const{__scopeTooltip:e,...r}=n,o=tf(e);return KN($0,e).isInside?null:b.jsx(ef,{...o,...r,ref:t})});XN.displayName=$0;function ZN(n,t){const e=Math.abs(t.top-n.y),r=Math.abs(t.bottom-n.y),o=Math.abs(t.right-n.x),a=Math.abs(t.left-n.x);switch(Math.min(e,r,o,a)){case a:return"left";case o:return"right";case e:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function QN(n,t,e=5){const r=[];switch(t){case"top":r.push({x:n.x-e,y:n.y+e},{x:n.x+e,y:n.y+e});break;case"bottom":r.push({x:n.x-e,y:n.y-e},{x:n.x+e,y:n.y-e});break;case"left":r.push({x:n.x+e,y:n.y-e},{x:n.x+e,y:n.y+e});break;case"right":r.push({x:n.x-e,y:n.y-e},{x:n.x-e,y:n.y+e});break}return r}function JN(n){const{top:t,right:e,bottom:r,left:o}=n;return[{x:o,y:t},{x:e,y:t},{x:e,y:r},{x:o,y:r}]}function e$(n,t){const{x:e,y:r}=n;let o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const s=t[a],u=t[i],c=s.x,l=s.y,d=u.x,f=u.y;l>r!=f>r&&e<(d-c)*(r-l)/(f-l)+c&&(o=!o)}return o}function t$(n){const t=n.slice();return t.sort((e,r)=>e.x<r.x?-1:e.x>r.x?1:e.y<r.y?-1:e.y>r.y?1:0),n$(t)}function n$(n){if(n.length<=1)return n.slice();const t=[];for(let r=0;r<n.length;r++){const o=n[r];for(;t.length>=2;){const a=t[t.length-1],i=t[t.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const e=[];for(let r=n.length-1;r>=0;r--){const o=n[r];for(;e.length>=2;){const a=e[e.length-1],i=e[e.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))e.pop();else break}e.push(o)}return e.pop(),t.length===1&&e.length===1&&t[0].x===e[0].x&&t[0].y===e[0].y?t:t.concat(e)}var r$=_0,k0=S0;const o$=r$,a$=k.forwardRef(({className:n,sideOffset:t=4,...e},r)=>b.jsx(k0,{ref:r,sideOffset:t,className:Be("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n),...e}));a$.displayName=k0.displayName;var pi=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(n){return this.listeners.add(n),this.onSubscribe(),()=>{this.listeners.delete(n),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},i$={setTimeout:(n,t)=>setTimeout(n,t),clearTimeout:n=>clearTimeout(n),setInterval:(n,t)=>setInterval(n,t),clearInterval:n=>clearInterval(n)},s$=(W_=class{constructor(){Ie(this,Yr,i$);Ie(this,Ka,!1)}setTimeoutProvider(n){process.env.NODE_ENV!=="production"&&W(this,Ka)&&n!==W(this,Yr)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:W(this,Yr),provider:n}),ge(this,Yr,n),process.env.NODE_ENV!=="production"&&ge(this,Ka,!1)}setTimeout(n,t){return process.env.NODE_ENV!=="production"&&ge(this,Ka,!0),W(this,Yr).setTimeout(n,t)}clearTimeout(n){W(this,Yr).clearTimeout(n)}setInterval(n,t){return process.env.NODE_ENV!=="production"&&ge(this,Ka,!0),W(this,Yr).setInterval(n,t)}clearInterval(n){W(this,Yr).clearInterval(n)}},Yr=new WeakMap,Ka=new WeakMap,W_),wa=new s$;function u$(n){setTimeout(n,0)}var Ca=typeof window>"u"||"Deno"in globalThis;function fn(){}function c$(n,t){return typeof n=="function"?n(t):n}function rf(n){return typeof n=="number"&&n>=0&&n!==1/0}function P0(n,t){return Math.max(n+(t||0)-Date.now(),0)}function To(n,t){return typeof n=="function"?n(t):n}function qn(n,t){return typeof n=="function"?n(t):n}function I0(n,t){const{type:e="all",exact:r,fetchStatus:o,predicate:a,queryKey:i,stale:s}=n;if(i){if(r){if(t.queryHash!==of(i,t.options))return!1}else if(!Ds(t.queryKey,i))return!1}if(e!=="all"){const u=t.isActive();if(e==="active"&&!u||e==="inactive"&&u)return!1}return!(typeof s=="boolean"&&t.isStale()!==s||o&&o!==t.state.fetchStatus||a&&!a(t))}function A0(n,t){const{exact:e,status:r,predicate:o,mutationKey:a}=n;if(a){if(!t.options.mutationKey)return!1;if(e){if(_a(t.options.mutationKey)!==_a(a))return!1}else if(!Ds(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function of(n,t){return((t==null?void 0:t.queryKeyHashFn)||_a)(n)}function _a(n){return JSON.stringify(n,(t,e)=>sf(e)?Object.keys(e).sort().reduce((r,o)=>(r[o]=e[o],r),{}):e)}function Ds(n,t){return n===t?!0:typeof n!=typeof t?!1:n&&t&&typeof n=="object"&&typeof t=="object"?Object.keys(t).every(e=>Ds(n[e],t[e])):!1}var l$=Object.prototype.hasOwnProperty;function af(n,t){if(n===t)return n;const e=T0(n)&&T0(t);if(!e&&!(sf(n)&&sf(t)))return t;const o=(e?n:Object.keys(n)).length,a=e?t:Object.keys(t),i=a.length,s=e?new Array(i):{};let u=0;for(let c=0;c<i;c++){const l=e?c:a[c],d=n[l],f=t[l];if(d===f){s[l]=d,(e?c<o:l$.call(n,l))&&u++;continue}if(d===null||f===null||typeof d!="object"||typeof f!="object"){s[l]=f;continue}const h=af(d,f);s[l]=h,h===d&&u++}return o===i&&u===o?n:s}function Cc(n,t){if(!t||Object.keys(n).length!==Object.keys(t).length)return!1;for(const e in n)if(n[e]!==t[e])return!1;return!0}function T0(n){return Array.isArray(n)&&n.length===Object.keys(n).length}function sf(n){if(!O0(n))return!1;const t=n.constructor;if(t===void 0)return!0;const e=t.prototype;return!(!O0(e)||!e.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(n)!==Object.prototype)}function O0(n){return Object.prototype.toString.call(n)==="[object Object]"}function d$(n){return new Promise(t=>{wa.setTimeout(t,n)})}function uf(n,t,e){if(typeof e.structuralSharing=="function")return e.structuralSharing(n,t);if(e.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return af(n,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. [${e.queryHash}]: ${r}`),r}return af(n,t)}return t}function f$(n,t,e=0){const r=[...n,t];return e&&r.length>e?r.slice(1):r}function h$(n,t,e=0){const r=[t,...n];return e&&r.length>e?r.slice(0,-1):r}var _c=Symbol();function D0(n,t){return process.env.NODE_ENV!=="production"&&n.queryFn===_c&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${n.queryHash}'`),!n.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!n.queryFn||n.queryFn===_c?()=>Promise.reject(new Error(`Missing queryFn: '${n.queryHash}'`)):n.queryFn}function M0(n,t){return typeof n=="function"?n(...t):!!n}var p$=(V_=class extends pi{constructor(){super();Ie(this,Ya);Ie(this,aa);Ie(this,ds);ge(this,ds,t=>{if(!Ca&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}})}onSubscribe(){W(this,aa)||this.setEventListener(W(this,ds))}onUnsubscribe(){var t;this.hasListeners()||((t=W(this,aa))==null||t.call(this),ge(this,aa,void 0))}setEventListener(t){var e;ge(this,ds,t),(e=W(this,aa))==null||e.call(this),ge(this,aa,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){W(this,Ya)!==t&&(ge(this,Ya,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){var t;return typeof W(this,Ya)=="boolean"?W(this,Ya):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Ya=new WeakMap,aa=new WeakMap,ds=new WeakMap,V_),cf=new p$;function lf(){let n,t;const e=new Promise((o,a)=>{n=o,t=a});e.status="pending",e.catch(()=>{});function r(o){Object.assign(e,o),delete e.resolve,delete e.reject}return e.resolve=o=>{r({status:"fulfilled",value:o}),n(o)},e.reject=o=>{r({status:"rejected",reason:o}),t(o)},e}var v$=u$;function m$(){let n=[],t=0,e=s=>{s()},r=s=>{s()},o=v$;const a=s=>{t?n.push(s):o(()=>{e(s)})},i=()=>{const s=n;n=[],s.length&&o(()=>{r(()=>{s.forEach(u=>{e(u)})})})};return{batch:s=>{let u;t++;try{u=s()}finally{t--,t||i()}return u},batchCalls:s=>(...u)=>{a(()=>{s(...u)})},schedule:a,setNotifyFunction:s=>{e=s},setBatchNotifyFunction:s=>{r=s},setScheduler:s=>{o=s}}}var Bt=m$(),g$=(j_=class extends pi{constructor(){super();Ie(this,fs,!0);Ie(this,ia);Ie(this,hs);ge(this,hs,t=>{if(!Ca&&window.addEventListener){const e=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",r)}}})}onSubscribe(){W(this,ia)||this.setEventListener(W(this,hs))}onUnsubscribe(){var t;this.hasListeners()||((t=W(this,ia))==null||t.call(this),ge(this,ia,void 0))}setEventListener(t){var e;ge(this,hs,t),(e=W(this,ia))==null||e.call(this),ge(this,ia,t(this.setOnline.bind(this)))}setOnline(t){W(this,fs)!==t&&(ge(this,fs,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return W(this,fs)}},fs=new WeakMap,ia=new WeakMap,hs=new WeakMap,j_),Ec=new g$;function y$(n){return Math.min(1e3*2**n,3e4)}function F0(n){return(n??"online")==="online"?Ec.isOnline():!0}var df=class extends Error{constructor(n){super("CancelledError"),this.revert=n==null?void 0:n.revert,this.silent=n==null?void 0:n.silent}};function R0(n){let t=!1,e=0,r;const o=lf(),a=()=>o.status!=="pending",i=p=>{var v;if(!a()){const g=new df(p);f(g),(v=n.onCancel)==null||v.call(n,g)}},s=()=>{t=!0},u=()=>{t=!1},c=()=>cf.isFocused()&&(n.networkMode==="always"||Ec.isOnline())&&n.canRun(),l=()=>F0(n.networkMode)&&n.canRun(),d=p=>{a()||(r==null||r(),o.resolve(p))},f=p=>{a()||(r==null||r(),o.reject(p))},h=()=>new Promise(p=>{var v;r=g=>{(a()||c())&&p(g)},(v=n.onPause)==null||v.call(n)}).then(()=>{var p;r=void 0,a()||(p=n.onContinue)==null||p.call(n)}),m=()=>{if(a())return;let p;const v=e===0?n.initialPromise:void 0;try{p=v??n.fn()}catch(g){p=Promise.reject(g)}Promise.resolve(p).then(d).catch(g=>{var _;if(a())return;const y=n.retry??(Ca?0:3),w=n.retryDelay??y$,x=typeof w=="function"?w(e,g):w,C=y===!0||typeof y=="number"&&e<y||typeof y=="function"&&y(e,g);if(t||!C){f(g);return}e++,(_=n.onFail)==null||_.call(n,e,g),d$(x).then(()=>c()?void 0:h()).then(()=>{t?f(g):m()})})};return{promise:o,status:()=>o.status,cancel:i,continue:()=>(r==null||r(),o),cancelRetry:s,continueRetry:u,canStart:l,start:()=>(l()?m():h().then(m),o)}}var L0=(U_=class{constructor(){Ie(this,Xa)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),rf(this.gcTime)&&ge(this,Xa,wa.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(n){this.gcTime=Math.max(this.gcTime||0,n??(Ca?1/0:5*60*1e3))}clearGcTimeout(){W(this,Xa)&&(wa.clearTimeout(W(this,Xa)),ge(this,Xa,void 0))}},Xa=new WeakMap,U_),b$=(z_=class extends L0{constructor(t){super();Ie(this,yr);Ie(this,Za);Ie(this,ps);Ie(this,Jn);Ie(this,Qa);Ie(this,Zt);Ie(this,zu);Ie(this,Ja);ge(this,Ja,!1),ge(this,zu,t.defaultOptions),this.setOptions(t.options),this.observers=[],ge(this,Qa,t.client),ge(this,Jn,W(this,Qa).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,ge(this,Za,W0(this.options)),this.state=t.state??W(this,Za),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=W(this,Zt))==null?void 0:t.promise}setOptions(t){if(this.options={...W(this,zu),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=W0(this.options);e.data!==void 0&&(this.setData(e.data,{updatedAt:e.dataUpdatedAt,manual:!0}),ge(this,Za,e))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&W(this,Jn).remove(this)}setData(t,e){const r=uf(this.state.data,t,this.options);return He(this,yr,$o).call(this,{data:r,type:"success",dataUpdatedAt:e==null?void 0:e.updatedAt,manual:e==null?void 0:e.manual}),r}setState(t,e){He(this,yr,$o).call(this,{type:"setState",state:t,setStateOptions:e})}cancel(t){var r,o;const e=(r=W(this,Zt))==null?void 0:r.promise;return(o=W(this,Zt))==null||o.cancel(t),e?e.then(fn).catch(fn):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(W(this,Za))}isActive(){return this.observers.some(t=>qn(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===_c||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>To(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:!P0(this.state.dataUpdatedAt,t)}onFocus(){var e;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(e=W(this,Zt))==null||e.continue()}onOnline(){var e;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(e=W(this,Zt))==null||e.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),W(this,Jn).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(W(this,Zt)&&(W(this,Ja)?W(this,Zt).cancel({revert:!0}):W(this,Zt).cancelRetry()),this.scheduleGc()),W(this,Jn).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||He(this,yr,$o).call(this,{type:"invalidate"})}async fetch(t,e){var u,c,l,d,f,h,m,p,v,g,y,w;if(this.state.fetchStatus!=="idle"&&((u=W(this,Zt))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(e!=null&&e.cancelRefetch))this.cancel({silent:!0});else if(W(this,Zt))return W(this,Zt).continueRetry(),W(this,Zt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const x=this.observers.find(C=>C.options.queryFn);x&&this.setOptions(x.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,o=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(ge(this,Ja,!0),r.signal)})},a=()=>{const x=D0(this.options,e),_=(()=>{const E={client:W(this,Qa),queryKey:this.queryKey,meta:this.meta};return o(E),E})();return ge(this,Ja,!1),this.options.persister?this.options.persister(x,_,this):x(_)},s=(()=>{const x={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:W(this,Qa),state:this.state,fetchFn:a};return o(x),x})();(c=this.options.behavior)==null||c.onFetch(s,this),ge(this,ps,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((l=s.fetchOptions)==null?void 0:l.meta))&&He(this,yr,$o).call(this,{type:"fetch",meta:(d=s.fetchOptions)==null?void 0:d.meta}),ge(this,Zt,R0({initialPromise:e==null?void 0:e.initialPromise,fn:s.fetchFn,onCancel:x=>{x instanceof df&&x.revert&&this.setState({...W(this,ps),fetchStatus:"idle"}),r.abort()},onFail:(x,C)=>{He(this,yr,$o).call(this,{type:"failed",failureCount:x,error:C})},onPause:()=>{He(this,yr,$o).call(this,{type:"pause"})},onContinue:()=>{He(this,yr,$o).call(this,{type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0}));try{const x=await W(this,Zt).start();if(x===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(x),(h=(f=W(this,Jn).config).onSuccess)==null||h.call(f,x,this),(p=(m=W(this,Jn).config).onSettled)==null||p.call(m,x,this.state.error,this),x}catch(x){if(x instanceof df){if(x.silent)return W(this,Zt).promise;if(x.revert){if(this.state.data===void 0)throw x;return this.state.data}}throw He(this,yr,$o).call(this,{type:"error",error:x}),(g=(v=W(this,Jn).config).onError)==null||g.call(v,x,this),(w=(y=W(this,Jn).config).onSettled)==null||w.call(y,this.state.data,x,this),x}finally{this.scheduleGc()}}},Za=new WeakMap,ps=new WeakMap,Jn=new WeakMap,Qa=new WeakMap,Zt=new WeakMap,zu=new WeakMap,Ja=new WeakMap,yr=new WeakSet,$o=function(t){const e=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,...B0(r.data,this.options),fetchMeta:t.meta??null};case"success":const o={...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return ge(this,ps,t.manual?o:void 0),o;case"error":const a=t.error;return{...r,error:a,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=e(this.state),Bt.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),W(this,Jn).notify({query:this,type:"updated",action:t})})},z_);function B0(n,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:F0(t.networkMode)?"fetching":"paused",...n===void 0&&{error:null,status:"pending"}}}function W0(n){const t=typeof n.initialData=="function"?n.initialData():n.initialData,e=t!==void 0,r=e?typeof n.initialDataUpdatedAt=="function"?n.initialDataUpdatedAt():n.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:e?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:e?"success":"pending",fetchStatus:"idle"}}var x$=(H_=class extends pi{constructor(t,e){super();Ie(this,ut);Ie(this,An);Ie(this,Qe);Ie(this,Hu);Ie(this,xn);Ie(this,ei);Ie(this,vs);Ie(this,wo);Ie(this,sa);Ie(this,Gu);Ie(this,ms);Ie(this,gs);Ie(this,ti);Ie(this,ni);Ie(this,ua);Ie(this,ys,new Set);this.options=e,ge(this,An,t),ge(this,sa,null),ge(this,wo,lf()),this.bindMethods(),this.setOptions(e)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(W(this,Qe).addObserver(this),V0(W(this,Qe),this.options)?He(this,ut,Yu).call(this):this.updateResult(),He(this,ut,Om).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ff(W(this,Qe),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ff(W(this,Qe),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,He(this,ut,Dm).call(this),He(this,ut,Mm).call(this),W(this,Qe).removeObserver(this)}setOptions(t){const e=this.options,r=W(this,Qe);if(this.options=W(this,An).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof qn(this.options.enabled,W(this,Qe))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");He(this,ut,Fm).call(this),W(this,Qe).setOptions(this.options),e._defaulted&&!Cc(this.options,e)&&W(this,An).getQueryCache().notify({type:"observerOptionsUpdated",query:W(this,Qe),observer:this});const o=this.hasListeners();o&&j0(W(this,Qe),r,this.options,e)&&He(this,ut,Yu).call(this),this.updateResult(),o&&(W(this,Qe)!==r||qn(this.options.enabled,W(this,Qe))!==qn(e.enabled,W(this,Qe))||To(this.options.staleTime,W(this,Qe))!==To(e.staleTime,W(this,Qe)))&&He(this,ut,Im).call(this);const a=He(this,ut,Am).call(this);o&&(W(this,Qe)!==r||qn(this.options.enabled,W(this,Qe))!==qn(e.enabled,W(this,Qe))||a!==W(this,ua))&&He(this,ut,Tm).call(this,a)}getOptimisticResult(t){const e=W(this,An).getQueryCache().build(W(this,An),t),r=this.createResult(e,t);return C$(this,r)&&(ge(this,xn,r),ge(this,vs,this.options),ge(this,ei,W(this,Qe).state)),r}getCurrentResult(){return W(this,xn)}trackResult(t,e){return new Proxy(t,{get:(r,o)=>(this.trackProp(o),e==null||e(o),o==="promise"&&!this.options.experimental_prefetchInRender&&W(this,wo).status==="pending"&&W(this,wo).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),Reflect.get(r,o))})}trackProp(t){W(this,ys).add(t)}getCurrentQuery(){return W(this,Qe)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=W(this,An).defaultQueryOptions(t),r=W(this,An).getQueryCache().build(W(this,An),e);return r.fetch().then(()=>this.createResult(r,e))}fetch(t){return He(this,ut,Yu).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),W(this,xn)))}createResult(t,e){var N;const r=W(this,Qe),o=this.options,a=W(this,xn),i=W(this,ei),s=W(this,vs),c=t!==r?t.state:W(this,Hu),{state:l}=t;let d={...l},f=!1,h;if(e._optimisticResults){const $=this.hasListeners(),A=!$&&V0(t,e),P=$&&j0(t,r,e,o);(A||P)&&(d={...d,...B0(l.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:p,status:v}=d;h=d.data;let g=!1;if(e.placeholderData!==void 0&&h===void 0&&v==="pending"){let $;a!=null&&a.isPlaceholderData&&e.placeholderData===(s==null?void 0:s.placeholderData)?($=a.data,g=!0):$=typeof e.placeholderData=="function"?e.placeholderData((N=W(this,gs))==null?void 0:N.state.data,W(this,gs)):e.placeholderData,$!==void 0&&(v="success",h=uf(a==null?void 0:a.data,$,e),f=!0)}if(e.select&&h!==void 0&&!g)if(a&&h===(i==null?void 0:i.data)&&e.select===W(this,Gu))h=W(this,ms);else try{ge(this,Gu,e.select),h=e.select(h),h=uf(a==null?void 0:a.data,h,e),ge(this,ms,h),ge(this,sa,null)}catch($){ge(this,sa,$)}W(this,sa)&&(m=W(this,sa),h=W(this,ms),p=Date.now(),v="error");const y=d.fetchStatus==="fetching",w=v==="pending",x=v==="error",C=w&&y,_=h!==void 0,S={status:v,fetchStatus:d.fetchStatus,isPending:w,isSuccess:v==="success",isError:x,isInitialLoading:C,isLoading:C,data:h,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:p,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:y,isRefetching:y&&!w,isLoadingError:x&&!_,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:x&&_,isStale:hf(t,e),refetch:this.refetch,promise:W(this,wo),isEnabled:qn(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const $=j=>{S.status==="error"?j.reject(S.error):S.data!==void 0&&j.resolve(S.data)},A=()=>{const j=ge(this,wo,S.promise=lf());$(j)},P=W(this,wo);switch(P.status){case"pending":t.queryHash===r.queryHash&&$(P);break;case"fulfilled":(S.status==="error"||S.data!==P.value)&&A();break;case"rejected":(S.status!=="error"||S.error!==P.reason)&&A();break}}return S}updateResult(){const t=W(this,xn),e=this.createResult(W(this,Qe),this.options);if(ge(this,ei,W(this,Qe).state),ge(this,vs,this.options),W(this,ei).data!==void 0&&ge(this,gs,W(this,Qe)),Cc(e,t))return;ge(this,xn,e);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:o}=this.options,a=typeof o=="function"?o():o;if(a==="all"||!a&&!W(this,ys).size)return!0;const i=new Set(a??W(this,ys));return this.options.throwOnError&&i.add("error"),Object.keys(W(this,xn)).some(s=>{const u=s;return W(this,xn)[u]!==t[u]&&i.has(u)})};He(this,ut,e4).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&He(this,ut,Om).call(this)}},An=new WeakMap,Qe=new WeakMap,Hu=new WeakMap,xn=new WeakMap,ei=new WeakMap,vs=new WeakMap,wo=new WeakMap,sa=new WeakMap,Gu=new WeakMap,ms=new WeakMap,gs=new WeakMap,ti=new WeakMap,ni=new WeakMap,ua=new WeakMap,ys=new WeakMap,ut=new WeakSet,Yu=function(t){He(this,ut,Fm).call(this);let e=W(this,Qe).fetch(this.options,t);return t!=null&&t.throwOnError||(e=e.catch(fn)),e},Im=function(){He(this,ut,Dm).call(this);const t=To(this.options.staleTime,W(this,Qe));if(Ca||W(this,xn).isStale||!rf(t))return;const r=P0(W(this,xn).dataUpdatedAt,t)+1;ge(this,ti,wa.setTimeout(()=>{W(this,xn).isStale||this.updateResult()},r))},Am=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(W(this,Qe)):this.options.refetchInterval)??!1},Tm=function(t){He(this,ut,Mm).call(this),ge(this,ua,t),!(Ca||qn(this.options.enabled,W(this,Qe))===!1||!rf(W(this,ua))||W(this,ua)===0)&&ge(this,ni,wa.setInterval(()=>{(this.options.refetchIntervalInBackground||cf.isFocused())&&He(this,ut,Yu).call(this)},W(this,ua)))},Om=function(){He(this,ut,Im).call(this),He(this,ut,Tm).call(this,He(this,ut,Am).call(this))},Dm=function(){W(this,ti)&&(wa.clearTimeout(W(this,ti)),ge(this,ti,void 0))},Mm=function(){W(this,ni)&&(wa.clearInterval(W(this,ni)),ge(this,ni,void 0))},Fm=function(){const t=W(this,An).getQueryCache().build(W(this,An),this.options);if(t===W(this,Qe))return;const e=W(this,Qe);ge(this,Qe,t),ge(this,Hu,t.state),this.hasListeners()&&(e==null||e.removeObserver(this),t.addObserver(this))},e4=function(t){Bt.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(W(this,xn))}),W(this,An).getQueryCache().notify({query:W(this,Qe),type:"observerResultsUpdated"})})},H_);function w$(n,t){return qn(t.enabled,n)!==!1&&n.state.data===void 0&&!(n.state.status==="error"&&t.retryOnMount===!1)}function V0(n,t){return w$(n,t)||n.state.data!==void 0&&ff(n,t,t.refetchOnMount)}function ff(n,t,e){if(qn(t.enabled,n)!==!1&&To(t.staleTime,n)!=="static"){const r=typeof e=="function"?e(n):e;return r==="always"||r!==!1&&hf(n,t)}return!1}function j0(n,t,e,r){return(n!==t||qn(r.enabled,n)===!1)&&(!e.suspense||n.state.status!=="error")&&hf(n,e)}function hf(n,t){return qn(t.enabled,n)!==!1&&n.isStaleByTime(To(t.staleTime,n))}function C$(n,t){return!Cc(n.getCurrentResult(),t)}function U0(n){return{onFetch:(t,e)=>{var l,d,f,h,m;const r=t.options,o=(f=(d=(l=t.fetchOptions)==null?void 0:l.meta)==null?void 0:d.fetchMore)==null?void 0:f.direction,a=((h=t.state.data)==null?void 0:h.pages)||[],i=((m=t.state.data)==null?void 0:m.pageParams)||[];let s={pages:[],pageParams:[]},u=0;const c=async()=>{let p=!1;const v=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(t.signal.aborted?p=!0:t.signal.addEventListener("abort",()=>{p=!0}),t.signal)})},g=D0(t.options,t.fetchOptions),y=async(w,x,C)=>{if(p)return Promise.reject();if(x==null&&w.pages.length)return Promise.resolve(w);const E=(()=>{const A={client:t.client,queryKey:t.queryKey,pageParam:x,direction:C?"backward":"forward",meta:t.options.meta};return v(A),A})(),S=await g(E),{maxPages:N}=t.options,$=C?h$:f$;return{pages:$(w.pages,S,N),pageParams:$(w.pageParams,x,N)}};if(o&&a.length){const w=o==="backward",x=w?_$:z0,C={pages:a,pageParams:i},_=x(r,C);s=await y(C,_,w)}else{const w=n??a.length;do{const x=u===0?i[0]??r.initialPageParam:z0(r,s);if(u>0&&x==null)break;s=await y(s,x),u++}while(u<w)}return s};t.options.persister?t.fetchFn=()=>{var p,v;return(v=(p=t.options).persister)==null?void 0:v.call(p,c,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},e)}:t.fetchFn=c}}}function z0(n,{pages:t,pageParams:e}){const r=t.length-1;return t.length>0?n.getNextPageParam(t[r],t,e[r],e):void 0}function _$(n,{pages:t,pageParams:e}){var r;return t.length>0?(r=n.getPreviousPageParam)==null?void 0:r.call(n,t[0],t,e[0],e):void 0}var E$=(G_=class extends L0{constructor(t){super();Ie(this,Zr);Ie(this,qu);Ie(this,Xr);Ie(this,wn);Ie(this,ri);ge(this,qu,t.client),this.mutationId=t.mutationId,ge(this,wn,t.mutationCache),ge(this,Xr,[]),this.state=t.state||H0(),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,Xr).includes(t)||(W(this,Xr).push(t),this.clearGcTimeout(),W(this,wn).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){ge(this,Xr,W(this,Xr).filter(e=>e!==t)),this.scheduleGc(),W(this,wn).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){W(this,Xr).length||(this.state.status==="pending"?this.scheduleGc():W(this,wn).remove(this))}continue(){var t;return((t=W(this,ri))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var i,s,u,c,l,d,f,h,m,p,v,g,y,w,x,C,_,E,S,N;const e=()=>{He(this,Zr,ga).call(this,{type:"continue"})},r={client:W(this,qu),meta:this.options.meta,mutationKey:this.options.mutationKey};ge(this,ri,R0({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:($,A)=>{He(this,Zr,ga).call(this,{type:"failed",failureCount:$,error:A})},onPause:()=>{He(this,Zr,ga).call(this,{type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>W(this,wn).canRun(this)}));const o=this.state.status==="pending",a=!W(this,ri).canStart();try{if(o)e();else{He(this,Zr,ga).call(this,{type:"pending",variables:t,isPaused:a}),await((s=(i=W(this,wn).config).onMutate)==null?void 0:s.call(i,t,this,r));const A=await((c=(u=this.options).onMutate)==null?void 0:c.call(u,t,r));A!==this.state.context&&He(this,Zr,ga).call(this,{type:"pending",context:A,variables:t,isPaused:a})}const $=await W(this,ri).start();return await((d=(l=W(this,wn).config).onSuccess)==null?void 0:d.call(l,$,t,this.state.context,this,r)),await((h=(f=this.options).onSuccess)==null?void 0:h.call(f,$,t,this.state.context,r)),await((p=(m=W(this,wn).config).onSettled)==null?void 0:p.call(m,$,null,this.state.variables,this.state.context,this,r)),await((g=(v=this.options).onSettled)==null?void 0:g.call(v,$,null,t,this.state.context,r)),He(this,Zr,ga).call(this,{type:"success",data:$}),$}catch($){try{throw await((w=(y=W(this,wn).config).onError)==null?void 0:w.call(y,$,t,this.state.context,this,r)),await((C=(x=this.options).onError)==null?void 0:C.call(x,$,t,this.state.context,r)),await((E=(_=W(this,wn).config).onSettled)==null?void 0:E.call(_,void 0,$,this.state.variables,this.state.context,this,r)),await((N=(S=this.options).onSettled)==null?void 0:N.call(S,void 0,$,t,this.state.context,r)),$}finally{He(this,Zr,ga).call(this,{type:"error",error:$})}}finally{W(this,wn).runNext(this)}}},qu=new WeakMap,Xr=new WeakMap,wn=new WeakMap,ri=new WeakMap,Zr=new WeakSet,ga=function(t){const e=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=e(this.state),Bt.batch(()=>{W(this,Xr).forEach(r=>{r.onMutationUpdate(t)}),W(this,wn).notify({mutation:this,type:"updated",action:t})})},G_);function H0(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var S$=(q_=class extends pi{constructor(t={}){super();Ie(this,Co);Ie(this,br);Ie(this,Ku);this.config=t,ge(this,Co,new Set),ge(this,br,new Map),ge(this,Ku,0)}build(t,e,r){const o=new E$({client:t,mutationCache:this,mutationId:++wd(this,Ku)._,options:t.defaultMutationOptions(e),state:r});return this.add(o),o}add(t){W(this,Co).add(t);const e=Sc(t);if(typeof e=="string"){const r=W(this,br).get(e);r?r.push(t):W(this,br).set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(W(this,Co).delete(t)){const e=Sc(t);if(typeof e=="string"){const r=W(this,br).get(e);if(r)if(r.length>1){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}else r[0]===t&&W(this,br).delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=Sc(t);if(typeof e=="string"){const r=W(this,br).get(e),o=r==null?void 0:r.find(a=>a.state.status==="pending");return!o||o===t}else return!0}runNext(t){var r;const e=Sc(t);if(typeof e=="string"){const o=(r=W(this,br).get(e))==null?void 0:r.find(a=>a!==t&&a.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Bt.batch(()=>{W(this,Co).forEach(t=>{this.notify({type:"removed",mutation:t})}),W(this,Co).clear(),W(this,br).clear()})}getAll(){return Array.from(W(this,Co))}find(t){const e={exact:!0,...t};return this.getAll().find(r=>A0(e,r))}findAll(t={}){return this.getAll().filter(e=>A0(t,e))}notify(t){Bt.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return Bt.batch(()=>Promise.all(t.map(e=>e.continue().catch(fn))))}},Co=new WeakMap,br=new WeakMap,Ku=new WeakMap,q_);function Sc(n){var t;return(t=n.options.scope)==null?void 0:t.id}var N$=(K_=class extends pi{constructor(e,r){super();Ie(this,So);Ie(this,_o);Ie(this,ca);Ie(this,Tn);Ie(this,Eo);ge(this,_o,e),this.setOptions(r),this.bindMethods(),He(this,So,Cd).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var o;const r=this.options;this.options=W(this,_o).defaultMutationOptions(e),Cc(this.options,r)||W(this,_o).getMutationCache().notify({type:"observerOptionsUpdated",mutation:W(this,Tn),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&_a(r.mutationKey)!==_a(this.options.mutationKey)?this.reset():((o=W(this,Tn))==null?void 0:o.state.status)==="pending"&&W(this,Tn).setOptions(this.options)}onUnsubscribe(){var e;this.hasListeners()||(e=W(this,Tn))==null||e.removeObserver(this)}onMutationUpdate(e){He(this,So,Cd).call(this),He(this,So,Rm).call(this,e)}getCurrentResult(){return W(this,ca)}reset(){var e;(e=W(this,Tn))==null||e.removeObserver(this),ge(this,Tn,void 0),He(this,So,Cd).call(this),He(this,So,Rm).call(this)}mutate(e,r){var o;return ge(this,Eo,r),(o=W(this,Tn))==null||o.removeObserver(this),ge(this,Tn,W(this,_o).getMutationCache().build(W(this,_o),this.options)),W(this,Tn).addObserver(this),W(this,Tn).execute(e)}},_o=new WeakMap,ca=new WeakMap,Tn=new WeakMap,Eo=new WeakMap,So=new WeakSet,Cd=function(){var r;const e=((r=W(this,Tn))==null?void 0:r.state)??H0();ge(this,ca,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})},Rm=function(e){Bt.batch(()=>{var r,o,a,i,s,u,c,l;if(W(this,Eo)&&this.hasListeners()){const d=W(this,ca).variables,f=W(this,ca).context,h={client:W(this,_o),meta:this.options.meta,mutationKey:this.options.mutationKey};(e==null?void 0:e.type)==="success"?((o=(r=W(this,Eo)).onSuccess)==null||o.call(r,e.data,d,f,h),(i=(a=W(this,Eo)).onSettled)==null||i.call(a,e.data,null,d,f,h)):(e==null?void 0:e.type)==="error"&&((u=(s=W(this,Eo)).onError)==null||u.call(s,e.error,d,f,h),(l=(c=W(this,Eo)).onSettled)==null||l.call(c,void 0,e.error,d,f,h))}this.listeners.forEach(d=>{d(W(this,ca))})})},K_),$$=(Y_=class extends pi{constructor(t={}){super();Ie(this,Qr);this.config=t,ge(this,Qr,new Map)}build(t,e,r){const o=e.queryKey,a=e.queryHash??of(o,e);let i=this.get(a);return i||(i=new b$({client:t,queryKey:o,queryHash:a,options:t.defaultQueryOptions(e),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(i)),i}add(t){W(this,Qr).has(t.queryHash)||(W(this,Qr).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=W(this,Qr).get(t.queryHash);e&&(t.destroy(),e===t&&W(this,Qr).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Bt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return W(this,Qr).get(t)}getAll(){return[...W(this,Qr).values()]}find(t){const e={exact:!0,...t};return this.getAll().find(r=>I0(e,r))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(r=>I0(t,r)):e}notify(t){Bt.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){Bt.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Bt.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Qr=new WeakMap,Y_),k$=(X_=class{constructor(n={}){Ie(this,Pt);Ie(this,la);Ie(this,da);Ie(this,bs);Ie(this,xs);Ie(this,fa);Ie(this,ws);Ie(this,Cs);ge(this,Pt,n.queryCache||new $$),ge(this,la,n.mutationCache||new S$),ge(this,da,n.defaultOptions||{}),ge(this,bs,new Map),ge(this,xs,new Map),ge(this,fa,0)}mount(){wd(this,fa)._++,W(this,fa)===1&&(ge(this,ws,cf.subscribe(async n=>{n&&(await this.resumePausedMutations(),W(this,Pt).onFocus())})),ge(this,Cs,Ec.subscribe(async n=>{n&&(await this.resumePausedMutations(),W(this,Pt).onOnline())})))}unmount(){var n,t;wd(this,fa)._--,W(this,fa)===0&&((n=W(this,ws))==null||n.call(this),ge(this,ws,void 0),(t=W(this,Cs))==null||t.call(this),ge(this,Cs,void 0))}isFetching(n){return W(this,Pt).findAll({...n,fetchStatus:"fetching"}).length}isMutating(n){return W(this,la).findAll({...n,status:"pending"}).length}getQueryData(n){var e;const t=this.defaultQueryOptions({queryKey:n});return(e=W(this,Pt).get(t.queryHash))==null?void 0:e.state.data}ensureQueryData(n){const t=this.defaultQueryOptions(n),e=W(this,Pt).build(this,t),r=e.state.data;return r===void 0?this.fetchQuery(n):(n.revalidateIfStale&&e.isStaleByTime(To(t.staleTime,e))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(n){return W(this,Pt).findAll(n).map(({queryKey:t,state:e})=>{const r=e.data;return[t,r]})}setQueryData(n,t,e){const r=this.defaultQueryOptions({queryKey:n}),o=W(this,Pt).get(r.queryHash),a=o==null?void 0:o.state.data,i=c$(t,a);if(i!==void 0)return W(this,Pt).build(this,r).setData(i,{...e,manual:!0})}setQueriesData(n,t,e){return Bt.batch(()=>W(this,Pt).findAll(n).map(({queryKey:r})=>[r,this.setQueryData(r,t,e)]))}getQueryState(n){var e;const t=this.defaultQueryOptions({queryKey:n});return(e=W(this,Pt).get(t.queryHash))==null?void 0:e.state}removeQueries(n){const t=W(this,Pt);Bt.batch(()=>{t.findAll(n).forEach(e=>{t.remove(e)})})}resetQueries(n,t){const e=W(this,Pt);return Bt.batch(()=>(e.findAll(n).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...n},t)))}cancelQueries(n,t={}){const e={revert:!0,...t},r=Bt.batch(()=>W(this,Pt).findAll(n).map(o=>o.cancel(e)));return Promise.all(r).then(fn).catch(fn)}invalidateQueries(n,t={}){return Bt.batch(()=>(W(this,Pt).findAll(n).forEach(e=>{e.invalidate()}),(n==null?void 0:n.refetchType)==="none"?Promise.resolve():this.refetchQueries({...n,type:(n==null?void 0:n.refetchType)??(n==null?void 0:n.type)??"active"},t)))}refetchQueries(n,t={}){const e={...t,cancelRefetch:t.cancelRefetch??!0},r=Bt.batch(()=>W(this,Pt).findAll(n).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let a=o.fetch(void 0,e);return e.throwOnError||(a=a.catch(fn)),o.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(fn)}fetchQuery(n){const t=this.defaultQueryOptions(n);t.retry===void 0&&(t.retry=!1);const e=W(this,Pt).build(this,t);return e.isStaleByTime(To(t.staleTime,e))?e.fetch(t):Promise.resolve(e.state.data)}prefetchQuery(n){return this.fetchQuery(n).then(fn).catch(fn)}fetchInfiniteQuery(n){return n.behavior=U0(n.pages),this.fetchQuery(n)}prefetchInfiniteQuery(n){return this.fetchInfiniteQuery(n).then(fn).catch(fn)}ensureInfiniteQueryData(n){return n.behavior=U0(n.pages),this.ensureQueryData(n)}resumePausedMutations(){return Ec.isOnline()?W(this,la).resumePausedMutations():Promise.resolve()}getQueryCache(){return W(this,Pt)}getMutationCache(){return W(this,la)}getDefaultOptions(){return W(this,da)}setDefaultOptions(n){ge(this,da,n)}setQueryDefaults(n,t){W(this,bs).set(_a(n),{queryKey:n,defaultOptions:t})}getQueryDefaults(n){const t=[...W(this,bs).values()],e={};return t.forEach(r=>{Ds(n,r.queryKey)&&Object.assign(e,r.defaultOptions)}),e}setMutationDefaults(n,t){W(this,xs).set(_a(n),{mutationKey:n,defaultOptions:t})}getMutationDefaults(n){const t=[...W(this,xs).values()],e={};return t.forEach(r=>{Ds(n,r.mutationKey)&&Object.assign(e,r.defaultOptions)}),e}defaultQueryOptions(n){if(n._defaulted)return n;const t={...W(this,da).queries,...this.getQueryDefaults(n.queryKey),...n,_defaulted:!0};return t.queryHash||(t.queryHash=of(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===_c&&(t.enabled=!1),t}defaultMutationOptions(n){return n!=null&&n._defaulted?n:{...W(this,da).mutations,...(n==null?void 0:n.mutationKey)&&this.getMutationDefaults(n.mutationKey),...n,_defaulted:!0}}clear(){W(this,Pt).clear(),W(this,la).clear()}},Pt=new WeakMap,la=new WeakMap,da=new WeakMap,bs=new WeakMap,xs=new WeakMap,fa=new WeakMap,ws=new WeakMap,Cs=new WeakMap,X_),G0=k.createContext(void 0),q0=n=>{const t=k.useContext(G0);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},P$=({client:n,children:t})=>(k.useEffect(()=>(n.mount(),()=>{n.unmount()}),[n]),b.jsx(G0.Provider,{value:n,children:t})),K0=k.createContext(!1),I$=()=>k.useContext(K0);K0.Provider;function A$(){let n=!1;return{clearReset:()=>{n=!1},reset:()=>{n=!0},isReset:()=>n}}var T$=k.createContext(A$()),O$=()=>k.useContext(T$),D$=(n,t)=>{(n.suspense||n.throwOnError||n.experimental_prefetchInRender)&&(t.isReset()||(n.retryOnMount=!1))},M$=n=>{k.useEffect(()=>{n.clearReset()},[n])},F$=({result:n,errorResetBoundary:t,throwOnError:e,query:r,suspense:o})=>n.isError&&!t.isReset()&&!n.isFetching&&r&&(o&&n.data===void 0||M0(e,[n.error,r])),R$=n=>{if(n.suspense){const e=o=>o==="static"?o:Math.max(o??1e3,1e3),r=n.staleTime;n.staleTime=typeof r=="function"?(...o)=>e(r(...o)):e(r),typeof n.gcTime=="number"&&(n.gcTime=Math.max(n.gcTime,1e3))}},L$=(n,t)=>n.isLoading&&n.isFetching&&!t,B$=(n,t)=>(n==null?void 0:n.suspense)&&t.isPending,Y0=(n,t,e)=>t.fetchOptimistic(n).catch(()=>{e.clearReset()});function W$(n,t,e){var d,f,h,m,p;if(process.env.NODE_ENV!=="production"&&(typeof n!="object"||Array.isArray(n)))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=I$(),o=O$(),a=q0(),i=a.defaultQueryOptions(n);(f=(d=a.getDefaultOptions().queries)==null?void 0:d._experimental_beforeQuery)==null||f.call(d,i),process.env.NODE_ENV!=="production"&&(i.queryFn||console.error(`[${i.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`)),i._optimisticResults=r?"isRestoring":"optimistic",R$(i),D$(i,o),M$(o);const s=!a.getQueryCache().get(i.queryHash),[u]=k.useState(()=>new t(a,i)),c=u.getOptimisticResult(i),l=!r&&n.subscribed!==!1;if(k.useSyncExternalStore(k.useCallback(v=>{const g=l?u.subscribe(Bt.batchCalls(v)):fn;return u.updateResult(),g},[u,l]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),k.useEffect(()=>{u.setOptions(i)},[i,u]),B$(i,c))throw Y0(i,u,o);if(F$({result:c,errorResetBoundary:o,throwOnError:i.throwOnError,query:a.getQueryCache().get(i.queryHash),suspense:i.suspense}))throw c.error;if((m=(h=a.getDefaultOptions().queries)==null?void 0:h._experimental_afterQuery)==null||m.call(h,i,c),i.experimental_prefetchInRender&&!Ca&&L$(c,r)){const v=s?Y0(i,u,o):(p=a.getQueryCache().get(i.queryHash))==null?void 0:p.promise;v==null||v.catch(fn).finally(()=>{u.updateResult()})}return i.notifyOnChangeProps?c:u.trackResult(c)}function V$(n,t){return W$(n,x$)}function X0(n,t){const e=q0(),[r]=k.useState(()=>new N$(e,n));k.useEffect(()=>{r.setOptions(n)},[r,n]);const o=k.useSyncExternalStore(k.useCallback(i=>r.subscribe(Bt.batchCalls(i)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=k.useCallback((i,s)=>{r.mutate(i,s).catch(fn)},[r]);if(o.error&&M0(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:a,mutateAsync:o.mutate}}const Nc=Dd("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),_t=k.forwardRef(({className:n,variant:t,size:e,asChild:r=!1,...o},a)=>{const i=r?Vm:"button";return b.jsx(i,{className:Be(Nc({variant:t,size:e,className:n})),ref:a,...o})});_t.displayName="Button";const hn=k.forwardRef(({className:n,...t},e)=>b.jsx("div",{ref:e,className:Be("rounded-lg border bg-card text-card-foreground shadow-sm",n),...t}));hn.displayName="Card";const Oo=k.forwardRef(({className:n,...t},e)=>b.jsx("div",{ref:e,className:Be("flex flex-col space-y-1.5 p-6",n),...t}));Oo.displayName="CardHeader";const pf=k.forwardRef(({className:n,...t},e)=>b.jsx("h3",{ref:e,className:Be("text-2xl font-semibold leading-none tracking-tight",n),...t}));pf.displayName="CardTitle";const j$=k.forwardRef(({className:n,...t},e)=>b.jsx("p",{ref:e,className:Be("text-sm text-muted-foreground",n),...t}));j$.displayName="CardDescription";const pn=k.forwardRef(({className:n,...t},e)=>b.jsx("div",{ref:e,className:Be("p-6 pt-0",n),...t}));pn.displayName="CardContent";const U$=k.forwardRef(({className:n,...t},e)=>b.jsx("div",{ref:e,className:Be("flex items-center p-6 pt-0",n),...t}));U$.displayName="CardFooter";const Z0=({title:n="Verify your identity",subtitle:t="We need some information to help us confirm your identity.",onContinue:e})=>b.jsx(hn,{className:"w-full max-w-md mx-auto",children:b.jsxs(pn,{className:"pt-8 text-center",children:[b.jsx("div",{className:"bg-gradient-to-br from-primary/10 to-primary/5 rounded-3xl p-8 mb-8",children:b.jsx("div",{className:"relative mb-8",children:b.jsxs("div",{className:"relative mx-auto w-48 h-32",children:[b.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-primary to-primary/80 rounded-2xl transform rotate-3 shadow-lg",children:b.jsx("div",{className:"flex items-center justify-center h-full",children:b.jsx("div",{className:"w-12 h-12 bg-white/20 rounded-full flex items-center justify-center",children:b.jsx("svg",{viewBox:"0 0 24 24",className:"w-6 h-6 text-white",fill:"currentColor",children:b.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"})})})})}),b.jsx("div",{className:"absolute top-4 right-0 bg-card rounded-xl shadow-lg p-4 transform -rotate-3",children:b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx("div",{className:"w-8 h-8 bg-primary/20 rounded-full"}),b.jsxs("div",{className:"space-y-1",children:[b.jsx("div",{className:"w-12 h-2 bg-primary rounded"}),b.jsx("div",{className:"w-8 h-2 bg-primary/60 rounded"})]})]})}),b.jsx("div",{className:"absolute -top-2 -right-2 w-10 h-10 bg-primary rounded-full flex items-center justify-center shadow-lg",children:b.jsx(Sg,{className:"w-6 h-6 text-white"})})]})})}),b.jsx("h1",{className:"text-3xl font-bold text-foreground mb-4",children:n}),b.jsx("p",{className:"text-lg text-muted-foreground mb-12",children:t}),b.jsx(_t,{className:"w-full h-14 text-lg font-semibold",onClick:e,children:"Start"}),b.jsx("p",{className:"text-sm text-muted-foreground mt-6",children:"Verifying usually takes a few seconds."})]})}),vn=k.forwardRef(({className:n,type:t,...e},r)=>b.jsx("input",{type:t,className:Be("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:r,...e}));vn.displayName="Input";var z$="Label",Q0=k.forwardRef((n,t)=>b.jsx(et.label,{...n,ref:t,onMouseDown:e=>{var o;e.target.closest("button, input, select, textarea")||((o=n.onMouseDown)==null||o.call(n,e),!e.defaultPrevented&&e.detail>1&&e.preventDefault())}}));Q0.displayName=z$;var J0=Q0;const H$=Dd("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ea=k.forwardRef(({className:n,...t},e)=>b.jsx(J0,{ref:e,className:Be(H$(),n),...t}));Ea.displayName=J0.displayName;const G$=({fullName:n,onNameChange:t,onContinue:e,renderProgress:r})=>b.jsxs(hn,{className:"w-full max-w-md mx-auto",children:[b.jsxs(Oo,{className:"text-center",children:[b.jsx(aE,{className:"w-12 h-12 mx-auto mb-4 text-primary"}),b.jsx(pf,{children:"Personal Information"}),b.jsx("p",{className:"text-muted-foreground",children:"Please enter your full legal name"})]}),b.jsxs(pn,{children:[b.jsxs("div",{className:"space-y-4",children:[b.jsxs("div",{children:[b.jsx(Ea,{htmlFor:"fullName",children:"Full Name"}),b.jsx(vn,{id:"fullName",placeholder:"Enter your full name",value:n,onChange:o=>t(o.target.value)})]}),b.jsx(_t,{className:"w-full",onClick:e,disabled:!n.trim(),children:"Continue"})]}),b.jsx("div",{className:"mt-6",children:r()})]})]}),Do=({title:n,subTitle:t,onBack:e})=>b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"flex items-center mb-6",children:[b.jsx(_t,{variant:"ghost",size:"icon",className:"mr-2",onClick:e,children:b.jsx(Cg,{className:"w-6 h-6"})}),b.jsx("h1",{className:"text-2xl font-semibold ml-4",children:n})]}),b.jsx("p",{className:"text-center text-muted-foreground mb-6",children:t})]}),vi=[{id:"id",title:"ID Card",description:"Government-issued personal ID.",icon:rE},{id:"license",title:"Drivers license",description:"Government-issued Drivers license",icon:J4},{id:"passport",title:"Passport",description:"Your official travel document.",icon:Q4},{id:"voterId",title:"Voter ID",description:"Government-issued Voter ID",icon:iE}],ey=({selectedDocumentType:n,onDocumentTypeChange:t,onContinue:e,onBack:r,renderProgress:o})=>b.jsx(hn,{className:"w-full max-w-md mx-auto",children:b.jsxs(pn,{className:"p-6",children:[b.jsx(Do,{title:"Upload ID",subTitle:"Choose the document type you would like to identify with",onBack:r}),b.jsx("div",{className:"space-y-3",children:vi.map(a=>{const i=a.icon;return b.jsx("button",{className:`w-full p-4 rounded-lg border text-left transition-colors hover:bg-muted/50 ${n===a.id?"border-primary bg-primary/5":"border-border"}`,onClick:()=>t(a.id),children:b.jsxs("div",{className:"flex items-center space-x-4",children:[b.jsx("div",{className:"w-12 h-12 bg-primary rounded-full flex items-center justify-center",children:b.jsx(i,{className:"w-6 h-6 text-white"})}),b.jsxs("div",{className:"flex-1",children:[b.jsx("h3",{className:"font-semibold text-foreground",children:a.title}),b.jsx("p",{className:"text-sm text-muted-foreground",children:a.description})]})]})},a.id)})}),b.jsx(_t,{className:"w-full mt-6",onClick:e,disabled:!n,children:"Continue"}),b.jsx("div",{className:"mt-6",children:o()})]})}),ty=({onContinue:n,onBack:t})=>b.jsx(hn,{className:"w-full max-w-md mx-auto",children:b.jsxs(pn,{className:"p-6",children:[b.jsx(Do,{title:"Selfie",subTitle:"Make sure your face is clear and is fully inside the frame.",onBack:t}),b.jsx("div",{className:"m-auto w-44 h-80 bg-gradient-to-br from-primary/20 to-primary/40 rounded-3xl p-4 shadow-2xl",children:b.jsx("div",{className:"w-full h-full bg-background rounded-2xl overflow-hidden relative",children:b.jsx("div",{className:"flex items-center justify-center h-full bg-muted/30",children:b.jsxs("div",{className:"text-center",children:[b.jsx("div",{className:"w-16 h-16 bg-primary rounded-full flex items-center justify-center mx-auto mb-2"}),b.jsx("div",{className:"w-28 h-32 bg-primary/30 rounded-2xl mx-auto"})]})})})}),b.jsx("div",{className:"mt-8",children:b.jsx(_t,{onClick:n,className:"w-full h-12 text-lg font-semibold",children:"Take a selfie"})})]})}),q$=({fullName:n,onComplete:t,onStartOver:e})=>b.jsxs(hn,{className:"w-full max-w-md mx-auto",children:[b.jsxs(Oo,{className:"text-center",children:[b.jsx(Sg,{className:"w-12 h-12 mx-auto mb-4 text-green-500"}),b.jsx(pf,{children:"Review Information"}),b.jsx("p",{className:"text-muted-foreground",children:"Please review your information before submitting"})]}),b.jsx(pn,{children:b.jsxs("div",{className:"space-y-4",children:[b.jsxs("div",{children:[b.jsx(Ea,{children:"Full Name"}),b.jsx("p",{className:"font-medium",children:n})]}),b.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[b.jsxs("div",{children:[b.jsx(Ea,{className:"text-xs",children:"Selfie"}),b.jsx("div",{className:"text-green-500",children:"✓"})]}),b.jsxs("div",{children:[b.jsx(Ea,{className:"text-xs",children:"ID Front"}),b.jsx("div",{className:"text-green-500",children:"✓"})]}),b.jsxs("div",{children:[b.jsx(Ea,{className:"text-xs",children:"ID Back"}),b.jsx("div",{className:"text-green-500",children:"✓"})]})]}),b.jsx(_t,{className:"w-full text-md",onClick:t,children:"Complete Verification"}),b.jsx(_t,{variant:"outline",className:"w-full text-md",onClick:e,children:"Start Over"})]})})]}),ny=({onComplete:n})=>(D.useEffect(()=>{const t=setTimeout(()=>{n()},3e3);return()=>clearTimeout(t)},[n]),b.jsx(hn,{className:"w-full max-w-md mx-auto min-h-[500px] flex items-center justify-center",children:b.jsxs(pn,{className:"text-center space-y-8",children:[b.jsx("div",{children:b.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-2",children:"We're verifying your documents"})}),b.jsx("div",{className:"flex justify-center",children:b.jsx("div",{className:"w-16 h-16 border-4 border-primary border-t-transparent rounded-full animate-spin"})})]})})),ry=({onDoneClick:n})=>b.jsx(hn,{className:"w-full max-w-md mx-auto min-h-[500px] flex items-center justify-center",children:b.jsx(pn,{className:"text-center space-y-8",children:b.jsxs("div",{children:[b.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-2",children:"Your documents have been submitted successfully"}),b.jsx("div",{className:"flex justify-center",children:b.jsx(ac,{size:60,className:"text-primary"})}),b.jsx("p",{className:"text-foreground mt-2",children:"Our compliance team will review your information, and we'll notify you once verification is complete."}),b.jsx("p",{className:"text-foreground mt-2",children:"Thank you for your patience."}),b.jsx(_t,{className:"text-md mt-8",onClick:n,children:"Explore App"})]})})});function vf(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var K$={exports:{}};(function(n){var t=function(e){var r=Object.prototype,o=r.hasOwnProperty,a=Object.defineProperty||function(O,I,L){O[I]=L.value},i,s=typeof Symbol=="function"?Symbol:{},u=s.iterator||"@@iterator",c=s.asyncIterator||"@@asyncIterator",l=s.toStringTag||"@@toStringTag";function d(O,I,L){return Object.defineProperty(O,I,{value:L,enumerable:!0,configurable:!0,writable:!0}),O[I]}try{d({},"")}catch{d=function(I,L,K){return I[L]=K}}function f(O,I,L,K){var q=I&&I.prototype instanceof w?I:w,Z=Object.create(q.prototype),oe=new H(K||[]);return a(Z,"_invoke",{value:P(O,L,oe)}),Z}e.wrap=f;function h(O,I,L){try{return{type:"normal",arg:O.call(I,L)}}catch(K){return{type:"throw",arg:K}}}var m="suspendedStart",p="suspendedYield",v="executing",g="completed",y={};function w(){}function x(){}function C(){}var _={};d(_,u,function(){return this});var E=Object.getPrototypeOf,S=E&&E(E(F([])));S&&S!==r&&o.call(S,u)&&(_=S);var N=C.prototype=w.prototype=Object.create(_);x.prototype=C,a(N,"constructor",{value:C,configurable:!0}),a(C,"constructor",{value:x,configurable:!0}),x.displayName=d(C,l,"GeneratorFunction");function $(O){["next","throw","return"].forEach(function(I){d(O,I,function(L){return this._invoke(I,L)})})}e.isGeneratorFunction=function(O){var I=typeof O=="function"&&O.constructor;return I?I===x||(I.displayName||I.name)==="GeneratorFunction":!1},e.mark=function(O){return Object.setPrototypeOf?Object.setPrototypeOf(O,C):(O.__proto__=C,d(O,l,"GeneratorFunction")),O.prototype=Object.create(N),O},e.awrap=function(O){return{__await:O}};function A(O,I){function L(Z,oe,ae,X){var re=h(O[Z],O,oe);if(re.type==="throw")X(re.arg);else{var ce=re.arg,ue=ce.value;return ue&&typeof ue=="object"&&o.call(ue,"__await")?I.resolve(ue.__await).then(function(se){L("next",se,ae,X)},function(se){L("throw",se,ae,X)}):I.resolve(ue).then(function(se){ce.value=se,ae(ce)},function(se){return L("throw",se,ae,X)})}}var K;function q(Z,oe){function ae(){return new I(function(X,re){L(Z,oe,X,re)})}return K=K?K.then(ae,ae):ae()}a(this,"_invoke",{value:q})}$(A.prototype),d(A.prototype,c,function(){return this}),e.AsyncIterator=A,e.async=function(O,I,L,K,q){q===void 0&&(q=Promise);var Z=new A(f(O,I,L,K),q);return e.isGeneratorFunction(I)?Z:Z.next().then(function(oe){return oe.done?oe.value:Z.next()})};function P(O,I,L){var K=m;return function(Z,oe){if(K===v)throw new Error("Generator is already running");if(K===g){if(Z==="throw")throw oe;return M()}for(L.method=Z,L.arg=oe;;){var ae=L.delegate;if(ae){var X=j(ae,L);if(X){if(X===y)continue;return X}}if(L.method==="next")L.sent=L._sent=L.arg;else if(L.method==="throw"){if(K===m)throw K=g,L.arg;L.dispatchException(L.arg)}else L.method==="return"&&L.abrupt("return",L.arg);K=v;var re=h(O,I,L);if(re.type==="normal"){if(K=L.done?g:p,re.arg===y)continue;return{value:re.arg,done:L.done}}else re.type==="throw"&&(K=g,L.method="throw",L.arg=re.arg)}}}function j(O,I){var L=I.method,K=O.iterator[L];if(K===i)return I.delegate=null,L==="throw"&&O.iterator.return&&(I.method="return",I.arg=i,j(O,I),I.method==="throw")||L!=="return"&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+L+"' method")),y;var q=h(K,O.iterator,I.arg);if(q.type==="throw")return I.method="throw",I.arg=q.arg,I.delegate=null,y;var Z=q.arg;if(!Z)return I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,y;if(Z.done)I[O.resultName]=Z.value,I.next=O.nextLoc,I.method!=="return"&&(I.method="next",I.arg=i);else return Z;return I.delegate=null,y}$(N),d(N,l,"Generator"),d(N,u,function(){return this}),d(N,"toString",function(){return"[object Generator]"});function B(O){var I={tryLoc:O[0]};1 in O&&(I.catchLoc=O[1]),2 in O&&(I.finallyLoc=O[2],I.afterLoc=O[3]),this.tryEntries.push(I)}function z(O){var I=O.completion||{};I.type="normal",delete I.arg,O.completion=I}function H(O){this.tryEntries=[{tryLoc:"root"}],O.forEach(B,this),this.reset(!0)}e.keys=function(O){var I=Object(O),L=[];for(var K in I)L.push(K);return L.reverse(),function q(){for(;L.length;){var Z=L.pop();if(Z in I)return q.value=Z,q.done=!1,q}return q.done=!0,q}};function F(O){if(O){var I=O[u];if(I)return I.call(O);if(typeof O.next=="function")return O;if(!isNaN(O.length)){var L=-1,K=function q(){for(;++L<O.length;)if(o.call(O,L))return q.value=O[L],q.done=!1,q;return q.value=i,q.done=!0,q};return K.next=K}}return{next:M}}e.values=F;function M(){return{value:i,done:!0}}return H.prototype={constructor:H,reset:function(O){if(this.prev=0,this.next=0,this.sent=this._sent=i,this.done=!1,this.delegate=null,this.method="next",this.arg=i,this.tryEntries.forEach(z),!O)for(var I in this)I.charAt(0)==="t"&&o.call(this,I)&&!isNaN(+I.slice(1))&&(this[I]=i)},stop:function(){this.done=!0;var O=this.tryEntries[0],I=O.completion;if(I.type==="throw")throw I.arg;return this.rval},dispatchException:function(O){if(this.done)throw O;var I=this;function L(X,re){return Z.type="throw",Z.arg=O,I.next=X,re&&(I.method="next",I.arg=i),!!re}for(var K=this.tryEntries.length-1;K>=0;--K){var q=this.tryEntries[K],Z=q.completion;if(q.tryLoc==="root")return L("end");if(q.tryLoc<=this.prev){var oe=o.call(q,"catchLoc"),ae=o.call(q,"finallyLoc");if(oe&&ae){if(this.prev<q.catchLoc)return L(q.catchLoc,!0);if(this.prev<q.finallyLoc)return L(q.finallyLoc)}else if(oe){if(this.prev<q.catchLoc)return L(q.catchLoc,!0)}else if(ae){if(this.prev<q.finallyLoc)return L(q.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(O,I){for(var L=this.tryEntries.length-1;L>=0;--L){var K=this.tryEntries[L];if(K.tryLoc<=this.prev&&o.call(K,"finallyLoc")&&this.prev<K.finallyLoc){var q=K;break}}q&&(O==="break"||O==="continue")&&q.tryLoc<=I&&I<=q.finallyLoc&&(q=null);var Z=q?q.completion:{};return Z.type=O,Z.arg=I,q?(this.method="next",this.next=q.finallyLoc,y):this.complete(Z)},complete:function(O,I){if(O.type==="throw")throw O.arg;return O.type==="break"||O.type==="continue"?this.next=O.arg:O.type==="return"?(this.rval=this.arg=O.arg,this.method="return",this.next="end"):O.type==="normal"&&I&&(this.next=I),y},finish:function(O){for(var I=this.tryEntries.length-1;I>=0;--I){var L=this.tryEntries[I];if(L.finallyLoc===O)return this.complete(L.completion,L.afterLoc),z(L),y}},catch:function(O){for(var I=this.tryEntries.length-1;I>=0;--I){var L=this.tryEntries[I];if(L.tryLoc===O){var K=L.completion;if(K.type==="throw"){var q=K.arg;z(L)}return q}}throw new Error("illegal catch attempt")},delegateYield:function(O,I,L){return this.delegate={iterator:F(O),resultName:I,nextLoc:L},this.method==="next"&&(this.arg=i),y}},e}(n.exports);try{regeneratorRuntime=t}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}})(K$);var mf=(n,t)=>`${n}-${t}-${Math.random().toString(16).slice(3,8)}`;const Y$=mf;let oy=0;var ay=({id:n,action:t,payload:e={}})=>{let r=n;return typeof r>"u"&&(r=Y$("Job",oy),oy+=1),{id:r,action:t,payload:e}},mi={};let gf=!1;mi.logging=gf,mi.setLogging=n=>{gf=n},mi.log=(...n)=>gf?console.log.apply(void 0,n):null;const X$=ay,{log:$c}=mi,Z$=mf;let iy=0;var Q$=()=>{const n=Z$("Scheduler",iy),t={},e={};let r=[];iy+=1;const o=()=>r.length,a=()=>Object.keys(t).length,i=()=>{if(r.length!==0){const d=Object.keys(t);for(let f=0;f<d.length;f+=1)if(typeof e[d[f]]>"u"){r[0](t[d[f]]);break}}},s=(d,f)=>new Promise((h,m)=>{const p=X$({action:d,payload:f});r.push(async v=>{r.shift(),e[v.id]=p;try{h(await v[d].apply(void 0,[...f,p.id]))}catch(g){m(g)}finally{delete e[v.id],i()}}),$c(`[${n}]: Add ${p.id} to JobQueue`),$c(`[${n}]: JobQueue length=${r.length}`),i()});return{addWorker:d=>(t[d.id]=d,$c(`[${n}]: Add ${d.id}`),$c(`[${n}]: Number of workers=${a()}`),i(),d.id),addJob:async(d,...f)=>{if(a()===0)throw Error(`[${n}]: You need to have at least one worker before adding jobs`);return s(d,f)},terminate:async()=>{Object.keys(t).forEach(async d=>{await t[d].terminate()}),r=[]},getQueueLen:o,getNumWorkers:a}};function J$(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ek=n=>{const t={};return typeof WorkerGlobalScope<"u"?t.type="webworker":typeof document=="object"?t.type="browser":typeof process=="object"&&typeof J$=="function"&&(t.type="node"),typeof n>"u"?t:t[n]};const tk=ek("type")==="browser"?n=>new URL(n,window.location.href).href:n=>n;var nk=n=>{const t={...n};return["corePath","workerPath","langPath"].forEach(e=>{n[e]&&(t[e]=tk(t[e]))}),t},sy={TESSERACT_ONLY:0,LSTM_ONLY:1,TESSERACT_LSTM_COMBINED:2,DEFAULT:3};const rk={version:"6.0.1"};var ok={workerBlobURL:!0,logger:()=>{}};const ak=rk.version;var ik={...ok,workerPath:`https://cdn.jsdelivr.net/npm/tesseract.js@v${ak}/dist/worker.min.js`},sk=({workerPath:n,workerBlobURL:t})=>{let e;if(Blob&&URL&&t){const r=new Blob([`importScripts("${n}");`],{type:"application/javascript"});e=new Worker(URL.createObjectURL(r))}else e=new Worker(n);return e},uk=n=>{n.terminate()},ck=(n,t)=>{n.onmessage=({data:e})=>{t(e)}},lk=async(n,t)=>{n.postMessage(t)};const yf=n=>new Promise((t,e)=>{const r=new FileReader;r.onload=()=>{t(r.result)},r.onerror=({target:{error:{code:o}}})=>{e(Error(`File could not be read! Code=${o}`))},r.readAsArrayBuffer(n)}),bf=async n=>{let t=n;if(typeof n>"u")return"undefined";if(typeof n=="string")/data:image\/([a-zA-Z]*);base64,([^"]*)/.test(n)?t=atob(n.split(",")[1]).split("").map(e=>e.charCodeAt(0)):t=await(await fetch(n)).arrayBuffer();else if(typeof HTMLElement<"u"&&n instanceof HTMLElement)n.tagName==="IMG"&&(t=await bf(n.src)),n.tagName==="VIDEO"&&(t=await bf(n.poster)),n.tagName==="CANVAS"&&await new Promise(e=>{n.toBlob(async r=>{t=await yf(r),e()})});else if(typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas){const e=await n.convertToBlob();t=await yf(e)}else(n instanceof File||n instanceof Blob)&&(t=await yf(n));return new Uint8Array(t)};var dk=bf,fk={defaultOptions:ik,spawnWorker:sk,terminateWorker:uk,onMessage:ck,send:lk,loadImage:dk};const hk=nk,Pr=ay,{log:uy}=mi,pk=mf,Sa=sy,{defaultOptions:vk,spawnWorker:mk,terminateWorker:gk,onMessage:yk,loadImage:cy,send:bk}=fk;let ly=0;var dy=async(n="eng",t=Sa.LSTM_ONLY,e={},r={})=>{const o=pk("Worker",ly),{logger:a,errorHandler:i,...s}=hk({...vk,...e}),u={},c=typeof n=="string"?n.split("+"):n;let l=t,d=r;const f=[Sa.DEFAULT,Sa.LSTM_ONLY].includes(t)&&!s.legacyCore;let h,m;const p=new Promise((F,M)=>{m=F,h=M}),v=F=>{h(F.message)};let g=mk(s);g.onerror=v,ly+=1;const y=({id:F,action:M,payload:O})=>new Promise((I,L)=>{uy(`[${o}]: Start ${F}, action=${M}`);const K=`${M}-${F}`;u[K]={resolve:I,reject:L},bk(g,{workerId:o,jobId:F,action:M,payload:O})}),w=()=>console.warn("`load` is depreciated and should be removed from code (workers now come pre-loaded)"),x=F=>y(Pr({id:F,action:"load",payload:{options:{lstmOnly:f,corePath:s.corePath,logging:s.logging}}})),C=(F,M,O)=>y(Pr({id:O,action:"FS",payload:{method:"writeFile",args:[F,M]}})),_=(F,M)=>y(Pr({id:M,action:"FS",payload:{method:"readFile",args:[F,{encoding:"utf8"}]}})),E=(F,M)=>y(Pr({id:M,action:"FS",payload:{method:"unlink",args:[F]}})),S=(F,M,O)=>y(Pr({id:O,action:"FS",payload:{method:F,args:M}})),N=(F,M)=>y(Pr({id:M,action:"loadLanguage",payload:{langs:F,options:{langPath:s.langPath,dataPath:s.dataPath,cachePath:s.cachePath,cacheMethod:s.cacheMethod,gzip:s.gzip,lstmOnly:[Sa.DEFAULT,Sa.LSTM_ONLY].includes(l)&&!s.legacyLang}}})),$=(F,M,O,I)=>y(Pr({id:I,action:"initialize",payload:{langs:F,oem:M,config:O}})),A=(F="eng",M,O,I)=>{if(f&&[Sa.TESSERACT_ONLY,Sa.TESSERACT_LSTM_COMBINED].includes(M))throw Error("Legacy model requested but code missing.");const L=M||l;l=L;const K=O||d;d=K;const Z=(typeof F=="string"?F.split("+"):F).filter(oe=>!c.includes(oe));return c.push(...Z),Z.length>0?N(Z,I).then(()=>$(F,L,K,I)):$(F,L,K,I)},P=(F={},M)=>y(Pr({id:M,action:"setParameters",payload:{params:F}})),j=async(F,M={},O={text:!0},I)=>y(Pr({id:I,action:"recognize",payload:{image:await cy(F),options:M,output:O}})),B=async(F,M)=>{if(f)throw Error("`worker.detect` requires Legacy model, which was not loaded.");return y(Pr({id:M,action:"detect",payload:{image:await cy(F)}}))},z=async()=>(g!==null&&(gk(g),g=null),Promise.resolve());yk(g,({workerId:F,jobId:M,status:O,action:I,data:L})=>{const K=`${I}-${M}`;if(O==="resolve")uy(`[${F}]: Complete ${M}`),u[K].resolve({jobId:M,data:L}),delete u[K];else if(O==="reject")if(u[K].reject(L),delete u[K],I==="load"&&h(L),i)i(L);else throw Error(L);else O==="progress"&&a({...L,userJobId:M})});const H={id:o,worker:g,load:w,writeText:C,readText:_,removeFile:E,FS:S,reinitialize:A,setParameters:P,recognize:j,detect:B,terminate:z};return x().then(()=>N(n)).then(()=>$(n,t,r)).then(()=>m(H)).catch(()=>{}),p};const fy=dy;var xk={recognize:async(n,t,e)=>{const r=await fy(t,1,e);return r.recognize(n).finally(async()=>{await r.terminate()})},detect:async(n,t)=>{const e=await fy("osd",0,t);return e.detect(n).finally(async()=>{await e.terminate()})}},wk={AFR:"afr",AMH:"amh",ARA:"ara",ASM:"asm",AZE:"aze",AZE_CYRL:"aze_cyrl",BEL:"bel",BEN:"ben",BOD:"bod",BOS:"bos",BUL:"bul",CAT:"cat",CEB:"ceb",CES:"ces",CHI_SIM:"chi_sim",CHI_TRA:"chi_tra",CHR:"chr",CYM:"cym",DAN:"dan",DEU:"deu",DZO:"dzo",ELL:"ell",ENG:"eng",ENM:"enm",EPO:"epo",EST:"est",EUS:"eus",FAS:"fas",FIN:"fin",FRA:"fra",FRK:"frk",FRM:"frm",GLE:"gle",GLG:"glg",GRC:"grc",GUJ:"guj",HAT:"hat",HEB:"heb",HIN:"hin",HRV:"hrv",HUN:"hun",IKU:"iku",IND:"ind",ISL:"isl",ITA:"ita",ITA_OLD:"ita_old",JAV:"jav",JPN:"jpn",KAN:"kan",KAT:"kat",KAT_OLD:"kat_old",KAZ:"kaz",KHM:"khm",KIR:"kir",KOR:"kor",KUR:"kur",LAO:"lao",LAT:"lat",LAV:"lav",LIT:"lit",MAL:"mal",MAR:"mar",MKD:"mkd",MLT:"mlt",MSA:"msa",MYA:"mya",NEP:"nep",NLD:"nld",NOR:"nor",ORI:"ori",PAN:"pan",POL:"pol",POR:"por",PUS:"pus",RON:"ron",RUS:"rus",SAN:"san",SIN:"sin",SLK:"slk",SLV:"slv",SPA:"spa",SPA_OLD:"spa_old",SQI:"sqi",SRP:"srp",SRP_LATN:"srp_latn",SWA:"swa",SWE:"swe",SYR:"syr",TAM:"tam",TEL:"tel",TGK:"tgk",TGL:"tgl",THA:"tha",TIR:"tir",TUR:"tur",UIG:"uig",UKR:"ukr",URD:"urd",UZB:"uzb",UZB_CYRL:"uzb_cyrl",VIE:"vie",YID:"yid"},Ck={OSD_ONLY:"0",AUTO_OSD:"1",AUTO_ONLY:"2",AUTO:"3",SINGLE_COLUMN:"4",SINGLE_BLOCK_VERT_TEXT:"5",SINGLE_BLOCK:"6",SINGLE_LINE:"7",SINGLE_WORD:"8",CIRCLE_WORD:"9",SINGLE_CHAR:"10",SPARSE_TEXT:"11",SPARSE_TEXT_OSD:"12",RAW_LINE:"13"};const _k=Q$,Ek=dy,Sk=xk,Nk=wk,$k=sy,kk=Ck,{setLogging:Pk}=mi;var Ik={languages:Nk,OEM:$k,PSM:kk,createScheduler:_k,createWorker:Ek,setLogging:Pk,...Sk};const Ak=vf(Ik);/**
|
|
102
|
+
`);function sc(n){return n.label!==void 0}var uS=3,cS="32px",lS="16px",Bg=4e3,dS=356,fS=14,hS=20,pS=200;function nr(...n){return n.filter(Boolean).join(" ")}function vS(n){let[t,e]=n.split("-"),r=[];return t&&r.push(t),e&&r.push(e),r}var mS=n=>{var t,e,r,o,a,i,s,u,c,l,d;let{invert:f,toast:h,unstyled:m,interacting:p,setHeights:v,visibleToasts:g,heights:y,index:w,toasts:x,expanded:C,removeToast:_,defaultRichColors:E,closeButton:S,style:N,cancelButtonStyle:$,actionButtonStyle:A,className:P="",descriptionClassName:j="",duration:B,position:z,gap:H,loadingIcon:F,expandByDefault:M,classNames:O,icons:I,closeButtonAriaLabel:L="Close toast",pauseWhenPageIsHidden:K}=n,[q,Z]=D.useState(null),[oe,ae]=D.useState(null),[X,re]=D.useState(!1),[ce,ue]=D.useState(!1),[se,ee]=D.useState(!1),[_e,Me]=D.useState(!1),[Ye,Ze]=D.useState(!1),[Lt,on]=D.useState(0),[Ct,V]=D.useState(0),Y=D.useRef(h.duration||B||Bg),te=D.useRef(null),he=D.useRef(null),pe=w===0,le=w+1<=g,ye=h.type,We=h.dismissible!==!1,Ge=h.className||"",Qt=h.descriptionClassName||"",xr=D.useMemo(()=>y.findIndex(Ve=>Ve.toastId===h.id)||0,[y,h.id]),er=D.useMemo(()=>{var Ve;return(Ve=h.closeButton)!=null?Ve:S},[h.closeButton,S]),_s=D.useMemo(()=>h.duration||B||Bg,[h.duration,B]),wr=D.useRef(0),On=D.useRef(0),ha=D.useRef(0),No=D.useRef(null),[Nm,xd]=z.split("-"),Z_=D.useMemo(()=>y.reduce((Ve,dt,gt)=>gt>=xr?Ve:Ve+dt.height,0),[y,xr]),Q_=eS(),hz=h.invert||f,$m=ye==="loading";On.current=D.useMemo(()=>xr*H+Z_,[xr,Z_]),D.useEffect(()=>{Y.current=_s},[_s]),D.useEffect(()=>{re(!0)},[]),D.useEffect(()=>{let Ve=he.current;if(Ve){let dt=Ve.getBoundingClientRect().height;return V(dt),v(gt=>[{toastId:h.id,height:dt,position:h.position},...gt]),()=>v(gt=>gt.filter(Cr=>Cr.toastId!==h.id))}},[v,h.id]),D.useLayoutEffect(()=>{if(!X)return;let Ve=he.current,dt=Ve.style.height;Ve.style.height="auto";let gt=Ve.getBoundingClientRect().height;Ve.style.height=dt,V(gt),v(Cr=>Cr.find(_r=>_r.toastId===h.id)?Cr.map(_r=>_r.toastId===h.id?{..._r,height:gt}:_r):[{toastId:h.id,height:gt,position:h.position},...Cr])},[X,h.title,h.description,v,h.id]);let pa=D.useCallback(()=>{ue(!0),on(On.current),v(Ve=>Ve.filter(dt=>dt.toastId!==h.id)),setTimeout(()=>{_(h)},pS)},[h,_,v,On]);D.useEffect(()=>{if(h.promise&&ye==="loading"||h.duration===1/0||h.type==="loading")return;let Ve;return C||p||K&&Q_?(()=>{if(ha.current<wr.current){let dt=new Date().getTime()-wr.current;Y.current=Y.current-dt}ha.current=new Date().getTime()})():Y.current!==1/0&&(wr.current=new Date().getTime(),Ve=setTimeout(()=>{var dt;(dt=h.onAutoClose)==null||dt.call(h,h),pa()},Y.current)),()=>clearTimeout(Ve)},[C,p,h,ye,K,Q_,pa]),D.useEffect(()=>{h.delete&&pa()},[pa,h.delete]);function pz(){var Ve,dt,gt;return I!=null&&I.loading?D.createElement("div",{className:nr(O==null?void 0:O.loader,(Ve=h==null?void 0:h.classNames)==null?void 0:Ve.loader,"sonner-loader"),"data-visible":ye==="loading"},I.loading):F?D.createElement("div",{className:nr(O==null?void 0:O.loader,(dt=h==null?void 0:h.classNames)==null?void 0:dt.loader,"sonner-loader"),"data-visible":ye==="loading"},F):D.createElement(KE,{className:nr(O==null?void 0:O.loader,(gt=h==null?void 0:h.classNames)==null?void 0:gt.loader),visible:ye==="loading"})}return D.createElement("li",{tabIndex:0,ref:he,className:nr(P,Ge,O==null?void 0:O.toast,(t=h==null?void 0:h.classNames)==null?void 0:t.toast,O==null?void 0:O.default,O==null?void 0:O[ye],(e=h==null?void 0:h.classNames)==null?void 0:e[ye]),"data-sonner-toast":"","data-rich-colors":(r=h.richColors)!=null?r:E,"data-styled":!(h.jsx||h.unstyled||m),"data-mounted":X,"data-promise":!!h.promise,"data-swiped":Ye,"data-removed":ce,"data-visible":le,"data-y-position":Nm,"data-x-position":xd,"data-index":w,"data-front":pe,"data-swiping":se,"data-dismissible":We,"data-type":ye,"data-invert":hz,"data-swipe-out":_e,"data-swipe-direction":oe,"data-expanded":!!(C||M&&X),style:{"--index":w,"--toasts-before":w,"--z-index":x.length-w,"--offset":`${ce?Lt:On.current}px`,"--initial-height":M?"auto":`${Ct}px`,...N,...h.style},onDragEnd:()=>{ee(!1),Z(null),No.current=null},onPointerDown:Ve=>{$m||!We||(te.current=new Date,on(On.current),Ve.target.setPointerCapture(Ve.pointerId),Ve.target.tagName!=="BUTTON"&&(ee(!0),No.current={x:Ve.clientX,y:Ve.clientY}))},onPointerUp:()=>{var Ve,dt,gt,Cr;if(_e||!We)return;No.current=null;let _r=Number(((Ve=he.current)==null?void 0:Ve.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),va=Number(((dt=he.current)==null?void 0:dt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),oi=new Date().getTime()-((gt=te.current)==null?void 0:gt.getTime()),Er=q==="x"?_r:va,ma=Math.abs(Er)/oi;if(Math.abs(Er)>=hS||ma>.11){on(On.current),(Cr=h.onDismiss)==null||Cr.call(h,h),ae(q==="x"?_r>0?"right":"left":va>0?"down":"up"),pa(),Me(!0),Ze(!1);return}ee(!1),Z(null)},onPointerMove:Ve=>{var dt,gt,Cr,_r;if(!No.current||!We||((dt=window.getSelection())==null?void 0:dt.toString().length)>0)return;let va=Ve.clientY-No.current.y,oi=Ve.clientX-No.current.x,Er=(gt=n.swipeDirections)!=null?gt:vS(z);!q&&(Math.abs(oi)>1||Math.abs(va)>1)&&Z(Math.abs(oi)>Math.abs(va)?"x":"y");let ma={x:0,y:0};q==="y"?(Er.includes("top")||Er.includes("bottom"))&&(Er.includes("top")&&va<0||Er.includes("bottom")&&va>0)&&(ma.y=va):q==="x"&&(Er.includes("left")||Er.includes("right"))&&(Er.includes("left")&&oi<0||Er.includes("right")&&oi>0)&&(ma.x=oi),(Math.abs(ma.x)>0||Math.abs(ma.y)>0)&&Ze(!0),(Cr=he.current)==null||Cr.style.setProperty("--swipe-amount-x",`${ma.x}px`),(_r=he.current)==null||_r.style.setProperty("--swipe-amount-y",`${ma.y}px`)}},er&&!h.jsx?D.createElement("button",{"aria-label":L,"data-disabled":$m,"data-close-button":!0,onClick:$m||!We?()=>{}:()=>{var Ve;pa(),(Ve=h.onDismiss)==null||Ve.call(h,h)},className:nr(O==null?void 0:O.closeButton,(o=h==null?void 0:h.classNames)==null?void 0:o.closeButton)},(a=I==null?void 0:I.close)!=null?a:JE):null,h.jsx||D.isValidElement(h.title)?h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title:D.createElement(D.Fragment,null,ye||h.icon||h.promise?D.createElement("div",{"data-icon":"",className:nr(O==null?void 0:O.icon,(i=h==null?void 0:h.classNames)==null?void 0:i.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||pz():null,h.type!=="loading"?h.icon||(I==null?void 0:I[ye])||GE(ye):null):null,D.createElement("div",{"data-content":"",className:nr(O==null?void 0:O.content,(s=h==null?void 0:h.classNames)==null?void 0:s.content)},D.createElement("div",{"data-title":"",className:nr(O==null?void 0:O.title,(u=h==null?void 0:h.classNames)==null?void 0:u.title)},typeof h.title=="function"?h.title():h.title),h.description?D.createElement("div",{"data-description":"",className:nr(j,Qt,O==null?void 0:O.description,(c=h==null?void 0:h.classNames)==null?void 0:c.description)},typeof h.description=="function"?h.description():h.description):null),D.isValidElement(h.cancel)?h.cancel:h.cancel&&sc(h.cancel)?D.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||$,onClick:Ve=>{var dt,gt;sc(h.cancel)&&We&&((gt=(dt=h.cancel).onClick)==null||gt.call(dt,Ve),pa())},className:nr(O==null?void 0:O.cancelButton,(l=h==null?void 0:h.classNames)==null?void 0:l.cancelButton)},h.cancel.label):null,D.isValidElement(h.action)?h.action:h.action&&sc(h.action)?D.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||A,onClick:Ve=>{var dt,gt;sc(h.action)&&((gt=(dt=h.action).onClick)==null||gt.call(dt,Ve),!Ve.defaultPrevented&&pa())},className:nr(O==null?void 0:O.actionButton,(d=h==null?void 0:h.classNames)==null?void 0:d.actionButton)},h.action.label):null))};function Wg(){if(typeof window>"u"||typeof document>"u")return"ltr";let n=document.documentElement.getAttribute("dir");return n==="auto"||!n?window.getComputedStyle(document.documentElement).direction:n}function gS(n,t){let e={};return[n,t].forEach((r,o)=>{let a=o===1,i=a?"--mobile-offset":"--offset",s=a?lS:cS;function u(c){["top","right","bottom","left"].forEach(l=>{e[`${i}-${l}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?u(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?e[`${i}-${c}`]=s:e[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):u(s)}),e}var yS=D.forwardRef(function(n,t){let{invert:e,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:a,closeButton:i,className:s,offset:u,mobileOffset:c,theme:l="light",richColors:d,duration:f,style:h,visibleToasts:m=uS,toastOptions:p,dir:v=Wg(),gap:g=fS,loadingIcon:y,icons:w,containerAriaLabel:x="Notifications",pauseWhenPageIsHidden:C}=n,[_,E]=D.useState([]),S=D.useMemo(()=>Array.from(new Set([r].concat(_.filter(K=>K.position).map(K=>K.position)))),[_,r]),[N,$]=D.useState([]),[A,P]=D.useState(!1),[j,B]=D.useState(!1),[z,H]=D.useState(l!=="system"?l:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),F=D.useRef(null),M=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),O=D.useRef(null),I=D.useRef(!1),L=D.useCallback(K=>{E(q=>{var Z;return(Z=q.find(oe=>oe.id===K.id))!=null&&Z.delete||Cn.dismiss(K.id),q.filter(({id:oe})=>oe!==K.id)})},[]);return D.useEffect(()=>Cn.subscribe(K=>{if(K.dismiss){E(q=>q.map(Z=>Z.id===K.id?{...Z,delete:!0}:Z));return}setTimeout(()=>{yt.flushSync(()=>{E(q=>{let Z=q.findIndex(oe=>oe.id===K.id);return Z!==-1?[...q.slice(0,Z),{...q[Z],...K},...q.slice(Z+1)]:[K,...q]})})})}),[]),D.useEffect(()=>{if(l!=="system"){H(l);return}if(l==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?H("dark"):H("light")),typeof window>"u")return;let K=window.matchMedia("(prefers-color-scheme: dark)");try{K.addEventListener("change",({matches:q})=>{H(q?"dark":"light")})}catch{K.addListener(({matches:Z})=>{try{H(Z?"dark":"light")}catch(oe){console.error(oe)}})}},[l]),D.useEffect(()=>{_.length<=1&&P(!1)},[_]),D.useEffect(()=>{let K=q=>{var Z,oe;o.every(ae=>q[ae]||q.code===ae)&&(P(!0),(Z=F.current)==null||Z.focus()),q.code==="Escape"&&(document.activeElement===F.current||(oe=F.current)!=null&&oe.contains(document.activeElement))&&P(!1)};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[o]),D.useEffect(()=>{if(F.current)return()=>{O.current&&(O.current.focus({preventScroll:!0}),O.current=null,I.current=!1)}},[F.current]),D.createElement("section",{ref:t,"aria-label":`${x} ${M}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},S.map((K,q)=>{var Z;let[oe,ae]=K.split("-");return _.length?D.createElement("ol",{key:K,dir:v==="auto"?Wg():v,tabIndex:-1,ref:F,className:s,"data-sonner-toaster":!0,"data-theme":z,"data-y-position":oe,"data-lifted":A&&_.length>1&&!a,"data-x-position":ae,style:{"--front-toast-height":`${((Z=N[0])==null?void 0:Z.height)||0}px`,"--width":`${dS}px`,"--gap":`${g}px`,...h,...gS(u,c)},onBlur:X=>{I.current&&!X.currentTarget.contains(X.relatedTarget)&&(I.current=!1,O.current&&(O.current.focus({preventScroll:!0}),O.current=null))},onFocus:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||I.current||(I.current=!0,O.current=X.relatedTarget)},onMouseEnter:()=>P(!0),onMouseMove:()=>P(!0),onMouseLeave:()=>{j||P(!1)},onDragEnd:()=>P(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||B(!0)},onPointerUp:()=>B(!1)},_.filter(X=>!X.position&&q===0||X.position===K).map((X,re)=>{var ce,ue;return D.createElement(mS,{key:X.id,icons:w,index:re,toast:X,defaultRichColors:d,duration:(ce=p==null?void 0:p.duration)!=null?ce:f,className:p==null?void 0:p.className,descriptionClassName:p==null?void 0:p.descriptionClassName,invert:e,visibleToasts:m,closeButton:(ue=p==null?void 0:p.closeButton)!=null?ue:i,interacting:j,position:K,style:p==null?void 0:p.style,unstyled:p==null?void 0:p.unstyled,classNames:p==null?void 0:p.classNames,cancelButtonStyle:p==null?void 0:p.cancelButtonStyle,actionButtonStyle:p==null?void 0:p.actionButtonStyle,removeToast:L,toasts:_.filter(se=>se.position==X.position),heights:N.filter(se=>se.position==X.position),setHeights:$,expandByDefault:a,gap:g,loadingIcon:y,expanded:A,pauseWhenPageIsHidden:C,swipeDirections:n.swipeDirections})})):null}))});const bS=({...n})=>{const{theme:t="system"}=HE();return b.jsx(yS,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...n})};var xS=k[" useId ".trim().toString()]||(()=>{}),wS=0;function uc(n){const[t,e]=k.useState(xS());return Jt(()=>{e(r=>r??String(wS++))},[n]),t?`radix-${t}`:""}const CS=["top","right","bottom","left"],Io=Math.min,Dn=Math.max,cc=Math.round,lc=Math.floor,Sr=n=>({x:n,y:n}),_S={left:"right",right:"left",bottom:"top",top:"bottom"},ES={start:"end",end:"start"};function Wd(n,t,e){return Dn(n,Io(t,e))}function eo(n,t){return typeof n=="function"?n(t):n}function to(n){return n.split("-")[0]}function ui(n){return n.split("-")[1]}function Vd(n){return n==="x"?"y":"x"}function jd(n){return n==="y"?"height":"width"}const SS=new Set(["top","bottom"]);function Nr(n){return SS.has(to(n))?"y":"x"}function Ud(n){return Vd(Nr(n))}function NS(n,t,e){e===void 0&&(e=!1);const r=ui(n),o=Ud(n),a=jd(o);let i=o==="x"?r===(e?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=dc(i)),[i,dc(i)]}function $S(n){const t=dc(n);return[zd(n),t,zd(t)]}function zd(n){return n.replace(/start|end/g,t=>ES[t])}const Vg=["left","right"],jg=["right","left"],kS=["top","bottom"],PS=["bottom","top"];function IS(n,t,e){switch(n){case"top":case"bottom":return e?t?jg:Vg:t?Vg:jg;case"left":case"right":return t?kS:PS;default:return[]}}function AS(n,t,e,r){const o=ui(n);let a=IS(to(n),e==="start",r);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(zd)))),a}function dc(n){return n.replace(/left|right|bottom|top/g,t=>_S[t])}function TS(n){return{top:0,right:0,bottom:0,left:0,...n}}function Ug(n){return typeof n!="number"?TS(n):{top:n,right:n,bottom:n,left:n}}function fc(n){const{x:t,y:e,width:r,height:o}=n;return{width:r,height:o,top:e,left:t,right:t+r,bottom:e+o,x:t,y:e}}function zg(n,t,e){let{reference:r,floating:o}=n;const a=Nr(t),i=Ud(t),s=jd(i),u=to(t),c=a==="y",l=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,f=r[s]/2-o[s]/2;let h;switch(u){case"top":h={x:l,y:r.y-o.height};break;case"bottom":h={x:l,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-o.width,y:d};break;default:h={x:r.x,y:r.y}}switch(ui(t)){case"start":h[i]-=f*(e&&c?-1:1);break;case"end":h[i]+=f*(e&&c?-1:1);break}return h}const OS=async(n,t,e)=>{const{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:i}=e,s=a.filter(Boolean),u=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:n,floating:t,strategy:o}),{x:l,y:d}=zg(c,r,u),f=r,h={},m=0;for(let p=0;p<s.length;p++){const{name:v,fn:g}=s[p],{x:y,y:w,data:x,reset:C}=await g({x:l,y:d,initialPlacement:r,placement:f,strategy:o,middlewareData:h,rects:c,platform:i,elements:{reference:n,floating:t}});l=y??l,d=w??d,h={...h,[v]:{...h[v],...x}},C&&m<=50&&(m++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:n,floating:t,strategy:o}):C.rects),{x:l,y:d}=zg(c,f,u)),p=-1)}return{x:l,y:d,placement:f,strategy:o,middlewareData:h}};async function As(n,t){var e;t===void 0&&(t={});const{x:r,y:o,platform:a,rects:i,elements:s,strategy:u}=n,{boundary:c="clippingAncestors",rootBoundary:l="viewport",elementContext:d="floating",altBoundary:f=!1,padding:h=0}=eo(t,n),m=Ug(h),v=s[f?d==="floating"?"reference":"floating":d],g=fc(await a.getClippingRect({element:(e=await(a.isElement==null?void 0:a.isElement(v)))==null||e?v:v.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:c,rootBoundary:l,strategy:u})),y=d==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),x=await(a.isElement==null?void 0:a.isElement(w))?await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1}:{x:1,y:1},C=fc(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:y,offsetParent:w,strategy:u}):y);return{top:(g.top-C.top+m.top)/x.y,bottom:(C.bottom-g.bottom+m.bottom)/x.y,left:(g.left-C.left+m.left)/x.x,right:(C.right-g.right+m.right)/x.x}}const DS=n=>({name:"arrow",options:n,async fn(t){const{x:e,y:r,placement:o,rects:a,platform:i,elements:s,middlewareData:u}=t,{element:c,padding:l=0}=eo(n,t)||{};if(c==null)return{};const d=Ug(l),f={x:e,y:r},h=Ud(o),m=jd(h),p=await i.getDimensions(c),v=h==="y",g=v?"top":"left",y=v?"bottom":"right",w=v?"clientHeight":"clientWidth",x=a.reference[m]+a.reference[h]-f[h]-a.floating[m],C=f[h]-a.reference[h],_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=_?_[w]:0;(!E||!await(i.isElement==null?void 0:i.isElement(_)))&&(E=s.floating[w]||a.floating[m]);const S=x/2-C/2,N=E/2-p[m]/2-1,$=Io(d[g],N),A=Io(d[y],N),P=$,j=E-p[m]-A,B=E/2-p[m]/2+S,z=Wd(P,B,j),H=!u.arrow&&ui(o)!=null&&B!==z&&a.reference[m]/2-(B<P?$:A)-p[m]/2<0,F=H?B<P?B-P:B-j:0;return{[h]:f[h]+F,data:{[h]:z,centerOffset:B-z-F,...H&&{alignmentOffset:F}},reset:H}}}),MS=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(t){var e,r;const{placement:o,middlewareData:a,rects:i,initialPlacement:s,platform:u,elements:c}=t,{mainAxis:l=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:p=!0,...v}=eo(n,t);if((e=a.arrow)!=null&&e.alignmentOffset)return{};const g=to(o),y=Nr(s),w=to(s)===s,x=await(u.isRTL==null?void 0:u.isRTL(c.floating)),C=f||(w||!p?[dc(s)]:$S(s)),_=m!=="none";!f&&_&&C.push(...AS(s,p,m,x));const E=[s,...C],S=await As(t,v),N=[];let $=((r=a.flip)==null?void 0:r.overflows)||[];if(l&&N.push(S[g]),d){const B=NS(o,i,x);N.push(S[B[0]],S[B[1]])}if($=[...$,{placement:o,overflows:N}],!N.every(B=>B<=0)){var A,P;const B=(((A=a.flip)==null?void 0:A.index)||0)+1,z=E[B];if(z&&(!(d==="alignment"?y!==Nr(z):!1)||$.every(M=>Nr(M.placement)===y?M.overflows[0]>0:!0)))return{data:{index:B,overflows:$},reset:{placement:z}};let H=(P=$.filter(F=>F.overflows[0]<=0).sort((F,M)=>F.overflows[1]-M.overflows[1])[0])==null?void 0:P.placement;if(!H)switch(h){case"bestFit":{var j;const F=(j=$.filter(M=>{if(_){const O=Nr(M.placement);return O===y||O==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(O=>O>0).reduce((O,I)=>O+I,0)]).sort((M,O)=>M[1]-O[1])[0])==null?void 0:j[0];F&&(H=F);break}case"initialPlacement":H=s;break}if(o!==H)return{reset:{placement:H}}}return{}}}};function Hg(n,t){return{top:n.top-t.height,right:n.right-t.width,bottom:n.bottom-t.height,left:n.left-t.width}}function Gg(n){return CS.some(t=>n[t]>=0)}const FS=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(t){const{rects:e}=t,{strategy:r="referenceHidden",...o}=eo(n,t);switch(r){case"referenceHidden":{const a=await As(t,{...o,elementContext:"reference"}),i=Hg(a,e.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Gg(i)}}}case"escaped":{const a=await As(t,{...o,altBoundary:!0}),i=Hg(a,e.floating);return{data:{escapedOffsets:i,escaped:Gg(i)}}}default:return{}}}}},qg=new Set(["left","top"]);async function RS(n,t){const{placement:e,platform:r,elements:o}=n,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=to(e),s=ui(e),u=Nr(e)==="y",c=qg.has(i)?-1:1,l=a&&u?-1:1,d=eo(t,n);let{mainAxis:f,crossAxis:h,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m=="number"&&(h=s==="end"?m*-1:m),u?{x:h*l,y:f*c}:{x:f*c,y:h*l}}const LS=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(t){var e,r;const{x:o,y:a,placement:i,middlewareData:s}=t,u=await RS(t,n);return i===((e=s.offset)==null?void 0:e.placement)&&(r=s.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:a+u.y,data:{...u,placement:i}}}}},BS=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(t){const{x:e,y:r,placement:o}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:s={fn:v=>{let{x:g,y}=v;return{x:g,y}}},...u}=eo(n,t),c={x:e,y:r},l=await As(t,u),d=Nr(to(o)),f=Vd(d);let h=c[f],m=c[d];if(a){const v=f==="y"?"top":"left",g=f==="y"?"bottom":"right",y=h+l[v],w=h-l[g];h=Wd(y,h,w)}if(i){const v=d==="y"?"top":"left",g=d==="y"?"bottom":"right",y=m+l[v],w=m-l[g];m=Wd(y,m,w)}const p=s.fn({...t,[f]:h,[d]:m});return{...p,data:{x:p.x-e,y:p.y-r,enabled:{[f]:a,[d]:i}}}}}},WS=function(n){return n===void 0&&(n={}),{options:n,fn(t){const{x:e,y:r,placement:o,rects:a,middlewareData:i}=t,{offset:s=0,mainAxis:u=!0,crossAxis:c=!0}=eo(n,t),l={x:e,y:r},d=Nr(o),f=Vd(d);let h=l[f],m=l[d];const p=eo(s,t),v=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(u){const w=f==="y"?"height":"width",x=a.reference[f]-a.floating[w]+v.mainAxis,C=a.reference[f]+a.reference[w]-v.mainAxis;h<x?h=x:h>C&&(h=C)}if(c){var g,y;const w=f==="y"?"width":"height",x=qg.has(to(o)),C=a.reference[d]-a.floating[w]+(x&&((g=i.offset)==null?void 0:g[d])||0)+(x?0:v.crossAxis),_=a.reference[d]+a.reference[w]+(x?0:((y=i.offset)==null?void 0:y[d])||0)-(x?v.crossAxis:0);m<C?m=C:m>_&&(m=_)}return{[f]:h,[d]:m}}}},VS=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(t){var e,r;const{placement:o,rects:a,platform:i,elements:s}=t,{apply:u=()=>{},...c}=eo(n,t),l=await As(t,c),d=to(o),f=ui(o),h=Nr(o)==="y",{width:m,height:p}=a.floating;let v,g;d==="top"||d==="bottom"?(v=d,g=f===(await(i.isRTL==null?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(g=d,v=f==="end"?"top":"bottom");const y=p-l.top-l.bottom,w=m-l.left-l.right,x=Io(p-l[v],y),C=Io(m-l[g],w),_=!t.middlewareData.shift;let E=x,S=C;if((e=t.middlewareData.shift)!=null&&e.enabled.x&&(S=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=y),_&&!f){const $=Dn(l.left,0),A=Dn(l.right,0),P=Dn(l.top,0),j=Dn(l.bottom,0);h?S=m-2*($!==0||A!==0?$+A:Dn(l.left,l.right)):E=p-2*(P!==0||j!==0?P+j:Dn(l.top,l.bottom))}await u({...t,availableWidth:S,availableHeight:E});const N=await i.getDimensions(s.floating);return m!==N.width||p!==N.height?{reset:{rects:!0}}:{}}}};function hc(){return typeof window<"u"}function ci(n){return Kg(n)?(n.nodeName||"").toLowerCase():"#document"}function Mn(n){var t;return(n==null||(t=n.ownerDocument)==null?void 0:t.defaultView)||window}function $r(n){var t;return(t=(Kg(n)?n.ownerDocument:n.document)||window.document)==null?void 0:t.documentElement}function Kg(n){return hc()?n instanceof Node||n instanceof Mn(n).Node:!1}function rr(n){return hc()?n instanceof Element||n instanceof Mn(n).Element:!1}function kr(n){return hc()?n instanceof HTMLElement||n instanceof Mn(n).HTMLElement:!1}function Yg(n){return!hc()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Mn(n).ShadowRoot}const jS=new Set(["inline","contents"]);function Ts(n){const{overflow:t,overflowX:e,overflowY:r,display:o}=or(n);return/auto|scroll|overlay|hidden|clip/.test(t+r+e)&&!jS.has(o)}const US=new Set(["table","td","th"]);function zS(n){return US.has(ci(n))}const HS=[":popover-open",":modal"];function pc(n){return HS.some(t=>{try{return n.matches(t)}catch{return!1}})}const GS=["transform","translate","scale","rotate","perspective"],qS=["transform","translate","scale","rotate","perspective","filter"],KS=["paint","layout","strict","content"];function Hd(n){const t=Gd(),e=rr(n)?or(n):n;return GS.some(r=>e[r]?e[r]!=="none":!1)||(e.containerType?e.containerType!=="normal":!1)||!t&&(e.backdropFilter?e.backdropFilter!=="none":!1)||!t&&(e.filter?e.filter!=="none":!1)||qS.some(r=>(e.willChange||"").includes(r))||KS.some(r=>(e.contain||"").includes(r))}function YS(n){let t=Ao(n);for(;kr(t)&&!li(t);){if(Hd(t))return t;if(pc(t))return null;t=Ao(t)}return null}function Gd(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const XS=new Set(["html","body","#document"]);function li(n){return XS.has(ci(n))}function or(n){return Mn(n).getComputedStyle(n)}function vc(n){return rr(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function Ao(n){if(ci(n)==="html")return n;const t=n.assignedSlot||n.parentNode||Yg(n)&&n.host||$r(n);return Yg(t)?t.host:t}function Xg(n){const t=Ao(n);return li(t)?n.ownerDocument?n.ownerDocument.body:n.body:kr(t)&&Ts(t)?t:Xg(t)}function Os(n,t,e){var r;t===void 0&&(t=[]),e===void 0&&(e=!0);const o=Xg(n),a=o===((r=n.ownerDocument)==null?void 0:r.body),i=Mn(o);if(a){const s=qd(i);return t.concat(i,i.visualViewport||[],Ts(o)?o:[],s&&e?Os(s):[])}return t.concat(o,Os(o,[],e))}function qd(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function Zg(n){const t=or(n);let e=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=kr(n),a=o?n.offsetWidth:e,i=o?n.offsetHeight:r,s=cc(e)!==a||cc(r)!==i;return s&&(e=a,r=i),{width:e,height:r,$:s}}function Kd(n){return rr(n)?n:n.contextElement}function di(n){const t=Kd(n);if(!kr(t))return Sr(1);const e=t.getBoundingClientRect(),{width:r,height:o,$:a}=Zg(t);let i=(a?cc(e.width):e.width)/r,s=(a?cc(e.height):e.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!s||!Number.isFinite(s))&&(s=1),{x:i,y:s}}const ZS=Sr(0);function Qg(n){const t=Mn(n);return!Gd()||!t.visualViewport?ZS:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function QS(n,t,e){return t===void 0&&(t=!1),!e||t&&e!==Mn(n)?!1:t}function xa(n,t,e,r){t===void 0&&(t=!1),e===void 0&&(e=!1);const o=n.getBoundingClientRect(),a=Kd(n);let i=Sr(1);t&&(r?rr(r)&&(i=di(r)):i=di(n));const s=QS(a,e,r)?Qg(a):Sr(0);let u=(o.left+s.x)/i.x,c=(o.top+s.y)/i.y,l=o.width/i.x,d=o.height/i.y;if(a){const f=Mn(a),h=r&&rr(r)?Mn(r):r;let m=f,p=qd(m);for(;p&&r&&h!==m;){const v=di(p),g=p.getBoundingClientRect(),y=or(p),w=g.left+(p.clientLeft+parseFloat(y.paddingLeft))*v.x,x=g.top+(p.clientTop+parseFloat(y.paddingTop))*v.y;u*=v.x,c*=v.y,l*=v.x,d*=v.y,u+=w,c+=x,m=Mn(p),p=qd(m)}}return fc({width:l,height:d,x:u,y:c})}function mc(n,t){const e=vc(n).scrollLeft;return t?t.left+e:xa($r(n)).left+e}function Jg(n,t){const e=n.getBoundingClientRect(),r=e.left+t.scrollLeft-mc(n,e),o=e.top+t.scrollTop;return{x:r,y:o}}function JS(n){let{elements:t,rect:e,offsetParent:r,strategy:o}=n;const a=o==="fixed",i=$r(r),s=t?pc(t.floating):!1;if(r===i||s&&a)return e;let u={scrollLeft:0,scrollTop:0},c=Sr(1);const l=Sr(0),d=kr(r);if((d||!d&&!a)&&((ci(r)!=="body"||Ts(i))&&(u=vc(r)),kr(r))){const h=xa(r);c=di(r),l.x=h.x+r.clientLeft,l.y=h.y+r.clientTop}const f=i&&!d&&!a?Jg(i,u):Sr(0);return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-u.scrollLeft*c.x+l.x+f.x,y:e.y*c.y-u.scrollTop*c.y+l.y+f.y}}function eN(n){return Array.from(n.getClientRects())}function tN(n){const t=$r(n),e=vc(n),r=n.ownerDocument.body,o=Dn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Dn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-e.scrollLeft+mc(n);const s=-e.scrollTop;return or(r).direction==="rtl"&&(i+=Dn(t.clientWidth,r.clientWidth)-o),{width:o,height:a,x:i,y:s}}const e0=25;function nN(n,t){const e=Mn(n),r=$r(n),o=e.visualViewport;let a=r.clientWidth,i=r.clientHeight,s=0,u=0;if(o){a=o.width,i=o.height;const l=Gd();(!l||l&&t==="fixed")&&(s=o.offsetLeft,u=o.offsetTop)}const c=mc(r);if(c<=0){const l=r.ownerDocument,d=l.body,f=getComputedStyle(d),h=l.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(r.clientWidth-d.clientWidth-h);m<=e0&&(a-=m)}else c<=e0&&(a+=c);return{width:a,height:i,x:s,y:u}}const rN=new Set(["absolute","fixed"]);function oN(n,t){const e=xa(n,!0,t==="fixed"),r=e.top+n.clientTop,o=e.left+n.clientLeft,a=kr(n)?di(n):Sr(1),i=n.clientWidth*a.x,s=n.clientHeight*a.y,u=o*a.x,c=r*a.y;return{width:i,height:s,x:u,y:c}}function t0(n,t,e){let r;if(t==="viewport")r=nN(n,e);else if(t==="document")r=tN($r(n));else if(rr(t))r=oN(t,e);else{const o=Qg(n);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return fc(r)}function n0(n,t){const e=Ao(n);return e===t||!rr(e)||li(e)?!1:or(e).position==="fixed"||n0(e,t)}function aN(n,t){const e=t.get(n);if(e)return e;let r=Os(n,[],!1).filter(s=>rr(s)&&ci(s)!=="body"),o=null;const a=or(n).position==="fixed";let i=a?Ao(n):n;for(;rr(i)&&!li(i);){const s=or(i),u=Hd(i);!u&&s.position==="fixed"&&(o=null),(a?!u&&!o:!u&&s.position==="static"&&!!o&&rN.has(o.position)||Ts(i)&&!u&&n0(n,i))?r=r.filter(l=>l!==i):o=s,i=Ao(i)}return t.set(n,r),r}function iN(n){let{element:t,boundary:e,rootBoundary:r,strategy:o}=n;const i=[...e==="clippingAncestors"?pc(t)?[]:aN(t,this._c):[].concat(e),r],s=i[0],u=i.reduce((c,l)=>{const d=t0(t,l,o);return c.top=Dn(d.top,c.top),c.right=Io(d.right,c.right),c.bottom=Io(d.bottom,c.bottom),c.left=Dn(d.left,c.left),c},t0(t,s,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function sN(n){const{width:t,height:e}=Zg(n);return{width:t,height:e}}function uN(n,t,e){const r=kr(t),o=$r(t),a=e==="fixed",i=xa(n,!0,a,t);let s={scrollLeft:0,scrollTop:0};const u=Sr(0);function c(){u.x=mc(o)}if(r||!r&&!a)if((ci(t)!=="body"||Ts(o))&&(s=vc(t)),r){const h=xa(t,!0,a,t);u.x=h.x+t.clientLeft,u.y=h.y+t.clientTop}else o&&c();a&&!r&&o&&c();const l=o&&!r&&!a?Jg(o,s):Sr(0),d=i.left+s.scrollLeft-u.x-l.x,f=i.top+s.scrollTop-u.y-l.y;return{x:d,y:f,width:i.width,height:i.height}}function Yd(n){return or(n).position==="static"}function r0(n,t){if(!kr(n)||or(n).position==="fixed")return null;if(t)return t(n);let e=n.offsetParent;return $r(n)===e&&(e=e.ownerDocument.body),e}function o0(n,t){const e=Mn(n);if(pc(n))return e;if(!kr(n)){let o=Ao(n);for(;o&&!li(o);){if(rr(o)&&!Yd(o))return o;o=Ao(o)}return e}let r=r0(n,t);for(;r&&zS(r)&&Yd(r);)r=r0(r,t);return r&&li(r)&&Yd(r)&&!Hd(r)?e:r||YS(n)||e}const cN=async function(n){const t=this.getOffsetParent||o0,e=this.getDimensions,r=await e(n.floating);return{reference:uN(n.reference,await t(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function lN(n){return or(n).direction==="rtl"}const dN={convertOffsetParentRelativeRectToViewportRelativeRect:JS,getDocumentElement:$r,getClippingRect:iN,getOffsetParent:o0,getElementRects:cN,getClientRects:eN,getDimensions:sN,getScale:di,isElement:rr,isRTL:lN};function a0(n,t){return n.x===t.x&&n.y===t.y&&n.width===t.width&&n.height===t.height}function fN(n,t){let e=null,r;const o=$r(n);function a(){var s;clearTimeout(r),(s=e)==null||s.disconnect(),e=null}function i(s,u){s===void 0&&(s=!1),u===void 0&&(u=1),a();const c=n.getBoundingClientRect(),{left:l,top:d,width:f,height:h}=c;if(s||t(),!f||!h)return;const m=lc(d),p=lc(o.clientWidth-(l+f)),v=lc(o.clientHeight-(d+h)),g=lc(l),w={rootMargin:-m+"px "+-p+"px "+-v+"px "+-g+"px",threshold:Dn(0,Io(1,u))||1};let x=!0;function C(_){const E=_[0].intersectionRatio;if(E!==u){if(!x)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!a0(c,n.getBoundingClientRect())&&i(),x=!1}try{e=new IntersectionObserver(C,{...w,root:o.ownerDocument})}catch{e=new IntersectionObserver(C,w)}e.observe(n)}return i(!0),a}function hN(n,t,e,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,c=Kd(n),l=o||a?[...c?Os(c):[],...Os(t)]:[];l.forEach(g=>{o&&g.addEventListener("scroll",e,{passive:!0}),a&&g.addEventListener("resize",e)});const d=c&&s?fN(c,e):null;let f=-1,h=null;i&&(h=new ResizeObserver(g=>{let[y]=g;y&&y.target===c&&h&&(h.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var w;(w=h)==null||w.observe(t)})),e()}),c&&!u&&h.observe(c),h.observe(t));let m,p=u?xa(n):null;u&&v();function v(){const g=xa(n);p&&!a0(p,g)&&e(),p=g,m=requestAnimationFrame(v)}return e(),()=>{var g;l.forEach(y=>{o&&y.removeEventListener("scroll",e),a&&y.removeEventListener("resize",e)}),d==null||d(),(g=h)==null||g.disconnect(),h=null,u&&cancelAnimationFrame(m)}}const pN=LS,vN=BS,mN=MS,gN=VS,yN=FS,i0=DS,bN=WS,xN=(n,t,e)=>{const r=new Map,o={platform:dN,...e},a={...o.platform,_c:r};return OS(n,t,{...o,platform:a})};var wN=typeof document<"u",CN=function(){},gc=wN?D.useLayoutEffect:CN;function yc(n,t){if(n===t)return!0;if(typeof n!=typeof t)return!1;if(typeof n=="function"&&n.toString()===t.toString())return!0;let e,r,o;if(n&&t&&typeof n=="object"){if(Array.isArray(n)){if(e=n.length,e!==t.length)return!1;for(r=e;r--!==0;)if(!yc(n[r],t[r]))return!1;return!0}if(o=Object.keys(n),e=o.length,e!==Object.keys(t).length)return!1;for(r=e;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=e;r--!==0;){const a=o[r];if(!(a==="_owner"&&n.$$typeof)&&!yc(n[a],t[a]))return!1}return!0}return n!==n&&t!==t}function s0(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function u0(n,t){const e=s0(n);return Math.round(t*e)/e}function Xd(n){const t=k.useRef(n);return gc(()=>{t.current=n}),t}function _N(n){n===void 0&&(n={});const{placement:t="bottom",strategy:e="absolute",middleware:r=[],platform:o,elements:{reference:a,floating:i}={},transform:s=!0,whileElementsMounted:u,open:c}=n,[l,d]=k.useState({x:0,y:0,strategy:e,placement:t,middlewareData:{},isPositioned:!1}),[f,h]=k.useState(r);yc(f,r)||h(r);const[m,p]=k.useState(null),[v,g]=k.useState(null),y=k.useCallback(M=>{M!==_.current&&(_.current=M,p(M))},[]),w=k.useCallback(M=>{M!==E.current&&(E.current=M,g(M))},[]),x=a||m,C=i||v,_=k.useRef(null),E=k.useRef(null),S=k.useRef(l),N=u!=null,$=Xd(u),A=Xd(o),P=Xd(c),j=k.useCallback(()=>{if(!_.current||!E.current)return;const M={placement:t,strategy:e,middleware:f};A.current&&(M.platform=A.current),xN(_.current,E.current,M).then(O=>{const I={...O,isPositioned:P.current!==!1};B.current&&!yc(S.current,I)&&(S.current=I,Es.flushSync(()=>{d(I)}))})},[f,t,e,A,P]);gc(()=>{c===!1&&S.current.isPositioned&&(S.current.isPositioned=!1,d(M=>({...M,isPositioned:!1})))},[c]);const B=k.useRef(!1);gc(()=>(B.current=!0,()=>{B.current=!1}),[]),gc(()=>{if(x&&(_.current=x),C&&(E.current=C),x&&C){if($.current)return $.current(x,C,j);j()}},[x,C,j,$,N]);const z=k.useMemo(()=>({reference:_,floating:E,setReference:y,setFloating:w}),[y,w]),H=k.useMemo(()=>({reference:x,floating:C}),[x,C]),F=k.useMemo(()=>{const M={position:e,left:0,top:0};if(!H.floating)return M;const O=u0(H.floating,l.x),I=u0(H.floating,l.y);return s?{...M,transform:"translate("+O+"px, "+I+"px)",...s0(H.floating)>=1.5&&{willChange:"transform"}}:{position:e,left:O,top:I}},[e,s,H.floating,l.x,l.y]);return k.useMemo(()=>({...l,update:j,refs:z,elements:H,floatingStyles:F}),[l,j,z,H,F])}const EN=n=>{function t(e){return{}.hasOwnProperty.call(e,"current")}return{name:"arrow",options:n,fn(e){const{element:r,padding:o}=typeof n=="function"?n(e):n;return r&&t(r)?r.current!=null?i0({element:r.current,padding:o}).fn(e):{}:r?i0({element:r,padding:o}).fn(e):{}}}},SN=(n,t)=>({...pN(n),options:[n,t]}),NN=(n,t)=>({...vN(n),options:[n,t]}),$N=(n,t)=>({...bN(n),options:[n,t]}),kN=(n,t)=>({...mN(n),options:[n,t]}),PN=(n,t)=>({...gN(n),options:[n,t]}),IN=(n,t)=>({...yN(n),options:[n,t]}),AN=(n,t)=>({...EN(n),options:[n,t]});var TN="Arrow",c0=k.forwardRef((n,t)=>{const{children:e,width:r=10,height:o=5,...a}=n;return b.jsx(et.svg,{...a,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:n.asChild?e:b.jsx("polygon",{points:"0,0 30,0 15,10"})})});c0.displayName=TN;var ON=c0;function DN(n){const[t,e]=k.useState(void 0);return Jt(()=>{if(n){e({width:n.offsetWidth,height:n.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let i,s;if("borderBoxSize"in a){const u=a.borderBoxSize,c=Array.isArray(u)?u[0]:u;i=c.inlineSize,s=c.blockSize}else i=n.offsetWidth,s=n.offsetHeight;e({width:i,height:s})});return r.observe(n,{box:"border-box"}),()=>r.unobserve(n)}else e(void 0)},[n]),t}var Zd="Popper",[l0,fi]=ba(Zd),[MN,d0]=l0(Zd),f0=n=>{const{__scopePopper:t,children:e}=n,[r,o]=k.useState(null);return b.jsx(MN,{scope:t,anchor:r,onAnchorChange:o,children:e})};f0.displayName=Zd;var h0="PopperAnchor",p0=k.forwardRef((n,t)=>{const{__scopePopper:e,virtualRef:r,...o}=n,a=d0(h0,e),i=k.useRef(null),s=mt(t,i),u=k.useRef(null);return k.useEffect(()=>{const c=u.current;u.current=(r==null?void 0:r.current)||i.current,c!==u.current&&a.onAnchorChange(u.current)}),r?null:b.jsx(et.div,{...o,ref:s})});p0.displayName=h0;var Qd="PopperContent",[FN,RN]=l0(Qd),v0=k.forwardRef((n,t)=>{var X,re,ce,ue,se,ee;const{__scopePopper:e,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:s=0,avoidCollisions:u=!0,collisionBoundary:c=[],collisionPadding:l=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:h="optimized",onPlaced:m,...p}=n,v=d0(Qd,e),[g,y]=k.useState(null),w=mt(t,_e=>y(_e)),[x,C]=k.useState(null),_=DN(x),E=(_==null?void 0:_.width)??0,S=(_==null?void 0:_.height)??0,N=r+(a!=="center"?"-"+a:""),$=typeof l=="number"?l:{top:0,right:0,bottom:0,left:0,...l},A=Array.isArray(c)?c:[c],P=A.length>0,j={padding:$,boundary:A.filter(BN),altBoundary:P},{refs:B,floatingStyles:z,placement:H,isPositioned:F,middlewareData:M}=_N({strategy:"fixed",placement:N,whileElementsMounted:(..._e)=>hN(..._e,{animationFrame:h==="always"}),elements:{reference:v.anchor},middleware:[SN({mainAxis:o+S,alignmentAxis:i}),u&&NN({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?$N():void 0,...j}),u&&kN({...j}),PN({...j,apply:({elements:_e,rects:Me,availableWidth:Ye,availableHeight:Ze})=>{const{width:Lt,height:on}=Me.reference,Ct=_e.floating.style;Ct.setProperty("--radix-popper-available-width",`${Ye}px`),Ct.setProperty("--radix-popper-available-height",`${Ze}px`),Ct.setProperty("--radix-popper-anchor-width",`${Lt}px`),Ct.setProperty("--radix-popper-anchor-height",`${on}px`)}}),x&&AN({element:x,padding:s}),WN({arrowWidth:E,arrowHeight:S}),f&&IN({strategy:"referenceHidden",...j})]}),[O,I]=y0(H),L=tr(m);Jt(()=>{F&&(L==null||L())},[F,L]);const K=(X=M.arrow)==null?void 0:X.x,q=(re=M.arrow)==null?void 0:re.y,Z=((ce=M.arrow)==null?void 0:ce.centerOffset)!==0,[oe,ae]=k.useState();return Jt(()=>{g&&ae(window.getComputedStyle(g).zIndex)},[g]),b.jsx("div",{ref:B.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:F?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:oe,"--radix-popper-transform-origin":[(ue=M.transformOrigin)==null?void 0:ue.x,(se=M.transformOrigin)==null?void 0:se.y].join(" "),...((ee=M.hide)==null?void 0:ee.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:n.dir,children:b.jsx(FN,{scope:e,placedSide:O,onArrowChange:C,arrowX:K,arrowY:q,shouldHideArrow:Z,children:b.jsx(et.div,{"data-side":O,"data-align":I,...p,ref:w,style:{...p.style,animation:F?void 0:"none"}})})})});v0.displayName=Qd;var m0="PopperArrow",LN={top:"bottom",right:"left",bottom:"top",left:"right"},g0=k.forwardRef(function(t,e){const{__scopePopper:r,...o}=t,a=RN(m0,r),i=LN[a.placedSide];return b.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:b.jsx(ON,{...o,ref:e,style:{...o.style,display:"block"}})})});g0.displayName=m0;function BN(n){return n!==null}var WN=n=>({name:"transformOrigin",options:n,fn(t){var v,g,y;const{placement:e,rects:r,middlewareData:o}=t,i=((v=o.arrow)==null?void 0:v.centerOffset)!==0,s=i?0:n.arrowWidth,u=i?0:n.arrowHeight,[c,l]=y0(e),d={start:"0%",center:"50%",end:"100%"}[l],f=(((g=o.arrow)==null?void 0:g.x)??0)+s/2,h=(((y=o.arrow)==null?void 0:y.y)??0)+u/2;let m="",p="";return c==="bottom"?(m=i?d:`${f}px`,p=`${-u}px`):c==="top"?(m=i?d:`${f}px`,p=`${r.floating.height+u}px`):c==="right"?(m=`${-u}px`,p=i?d:`${h}px`):c==="left"&&(m=`${r.floating.width+u}px`,p=i?d:`${h}px`),{data:{x:m,y:p}}}});function y0(n){const[t,e="center"]=n.split("-");return[t,e]}var b0=f0,bc=p0,Jd=v0,ef=g0,[xc]=ba("Tooltip",[fi]),tf=fi(),x0="TooltipProvider",VN=700,w0="tooltip.open",[jN,C0]=xc(x0),_0=n=>{const{__scopeTooltip:t,delayDuration:e=VN,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:a}=n,i=k.useRef(!0),s=k.useRef(!1),u=k.useRef(0);return k.useEffect(()=>{const c=u.current;return()=>window.clearTimeout(c)},[]),b.jsx(jN,{scope:t,isOpenDelayedRef:i,delayDuration:e,onOpen:k.useCallback(()=>{window.clearTimeout(u.current),i.current=!1},[]),onClose:k.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:k.useCallback(c=>{s.current=c},[]),disableHoverableContent:o,children:a})};_0.displayName=x0;var E0="Tooltip",[yz,wc]=xc(E0),nf="TooltipTrigger",UN=k.forwardRef((n,t)=>{const{__scopeTooltip:e,...r}=n,o=wc(nf,e),a=C0(nf,e),i=tf(e),s=k.useRef(null),u=mt(t,s,o.onTriggerChange),c=k.useRef(!1),l=k.useRef(!1),d=k.useCallback(()=>c.current=!1,[]);return k.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),b.jsx(bc,{asChild:!0,...i,children:b.jsx(et.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:u,onPointerMove:je(n.onPointerMove,f=>{f.pointerType!=="touch"&&!l.current&&!a.isPointerInTransitRef.current&&(o.onTriggerEnter(),l.current=!0)}),onPointerLeave:je(n.onPointerLeave,()=>{o.onTriggerLeave(),l.current=!1}),onPointerDown:je(n.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:je(n.onFocus,()=>{c.current||o.onOpen()}),onBlur:je(n.onBlur,o.onClose),onClick:je(n.onClick,o.onClose)})})});UN.displayName=nf;var zN="TooltipPortal",[bz,HN]=xc(zN,{forceMount:void 0}),hi="TooltipContent",S0=k.forwardRef((n,t)=>{const e=HN(hi,n.__scopeTooltip),{forceMount:r=e.forceMount,side:o="top",...a}=n,i=wc(hi,n.__scopeTooltip);return b.jsx($s,{present:r||i.open,children:i.disableHoverableContent?b.jsx(N0,{side:o,...a,ref:t}):b.jsx(GN,{side:o,...a,ref:t})})}),GN=k.forwardRef((n,t)=>{const e=wc(hi,n.__scopeTooltip),r=C0(hi,n.__scopeTooltip),o=k.useRef(null),a=mt(t,o),[i,s]=k.useState(null),{trigger:u,onClose:c}=e,l=o.current,{onPointerInTransitChange:d}=r,f=k.useCallback(()=>{s(null),d(!1)},[d]),h=k.useCallback((m,p)=>{const v=m.currentTarget,g={x:m.clientX,y:m.clientY},y=ZN(g,v.getBoundingClientRect()),w=QN(g,y),x=JN(p.getBoundingClientRect()),C=t$([...w,...x]);s(C),d(!0)},[d]);return k.useEffect(()=>()=>f(),[f]),k.useEffect(()=>{if(u&&l){const m=v=>h(v,l),p=v=>h(v,u);return u.addEventListener("pointerleave",m),l.addEventListener("pointerleave",p),()=>{u.removeEventListener("pointerleave",m),l.removeEventListener("pointerleave",p)}}},[u,l,h,f]),k.useEffect(()=>{if(i){const m=p=>{const v=p.target,g={x:p.clientX,y:p.clientY},y=(u==null?void 0:u.contains(v))||(l==null?void 0:l.contains(v)),w=!e$(g,i);y?f():w&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[u,l,i,c,f]),b.jsx(N0,{...n,ref:a})}),[qN,KN]=xc(E0,{isInside:!1}),YN=u4("TooltipContent"),N0=k.forwardRef((n,t)=>{const{__scopeTooltip:e,children:r,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:i,...s}=n,u=wc(hi,e),c=tf(e),{onClose:l}=u;return k.useEffect(()=>(document.addEventListener(w0,l),()=>document.removeEventListener(w0,l)),[l]),k.useEffect(()=>{if(u.trigger){const d=f=>{const h=f.target;h!=null&&h.contains(u.trigger)&&l()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[u.trigger,l]),b.jsx(Ns,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:d=>d.preventDefault(),onDismiss:l,children:b.jsxs(Jd,{"data-state":u.stateAttribute,...c,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[b.jsx(YN,{children:r}),b.jsx(qN,{scope:e,isInside:!0,children:b.jsx(I4,{id:u.contentId,role:"tooltip",children:o||r})})]})})});S0.displayName=hi;var $0="TooltipArrow",XN=k.forwardRef((n,t)=>{const{__scopeTooltip:e,...r}=n,o=tf(e);return KN($0,e).isInside?null:b.jsx(ef,{...o,...r,ref:t})});XN.displayName=$0;function ZN(n,t){const e=Math.abs(t.top-n.y),r=Math.abs(t.bottom-n.y),o=Math.abs(t.right-n.x),a=Math.abs(t.left-n.x);switch(Math.min(e,r,o,a)){case a:return"left";case o:return"right";case e:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function QN(n,t,e=5){const r=[];switch(t){case"top":r.push({x:n.x-e,y:n.y+e},{x:n.x+e,y:n.y+e});break;case"bottom":r.push({x:n.x-e,y:n.y-e},{x:n.x+e,y:n.y-e});break;case"left":r.push({x:n.x+e,y:n.y-e},{x:n.x+e,y:n.y+e});break;case"right":r.push({x:n.x-e,y:n.y-e},{x:n.x-e,y:n.y+e});break}return r}function JN(n){const{top:t,right:e,bottom:r,left:o}=n;return[{x:o,y:t},{x:e,y:t},{x:e,y:r},{x:o,y:r}]}function e$(n,t){const{x:e,y:r}=n;let o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const s=t[a],u=t[i],c=s.x,l=s.y,d=u.x,f=u.y;l>r!=f>r&&e<(d-c)*(r-l)/(f-l)+c&&(o=!o)}return o}function t$(n){const t=n.slice();return t.sort((e,r)=>e.x<r.x?-1:e.x>r.x?1:e.y<r.y?-1:e.y>r.y?1:0),n$(t)}function n$(n){if(n.length<=1)return n.slice();const t=[];for(let r=0;r<n.length;r++){const o=n[r];for(;t.length>=2;){const a=t[t.length-1],i=t[t.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const e=[];for(let r=n.length-1;r>=0;r--){const o=n[r];for(;e.length>=2;){const a=e[e.length-1],i=e[e.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))e.pop();else break}e.push(o)}return e.pop(),t.length===1&&e.length===1&&t[0].x===e[0].x&&t[0].y===e[0].y?t:t.concat(e)}var r$=_0,k0=S0;const o$=r$,a$=k.forwardRef(({className:n,sideOffset:t=4,...e},r)=>b.jsx(k0,{ref:r,sideOffset:t,className:Be("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n),...e}));a$.displayName=k0.displayName;var pi=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(n){return this.listeners.add(n),this.onSubscribe(),()=>{this.listeners.delete(n),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},i$={setTimeout:(n,t)=>setTimeout(n,t),clearTimeout:n=>clearTimeout(n),setInterval:(n,t)=>setInterval(n,t),clearInterval:n=>clearInterval(n)},s$=(W_=class{constructor(){Ie(this,Yr,i$);Ie(this,Ka,!1)}setTimeoutProvider(n){process.env.NODE_ENV!=="production"&&W(this,Ka)&&n!==W(this,Yr)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:W(this,Yr),provider:n}),ge(this,Yr,n),process.env.NODE_ENV!=="production"&&ge(this,Ka,!1)}setTimeout(n,t){return process.env.NODE_ENV!=="production"&&ge(this,Ka,!0),W(this,Yr).setTimeout(n,t)}clearTimeout(n){W(this,Yr).clearTimeout(n)}setInterval(n,t){return process.env.NODE_ENV!=="production"&&ge(this,Ka,!0),W(this,Yr).setInterval(n,t)}clearInterval(n){W(this,Yr).clearInterval(n)}},Yr=new WeakMap,Ka=new WeakMap,W_),wa=new s$;function u$(n){setTimeout(n,0)}var Ca=typeof window>"u"||"Deno"in globalThis;function fn(){}function c$(n,t){return typeof n=="function"?n(t):n}function rf(n){return typeof n=="number"&&n>=0&&n!==1/0}function P0(n,t){return Math.max(n+(t||0)-Date.now(),0)}function To(n,t){return typeof n=="function"?n(t):n}function qn(n,t){return typeof n=="function"?n(t):n}function I0(n,t){const{type:e="all",exact:r,fetchStatus:o,predicate:a,queryKey:i,stale:s}=n;if(i){if(r){if(t.queryHash!==of(i,t.options))return!1}else if(!Ds(t.queryKey,i))return!1}if(e!=="all"){const u=t.isActive();if(e==="active"&&!u||e==="inactive"&&u)return!1}return!(typeof s=="boolean"&&t.isStale()!==s||o&&o!==t.state.fetchStatus||a&&!a(t))}function A0(n,t){const{exact:e,status:r,predicate:o,mutationKey:a}=n;if(a){if(!t.options.mutationKey)return!1;if(e){if(_a(t.options.mutationKey)!==_a(a))return!1}else if(!Ds(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function of(n,t){return((t==null?void 0:t.queryKeyHashFn)||_a)(n)}function _a(n){return JSON.stringify(n,(t,e)=>sf(e)?Object.keys(e).sort().reduce((r,o)=>(r[o]=e[o],r),{}):e)}function Ds(n,t){return n===t?!0:typeof n!=typeof t?!1:n&&t&&typeof n=="object"&&typeof t=="object"?Object.keys(t).every(e=>Ds(n[e],t[e])):!1}var l$=Object.prototype.hasOwnProperty;function af(n,t){if(n===t)return n;const e=T0(n)&&T0(t);if(!e&&!(sf(n)&&sf(t)))return t;const o=(e?n:Object.keys(n)).length,a=e?t:Object.keys(t),i=a.length,s=e?new Array(i):{};let u=0;for(let c=0;c<i;c++){const l=e?c:a[c],d=n[l],f=t[l];if(d===f){s[l]=d,(e?c<o:l$.call(n,l))&&u++;continue}if(d===null||f===null||typeof d!="object"||typeof f!="object"){s[l]=f;continue}const h=af(d,f);s[l]=h,h===d&&u++}return o===i&&u===o?n:s}function Cc(n,t){if(!t||Object.keys(n).length!==Object.keys(t).length)return!1;for(const e in n)if(n[e]!==t[e])return!1;return!0}function T0(n){return Array.isArray(n)&&n.length===Object.keys(n).length}function sf(n){if(!O0(n))return!1;const t=n.constructor;if(t===void 0)return!0;const e=t.prototype;return!(!O0(e)||!e.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(n)!==Object.prototype)}function O0(n){return Object.prototype.toString.call(n)==="[object Object]"}function d$(n){return new Promise(t=>{wa.setTimeout(t,n)})}function uf(n,t,e){if(typeof e.structuralSharing=="function")return e.structuralSharing(n,t);if(e.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return af(n,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. [${e.queryHash}]: ${r}`),r}return af(n,t)}return t}function f$(n,t,e=0){const r=[...n,t];return e&&r.length>e?r.slice(1):r}function h$(n,t,e=0){const r=[t,...n];return e&&r.length>e?r.slice(0,-1):r}var _c=Symbol();function D0(n,t){return process.env.NODE_ENV!=="production"&&n.queryFn===_c&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${n.queryHash}'`),!n.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!n.queryFn||n.queryFn===_c?()=>Promise.reject(new Error(`Missing queryFn: '${n.queryHash}'`)):n.queryFn}function M0(n,t){return typeof n=="function"?n(...t):!!n}var p$=(V_=class extends pi{constructor(){super();Ie(this,Ya);Ie(this,aa);Ie(this,ds);ge(this,ds,t=>{if(!Ca&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}})}onSubscribe(){W(this,aa)||this.setEventListener(W(this,ds))}onUnsubscribe(){var t;this.hasListeners()||((t=W(this,aa))==null||t.call(this),ge(this,aa,void 0))}setEventListener(t){var e;ge(this,ds,t),(e=W(this,aa))==null||e.call(this),ge(this,aa,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){W(this,Ya)!==t&&(ge(this,Ya,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){var t;return typeof W(this,Ya)=="boolean"?W(this,Ya):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Ya=new WeakMap,aa=new WeakMap,ds=new WeakMap,V_),cf=new p$;function lf(){let n,t;const e=new Promise((o,a)=>{n=o,t=a});e.status="pending",e.catch(()=>{});function r(o){Object.assign(e,o),delete e.resolve,delete e.reject}return e.resolve=o=>{r({status:"fulfilled",value:o}),n(o)},e.reject=o=>{r({status:"rejected",reason:o}),t(o)},e}var v$=u$;function m$(){let n=[],t=0,e=s=>{s()},r=s=>{s()},o=v$;const a=s=>{t?n.push(s):o(()=>{e(s)})},i=()=>{const s=n;n=[],s.length&&o(()=>{r(()=>{s.forEach(u=>{e(u)})})})};return{batch:s=>{let u;t++;try{u=s()}finally{t--,t||i()}return u},batchCalls:s=>(...u)=>{a(()=>{s(...u)})},schedule:a,setNotifyFunction:s=>{e=s},setBatchNotifyFunction:s=>{r=s},setScheduler:s=>{o=s}}}var Bt=m$(),g$=(j_=class extends pi{constructor(){super();Ie(this,fs,!0);Ie(this,ia);Ie(this,hs);ge(this,hs,t=>{if(!Ca&&window.addEventListener){const e=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",r)}}})}onSubscribe(){W(this,ia)||this.setEventListener(W(this,hs))}onUnsubscribe(){var t;this.hasListeners()||((t=W(this,ia))==null||t.call(this),ge(this,ia,void 0))}setEventListener(t){var e;ge(this,hs,t),(e=W(this,ia))==null||e.call(this),ge(this,ia,t(this.setOnline.bind(this)))}setOnline(t){W(this,fs)!==t&&(ge(this,fs,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return W(this,fs)}},fs=new WeakMap,ia=new WeakMap,hs=new WeakMap,j_),Ec=new g$;function y$(n){return Math.min(1e3*2**n,3e4)}function F0(n){return(n??"online")==="online"?Ec.isOnline():!0}var df=class extends Error{constructor(n){super("CancelledError"),this.revert=n==null?void 0:n.revert,this.silent=n==null?void 0:n.silent}};function R0(n){let t=!1,e=0,r;const o=lf(),a=()=>o.status!=="pending",i=p=>{var v;if(!a()){const g=new df(p);f(g),(v=n.onCancel)==null||v.call(n,g)}},s=()=>{t=!0},u=()=>{t=!1},c=()=>cf.isFocused()&&(n.networkMode==="always"||Ec.isOnline())&&n.canRun(),l=()=>F0(n.networkMode)&&n.canRun(),d=p=>{a()||(r==null||r(),o.resolve(p))},f=p=>{a()||(r==null||r(),o.reject(p))},h=()=>new Promise(p=>{var v;r=g=>{(a()||c())&&p(g)},(v=n.onPause)==null||v.call(n)}).then(()=>{var p;r=void 0,a()||(p=n.onContinue)==null||p.call(n)}),m=()=>{if(a())return;let p;const v=e===0?n.initialPromise:void 0;try{p=v??n.fn()}catch(g){p=Promise.reject(g)}Promise.resolve(p).then(d).catch(g=>{var _;if(a())return;const y=n.retry??(Ca?0:3),w=n.retryDelay??y$,x=typeof w=="function"?w(e,g):w,C=y===!0||typeof y=="number"&&e<y||typeof y=="function"&&y(e,g);if(t||!C){f(g);return}e++,(_=n.onFail)==null||_.call(n,e,g),d$(x).then(()=>c()?void 0:h()).then(()=>{t?f(g):m()})})};return{promise:o,status:()=>o.status,cancel:i,continue:()=>(r==null||r(),o),cancelRetry:s,continueRetry:u,canStart:l,start:()=>(l()?m():h().then(m),o)}}var L0=(U_=class{constructor(){Ie(this,Xa)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),rf(this.gcTime)&&ge(this,Xa,wa.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(n){this.gcTime=Math.max(this.gcTime||0,n??(Ca?1/0:5*60*1e3))}clearGcTimeout(){W(this,Xa)&&(wa.clearTimeout(W(this,Xa)),ge(this,Xa,void 0))}},Xa=new WeakMap,U_),b$=(z_=class extends L0{constructor(t){super();Ie(this,yr);Ie(this,Za);Ie(this,ps);Ie(this,Jn);Ie(this,Qa);Ie(this,Zt);Ie(this,zu);Ie(this,Ja);ge(this,Ja,!1),ge(this,zu,t.defaultOptions),this.setOptions(t.options),this.observers=[],ge(this,Qa,t.client),ge(this,Jn,W(this,Qa).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,ge(this,Za,W0(this.options)),this.state=t.state??W(this,Za),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=W(this,Zt))==null?void 0:t.promise}setOptions(t){if(this.options={...W(this,zu),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=W0(this.options);e.data!==void 0&&(this.setData(e.data,{updatedAt:e.dataUpdatedAt,manual:!0}),ge(this,Za,e))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&W(this,Jn).remove(this)}setData(t,e){const r=uf(this.state.data,t,this.options);return He(this,yr,$o).call(this,{data:r,type:"success",dataUpdatedAt:e==null?void 0:e.updatedAt,manual:e==null?void 0:e.manual}),r}setState(t,e){He(this,yr,$o).call(this,{type:"setState",state:t,setStateOptions:e})}cancel(t){var r,o;const e=(r=W(this,Zt))==null?void 0:r.promise;return(o=W(this,Zt))==null||o.cancel(t),e?e.then(fn).catch(fn):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(W(this,Za))}isActive(){return this.observers.some(t=>qn(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===_c||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>To(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:!P0(this.state.dataUpdatedAt,t)}onFocus(){var e;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(e=W(this,Zt))==null||e.continue()}onOnline(){var e;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(e=W(this,Zt))==null||e.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),W(this,Jn).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(W(this,Zt)&&(W(this,Ja)?W(this,Zt).cancel({revert:!0}):W(this,Zt).cancelRetry()),this.scheduleGc()),W(this,Jn).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||He(this,yr,$o).call(this,{type:"invalidate"})}async fetch(t,e){var u,c,l,d,f,h,m,p,v,g,y,w;if(this.state.fetchStatus!=="idle"&&((u=W(this,Zt))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(e!=null&&e.cancelRefetch))this.cancel({silent:!0});else if(W(this,Zt))return W(this,Zt).continueRetry(),W(this,Zt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const x=this.observers.find(C=>C.options.queryFn);x&&this.setOptions(x.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,o=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(ge(this,Ja,!0),r.signal)})},a=()=>{const x=D0(this.options,e),_=(()=>{const E={client:W(this,Qa),queryKey:this.queryKey,meta:this.meta};return o(E),E})();return ge(this,Ja,!1),this.options.persister?this.options.persister(x,_,this):x(_)},s=(()=>{const x={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:W(this,Qa),state:this.state,fetchFn:a};return o(x),x})();(c=this.options.behavior)==null||c.onFetch(s,this),ge(this,ps,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((l=s.fetchOptions)==null?void 0:l.meta))&&He(this,yr,$o).call(this,{type:"fetch",meta:(d=s.fetchOptions)==null?void 0:d.meta}),ge(this,Zt,R0({initialPromise:e==null?void 0:e.initialPromise,fn:s.fetchFn,onCancel:x=>{x instanceof df&&x.revert&&this.setState({...W(this,ps),fetchStatus:"idle"}),r.abort()},onFail:(x,C)=>{He(this,yr,$o).call(this,{type:"failed",failureCount:x,error:C})},onPause:()=>{He(this,yr,$o).call(this,{type:"pause"})},onContinue:()=>{He(this,yr,$o).call(this,{type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0}));try{const x=await W(this,Zt).start();if(x===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(x),(h=(f=W(this,Jn).config).onSuccess)==null||h.call(f,x,this),(p=(m=W(this,Jn).config).onSettled)==null||p.call(m,x,this.state.error,this),x}catch(x){if(x instanceof df){if(x.silent)return W(this,Zt).promise;if(x.revert){if(this.state.data===void 0)throw x;return this.state.data}}throw He(this,yr,$o).call(this,{type:"error",error:x}),(g=(v=W(this,Jn).config).onError)==null||g.call(v,x,this),(w=(y=W(this,Jn).config).onSettled)==null||w.call(y,this.state.data,x,this),x}finally{this.scheduleGc()}}},Za=new WeakMap,ps=new WeakMap,Jn=new WeakMap,Qa=new WeakMap,Zt=new WeakMap,zu=new WeakMap,Ja=new WeakMap,yr=new WeakSet,$o=function(t){const e=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,...B0(r.data,this.options),fetchMeta:t.meta??null};case"success":const o={...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return ge(this,ps,t.manual?o:void 0),o;case"error":const a=t.error;return{...r,error:a,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=e(this.state),Bt.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),W(this,Jn).notify({query:this,type:"updated",action:t})})},z_);function B0(n,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:F0(t.networkMode)?"fetching":"paused",...n===void 0&&{error:null,status:"pending"}}}function W0(n){const t=typeof n.initialData=="function"?n.initialData():n.initialData,e=t!==void 0,r=e?typeof n.initialDataUpdatedAt=="function"?n.initialDataUpdatedAt():n.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:e?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:e?"success":"pending",fetchStatus:"idle"}}var x$=(H_=class extends pi{constructor(t,e){super();Ie(this,ut);Ie(this,An);Ie(this,Qe);Ie(this,Hu);Ie(this,xn);Ie(this,ei);Ie(this,vs);Ie(this,wo);Ie(this,sa);Ie(this,Gu);Ie(this,ms);Ie(this,gs);Ie(this,ti);Ie(this,ni);Ie(this,ua);Ie(this,ys,new Set);this.options=e,ge(this,An,t),ge(this,sa,null),ge(this,wo,lf()),this.bindMethods(),this.setOptions(e)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(W(this,Qe).addObserver(this),V0(W(this,Qe),this.options)?He(this,ut,Yu).call(this):this.updateResult(),He(this,ut,Om).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ff(W(this,Qe),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ff(W(this,Qe),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,He(this,ut,Dm).call(this),He(this,ut,Mm).call(this),W(this,Qe).removeObserver(this)}setOptions(t){const e=this.options,r=W(this,Qe);if(this.options=W(this,An).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof qn(this.options.enabled,W(this,Qe))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");He(this,ut,Fm).call(this),W(this,Qe).setOptions(this.options),e._defaulted&&!Cc(this.options,e)&&W(this,An).getQueryCache().notify({type:"observerOptionsUpdated",query:W(this,Qe),observer:this});const o=this.hasListeners();o&&j0(W(this,Qe),r,this.options,e)&&He(this,ut,Yu).call(this),this.updateResult(),o&&(W(this,Qe)!==r||qn(this.options.enabled,W(this,Qe))!==qn(e.enabled,W(this,Qe))||To(this.options.staleTime,W(this,Qe))!==To(e.staleTime,W(this,Qe)))&&He(this,ut,Im).call(this);const a=He(this,ut,Am).call(this);o&&(W(this,Qe)!==r||qn(this.options.enabled,W(this,Qe))!==qn(e.enabled,W(this,Qe))||a!==W(this,ua))&&He(this,ut,Tm).call(this,a)}getOptimisticResult(t){const e=W(this,An).getQueryCache().build(W(this,An),t),r=this.createResult(e,t);return C$(this,r)&&(ge(this,xn,r),ge(this,vs,this.options),ge(this,ei,W(this,Qe).state)),r}getCurrentResult(){return W(this,xn)}trackResult(t,e){return new Proxy(t,{get:(r,o)=>(this.trackProp(o),e==null||e(o),o==="promise"&&!this.options.experimental_prefetchInRender&&W(this,wo).status==="pending"&&W(this,wo).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),Reflect.get(r,o))})}trackProp(t){W(this,ys).add(t)}getCurrentQuery(){return W(this,Qe)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=W(this,An).defaultQueryOptions(t),r=W(this,An).getQueryCache().build(W(this,An),e);return r.fetch().then(()=>this.createResult(r,e))}fetch(t){return He(this,ut,Yu).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),W(this,xn)))}createResult(t,e){var N;const r=W(this,Qe),o=this.options,a=W(this,xn),i=W(this,ei),s=W(this,vs),c=t!==r?t.state:W(this,Hu),{state:l}=t;let d={...l},f=!1,h;if(e._optimisticResults){const $=this.hasListeners(),A=!$&&V0(t,e),P=$&&j0(t,r,e,o);(A||P)&&(d={...d,...B0(l.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:p,status:v}=d;h=d.data;let g=!1;if(e.placeholderData!==void 0&&h===void 0&&v==="pending"){let $;a!=null&&a.isPlaceholderData&&e.placeholderData===(s==null?void 0:s.placeholderData)?($=a.data,g=!0):$=typeof e.placeholderData=="function"?e.placeholderData((N=W(this,gs))==null?void 0:N.state.data,W(this,gs)):e.placeholderData,$!==void 0&&(v="success",h=uf(a==null?void 0:a.data,$,e),f=!0)}if(e.select&&h!==void 0&&!g)if(a&&h===(i==null?void 0:i.data)&&e.select===W(this,Gu))h=W(this,ms);else try{ge(this,Gu,e.select),h=e.select(h),h=uf(a==null?void 0:a.data,h,e),ge(this,ms,h),ge(this,sa,null)}catch($){ge(this,sa,$)}W(this,sa)&&(m=W(this,sa),h=W(this,ms),p=Date.now(),v="error");const y=d.fetchStatus==="fetching",w=v==="pending",x=v==="error",C=w&&y,_=h!==void 0,S={status:v,fetchStatus:d.fetchStatus,isPending:w,isSuccess:v==="success",isError:x,isInitialLoading:C,isLoading:C,data:h,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:p,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:y,isRefetching:y&&!w,isLoadingError:x&&!_,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:x&&_,isStale:hf(t,e),refetch:this.refetch,promise:W(this,wo),isEnabled:qn(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const $=j=>{S.status==="error"?j.reject(S.error):S.data!==void 0&&j.resolve(S.data)},A=()=>{const j=ge(this,wo,S.promise=lf());$(j)},P=W(this,wo);switch(P.status){case"pending":t.queryHash===r.queryHash&&$(P);break;case"fulfilled":(S.status==="error"||S.data!==P.value)&&A();break;case"rejected":(S.status!=="error"||S.error!==P.reason)&&A();break}}return S}updateResult(){const t=W(this,xn),e=this.createResult(W(this,Qe),this.options);if(ge(this,ei,W(this,Qe).state),ge(this,vs,this.options),W(this,ei).data!==void 0&&ge(this,gs,W(this,Qe)),Cc(e,t))return;ge(this,xn,e);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:o}=this.options,a=typeof o=="function"?o():o;if(a==="all"||!a&&!W(this,ys).size)return!0;const i=new Set(a??W(this,ys));return this.options.throwOnError&&i.add("error"),Object.keys(W(this,xn)).some(s=>{const u=s;return W(this,xn)[u]!==t[u]&&i.has(u)})};He(this,ut,e4).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&He(this,ut,Om).call(this)}},An=new WeakMap,Qe=new WeakMap,Hu=new WeakMap,xn=new WeakMap,ei=new WeakMap,vs=new WeakMap,wo=new WeakMap,sa=new WeakMap,Gu=new WeakMap,ms=new WeakMap,gs=new WeakMap,ti=new WeakMap,ni=new WeakMap,ua=new WeakMap,ys=new WeakMap,ut=new WeakSet,Yu=function(t){He(this,ut,Fm).call(this);let e=W(this,Qe).fetch(this.options,t);return t!=null&&t.throwOnError||(e=e.catch(fn)),e},Im=function(){He(this,ut,Dm).call(this);const t=To(this.options.staleTime,W(this,Qe));if(Ca||W(this,xn).isStale||!rf(t))return;const r=P0(W(this,xn).dataUpdatedAt,t)+1;ge(this,ti,wa.setTimeout(()=>{W(this,xn).isStale||this.updateResult()},r))},Am=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(W(this,Qe)):this.options.refetchInterval)??!1},Tm=function(t){He(this,ut,Mm).call(this),ge(this,ua,t),!(Ca||qn(this.options.enabled,W(this,Qe))===!1||!rf(W(this,ua))||W(this,ua)===0)&&ge(this,ni,wa.setInterval(()=>{(this.options.refetchIntervalInBackground||cf.isFocused())&&He(this,ut,Yu).call(this)},W(this,ua)))},Om=function(){He(this,ut,Im).call(this),He(this,ut,Tm).call(this,He(this,ut,Am).call(this))},Dm=function(){W(this,ti)&&(wa.clearTimeout(W(this,ti)),ge(this,ti,void 0))},Mm=function(){W(this,ni)&&(wa.clearInterval(W(this,ni)),ge(this,ni,void 0))},Fm=function(){const t=W(this,An).getQueryCache().build(W(this,An),this.options);if(t===W(this,Qe))return;const e=W(this,Qe);ge(this,Qe,t),ge(this,Hu,t.state),this.hasListeners()&&(e==null||e.removeObserver(this),t.addObserver(this))},e4=function(t){Bt.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(W(this,xn))}),W(this,An).getQueryCache().notify({query:W(this,Qe),type:"observerResultsUpdated"})})},H_);function w$(n,t){return qn(t.enabled,n)!==!1&&n.state.data===void 0&&!(n.state.status==="error"&&t.retryOnMount===!1)}function V0(n,t){return w$(n,t)||n.state.data!==void 0&&ff(n,t,t.refetchOnMount)}function ff(n,t,e){if(qn(t.enabled,n)!==!1&&To(t.staleTime,n)!=="static"){const r=typeof e=="function"?e(n):e;return r==="always"||r!==!1&&hf(n,t)}return!1}function j0(n,t,e,r){return(n!==t||qn(r.enabled,n)===!1)&&(!e.suspense||n.state.status!=="error")&&hf(n,e)}function hf(n,t){return qn(t.enabled,n)!==!1&&n.isStaleByTime(To(t.staleTime,n))}function C$(n,t){return!Cc(n.getCurrentResult(),t)}function U0(n){return{onFetch:(t,e)=>{var l,d,f,h,m;const r=t.options,o=(f=(d=(l=t.fetchOptions)==null?void 0:l.meta)==null?void 0:d.fetchMore)==null?void 0:f.direction,a=((h=t.state.data)==null?void 0:h.pages)||[],i=((m=t.state.data)==null?void 0:m.pageParams)||[];let s={pages:[],pageParams:[]},u=0;const c=async()=>{let p=!1;const v=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(t.signal.aborted?p=!0:t.signal.addEventListener("abort",()=>{p=!0}),t.signal)})},g=D0(t.options,t.fetchOptions),y=async(w,x,C)=>{if(p)return Promise.reject();if(x==null&&w.pages.length)return Promise.resolve(w);const E=(()=>{const A={client:t.client,queryKey:t.queryKey,pageParam:x,direction:C?"backward":"forward",meta:t.options.meta};return v(A),A})(),S=await g(E),{maxPages:N}=t.options,$=C?h$:f$;return{pages:$(w.pages,S,N),pageParams:$(w.pageParams,x,N)}};if(o&&a.length){const w=o==="backward",x=w?_$:z0,C={pages:a,pageParams:i},_=x(r,C);s=await y(C,_,w)}else{const w=n??a.length;do{const x=u===0?i[0]??r.initialPageParam:z0(r,s);if(u>0&&x==null)break;s=await y(s,x),u++}while(u<w)}return s};t.options.persister?t.fetchFn=()=>{var p,v;return(v=(p=t.options).persister)==null?void 0:v.call(p,c,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},e)}:t.fetchFn=c}}}function z0(n,{pages:t,pageParams:e}){const r=t.length-1;return t.length>0?n.getNextPageParam(t[r],t,e[r],e):void 0}function _$(n,{pages:t,pageParams:e}){var r;return t.length>0?(r=n.getPreviousPageParam)==null?void 0:r.call(n,t[0],t,e[0],e):void 0}var E$=(G_=class extends L0{constructor(t){super();Ie(this,Zr);Ie(this,qu);Ie(this,Xr);Ie(this,wn);Ie(this,ri);ge(this,qu,t.client),this.mutationId=t.mutationId,ge(this,wn,t.mutationCache),ge(this,Xr,[]),this.state=t.state||H0(),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,Xr).includes(t)||(W(this,Xr).push(t),this.clearGcTimeout(),W(this,wn).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){ge(this,Xr,W(this,Xr).filter(e=>e!==t)),this.scheduleGc(),W(this,wn).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){W(this,Xr).length||(this.state.status==="pending"?this.scheduleGc():W(this,wn).remove(this))}continue(){var t;return((t=W(this,ri))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var i,s,u,c,l,d,f,h,m,p,v,g,y,w,x,C,_,E,S,N;const e=()=>{He(this,Zr,ga).call(this,{type:"continue"})},r={client:W(this,qu),meta:this.options.meta,mutationKey:this.options.mutationKey};ge(this,ri,R0({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:($,A)=>{He(this,Zr,ga).call(this,{type:"failed",failureCount:$,error:A})},onPause:()=>{He(this,Zr,ga).call(this,{type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>W(this,wn).canRun(this)}));const o=this.state.status==="pending",a=!W(this,ri).canStart();try{if(o)e();else{He(this,Zr,ga).call(this,{type:"pending",variables:t,isPaused:a}),await((s=(i=W(this,wn).config).onMutate)==null?void 0:s.call(i,t,this,r));const A=await((c=(u=this.options).onMutate)==null?void 0:c.call(u,t,r));A!==this.state.context&&He(this,Zr,ga).call(this,{type:"pending",context:A,variables:t,isPaused:a})}const $=await W(this,ri).start();return await((d=(l=W(this,wn).config).onSuccess)==null?void 0:d.call(l,$,t,this.state.context,this,r)),await((h=(f=this.options).onSuccess)==null?void 0:h.call(f,$,t,this.state.context,r)),await((p=(m=W(this,wn).config).onSettled)==null?void 0:p.call(m,$,null,this.state.variables,this.state.context,this,r)),await((g=(v=this.options).onSettled)==null?void 0:g.call(v,$,null,t,this.state.context,r)),He(this,Zr,ga).call(this,{type:"success",data:$}),$}catch($){try{throw await((w=(y=W(this,wn).config).onError)==null?void 0:w.call(y,$,t,this.state.context,this,r)),await((C=(x=this.options).onError)==null?void 0:C.call(x,$,t,this.state.context,r)),await((E=(_=W(this,wn).config).onSettled)==null?void 0:E.call(_,void 0,$,this.state.variables,this.state.context,this,r)),await((N=(S=this.options).onSettled)==null?void 0:N.call(S,void 0,$,t,this.state.context,r)),$}finally{He(this,Zr,ga).call(this,{type:"error",error:$})}}finally{W(this,wn).runNext(this)}}},qu=new WeakMap,Xr=new WeakMap,wn=new WeakMap,ri=new WeakMap,Zr=new WeakSet,ga=function(t){const e=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=e(this.state),Bt.batch(()=>{W(this,Xr).forEach(r=>{r.onMutationUpdate(t)}),W(this,wn).notify({mutation:this,type:"updated",action:t})})},G_);function H0(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var S$=(q_=class extends pi{constructor(t={}){super();Ie(this,Co);Ie(this,br);Ie(this,Ku);this.config=t,ge(this,Co,new Set),ge(this,br,new Map),ge(this,Ku,0)}build(t,e,r){const o=new E$({client:t,mutationCache:this,mutationId:++wd(this,Ku)._,options:t.defaultMutationOptions(e),state:r});return this.add(o),o}add(t){W(this,Co).add(t);const e=Sc(t);if(typeof e=="string"){const r=W(this,br).get(e);r?r.push(t):W(this,br).set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(W(this,Co).delete(t)){const e=Sc(t);if(typeof e=="string"){const r=W(this,br).get(e);if(r)if(r.length>1){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}else r[0]===t&&W(this,br).delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=Sc(t);if(typeof e=="string"){const r=W(this,br).get(e),o=r==null?void 0:r.find(a=>a.state.status==="pending");return!o||o===t}else return!0}runNext(t){var r;const e=Sc(t);if(typeof e=="string"){const o=(r=W(this,br).get(e))==null?void 0:r.find(a=>a!==t&&a.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Bt.batch(()=>{W(this,Co).forEach(t=>{this.notify({type:"removed",mutation:t})}),W(this,Co).clear(),W(this,br).clear()})}getAll(){return Array.from(W(this,Co))}find(t){const e={exact:!0,...t};return this.getAll().find(r=>A0(e,r))}findAll(t={}){return this.getAll().filter(e=>A0(t,e))}notify(t){Bt.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return Bt.batch(()=>Promise.all(t.map(e=>e.continue().catch(fn))))}},Co=new WeakMap,br=new WeakMap,Ku=new WeakMap,q_);function Sc(n){var t;return(t=n.options.scope)==null?void 0:t.id}var N$=(K_=class extends pi{constructor(e,r){super();Ie(this,So);Ie(this,_o);Ie(this,ca);Ie(this,Tn);Ie(this,Eo);ge(this,_o,e),this.setOptions(r),this.bindMethods(),He(this,So,Cd).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var o;const r=this.options;this.options=W(this,_o).defaultMutationOptions(e),Cc(this.options,r)||W(this,_o).getMutationCache().notify({type:"observerOptionsUpdated",mutation:W(this,Tn),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&_a(r.mutationKey)!==_a(this.options.mutationKey)?this.reset():((o=W(this,Tn))==null?void 0:o.state.status)==="pending"&&W(this,Tn).setOptions(this.options)}onUnsubscribe(){var e;this.hasListeners()||(e=W(this,Tn))==null||e.removeObserver(this)}onMutationUpdate(e){He(this,So,Cd).call(this),He(this,So,Rm).call(this,e)}getCurrentResult(){return W(this,ca)}reset(){var e;(e=W(this,Tn))==null||e.removeObserver(this),ge(this,Tn,void 0),He(this,So,Cd).call(this),He(this,So,Rm).call(this)}mutate(e,r){var o;return ge(this,Eo,r),(o=W(this,Tn))==null||o.removeObserver(this),ge(this,Tn,W(this,_o).getMutationCache().build(W(this,_o),this.options)),W(this,Tn).addObserver(this),W(this,Tn).execute(e)}},_o=new WeakMap,ca=new WeakMap,Tn=new WeakMap,Eo=new WeakMap,So=new WeakSet,Cd=function(){var r;const e=((r=W(this,Tn))==null?void 0:r.state)??H0();ge(this,ca,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})},Rm=function(e){Bt.batch(()=>{var r,o,a,i,s,u,c,l;if(W(this,Eo)&&this.hasListeners()){const d=W(this,ca).variables,f=W(this,ca).context,h={client:W(this,_o),meta:this.options.meta,mutationKey:this.options.mutationKey};(e==null?void 0:e.type)==="success"?((o=(r=W(this,Eo)).onSuccess)==null||o.call(r,e.data,d,f,h),(i=(a=W(this,Eo)).onSettled)==null||i.call(a,e.data,null,d,f,h)):(e==null?void 0:e.type)==="error"&&((u=(s=W(this,Eo)).onError)==null||u.call(s,e.error,d,f,h),(l=(c=W(this,Eo)).onSettled)==null||l.call(c,void 0,e.error,d,f,h))}this.listeners.forEach(d=>{d(W(this,ca))})})},K_),$$=(Y_=class extends pi{constructor(t={}){super();Ie(this,Qr);this.config=t,ge(this,Qr,new Map)}build(t,e,r){const o=e.queryKey,a=e.queryHash??of(o,e);let i=this.get(a);return i||(i=new b$({client:t,queryKey:o,queryHash:a,options:t.defaultQueryOptions(e),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(i)),i}add(t){W(this,Qr).has(t.queryHash)||(W(this,Qr).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=W(this,Qr).get(t.queryHash);e&&(t.destroy(),e===t&&W(this,Qr).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Bt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return W(this,Qr).get(t)}getAll(){return[...W(this,Qr).values()]}find(t){const e={exact:!0,...t};return this.getAll().find(r=>I0(e,r))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(r=>I0(t,r)):e}notify(t){Bt.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){Bt.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Bt.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Qr=new WeakMap,Y_),k$=(X_=class{constructor(n={}){Ie(this,Pt);Ie(this,la);Ie(this,da);Ie(this,bs);Ie(this,xs);Ie(this,fa);Ie(this,ws);Ie(this,Cs);ge(this,Pt,n.queryCache||new $$),ge(this,la,n.mutationCache||new S$),ge(this,da,n.defaultOptions||{}),ge(this,bs,new Map),ge(this,xs,new Map),ge(this,fa,0)}mount(){wd(this,fa)._++,W(this,fa)===1&&(ge(this,ws,cf.subscribe(async n=>{n&&(await this.resumePausedMutations(),W(this,Pt).onFocus())})),ge(this,Cs,Ec.subscribe(async n=>{n&&(await this.resumePausedMutations(),W(this,Pt).onOnline())})))}unmount(){var n,t;wd(this,fa)._--,W(this,fa)===0&&((n=W(this,ws))==null||n.call(this),ge(this,ws,void 0),(t=W(this,Cs))==null||t.call(this),ge(this,Cs,void 0))}isFetching(n){return W(this,Pt).findAll({...n,fetchStatus:"fetching"}).length}isMutating(n){return W(this,la).findAll({...n,status:"pending"}).length}getQueryData(n){var e;const t=this.defaultQueryOptions({queryKey:n});return(e=W(this,Pt).get(t.queryHash))==null?void 0:e.state.data}ensureQueryData(n){const t=this.defaultQueryOptions(n),e=W(this,Pt).build(this,t),r=e.state.data;return r===void 0?this.fetchQuery(n):(n.revalidateIfStale&&e.isStaleByTime(To(t.staleTime,e))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(n){return W(this,Pt).findAll(n).map(({queryKey:t,state:e})=>{const r=e.data;return[t,r]})}setQueryData(n,t,e){const r=this.defaultQueryOptions({queryKey:n}),o=W(this,Pt).get(r.queryHash),a=o==null?void 0:o.state.data,i=c$(t,a);if(i!==void 0)return W(this,Pt).build(this,r).setData(i,{...e,manual:!0})}setQueriesData(n,t,e){return Bt.batch(()=>W(this,Pt).findAll(n).map(({queryKey:r})=>[r,this.setQueryData(r,t,e)]))}getQueryState(n){var e;const t=this.defaultQueryOptions({queryKey:n});return(e=W(this,Pt).get(t.queryHash))==null?void 0:e.state}removeQueries(n){const t=W(this,Pt);Bt.batch(()=>{t.findAll(n).forEach(e=>{t.remove(e)})})}resetQueries(n,t){const e=W(this,Pt);return Bt.batch(()=>(e.findAll(n).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...n},t)))}cancelQueries(n,t={}){const e={revert:!0,...t},r=Bt.batch(()=>W(this,Pt).findAll(n).map(o=>o.cancel(e)));return Promise.all(r).then(fn).catch(fn)}invalidateQueries(n,t={}){return Bt.batch(()=>(W(this,Pt).findAll(n).forEach(e=>{e.invalidate()}),(n==null?void 0:n.refetchType)==="none"?Promise.resolve():this.refetchQueries({...n,type:(n==null?void 0:n.refetchType)??(n==null?void 0:n.type)??"active"},t)))}refetchQueries(n,t={}){const e={...t,cancelRefetch:t.cancelRefetch??!0},r=Bt.batch(()=>W(this,Pt).findAll(n).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let a=o.fetch(void 0,e);return e.throwOnError||(a=a.catch(fn)),o.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(fn)}fetchQuery(n){const t=this.defaultQueryOptions(n);t.retry===void 0&&(t.retry=!1);const e=W(this,Pt).build(this,t);return e.isStaleByTime(To(t.staleTime,e))?e.fetch(t):Promise.resolve(e.state.data)}prefetchQuery(n){return this.fetchQuery(n).then(fn).catch(fn)}fetchInfiniteQuery(n){return n.behavior=U0(n.pages),this.fetchQuery(n)}prefetchInfiniteQuery(n){return this.fetchInfiniteQuery(n).then(fn).catch(fn)}ensureInfiniteQueryData(n){return n.behavior=U0(n.pages),this.ensureQueryData(n)}resumePausedMutations(){return Ec.isOnline()?W(this,la).resumePausedMutations():Promise.resolve()}getQueryCache(){return W(this,Pt)}getMutationCache(){return W(this,la)}getDefaultOptions(){return W(this,da)}setDefaultOptions(n){ge(this,da,n)}setQueryDefaults(n,t){W(this,bs).set(_a(n),{queryKey:n,defaultOptions:t})}getQueryDefaults(n){const t=[...W(this,bs).values()],e={};return t.forEach(r=>{Ds(n,r.queryKey)&&Object.assign(e,r.defaultOptions)}),e}setMutationDefaults(n,t){W(this,xs).set(_a(n),{mutationKey:n,defaultOptions:t})}getMutationDefaults(n){const t=[...W(this,xs).values()],e={};return t.forEach(r=>{Ds(n,r.mutationKey)&&Object.assign(e,r.defaultOptions)}),e}defaultQueryOptions(n){if(n._defaulted)return n;const t={...W(this,da).queries,...this.getQueryDefaults(n.queryKey),...n,_defaulted:!0};return t.queryHash||(t.queryHash=of(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===_c&&(t.enabled=!1),t}defaultMutationOptions(n){return n!=null&&n._defaulted?n:{...W(this,da).mutations,...(n==null?void 0:n.mutationKey)&&this.getMutationDefaults(n.mutationKey),...n,_defaulted:!0}}clear(){W(this,Pt).clear(),W(this,la).clear()}},Pt=new WeakMap,la=new WeakMap,da=new WeakMap,bs=new WeakMap,xs=new WeakMap,fa=new WeakMap,ws=new WeakMap,Cs=new WeakMap,X_),G0=k.createContext(void 0),q0=n=>{const t=k.useContext(G0);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},P$=({client:n,children:t})=>(k.useEffect(()=>(n.mount(),()=>{n.unmount()}),[n]),b.jsx(G0.Provider,{value:n,children:t})),K0=k.createContext(!1),I$=()=>k.useContext(K0);K0.Provider;function A$(){let n=!1;return{clearReset:()=>{n=!1},reset:()=>{n=!0},isReset:()=>n}}var T$=k.createContext(A$()),O$=()=>k.useContext(T$),D$=(n,t)=>{(n.suspense||n.throwOnError||n.experimental_prefetchInRender)&&(t.isReset()||(n.retryOnMount=!1))},M$=n=>{k.useEffect(()=>{n.clearReset()},[n])},F$=({result:n,errorResetBoundary:t,throwOnError:e,query:r,suspense:o})=>n.isError&&!t.isReset()&&!n.isFetching&&r&&(o&&n.data===void 0||M0(e,[n.error,r])),R$=n=>{if(n.suspense){const e=o=>o==="static"?o:Math.max(o??1e3,1e3),r=n.staleTime;n.staleTime=typeof r=="function"?(...o)=>e(r(...o)):e(r),typeof n.gcTime=="number"&&(n.gcTime=Math.max(n.gcTime,1e3))}},L$=(n,t)=>n.isLoading&&n.isFetching&&!t,B$=(n,t)=>(n==null?void 0:n.suspense)&&t.isPending,Y0=(n,t,e)=>t.fetchOptimistic(n).catch(()=>{e.clearReset()});function W$(n,t,e){var d,f,h,m,p;if(process.env.NODE_ENV!=="production"&&(typeof n!="object"||Array.isArray(n)))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=I$(),o=O$(),a=q0(),i=a.defaultQueryOptions(n);(f=(d=a.getDefaultOptions().queries)==null?void 0:d._experimental_beforeQuery)==null||f.call(d,i),process.env.NODE_ENV!=="production"&&(i.queryFn||console.error(`[${i.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`)),i._optimisticResults=r?"isRestoring":"optimistic",R$(i),D$(i,o),M$(o);const s=!a.getQueryCache().get(i.queryHash),[u]=k.useState(()=>new t(a,i)),c=u.getOptimisticResult(i),l=!r&&n.subscribed!==!1;if(k.useSyncExternalStore(k.useCallback(v=>{const g=l?u.subscribe(Bt.batchCalls(v)):fn;return u.updateResult(),g},[u,l]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),k.useEffect(()=>{u.setOptions(i)},[i,u]),B$(i,c))throw Y0(i,u,o);if(F$({result:c,errorResetBoundary:o,throwOnError:i.throwOnError,query:a.getQueryCache().get(i.queryHash),suspense:i.suspense}))throw c.error;if((m=(h=a.getDefaultOptions().queries)==null?void 0:h._experimental_afterQuery)==null||m.call(h,i,c),i.experimental_prefetchInRender&&!Ca&&L$(c,r)){const v=s?Y0(i,u,o):(p=a.getQueryCache().get(i.queryHash))==null?void 0:p.promise;v==null||v.catch(fn).finally(()=>{u.updateResult()})}return i.notifyOnChangeProps?c:u.trackResult(c)}function V$(n,t){return W$(n,x$)}function X0(n,t){const e=q0(),[r]=k.useState(()=>new N$(e,n));k.useEffect(()=>{r.setOptions(n)},[r,n]);const o=k.useSyncExternalStore(k.useCallback(i=>r.subscribe(Bt.batchCalls(i)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=k.useCallback((i,s)=>{r.mutate(i,s).catch(fn)},[r]);if(o.error&&M0(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:a,mutateAsync:o.mutate}}const Nc=Dd("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),_t=k.forwardRef(({className:n,variant:t,size:e,asChild:r=!1,...o},a)=>{const i=r?Vm:"button";return b.jsx(i,{className:Be(Nc({variant:t,size:e,className:n})),ref:a,...o})});_t.displayName="Button";const hn=k.forwardRef(({className:n,...t},e)=>b.jsx("div",{ref:e,className:Be("rounded-lg border bg-card text-card-foreground shadow-sm",n),...t}));hn.displayName="Card";const Oo=k.forwardRef(({className:n,...t},e)=>b.jsx("div",{ref:e,className:Be("flex flex-col space-y-1.5 p-6",n),...t}));Oo.displayName="CardHeader";const pf=k.forwardRef(({className:n,...t},e)=>b.jsx("h3",{ref:e,className:Be("text-2xl font-semibold leading-none tracking-tight",n),...t}));pf.displayName="CardTitle";const j$=k.forwardRef(({className:n,...t},e)=>b.jsx("p",{ref:e,className:Be("text-sm text-muted-foreground",n),...t}));j$.displayName="CardDescription";const pn=k.forwardRef(({className:n,...t},e)=>b.jsx("div",{ref:e,className:Be("p-6 pt-0",n),...t}));pn.displayName="CardContent";const U$=k.forwardRef(({className:n,...t},e)=>b.jsx("div",{ref:e,className:Be("flex items-center p-6 pt-0",n),...t}));U$.displayName="CardFooter";const Z0=({title:n="Verify your identity",subtitle:t="We need some information to help us confirm your identity.",onContinue:e})=>b.jsx(hn,{className:"w-full max-w-md mx-auto",children:b.jsxs(pn,{className:"pt-8 text-center",children:[b.jsx("div",{className:"bg-gradient-to-br from-primary/10 to-primary/5 rounded-3xl p-8 mb-8",children:b.jsx("div",{className:"relative mb-8",children:b.jsxs("div",{className:"relative mx-auto w-48 h-32",children:[b.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-primary to-primary/80 rounded-2xl transform rotate-3 shadow-lg",children:b.jsx("div",{className:"flex items-center justify-center h-full",children:b.jsx("div",{className:"w-12 h-12 bg-white/20 rounded-full flex items-center justify-center",children:b.jsx("svg",{viewBox:"0 0 24 24",className:"w-6 h-6 text-white",fill:"currentColor",children:b.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"})})})})}),b.jsx("div",{className:"absolute top-4 right-0 bg-card rounded-xl shadow-lg p-4 transform -rotate-3",children:b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx("div",{className:"w-8 h-8 bg-primary/20 rounded-full"}),b.jsxs("div",{className:"space-y-1",children:[b.jsx("div",{className:"w-12 h-2 bg-primary rounded"}),b.jsx("div",{className:"w-8 h-2 bg-primary/60 rounded"})]})]})}),b.jsx("div",{className:"absolute -top-2 -right-2 w-10 h-10 bg-primary rounded-full flex items-center justify-center shadow-lg",children:b.jsx(Sg,{className:"w-6 h-6 text-white"})})]})})}),b.jsx("h1",{className:"text-3xl font-bold text-foreground mb-4",children:n}),b.jsx("p",{className:"text-lg text-muted-foreground mb-12",children:t}),b.jsx(_t,{className:"w-full h-14 text-lg font-semibold",onClick:e,children:"Start"}),b.jsx("p",{className:"text-sm text-muted-foreground mt-6",children:"Verifying usually takes a few seconds."})]})}),vn=k.forwardRef(({className:n,type:t,...e},r)=>b.jsx("input",{type:t,className:Be("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:r,...e}));vn.displayName="Input";var z$="Label",Q0=k.forwardRef((n,t)=>b.jsx(et.label,{...n,ref:t,onMouseDown:e=>{var o;e.target.closest("button, input, select, textarea")||((o=n.onMouseDown)==null||o.call(n,e),!e.defaultPrevented&&e.detail>1&&e.preventDefault())}}));Q0.displayName=z$;var J0=Q0;const H$=Dd("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ea=k.forwardRef(({className:n,...t},e)=>b.jsx(J0,{ref:e,className:Be(H$(),n),...t}));Ea.displayName=J0.displayName;const G$=({fullName:n,onNameChange:t,onContinue:e,renderProgress:r})=>b.jsxs(hn,{className:"w-full max-w-md mx-auto",children:[b.jsxs(Oo,{className:"text-center",children:[b.jsx(aE,{className:"w-12 h-12 mx-auto mb-4 text-primary"}),b.jsx(pf,{children:"Personal Information"}),b.jsx("p",{className:"text-muted-foreground",children:"Please enter your full legal name"})]}),b.jsxs(pn,{children:[b.jsxs("div",{className:"space-y-4",children:[b.jsxs("div",{children:[b.jsx(Ea,{htmlFor:"fullName",children:"Full Name"}),b.jsx(vn,{id:"fullName",placeholder:"Enter your full name",value:n,onChange:o=>t(o.target.value)})]}),b.jsx(_t,{className:"w-full",onClick:e,disabled:!n.trim(),children:"Continue"})]}),b.jsx("div",{className:"mt-6",children:r()})]})]}),Do=({title:n,subTitle:t,onBack:e})=>b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"flex items-center mb-6",children:[b.jsx(_t,{variant:"ghost",size:"icon",className:"mr-2",onClick:e,children:b.jsx(Cg,{className:"w-6 h-6"})}),b.jsx("h1",{className:"text-2xl font-semibold ml-4",children:n})]}),b.jsx("p",{className:"text-center text-muted-foreground mb-6",children:t})]}),vi=[{id:"id",title:"ID Card",description:"Government-issued personal ID.",icon:rE},{id:"license",title:"Drivers license",description:"Government-issued Drivers license",icon:J4},{id:"passport",title:"Passport",description:"Your official travel document.",icon:Q4},{id:"voterId",title:"Voter ID",description:"Government-issued Voter ID",icon:iE}],ey=({selectedDocumentType:n,onDocumentTypeChange:t,onContinue:e,onBack:r,renderProgress:o})=>b.jsx(hn,{className:"w-full max-w-md mx-auto",children:b.jsxs(pn,{className:"p-6",children:[b.jsx(Do,{title:"Upload ID",subTitle:"Choose the document type you would like to identify with",onBack:r}),b.jsx("div",{className:"space-y-3",children:vi.map(a=>{const i=a.icon;return b.jsx("button",{className:`w-full p-4 rounded-lg border text-left transition-colors hover:bg-muted/50 ${n===a.id?"border-primary bg-primary/5":"border-border"}`,onClick:()=>t(a.id),children:b.jsxs("div",{className:"flex items-center space-x-4",children:[b.jsx("div",{className:"w-12 h-12 bg-primary rounded-full flex items-center justify-center",children:b.jsx(i,{className:"w-6 h-6 text-white"})}),b.jsxs("div",{className:"flex-1",children:[b.jsx("h3",{className:"font-semibold text-foreground",children:a.title}),b.jsx("p",{className:"text-sm text-muted-foreground",children:a.description})]})]})},a.id)})}),b.jsx(_t,{className:"w-full mt-6",onClick:e,disabled:!n,children:"Continue"}),b.jsx("div",{className:"mt-6",children:o()})]})}),ty=({onContinue:n,onBack:t})=>b.jsx(hn,{className:"w-full max-w-md mx-auto",children:b.jsxs(pn,{className:"p-6",children:[b.jsx(Do,{title:"Selfie",subTitle:"Make sure your face is clear and is fully inside the frame.",onBack:t}),b.jsx("div",{className:"m-auto w-44 h-80 bg-gradient-to-br from-primary/20 to-primary/40 rounded-3xl p-4 shadow-2xl",children:b.jsx("div",{className:"w-full h-full bg-background rounded-2xl overflow-hidden relative",children:b.jsx("div",{className:"flex items-center justify-center h-full bg-muted/30",children:b.jsxs("div",{className:"text-center",children:[b.jsx("div",{className:"w-16 h-16 bg-primary rounded-full flex items-center justify-center mx-auto mb-2"}),b.jsx("div",{className:"w-28 h-32 bg-primary/30 rounded-2xl mx-auto"})]})})})}),b.jsx("div",{className:"mt-8",children:b.jsx(_t,{onClick:n,className:"w-full h-12 text-lg font-semibold",children:"Take a selfie"})})]})}),q$=({fullName:n,onComplete:t,onStartOver:e})=>b.jsxs(hn,{className:"w-full max-w-md mx-auto",children:[b.jsxs(Oo,{className:"text-center",children:[b.jsx(Sg,{className:"w-12 h-12 mx-auto mb-4 text-green-500"}),b.jsx(pf,{children:"Review Information"}),b.jsx("p",{className:"text-muted-foreground",children:"Please review your information before submitting"})]}),b.jsx(pn,{children:b.jsxs("div",{className:"space-y-4",children:[b.jsxs("div",{children:[b.jsx(Ea,{children:"Full Name"}),b.jsx("p",{className:"font-medium",children:n})]}),b.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[b.jsxs("div",{children:[b.jsx(Ea,{className:"text-xs",children:"Selfie"}),b.jsx("div",{className:"text-green-500",children:"✓"})]}),b.jsxs("div",{children:[b.jsx(Ea,{className:"text-xs",children:"ID Front"}),b.jsx("div",{className:"text-green-500",children:"✓"})]}),b.jsxs("div",{children:[b.jsx(Ea,{className:"text-xs",children:"ID Back"}),b.jsx("div",{className:"text-green-500",children:"✓"})]})]}),b.jsx(_t,{className:"w-full text-md",onClick:t,children:"Complete Verification"}),b.jsx(_t,{variant:"outline",className:"w-full text-md",onClick:e,children:"Start Over"})]})})]}),ny=({onComplete:n})=>(D.useEffect(()=>{const t=setTimeout(()=>{n()},3e3);return()=>clearTimeout(t)},[n]),b.jsx(hn,{className:"w-full max-w-md mx-auto min-h-[500px] flex items-center justify-center",children:b.jsxs(pn,{className:"text-center space-y-8",children:[b.jsx("div",{children:b.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-2",children:"We're verifying your documents"})}),b.jsx("div",{className:"flex justify-center",children:b.jsx("div",{className:"w-16 h-16 border-4 border-primary border-t-transparent rounded-full animate-spin"})})]})})),ry=({onDoneClick:n})=>b.jsx(hn,{className:"w-full max-w-md mx-auto min-h-[500px] flex items-center justify-center",children:b.jsx(pn,{className:"text-center space-y-8",children:b.jsxs("div",{children:[b.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-2",children:"Your documents have been submitted successfully"}),b.jsx("div",{className:"flex justify-center",children:b.jsx(ac,{size:60,className:"text-primary"})}),b.jsx("p",{className:"text-foreground mt-2",children:"Our compliance team will review your information, and we'll notify you once verification is complete."}),b.jsx("p",{className:"text-foreground mt-2",children:"Thank you for your patience."}),b.jsx(_t,{className:"text-md mt-8",onClick:n,children:"Explore App"})]})})});function vf(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var K$={exports:{}};(function(n){var t=function(e){var r=Object.prototype,o=r.hasOwnProperty,a=Object.defineProperty||function(O,I,L){O[I]=L.value},i,s=typeof Symbol=="function"?Symbol:{},u=s.iterator||"@@iterator",c=s.asyncIterator||"@@asyncIterator",l=s.toStringTag||"@@toStringTag";function d(O,I,L){return Object.defineProperty(O,I,{value:L,enumerable:!0,configurable:!0,writable:!0}),O[I]}try{d({},"")}catch{d=function(I,L,K){return I[L]=K}}function f(O,I,L,K){var q=I&&I.prototype instanceof w?I:w,Z=Object.create(q.prototype),oe=new H(K||[]);return a(Z,"_invoke",{value:P(O,L,oe)}),Z}e.wrap=f;function h(O,I,L){try{return{type:"normal",arg:O.call(I,L)}}catch(K){return{type:"throw",arg:K}}}var m="suspendedStart",p="suspendedYield",v="executing",g="completed",y={};function w(){}function x(){}function C(){}var _={};d(_,u,function(){return this});var E=Object.getPrototypeOf,S=E&&E(E(F([])));S&&S!==r&&o.call(S,u)&&(_=S);var N=C.prototype=w.prototype=Object.create(_);x.prototype=C,a(N,"constructor",{value:C,configurable:!0}),a(C,"constructor",{value:x,configurable:!0}),x.displayName=d(C,l,"GeneratorFunction");function $(O){["next","throw","return"].forEach(function(I){d(O,I,function(L){return this._invoke(I,L)})})}e.isGeneratorFunction=function(O){var I=typeof O=="function"&&O.constructor;return I?I===x||(I.displayName||I.name)==="GeneratorFunction":!1},e.mark=function(O){return Object.setPrototypeOf?Object.setPrototypeOf(O,C):(O.__proto__=C,d(O,l,"GeneratorFunction")),O.prototype=Object.create(N),O},e.awrap=function(O){return{__await:O}};function A(O,I){function L(Z,oe,ae,X){var re=h(O[Z],O,oe);if(re.type==="throw")X(re.arg);else{var ce=re.arg,ue=ce.value;return ue&&typeof ue=="object"&&o.call(ue,"__await")?I.resolve(ue.__await).then(function(se){L("next",se,ae,X)},function(se){L("throw",se,ae,X)}):I.resolve(ue).then(function(se){ce.value=se,ae(ce)},function(se){return L("throw",se,ae,X)})}}var K;function q(Z,oe){function ae(){return new I(function(X,re){L(Z,oe,X,re)})}return K=K?K.then(ae,ae):ae()}a(this,"_invoke",{value:q})}$(A.prototype),d(A.prototype,c,function(){return this}),e.AsyncIterator=A,e.async=function(O,I,L,K,q){q===void 0&&(q=Promise);var Z=new A(f(O,I,L,K),q);return e.isGeneratorFunction(I)?Z:Z.next().then(function(oe){return oe.done?oe.value:Z.next()})};function P(O,I,L){var K=m;return function(Z,oe){if(K===v)throw new Error("Generator is already running");if(K===g){if(Z==="throw")throw oe;return M()}for(L.method=Z,L.arg=oe;;){var ae=L.delegate;if(ae){var X=j(ae,L);if(X){if(X===y)continue;return X}}if(L.method==="next")L.sent=L._sent=L.arg;else if(L.method==="throw"){if(K===m)throw K=g,L.arg;L.dispatchException(L.arg)}else L.method==="return"&&L.abrupt("return",L.arg);K=v;var re=h(O,I,L);if(re.type==="normal"){if(K=L.done?g:p,re.arg===y)continue;return{value:re.arg,done:L.done}}else re.type==="throw"&&(K=g,L.method="throw",L.arg=re.arg)}}}function j(O,I){var L=I.method,K=O.iterator[L];if(K===i)return I.delegate=null,L==="throw"&&O.iterator.return&&(I.method="return",I.arg=i,j(O,I),I.method==="throw")||L!=="return"&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+L+"' method")),y;var q=h(K,O.iterator,I.arg);if(q.type==="throw")return I.method="throw",I.arg=q.arg,I.delegate=null,y;var Z=q.arg;if(!Z)return I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,y;if(Z.done)I[O.resultName]=Z.value,I.next=O.nextLoc,I.method!=="return"&&(I.method="next",I.arg=i);else return Z;return I.delegate=null,y}$(N),d(N,l,"Generator"),d(N,u,function(){return this}),d(N,"toString",function(){return"[object Generator]"});function B(O){var I={tryLoc:O[0]};1 in O&&(I.catchLoc=O[1]),2 in O&&(I.finallyLoc=O[2],I.afterLoc=O[3]),this.tryEntries.push(I)}function z(O){var I=O.completion||{};I.type="normal",delete I.arg,O.completion=I}function H(O){this.tryEntries=[{tryLoc:"root"}],O.forEach(B,this),this.reset(!0)}e.keys=function(O){var I=Object(O),L=[];for(var K in I)L.push(K);return L.reverse(),function q(){for(;L.length;){var Z=L.pop();if(Z in I)return q.value=Z,q.done=!1,q}return q.done=!0,q}};function F(O){if(O){var I=O[u];if(I)return I.call(O);if(typeof O.next=="function")return O;if(!isNaN(O.length)){var L=-1,K=function q(){for(;++L<O.length;)if(o.call(O,L))return q.value=O[L],q.done=!1,q;return q.value=i,q.done=!0,q};return K.next=K}}return{next:M}}e.values=F;function M(){return{value:i,done:!0}}return H.prototype={constructor:H,reset:function(O){if(this.prev=0,this.next=0,this.sent=this._sent=i,this.done=!1,this.delegate=null,this.method="next",this.arg=i,this.tryEntries.forEach(z),!O)for(var I in this)I.charAt(0)==="t"&&o.call(this,I)&&!isNaN(+I.slice(1))&&(this[I]=i)},stop:function(){this.done=!0;var O=this.tryEntries[0],I=O.completion;if(I.type==="throw")throw I.arg;return this.rval},dispatchException:function(O){if(this.done)throw O;var I=this;function L(X,re){return Z.type="throw",Z.arg=O,I.next=X,re&&(I.method="next",I.arg=i),!!re}for(var K=this.tryEntries.length-1;K>=0;--K){var q=this.tryEntries[K],Z=q.completion;if(q.tryLoc==="root")return L("end");if(q.tryLoc<=this.prev){var oe=o.call(q,"catchLoc"),ae=o.call(q,"finallyLoc");if(oe&&ae){if(this.prev<q.catchLoc)return L(q.catchLoc,!0);if(this.prev<q.finallyLoc)return L(q.finallyLoc)}else if(oe){if(this.prev<q.catchLoc)return L(q.catchLoc,!0)}else if(ae){if(this.prev<q.finallyLoc)return L(q.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(O,I){for(var L=this.tryEntries.length-1;L>=0;--L){var K=this.tryEntries[L];if(K.tryLoc<=this.prev&&o.call(K,"finallyLoc")&&this.prev<K.finallyLoc){var q=K;break}}q&&(O==="break"||O==="continue")&&q.tryLoc<=I&&I<=q.finallyLoc&&(q=null);var Z=q?q.completion:{};return Z.type=O,Z.arg=I,q?(this.method="next",this.next=q.finallyLoc,y):this.complete(Z)},complete:function(O,I){if(O.type==="throw")throw O.arg;return O.type==="break"||O.type==="continue"?this.next=O.arg:O.type==="return"?(this.rval=this.arg=O.arg,this.method="return",this.next="end"):O.type==="normal"&&I&&(this.next=I),y},finish:function(O){for(var I=this.tryEntries.length-1;I>=0;--I){var L=this.tryEntries[I];if(L.finallyLoc===O)return this.complete(L.completion,L.afterLoc),z(L),y}},catch:function(O){for(var I=this.tryEntries.length-1;I>=0;--I){var L=this.tryEntries[I];if(L.tryLoc===O){var K=L.completion;if(K.type==="throw"){var q=K.arg;z(L)}return q}}throw new Error("illegal catch attempt")},delegateYield:function(O,I,L){return this.delegate={iterator:F(O),resultName:I,nextLoc:L},this.method==="next"&&(this.arg=i),y}},e}(n.exports);try{regeneratorRuntime=t}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}})(K$);var mf=(n,t)=>`${n}-${t}-${Math.random().toString(16).slice(3,8)}`;const Y$=mf;let oy=0;var ay=({id:n,action:t,payload:e={}})=>{let r=n;return typeof r>"u"&&(r=Y$("Job",oy),oy+=1),{id:r,action:t,payload:e}},mi={};let gf=!1;mi.logging=gf,mi.setLogging=n=>{gf=n},mi.log=(...n)=>gf?console.log.apply(void 0,n):null;const X$=ay,{log:$c}=mi,Z$=mf;let iy=0;var Q$=()=>{const n=Z$("Scheduler",iy),t={},e={};let r=[];iy+=1;const o=()=>r.length,a=()=>Object.keys(t).length,i=()=>{if(r.length!==0){const d=Object.keys(t);for(let f=0;f<d.length;f+=1)if(typeof e[d[f]]>"u"){r[0](t[d[f]]);break}}},s=(d,f)=>new Promise((h,m)=>{const p=X$({action:d,payload:f});r.push(async v=>{r.shift(),e[v.id]=p;try{h(await v[d].apply(void 0,[...f,p.id]))}catch(g){m(g)}finally{delete e[v.id],i()}}),$c(`[${n}]: Add ${p.id} to JobQueue`),$c(`[${n}]: JobQueue length=${r.length}`),i()});return{addWorker:d=>(t[d.id]=d,$c(`[${n}]: Add ${d.id}`),$c(`[${n}]: Number of workers=${a()}`),i(),d.id),addJob:async(d,...f)=>{if(a()===0)throw Error(`[${n}]: You need to have at least one worker before adding jobs`);return s(d,f)},terminate:async()=>{Object.keys(t).forEach(async d=>{await t[d].terminate()}),r=[]},getQueueLen:o,getNumWorkers:a}};function J$(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ek=n=>{const t={};return typeof WorkerGlobalScope<"u"?t.type="webworker":typeof document=="object"?t.type="browser":typeof process=="object"&&typeof J$=="function"&&(t.type="node"),typeof n>"u"?t:t[n]};const tk=ek("type")==="browser"?n=>new URL(n,window.location.href).href:n=>n;var nk=n=>{const t={...n};return["corePath","workerPath","langPath"].forEach(e=>{n[e]&&(t[e]=tk(t[e]))}),t},sy={TESSERACT_ONLY:0,LSTM_ONLY:1,TESSERACT_LSTM_COMBINED:2,DEFAULT:3};const rk={version:"6.0.1"};var ok={workerBlobURL:!0,logger:()=>{}};const ak=rk.version;var ik={...ok,workerPath:`https://cdn.jsdelivr.net/npm/tesseract.js@v${ak}/dist/worker.min.js`},sk=({workerPath:n,workerBlobURL:t})=>{let e;if(Blob&&URL&&t){const r=new Blob([`importScripts("${n}");`],{type:"application/javascript"});e=new Worker(URL.createObjectURL(r))}else e=new Worker(n);return e},uk=n=>{n.terminate()},ck=(n,t)=>{n.onmessage=({data:e})=>{t(e)}},lk=async(n,t)=>{n.postMessage(t)};const yf=n=>new Promise((t,e)=>{const r=new FileReader;r.onload=()=>{t(r.result)},r.onerror=({target:{error:{code:o}}})=>{e(Error(`File could not be read! Code=${o}`))},r.readAsArrayBuffer(n)}),bf=async n=>{let t=n;if(typeof n>"u")return"undefined";if(typeof n=="string")/data:image\/([a-zA-Z]*);base64,([^"]*)/.test(n)?t=atob(n.split(",")[1]).split("").map(e=>e.charCodeAt(0)):t=await(await fetch(n)).arrayBuffer();else if(typeof HTMLElement<"u"&&n instanceof HTMLElement)n.tagName==="IMG"&&(t=await bf(n.src)),n.tagName==="VIDEO"&&(t=await bf(n.poster)),n.tagName==="CANVAS"&&await new Promise(e=>{n.toBlob(async r=>{t=await yf(r),e()})});else if(typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas){const e=await n.convertToBlob();t=await yf(e)}else(n instanceof File||n instanceof Blob)&&(t=await yf(n));return new Uint8Array(t)};var dk=bf,fk={defaultOptions:ik,spawnWorker:sk,terminateWorker:uk,onMessage:ck,send:lk,loadImage:dk};const hk=nk,Pr=ay,{log:uy}=mi,pk=mf,Sa=sy,{defaultOptions:vk,spawnWorker:mk,terminateWorker:gk,onMessage:yk,loadImage:cy,send:bk}=fk;let ly=0;var dy=async(n="eng",t=Sa.LSTM_ONLY,e={},r={})=>{const o=pk("Worker",ly),{logger:a,errorHandler:i,...s}=hk({...vk,...e}),u={},c=typeof n=="string"?n.split("+"):n;let l=t,d=r;const f=[Sa.DEFAULT,Sa.LSTM_ONLY].includes(t)&&!s.legacyCore;let h,m;const p=new Promise((F,M)=>{m=F,h=M}),v=F=>{h(F.message)};let g=mk(s);g.onerror=v,ly+=1;const y=({id:F,action:M,payload:O})=>new Promise((I,L)=>{uy(`[${o}]: Start ${F}, action=${M}`);const K=`${M}-${F}`;u[K]={resolve:I,reject:L},bk(g,{workerId:o,jobId:F,action:M,payload:O})}),w=()=>console.warn("`load` is depreciated and should be removed from code (workers now come pre-loaded)"),x=F=>y(Pr({id:F,action:"load",payload:{options:{lstmOnly:f,corePath:s.corePath,logging:s.logging}}})),C=(F,M,O)=>y(Pr({id:O,action:"FS",payload:{method:"writeFile",args:[F,M]}})),_=(F,M)=>y(Pr({id:M,action:"FS",payload:{method:"readFile",args:[F,{encoding:"utf8"}]}})),E=(F,M)=>y(Pr({id:M,action:"FS",payload:{method:"unlink",args:[F]}})),S=(F,M,O)=>y(Pr({id:O,action:"FS",payload:{method:F,args:M}})),N=(F,M)=>y(Pr({id:M,action:"loadLanguage",payload:{langs:F,options:{langPath:s.langPath,dataPath:s.dataPath,cachePath:s.cachePath,cacheMethod:s.cacheMethod,gzip:s.gzip,lstmOnly:[Sa.DEFAULT,Sa.LSTM_ONLY].includes(l)&&!s.legacyLang}}})),$=(F,M,O,I)=>y(Pr({id:I,action:"initialize",payload:{langs:F,oem:M,config:O}})),A=(F="eng",M,O,I)=>{if(f&&[Sa.TESSERACT_ONLY,Sa.TESSERACT_LSTM_COMBINED].includes(M))throw Error("Legacy model requested but code missing.");const L=M||l;l=L;const K=O||d;d=K;const Z=(typeof F=="string"?F.split("+"):F).filter(oe=>!c.includes(oe));return c.push(...Z),Z.length>0?N(Z,I).then(()=>$(F,L,K,I)):$(F,L,K,I)},P=(F={},M)=>y(Pr({id:M,action:"setParameters",payload:{params:F}})),j=async(F,M={},O={text:!0},I)=>y(Pr({id:I,action:"recognize",payload:{image:await cy(F),options:M,output:O}})),B=async(F,M)=>{if(f)throw Error("`worker.detect` requires Legacy model, which was not loaded.");return y(Pr({id:M,action:"detect",payload:{image:await cy(F)}}))},z=async()=>(g!==null&&(gk(g),g=null),Promise.resolve());yk(g,({workerId:F,jobId:M,status:O,action:I,data:L})=>{const K=`${I}-${M}`;if(O==="resolve")uy(`[${F}]: Complete ${M}`),u[K].resolve({jobId:M,data:L}),delete u[K];else if(O==="reject")if(u[K].reject(L),delete u[K],I==="load"&&h(L),i)i(L);else throw Error(L);else O==="progress"&&a({...L,userJobId:M})});const H={id:o,worker:g,load:w,writeText:C,readText:_,removeFile:E,FS:S,reinitialize:A,setParameters:P,recognize:j,detect:B,terminate:z};return x().then(()=>N(n)).then(()=>$(n,t,r)).then(()=>m(H)).catch(()=>{}),p};const fy=dy;var xk={recognize:async(n,t,e)=>{const r=await fy(t,1,e);return r.recognize(n).finally(async()=>{await r.terminate()})},detect:async(n,t)=>{const e=await fy("osd",0,t);return e.detect(n).finally(async()=>{await e.terminate()})}},wk={AFR:"afr",AMH:"amh",ARA:"ara",ASM:"asm",AZE:"aze",AZE_CYRL:"aze_cyrl",BEL:"bel",BEN:"ben",BOD:"bod",BOS:"bos",BUL:"bul",CAT:"cat",CEB:"ceb",CES:"ces",CHI_SIM:"chi_sim",CHI_TRA:"chi_tra",CHR:"chr",CYM:"cym",DAN:"dan",DEU:"deu",DZO:"dzo",ELL:"ell",ENG:"eng",ENM:"enm",EPO:"epo",EST:"est",EUS:"eus",FAS:"fas",FIN:"fin",FRA:"fra",FRK:"frk",FRM:"frm",GLE:"gle",GLG:"glg",GRC:"grc",GUJ:"guj",HAT:"hat",HEB:"heb",HIN:"hin",HRV:"hrv",HUN:"hun",IKU:"iku",IND:"ind",ISL:"isl",ITA:"ita",ITA_OLD:"ita_old",JAV:"jav",JPN:"jpn",KAN:"kan",KAT:"kat",KAT_OLD:"kat_old",KAZ:"kaz",KHM:"khm",KIR:"kir",KOR:"kor",KUR:"kur",LAO:"lao",LAT:"lat",LAV:"lav",LIT:"lit",MAL:"mal",MAR:"mar",MKD:"mkd",MLT:"mlt",MSA:"msa",MYA:"mya",NEP:"nep",NLD:"nld",NOR:"nor",ORI:"ori",PAN:"pan",POL:"pol",POR:"por",PUS:"pus",RON:"ron",RUS:"rus",SAN:"san",SIN:"sin",SLK:"slk",SLV:"slv",SPA:"spa",SPA_OLD:"spa_old",SQI:"sqi",SRP:"srp",SRP_LATN:"srp_latn",SWA:"swa",SWE:"swe",SYR:"syr",TAM:"tam",TEL:"tel",TGK:"tgk",TGL:"tgl",THA:"tha",TIR:"tir",TUR:"tur",UIG:"uig",UKR:"ukr",URD:"urd",UZB:"uzb",UZB_CYRL:"uzb_cyrl",VIE:"vie",YID:"yid"},Ck={OSD_ONLY:"0",AUTO_OSD:"1",AUTO_ONLY:"2",AUTO:"3",SINGLE_COLUMN:"4",SINGLE_BLOCK_VERT_TEXT:"5",SINGLE_BLOCK:"6",SINGLE_LINE:"7",SINGLE_WORD:"8",CIRCLE_WORD:"9",SINGLE_CHAR:"10",SPARSE_TEXT:"11",SPARSE_TEXT_OSD:"12",RAW_LINE:"13"};const _k=Q$,Ek=dy,Sk=xk,Nk=wk,$k=sy,kk=Ck,{setLogging:Pk}=mi;var Ik={languages:Nk,OEM:$k,PSM:kk,createScheduler:_k,createWorker:Ek,setLogging:Pk,...Sk};const Ak=vf(Ik);/**
|
|
103
103
|
* @license
|
|
104
104
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
105
105
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -3926,7 +3926,7 @@ Manifest JSON has weights with names: `+u.join(", ")+".");return l=a.reduce(func
|
|
|
3926
3926
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
3927
3927
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
3928
3928
|
PERFORMANCE OF THIS SOFTWARE.
|
|
3929
|
-
***************************************************************************** */var Wh=function(n,t){return Wh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var o in r)r.hasOwnProperty(o)&&(e[o]=r[o])},Wh(n,t)};function De(n,t){Wh(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var dn=function(){return dn=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},dn.apply(this,arguments)};function $e(n,t,e,r){function o(a){return a instanceof e?a:new e(function(i){i(a)})}return new(e||(e=Promise))(function(a,i){function s(l){try{c(r.next(l))}catch(d){i(d)}}function u(l){try{c(r.throw(l))}catch(d){i(d)}}function c(l){l.done?a(l.value):o(l.value).then(s,u)}c((r=r.apply(n,[])).next())})}function ke(n,t){var e={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,o,a,i;return i={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(c){return function(l){return u([c,l])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;e;)try{if(r=1,o&&(a=c[0]&2?o.return:c[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,c[1])).done)return a;switch(o=0,a&&(c=[c[0]&2,a.value]),c[0]){case 0:case 1:a=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,o=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(a=e.trys,!(a=a.length>0&&a[a.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){e.label=c[1];break}if(c[0]===6&&e.label<a[1]){e.label=a[1],a=c;break}if(a&&e.label<a[2]){e.label=a[2],e.ops.push(c);break}a[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(l){c=[6,l],o=0}finally{r=a=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function eu(){for(var n=0,t=0,e=arguments.length;t<e;t++)n+=arguments[t].length;for(var r=Array(n),o=0,t=0;t<e;t++)for(var a=arguments[t],i=0,s=a.length;i<s;i++,o++)r[o]=a[i];return r}var Fi=function(){function n(t,e){if(!La(t)||!La(e))throw new Error("Dimensions.constructor - expected width and height to be valid numbers, instead have "+JSON.stringify({width:t,height:e}));this._width=t,this._height=e}return Object.defineProperty(n.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),n.prototype.reverse=function(){return new n(1/this.width,1/this.height)},n}();function fl(n,t){return n instanceof bt&&n.shape.length===t}function l5(n){return fl(n,2)}function hl(n){return fl(n,3)}function jo(n){return fl(n,4)}function d5(n){return n%1!==0}function Bb(n){return n%2===0}function f5(n,t){t===void 0&&(t=2);var e=Math.pow(10,t);return Math.floor(n*e)/e}function Wb(n){return n&&n.width&&n.height}function h5(n,t){var e=n.width,r=n.height,o=t/Math.max(r,e);return new Fi(Math.round(e*o),Math.round(r*o))}function Vh(n){return n.reduce(function(t,e){return t.add(e)},new ot(0,0)).div(new ot(n.length,n.length))}function tu(n,t,e){return Array(n).fill(0).map(function(r,o){return t+o*e})}function La(n){return!!n&&n!==1/0&&n!==-1/0&&!isNaN(n)||n===0}function Vb(n){return La(n)&&0<=n&&n<=1}var ot=function(){function n(t,e){this._x=t,this._y=e}return Object.defineProperty(n.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),n.prototype.add=function(t){return new n(this.x+t.x,this.y+t.y)},n.prototype.sub=function(t){return new n(this.x-t.x,this.y-t.y)},n.prototype.mul=function(t){return new n(this.x*t.x,this.y*t.y)},n.prototype.div=function(t){return new n(this.x/t.x,this.y/t.y)},n.prototype.abs=function(){return new n(Math.abs(this.x),Math.abs(this.y))},n.prototype.magnitude=function(){return Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2))},n.prototype.floor=function(){return new n(Math.floor(this.x),Math.floor(this.y))},n}(),Uo=function(){function n(t,e){e===void 0&&(e=!0);var r=t||{},o=[r.left,r.top,r.right,r.bottom].every(La),a=[r.x,r.y,r.width,r.height].every(La);if(!a&&!o)throw new Error("Box.constructor - expected box to be IBoundingBox | IRect, instead have "+JSON.stringify(r));var i=a?[r.x,r.y,r.width,r.height]:[r.left,r.top,r.right-r.left,r.bottom-r.top],s=i[0],u=i[1],c=i[2],l=i[3];n.assertIsValidBox({x:s,y:u,width:c,height:l},"Box.constructor",e),this._x=s,this._y=u,this._width=c,this._height=l}return n.isRect=function(t){return!!t&&[t.x,t.y,t.width,t.height].every(La)},n.assertIsValidBox=function(t,e,r){if(r===void 0&&(r=!1),!n.isRect(t))throw new Error(e+" - invalid box: "+JSON.stringify(t)+", expected object with properties x, y, width, height");if(!r&&(t.width<0||t.height<0))throw new Error(e+" - width ("+t.width+") and height ("+t.height+") must be positive numbers")},Object.defineProperty(n.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"left",{get:function(){return this.x},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"top",{get:function(){return this.y},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"right",{get:function(){return this.x+this.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"area",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"topLeft",{get:function(){return new ot(this.left,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"topRight",{get:function(){return new ot(this.right,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bottomLeft",{get:function(){return new ot(this.left,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bottomRight",{get:function(){return new ot(this.right,this.bottom)},enumerable:!0,configurable:!0}),n.prototype.round=function(){var t=[this.x,this.y,this.width,this.height].map(function(i){return Math.round(i)}),e=t[0],r=t[1],o=t[2],a=t[3];return new n({x:e,y:r,width:o,height:a})},n.prototype.floor=function(){var t=[this.x,this.y,this.width,this.height].map(function(i){return Math.floor(i)}),e=t[0],r=t[1],o=t[2],a=t[3];return new n({x:e,y:r,width:o,height:a})},n.prototype.toSquare=function(){var t=this,e=t.x,r=t.y,o=t.width,a=t.height,i=Math.abs(o-a);return o<a&&(e-=i/2,o+=i),a<o&&(r-=i/2,a+=i),new n({x:e,y:r,width:o,height:a})},n.prototype.rescale=function(t){var e=Wb(t)?t.width:t,r=Wb(t)?t.height:t;return new n({x:this.x*e,y:this.y*r,width:this.width*e,height:this.height*r})},n.prototype.pad=function(t,e){var r=[this.x-t/2,this.y-e/2,this.width+t,this.height+e],o=r[0],a=r[1],i=r[2],s=r[3];return new n({x:o,y:a,width:i,height:s})},n.prototype.clipAtImageBorders=function(t,e){var r=this,o=r.x,a=r.y,i=r.right,s=r.bottom,u=Math.max(o,0),c=Math.max(a,0),l=i-u,d=s-c,f=Math.min(l,t-u),h=Math.min(d,e-c);return new n({x:u,y:c,width:f,height:h}).floor()},n.prototype.shift=function(t,e){var r=this,o=r.width,a=r.height,i=this.x+t,s=this.y+e;return new n({x:i,y:s,width:o,height:a})},n.prototype.padAtBorders=function(t,e){var r=this.width+1,o=this.height+1,a=1,i=1,s=r,u=o,c=this.left,l=this.top,d=this.right,f=this.bottom;return d>e&&(s=-d+e+r,d=e),f>t&&(u=-f+t+o,f=t),c<1&&(u=2-c,c=1),l<1&&(u=2-l,l=1),{dy:i,edy:u,dx:a,edx:s,y:l,ey:f,x:c,ex:d,w:r,h:o}},n.prototype.calibrate=function(t){return new n({left:this.left+t.left*this.width,top:this.top+t.top*this.height,right:this.right+t.right*this.width,bottom:this.bottom+t.bottom*this.height}).toSquare().round()},n}(),pl=function(n){De(t,n);function t(e,r,o,a,i){return i===void 0&&(i=!1),n.call(this,{left:e,top:r,right:o,bottom:a},i)||this}return t}(Uo),jb=function(){function n(t,e,r,o,a){this._imageDims=new Fi(a.width,a.height),this._score=t,this._classScore=e,this._className=r,this._box=new Uo(o).rescale(this._imageDims)}return Object.defineProperty(n.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"className",{get:function(){return this._className},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"box",{get:function(){return this._box},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageDims",{get:function(){return this._imageDims},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageWidth",{get:function(){return this.imageDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageHeight",{get:function(){return this.imageDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"relativeBox",{get:function(){return new Uo(this._box).rescale(this.imageDims.reverse())},enumerable:!0,configurable:!0}),n.prototype.forSize=function(t,e){return new n(this.score,this.classScore,this.className,this.relativeBox,{width:t,height:e})},n}(),Wr=function(n){De(t,n);function t(e,r,o){return n.call(this,e,e,"",r,o)||this}return t.prototype.forSize=function(e,r){var o=n.prototype.forSize.call(this,e,r),a=o.score,i=o.relativeBox,s=o.imageDims;return new t(a,i,s)},t}(jb);function p5(n,t,e){e===void 0&&(e=!0);var r=Math.max(0,Math.min(n.right,t.right)-Math.max(n.left,t.left)),o=Math.max(0,Math.min(n.bottom,t.bottom)-Math.max(n.top,t.top)),a=r*o;return e?a/(n.area+t.area-a):a/Math.min(n.area,t.area)}function v5(n){var t=n.map(function(s){return s.x}),e=n.map(function(s){return s.y}),r=t.reduce(function(s,u){return u<s?u:s},1/0),o=e.reduce(function(s,u){return u<s?u:s},1/0),a=t.reduce(function(s,u){return s<u?u:s},0),i=e.reduce(function(s,u){return s<u?u:s},0);return new pl(r,o,a,i)}function nu(n,t,e,r){r===void 0&&(r=!0);for(var o=t.map(function(s,u){return{score:s,boxIndex:u}}).sort(function(s,u){return s.score-u.score}).map(function(s){return s.boxIndex}),a=[],i=function(){var s=o.pop();a.push(s);for(var u=o,c=[],l=0;l<u.length;l++){var d=u[l],f=n[s],h=n[d];c.push(p5(f,h,r))}o=o.filter(function(m,p){return c[p]<=e})};o.length>0;)i();return a}function ru(n,t){return xe(function(){var e=t[0],r=t[1],o=t[2],a=Lr(eu(n.shape.slice(0,3),[1]),e),i=Lr(eu(n.shape.slice(0,3),[1]),r),s=Lr(eu(n.shape.slice(0,3),[1]),o),u=Vt([a,i,s],3);return zt(n,u)})}function m5(n,t){return t===void 0&&(t=!1),xe(function(){var e=n.shape.slice(1),r=e[0],o=e[1];if(r===o)return n;var a=Math.abs(r-o),i=Math.round(a*(t?.5:1)),s=r>o?2:1,u=function(h){var m=n.shape.slice();return m[s]=h,Lr(m,0)},c=u(i),l=a-c.shape[s],d=t&&l?u(l):null,f=[d,n,c].filter(function(h){return!!h}).map(function(h){return h.toFloat()});return Vt(f,s)})}function jh(n){return 1/(1+Math.exp(-n))}var Uh=function(n){De(t,n);function t(e,r,o,a,i){return i===void 0&&(i=!1),n.call(this,{x:e,y:r,width:o,height:a},i)||this}return t}(Uo),g5=.5,y5=.43,b5=.45,vl=function(){function n(t,e,r){r===void 0&&(r=new ot(0,0));var o=e.width,a=e.height;this._imgDims=new Fi(o,a),this._shift=r,this._positions=t.map(function(i){return i.mul(new ot(o,a)).add(r)})}return Object.defineProperty(n.prototype,"shift",{get:function(){return new ot(this._shift.x,this._shift.y)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageWidth",{get:function(){return this._imgDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageHeight",{get:function(){return this._imgDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"positions",{get:function(){return this._positions},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"relativePositions",{get:function(){var t=this;return this._positions.map(function(e){return e.sub(t._shift).div(new ot(t.imageWidth,t.imageHeight))})},enumerable:!0,configurable:!0}),n.prototype.forSize=function(t,e){return new this.constructor(this.relativePositions,{width:t,height:e})},n.prototype.shiftBy=function(t,e){return new this.constructor(this.relativePositions,this._imgDims,new ot(t,e))},n.prototype.shiftByPoint=function(t){return this.shiftBy(t.x,t.y)},n.prototype.align=function(t,e){if(e===void 0&&(e={}),t){var r=t instanceof Wr?t.box.floor():new Uo(t);return this.shiftBy(r.x,r.y).align(null,e)}var o=Object.assign({},{useDlibAlignment:!1,minBoxPadding:.2},e),a=o.useDlibAlignment,i=o.minBoxPadding;return a?this.alignDlib():this.alignMinBbox(i)},n.prototype.alignDlib=function(){var t=this.getRefPointsForAlignment(),e=t[0],r=t[1],o=t[2],a=function(d){return o.sub(d).magnitude()},i=(a(e)+a(r))/2,s=Math.floor(i/b5),u=Vh(t),c=Math.floor(Math.max(0,u.x-g5*s)),l=Math.floor(Math.max(0,u.y-y5*s));return new Uh(c,l,Math.min(s,this.imageWidth+c),Math.min(s,this.imageHeight+l))},n.prototype.alignMinBbox=function(t){var e=v5(this.positions);return e.pad(e.width*t,e.height*t)},n.prototype.getRefPointsForAlignment=function(){throw new Error("getRefPointsForAlignment not implemented by base class")},n}(),x5=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getRefPointsForAlignment=function(){var e=this.positions;return[e[0],e[1],Vh([e[3],e[4]])]},t}(vl),w5=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getJawOutline=function(){return this.positions.slice(0,17)},t.prototype.getLeftEyeBrow=function(){return this.positions.slice(17,22)},t.prototype.getRightEyeBrow=function(){return this.positions.slice(22,27)},t.prototype.getNose=function(){return this.positions.slice(27,36)},t.prototype.getLeftEye=function(){return this.positions.slice(36,42)},t.prototype.getRightEye=function(){return this.positions.slice(42,48)},t.prototype.getMouth=function(){return this.positions.slice(48,68)},t.prototype.getRefPointsForAlignment=function(){return[this.getLeftEye(),this.getRightEye(),this.getMouth()].map(Vh)},t}(vl),Ub=function(){function n(t,e){this._label=t,this._distance=e}return Object.defineProperty(n.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"distance",{get:function(){return this._distance},enumerable:!0,configurable:!0}),n.prototype.toString=function(t){return t===void 0&&(t=!0),""+this.label+(t?" ("+f5(this.distance)+")":"")},n}(),zb=function(n){De(t,n);function t(e,r){var o=n.call(this,e)||this;return o._label=r,o}return t.assertIsValidLabeledBox=function(e,r){if(Uo.assertIsValidBox(e,r),!La(e.label))throw new Error(r+" - expected property label ("+e.label+") to be a number")},Object.defineProperty(t.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),t}(Uo),ml=function(){function n(t,e){if(typeof t!="string")throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(e)||e.some(function(r){return!(r instanceof Float32Array)}))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=t,this._descriptors=e}return Object.defineProperty(n.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"descriptors",{get:function(){return this._descriptors},enumerable:!0,configurable:!0}),n.prototype.toJSON=function(){return{label:this.label,descriptors:this.descriptors.map(function(t){return Array.from(t)})}},n.fromJSON=function(t){var e=t.descriptors.map(function(r){return new Float32Array(r)});return new n(t.label,e)},n}();(function(n){De(t,n);function t(e,r,o,a){var i=n.call(this,e,r)||this;return i._score=o,i._classScore=a,i}return t.assertIsValidPredictedBox=function(e,r){if(zb.assertIsValidLabeledBox(e,r),!Vb(e.score)||!Vb(e.classScore))throw new Error(r+" - expected properties score ("+e.score+") and ("+e.classScore+") to be a number between [0, 1]")},Object.defineProperty(t.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),t})(zb);function C5(n){return n.detection instanceof Wr}function zh(n,t){var e={detection:t};return Object.assign({},n,e)}function Hb(){var n=window.fetch||function(){throw new Error("fetch - missing fetch implementation for browser environment")},t=function(){throw new Error("readFile - filesystem not available for browser environment")};return{Canvas:HTMLCanvasElement,CanvasRenderingContext2D,Image:HTMLImageElement,ImageData,Video:HTMLVideoElement,createCanvasElement:function(){return document.createElement("canvas")},createImageElement:function(){return document.createElement("img")},fetch:n,readFile:t}}function Gb(n){var t="";if(!n)try{n=require("fs")}catch(r){t=r.toString()}var e=n?function(r){return new Promise(function(o,a){n.readFile(r,function(i,s){return i?a(i):o(s)})})}:function(){throw new Error("readFile - failed to require fs in nodejs environment with error: "+t)};return{readFile:e}}function qb(){var n=global.Canvas||global.HTMLCanvasElement,t=global.Image||global.HTMLImageElement,e=function(){if(n)return new n;throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment")},r=function(){if(t)return new t;throw new Error("createImageElement - missing Image implementation for nodejs environment")},o=global.fetch||function(){throw new Error("fetch - missing fetch implementation for nodejs environment")},a=Gb();return dn({Canvas:n||function(){function i(){}return i}(),CanvasRenderingContext2D:global.CanvasRenderingContext2D||function(){function i(){}return i}(),Image:t||function(){function i(){}return i}(),ImageData:global.ImageData||function(){function i(){}return i}(),Video:global.HTMLVideoElement||function(){function i(){}return i}(),createCanvasElement:e,createImageElement:r,fetch:o},a)}function Kb(){return typeof window=="object"&&typeof document<"u"&&typeof HTMLImageElement<"u"&&typeof HTMLCanvasElement<"u"&&typeof HTMLVideoElement<"u"&&typeof ImageData<"u"&&typeof CanvasRenderingContext2D<"u"}function Yb(){return typeof global=="object"&&typeof require=="function"&&typeof module<"u"&&typeof process<"u"&&!!process.version}var Ht;function _5(){if(!Ht)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return Ht}function Hh(n){Ht=n}function Gh(){Kb()&&Hh(Hb()),Yb()&&Hh(qb())}function E5(n){if(Ht||Gh(),!Ht)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");var t=n.Canvas,e=t===void 0?Ht.Canvas:t,r=n.Image,o=r===void 0?Ht.Image:r;Ht.Canvas=e,Ht.Image=o,Ht.createCanvasElement=n.createCanvasElement||function(){return new e},Ht.createImageElement=n.createImageElement||function(){return new o},Ht.ImageData=n.ImageData||Ht.ImageData,Ht.Video=n.Video||Ht.Video,Ht.fetch=n.fetch||Ht.fetch,Ht.readFile=n.readFile||Ht.readFile}var rn={getEnv:_5,setEnv:Hh,initialize:Gh,createBrowserEnv:Hb,createFileSystem:Gb,createNodejsEnv:qb,monkeyPatch:E5,isBrowser:Kb,isNodejs:Yb};Gh();function Xb(n){return!rn.isNodejs()&&typeof n=="string"?document.getElementById(n):n}function Ba(n){var t=rn.getEnv(),e=t.Canvas,r=t.CanvasRenderingContext2D;if(n instanceof r)return n;var o=Xb(n);if(!(o instanceof e))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");var a=o.getContext("2d");if(!a)throw new Error("resolveContext2d - canvas 2d context is null");return a}var Zb;(function(n){n.TOP_LEFT="TOP_LEFT",n.TOP_RIGHT="TOP_RIGHT",n.BOTTOM_LEFT="BOTTOM_LEFT",n.BOTTOM_RIGHT="BOTTOM_RIGHT"})(Zb||(Zb={}));function Qb(n){var t=rn.getEnv(),e=t.Image,r=t.Video;return n instanceof e&&n.complete||n instanceof r&&n.readyState>=3}function S5(n){return new Promise(function(t,e){if(n instanceof rn.getEnv().Canvas||Qb(n))return t();function r(a){a.currentTarget&&(a.currentTarget.removeEventListener("load",r),a.currentTarget.removeEventListener("error",o),t(a))}function o(a){a.currentTarget&&(a.currentTarget.removeEventListener("load",r),a.currentTarget.removeEventListener("error",o),e(a))}n.addEventListener("load",r),n.addEventListener("error",o)})}function Jb(n){var t=rn.getEnv(),e=t.Image,r=t.Video;return n instanceof e?new Fi(n.naturalWidth,n.naturalHeight):n instanceof r?new Fi(n.videoWidth,n.videoHeight):new Fi(n.width,n.height)}function gl(n){var t=n.width,e=n.height,r=rn.getEnv().createCanvasElement,o=r();return o.width=t,o.height=e,o}function qh(n,t){var e=rn.getEnv().ImageData;if(!(n instanceof e)&&!Qb(n))throw new Error("createCanvasFromMedia - media has not finished loading yet");var r=Jb(n),o=r.width,a=r.height,i=gl({width:o,height:a});return n instanceof e?Ba(i).putImageData(n,0,0):Ba(i).drawImage(n,0,0,o,a),i}function N5(n,t){return $e(this,void 0,void 0,function(){var e,r,o,a,i,s;return ke(this,function(u){switch(u.label){case 0:return e=rn.getEnv().createCanvasElement(),r=n.shape.slice(jo(n)?1:0),o=r[0],a=r[1],i=r[2],s=xe(function(){return n.as3D(o,a,i).toInt()}),[4,Bh.toPixels(s,e)];case 1:return u.sent(),s.dispose(),[2,e]}})})}function e2(n){var t=rn.getEnv(),e=t.Image,r=t.Canvas,o=t.Video;return n instanceof e||n instanceof r||n instanceof o}function $5(n,t,e){e===void 0&&(e=!1);var r=rn.getEnv(),o=r.Image,a=r.Canvas;if(!(n instanceof o||n instanceof a))throw new Error("imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement");var i=Jb(n),s=t/Math.max(i.height,i.width),u=s*i.width,c=s*i.height,l=gl({width:t,height:t}),d=n instanceof a?n:qh(n),f=Math.abs(u-c)/2,h=e&&u<c?f:0,m=e&&c<u?f:0;return Ba(l).drawImage(d,h,m,u,c),l}var yl=function(){function n(t,e){var r=this;if(e===void 0&&(e=!1),this._imageTensors=[],this._canvases=[],this._treatAsBatchInput=!1,this._inputDimensions=[],!Array.isArray(t))throw new Error("NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have "+t);this._treatAsBatchInput=e,this._batchSize=t.length,t.forEach(function(o,a){if(hl(o)){r._imageTensors[a]=o,r._inputDimensions[a]=o.shape;return}if(jo(o)){var i=o.shape[0];if(i!==1)throw new Error("NetInput - tf.Tensor4D with batchSize "+i+" passed, but not supported in input array");r._imageTensors[a]=o,r._inputDimensions[a]=o.shape.slice(1);return}var s=o instanceof rn.getEnv().Canvas?o:qh(o);r._canvases[a]=s,r._inputDimensions[a]=[s.height,s.width,3]})}return Object.defineProperty(n.prototype,"imageTensors",{get:function(){return this._imageTensors},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"canvases",{get:function(){return this._canvases},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isBatchInput",{get:function(){return this.batchSize>1||this._treatAsBatchInput},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"batchSize",{get:function(){return this._batchSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"inputDimensions",{get:function(){return this._inputDimensions},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"reshapedInputDimensions",{get:function(){var t=this;return tu(this.batchSize,0,1).map(function(e,r){return t.getReshapedInputDimensions(r)})},enumerable:!0,configurable:!0}),n.prototype.getInput=function(t){return this.canvases[t]||this.imageTensors[t]},n.prototype.getInputDimensions=function(t){return this._inputDimensions[t]},n.prototype.getInputHeight=function(t){return this._inputDimensions[t][0]},n.prototype.getInputWidth=function(t){return this._inputDimensions[t][1]},n.prototype.getReshapedInputDimensions=function(t){if(typeof this.inputSize!="number")throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");var e=this.getInputWidth(t),r=this.getInputHeight(t);return h5({width:e,height:r},this.inputSize)},n.prototype.toBatchTensor=function(t,e){var r=this;return e===void 0&&(e=!0),this._inputSize=t,xe(function(){var o=tu(r.batchSize,0,1).map(function(i){var s=r.getInput(i);if(s instanceof bt){var u=jo(s)?s:s.expandDims();return u=m5(u,e),(u.shape[1]!==t||u.shape[2]!==t)&&(u=wh.resizeBilinear(u,[t,t])),u.as3D(t,t,3)}if(s instanceof rn.getEnv().Canvas)return Bh.fromPixels($5(s,t,e));throw new Error("toBatchTensor - at batchIdx "+i+", expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have "+s)}),a=Bn(o.map(function(i){return i.toFloat()})).as4D(r.batchSize,t,t,3);return a})},n}();function Yt(n){return $e(this,void 0,void 0,function(){var t,e,r;return ke(this,function(o){switch(o.label){case 0:if(n instanceof yl)return[2,n];if(t=Array.isArray(n)?n:[n],!t.length)throw new Error("toNetInput - empty array passed as input");return e=function(a){return Array.isArray(n)?" at input index "+a+":":""},r=t.map(Xb),r.forEach(function(a,i){if(!e2(a)&&!hl(a)&&!jo(a))throw typeof t[i]=="string"?new Error("toNetInput -"+e(i)+" string passed, but could not resolve HTMLElement for element id "+t[i]):new Error("toNetInput -"+e(i)+" expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id");if(jo(a)){var s=a.shape[0];if(s!==1)throw new Error("toNetInput -"+e(i)+" tf.Tensor4D with batchSize "+s+" passed, but not supported in input array")}}),[4,Promise.all(r.map(function(a){return e2(a)&&S5(a)}))];case 1:return o.sent(),[2,new yl(r,Array.isArray(n))]}})})}function Kh(n,t){return $e(this,void 0,void 0,function(){var e,r,o,a,i,s,u;return ke(this,function(c){switch(c.label){case 0:return e=rn.getEnv().Canvas,r=n,n instanceof e?[3,5]:[4,Yt(n)];case 1:if(o=c.sent(),o.batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");return a=o.getInput(0),a instanceof e?(i=a,[3,4]):[3,2];case 2:return[4,N5(a)];case 3:i=c.sent(),c.label=4;case 4:r=i,c.label=5;case 5:return s=Ba(r),u=t.map(function(l){return l instanceof Wr?l.forSize(r.width,r.height).box.floor():l}).map(function(l){return l.clipAtImageBorders(r.width,r.height)}),[2,u.map(function(l){var d=l.x,f=l.y,h=l.width,m=l.height,p=gl({width:h,height:m});return Ba(p).putImageData(s.getImageData(d,f,h,m),0,0),p})]}})})}function Yh(n,t){return $e(this,void 0,void 0,function(){return ke(this,function(e){if(!hl(n)&&!jo(n))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(jo(n)&&n.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return[2,xe(function(){var r=n.shape.slice(jo(n)?1:0),o=r[0],a=r[1],i=r[2],s=t.map(function(c){return c instanceof Wr?c.forSize(a,o).box:c}).map(function(c){return c.clipAtImageBorders(a,o)}),u=s.map(function(c){var l=c.x,d=c.y,f=c.width,h=c.height;return sb(n.as3D(o,a,i),[d,l,0],[h,f,i])});return u})]})})}function k5(n,t){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return e=rn.getEnv().fetch,[4,e(n,t)];case 1:if(r=o.sent(),!(r.status<400))throw new Error("failed to fetch: ("+r.status+") "+r.statusText+", from url: "+r.url);return[2,r]}})})}function P5(n){return $e(this,void 0,void 0,function(){return ke(this,function(t){switch(t.label){case 0:return[4,k5(n)];case 1:return[2,t.sent().json()]}})})}function t2(n,t){var e=t+"-weights_manifest.json";if(!n)return{modelBaseUri:"",manifestUri:e};if(n==="/")return{modelBaseUri:"/",manifestUri:"/"+e};var r=n.startsWith("http://")?"http://":n.startsWith("https://")?"https://":"";n=n.replace(r,"");var o=n.split("/").filter(function(s){return s}),a=n.endsWith(".json")?o[o.length-1]:e,i=r+(n.endsWith(".json")?o.slice(0,o.length-1):o).join("/");return i=n.startsWith("/")?"/"+i:i,{modelBaseUri:i,manifestUri:i==="/"?"/"+a:i+"/"+a}}function I5(n,t){return $e(this,void 0,void 0,function(){var e,r,o,a;return ke(this,function(i){switch(i.label){case 0:return e=t2(n,t),r=e.manifestUri,o=e.modelBaseUri,[4,P5(r)];case 1:return a=i.sent(),[2,Rb.loadWeights(a,o)]}})})}var uo=function(){function n(t){this._name=t,this._params=void 0,this._paramMappings=[]}return Object.defineProperty(n.prototype,"params",{get:function(){return this._params},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"paramMappings",{get:function(){return this._paramMappings},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isLoaded",{get:function(){return!!this.params},enumerable:!0,configurable:!0}),n.prototype.getParamFromPath=function(t){var e=this.traversePropertyPath(t),r=e.obj,o=e.objProp;return r[o]},n.prototype.reassignParamFromPath=function(t,e){var r=this.traversePropertyPath(t),o=r.obj,a=r.objProp;o[a].dispose(),o[a]=e},n.prototype.getParamList=function(){var t=this;return this._paramMappings.map(function(e){var r=e.paramPath;return{path:r,tensor:t.getParamFromPath(r)}})},n.prototype.getTrainableParams=function(){return this.getParamList().filter(function(t){return t.tensor instanceof xi})},n.prototype.getFrozenParams=function(){return this.getParamList().filter(function(t){return!(t.tensor instanceof xi)})},n.prototype.variable=function(){var t=this;this.getFrozenParams().forEach(function(e){var r=e.path,o=e.tensor;t.reassignParamFromPath(r,o.variable())})},n.prototype.freeze=function(){var t=this;this.getTrainableParams().forEach(function(e){var r=e.path,o=e.tensor,a=nn(o.dataSync());o.dispose(),t.reassignParamFromPath(r,a)})},n.prototype.dispose=function(t){t===void 0&&(t=!0),this.getParamList().forEach(function(e){if(t&&e.tensor.isDisposed)throw new Error("param tensor has already been disposed for path "+e.path);e.tensor.dispose()}),this._params=void 0},n.prototype.serializeParams=function(){return new Float32Array(this.getParamList().map(function(t){var e=t.tensor;return Array.from(e.dataSync())}).reduce(function(t,e){return t.concat(e)}))},n.prototype.load=function(t){return $e(this,void 0,void 0,function(){return ke(this,function(e){switch(e.label){case 0:return t instanceof Float32Array?(this.extractWeights(t),[2]):[4,this.loadFromUri(t)];case 1:return e.sent(),[2]}})})},n.prototype.loadFromUri=function(t){return $e(this,void 0,void 0,function(){var e;return ke(this,function(r){switch(r.label){case 0:if(t&&typeof t!="string")throw new Error(this._name+".loadFromUri - expected model uri");return[4,I5(t,this.getDefaultModelName())];case 1:return e=r.sent(),this.loadFromWeightMap(e),[2]}})})},n.prototype.loadFromDisk=function(t){return $e(this,void 0,void 0,function(){var e,r,o,a,i,s,u,c,l,d;return ke(this,function(f){switch(f.label){case 0:if(t&&typeof t!="string")throw new Error(this._name+".loadFromDisk - expected model file path");return e=rn.getEnv().readFile,r=t2(t,this.getDefaultModelName()),o=r.manifestUri,a=r.modelBaseUri,i=function(h){return Promise.all(h.map(function(m){return e(m).then(function(p){return p.buffer})}))},s=Rb.weightsLoaderFactory(i),l=(c=JSON).parse,[4,e(o)];case 1:return u=l.apply(c,[f.sent().toString()]),[4,s(u,a)];case 2:return d=f.sent(),this.loadFromWeightMap(d),[2]}})})},n.prototype.loadFromWeightMap=function(t){var e=this.extractParamsFromWeigthMap(t),r=e.paramMappings,o=e.params;this._paramMappings=r,this._params=o},n.prototype.extractWeights=function(t){var e=this.extractParams(t),r=e.paramMappings,o=e.params;this._paramMappings=r,this._params=o},n.prototype.traversePropertyPath=function(t){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");var e=t.split("/").reduce(function(a,i){if(!a.nextObj.hasOwnProperty(i))throw new Error("traversePropertyPath - object does not have property "+i+", for path "+t);return{obj:a.nextObj,objProp:i,nextObj:a.nextObj[i]}},{nextObj:this.params}),r=e.obj,o=e.objProp;if(!r||!o||!(r[o]instanceof bt))throw new Error("traversePropertyPath - parameter is not a tensor, for path "+t);return{obj:r,objProp:o}},n}();function Vn(n,t,e){return xe(function(){var r=mh(n,t.depthwise_filter,t.pointwise_filter,e,"same");return r=qe(r,t.bias),r})}function Xh(n,t,e){return e===void 0&&(e=!1),xe(function(){var r=wt(e?qe(Zn(n,t.conv0.filters,[2,2],"same"),t.conv0.bias):Vn(n,t.conv0,[2,2])),o=Vn(r,t.conv1,[1,1]),a=wt(qe(r,o)),i=Vn(a,t.conv2,[1,1]);return wt(qe(r,qe(o,i)))})}function bl(n,t,e,r){return e===void 0&&(e=!1),r===void 0&&(r=!0),xe(function(){var o=wt(e?qe(Zn(n,t.conv0.filters,r?[2,2]:[1,1],"same"),t.conv0.bias):Vn(n,t.conv0,r?[2,2]:[1,1])),a=Vn(o,t.conv1,[1,1]),i=wt(qe(o,a)),s=Vn(i,t.conv2,[1,1]),u=wt(qe(o,qe(a,s))),c=Vn(u,t.conv3,[1,1]);return wt(qe(o,qe(a,qe(s,c))))})}function cr(n,t,e,r){return e===void 0&&(e="same"),r===void 0&&(r=!1),xe(function(){var o=qe(Zn(n,t.filters,[1,1],e),t.bias);return r?wt(o):o})}function co(n,t){Object.keys(n).forEach(function(e){t.some(function(r){return r.originalPath===e})||n[e].dispose()})}function xl(n,t){return function(e,r,o,a){var i=Sn(n(e*r*o*o),[o,o,e,r]),s=Ot(n(r));return t.push({paramPath:a+"/filters"},{paramPath:a+"/bias"}),{filters:i,bias:s}}}function Zh(n,t){return function(e,r,o){var a=Ro(n(e*r),[e,r]),i=Ot(n(r));return t.push({paramPath:o+"/weights"},{paramPath:o+"/bias"}),{weights:a,bias:i}}}var n2=function(){function n(t,e,r){this.depthwise_filter=t,this.pointwise_filter=e,this.bias=r}return n}();function Qh(n,t){return function(e,r,o){var a=Sn(n(9*e),[3,3,e,1]),i=Sn(n(e*r),[1,1,e,r]),s=Ot(n(r));return t.push({paramPath:o+"/depthwise_filter"},{paramPath:o+"/pointwise_filter"},{paramPath:o+"/bias"}),new n2(a,i,s)}}function Jh(n){return function(t){var e=n(t+"/depthwise_filter",4),r=n(t+"/pointwise_filter",4),o=n(t+"/bias",1);return new n2(e,r,o)}}function zo(n,t){return function(e,r,o){var a=n[e];if(!fl(a,r))throw new Error("expected weightMap["+e+"] to be a Tensor"+r+"D, instead have "+a);return t.push({originalPath:e,paramPath:o||e}),a}}function lo(n){var t=n;function e(o){var a=t.slice(0,o);return t=t.slice(o),a}function r(){return t}return{extractWeights:e,getRemainingWeights:r}}function r2(n,t){var e=xl(n,t),r=Qh(n,t);function o(i,s,u,c){c===void 0&&(c=!1);var l=c?e(i,s,3,u+"/conv0"):r(i,s,u+"/conv0"),d=r(s,s,u+"/conv1"),f=r(s,s,u+"/conv2");return{conv0:l,conv1:d,conv2:f}}function a(i,s,u,c){c===void 0&&(c=!1);var l=o(i,s,u,c),d=l.conv0,f=l.conv1,h=l.conv2,m=r(s,s,u+"/conv3");return{conv0:d,conv1:f,conv2:h,conv3:m}}return{extractDenseBlock3Params:o,extractDenseBlock4Params:a}}function A5(n){var t=[],e=lo(n),r=e.extractWeights,o=e.getRemainingWeights,a=r2(r,t).extractDenseBlock4Params,i=a(3,32,"dense0",!0),s=a(32,64,"dense1"),u=a(64,128,"dense2"),c=a(128,256,"dense3");if(o().length!==0)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:t,params:{dense0:i,dense1:s,dense2:u,dense3:c}}}function o2(n){return function(t){var e=n(t+"/filters",4),r=n(t+"/bias",1);return{filters:e,bias:r}}}function a2(n,t){var e=zo(n,t),r=o2(e),o=Jh(e);function a(s,u){u===void 0&&(u=!1);var c=u?r(s+"/conv0"):o(s+"/conv0"),l=o(s+"/conv1"),d=o(s+"/conv2");return{conv0:c,conv1:l,conv2:d}}function i(s,u){u===void 0&&(u=!1);var c=u?r(s+"/conv0"):o(s+"/conv0"),l=o(s+"/conv1"),d=o(s+"/conv2"),f=o(s+"/conv3");return{conv0:c,conv1:l,conv2:d,conv3:f}}return{extractDenseBlock3Params:a,extractDenseBlock4Params:i}}function T5(n){var t=[],e=a2(n,t).extractDenseBlock4Params,r={dense0:e("dense0",!0),dense1:e("dense1"),dense2:e("dense2"),dense3:e("dense3")};return co(n,t),{params:r,paramMappings:t}}var i2=function(n){De(t,n);function t(){return n.call(this,"FaceFeatureExtractor")||this}return t.prototype.forwardInput=function(e){var r=this.params;if(!r)throw new Error("FaceFeatureExtractor - load model before inference");return xe(function(){var o=e.toBatchTensor(112,!0),a=[122.782,117.001,104.298],i=ru(o,a).div(ve(255)),s=bl(i,r.dense0,!0);return s=bl(s,r.dense1),s=bl(s,r.dense2),s=bl(s,r.dense3),s=Qs(s,[7,7],[2,2],"valid"),s})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.getDefaultModelName=function(){return"face_feature_extractor_model"},t.prototype.extractParamsFromWeigthMap=function(e){return T5(e)},t.prototype.extractParams=function(e){return A5(e)},t}(uo);function Vr(n,t){return xe(function(){return qe(il(n,t.weights),t.bias)})}function O5(n,t,e){var r=[],o=lo(n),a=o.extractWeights,i=o.getRemainingWeights,s=Zh(a,r),u=s(t,e,"fc");if(i().length!==0)throw new Error("weights remaing after extract: "+i().length);return{paramMappings:r,params:{fc:u}}}function D5(n){var t=[],e=zo(n,t);function r(a){var i=e(a+"/weights",2),s=e(a+"/bias",1);return{weights:i,bias:s}}var o={fc:r("fc")};return co(n,t),{params:o,paramMappings:t}}function s2(n){var t={},e={};return Object.keys(n).forEach(function(r){var o=r.startsWith("fc")?e:t;o[r]=n[r]}),{featureExtractorMap:t,classifierMap:e}}var u2=function(n){De(t,n);function t(e,r){var o=n.call(this,e)||this;return o._faceFeatureExtractor=r,o}return Object.defineProperty(t.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),t.prototype.runNet=function(e){var r=this,o=this.params;if(!o)throw new Error(this._name+" - load model before inference");return xe(function(){var a=e instanceof yl?r.faceFeatureExtractor.forwardInput(e):e;return Vr(a.as2D(a.shape[0],-1),o.fc)})},t.prototype.dispose=function(e){e===void 0&&(e=!0),this.faceFeatureExtractor.dispose(e),n.prototype.dispose.call(this,e)},t.prototype.loadClassifierParams=function(e){var r=this.extractClassifierParams(e),o=r.params,a=r.paramMappings;this._params=o,this._paramMappings=a},t.prototype.extractClassifierParams=function(e){return O5(e,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())},t.prototype.extractParamsFromWeigthMap=function(e){var r=s2(e),o=r.featureExtractorMap,a=r.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(o),D5(a)},t.prototype.extractParams=function(e){var r=this.getClassifierChannelsIn(),o=this.getClassifierChannelsOut(),a=o*r+o,i=e.slice(0,e.length-a),s=e.slice(e.length-a);return this.faceFeatureExtractor.extractWeights(i),this.extractClassifierParams(s)},t}(uo),c2=["neutral","happy","sad","angry","fearful","disgusted","surprised"],M5=function(){function n(t){var e=this;if(t.length!==7)throw new Error("FaceExpressions.constructor - expected probabilities.length to be 7, have: "+t.length);c2.forEach(function(r,o){e[r]=t[o]})}return n.prototype.asSortedArray=function(){var t=this;return c2.map(function(e){return{expression:e,probability:t[e]}}).sort(function(e,r){return r.probability-e.probability})},n}(),F5=function(n){De(t,n);function t(e){return e===void 0&&(e=new i2),n.call(this,"FaceExpressionNet",e)||this}return t.prototype.forwardInput=function(e){var r=this;return xe(function(){return oo(r.runNet(e))})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.predictExpressions=function(e){return $e(this,void 0,void 0,function(){var r,o,a,i,s=this;return ke(this,function(u){switch(u.label){case 0:return[4,Yt(e)];case 1:return r=u.sent(),[4,this.forwardInput(r)];case 2:return o=u.sent(),[4,Promise.all(jt(o).map(function(c){return $e(s,void 0,void 0,function(){var l;return ke(this,function(d){switch(d.label){case 0:return[4,c.data()];case 1:return l=d.sent(),c.dispose(),[2,l]}})})}))];case 3:return a=u.sent(),o.dispose(),i=a.map(function(c){return new M5(c)}),[2,r.isBatchInput?i:i[0]]}})})},t.prototype.getDefaultModelName=function(){return"face_expression_model"},t.prototype.getClassifierChannelsIn=function(){return 256},t.prototype.getClassifierChannelsOut=function(){return 7},t}(u2);function l2(n,t){var e={expressions:t};return Object.assign({},n,e)}function R5(n){return C5(n)&&n.landmarks instanceof vl&&n.unshiftedLandmarks instanceof vl&&n.alignedRect instanceof Wr}function ep(n,t){var e=n.detection.box,r=t.shiftBy(e.x,e.y),o=r.align(),a=n.detection.imageDims,i=new Wr(n.detection.score,o.rescale(a.reverse()),a),s={landmarks:r,unshiftedLandmarks:t,alignedRect:i};return Object.assign({},n,s)}function L5(n,t){var e=xl(n,t),r=Qh(n,t);function o(i,s,u){var c=r(i,s,u+"/separable_conv0"),l=r(s,s,u+"/separable_conv1"),d=e(i,s,1,u+"/expansion_conv");return{separable_conv0:c,separable_conv1:l,expansion_conv:d}}function a(i,s){var u=r(i,i,s+"/separable_conv0"),c=r(i,i,s+"/separable_conv1"),l=r(i,i,s+"/separable_conv2");return{separable_conv0:u,separable_conv1:c,separable_conv2:l}}return{extractConvParams:e,extractSeparableConvParams:r,extractReductionBlockParams:o,extractMainBlockParams:a}}function B5(n,t){var e=[],r=lo(n),o=r.extractWeights,a=r.getRemainingWeights,i=L5(o,e),s=i.extractConvParams,u=i.extractSeparableConvParams,c=i.extractReductionBlockParams,l=i.extractMainBlockParams,d=s(3,32,3,"entry_flow/conv_in"),f=c(32,64,"entry_flow/reduction_block_0"),h=c(64,128,"entry_flow/reduction_block_1"),m={conv_in:d,reduction_block_0:f,reduction_block_1:h},p={};tu(t,0,1).forEach(function(w){p["main_block_"+w]=l(128,"middle_flow/main_block_"+w)});var v=c(128,256,"exit_flow/reduction_block"),g=u(256,512,"exit_flow/separable_conv"),y={reduction_block:v,separable_conv:g};if(a().length!==0)throw new Error("weights remaing after extract: "+a().length);return{paramMappings:e,params:{entry_flow:m,middle_flow:p,exit_flow:y}}}function W5(n,t){var e=zo(n,t),r=o2(e),o=Jh(e);function a(s){var u=o(s+"/separable_conv0"),c=o(s+"/separable_conv1"),l=r(s+"/expansion_conv");return{separable_conv0:u,separable_conv1:c,expansion_conv:l}}function i(s){var u=o(s+"/separable_conv0"),c=o(s+"/separable_conv1"),l=o(s+"/separable_conv2");return{separable_conv0:u,separable_conv1:c,separable_conv2:l}}return{extractConvParams:r,extractSeparableConvParams:o,extractReductionBlockParams:a,extractMainBlockParams:i}}function V5(n,t){var e=[],r=W5(n,e),o=r.extractConvParams,a=r.extractSeparableConvParams,i=r.extractReductionBlockParams,s=r.extractMainBlockParams,u=o("entry_flow/conv_in"),c=i("entry_flow/reduction_block_0"),l=i("entry_flow/reduction_block_1"),d={conv_in:u,reduction_block_0:c,reduction_block_1:l},f={};tu(t,0,1).forEach(function(v){f["main_block_"+v]=s("middle_flow/main_block_"+v)});var h=i("exit_flow/reduction_block"),m=a("exit_flow/separable_conv"),p={reduction_block:h,separable_conv:m};return co(n,e),{params:{entry_flow:d,middle_flow:f,exit_flow:p},paramMappings:e}}function d2(n,t,e){return qe(Zn(n,t.filters,e,"same"),t.bias)}function tp(n,t,e){e===void 0&&(e=!0);var r=e?wt(n):n;return r=Vn(r,t.separable_conv0,[1,1]),r=Vn(wt(r),t.separable_conv1,[1,1]),r=Kt(r,[3,3],[2,2],"same"),r=qe(r,d2(n,t.expansion_conv,[2,2])),r}function j5(n,t){var e=Vn(wt(n),t.separable_conv0,[1,1]);return e=Vn(wt(e),t.separable_conv1,[1,1]),e=Vn(wt(e),t.separable_conv2,[1,1]),e=qe(e,n),e}var U5=function(n){De(t,n);function t(e){var r=n.call(this,"TinyXception")||this;return r._numMainBlocks=e,r}return t.prototype.forwardInput=function(e){var r=this,o=this.params;if(!o)throw new Error("TinyXception - load model before inference");return xe(function(){var a=e.toBatchTensor(112,!0),i=[122.782,117.001,104.298],s=ru(a,i).div(ve(256)),u=wt(d2(s,o.entry_flow.conv_in,[2,2]));return u=tp(u,o.entry_flow.reduction_block_0,!1),u=tp(u,o.entry_flow.reduction_block_1),tu(r._numMainBlocks,0,1).forEach(function(c){u=j5(u,o.middle_flow["main_block_"+c])}),u=tp(u,o.exit_flow.reduction_block),u=wt(Vn(u,o.exit_flow.separable_conv,[1,1])),u})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.getDefaultModelName=function(){return"tiny_xception_model"},t.prototype.extractParamsFromWeigthMap=function(e){return V5(e,this._numMainBlocks)},t.prototype.extractParams=function(e){return B5(e,this._numMainBlocks)},t}(uo);function z5(n){var t=[],e=lo(n),r=e.extractWeights,o=e.getRemainingWeights,a=Zh(r,t),i=a(512,1,"fc/age"),s=a(512,2,"fc/gender");if(o().length!==0)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:t,params:{fc:{age:i,gender:s}}}}function H5(n){var t=[],e=zo(n,t);function r(a){var i=e(a+"/weights",2),s=e(a+"/bias",1);return{weights:i,bias:s}}var o={fc:{age:r("fc/age"),gender:r("fc/gender")}};return co(n,t),{params:o,paramMappings:t}}var wl;(function(n){n.FEMALE="female",n.MALE="male"})(wl||(wl={}));var G5=function(n){De(t,n);function t(e){e===void 0&&(e=new U5(2));var r=n.call(this,"AgeGenderNet")||this;return r._faceFeatureExtractor=e,r}return Object.defineProperty(t.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),t.prototype.runNet=function(e){var r=this,o=this.params;if(!o)throw new Error(this._name+" - load model before inference");return xe(function(){var a=e instanceof yl?r.faceFeatureExtractor.forwardInput(e):e,i=Qs(a,[7,7],[2,2],"valid").as2D(a.shape[0],-1),s=Vr(i,o.fc.age).as1D(),u=Vr(i,o.fc.gender);return{age:s,gender:u}})},t.prototype.forwardInput=function(e){var r=this;return xe(function(){var o=r.runNet(e),a=o.age,i=o.gender;return{age:a,gender:oo(i)}})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.predictAgeAndGender=function(e){return $e(this,void 0,void 0,function(){var r,o,a,i,s,u,c=this;return ke(this,function(l){switch(l.label){case 0:return[4,Yt(e)];case 1:return r=l.sent(),[4,this.forwardInput(r)];case 2:return o=l.sent(),a=jt(o.age),i=jt(o.gender),s=a.map(function(d,f){return{ageTensor:d,genderTensor:i[f]}}),[4,Promise.all(s.map(function(d){var f=d.ageTensor,h=d.genderTensor;return $e(c,void 0,void 0,function(){var m,p,v,g,y;return ke(this,function(w){switch(w.label){case 0:return[4,f.data()];case 1:return m=w.sent()[0],[4,h.data()];case 2:return p=w.sent()[0],v=p>.5,g=v?wl.MALE:wl.FEMALE,y=v?p:1-p,f.dispose(),h.dispose(),[2,{age:m,gender:g,genderProbability:y}]}})})}))];case 3:return u=l.sent(),o.age.dispose(),o.gender.dispose(),[2,r.isBatchInput?u:u[0]]}})})},t.prototype.getDefaultModelName=function(){return"age_gender_model"},t.prototype.dispose=function(e){e===void 0&&(e=!0),this.faceFeatureExtractor.dispose(e),n.prototype.dispose.call(this,e)},t.prototype.loadClassifierParams=function(e){var r=this.extractClassifierParams(e),o=r.params,a=r.paramMappings;this._params=o,this._paramMappings=a},t.prototype.extractClassifierParams=function(e){return z5(e)},t.prototype.extractParamsFromWeigthMap=function(e){var r=s2(e),o=r.featureExtractorMap,a=r.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(o),H5(a)},t.prototype.extractParams=function(e){var r=1539,o=e.slice(0,e.length-r),a=e.slice(e.length-r);return this.faceFeatureExtractor.extractWeights(o),this.extractClassifierParams(a)},t}(uo),f2=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.postProcess=function(e,r,o){var a=o.map(function(s){var u=s.width,c=s.height,l=r/Math.max(c,u);return{width:u*l,height:c*l}}),i=a.length;return xe(function(){var s=function(f,h){return Bn([Lr([68],f),Lr([68],h)],1).as2D(1,136).as1D()},u=function(f,h){var m=a[f],p=m.width,v=m.height;return h(p,v)?Math.abs(p-v)/2:0},c=function(f){return u(f,function(h,m){return h<m})},l=function(f){return u(f,function(h,m){return m<h})},d=e.mul(Lr([i,136],r)).sub(Bn(Array.from(Array(i),function(f,h){return s(c(h),l(h))}))).div(Bn(Array.from(Array(i),function(f,h){return s(a[h].width,a[h].height)})));return d})},t.prototype.forwardInput=function(e){var r=this;return xe(function(){var o=r.runNet(e);return r.postProcess(o,e.inputSize,e.inputDimensions.map(function(a){var i=a[0],s=a[1];return{height:i,width:s}}))})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.detectLandmarks=function(e){return $e(this,void 0,void 0,function(){var r,o,a,i=this;return ke(this,function(s){switch(s.label){case 0:return[4,Yt(e)];case 1:return r=s.sent(),o=xe(function(){return jt(i.forwardInput(r))}),[4,Promise.all(o.map(function(u,c){return $e(i,void 0,void 0,function(){var l,d,f,h,m;return ke(this,function(p){switch(p.label){case 0:return f=(d=Array).from,[4,u.data()];case 1:return l=f.apply(d,[p.sent()]),h=l.filter(function(v,g){return Bb(g)}),m=l.filter(function(v,g){return!Bb(g)}),[2,new w5(Array(68).fill(0).map(function(v,g){return new ot(h[g],m[g])}),{height:r.getInputHeight(c),width:r.getInputWidth(c)})]}})})}))];case 2:return a=s.sent(),o.forEach(function(u){return u.dispose()}),[2,r.isBatchInput?a:a[0]]}})})},t.prototype.getClassifierChannelsOut=function(){return 136},t}(u2),h2=function(n){De(t,n);function t(e){return e===void 0&&(e=new i2),n.call(this,"FaceLandmark68Net",e)||this}return t.prototype.getDefaultModelName=function(){return"face_landmark_68_model"},t.prototype.getClassifierChannelsIn=function(){return 256},t}(f2);function q5(n){var t=[],e=a2(n,t).extractDenseBlock3Params,r={dense0:e("dense0",!0),dense1:e("dense1"),dense2:e("dense2")};return co(n,t),{params:r,paramMappings:t}}function K5(n){var t=[],e=lo(n),r=e.extractWeights,o=e.getRemainingWeights,a=r2(r,t).extractDenseBlock3Params,i=a(3,32,"dense0",!0),s=a(32,64,"dense1"),u=a(64,128,"dense2");if(o().length!==0)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:t,params:{dense0:i,dense1:s,dense2:u}}}var Y5=function(n){De(t,n);function t(){return n.call(this,"TinyFaceFeatureExtractor")||this}return t.prototype.forwardInput=function(e){var r=this.params;if(!r)throw new Error("TinyFaceFeatureExtractor - load model before inference");return xe(function(){var o=e.toBatchTensor(112,!0),a=[122.782,117.001,104.298],i=ru(o,a).div(ve(255)),s=Xh(i,r.dense0,!0);return s=Xh(s,r.dense1),s=Xh(s,r.dense2),s=Qs(s,[14,14],[2,2],"valid"),s})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.getDefaultModelName=function(){return"face_feature_extractor_tiny_model"},t.prototype.extractParamsFromWeigthMap=function(e){return q5(e)},t.prototype.extractParams=function(e){return K5(e)},t}(uo),X5=function(n){De(t,n);function t(e){return e===void 0&&(e=new Y5),n.call(this,"FaceLandmark68TinyNet",e)||this}return t.prototype.getDefaultModelName=function(){return"face_landmark_68_tiny_model"},t.prototype.getClassifierChannelsIn=function(){return 128},t}(f2);(function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t})(h2);function Z5(n,t){return qe(cn(n,t.weights),t.biases)}function np(n,t,e,r,o){o===void 0&&(o="same");var a=t.conv,i=a.filters,s=a.bias,u=Zn(n,i,e,o);return u=qe(u,s),u=Z5(u,t.scale),r?wt(u):u}function Q5(n,t){return np(n,t,[1,1],!0)}function p2(n,t){return np(n,t,[1,1],!1)}function v2(n,t){return np(n,t,[2,2],!0,"valid")}function J5(n,t){function e(s,u,c){var l=n(s),d=l.length/(u*c*c);if(d5(d))throw new Error("depth has to be an integer: "+d+", weights.length: "+l.length+", numFilters: "+u+", filterSize: "+c);return xe(function(){return Bo(Sn(l,[u,d,c,c]),[2,3,1,0])})}function r(s,u,c,l){var d=e(s,u,c),f=Ot(n(u));return t.push({paramPath:l+"/filters"},{paramPath:l+"/bias"}),{filters:d,bias:f}}function o(s,u){var c=Ot(n(s)),l=Ot(n(s));return t.push({paramPath:u+"/weights"},{paramPath:u+"/biases"}),{weights:c,biases:l}}function a(s,u,c,l){var d=r(s,u,c,l+"/conv"),f=o(u,l+"/scale");return{conv:d,scale:f}}function i(s,u,c,l,d){d===void 0&&(d=!1);var f=a((d?.5:1)*s,u,c,l+"/conv1"),h=a(s,u,c,l+"/conv2");return{conv1:f,conv2:h}}return{extractConvLayerParams:a,extractResidualLayerParams:i}}function e9(n){var t=lo(n),e=t.extractWeights,r=t.getRemainingWeights,o=[],a=J5(e,o),i=a.extractConvLayerParams,s=a.extractResidualLayerParams,u=i(4704,32,7,"conv32_down"),c=s(9216,32,3,"conv32_1"),l=s(9216,32,3,"conv32_2"),d=s(9216,32,3,"conv32_3"),f=s(36864,64,3,"conv64_down",!0),h=s(36864,64,3,"conv64_1"),m=s(36864,64,3,"conv64_2"),p=s(36864,64,3,"conv64_3"),v=s(147456,128,3,"conv128_down",!0),g=s(147456,128,3,"conv128_1"),y=s(147456,128,3,"conv128_2"),w=s(589824,256,3,"conv256_down",!0),x=s(589824,256,3,"conv256_1"),C=s(589824,256,3,"conv256_2"),_=s(589824,256,3,"conv256_down_out"),E=xe(function(){return Bo(Ro(e(256*128),[128,256]),[1,0])});if(o.push({paramPath:"fc"}),r().length!==0)throw new Error("weights remaing after extract: "+r().length);var S={conv32_down:u,conv32_1:c,conv32_2:l,conv32_3:d,conv64_down:f,conv64_1:h,conv64_2:m,conv64_3:p,conv128_down:v,conv128_1:g,conv128_2:y,conv256_down:w,conv256_1:x,conv256_2:C,conv256_down_out:_,fc:E};return{params:S,paramMappings:o}}function t9(n,t){var e=zo(n,t);function r(i){var s=e(i+"/scale/weights",1),u=e(i+"/scale/biases",1);return{weights:s,biases:u}}function o(i){var s=e(i+"/conv/filters",4),u=e(i+"/conv/bias",1),c=r(i);return{conv:{filters:s,bias:u},scale:c}}function a(i){return{conv1:o(i+"/conv1"),conv2:o(i+"/conv2")}}return{extractConvLayerParams:o,extractResidualLayerParams:a}}function n9(n){var t=[],e=t9(n,t),r=e.extractConvLayerParams,o=e.extractResidualLayerParams,a=r("conv32_down"),i=o("conv32_1"),s=o("conv32_2"),u=o("conv32_3"),c=o("conv64_down"),l=o("conv64_1"),d=o("conv64_2"),f=o("conv64_3"),h=o("conv128_down"),m=o("conv128_1"),p=o("conv128_2"),v=o("conv256_down"),g=o("conv256_1"),y=o("conv256_2"),w=o("conv256_down_out"),x=n.fc;if(t.push({originalPath:"fc",paramPath:"fc"}),!l5(x))throw new Error("expected weightMap[fc] to be a Tensor2D, instead have "+x);var C={conv32_down:a,conv32_1:i,conv32_2:s,conv32_3:u,conv64_down:c,conv64_1:l,conv64_2:d,conv64_3:f,conv128_down:h,conv128_1:m,conv128_2:p,conv256_down:v,conv256_1:g,conv256_2:y,conv256_down_out:w,fc:x};return co(n,t),{params:C,paramMappings:t}}function jr(n,t){var e=Q5(n,t.conv1);return e=p2(e,t.conv2),e=qe(e,n),e=wt(e),e}function Cl(n,t){var e=v2(n,t.conv1);e=p2(e,t.conv2);var r=Qs(n,2,2,"valid"),o=vt(r.shape),a=r.shape[3]!==e.shape[3],i=r.shape[1]!==e.shape[1]||r.shape[2]!==e.shape[2];if(i){var s=eu(e.shape);s[1]=1;var u=vt(s);e=Vt([e,u],1);var c=eu(e.shape);c[2]=1;var l=vt(c);e=Vt([e,l],2)}return r=a?Vt([r,o],3):r,e=qe(r,e),e=wt(e),e}var r9=function(n){De(t,n);function t(){return n.call(this,"FaceRecognitionNet")||this}return t.prototype.forwardInput=function(e){var r=this.params;if(!r)throw new Error("FaceRecognitionNet - load model before inference");return xe(function(){var o=e.toBatchTensor(150,!0).toFloat(),a=[122.782,117.001,104.298],i=ru(o,a).div(ve(256)),s=v2(i,r.conv32_down);s=Kt(s,3,2,"valid"),s=jr(s,r.conv32_1),s=jr(s,r.conv32_2),s=jr(s,r.conv32_3),s=Cl(s,r.conv64_down),s=jr(s,r.conv64_1),s=jr(s,r.conv64_2),s=jr(s,r.conv64_3),s=Cl(s,r.conv128_down),s=jr(s,r.conv128_1),s=jr(s,r.conv128_2),s=Cl(s,r.conv256_down),s=jr(s,r.conv256_1),s=jr(s,r.conv256_2),s=Cl(s,r.conv256_down_out);var u=s.mean([1,2]),c=il(u,r.fc);return c})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.computeFaceDescriptor=function(e){return $e(this,void 0,void 0,function(){var r,o,a,i=this;return ke(this,function(s){switch(s.label){case 0:return[4,Yt(e)];case 1:return r=s.sent(),o=xe(function(){return jt(i.forwardInput(r))}),[4,Promise.all(o.map(function(u){return u.data()}))];case 2:return a=s.sent(),o.forEach(function(u){return u.dispose()}),[2,r.isBatchInput?a:a[0]]}})})},t.prototype.getDefaultModelName=function(){return"face_recognition_model"},t.prototype.extractParamsFromWeigthMap=function(e){return n9(e)},t.prototype.extractParams=function(e){return e9(e)},t}(uo);function m2(n,t){var e={descriptor:t};return Object.assign({},n,e)}function g2(n,t){var e={age:t};return Object.assign({},n,e)}function y2(n,t,e){var r={gender:t,genderProbability:e};return Object.assign({},n,r)}var b2=function(){function n(t){var e=t===void 0?{}:t,r=e.minFaceSize,o=e.scaleFactor,a=e.maxNumScales,i=e.scoreThresholds,s=e.scaleSteps;if(this._name="MtcnnOptions",this._minFaceSize=r||20,this._scaleFactor=o||.709,this._maxNumScales=a||10,this._scoreThresholds=i||[.6,.7,.7],this._scaleSteps=s,typeof this._minFaceSize!="number"||this._minFaceSize<0)throw new Error(this._name+" - expected minFaceSize to be a number > 0");if(typeof this._scaleFactor!="number"||this._scaleFactor<=0||this._scaleFactor>=1)throw new Error(this._name+" - expected scaleFactor to be a number between 0 and 1");if(typeof this._maxNumScales!="number"||this._maxNumScales<0)throw new Error(this._name+" - expected maxNumScales to be a number > 0");if(!Array.isArray(this._scoreThresholds)||this._scoreThresholds.length!==3||this._scoreThresholds.some(function(u){return typeof u!="number"}))throw new Error(this._name+" - expected scoreThresholds to be an array of numbers of length 3");if(this._scaleSteps&&(!Array.isArray(this._scaleSteps)||this._scaleSteps.some(function(u){return typeof u!="number"})))throw new Error(this._name+" - expected scaleSteps to be an array of numbers")}return Object.defineProperty(n.prototype,"minFaceSize",{get:function(){return this._minFaceSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scaleFactor",{get:function(){return this._scaleFactor},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"maxNumScales",{get:function(){return this._maxNumScales},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scoreThresholds",{get:function(){return this._scoreThresholds},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scaleSteps",{get:function(){return this._scaleSteps},enumerable:!0,configurable:!0}),n}();function o9(n,t){function e(u,c){var l=Sn(n(9*u),[3,3,u,1]),d=Ot(n(u)),f=Ot(n(u)),h=Ot(n(u)),m=Ot(n(u));return t.push({paramPath:c+"/filters"},{paramPath:c+"/batch_norm_scale"},{paramPath:c+"/batch_norm_offset"},{paramPath:c+"/batch_norm_mean"},{paramPath:c+"/batch_norm_variance"}),{filters:l,batch_norm_scale:d,batch_norm_offset:f,batch_norm_mean:h,batch_norm_variance:m}}function r(u,c,l,d,f){var h=Sn(n(u*c*l*l),[l,l,u,c]),m=Ot(n(c));return t.push({paramPath:d+"/filters"},{paramPath:d+"/"+(f?"batch_norm_offset":"bias")}),{filters:h,bias:m}}function o(u,c,l,d){var f=r(u,c,l,d,!0),h=f.filters,m=f.bias;return{filters:h,batch_norm_offset:m}}function a(u,c,l){var d=e(u,l+"/depthwise_conv"),f=o(u,c,1,l+"/pointwise_conv");return{depthwise_conv:d,pointwise_conv:f}}function i(){var u=o(3,32,3,"mobilenetv1/conv_0"),c=a(32,64,"mobilenetv1/conv_1"),l=a(64,128,"mobilenetv1/conv_2"),d=a(128,128,"mobilenetv1/conv_3"),f=a(128,256,"mobilenetv1/conv_4"),h=a(256,256,"mobilenetv1/conv_5"),m=a(256,512,"mobilenetv1/conv_6"),p=a(512,512,"mobilenetv1/conv_7"),v=a(512,512,"mobilenetv1/conv_8"),g=a(512,512,"mobilenetv1/conv_9"),y=a(512,512,"mobilenetv1/conv_10"),w=a(512,512,"mobilenetv1/conv_11"),x=a(512,1024,"mobilenetv1/conv_12"),C=a(1024,1024,"mobilenetv1/conv_13");return{conv_0:u,conv_1:c,conv_2:l,conv_3:d,conv_4:f,conv_5:h,conv_6:m,conv_7:p,conv_8:v,conv_9:g,conv_10:y,conv_11:w,conv_12:x,conv_13:C}}function s(){var u=o(1024,256,1,"prediction_layer/conv_0"),c=o(256,512,3,"prediction_layer/conv_1"),l=o(512,128,1,"prediction_layer/conv_2"),d=o(128,256,3,"prediction_layer/conv_3"),f=o(256,128,1,"prediction_layer/conv_4"),h=o(128,256,3,"prediction_layer/conv_5"),m=o(256,64,1,"prediction_layer/conv_6"),p=o(64,128,3,"prediction_layer/conv_7"),v=r(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),g=r(512,9,1,"prediction_layer/box_predictor_0/class_predictor"),y=r(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),w=r(1024,18,1,"prediction_layer/box_predictor_1/class_predictor"),x=r(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),C=r(512,18,1,"prediction_layer/box_predictor_2/class_predictor"),_=r(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),E=r(256,18,1,"prediction_layer/box_predictor_3/class_predictor"),S=r(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),N=r(256,18,1,"prediction_layer/box_predictor_4/class_predictor"),$=r(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),A=r(128,18,1,"prediction_layer/box_predictor_5/class_predictor"),P={box_encoding_predictor:v,class_predictor:g},j={box_encoding_predictor:y,class_predictor:w},B={box_encoding_predictor:x,class_predictor:C},z={box_encoding_predictor:_,class_predictor:E},H={box_encoding_predictor:S,class_predictor:N},F={box_encoding_predictor:$,class_predictor:A};return{conv_0:u,conv_1:c,conv_2:l,conv_3:d,conv_4:f,conv_5:h,conv_6:m,conv_7:p,box_predictor_0:P,box_predictor_1:j,box_predictor_2:B,box_predictor_3:z,box_predictor_4:H,box_predictor_5:F}}return{extractMobilenetV1Params:i,extractPredictionLayerParams:s}}function a9(n){var t=[],e=lo(n),r=e.extractWeights,o=e.getRemainingWeights,a=o9(r,t),i=a.extractMobilenetV1Params,s=a.extractPredictionLayerParams,u=i(),c=s(),l=jf(r(5118*4),[1,5118,4]),d={extra_dim:l};if(t.push({paramPath:"output_layer/extra_dim"}),o().length!==0)throw new Error("weights remaing after extract: "+o().length);return{params:{mobilenetv1:u,prediction_layer:c,output_layer:d},paramMappings:t}}function i9(n,t){var e=zo(n,t);function r(c,l,d){var f=e(c+"/Conv2d_"+l+"_pointwise/weights",4,d+"/filters"),h=e(c+"/Conv2d_"+l+"_pointwise/convolution_bn_offset",1,d+"/batch_norm_offset");return{filters:f,batch_norm_offset:h}}function o(c){var l="mobilenetv1/conv_"+c,d="MobilenetV1/Conv2d_"+c+"_depthwise",f=l+"/depthwise_conv",h=l+"/pointwise_conv",m=e(d+"/depthwise_weights",4,f+"/filters"),p=e(d+"/BatchNorm/gamma",1,f+"/batch_norm_scale"),v=e(d+"/BatchNorm/beta",1,f+"/batch_norm_offset"),g=e(d+"/BatchNorm/moving_mean",1,f+"/batch_norm_mean"),y=e(d+"/BatchNorm/moving_variance",1,f+"/batch_norm_variance");return{depthwise_conv:{filters:m,batch_norm_scale:p,batch_norm_offset:v,batch_norm_mean:g,batch_norm_variance:y},pointwise_conv:r("MobilenetV1",c,h)}}function a(){return{conv_0:r("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:o(1),conv_2:o(2),conv_3:o(3),conv_4:o(4),conv_5:o(5),conv_6:o(6),conv_7:o(7),conv_8:o(8),conv_9:o(9),conv_10:o(10),conv_11:o(11),conv_12:o(12),conv_13:o(13)}}function i(c,l){var d=e(c+"/weights",4,l+"/filters"),f=e(c+"/biases",1,l+"/bias");return{filters:d,bias:f}}function s(c){var l=i("Prediction/BoxPredictor_"+c+"/BoxEncodingPredictor","prediction_layer/box_predictor_"+c+"/box_encoding_predictor"),d=i("Prediction/BoxPredictor_"+c+"/ClassPredictor","prediction_layer/box_predictor_"+c+"/class_predictor");return{box_encoding_predictor:l,class_predictor:d}}function u(){return{conv_0:r("Prediction",0,"prediction_layer/conv_0"),conv_1:r("Prediction",1,"prediction_layer/conv_1"),conv_2:r("Prediction",2,"prediction_layer/conv_2"),conv_3:r("Prediction",3,"prediction_layer/conv_3"),conv_4:r("Prediction",4,"prediction_layer/conv_4"),conv_5:r("Prediction",5,"prediction_layer/conv_5"),conv_6:r("Prediction",6,"prediction_layer/conv_6"),conv_7:r("Prediction",7,"prediction_layer/conv_7"),box_predictor_0:s(0),box_predictor_1:s(1),box_predictor_2:s(2),box_predictor_3:s(3),box_predictor_4:s(4),box_predictor_5:s(5)}}return{extractMobilenetV1Params:a,extractPredictionLayerParams:u}}function s9(n){var t=[],e=i9(n,t),r=e.extractMobilenetV1Params,o=e.extractPredictionLayerParams,a=n["Output/extra_dim"];if(t.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!hl(a))throw new Error("expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have "+a);var i={mobilenetv1:r(),prediction_layer:o(),output_layer:{extra_dim:a}};return co(n,t),{params:i,paramMappings:t}}function Ur(n,t,e){return xe(function(){var r=Zn(n,t.filters,e,"same");return r=qe(r,t.batch_norm_offset),lh(r,0,6)})}var u9=.0010000000474974513;function c9(n,t,e){return xe(function(){var r=al(n,t.filters,e,"same");return r=z1(r,t.batch_norm_mean,t.batch_norm_variance,t.batch_norm_offset,t.batch_norm_scale,u9),lh(r,0,6)})}function l9(n){return[2,4,6,12].some(function(t){return t===n})?[2,2]:[1,1]}function d9(n,t){return xe(function(){var e=null,r=Ur(n,t.conv_0,[2,2]),o=[t.conv_1,t.conv_2,t.conv_3,t.conv_4,t.conv_5,t.conv_6,t.conv_7,t.conv_8,t.conv_9,t.conv_10,t.conv_11,t.conv_12,t.conv_13];if(o.forEach(function(a,i){var s=i+1,u=l9(s);r=c9(r,a.depthwise_conv,u),r=Ur(r,a.pointwise_conv,[1,1]),s===11&&(e=r)}),e===null)throw new Error("mobileNetV1 - output of conv layer 11 is null");return{out:r,conv11:e}})}function f9(n,t,e,r,o){var a=n.shape[0],i=Math.min(e,a),s=t.map(function(l,d){return{score:l,boxIndex:d}}).filter(function(l){return l.score>o}).sort(function(l,d){return d.score-l.score}),u=function(l){return l<=r?1:0},c=[];return s.forEach(function(l){if(!(c.length>=i)){for(var d=l.score,f=c.length-1;f>=0;--f){var h=h9(n,l.boxIndex,c[f]);if(h!==0&&(l.score*=u(h),l.score<=o))break}d===l.score&&c.push(l.boxIndex)}}),c}function h9(n,t,e){var r=n.arraySync(),o=Math.min(r[t][0],r[t][2]),a=Math.min(r[t][1],r[t][3]),i=Math.max(r[t][0],r[t][2]),s=Math.max(r[t][1],r[t][3]),u=Math.min(r[e][0],r[e][2]),c=Math.min(r[e][1],r[e][3]),l=Math.max(r[e][0],r[e][2]),d=Math.max(r[e][1],r[e][3]),f=(i-o)*(s-a),h=(l-u)*(d-c);if(f<=0||h<=0)return 0;var m=Math.max(o,u),p=Math.max(a,c),v=Math.min(i,l),g=Math.min(s,d),y=Math.max(v-m,0)*Math.max(g-p,0);return y/(f+h-y)}function p9(n){var t=jt(Bo(n,[1,0])),e=[zt(t[2],t[0]),zt(t[3],t[1])],r=[qe(t[0],ur(e[0],ve(2))),qe(t[1],ur(e[1],ve(2)))];return{sizes:e,centers:r}}function v9(n,t){var e=p9(n),r=e.sizes,o=e.centers,a=jt(Bo(t,[1,0])),i=ur(cn(dh(ur(a[2],ve(5))),r[0]),ve(2)),s=qe(cn(ur(a[0],ve(10)),r[0]),o[0]),u=ur(cn(dh(ur(a[3],ve(5))),r[1]),ve(2)),c=qe(cn(ur(a[1],ve(10)),r[1]),o[1]);return Bo(Bn([zt(s,i),zt(c,u),qe(s,i),qe(c,u)]),[1,0])}function m9(n,t,e){return xe(function(){var r=n.shape[0],o=v9(ir(_i(e.extra_dim,[r,1,1]),[-1,4]),ir(n,[-1,4]));o=ir(o,[r,o.shape[0]/r,4]);var a=W1(Br(t,[0,0,1],[-1,-1,-1])),i=Br(a,[0,0,0],[-1,-1,1]);i=ir(i,[r,i.shape[1]]);var s=jt(o),u=jt(i);return{boxes:s,scores:u}})}function Ri(n,t){return xe(function(){var e=n.shape[0],r=ir(cr(n,t.box_encoding_predictor),[e,-1,1,4]),o=ir(cr(n,t.class_predictor),[e,-1,3]);return{boxPredictionEncoding:r,classPrediction:o}})}function g9(n,t,e){return xe(function(){var r=Ur(n,e.conv_0,[1,1]),o=Ur(r,e.conv_1,[2,2]),a=Ur(o,e.conv_2,[1,1]),i=Ur(a,e.conv_3,[2,2]),s=Ur(i,e.conv_4,[1,1]),u=Ur(s,e.conv_5,[2,2]),c=Ur(u,e.conv_6,[1,1]),l=Ur(c,e.conv_7,[2,2]),d=Ri(t,e.box_predictor_0),f=Ri(n,e.box_predictor_1),h=Ri(o,e.box_predictor_2),m=Ri(i,e.box_predictor_3),p=Ri(u,e.box_predictor_4),v=Ri(l,e.box_predictor_5),g=Vt([d.boxPredictionEncoding,f.boxPredictionEncoding,h.boxPredictionEncoding,m.boxPredictionEncoding,p.boxPredictionEncoding,v.boxPredictionEncoding],1),y=Vt([d.classPrediction,f.classPrediction,h.classPrediction,m.classPrediction,p.classPrediction,v.classPrediction],1);return{boxPredictions:g,classPredictions:y}})}var ou=function(){function n(t){var e=t===void 0?{}:t,r=e.minConfidence,o=e.maxResults;if(this._name="SsdMobilenetv1Options",this._minConfidence=r||.5,this._maxResults=o||100,typeof this._minConfidence!="number"||this._minConfidence<=0||this._minConfidence>=1)throw new Error(this._name+" - expected minConfidence to be a number between 0 and 1");if(typeof this._maxResults!="number")throw new Error(this._name+" - expected maxResults to be a number")}return Object.defineProperty(n.prototype,"minConfidence",{get:function(){return this._minConfidence},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"maxResults",{get:function(){return this._maxResults},enumerable:!0,configurable:!0}),n}(),x2=function(n){De(t,n);function t(){return n.call(this,"SsdMobilenetv1")||this}return t.prototype.forwardInput=function(e){var r=this.params;if(!r)throw new Error("SsdMobilenetv1 - load model before inference");return xe(function(){var o=e.toBatchTensor(512,!1).toFloat(),a=zt(cn(o,ve(.007843137718737125)),ve(1)),i=d9(a,r.mobilenetv1),s=g9(i.out,i.conv11,r.prediction_layer),u=s.boxPredictions,c=s.classPredictions;return m9(u,c,r.output_layer)})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.locateFaces=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o,a,i,s,u,c,l,d,f,h,m,p,v,g,y,w,x,C,_,E,S;return ke(this,function(N){switch(N.label){case 0:return o=new ou(r),a=o.maxResults,i=o.minConfidence,[4,Yt(e)];case 1:for(s=N.sent(),u=this.forwardInput(s),c=u.boxes,l=u.scores,d=c[0],f=l[0],h=1;h<c.length;h++)c[h].dispose(),l[h].dispose();return v=(p=Array).from,[4,f.data()];case 2:return m=v.apply(p,[N.sent()]),g=.5,y=f9(d,m,a,g,i),w=s.getReshapedInputDimensions(0),x=s.inputSize,C=x/w.width,_=x/w.height,E=d.arraySync(),S=y.map(function($){var A=[Math.max(0,E[$][0]),Math.min(1,E[$][2])].map(function(F){return F*_}),P=A[0],j=A[1],B=[Math.max(0,E[$][1]),Math.min(1,E[$][3])].map(function(F){return F*C}),z=B[0],H=B[1];return new Wr(m[$],new Uh(z,P,H-z,j-P),{height:s.getInputHeight(0),width:s.getInputWidth(0)})}),d.dispose(),f.dispose(),[2,S]}})})},t.prototype.getDefaultModelName=function(){return"ssd_mobilenetv1_model"},t.prototype.extractParamsFromWeigthMap=function(e){return s9(e)},t.prototype.extractParams=function(e){return a9(e)},t}(uo);(function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t})(x2);var y9=.4,b9=[new ot(.738768,.874946),new ot(2.42204,2.65704),new ot(4.30971,7.04493),new ot(10.246,4.59428),new ot(12.6868,11.8741)],x9=[new ot(1.603231,2.094468),new ot(6.041143,7.080126),new ot(2.882459,3.518061),new ot(4.266906,5.178857),new ot(9.041765,10.66308)],w9=[117.001,114.697,97.404],C9="tiny_yolov2_model",_9="tiny_yolov2_separable_conv_model",_l=function(n){return typeof n=="number"};function E9(n){if(!n)throw new Error("invalid config: "+n);if(typeof n.withSeparableConvs!="boolean")throw new Error("config.withSeparableConvs has to be a boolean, have: "+n.withSeparableConvs);if(!_l(n.iouThreshold)||n.iouThreshold<0||n.iouThreshold>1)throw new Error("config.iouThreshold has to be a number between [0, 1], have: "+n.iouThreshold);if(!Array.isArray(n.classes)||!n.classes.length||!n.classes.every(function(t){return typeof t=="string"}))throw new Error("config.classes has to be an array class names: string[], have: "+JSON.stringify(n.classes));if(!Array.isArray(n.anchors)||!n.anchors.length||!n.anchors.map(function(t){return t||{}}).every(function(t){return _l(t.x)&&_l(t.y)}))throw new Error("config.anchors has to be an array of { x: number, y: number }, have: "+JSON.stringify(n.anchors));if(n.meanRgb&&(!Array.isArray(n.meanRgb)||n.meanRgb.length!==3||!n.meanRgb.every(_l)))throw new Error("config.meanRgb has to be an array of shape [number, number, number], have: "+JSON.stringify(n.meanRgb))}function rp(n){return xe(function(){var t=cn(n,ve(.10000000149011612));return qe(wt(zt(n,t)),t)})}function Ho(n,t){return xe(function(){var e=Ia(n,[[0,0],[1,1],[1,1],[0,0]]);return e=Zn(e,t.conv.filters,[1,1],"valid"),e=zt(e,t.bn.sub),e=cn(e,t.bn.truediv),e=qe(e,t.conv.bias),rp(e)})}function Go(n,t){return xe(function(){var e=Ia(n,[[0,0],[1,1],[1,1],[0,0]]);return e=mh(e,t.depthwise_filter,t.pointwise_filter,[1,1],"valid"),e=qe(e,t.bias),rp(e)})}function S9(n,t){var e=xl(n,t);function r(i,s){var u=Ot(n(i)),c=Ot(n(i));return t.push({paramPath:s+"/sub"},{paramPath:s+"/truediv"}),{sub:u,truediv:c}}function o(i,s,u){var c=e(i,s,3,u+"/conv"),l=r(s,u+"/bn");return{conv:c,bn:l}}var a=Qh(n,t);return{extractConvParams:e,extractConvWithBatchNormParams:o,extractSeparableConvParams:a}}function N9(n,t,e,r){var o=lo(n),a=o.extractWeights,i=o.getRemainingWeights,s=[],u=S9(a,s),c=u.extractConvParams,l=u.extractConvWithBatchNormParams,d=u.extractSeparableConvParams,f;if(t.withSeparableConvs){var h=r[0],m=r[1],p=r[2],v=r[3],g=r[4],y=r[5],w=r[6],x=r[7],C=r[8],_=t.isFirstLayerConv2d?c(h,m,3,"conv0"):d(h,m,"conv0"),E=d(m,p,"conv1"),S=d(p,v,"conv2"),N=d(v,g,"conv3"),$=d(g,y,"conv4"),A=d(y,w,"conv5"),P=x?d(w,x,"conv6"):void 0,j=C?d(x,C,"conv7"):void 0,B=c(C||x||w,5*e,1,"conv8");f={conv0:_,conv1:E,conv2:S,conv3:N,conv4:$,conv5:A,conv6:P,conv7:j,conv8:B}}else{var h=r[0],m=r[1],p=r[2],v=r[3],g=r[4],y=r[5],w=r[6],x=r[7],C=r[8],_=l(h,m,"conv0"),E=l(m,p,"conv1"),S=l(p,v,"conv2"),N=l(v,g,"conv3"),$=l(g,y,"conv4"),A=l(y,w,"conv5"),P=l(w,x,"conv6"),j=l(x,C,"conv7"),B=c(C,5*e,1,"conv8");f={conv0:_,conv1:E,conv2:S,conv3:N,conv4:$,conv5:A,conv6:P,conv7:j,conv8:B}}if(i().length!==0)throw new Error("weights remaing after extract: "+i().length);return{params:f,paramMappings:s}}function $9(n,t){var e=zo(n,t);function r(s){var u=e(s+"/sub",1),c=e(s+"/truediv",1);return{sub:u,truediv:c}}function o(s){var u=e(s+"/filters",4),c=e(s+"/bias",1);return{filters:u,bias:c}}function a(s){var u=o(s+"/conv"),c=r(s+"/bn");return{conv:u,bn:c}}var i=Jh(e);return{extractConvParams:o,extractConvWithBatchNormParams:a,extractSeparableConvParams:i}}function k9(n,t){var e=[],r=$9(n,e),o=r.extractConvParams,a=r.extractConvWithBatchNormParams,i=r.extractSeparableConvParams,s;if(t.withSeparableConvs){var u=t.filterSizes&&t.filterSizes.length||9;s={conv0:t.isFirstLayerConv2d?o("conv0"):i("conv0"),conv1:i("conv1"),conv2:i("conv2"),conv3:i("conv3"),conv4:i("conv4"),conv5:i("conv5"),conv6:u>7?i("conv6"):void 0,conv7:u>8?i("conv7"):void 0,conv8:o("conv8")}}else s={conv0:a("conv0"),conv1:a("conv1"),conv2:a("conv2"),conv3:a("conv3"),conv4:a("conv4"),conv5:a("conv5"),conv6:a("conv6"),conv7:a("conv7"),conv8:o("conv8")};return co(n,e),{params:s,paramMappings:e}}var w2;(function(n){n[n.XS=224]="XS",n[n.SM=320]="SM",n[n.MD=416]="MD",n[n.LG=608]="LG"})(w2||(w2={}));var op=function(){function n(t){var e=t===void 0?{}:t,r=e.inputSize,o=e.scoreThreshold;if(this._name="TinyYolov2Options",this._inputSize=r||416,this._scoreThreshold=o||.5,typeof this._inputSize!="number"||this._inputSize%32!==0)throw new Error(this._name+" - expected inputSize to be a number divisible by 32");if(typeof this._scoreThreshold!="number"||this._scoreThreshold<=0||this._scoreThreshold>=1)throw new Error(this._name+" - expected scoreThreshold to be a number between 0 and 1")}return Object.defineProperty(n.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scoreThreshold",{get:function(){return this._scoreThreshold},enumerable:!0,configurable:!0}),n}(),C2=function(n){De(t,n);function t(e){var r=n.call(this,"TinyYolov2")||this;return E9(e),r._config=e,r}return Object.defineProperty(t.prototype,"config",{get:function(){return this._config},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"withClassScores",{get:function(){return this.config.withClassScores||this.config.classes.length>1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"boxEncodingSize",{get:function(){return 5+(this.withClassScores?this.config.classes.length:0)},enumerable:!0,configurable:!0}),t.prototype.runTinyYolov2=function(e,r){var o=Ho(e,r.conv0);return o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv1),o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv2),o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv3),o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv4),o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv5),o=Kt(o,[2,2],[1,1],"same"),o=Ho(o,r.conv6),o=Ho(o,r.conv7),cr(o,r.conv8,"valid",!1)},t.prototype.runMobilenet=function(e,r){var o=this.config.isFirstLayerConv2d?rp(cr(e,r.conv0,"valid",!1)):Go(e,r.conv0);return o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv1),o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv2),o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv3),o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv4),o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv5),o=Kt(o,[2,2],[1,1],"same"),o=r.conv6?Go(o,r.conv6):o,o=r.conv7?Go(o,r.conv7):o,cr(o,r.conv8,"valid",!1)},t.prototype.forwardInput=function(e,r){var o=this,a=this.params;if(!a)throw new Error("TinyYolov2 - load model before inference");return xe(function(){var i=e.toBatchTensor(r,!1).toFloat();return i=o.config.meanRgb?ru(i,o.config.meanRgb):i,i=i.div(ve(256)),o.config.withSeparableConvs?o.runMobilenet(i,a):o.runTinyYolov2(i,a)})},t.prototype.forward=function(e,r){return $e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return o=this.forwardInput,[4,Yt(e)];case 1:return[4,o.apply(this,[a.sent(),r])];case 2:return[2,a.sent()]}})})},t.prototype.detect=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o,a,i,s,u,c,l,d,f,h,m,p,v,g,y=this;return ke(this,function(w){switch(w.label){case 0:return o=new op(r),a=o.inputSize,i=o.scoreThreshold,[4,Yt(e)];case 1:return s=w.sent(),[4,this.forwardInput(s,a)];case 2:return u=w.sent(),c=xe(function(){return jt(u)[0].expandDims()}),l={width:s.getInputWidth(0),height:s.getInputHeight(0)},[4,this.extractBoxes(c,s.getReshapedInputDimensions(0),i)];case 3:return d=w.sent(),u.dispose(),c.dispose(),f=d.map(function(x){return x.box}),h=d.map(function(x){return x.score}),m=d.map(function(x){return x.classScore}),p=d.map(function(x){return y.config.classes[x.label]}),v=nu(f.map(function(x){return x.rescale(a)}),h,this.config.iouThreshold,!0),g=v.map(function(x){return new jb(h[x],m[x],p[x],f[x],l)}),[2,g]}})})},t.prototype.getDefaultModelName=function(){return""},t.prototype.extractParamsFromWeigthMap=function(e){return k9(e,this.config)},t.prototype.extractParams=function(e){var r=this.config.filterSizes||t.DEFAULT_FILTER_SIZES,o=r?r.length:void 0;if(o!==7&&o!==8&&o!==9)throw new Error("TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found "+o+" filterSizes in config");return N9(e,this.config,this.boxEncodingSize,r)},t.prototype.extractBoxes=function(e,r,o){return $e(this,void 0,void 0,function(){var a,i,s,u,c,l,d,f,h,m,p,v,g,y,w,x,C,_,E,S,N,$,A,P,j,B,z,H,F,M=this;return ke(this,function(O){switch(O.label){case 0:return a=r.width,i=r.height,s=Math.max(a,i),u=s/a,c=s/i,l=e.shape[1],d=this.config.anchors.length,f=xe(function(){var I=e.reshape([l,l,d,M.boxEncodingSize]),L=I.slice([0,0,0,0],[l,l,d,4]),K=I.slice([0,0,0,4],[l,l,d,1]),q=M.withClassScores?oo(I.slice([0,0,0,5],[l,l,d,M.config.classes.length]),3):ve(0);return[L,K,q]}),h=f[0],m=f[1],p=f[2],v=[],[4,m.array()];case 1:return g=O.sent(),[4,h.array()];case 2:y=O.sent(),w=0,O.label=3;case 3:if(!(w<l))return[3,12];x=0,O.label=4;case 4:if(!(x<l))return[3,11];C=0,O.label=5;case 5:return C<d?(_=jh(g[w][x][C][0]),!o||_>o?(E=(x+jh(y[w][x][C][0]))/l*u,S=(w+jh(y[w][x][C][1]))/l*c,N=Math.exp(y[w][x][C][2])*this.config.anchors[C].x/l*u,$=Math.exp(y[w][x][C][3])*this.config.anchors[C].y/l*c,A=E-N/2,P=S-$/2,j={row:w,col:x,anchor:C},this.withClassScores?[4,this.extractPredictedClass(p,j)]:[3,7]):[3,9]):[3,10];case 6:return F=O.sent(),[3,8];case 7:F={classScore:1,label:0},O.label=8;case 8:B=F,z=B.classScore,H=B.label,v.push(dn({box:new pl(A,P,A+N,P+$),score:_,classScore:_*z,label:H},j)),O.label=9;case 9:return C++,[3,5];case 10:return x++,[3,4];case 11:return w++,[3,3];case 12:return h.dispose(),m.dispose(),p.dispose(),[2,v]}})})},t.prototype.extractPredictedClass=function(e,r){return $e(this,void 0,void 0,function(){var o,a,i,s;return ke(this,function(u){switch(u.label){case 0:return o=r.row,a=r.col,i=r.anchor,[4,e.array()];case 1:return s=u.sent(),[2,Array(this.config.classes.length).fill(0).map(function(c,l){return s[o][a][i][l]}).map(function(c,l){return{classScore:c,label:l}}).reduce(function(c,l){return c.classScore>l.classScore?c:l})]}})})},t.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024],t}(uo),P9=function(n){De(t,n);function t(e){e===void 0&&(e=!0);var r=this,o=Object.assign({},{withSeparableConvs:e,iouThreshold:y9,classes:["face"]},e?{anchors:x9,meanRgb:w9}:{anchors:b9,withClassScores:!0});return r=n.call(this,o)||this,r}return Object.defineProperty(t.prototype,"withSeparableConvs",{get:function(){return this.config.withSeparableConvs},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),t.prototype.locateFaces=function(e,r){return $e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return[4,this.detect(e,r)];case 1:return o=a.sent(),[2,o.map(function(i){return new Wr(i.score,i.relativeBox,{width:i.imageWidth,height:i.imageHeight})})]}})})},t.prototype.getDefaultModelName=function(){return this.withSeparableConvs?_9:C9},t.prototype.extractParamsFromWeigthMap=function(e){return n.prototype.extractParamsFromWeigthMap.call(this,e)},t}(C2),I9=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e._name="TinyFaceDetectorOptions",e}return t}(op),au=function(){function n(){}return n.prototype.then=function(t){return $e(this,void 0,void 0,function(){var e;return ke(this,function(r){switch(r.label){case 0:return e=t,[4,this.run()];case 1:return[2,e.apply(void 0,[r.sent()])]}})})},n.prototype.run=function(){return $e(this,void 0,void 0,function(){return ke(this,function(t){throw new Error("ComposableTask - run is not implemented")})})},n}();function El(n,t,e,r,o){return o===void 0&&(o=function(a){var i=a.alignedRect;return i}),$e(this,void 0,void 0,function(){var a,i,s,u,c;return ke(this,function(l){switch(l.label){case 0:return a=n.map(function(d){return R5(d)?o(d):d.detection}),s=r,s?[3,5]:t instanceof bt?[4,Yh(t,a)]:[3,2];case 1:return u=l.sent(),[3,4];case 2:return[4,Kh(t,a)];case 3:u=l.sent(),l.label=4;case 4:s=u,l.label=5;case 5:return i=s,[4,e(i)];case 6:return c=l.sent(),i.forEach(function(d){return d instanceof bt&&d.dispose()}),[2,c]}})})}function ap(n,t,e,r,o){return $e(this,void 0,void 0,function(){var a=this;return ke(this,function(i){return[2,El([n],t,function(s){return $e(a,void 0,void 0,function(){return ke(this,function(u){return[2,e(s[0])]})})},r,o)]})})}function A9(n){return xe(function(){return Bn(jt(n,3).reverse(),3)})}var Sl=2,Nl=12;function T9(n,t){var e=xl(n,t),r=Zh(n,t);function o(c,l){var d=Ot(n(c));return t.push({paramPath:l}),d}function a(c,l,d){d===void 0&&(d=!1);var f=e(c[0],c[1],3,l+"/conv1"),h=o(c[1],l+"/prelu1_alpha"),m=e(c[1],c[2],3,l+"/conv2"),p=o(c[2],l+"/prelu2_alpha"),v=e(c[2],c[3],d?2:3,l+"/conv3"),g=o(c[3],l+"/prelu3_alpha");return{conv1:f,prelu1_alpha:h,conv2:m,prelu2_alpha:p,conv3:v,prelu3_alpha:g}}function i(){var c=a([3,10,16,32],"pnet"),l=e(32,2,1,"pnet/conv4_1"),d=e(32,4,1,"pnet/conv4_2");return dn(dn({},c),{conv4_1:l,conv4_2:d})}function s(){var c=a([3,28,48,64],"rnet",!0),l=r(576,128,"rnet/fc1"),d=o(128,"rnet/prelu4_alpha"),f=r(128,2,"rnet/fc2_1"),h=r(128,4,"rnet/fc2_2");return dn(dn({},c),{fc1:l,prelu4_alpha:d,fc2_1:f,fc2_2:h})}function u(){var c=a([3,32,64,64],"onet"),l=e(64,128,2,"onet/conv4"),d=o(128,"onet/prelu4_alpha"),f=r(1152,256,"onet/fc1"),h=o(256,"onet/prelu5_alpha"),m=r(256,2,"onet/fc2_1"),p=r(256,4,"onet/fc2_2"),v=r(256,10,"onet/fc2_3");return dn(dn({},c),{conv4:l,prelu4_alpha:d,fc1:f,prelu5_alpha:h,fc2_1:m,fc2_2:p,fc2_3:v})}return{extractPNetParams:i,extractRNetParams:s,extractONetParams:u}}function O9(n){var t=lo(n),e=t.extractWeights,r=t.getRemainingWeights,o=[],a=T9(e,o),i=a.extractPNetParams,s=a.extractRNetParams,u=a.extractONetParams,c=i(),l=s(),d=u();if(r().length!==0)throw new Error("weights remaing after extract: "+r().length);return{params:{pnet:c,rnet:l,onet:d},paramMappings:o}}function D9(n,t){var e=zo(n,t);function r(l){var d=e(l+"/weights",4,l+"/filters"),f=e(l+"/bias",1);return{filters:d,bias:f}}function o(l){var d=e(l+"/weights",2),f=e(l+"/bias",1);return{weights:d,bias:f}}function a(l){return e(l,1)}function i(l){var d=r(l+"/conv1"),f=a(l+"/prelu1_alpha"),h=r(l+"/conv2"),m=a(l+"/prelu2_alpha"),p=r(l+"/conv3"),v=a(l+"/prelu3_alpha");return{conv1:d,prelu1_alpha:f,conv2:h,prelu2_alpha:m,conv3:p,prelu3_alpha:v}}function s(){var l=i("pnet"),d=r("pnet/conv4_1"),f=r("pnet/conv4_2");return dn(dn({},l),{conv4_1:d,conv4_2:f})}function u(){var l=i("rnet"),d=o("rnet/fc1"),f=a("rnet/prelu4_alpha"),h=o("rnet/fc2_1"),m=o("rnet/fc2_2");return dn(dn({},l),{fc1:d,prelu4_alpha:f,fc2_1:h,fc2_2:m})}function c(){var l=i("onet"),d=r("onet/conv4"),f=a("onet/prelu4_alpha"),h=o("onet/fc1"),m=a("onet/prelu5_alpha"),p=o("onet/fc2_1"),v=o("onet/fc2_2"),g=o("onet/fc2_3");return dn(dn({},l),{conv4:d,prelu4_alpha:f,fc1:h,prelu5_alpha:m,fc2_1:p,fc2_2:v,fc2_3:g})}return{extractPNetParams:s,extractRNetParams:u,extractONetParams:c}}function M9(n){var t=[],e=D9(n,t),r=e.extractPNetParams,o=e.extractRNetParams,a=e.extractONetParams,i=r(),s=o(),u=a();return co(n,t),{params:{pnet:i,rnet:s,onet:u},paramMappings:t}}function ip(n,t){var e=t[0],r=t[1];return{height:Math.floor(e*n),width:Math.floor(r*n)}}function F9(n,t,e){for(var r=e[0],o=e[1],a=Nl/n,i=[],s=Math.min(r,o)*a,u=0;s>=12;)i.push(a*Math.pow(t,u)),s=s*t,u+=1;return i}var sp=function(n){De(t,n);function t(e,r,o,a){return n.call(this,{left:e,top:r,right:o,bottom:a},!0)||this}return t}(Uo);function _2(n){return xe(function(){return cn(zt(n,ve(127.5)),ve(.0078125))})}function Li(n,t){return xe(function(){return qe(wt(n),cn(t,el(wt(el(n)))))})}function up(n,t,e){return e===void 0&&(e=!1),xe(function(){var r=cr(n,t.conv1,"valid");return r=Li(r,t.prelu1_alpha),r=Kt(r,e?[2,2]:[3,3],[2,2],"same"),r=cr(r,t.conv2,"valid"),r=Li(r,t.prelu2_alpha),r=e?r:Kt(r,[3,3],[2,2],"valid"),r=cr(r,t.conv3,"valid"),r=Li(r,t.prelu3_alpha),r})}function R9(n,t){return xe(function(){var e=up(n,t,!0),r=cr(e,t.conv4_1,"valid"),o=Xn(sl(r,3),3),a=oo(zt(r,o),3),i=cr(e,t.conv4_2,"valid");return{prob:a,regions:i}})}function L9(n,t){return xe(function(){var e=ip(t,n.shape.slice(1)),r=e.height,o=e.width,a=wh.resizeBilinear(n,[r,o]),i=_2(a);return Bo(i,[0,2,1,3])})}function B9(n,t,e,r){for(var o=[],a=n.arraySync(),i=0;i<n.shape[0];i++)for(var s=0;s<n.shape[1];s++)a[i][s]>=r&&o.push(new ot(s,i));var u=o.map(function(c){var l=new pl(Math.round((c.y*Sl+1)/e),Math.round((c.x*Sl+1)/e),Math.round((c.y*Sl+Nl)/e),Math.round((c.x*Sl+Nl)/e)),d=a[c.y][c.x],f=t.arraySync(),h=new sp(f[c.y][c.x][0],f[c.y][c.x][1],f[c.y][c.x][2],f[c.y][c.x][3]);return{cell:l,score:d,region:h}});return u}function W9(n,t,e,r,o){o.stage1=[];var a=t.map(function(f){return xe(function(){var h={scale:f},m=L9(n,f),p=Date.now(),v=R9(m,r),g=v.prob,y=v.regions;h.pnet=Date.now()-p;var w=jt(jt(g,3)[1])[0],x=jt(y)[0];return{scoresTensor:w,regionsTensor:x,scale:f,statsForScale:h}})}),i=a.map(function(f){var h=f.scoresTensor,m=f.regionsTensor,p=f.scale,v=f.statsForScale,g=B9(h,m,p,e);if(h.dispose(),m.dispose(),!g.length)return o.stage1.push(v),[];var y=Date.now(),w=nu(g.map(function(x){return x.cell}),g.map(function(x){return x.score}),.5);return v.nms=Date.now()-y,v.numBoxes=w.length,o.stage1.push(v),w.map(function(x){return g[x]})}),s=i.reduce(function(f,h){return f.concat(h)},[]),u=[],c=[];if(s.length>0){var l=Date.now(),d=nu(s.map(function(f){return f.cell}),s.map(function(f){return f.score}),.7);o.stage1_nms=Date.now()-l,c=d.map(function(f){return s[f].score}),u=d.map(function(f){return s[f]}).map(function(f){var h=f.cell,m=f.region;return new pl(h.left+m.left*h.width,h.top+m.top*h.height,h.right+m.right*h.width,h.bottom+m.bottom*h.height).toSquare().round()})}return{boxes:u,scores:c}}function E2(n,t,e){var r=e.width,o=e.height;return $e(this,void 0,void 0,function(){var a,i,s,u=this;return ke(this,function(c){switch(c.label){case 0:return a=Ba(n),[4,Promise.all(t.map(function(l){return $e(u,void 0,void 0,function(){var d,f,h,m,p,v,g,y;return ke(this,function(w){return d=l.padAtBorders(n.height,n.width),f=d.y,h=d.ey,m=d.x,p=d.ex,v=m-1,g=f-1,y=a.getImageData(v,g,p-v,h-g),[2,rn.isNodejs()?qh(y):createImageBitmap(y)]})})}))];case 1:return i=c.sent(),s=[],i.forEach(function(l){var d=gl({width:r,height:o}),f=Ba(d);f.drawImage(l,0,0,r,o);for(var h=f.getImageData(0,0,r,o).data,m=[],p=0;p<h.length;p+=4)m.push(h[p+2]),m.push(h[p+1]),m.push(h[p]);s.push(m)}),[2,s.map(function(l){var d=xe(function(){var f=Bo(Sn(l,[1,r,o,3]),[0,2,1,3]).toFloat();return _2(f)});return d})]}})})}function V9(n,t){return xe(function(){var e=up(n,t),r=ir(e,[e.shape[0],t.fc1.weights.shape[0]]),o=Vr(r,t.fc1),a=Li(o,t.prelu4_alpha),i=Vr(a,t.fc2_1),s=Xn(sl(i,1),1),u=oo(zt(i,s),1),c=Vr(a,t.fc2_2),l=jt(u,1)[1];return{scores:l,regions:c}})}function j9(n,t,e,r,o){return $e(this,void 0,void 0,function(){var a,i,s,u,c,l,d,f,h,m,p,v,g,y;return ke(this,function(w){switch(w.label){case 0:return a=Date.now(),[4,E2(n,t,{width:24,height:24})];case 1:return i=w.sent(),o.stage2_extractImagePatches=Date.now()-a,a=Date.now(),s=i.map(function(x){var C=V9(x,r);return x.dispose(),C}),o.stage2_rnet=Date.now()-a,u=s.length>1?Vt(s.map(function(x){return x.scores})):s[0].scores,d=(l=Array).from,[4,u.data()];case 2:return c=d.apply(l,[w.sent()]),u.dispose(),f=c.map(function(x,C){return{score:x,idx:C}}).filter(function(x){return x.score>e}).map(function(x){var C=x.idx;return C}),h=f.map(function(x){return t[x]}),m=f.map(function(x){return c[x]}),p=[],v=[],h.length>0&&(a=Date.now(),g=nu(h,m,.7),o.stage2_nms=Date.now()-a,y=g.map(function(x){var C=s[f[x]].regions.arraySync();return new sp(C[0][0],C[0][1],C[0][2],C[0][3])}),v=g.map(function(x){return m[x]}),p=g.map(function(x,C){return h[x].calibrate(y[C])})),s.forEach(function(x){x.regions.dispose(),x.scores.dispose()}),[2,{boxes:p,scores:v}]}})})}function U9(n,t){return xe(function(){var e=up(n,t);e=Kt(e,[2,2],[2,2],"same"),e=cr(e,t.conv4,"valid"),e=Li(e,t.prelu4_alpha);var r=ir(e,[e.shape[0],t.fc1.weights.shape[0]]),o=Vr(r,t.fc1),a=Li(o,t.prelu5_alpha),i=Vr(a,t.fc2_1),s=Xn(sl(i,1),1),u=oo(zt(i,s),1),c=Vr(a,t.fc2_2),l=Vr(a,t.fc2_3),d=jt(u,1)[1];return{scores:d,regions:c,points:l}})}function z9(n,t,e,r,o){return $e(this,void 0,void 0,function(){var a,i,s,u,c,l,d,f,h,m,p,v,g,y,w;return ke(this,function(x){switch(x.label){case 0:return a=Date.now(),[4,E2(n,t,{width:48,height:48})];case 1:return i=x.sent(),o.stage3_extractImagePatches=Date.now()-a,a=Date.now(),s=i.map(function(C){var _=U9(C,r);return C.dispose(),_}),o.stage3_onet=Date.now()-a,u=s.length>1?Vt(s.map(function(C){return C.scores})):s[0].scores,d=(l=Array).from,[4,u.data()];case 2:return c=d.apply(l,[x.sent()]),u.dispose(),f=c.map(function(C,_){return{score:C,idx:_}}).filter(function(C){return C.score>e}).map(function(C){var _=C.idx;return _}),h=f.map(function(C){var _=s[C].regions.arraySync();return new sp(_[0][0],_[0][1],_[0][2],_[0][3])}),m=f.map(function(C,_){return t[C].calibrate(h[_])}),p=f.map(function(C){return c[C]}),v=[],g=[],y=[],m.length>0&&(a=Date.now(),w=nu(m,p,.7,!1),o.stage3_nms=Date.now()-a,v=w.map(function(C){return m[C]}),g=w.map(function(C){return p[C]}),y=w.map(function(C,_){return Array(5).fill(0).map(function(E,S){var N=s[C].points.arraySync();return new ot(N[0][S]*(v[_].width+1)+v[_].left,N[0][S+5]*(v[_].height+1)+v[_].top)})})),s.forEach(function(C){C.regions.dispose(),C.scores.dispose(),C.points.dispose()}),[2,{boxes:v,scores:g,points:y}]}})})}var H9=function(n){De(t,n);function t(){return n.call(this,"Mtcnn")||this}return t.prototype.load=function(e){return $e(this,void 0,void 0,function(){return ke(this,function(r){return console.warn("mtcnn is deprecated and will be removed soon"),[2,n.prototype.load.call(this,e)]})})},t.prototype.loadFromDisk=function(e){return $e(this,void 0,void 0,function(){return ke(this,function(r){return console.warn("mtcnn is deprecated and will be removed soon"),[2,n.prototype.loadFromDisk.call(this,e)]})})},t.prototype.forwardInput=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o,a,i,s,u,c,l,d,f,h,m,p,v,g,y,w,x,C,_,E,S;return ke(this,function(N){switch(N.label){case 0:if(o=this.params,!o)throw new Error("Mtcnn - load model before inference");if(a=e.canvases[0],!a)throw new Error("Mtcnn - inputCanvas is not defined, note that passing tensors into Mtcnn.forwardInput is not supported yet.");return i={},s=Date.now(),u=xe(function(){return A9(Xn(Bh.fromPixels(a)).toFloat())}),c=function($){return u.dispose(),i.total=Date.now()-s,$},l=u.shape.slice(1),d=l[0],f=l[1],h=new b2(r),m=h.minFaceSize,p=h.scaleFactor,v=h.maxNumScales,g=h.scoreThresholds,y=h.scaleSteps,w=(y||F9(m,p,[d,f])).filter(function($){var A=ip($,[d,f]);return Math.min(A.width,A.height)>Nl}).slice(0,v),i.scales=w,i.pyramid=w.map(function($){return ip($,[d,f])}),x=Date.now(),[4,W9(u,w,g[0],o.pnet,i)];case 1:return C=N.sent(),i.total_stage1=Date.now()-x,C.boxes.length?(i.stage2_numInputBoxes=C.boxes.length,x=Date.now(),[4,j9(a,C.boxes,g[1],o.rnet,i)]):[2,c({results:[],stats:i})];case 2:return _=N.sent(),i.total_stage2=Date.now()-x,_.boxes.length?(i.stage3_numInputBoxes=_.boxes.length,x=Date.now(),[4,z9(a,_.boxes,g[2],o.onet,i)]):[2,c({results:[],stats:i})];case 3:return E=N.sent(),i.total_stage3=Date.now()-x,S=E.boxes.map(function($,A){return ep(zh({},new Wr(E.scores[A],new Uh($.left/f,$.top/d,$.width/f,$.height/d),{height:d,width:f})),new x5(E.points[A].map(function(P){return P.sub(new ot($.left,$.top)).div(new ot($.width,$.height))}),{width:$.width,height:$.height}))}),[2,c({results:S,stats:i})]}})})},t.prototype.forward=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return o=this.forwardInput,[4,Yt(e)];case 1:return[4,o.apply(this,[a.sent(),r])];case 2:return[2,a.sent().results]}})})},t.prototype.forwardWithStats=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return o=this.forwardInput,[4,Yt(e)];case 1:return[2,o.apply(this,[a.sent(),r])]}})})},t.prototype.getDefaultModelName=function(){return"mtcnn_model"},t.prototype.extractParamsFromWeigthMap=function(e){return M9(e)},t.prototype.extractParams=function(e){return O9(e)},t}(uo),G9=.4,q9=[new ot(1.603231,2.094468),new ot(6.041143,7.080126),new ot(2.882459,3.518061),new ot(4.266906,5.178857),new ot(9.041765,10.66308)],K9=[117.001,114.697,97.404],Y9=function(n){De(t,n);function t(){var e=this,r={withSeparableConvs:!0,iouThreshold:G9,classes:["face"],anchors:q9,meanRgb:K9,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]};return e=n.call(this,r)||this,e}return Object.defineProperty(t.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),t.prototype.locateFaces=function(e,r){return $e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return[4,this.detect(e,r)];case 1:return o=a.sent(),[2,o.map(function(i){return new Wr(i.score,i.relativeBox,{width:i.imageWidth,height:i.imageHeight})})]}})})},t.prototype.getDefaultModelName=function(){return"tiny_face_detector_model"},t.prototype.extractParamsFromWeigthMap=function(e){return n.prototype.extractParamsFromWeigthMap.call(this,e)},t}(C2),mn={ssdMobilenetv1:new x2,tinyFaceDetector:new Y9,tinyYolov2:new P9,mtcnn:new H9,faceLandmark68Net:new h2,faceLandmark68TinyNet:new X5,faceRecognitionNet:new r9,faceExpressionNet:new F5,ageGenderNet:new G5},S2=function(n){De(t,n);function t(e,r,o){var a=n.call(this)||this;return a.parentTask=e,a.input=r,a.extractedFaces=o,a}return t}(au),cp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o=this;return ke(this,function(a){switch(a.label){case 0:return[4,this.parentTask];case 1:return e=a.sent(),[4,El(e,this.input,function(i){return $e(o,void 0,void 0,function(){return ke(this,function(s){switch(s.label){case 0:return[4,Promise.all(i.map(function(u){return mn.faceExpressionNet.predictExpressions(u)}))];case 1:return[2,s.sent()]}})})},this.extractedFaces)];case 2:return r=a.sent(),[2,e.map(function(i,s){return l2(i,r[s])})]}})})},t.prototype.withAgeAndGender=function(){return new hp(this,this.input)},t}(S2),lp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return[4,this.parentTask];case 1:return e=o.sent(),e?[4,ap(e,this.input,function(a){return mn.faceExpressionNet.predictExpressions(a)},this.extractedFaces)]:[2];case 2:return r=o.sent(),[2,l2(e,r)]}})})},t.prototype.withAgeAndGender=function(){return new pp(this,this.input)},t}(S2),dp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.withAgeAndGender=function(){return new vp(this,this.input)},t.prototype.withFaceDescriptors=function(){return new gp(this,this.input)},t}(cp),fp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.withAgeAndGender=function(){return new mp(this,this.input)},t.prototype.withFaceDescriptor=function(){return new yp(this,this.input)},t}(lp),N2=function(n){De(t,n);function t(e,r,o){var a=n.call(this)||this;return a.parentTask=e,a.input=r,a.extractedFaces=o,a}return t}(au),hp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o=this;return ke(this,function(a){switch(a.label){case 0:return[4,this.parentTask];case 1:return e=a.sent(),[4,El(e,this.input,function(i){return $e(o,void 0,void 0,function(){return ke(this,function(s){switch(s.label){case 0:return[4,Promise.all(i.map(function(u){return mn.ageGenderNet.predictAgeAndGender(u)}))];case 1:return[2,s.sent()]}})})},this.extractedFaces)];case 2:return r=a.sent(),[2,e.map(function(i,s){var u=r[s],c=u.age,l=u.gender,d=u.genderProbability;return g2(y2(i,l,d),c)})]}})})},t.prototype.withFaceExpressions=function(){return new cp(this,this.input)},t}(N2),pp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o,a,i;return ke(this,function(s){switch(s.label){case 0:return[4,this.parentTask];case 1:return e=s.sent(),e?[4,ap(e,this.input,function(u){return mn.ageGenderNet.predictAgeAndGender(u)},this.extractedFaces)]:[2];case 2:return r=s.sent(),o=r.age,a=r.gender,i=r.genderProbability,[2,g2(y2(e,a,i),o)]}})})},t.prototype.withFaceExpressions=function(){return new lp(this,this.input)},t}(N2),vp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.withFaceExpressions=function(){return new dp(this,this.input)},t.prototype.withFaceDescriptors=function(){return new gp(this,this.input)},t}(hp),mp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.withFaceExpressions=function(){return new fp(this,this.input)},t.prototype.withFaceDescriptor=function(){return new yp(this,this.input)},t}(pp),$2=function(n){De(t,n);function t(e,r){var o=n.call(this)||this;return o.parentTask=e,o.input=r,o}return t}(au),gp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return[4,this.parentTask];case 1:return e=o.sent(),[4,El(e,this.input,function(a){return Promise.all(a.map(function(i){return mn.faceRecognitionNet.computeFaceDescriptor(i)}))},null,function(a){return a.landmarks.align(null,{useDlibAlignment:!0})})];case 2:return r=o.sent(),[2,r.map(function(a,i){return m2(e[i],a)})]}})})},t.prototype.withFaceExpressions=function(){return new dp(this,this.input)},t.prototype.withAgeAndGender=function(){return new vp(this,this.input)},t}($2),yp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return[4,this.parentTask];case 1:return e=o.sent(),e?[4,ap(e,this.input,function(a){return mn.faceRecognitionNet.computeFaceDescriptor(a)},null,function(a){return a.landmarks.align(null,{useDlibAlignment:!0})})]:[2];case 2:return r=o.sent(),[2,m2(e,r)]}})})},t.prototype.withFaceExpressions=function(){return new fp(this,this.input)},t.prototype.withAgeAndGender=function(){return new mp(this,this.input)},t}($2),k2=function(n){De(t,n);function t(e,r,o){var a=n.call(this)||this;return a.parentTask=e,a.input=r,a.useTinyLandmarkNet=o,a}return Object.defineProperty(t.prototype,"landmarkNet",{get:function(){return this.useTinyLandmarkNet?mn.faceLandmark68TinyNet:mn.faceLandmark68Net},enumerable:!0,configurable:!0}),t}(au),X9=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o,a,i,s=this;return ke(this,function(u){switch(u.label){case 0:return[4,this.parentTask];case 1:return e=u.sent(),r=e.map(function(c){return c.detection}),this.input instanceof bt?[4,Yh(this.input,r)]:[3,3];case 2:return a=u.sent(),[3,5];case 3:return[4,Kh(this.input,r)];case 4:a=u.sent(),u.label=5;case 5:return o=a,[4,Promise.all(o.map(function(c){return s.landmarkNet.detectLandmarks(c)}))];case 6:return i=u.sent(),o.forEach(function(c){return c instanceof bt&&c.dispose()}),[2,e.map(function(c,l){return ep(c,i[l])})]}})})},t.prototype.withFaceExpressions=function(){return new dp(this,this.input)},t.prototype.withAgeAndGender=function(){return new vp(this,this.input)},t.prototype.withFaceDescriptors=function(){return new gp(this,this.input)},t}(k2),Z9=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o,a,i;return ke(this,function(s){switch(s.label){case 0:return[4,this.parentTask];case 1:return e=s.sent(),e?(r=e.detection,this.input instanceof bt?[4,Yh(this.input,[r])]:[3,3]):[2];case 2:return a=s.sent(),[3,5];case 3:return[4,Kh(this.input,[r])];case 4:a=s.sent(),s.label=5;case 5:return o=a,[4,this.landmarkNet.detectLandmarks(o[0])];case 6:return i=s.sent(),o.forEach(function(u){return u instanceof bt&&u.dispose()}),[2,ep(e,i)]}})})},t.prototype.withFaceExpressions=function(){return new fp(this,this.input)},t.prototype.withAgeAndGender=function(){return new mp(this,this.input)},t.prototype.withFaceDescriptor=function(){return new yp(this,this.input)},t}(k2),P2=function(n){De(t,n);function t(e,r){r===void 0&&(r=new ou);var o=n.call(this)||this;return o.input=e,o.options=r,o}return t}(au),I2=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o,a;return ke(this,function(i){switch(i.label){case 0:return e=this,r=e.input,o=e.options,o instanceof b2?[4,mn.mtcnn.forward(r,o)]:[3,2];case 1:return[2,i.sent().map(function(s){return s.detection})];case 2:if(a=o instanceof I9?function(s){return mn.tinyFaceDetector.locateFaces(s,o)}:o instanceof ou?function(s){return mn.ssdMobilenetv1.locateFaces(s,o)}:o instanceof op?function(s){return mn.tinyYolov2.locateFaces(s,o)}:null,!a)throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TinyYolov2Options");return[2,a(r)]}})})},t.prototype.runAndExtendWithFaceDetections=function(){var e=this;return new Promise(function(r){return $e(e,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return[4,this.run()];case 1:return o=a.sent(),[2,r(o.map(function(i){return zh({},i)}))]}})})})},t.prototype.withFaceLandmarks=function(e){return e===void 0&&(e=!1),new X9(this.runAndExtendWithFaceDetections(),this.input,e)},t.prototype.withFaceExpressions=function(){return new cp(this.runAndExtendWithFaceDetections(),this.input)},t.prototype.withAgeAndGender=function(){return new hp(this.runAndExtendWithFaceDetections(),this.input)},t}(P2);(function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return[4,new I2(this.input,this.options)];case 1:return e=o.sent(),r=e[0],e.forEach(function(a){a.score>r.score&&(r=a)}),[2,r]}})})},t.prototype.runAndExtendWithFaceDetection=function(){var e=this;return new Promise(function(r){return $e(e,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return[4,this.run()];case 1:return o=a.sent(),[2,r(o?zh({},o):void 0)]}})})})},t.prototype.withFaceLandmarks=function(e){return e===void 0&&(e=!1),new Z9(this.runAndExtendWithFaceDetection(),this.input,e)},t.prototype.withFaceExpressions=function(){return new lp(this.runAndExtendWithFaceDetection(),this.input)},t.prototype.withAgeAndGender=function(){return new pp(this.runAndExtendWithFaceDetection(),this.input)},t})(P2);function Q9(n,t){return t===void 0&&(t=new ou),new I2(n,t)}function J9(n,t){if(n.length!==t.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");var e=Array.from(n),r=Array.from(t);return Math.sqrt(e.map(function(o,a){return o-r[a]}).reduce(function(o,a){return o+Math.pow(a,2)},0))}(function(){function n(t,e){e===void 0&&(e=.6),this._distanceThreshold=e;var r=Array.isArray(t)?t:[t];if(!r.length)throw new Error("FaceRecognizer.constructor - expected atleast one input");var o=1,a=function(){return"person "+o++};this._labeledDescriptors=r.map(function(i){if(i instanceof ml)return i;if(i instanceof Float32Array)return new ml(a(),[i]);if(i.descriptor&&i.descriptor instanceof Float32Array)return new ml(a(),[i.descriptor]);throw new Error("FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>")})}return Object.defineProperty(n.prototype,"labeledDescriptors",{get:function(){return this._labeledDescriptors},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"distanceThreshold",{get:function(){return this._distanceThreshold},enumerable:!0,configurable:!0}),n.prototype.computeMeanDistance=function(t,e){return e.map(function(r){return J9(r,t)}).reduce(function(r,o){return r+o},0)/(e.length||1)},n.prototype.matchDescriptor=function(t){var e=this;return this.labeledDescriptors.map(function(r){var o=r.descriptors,a=r.label;return new Ub(a,e.computeMeanDistance(t,o))}).reduce(function(r,o){return r.distance<o.distance?r:o})},n.prototype.findBestMatch=function(t){var e=this.matchDescriptor(t);return e.distance<this.distanceThreshold?e:new Ub("unknown",e.distance)},n.prototype.toJSON=function(){return{distanceThreshold:this.distanceThreshold,labeledDescriptors:this.labeledDescriptors.map(function(t){return t.toJSON()})}},n.fromJSON=function(t){var e=t.labeledDescriptors.map(function(r){return ml.fromJSON(r)});return new n(e,t.distanceThreshold)},n})();function fo(n){return Array.isArray?Array.isArray(n):O2(n)==="[object Array]"}function eD(n){if(typeof n=="string")return n;let t=n+"";return t=="0"&&1/n==-1/0?"-0":t}function tD(n){return n==null?"":eD(n)}function zr(n){return typeof n=="string"}function A2(n){return typeof n=="number"}function nD(n){return n===!0||n===!1||rD(n)&&O2(n)=="[object Boolean]"}function T2(n){return typeof n=="object"}function rD(n){return T2(n)&&n!==null}function jn(n){return n!=null}function bp(n){return!n.trim().length}function O2(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}const oD="Incorrect 'index' type",aD=n=>`Invalid value for key ${n}`,iD=n=>`Pattern length exceeds max of ${n}.`,sD=n=>`Missing ${n} property in key`,uD=n=>`Property 'weight' in key '${n}' must be a positive integer`,D2=Object.prototype.hasOwnProperty;class cD{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(r=>{let o=M2(r);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(r=>{r.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function M2(n){let t=null,e=null,r=null,o=1,a=null;if(zr(n)||fo(n))r=n,t=F2(n),e=xp(n);else{if(!D2.call(n,"name"))throw new Error(sD("name"));const i=n.name;if(r=i,D2.call(n,"weight")&&(o=n.weight,o<=0))throw new Error(uD(i));t=F2(i),e=xp(i),a=n.getFn}return{path:t,id:e,weight:o,src:r,getFn:a}}function F2(n){return fo(n)?n:n.split(".")}function xp(n){return fo(n)?n.join("."):n}function lD(n,t){let e=[],r=!1;const o=(a,i,s)=>{if(jn(a))if(!i[s])e.push(a);else{let u=i[s];const c=a[u];if(!jn(c))return;if(s===i.length-1&&(zr(c)||A2(c)||nD(c)))e.push(tD(c));else if(fo(c)){r=!0;for(let l=0,d=c.length;l<d;l+=1)o(c[l],i,s+1)}else i.length&&o(c,i,s+1)}};return o(n,zr(t)?t.split("."):t,0),r?e:e[0]}var Ae={...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(n,t)=>n.score===t.score?n.idx<t.idx?-1:1:n.score<t.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,getFn:lD,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const dD=/[^ ]+/g;function fD(n=1,t=3){const e=new Map,r=Math.pow(10,t);return{get(o){const a=o.match(dD).length;if(e.has(a))return e.get(a);const i=1/Math.pow(a,.5*n),s=parseFloat(Math.round(i*r)/r);return e.set(a,s),s},clear(){e.clear()}}}class wp{constructor({getFn:t=Ae.getFn,fieldNormWeight:e=Ae.fieldNormWeight}={}){this.norm=fD(e,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,r)=>{this._keysMap[e.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,zr(this.docs[0])?this.docs.forEach((t,e)=>{this._addString(t,e)}):this.docs.forEach((t,e)=>{this._addObject(t,e)}),this.norm.clear())}add(t){const e=this.size();zr(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,r=this.size();e<r;e+=1)this.records[e].i-=1}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!jn(t)||bp(t))return;let r={v:t,i:e,n:this.norm.get(t)};this.records.push(r)}_addObject(t,e){let r={i:e,$:{}};this.keys.forEach((o,a)=>{let i=o.getFn?o.getFn(t):this.getFn(t,o.path);if(jn(i)){if(fo(i)){let s=[];const u=[{nestedArrIndex:-1,value:i}];for(;u.length;){const{nestedArrIndex:c,value:l}=u.pop();if(jn(l))if(zr(l)&&!bp(l)){let d={v:l,i:c,n:this.norm.get(l)};s.push(d)}else fo(l)&&l.forEach((d,f)=>{u.push({nestedArrIndex:f,value:d})})}r.$[a]=s}else if(zr(i)&&!bp(i)){let s={v:i,n:this.norm.get(i)};r.$[a]=s}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function R2(n,t,{getFn:e=Ae.getFn,fieldNormWeight:r=Ae.fieldNormWeight}={}){const o=new wp({getFn:e,fieldNormWeight:r});return o.setKeys(n.map(M2)),o.setSources(t),o.create(),o}function hD(n,{getFn:t=Ae.getFn,fieldNormWeight:e=Ae.fieldNormWeight}={}){const{keys:r,records:o}=n,a=new wp({getFn:t,fieldNormWeight:e});return a.setKeys(r),a.setIndexRecords(o),a}function $l(n,{errors:t=0,currentLocation:e=0,expectedLocation:r=0,distance:o=Ae.distance,ignoreLocation:a=Ae.ignoreLocation}={}){const i=t/n.length;if(a)return i;const s=Math.abs(r-e);return o?i+s/o:s?1:i}function pD(n=[],t=Ae.minMatchCharLength){let e=[],r=-1,o=-1,a=0;for(let i=n.length;a<i;a+=1){let s=n[a];s&&r===-1?r=a:!s&&r!==-1&&(o=a-1,o-r+1>=t&&e.push([r,o]),r=-1)}return n[a-1]&&a-r>=t&&e.push([r,a-1]),e}const Wa=32;function vD(n,t,e,{location:r=Ae.location,distance:o=Ae.distance,threshold:a=Ae.threshold,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:s=Ae.minMatchCharLength,includeMatches:u=Ae.includeMatches,ignoreLocation:c=Ae.ignoreLocation}={}){if(t.length>Wa)throw new Error(iD(Wa));const l=t.length,d=n.length,f=Math.max(0,Math.min(r,d));let h=a,m=f;const p=s>1||u,v=p?Array(d):[];let g;for(;(g=n.indexOf(t,m))>-1;){let E=$l(t,{currentLocation:g,expectedLocation:f,distance:o,ignoreLocation:c});if(h=Math.min(E,h),m=g+l,p){let S=0;for(;S<l;)v[g+S]=1,S+=1}}m=-1;let y=[],w=1,x=l+d;const C=1<<l-1;for(let E=0;E<l;E+=1){let S=0,N=x;for(;S<N;)$l(t,{errors:E,currentLocation:f+N,expectedLocation:f,distance:o,ignoreLocation:c})<=h?S=N:x=N,N=Math.floor((x-S)/2+S);x=N;let $=Math.max(1,f-N+1),A=i?d:Math.min(f+N,d)+l,P=Array(A+2);P[A+1]=(1<<E)-1;for(let B=A;B>=$;B-=1){let z=B-1,H=e[n.charAt(z)];if(p&&(v[z]=+!!H),P[B]=(P[B+1]<<1|1)&H,E&&(P[B]|=(y[B+1]|y[B])<<1|1|y[B+1]),P[B]&C&&(w=$l(t,{errors:E,currentLocation:z,expectedLocation:f,distance:o,ignoreLocation:c}),w<=h)){if(h=w,m=z,m<=f)break;$=Math.max(1,2*f-m)}}if($l(t,{errors:E+1,currentLocation:f,expectedLocation:f,distance:o,ignoreLocation:c})>h)break;y=P}const _={isMatch:m>=0,score:Math.max(.001,w)};if(p){const E=pD(v,s);E.length?u&&(_.indices=E):_.isMatch=!1}return _}function mD(n){let t={};for(let e=0,r=n.length;e<r;e+=1){const o=n.charAt(e);t[o]=(t[o]||0)|1<<r-e-1}return t}const kl=String.prototype.normalize?n=>n.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,""):n=>n;class L2{constructor(t,{location:e=Ae.location,threshold:r=Ae.threshold,distance:o=Ae.distance,includeMatches:a=Ae.includeMatches,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:s=Ae.minMatchCharLength,isCaseSensitive:u=Ae.isCaseSensitive,ignoreDiacritics:c=Ae.ignoreDiacritics,ignoreLocation:l=Ae.ignoreLocation}={}){if(this.options={location:e,threshold:r,distance:o,includeMatches:a,findAllMatches:i,minMatchCharLength:s,isCaseSensitive:u,ignoreDiacritics:c,ignoreLocation:l},t=u?t:t.toLowerCase(),t=c?kl(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const d=(h,m)=>{this.chunks.push({pattern:h,alphabet:mD(h),startIndex:m})},f=this.pattern.length;if(f>Wa){let h=0;const m=f%Wa,p=f-m;for(;h<p;)d(this.pattern.substr(h,Wa),h),h+=Wa;if(m){const v=f-Wa;d(this.pattern.substr(v),v)}}else d(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:r,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=r?kl(t):t,this.pattern===t){let p={isMatch:!0,score:0};return o&&(p.indices=[[0,t.length-1]]),p}const{location:a,distance:i,threshold:s,findAllMatches:u,minMatchCharLength:c,ignoreLocation:l}=this.options;let d=[],f=0,h=!1;this.chunks.forEach(({pattern:p,alphabet:v,startIndex:g})=>{const{isMatch:y,score:w,indices:x}=vD(t,p,v,{location:a+g,distance:i,threshold:s,findAllMatches:u,minMatchCharLength:c,includeMatches:o,ignoreLocation:l});y&&(h=!0),f+=w,y&&x&&(d=[...d,...x])});let m={isMatch:h,score:h?f/this.chunks.length:1};return h&&o&&(m.indices=d),m}}class qo{constructor(t){this.pattern=t}static isMultiMatch(t){return B2(t,this.multiRegex)}static isSingleMatch(t){return B2(t,this.singleRegex)}search(){}}function B2(n,t){const e=n.match(t);return e?e[1]:null}class gD extends qo{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class yD extends qo{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const r=t.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,t.length-1]}}}class bD extends qo{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class xD extends qo{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class wD extends qo{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class CD extends qo{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class W2 extends qo{constructor(t,{location:e=Ae.location,threshold:r=Ae.threshold,distance:o=Ae.distance,includeMatches:a=Ae.includeMatches,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:s=Ae.minMatchCharLength,isCaseSensitive:u=Ae.isCaseSensitive,ignoreDiacritics:c=Ae.ignoreDiacritics,ignoreLocation:l=Ae.ignoreLocation}={}){super(t),this._bitapSearch=new L2(t,{location:e,threshold:r,distance:o,includeMatches:a,findAllMatches:i,minMatchCharLength:s,isCaseSensitive:u,ignoreDiacritics:c,ignoreLocation:l})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class V2 extends qo{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,r;const o=[],a=this.pattern.length;for(;(r=t.indexOf(this.pattern,e))>-1;)e=r+a,o.push([r,e-1]);const i=!!o.length;return{isMatch:i,score:i?0:1,indices:o}}}const Cp=[gD,V2,bD,xD,CD,wD,yD,W2],j2=Cp.length,_D=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,ED="|";function SD(n,t={}){return n.split(ED).map(e=>{let r=e.trim().split(_D).filter(a=>a&&!!a.trim()),o=[];for(let a=0,i=r.length;a<i;a+=1){const s=r[a];let u=!1,c=-1;for(;!u&&++c<j2;){const l=Cp[c];let d=l.isMultiMatch(s);d&&(o.push(new l(d,t)),u=!0)}if(!u)for(c=-1;++c<j2;){const l=Cp[c];let d=l.isSingleMatch(s);if(d){o.push(new l(d,t));break}}}return o})}const ND=new Set([W2.type,V2.type]);class $D{constructor(t,{isCaseSensitive:e=Ae.isCaseSensitive,ignoreDiacritics:r=Ae.ignoreDiacritics,includeMatches:o=Ae.includeMatches,minMatchCharLength:a=Ae.minMatchCharLength,ignoreLocation:i=Ae.ignoreLocation,findAllMatches:s=Ae.findAllMatches,location:u=Ae.location,threshold:c=Ae.threshold,distance:l=Ae.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:r,includeMatches:o,minMatchCharLength:a,findAllMatches:s,ignoreLocation:i,location:u,threshold:c,distance:l},t=e?t:t.toLowerCase(),t=r?kl(t):t,this.pattern=t,this.query=SD(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:o,ignoreDiacritics:a}=this.options;t=o?t:t.toLowerCase(),t=a?kl(t):t;let i=0,s=[],u=0;for(let c=0,l=e.length;c<l;c+=1){const d=e[c];s.length=0,i=0;for(let f=0,h=d.length;f<h;f+=1){const m=d[f],{isMatch:p,indices:v,score:g}=m.search(t);if(p){if(i+=1,u+=g,r){const y=m.constructor.type;ND.has(y)?s=[...s,...v]:s.push(v)}}else{u=0,i=0,s.length=0;break}}if(i){let f={isMatch:!0,score:u/i};return r&&(f.indices=s),f}}return{isMatch:!1,score:1}}}const _p=[];function kD(...n){_p.push(...n)}function Ep(n,t){for(let e=0,r=_p.length;e<r;e+=1){let o=_p[e];if(o.condition(n,t))return new o(n,t)}return new L2(n,t)}const Pl={AND:"$and",OR:"$or"},Sp={PATH:"$path",PATTERN:"$val"},Np=n=>!!(n[Pl.AND]||n[Pl.OR]),PD=n=>!!n[Sp.PATH],ID=n=>!fo(n)&&T2(n)&&!Np(n),U2=n=>({[Pl.AND]:Object.keys(n).map(t=>({[t]:n[t]}))});function z2(n,t,{auto:e=!0}={}){const r=o=>{let a=Object.keys(o);const i=PD(o);if(!i&&a.length>1&&!Np(o))return r(U2(o));if(ID(o)){const u=i?o[Sp.PATH]:a[0],c=i?o[Sp.PATTERN]:o[u];if(!zr(c))throw new Error(aD(u));const l={keyId:xp(u),pattern:c};return e&&(l.searcher=Ep(c,t)),l}let s={children:[],operator:a[0]};return a.forEach(u=>{const c=o[u];fo(c)&&c.forEach(l=>{s.children.push(r(l))})}),s};return Np(n)||(n=U2(n)),r(n)}function AD(n,{ignoreFieldNorm:t=Ae.ignoreFieldNorm}){n.forEach(e=>{let r=1;e.matches.forEach(({key:o,norm:a,score:i})=>{const s=o?o.weight:null;r*=Math.pow(i===0&&s?Number.EPSILON:i,(s||1)*(t?1:a))}),e.score=r})}function TD(n,t){const e=n.matches;t.matches=[],jn(e)&&e.forEach(r=>{if(!jn(r.indices)||!r.indices.length)return;const{indices:o,value:a}=r;let i={indices:o,value:a};r.key&&(i.key=r.key.src),r.idx>-1&&(i.refIndex=r.idx),t.matches.push(i)})}function OD(n,t){t.score=n.score}function DD(n,t,{includeMatches:e=Ae.includeMatches,includeScore:r=Ae.includeScore}={}){const o=[];return e&&o.push(TD),r&&o.push(OD),n.map(a=>{const{idx:i}=a,s={item:t[i],refIndex:i};return o.length&&o.forEach(u=>{u(a,s)}),s})}class Bi{constructor(t,e={},r){this.options={...Ae,...e},this.options.useExtendedSearch,this._keyStore=new cD(this.options.keys),this.setCollection(t,r)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof wp))throw new Error(oD);this._myIndex=e||R2(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){jn(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let r=0,o=this._docs.length;r<o;r+=1){const a=this._docs[r];t(a,r)&&(this.removeAt(r),r-=1,o-=1,e.push(a))}return e}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:e=-1}={}){const{includeMatches:r,includeScore:o,shouldSort:a,sortFn:i,ignoreFieldNorm:s}=this.options;let u=zr(t)?zr(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return AD(u,{ignoreFieldNorm:s}),a&&u.sort(i),A2(e)&&e>-1&&(u=u.slice(0,e)),DD(u,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(t){const e=Ep(t,this.options),{records:r}=this._myIndex,o=[];return r.forEach(({v:a,i,n:s})=>{if(!jn(a))return;const{isMatch:u,score:c,indices:l}=e.searchIn(a);u&&o.push({item:a,idx:i,matches:[{score:c,value:a,norm:s,indices:l}]})}),o}_searchLogical(t){const e=z2(t,this.options),r=(s,u,c)=>{if(!s.children){const{keyId:d,searcher:f}=s,h=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(u,d),searcher:f});return h&&h.length?[{idx:c,item:u,matches:h}]:[]}const l=[];for(let d=0,f=s.children.length;d<f;d+=1){const h=s.children[d],m=r(h,u,c);if(m.length)l.push(...m);else if(s.operator===Pl.AND)return[]}return l},o=this._myIndex.records,a={},i=[];return o.forEach(({$:s,i:u})=>{if(jn(s)){let c=r(e,s,u);c.length&&(a[u]||(a[u]={idx:u,item:s,matches:[]},i.push(a[u])),c.forEach(({matches:l})=>{a[u].matches.push(...l)}))}}),i}_searchObjectList(t){const e=Ep(t,this.options),{keys:r,records:o}=this._myIndex,a=[];return o.forEach(({$:i,i:s})=>{if(!jn(i))return;let u=[];r.forEach((c,l)=>{u.push(...this._findMatches({key:c,value:i[l],searcher:e}))}),u.length&&a.push({idx:s,item:i,matches:u})}),a}_findMatches({key:t,value:e,searcher:r}){if(!jn(e))return[];let o=[];if(fo(e))e.forEach(({v:a,i,n:s})=>{if(!jn(a))return;const{isMatch:u,score:c,indices:l}=r.searchIn(a);u&&o.push({score:c,key:t,value:a,idx:i,norm:s,indices:l})});else{const{v:a,n:i}=e,{isMatch:s,score:u,indices:c}=r.searchIn(a);s&&o.push({score:u,key:t,value:a,norm:i,indices:c})}return o}}Bi.version="7.1.0",Bi.createIndex=R2,Bi.parseIndex=hD,Bi.config=Ae,Bi.parseQuery=z2,kD($D);const MD=D.createContext(void 0);let $p;const FD=({apiEndpoint:n,children:t})=>(D.useEffect(()=>{$p=n},[n]),b.jsx(MD.Provider,{value:{apiEndpoint:n},children:t})),RD=()=>{if(!$p)throw new Error("ApiEndpoint not initialized. Make sure ApiProvider is mounted.");return $p};typeof window>"u"&&(async()=>{const{Canvas:n,Image:t,ImageData:e,loadImage:r}=await Promise.resolve().then(()=>dz);global.Image=t,global.HTMLImageElement=t,global.ImageData=e,global.HTMLCanvasElement=n,global.CanvasRenderingContext2D=n,global.loadImage=r,rn.monkeyPatch({Canvas:n,Image:t,ImageData:e,createCanvasElement:()=>new n(1,1),createImageElement:()=>new t})})();class LD{constructor(){km(this,"signalMap");km(this,"modelsLoaded",!1);this.signalMap={id:["date of birth","birth date","place of birth","id","identification","identity card","permit","valid until","expiration date","given name","surname","sex","gender","height","weight","address","issuing authority","issued by","card number","personal number","nationality"],passport:["passport","passport number","country code","issuing country","issuing state","place of issue","place of birth","date of issue","date of expiry","expiry date","valid until","authority","surname","given name","name","sex","nationality","type","holder","mrz","document","travel","abroad","citizen"],license:["license","driver","driver license","dl number","licence number","permit","valid until","date of birth","birth date","issue date","expiration date","holder's signature","authority","class","restrictions","endorsements","sex","eyes","hair","height","weight","organ donor","address"],voterId:["voter","voting","voter id","voter card","elector","elector's name","father's name","electoral roll","polling station","constituency","elector id","serial number","sex","age","dob","date of birth","part number","section","epic","identity card","address"],default:["name","id","date","dob","expiry","number","document","issued"]}}async validateIdCard(t,e){let r=t;if(typeof t!="string"){const s=await t.arrayBuffer(),c=Buffer.from(s).toString("base64");r=`data:${t.type};base64,${c}`}const{data:{text:o}}=await Ak.recognize(r,"eng"),a=this.signalMap[e]||this.signalMap.default;console.log("OCR Result:",{text:o});let i=a.some(s=>{const u=o.toLowerCase().includes(s);return u&&console.log(`Found ${e} match:`,s),u});if(!i){const u=new Bi(a,{includeScore:!0,threshold:.6}).search(o.toLowerCase());i=u.length>0,i&&console.log("Found fuzzy match:",u[0].item,u[0].score,{found:u})}return{type:e,passed:i,textSnippet:o.slice(0,200),fullText:o}}async loadModels(){if(this.modelsLoaded)return;const e=`${RD()}/api/models`;await Promise.all([mn.ssdMobilenetv1.loadFromUri(e),mn.faceLandmark68Net.loadFromUri(e),mn.faceRecognitionNet.loadFromUri(e)]),this.modelsLoaded=!0}async validateFace(t){await this.loadModels();let e=t;if(typeof t!="string"){const i=await t.arrayBuffer(),u=Buffer.from(i).toString("base64");e=`data:${t.type};base64,${u}`}const r=await this.fileToImage(e),o=await Q9(r,new ou);return{type:"face",passed:o.length===1,facesDetected:o.length}}async fileToImage(t){return new Promise((e,r)=>{const o=new Image;if(o.onload=()=>e(o),o.onerror=r,typeof t=="string")o.src=t;else{const a=new FileReader;a.onload=()=>{o.src=a.result},a.onerror=r,a.readAsDataURL(t)}})}}const H2=new LD,BD=(n,t,e,r,o,a,i)=>{const[s,u]=D.useState(null),[c,l]=D.useState(null),[d,f]=D.useState({x:0,y:0,w:320,h:192}),h=D.useRef(`frameMask-${Math.random().toString(36).slice(2)}`),{toast:m}=Qu(),p=D.useMemo(()=>c?URL.createObjectURL(c):null,[c]),v=vi.find(x=>x.id===i);D.useEffect(()=>{e.current&&s&&(e.current.srcObject=s)},[s]),D.useEffect(()=>()=>{p&&URL.revokeObjectURL(p)},[p]);const g=D.useCallback(async()=>{try{const x=await navigator.mediaDevices.getUserMedia({video:{facingMode:n==="selfie"?"user":"environment",width:{ideal:9999},height:{ideal:9999}}});u(x)}catch{try{const x=await navigator.mediaDevices.getUserMedia({video:{facingMode:n==="selfie"?"user":"environment",width:{ideal:1280},height:{ideal:720}}});u(x)}catch{m({title:"Camera Error",description:"Unable to access camera. Please check permissions.",variant:"destructive"})}}},[n,m]),y=D.useCallback(()=>{s&&(s.getTracks().forEach(x=>x.stop()),u(null))},[s]),w=D.useCallback(async()=>{if(!e.current||!r.current||!o.current)return;const x=e.current,C=r.current,_=C.getContext("2d");if(!_)return;const E=x.videoWidth,S=x.videoHeight;if(n==="selfie"){C.width=E,C.height=S,_.drawImage(x,0,0,E,S),C.toBlob(async L=>{if(!L)return;const K=new File([L],`${n}-${Date.now()}.jpg`,{type:"image/jpeg"});try{const q=document.createElement("canvas"),Z=q.getContext("2d");if(!Z)return;const oe=x.getBoundingClientRect(),ae=E/oe.width,X=S/oe.height,re=10,ce=(d.x-re)*ae,ue=(d.y-re)*X,se=(d.w+2*re)*ae,ee=(d.h+2*re)*X;q.width=se,q.height=ee,Z.drawImage(x,ce,ue,se,ee,0,0,se,ee);const _e=await new Promise(Ze=>q.toBlob(Ze,"image/jpeg",.8));if(!_e)return;const Me=new File([_e],`crop-${Date.now()}.jpg`,{type:"image/jpeg"});if(m({title:"Validating...",description:"Checking if the photo has a face..."}),!(await H2.validateFace(Me)).passed){m({title:"Validation Failed",description:"No face detected. Please retake your selfie.",variant:"destructive"});return}m({title:"Photo Captured",description:"Selfie captured successfully"}),l(K),y()}catch(q){console.error("Face validation error:",q),m({title:"Validation Error",description:"We couldn’t process the selfie. Please try again.",variant:"destructive"})}},"image/jpeg",.8);return}const N=x.getBoundingClientRect(),$=E/N.width,A=S/N.height,P=10,j=(d.x-P)*$,B=(d.y-P)*A,z=(d.w+2*P)*$,H=(d.h+2*P)*A,F=Math.max(0,Math.min(j,E-z)),M=Math.max(0,Math.min(B,S-H)),O=Math.min(z,E-F),I=Math.min(H,S-M);if(C.width=t==="circular"?Math.max(O,I):O,C.height=t==="circular"?Math.max(O,I):I,t==="circular"){const L=Math.min(O,I)/2;_.beginPath(),_.arc(C.width/2,C.height/2,L+P*$,0,Math.PI*2),_.clip(),_.drawImage(x,F-(C.width-O)/2,M-(C.height-I)/2,C.width,C.height,0,0,C.width,C.height)}else _.drawImage(x,F,M,O,I,0,0,C.width,C.height);C.toBlob(async L=>{if(!L)return;const K=new File([L],`${n}-${Date.now()}.jpg`,{type:"image/jpeg"});try{if(m({title:"Validating...",description:`Checking if the photo looks like ${v.title} ...`}),!(await H2.validateIdCard(K,i)).passed){m({title:"Validation Failed",description:`This doesn’t look like ${v.title} card. Try again.`,variant:"destructive"});return}l(K),y(),m({title:"Photo Captured",description:`${v.title} validated successfully`})}catch(q){console.error(q),m({title:"OCR Error",description:"We couldn’t process the photo. Please try again.",variant:"destructive"})}},"image/jpeg",.8)},[n,y,m,t,d,e,r,o]);return D.useEffect(()=>(!c&&!s&&g(),()=>{y()}),[c,s,g,y]),D.useEffect(()=>{if(!o.current||!a.current)return;const x=()=>{const _=o.current.getBoundingClientRect(),E=a.current.getBoundingClientRect();f({x:Math.round(E.left-_.left),y:Math.round(E.top-_.top),w:Math.round(E.width),h:Math.round(E.height)})};x();const C=new ResizeObserver(x);return C.observe(a.current),C.observe(o.current),window.addEventListener("resize",x),window.addEventListener("scroll",x,!0),()=>{C.disconnect(),window.removeEventListener("resize",x),window.removeEventListener("scroll",x,!0)}},[t,s,o,a]),{stream:s,photo:c,setPhoto:l,hole:d,maskId:h.current,photoUrl:p,capturePhoto:w}},kp=768;function WD(){const[n,t]=k.useState(void 0);return k.useEffect(()=>{const e=window.matchMedia(`(max-width: ${kp-1}px)`),r=()=>{t(window.innerWidth<kp)};return e.addEventListener("change",r),t(window.innerWidth<kp),()=>e.removeEventListener("change",r)},[]),!!n}const VD={"id-front":"ID Front","id-back":"ID Back",selfie:"Selfie"},Wi=({currentStep:n,onRetake:t,onConfirm:e,onBack:r,title:o,description:a,frameType:i,documentTypeId:s})=>{const u=D.useRef(null),c=D.useRef(null),l=D.useRef(null),d=D.useRef(null),f=WD(),{stream:h,photo:m,setPhoto:p,hole:v,maskId:g,photoUrl:y,capturePhoto:w}=BD(n,i,u,c,l,d,s),x=!!h,C=()=>{p(null),r()},_=()=>{p(null),t()},E=()=>{m&&e(m),m&&e(m),p(null)},S=v.x+v.w/2,N=v.y+v.h/2,$=Math.max(v.w,v.h)/2,A=()=>{const P=VD[n]||"Photo";return b.jsx(hn,{className:"w-full max-w-md mx-auto",children:b.jsxs(pn,{className:"p-6",children:[b.jsx(Do,{title:`Review ${P}`,subTitle:"Make sure the information is seen clearly, with no blur or glare.",onBack:C}),b.jsx("div",{className:"mb-8",children:b.jsx("div",{className:"relative",children:y&&b.jsx("img",{src:y,alt:"Captured photo",className:`w-full h-64 object-cover ${n==="selfie"?"":i==="circular"?"rounded-full":"rounded-2xl"} bg-muted`})})}),b.jsxs("div",{className:"flex gap-4",children:[b.jsx(_t,{variant:"outline",onClick:_,className:"flex-1 text-md",children:"Take again"}),b.jsx(_t,{onClick:E,className:"flex-1 text-md",children:"Looks good"})]})]})})};return m?A():b.jsxs(hn,{className:"relative w-full max-w-md mx-auto bg-gray-900 border-gray-900 overflow-hidden",children:[x&&b.jsx("video",{ref:u,autoPlay:!0,playsInline:!0,muted:!0,loop:!0,className:`absolute inset-0 w-full h-full object-cover z-0 ${!f&&"scale-x-[-1]"}`}),b.jsx("div",{ref:l,className:"absolute inset-0 z-5 pointer-events-none","aria-hidden":!0,children:b.jsxs("svg",{className:"w-full h-full",children:[b.jsx("defs",{children:b.jsxs("mask",{id:g,children:[b.jsx("rect",{width:"100%",height:"100%",fill:"white"}),i==="circular"?b.jsx("circle",{cx:S,cy:N,r:$,fill:"black"}):b.jsx("rect",{x:v.x,y:v.y,width:v.w,height:v.h,fill:"black"})]})}),b.jsx("rect",{width:"100%",height:"100%",fill:"rgba(17,24,39,0.7)",mask:`url(#${g})`})]})}),b.jsx("canvas",{ref:c,className:"hidden"}),b.jsxs(pn,{className:"relative z-10 text-white flex flex-col h-full",children:[b.jsxs("div",{className:"flex items-center p-6",children:[b.jsx(_t,{variant:"ghost",size:"sm",onClick:C,className:"text-white hover:bg-gray-600",children:b.jsx(Cg,{className:"h-6 w-6"})}),b.jsx("h1",{className:"text-xl font-semibold ml-4",children:o})]}),b.jsx("div",{className:"px-6 mb-8",children:b.jsx("p",{className:"text-gray-300 text-center",children:a})}),b.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6",children:[b.jsx("div",{className:"relative mb-16",children:x?b.jsxs("div",{ref:d,className:`relative z-20 ${i==="circular"?"w-80 h-80 rounded-full":s==="passport"?"w-80 h-[350px]":"w-80 h-48"}`,children:[b.jsx("div",{className:`absolute inset-0 opacity-0 ${i==="circular"?"rounded-full":""} z-10`}),i==="circular"?null:b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"absolute w-6 h-6 border-t-4 border-l-4 border-white z-30",style:{top:"-4px",left:"-4px"}}),b.jsx("div",{className:"absolute w-6 h-6 border-t-4 border-r-4 border-white z-30",style:{top:"-4px",right:"-4px"}}),b.jsx("div",{className:"absolute w-6 h-6 border-b-4 border-l-4 border-white z-30",style:{bottom:"-4px",left:"-4px"}}),b.jsx("div",{className:"absolute w-6 h-6 border-b-4 border-r-4 border-white z-30",style:{bottom:"-4px",right:"-4px"}})]})]}):b.jsx("div",{className:`bg-gray-700 flex items-center justify-center ${i==="circular"?"w-80 h-80 rounded-full":s==="passport"?"w-80 h-[350px]":"w-80 h-48"}`,children:b.jsx("p",{className:"text-gray-400",children:"Camera loading..."})})}),b.jsx(_t,{onClick:w,size:"lg",className:"w-16 h-16 rounded-full bg-white hover:bg-gray-100 border-4 border-gray-600 p-0",disabled:!x,children:b.jsx("div",{className:"w-8 h-8 rounded-full bg-white"})})]})]})]})},jD=({apiEndpoint:n,apiKey:t,onComplete:e,onDoneClick:r})=>{const[o,a]=D.useState("landing"),[i,s]=D.useState(""),[u,c]=D.useState(""),[l,d]=D.useState(null),[f,h]=D.useState(null),[m,p]=D.useState(null),{data:v}=HD(n,t),g=X0({mutationFn:UD}),{toast:y}=Qu(),w=D.useMemo(()=>[...v!=null&&v.hide_name_step?[]:["name"],...v!=null&&v.hide_document_selection_step?[]:["document-selection"],"selfie","pre-selfie","id-front","id-back","verify"],[v]),x=()=>v.hide_name_step?v.hide_document_selection_step?"id-front":"document-selection":"name",C=async()=>{if((v.hide_name_step||!!i)&&l&&f&&m){const N={full_name:i,selfie_photo:l,id_photo:f,id_photo_back:m},$=await g.mutateAsync({apiEndpoint:n,apiKey:t,data:N});e($.data.token,N),y({title:"KYC Complete",description:"Identity verification completed successfully"}),s(""),d(null),h(null),p(null),a("done")}},_=()=>b.jsx(b.Fragment,{children:o!=="landing"&&b.jsx("div",{className:"flex justify-center",children:b.jsx("div",{className:"flex space-x-2",children:w.map((S,N)=>b.jsx("div",{className:`w-3 h-3 rounded-full ${w.indexOf(o)>=N?"bg-primary":"bg-muted"}`},S))})})}),E=()=>{switch(console.log("currentStep",o),o){case"landing":return b.jsx(Z0,{onContinue:()=>a(x())});case"name":return b.jsx(G$,{fullName:i,onNameChange:s,onContinue:()=>a(v.hide_document_selection_step?"id-front":"document-selection"),renderProgress:_});case"document-selection":return b.jsx(ey,{selectedDocumentType:u,onDocumentTypeChange:c,onContinue:()=>a("id-front"),onBack:()=>a(v.hide_name_step?"landing":"name"),renderProgress:_});case"id-front":return b.jsx(Wi,{title:"Upload ID",description:"Place your ID inside the frame and take a picture. Make sure it is not cut or has any glare.",frameType:"rectangular",currentStep:o,onRetake:()=>{h(null)},onConfirm:S=>{h(S),a(u==="passport"?"pre-selfie":"id-back")},onBack:()=>{h(null),a(v.hide_document_selection_step?v.hide_name_step?"landing":"name":"document-selection")}});case"id-back":return b.jsx(Wi,{title:"Upload ID Back",description:"Place the back of your ID inside the frame and take a picture. Make sure it is not cut or has any glare.",frameType:"rectangular",currentStep:o,onRetake:()=>{p(null)},onConfirm:S=>{p(S),a("pre-selfie")},onBack:()=>{p(null),a("id-front")}});case"pre-selfie":return b.jsx(ty,{onContinue:()=>a("selfie"),onBack:()=>a("id-back")});case"selfie":return b.jsx(Wi,{title:"Selfie",description:"Place your face inside the frame and take a picture. Make sure it is clearly visible.",frameType:"circular",currentStep:o,onRetake:()=>{d(null)},onConfirm:S=>{d(S),a("verify")},onBack:()=>{d(null),a("id-back")}});case"verify":return b.jsx(q$,{fullName:i,onComplete:()=>a("processing"),onStartOver:()=>a("landing")});case"processing":return b.jsx(ny,{onComplete:C});case"done":return b.jsx(ry,{onDoneClick:r});default:return null}};return b.jsx("div",{className:"w-[430px]",children:E()})};async function UD({apiEndpoint:n,apiKey:t,data:e}){const r=new FormData;r.append("full_name",e.full_name),r.append("selfie_photo",e.selfie_photo,e.selfie_photo.name),r.append("id_photo",e.id_photo,e.id_photo.name),r.append("id_photo_back",e.id_photo_back,e.id_photo_back.name);const o=await fetch(`${n}/api/kyc`,{method:"POST",headers:{"X-API-Key":t},body:r});if(!o.ok)throw new Error("Network response was not ok");return o.json()}const zD=async(n,t)=>{const e=await fetch(`${n}/api/settings`,{method:"GET",headers:{"X-API-Key":t,"Content-Type":"application/json"}});if(!e.ok)throw new Error("Network response was not ok");return(await e.json()).data},HD=(n,t)=>V$({queryKey:["settings",n,t],queryFn:()=>zD(n,t),enabled:!!n&&!!t});var iu=n=>n.type==="checkbox",Va=n=>n instanceof Date,gn=n=>n==null;const G2=n=>typeof n=="object";var Dt=n=>!gn(n)&&!Array.isArray(n)&&G2(n)&&!Va(n),q2=n=>Dt(n)&&n.target?iu(n.target)?n.target.checked:n.target.value:n,GD=n=>n.substring(0,n.search(/\.\d+(\.|$)/))||n,K2=(n,t)=>n.has(GD(t)),qD=n=>{const t=n.constructor&&n.constructor.prototype;return Dt(t)&&t.hasOwnProperty("isPrototypeOf")},Pp=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Gt(n){let t;const e=Array.isArray(n),r=typeof FileList<"u"?n instanceof FileList:!1;if(n instanceof Date)t=new Date(n);else if(!(Pp&&(n instanceof Blob||r))&&(e||Dt(n)))if(t=e?[]:Object.create(Object.getPrototypeOf(n)),!e&&!qD(n))t=n;else for(const o in n)n.hasOwnProperty(o)&&(t[o]=Gt(n[o]));else return n;return t}var Il=n=>/^\w*$/.test(n),At=n=>n===void 0,Ip=n=>Array.isArray(n)?n.filter(Boolean):[],Ap=n=>Ip(n.replace(/["|']|\]/g,"").split(/\.|\[/)),me=(n,t,e)=>{if(!t||!Dt(n))return e;const r=(Il(t)?[t]:Ap(t)).reduce((o,a)=>gn(o)?o:o[a],n);return At(r)||r===n?At(n[t])?e:n[t]:r},Un=n=>typeof n=="boolean",ct=(n,t,e)=>{let r=-1;const o=Il(t)?[t]:Ap(t),a=o.length,i=a-1;for(;++r<a;){const s=o[r];let u=e;if(r!==i){const c=n[s];u=Dt(c)||Array.isArray(c)?c:isNaN(+o[r+1])?{}:[]}if(s==="__proto__"||s==="constructor"||s==="prototype")return;n[s]=u,n=n[s]}};const Al={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},lr={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ho={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Tp=D.createContext(null);Tp.displayName="HookFormContext";const Tl=()=>D.useContext(Tp),KD=n=>{const{children:t,...e}=n;return D.createElement(Tp.Provider,{value:e},t)};var Y2=(n,t,e,r=!0)=>{const o={defaultValues:t._defaultValues};for(const a in n)Object.defineProperty(o,a,{get:()=>{const i=a;return t._proxyFormState[i]!==lr.all&&(t._proxyFormState[i]=!r||lr.all),e&&(e[i]=!0),n[i]}});return o};const Op=typeof window<"u"?D.useLayoutEffect:D.useEffect;function YD(n){const t=Tl(),{control:e=t.control,disabled:r,name:o,exact:a}=n||{},[i,s]=D.useState(e._formState),u=D.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Op(()=>e._subscribe({name:o,formState:u.current,exact:a,callback:c=>{!r&&s({...e._formState,...c})}}),[o,r,a]),D.useEffect(()=>{u.current.isValid&&e._setValid(!0)},[e]),D.useMemo(()=>Y2(i,e,u.current,!1),[i,e])}var zn=n=>typeof n=="string",X2=(n,t,e,r,o)=>zn(n)?(r&&t.watch.add(n),me(e,n,o)):Array.isArray(n)?n.map(a=>(r&&t.watch.add(a),me(e,a))):(r&&(t.watchAll=!0),e),Dp=n=>gn(n)||!G2(n);function po(n,t,e=new WeakSet){if(Dp(n)||Dp(t))return n===t;if(Va(n)&&Va(t))return n.getTime()===t.getTime();const r=Object.keys(n),o=Object.keys(t);if(r.length!==o.length)return!1;if(e.has(n)||e.has(t))return!0;e.add(n),e.add(t);for(const a of r){const i=n[a];if(!o.includes(a))return!1;if(a!=="ref"){const s=t[a];if(Va(i)&&Va(s)||Dt(i)&&Dt(s)||Array.isArray(i)&&Array.isArray(s)?!po(i,s,e):i!==s)return!1}}return!0}function XD(n){const t=Tl(),{control:e=t.control,name:r,defaultValue:o,disabled:a,exact:i,compute:s}=n||{},u=D.useRef(o),c=D.useRef(s),l=D.useRef(void 0);c.current=s;const d=D.useMemo(()=>e._getWatch(r,u.current),[e,r]),[f,h]=D.useState(c.current?c.current(d):d);return Op(()=>e._subscribe({name:r,formState:{values:!0},exact:i,callback:m=>{if(!a){const p=X2(r,e._names,m.values||e._formValues,!1,u.current);if(c.current){const v=c.current(p);po(v,l.current)||(h(v),l.current=v)}else h(p)}}}),[e,a,r,i]),D.useEffect(()=>e._removeUnmounted()),f}function Z2(n){const t=Tl(),{name:e,disabled:r,control:o=t.control,shouldUnregister:a,defaultValue:i}=n,s=K2(o._names.array,e),u=D.useMemo(()=>me(o._formValues,e,me(o._defaultValues,e,i)),[o,e,i]),c=XD({control:o,name:e,defaultValue:u,exact:!0}),l=YD({control:o,name:e,exact:!0}),d=D.useRef(n),f=D.useRef(void 0),h=D.useRef(o.register(e,{...n.rules,value:c,...Un(n.disabled)?{disabled:n.disabled}:{}}));d.current=n;const m=D.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!me(l.errors,e)},isDirty:{enumerable:!0,get:()=>!!me(l.dirtyFields,e)},isTouched:{enumerable:!0,get:()=>!!me(l.touchedFields,e)},isValidating:{enumerable:!0,get:()=>!!me(l.validatingFields,e)},error:{enumerable:!0,get:()=>me(l.errors,e)}}),[l,e]),p=D.useCallback(w=>h.current.onChange({target:{value:q2(w),name:e},type:Al.CHANGE}),[e]),v=D.useCallback(()=>h.current.onBlur({target:{value:me(o._formValues,e),name:e},type:Al.BLUR}),[e,o._formValues]),g=D.useCallback(w=>{const x=me(o._fields,e);x&&w&&(x._f.ref={focus:()=>w.focus&&w.focus(),select:()=>w.select&&w.select(),setCustomValidity:C=>w.setCustomValidity(C),reportValidity:()=>w.reportValidity()})},[o._fields,e]),y=D.useMemo(()=>({name:e,value:c,...Un(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:p,onBlur:v,ref:g}),[e,r,l.disabled,p,v,g,c]);return D.useEffect(()=>{const w=o._options.shouldUnregister||a,x=f.current;x&&x!==e&&!s&&o.unregister(x),o.register(e,{...d.current.rules,...Un(d.current.disabled)?{disabled:d.current.disabled}:{}});const C=(_,E)=>{const S=me(o._fields,_);S&&S._f&&(S._f.mount=E)};if(C(e,!0),w){const _=Gt(me(o._options.defaultValues,e));ct(o._defaultValues,e,_),At(me(o._formValues,e))&&ct(o._formValues,e,_)}return!s&&o.register(e),f.current=e,()=>{(s?w&&!o._state.action:w)?o.unregister(e):C(e,!1)}},[e,o,s,a]),D.useEffect(()=>{o._setDisabledField({disabled:r,name:e})},[r,e,o]),D.useMemo(()=>({field:y,formState:l,fieldState:m}),[y,l,m])}const ZD=n=>n.render(Z2(n));var Q2=(n,t,e,r,o)=>t?{...e[n],types:{...e[n]&&e[n].types?e[n].types:{},[r]:o||!0}}:{},su=n=>Array.isArray(n)?n:[n],J2=()=>{let n=[];return{get observers(){return n},next:o=>{for(const a of n)a.next&&a.next(o)},subscribe:o=>(n.push(o),{unsubscribe:()=>{n=n.filter(a=>a!==o)}}),unsubscribe:()=>{n=[]}}};function ex(n,t){const e={};for(const r in n)if(n.hasOwnProperty(r)){const o=n[r],a=t[r];if(o&&Dt(o)&&a){const i=ex(o,a);Dt(i)&&(e[r]=i)}else n[r]&&(e[r]=a)}return e}var kn=n=>Dt(n)&&!Object.keys(n).length,Mp=n=>n.type==="file",dr=n=>typeof n=="function",Ol=n=>{if(!Pp)return!1;const t=n?n.ownerDocument:0;return n instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},tx=n=>n.type==="select-multiple",Fp=n=>n.type==="radio",QD=n=>Fp(n)||iu(n),Rp=n=>Ol(n)&&n.isConnected;function JD(n,t){const e=t.slice(0,-1).length;let r=0;for(;r<e;)n=At(n)?r++:n[t[r++]];return n}function e8(n){for(const t in n)if(n.hasOwnProperty(t)&&!At(n[t]))return!1;return!0}function Mt(n,t){const e=Array.isArray(t)?t:Il(t)?[t]:Ap(t),r=e.length===1?n:JD(n,e),o=e.length-1,a=e[o];return r&&delete r[a],o!==0&&(Dt(r)&&kn(r)||Array.isArray(r)&&e8(r))&&Mt(n,e.slice(0,-1)),n}var t8=n=>{for(const t in n)if(dr(n[t]))return!0;return!1};function nx(n){return Array.isArray(n)||Dt(n)&&!t8(n)}function Lp(n,t={}){for(const e in n)nx(n[e])?(t[e]=Array.isArray(n[e])?[]:{},Lp(n[e],t[e])):gn(n[e])||(t[e]=!0);return t}function Vi(n,t,e){e||(e=Lp(t));for(const r in n)nx(n[r])?At(t)||Dp(e[r])?e[r]=Lp(n[r],Array.isArray(n[r])?[]:{}):Vi(n[r],gn(t)?{}:t[r],e[r]):e[r]=!po(n[r],t[r]);return e}const rx={value:!1,isValid:!1},ox={value:!0,isValid:!0};var ax=n=>{if(Array.isArray(n)){if(n.length>1){const t=n.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return n[0].checked&&!n[0].disabled?n[0].attributes&&!At(n[0].attributes.value)?At(n[0].value)||n[0].value===""?ox:{value:n[0].value,isValid:!0}:ox:rx}return rx},ix=(n,{valueAsNumber:t,valueAsDate:e,setValueAs:r})=>At(n)?n:t?n===""?NaN:n&&+n:e&&zn(n)?new Date(n):r?r(n):n;const sx={isValid:!1,value:null};var ux=n=>Array.isArray(n)?n.reduce((t,e)=>e&&e.checked&&!e.disabled?{isValid:!0,value:e.value}:t,sx):sx;function cx(n){const t=n.ref;return Mp(t)?t.files:Fp(t)?ux(n.refs).value:tx(t)?[...t.selectedOptions].map(({value:e})=>e):iu(t)?ax(n.refs).value:ix(At(t.value)?n.ref.value:t.value,n)}var n8=(n,t,e,r)=>{const o={};for(const a of n){const i=me(t,a);i&&ct(o,a,i._f)}return{criteriaMode:e,names:[...n],fields:o,shouldUseNativeValidation:r}},Dl=n=>n instanceof RegExp,uu=n=>At(n)?n:Dl(n)?n.source:Dt(n)?Dl(n.value)?n.value.source:n.value:n,lx=n=>({isOnSubmit:!n||n===lr.onSubmit,isOnBlur:n===lr.onBlur,isOnChange:n===lr.onChange,isOnAll:n===lr.all,isOnTouch:n===lr.onTouched});const dx="AsyncFunction";var r8=n=>!!n&&!!n.validate&&!!(dr(n.validate)&&n.validate.constructor.name===dx||Dt(n.validate)&&Object.values(n.validate).find(t=>t.constructor.name===dx)),o8=n=>n.mount&&(n.required||n.min||n.max||n.maxLength||n.minLength||n.pattern||n.validate),fx=(n,t,e)=>!e&&(t.watchAll||t.watch.has(n)||[...t.watch].some(r=>n.startsWith(r)&&/^\.\w+/.test(n.slice(r.length))));const cu=(n,t,e,r)=>{for(const o of e||Object.keys(n)){const a=me(n,o);if(a){const{_f:i,...s}=a;if(i){if(i.refs&&i.refs[0]&&t(i.refs[0],o)&&!r)return!0;if(i.ref&&t(i.ref,i.name)&&!r)return!0;if(cu(s,t))break}else if(Dt(s)&&cu(s,t))break}}};function hx(n,t,e){const r=me(n,e);if(r||Il(e))return{error:r,name:e};const o=e.split(".");for(;o.length;){const a=o.join("."),i=me(t,a),s=me(n,a);if(i&&!Array.isArray(i)&&e!==a)return{name:e};if(s&&s.type)return{name:a,error:s};if(s&&s.root&&s.root.type)return{name:`${a}.root`,error:s.root};o.pop()}return{name:e}}var a8=(n,t,e,r)=>{e(n);const{name:o,...a}=n;return kn(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(i=>t[i]===(!r||lr.all))},i8=(n,t,e)=>!n||!t||n===t||su(n).some(r=>r&&(e?r===t:r.startsWith(t)||t.startsWith(r))),s8=(n,t,e,r,o)=>o.isOnAll?!1:!e&&o.isOnTouch?!(t||n):(e?r.isOnBlur:o.isOnBlur)?!n:(e?r.isOnChange:o.isOnChange)?n:!0,u8=(n,t)=>!Ip(me(n,t)).length&&Mt(n,t),c8=(n,t,e)=>{const r=su(me(n,e));return ct(r,"root",t[e]),ct(n,e,r),n};function px(n,t,e="validate"){if(zn(n)||Array.isArray(n)&&n.every(zn)||Un(n)&&!n)return{type:e,message:zn(n)?n:"",ref:t}}var ji=n=>Dt(n)&&!Dl(n)?n:{value:n,message:""},vx=async(n,t,e,r,o,a)=>{const{ref:i,refs:s,required:u,maxLength:c,minLength:l,min:d,max:f,pattern:h,validate:m,name:p,valueAsNumber:v,mount:g}=n._f,y=me(e,p);if(!g||t.has(p))return{};const w=s?s[0]:i,x=P=>{o&&w.reportValidity&&(w.setCustomValidity(Un(P)?"":P||""),w.reportValidity())},C={},_=Fp(i),E=iu(i),S=_||E,N=(v||Mp(i))&&At(i.value)&&At(y)||Ol(i)&&i.value===""||y===""||Array.isArray(y)&&!y.length,$=Q2.bind(null,p,r,C),A=(P,j,B,z=ho.maxLength,H=ho.minLength)=>{const F=P?j:B;C[p]={type:P?z:H,message:F,ref:i,...$(P?z:H,F)}};if(a?!Array.isArray(y)||!y.length:u&&(!S&&(N||gn(y))||Un(y)&&!y||E&&!ax(s).isValid||_&&!ux(s).isValid)){const{value:P,message:j}=zn(u)?{value:!!u,message:u}:ji(u);if(P&&(C[p]={type:ho.required,message:j,ref:w,...$(ho.required,j)},!r))return x(j),C}if(!N&&(!gn(d)||!gn(f))){let P,j;const B=ji(f),z=ji(d);if(!gn(y)&&!isNaN(y)){const H=i.valueAsNumber||y&&+y;gn(B.value)||(P=H>B.value),gn(z.value)||(j=H<z.value)}else{const H=i.valueAsDate||new Date(y),F=I=>new Date(new Date().toDateString()+" "+I),M=i.type=="time",O=i.type=="week";zn(B.value)&&y&&(P=M?F(y)>F(B.value):O?y>B.value:H>new Date(B.value)),zn(z.value)&&y&&(j=M?F(y)<F(z.value):O?y<z.value:H<new Date(z.value))}if((P||j)&&(A(!!P,B.message,z.message,ho.max,ho.min),!r))return x(C[p].message),C}if((c||l)&&!N&&(zn(y)||a&&Array.isArray(y))){const P=ji(c),j=ji(l),B=!gn(P.value)&&y.length>+P.value,z=!gn(j.value)&&y.length<+j.value;if((B||z)&&(A(B,P.message,j.message),!r))return x(C[p].message),C}if(h&&!N&&zn(y)){const{value:P,message:j}=ji(h);if(Dl(P)&&!y.match(P)&&(C[p]={type:ho.pattern,message:j,ref:i,...$(ho.pattern,j)},!r))return x(j),C}if(m){if(dr(m)){const P=await m(y,e),j=px(P,w);if(j&&(C[p]={...j,...$(ho.validate,j.message)},!r))return x(j.message),C}else if(Dt(m)){let P={};for(const j in m){if(!kn(P)&&!r)break;const B=px(await m[j](y,e),w,j);B&&(P={...B,...$(j,B.message)},x(B.message),r&&(C[p]=P))}if(!kn(P)&&(C[p]={ref:w,...P},!r))return C}}return x(!0),C};const l8={mode:lr.onSubmit,reValidateMode:lr.onChange,shouldFocusError:!0};function d8(n={}){let t={...l8,...n},e={submitCount:0,isDirty:!1,isReady:!1,isLoading:dr(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},o=Dt(t.defaultValues)||Dt(t.values)?Gt(t.defaultValues||t.values)||{}:{},a=t.shouldUnregister?{}:Gt(o),i={action:!1,mount:!1,watch:!1},s={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},u,c=0;const l={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let d={...l};const f={array:J2(),state:J2()},h=t.criteriaMode===lr.all,m=V=>Y=>{clearTimeout(c),c=setTimeout(V,Y)},p=async V=>{if(!t.disabled&&(l.isValid||d.isValid||V)){const Y=t.resolver?kn((await E()).errors):await N(r,!0);Y!==e.isValid&&f.state.next({isValid:Y})}},v=(V,Y)=>{!t.disabled&&(l.isValidating||l.validatingFields||d.isValidating||d.validatingFields)&&((V||Array.from(s.mount)).forEach(te=>{te&&(Y?ct(e.validatingFields,te,Y):Mt(e.validatingFields,te))}),f.state.next({validatingFields:e.validatingFields,isValidating:!kn(e.validatingFields)}))},g=(V,Y=[],te,he,pe=!0,le=!0)=>{if(he&&te&&!t.disabled){if(i.action=!0,le&&Array.isArray(me(r,V))){const ye=te(me(r,V),he.argA,he.argB);pe&&ct(r,V,ye)}if(le&&Array.isArray(me(e.errors,V))){const ye=te(me(e.errors,V),he.argA,he.argB);pe&&ct(e.errors,V,ye),u8(e.errors,V)}if((l.touchedFields||d.touchedFields)&&le&&Array.isArray(me(e.touchedFields,V))){const ye=te(me(e.touchedFields,V),he.argA,he.argB);pe&&ct(e.touchedFields,V,ye)}(l.dirtyFields||d.dirtyFields)&&(e.dirtyFields=Vi(o,a)),f.state.next({name:V,isDirty:A(V,Y),dirtyFields:e.dirtyFields,errors:e.errors,isValid:e.isValid})}else ct(a,V,Y)},y=(V,Y)=>{ct(e.errors,V,Y),f.state.next({errors:e.errors})},w=V=>{e.errors=V,f.state.next({errors:e.errors,isValid:!1})},x=(V,Y,te,he)=>{const pe=me(r,V);if(pe){const le=me(a,V,At(te)?me(o,V):te);At(le)||he&&he.defaultChecked||Y?ct(a,V,Y?le:cx(pe._f)):B(V,le),i.mount&&p()}},C=(V,Y,te,he,pe)=>{let le=!1,ye=!1;const We={name:V};if(!t.disabled){if(!te||he){(l.isDirty||d.isDirty)&&(ye=e.isDirty,e.isDirty=We.isDirty=A(),le=ye!==We.isDirty);const Ge=po(me(o,V),Y);ye=!!me(e.dirtyFields,V),Ge?Mt(e.dirtyFields,V):ct(e.dirtyFields,V,!0),We.dirtyFields=e.dirtyFields,le=le||(l.dirtyFields||d.dirtyFields)&&ye!==!Ge}if(te){const Ge=me(e.touchedFields,V);Ge||(ct(e.touchedFields,V,te),We.touchedFields=e.touchedFields,le=le||(l.touchedFields||d.touchedFields)&&Ge!==te)}le&&pe&&f.state.next(We)}return le?We:{}},_=(V,Y,te,he)=>{const pe=me(e.errors,V),le=(l.isValid||d.isValid)&&Un(Y)&&e.isValid!==Y;if(t.delayError&&te?(u=m(()=>y(V,te)),u(t.delayError)):(clearTimeout(c),u=null,te?ct(e.errors,V,te):Mt(e.errors,V)),(te?!po(pe,te):pe)||!kn(he)||le){const ye={...he,...le&&Un(Y)?{isValid:Y}:{},errors:e.errors,name:V};e={...e,...ye},f.state.next(ye)}},E=async V=>{v(V,!0);const Y=await t.resolver(a,t.context,n8(V||s.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return v(V),Y},S=async V=>{const{errors:Y}=await E(V);if(V)for(const te of V){const he=me(Y,te);he?ct(e.errors,te,he):Mt(e.errors,te)}else e.errors=Y;return Y},N=async(V,Y,te={valid:!0})=>{for(const he in V){const pe=V[he];if(pe){const{_f:le,...ye}=pe;if(le){const We=s.array.has(le.name),Ge=pe._f&&r8(pe._f);Ge&&l.validatingFields&&v([le.name],!0);const Qt=await vx(pe,s.disabled,a,h,t.shouldUseNativeValidation&&!Y,We);if(Ge&&l.validatingFields&&v([le.name]),Qt[le.name]&&(te.valid=!1,Y))break;!Y&&(me(Qt,le.name)?We?c8(e.errors,Qt,le.name):ct(e.errors,le.name,Qt[le.name]):Mt(e.errors,le.name))}!kn(ye)&&await N(ye,Y,te)}}return te.valid},$=()=>{for(const V of s.unMount){const Y=me(r,V);Y&&(Y._f.refs?Y._f.refs.every(te=>!Rp(te)):!Rp(Y._f.ref))&&X(V)}s.unMount=new Set},A=(V,Y)=>!t.disabled&&(V&&Y&&ct(a,V,Y),!po(I(),o)),P=(V,Y,te)=>X2(V,s,{...i.mount?a:At(Y)?o:zn(V)?{[V]:Y}:Y},te,Y),j=V=>Ip(me(i.mount?a:o,V,t.shouldUnregister?me(o,V,[]):[])),B=(V,Y,te={})=>{const he=me(r,V);let pe=Y;if(he){const le=he._f;le&&(!le.disabled&&ct(a,V,ix(Y,le)),pe=Ol(le.ref)&&gn(Y)?"":Y,tx(le.ref)?[...le.ref.options].forEach(ye=>ye.selected=pe.includes(ye.value)):le.refs?iu(le.ref)?le.refs.forEach(ye=>{(!ye.defaultChecked||!ye.disabled)&&(Array.isArray(pe)?ye.checked=!!pe.find(We=>We===ye.value):ye.checked=pe===ye.value||!!pe)}):le.refs.forEach(ye=>ye.checked=ye.value===pe):Mp(le.ref)?le.ref.value="":(le.ref.value=pe,le.ref.type||f.state.next({name:V,values:Gt(a)})))}(te.shouldDirty||te.shouldTouch)&&C(V,pe,te.shouldTouch,te.shouldDirty,!0),te.shouldValidate&&O(V)},z=(V,Y,te)=>{for(const he in Y){if(!Y.hasOwnProperty(he))return;const pe=Y[he],le=V+"."+he,ye=me(r,le);(s.array.has(V)||Dt(pe)||ye&&!ye._f)&&!Va(pe)?z(le,pe,te):B(le,pe,te)}},H=(V,Y,te={})=>{const he=me(r,V),pe=s.array.has(V),le=Gt(Y);ct(a,V,le),pe?(f.array.next({name:V,values:Gt(a)}),(l.isDirty||l.dirtyFields||d.isDirty||d.dirtyFields)&&te.shouldDirty&&f.state.next({name:V,dirtyFields:Vi(o,a),isDirty:A(V,le)})):he&&!he._f&&!gn(le)?z(V,le,te):B(V,le,te),fx(V,s)&&f.state.next({...e,name:V}),f.state.next({name:i.mount?V:void 0,values:Gt(a)})},F=async V=>{i.mount=!0;const Y=V.target;let te=Y.name,he=!0;const pe=me(r,te),le=Ge=>{he=Number.isNaN(Ge)||Va(Ge)&&isNaN(Ge.getTime())||po(Ge,me(a,te,Ge))},ye=lx(t.mode),We=lx(t.reValidateMode);if(pe){let Ge,Qt;const xr=Y.type?cx(pe._f):q2(V),er=V.type===Al.BLUR||V.type===Al.FOCUS_OUT,_s=!o8(pe._f)&&!t.resolver&&!me(e.errors,te)&&!pe._f.deps||s8(er,me(e.touchedFields,te),e.isSubmitted,We,ye),wr=fx(te,s,er);ct(a,te,xr),er?(!Y||!Y.readOnly)&&(pe._f.onBlur&&pe._f.onBlur(V),u&&u(0)):pe._f.onChange&&pe._f.onChange(V);const On=C(te,xr,er),ha=!kn(On)||wr;if(!er&&f.state.next({name:te,type:V.type,values:Gt(a)}),_s)return(l.isValid||d.isValid)&&(t.mode==="onBlur"?er&&p():er||p()),ha&&f.state.next({name:te,...wr?{}:On});if(!er&&wr&&f.state.next({...e}),t.resolver){const{errors:No}=await E([te]);if(le(xr),he){const Nm=hx(e.errors,r,te),xd=hx(No,r,Nm.name||te);Ge=xd.error,te=xd.name,Qt=kn(No)}}else v([te],!0),Ge=(await vx(pe,s.disabled,a,h,t.shouldUseNativeValidation))[te],v([te]),le(xr),he&&(Ge?Qt=!1:(l.isValid||d.isValid)&&(Qt=await N(r,!0)));he&&(pe._f.deps&&(!Array.isArray(pe._f.deps)||pe._f.deps.length>0)&&O(pe._f.deps),_(te,Qt,Ge,On))}},M=(V,Y)=>{if(me(e.errors,Y)&&V.focus)return V.focus(),1},O=async(V,Y={})=>{let te,he;const pe=su(V);if(t.resolver){const le=await S(At(V)?V:pe);te=kn(le),he=V?!pe.some(ye=>me(le,ye)):te}else V?(he=(await Promise.all(pe.map(async le=>{const ye=me(r,le);return await N(ye&&ye._f?{[le]:ye}:ye)}))).every(Boolean),!(!he&&!e.isValid)&&p()):he=te=await N(r);return f.state.next({...!zn(V)||(l.isValid||d.isValid)&&te!==e.isValid?{}:{name:V},...t.resolver||!V?{isValid:te}:{},errors:e.errors}),Y.shouldFocus&&!he&&cu(r,M,V?pe:s.mount),he},I=(V,Y)=>{let te={...i.mount?a:o};return Y&&(te=ex(Y.dirtyFields?e.dirtyFields:e.touchedFields,te)),At(V)?te:zn(V)?me(te,V):V.map(he=>me(te,he))},L=(V,Y)=>({invalid:!!me((Y||e).errors,V),isDirty:!!me((Y||e).dirtyFields,V),error:me((Y||e).errors,V),isValidating:!!me(e.validatingFields,V),isTouched:!!me((Y||e).touchedFields,V)}),K=V=>{V&&su(V).forEach(Y=>Mt(e.errors,Y)),f.state.next({errors:V?e.errors:{}})},q=(V,Y,te)=>{const he=(me(r,V,{_f:{}})._f||{}).ref,pe=me(e.errors,V)||{},{ref:le,message:ye,type:We,...Ge}=pe;ct(e.errors,V,{...Ge,...Y,ref:he}),f.state.next({name:V,errors:e.errors,isValid:!1}),te&&te.shouldFocus&&he&&he.focus&&he.focus()},Z=(V,Y)=>dr(V)?f.state.subscribe({next:te=>"values"in te&&V(P(void 0,Y),te)}):P(V,Y,!0),oe=V=>f.state.subscribe({next:Y=>{i8(V.name,Y.name,V.exact)&&a8(Y,V.formState||l,Lt,V.reRenderRoot)&&V.callback({values:{...a},...e,...Y,defaultValues:o})}}).unsubscribe,ae=V=>(i.mount=!0,d={...d,...V.formState},oe({...V,formState:d})),X=(V,Y={})=>{for(const te of V?su(V):s.mount)s.mount.delete(te),s.array.delete(te),Y.keepValue||(Mt(r,te),Mt(a,te)),!Y.keepError&&Mt(e.errors,te),!Y.keepDirty&&Mt(e.dirtyFields,te),!Y.keepTouched&&Mt(e.touchedFields,te),!Y.keepIsValidating&&Mt(e.validatingFields,te),!t.shouldUnregister&&!Y.keepDefaultValue&&Mt(o,te);f.state.next({values:Gt(a)}),f.state.next({...e,...Y.keepDirty?{isDirty:A()}:{}}),!Y.keepIsValid&&p()},re=({disabled:V,name:Y})=>{(Un(V)&&i.mount||V||s.disabled.has(Y))&&(V?s.disabled.add(Y):s.disabled.delete(Y))},ce=(V,Y={})=>{let te=me(r,V);const he=Un(Y.disabled)||Un(t.disabled);return ct(r,V,{...te||{},_f:{...te&&te._f?te._f:{ref:{name:V}},name:V,mount:!0,...Y}}),s.mount.add(V),te?re({disabled:Un(Y.disabled)?Y.disabled:t.disabled,name:V}):x(V,!0,Y.value),{...he?{disabled:Y.disabled||t.disabled}:{},...t.progressive?{required:!!Y.required,min:uu(Y.min),max:uu(Y.max),minLength:uu(Y.minLength),maxLength:uu(Y.maxLength),pattern:uu(Y.pattern)}:{},name:V,onChange:F,onBlur:F,ref:pe=>{if(pe){ce(V,Y),te=me(r,V);const le=At(pe.value)&&pe.querySelectorAll&&pe.querySelectorAll("input,select,textarea")[0]||pe,ye=QD(le),We=te._f.refs||[];if(ye?We.find(Ge=>Ge===le):le===te._f.ref)return;ct(r,V,{_f:{...te._f,...ye?{refs:[...We.filter(Rp),le,...Array.isArray(me(o,V))?[{}]:[]],ref:{type:le.type,name:V}}:{ref:le}}}),x(V,!1,void 0,le)}else te=me(r,V,{}),te._f&&(te._f.mount=!1),(t.shouldUnregister||Y.shouldUnregister)&&!(K2(s.array,V)&&i.action)&&s.unMount.add(V)}}},ue=()=>t.shouldFocusError&&cu(r,M,s.mount),se=V=>{Un(V)&&(f.state.next({disabled:V}),cu(r,(Y,te)=>{const he=me(r,te);he&&(Y.disabled=he._f.disabled||V,Array.isArray(he._f.refs)&&he._f.refs.forEach(pe=>{pe.disabled=he._f.disabled||V}))},0,!1))},ee=(V,Y)=>async te=>{let he;te&&(te.preventDefault&&te.preventDefault(),te.persist&&te.persist());let pe=Gt(a);if(f.state.next({isSubmitting:!0}),t.resolver){const{errors:le,values:ye}=await E();e.errors=le,pe=Gt(ye)}else await N(r);if(s.disabled.size)for(const le of s.disabled)Mt(pe,le);if(Mt(e.errors,"root"),kn(e.errors)){f.state.next({errors:{}});try{await V(pe,te)}catch(le){he=le}}else Y&&await Y({...e.errors},te),ue(),setTimeout(ue);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:kn(e.errors)&&!he,submitCount:e.submitCount+1,errors:e.errors}),he)throw he},_e=(V,Y={})=>{me(r,V)&&(At(Y.defaultValue)?H(V,Gt(me(o,V))):(H(V,Y.defaultValue),ct(o,V,Gt(Y.defaultValue))),Y.keepTouched||Mt(e.touchedFields,V),Y.keepDirty||(Mt(e.dirtyFields,V),e.isDirty=Y.defaultValue?A(V,Gt(me(o,V))):A()),Y.keepError||(Mt(e.errors,V),l.isValid&&p()),f.state.next({...e}))},Me=(V,Y={})=>{const te=V?Gt(V):o,he=Gt(te),pe=kn(V),le=pe?o:he;if(Y.keepDefaultValues||(o=te),!Y.keepValues){if(Y.keepDirtyValues){const ye=new Set([...s.mount,...Object.keys(Vi(o,a))]);for(const We of Array.from(ye))me(e.dirtyFields,We)?ct(le,We,me(a,We)):H(We,me(le,We))}else{if(Pp&&At(V))for(const ye of s.mount){const We=me(r,ye);if(We&&We._f){const Ge=Array.isArray(We._f.refs)?We._f.refs[0]:We._f.ref;if(Ol(Ge)){const Qt=Ge.closest("form");if(Qt){Qt.reset();break}}}}if(Y.keepFieldsRef)for(const ye of s.mount)H(ye,me(le,ye));else r={}}a=t.shouldUnregister?Y.keepDefaultValues?Gt(o):{}:Gt(le),f.array.next({values:{...le}}),f.state.next({values:{...le}})}s={mount:Y.keepDirtyValues?s.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!l.isValid||!!Y.keepIsValid||!!Y.keepDirtyValues,i.watch=!!t.shouldUnregister,f.state.next({submitCount:Y.keepSubmitCount?e.submitCount:0,isDirty:pe?!1:Y.keepDirty?e.isDirty:!!(Y.keepDefaultValues&&!po(V,o)),isSubmitted:Y.keepIsSubmitted?e.isSubmitted:!1,dirtyFields:pe?{}:Y.keepDirtyValues?Y.keepDefaultValues&&a?Vi(o,a):e.dirtyFields:Y.keepDefaultValues&&V?Vi(o,V):Y.keepDirty?e.dirtyFields:{},touchedFields:Y.keepTouched?e.touchedFields:{},errors:Y.keepErrors?e.errors:{},isSubmitSuccessful:Y.keepIsSubmitSuccessful?e.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:o})},Ye=(V,Y)=>Me(dr(V)?V(a):V,Y),Ze=(V,Y={})=>{const te=me(r,V),he=te&&te._f;if(he){const pe=he.refs?he.refs[0]:he.ref;pe.focus&&(pe.focus(),Y.shouldSelect&&dr(pe.select)&&pe.select())}},Lt=V=>{e={...e,...V}},Ct={control:{register:ce,unregister:X,getFieldState:L,handleSubmit:ee,setError:q,_subscribe:oe,_runSchema:E,_focusError:ue,_getWatch:P,_getDirty:A,_setValid:p,_setFieldArray:g,_setDisabledField:re,_setErrors:w,_getFieldArray:j,_reset:Me,_resetDefaultValues:()=>dr(t.defaultValues)&&t.defaultValues().then(V=>{Ye(V,t.resetOptions),f.state.next({isLoading:!1})}),_removeUnmounted:$,_disableForm:se,_subjects:f,_proxyFormState:l,get _fields(){return r},get _formValues(){return a},get _state(){return i},set _state(V){i=V},get _defaultValues(){return o},get _names(){return s},set _names(V){s=V},get _formState(){return e},get _options(){return t},set _options(V){t={...t,...V}}},subscribe:ae,trigger:O,register:ce,handleSubmit:ee,watch:Z,setValue:H,getValues:I,reset:Ye,resetField:_e,clearErrors:K,unregister:X,setError:q,setFocus:Ze,getFieldState:L};return{...Ct,formControl:Ct}}function lu(n={}){const t=D.useRef(void 0),e=D.useRef(void 0),[r,o]=D.useState({isDirty:!1,isValidating:!1,isLoading:dr(n.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:n.errors||{},disabled:n.disabled||!1,isReady:!1,defaultValues:dr(n.defaultValues)?void 0:n.defaultValues});if(!t.current)if(n.formControl)t.current={...n.formControl,formState:r},n.defaultValues&&!dr(n.defaultValues)&&n.formControl.reset(n.defaultValues,n.resetOptions);else{const{formControl:i,...s}=d8(n);t.current={...s,formState:r}}const a=t.current.control;return a._options=n,Op(()=>{const i=a._subscribe({formState:a._proxyFormState,callback:()=>o({...a._formState}),reRenderRoot:!0});return o(s=>({...s,isReady:!0})),a._formState.isReady=!0,i},[a]),D.useEffect(()=>a._disableForm(n.disabled),[a,n.disabled]),D.useEffect(()=>{n.mode&&(a._options.mode=n.mode),n.reValidateMode&&(a._options.reValidateMode=n.reValidateMode)},[a,n.mode,n.reValidateMode]),D.useEffect(()=>{n.errors&&(a._setErrors(n.errors),a._focusError())},[a,n.errors]),D.useEffect(()=>{n.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,n.shouldUnregister]),D.useEffect(()=>{if(a._proxyFormState.isDirty){const i=a._getDirty();i!==r.isDirty&&a._subjects.state.next({isDirty:i})}},[a,r.isDirty]),D.useEffect(()=>{n.values&&!po(n.values,e.current)?(a._reset(n.values,{keepFieldsRef:!0,...a._options.resetOptions}),e.current=n.values,o(i=>({...i}))):a._resetDefaultValues()},[a,n.values]),D.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=Y2(r,a),t.current}const mx=(n,t,e)=>{if(n&&"reportValidity"in n){const r=me(e,t);n.setCustomValidity(r&&r.message||""),n.reportValidity()}},gx=(n,t)=>{for(const e in t.fields){const r=t.fields[e];r&&r.ref&&"reportValidity"in r.ref?mx(r.ref,e,n):r.refs&&r.refs.forEach(o=>mx(o,e,n))}},f8=(n,t)=>{t.shouldUseNativeValidation&&gx(n,t);const e={};for(const r in n){const o=me(t.fields,r),a=Object.assign(n[r]||{},{ref:o&&o.ref});if(h8(t.names||Object.keys(n),r)){const i=Object.assign({},me(e,r));ct(i,"root",a),ct(e,r,i)}else ct(e,r,a)}return e},h8=(n,t)=>n.some(e=>e.startsWith(t+"."));var p8=function(n,t){for(var e={};n.length;){var r=n[0],o=r.code,a=r.message,i=r.path.join(".");if(!e[i])if("unionErrors"in r){var s=r.unionErrors[0].errors[0];e[i]={message:s.message,type:s.code}}else e[i]={message:a,type:o};if("unionErrors"in r&&r.unionErrors.forEach(function(l){return l.errors.forEach(function(d){return n.push(d)})}),t){var u=e[i].types,c=u&&u[r.code];e[i]=Q2(i,t,e,o,c?[].concat(c,r.message):r.message)}n.shift()}return e},du=function(n,t,e){return e===void 0&&(e={}),function(r,o,a){try{return Promise.resolve(function(i,s){try{var u=Promise.resolve(n[e.mode==="sync"?"parse":"parseAsync"](r,t)).then(function(c){return a.shouldUseNativeValidation&&gx({},a),{errors:{},values:e.raw?r:c}})}catch(c){return s(c)}return u&&u.then?u.then(void 0,s):u}(0,function(i){if(function(s){return Array.isArray(s==null?void 0:s.errors)}(i))return{values:{},errors:f8(p8(i.errors,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw i}))}catch(i){return Promise.reject(i)}}},rt;(function(n){n.assertEqual=o=>{};function t(o){}n.assertIs=t;function e(o){throw new Error}n.assertNever=e,n.arrayToEnum=o=>{const a={};for(const i of o)a[i]=i;return a},n.getValidEnumValues=o=>{const a=n.objectKeys(o).filter(s=>typeof o[o[s]]!="number"),i={};for(const s of a)i[s]=o[s];return n.objectValues(i)},n.objectValues=o=>n.objectKeys(o).map(function(a){return o[a]}),n.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{const a=[];for(const i in o)Object.prototype.hasOwnProperty.call(o,i)&&a.push(i);return a},n.find=(o,a)=>{for(const i of o)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function r(o,a=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(o,a)=>typeof a=="bigint"?a.toString():a})(rt||(rt={}));var yx;(function(n){n.mergeShapes=(t,e)=>({...t,...e})})(yx||(yx={}));const Ee=rt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ko=n=>{switch(typeof n){case"undefined":return Ee.undefined;case"string":return Ee.string;case"number":return Number.isNaN(n)?Ee.nan:Ee.number;case"boolean":return Ee.boolean;case"function":return Ee.function;case"bigint":return Ee.bigint;case"symbol":return Ee.symbol;case"object":return Array.isArray(n)?Ee.array:n===null?Ee.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Ee.promise:typeof Map<"u"&&n instanceof Map?Ee.map:typeof Set<"u"&&n instanceof Set?Ee.set:typeof Date<"u"&&n instanceof Date?Ee.date:Ee.object;default:return Ee.unknown}},fe=rt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class vo extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=t}format(t){const e=t||function(a){return a.message},r={_errors:[]},o=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)r._errors.push(e(i));else{let s=r,u=0;for(;u<i.path.length;){const c=i.path[u];u===i.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(e(i))):s[c]=s[c]||{_errors:[]},s=s[c],u++}}};return o(this),r}static assert(t){if(!(t instanceof vo))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,rt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=e=>e.message){const e={},r=[];for(const o of this.issues)if(o.path.length>0){const a=o.path[0];e[a]=e[a]||[],e[a].push(t(o))}else r.push(t(o));return{formErrors:r,fieldErrors:e}}get formErrors(){return this.flatten()}}vo.create=n=>new vo(n);const Bp=(n,t)=>{let e;switch(n.code){case fe.invalid_type:n.received===Ee.undefined?e="Required":e=`Expected ${n.expected}, received ${n.received}`;break;case fe.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(n.expected,rt.jsonStringifyReplacer)}`;break;case fe.unrecognized_keys:e=`Unrecognized key(s) in object: ${rt.joinValues(n.keys,", ")}`;break;case fe.invalid_union:e="Invalid input";break;case fe.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${rt.joinValues(n.options)}`;break;case fe.invalid_enum_value:e=`Invalid enum value. Expected ${rt.joinValues(n.options)}, received '${n.received}'`;break;case fe.invalid_arguments:e="Invalid function arguments";break;case fe.invalid_return_type:e="Invalid function return type";break;case fe.invalid_date:e="Invalid date";break;case fe.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(e=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(e=`${e} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?e=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?e=`Invalid input: must end with "${n.validation.endsWith}"`:rt.assertNever(n.validation):n.validation!=="regex"?e=`Invalid ${n.validation}`:e="Invalid";break;case fe.too_small:n.type==="array"?e=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?e=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?e=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?e=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?e=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:e="Invalid input";break;case fe.too_big:n.type==="array"?e=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?e=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?e=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?e=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?e=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:e="Invalid input";break;case fe.custom:e="Invalid input";break;case fe.invalid_intersection_types:e="Intersection results could not be merged";break;case fe.not_multiple_of:e=`Number must be a multiple of ${n.multipleOf}`;break;case fe.not_finite:e="Number must be finite";break;default:e=t.defaultError,rt.assertNever(n)}return{message:e}};let v8=Bp;function m8(){return v8}const g8=n=>{const{data:t,path:e,errorMaps:r,issueData:o}=n,a=[...e,...o.path||[]],i={...o,path:a};if(o.message!==void 0)return{...o,path:a,message:o.message};let s="";const u=r.filter(c=>!!c).slice().reverse();for(const c of u)s=c(i,{data:t,defaultError:s}).message;return{...o,path:a,message:s}};function be(n,t){const e=m8(),r=g8({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,e,e===Bp?void 0:Bp].filter(o=>!!o)});n.common.issues.push(r)}class Hn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,e){const r=[];for(const o of e){if(o.status==="aborted")return Re;o.status==="dirty"&&t.dirty(),r.push(o.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,e){const r=[];for(const o of e){const a=await o.key,i=await o.value;r.push({key:a,value:i})}return Hn.mergeObjectSync(t,r)}static mergeObjectSync(t,e){const r={};for(const o of e){const{key:a,value:i}=o;if(a.status==="aborted"||i.status==="aborted")return Re;a.status==="dirty"&&t.dirty(),i.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(r[a.value]=i.value)}return{status:t.value,value:r}}}const Re=Object.freeze({status:"aborted"}),fu=n=>({status:"dirty",value:n}),Qn=n=>({status:"valid",value:n}),bx=n=>n.status==="aborted",xx=n=>n.status==="dirty",Ui=n=>n.status==="valid",Ml=n=>typeof Promise<"u"&&n instanceof Promise;var Pe;(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Pe||(Pe={}));class Yo{constructor(t,e,r,o){this._cachedPath=[],this.parent=t,this.data=e,this._path=r,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const wx=(n,t)=>{if(Ui(t))return{success:!0,data:t.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const e=new vo(n.common.issues);return this._error=e,this._error}}};function Ke(n){if(!n)return{};const{errorMap:t,invalid_type_error:e,required_error:r,description:o}=n;if(t&&(e||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:(i,s)=>{const{message:u}=n;return i.code==="invalid_enum_value"?{message:u??s.defaultError}:typeof s.data>"u"?{message:u??r??s.defaultError}:i.code!=="invalid_type"?{message:s.defaultError}:{message:u??e??s.defaultError}},description:o}}class tt{get description(){return this._def.description}_getType(t){return Ko(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:Ko(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Hn,ctx:{common:t.parent.common,data:t.data,parsedType:Ko(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const e=this._parse(t);if(Ml(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){const e=this._parse(t);return Promise.resolve(e)}parse(t,e){const r=this.safeParse(t,e);if(r.success)return r.data;throw r.error}safeParse(t,e){const r={common:{issues:[],async:(e==null?void 0:e.async)??!1,contextualErrorMap:e==null?void 0:e.errorMap},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ko(t)},o=this._parseSync({data:t,path:r.path,parent:r});return wx(r,o)}"~validate"(t){var r,o;const e={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ko(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:e});return Ui(a)?{value:a.value}:{issues:e.common.issues}}catch(a){(o=(r=a==null?void 0:a.message)==null?void 0:r.toLowerCase())!=null&&o.includes("encountered")&&(this["~standard"].async=!0),e.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:e}).then(a=>Ui(a)?{value:a.value}:{issues:e.common.issues})}async parseAsync(t,e){const r=await this.safeParseAsync(t,e);if(r.success)return r.data;throw r.error}async safeParseAsync(t,e){const r={common:{issues:[],contextualErrorMap:e==null?void 0:e.errorMap,async:!0},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ko(t)},o=this._parse({data:t,path:r.path,parent:r}),a=await(Ml(o)?o:Promise.resolve(o));return wx(r,a)}refine(t,e){const r=o=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(o):e;return this._refinement((o,a)=>{const i=t(o),s=()=>a.addIssue({code:fe.custom,...r(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(s(),!1)):i?!0:(s(),!1)})}refinement(t,e){return this._refinement((r,o)=>t(r)?!0:(o.addIssue(typeof e=="function"?e(r,o):e),!1))}_refinement(t){return new Gi({schema:this,typeName:Le.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Qo.create(this,this._def)}nullable(){return qi.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Hr.create(this)}promise(){return Ll.create(this,this._def)}or(t){return Fl.create([this,t],this._def)}and(t){return Rl.create(this,t,this._def)}transform(t){return new Gi({...Ke(this._def),schema:this,typeName:Le.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const e=typeof t=="function"?t:()=>t;return new Up({...Ke(this._def),innerType:this,defaultValue:e,typeName:Le.ZodDefault})}brand(){return new W8({typeName:Le.ZodBranded,type:this,...Ke(this._def)})}catch(t){const e=typeof t=="function"?t:()=>t;return new zp({...Ke(this._def),innerType:this,catchValue:e,typeName:Le.ZodCatch})}describe(t){const e=this.constructor;return new e({...this._def,description:t})}pipe(t){return Hp.create(this,t)}readonly(){return Gp.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const y8=/^c[^\s-]{8,}$/i,b8=/^[0-9a-z]+$/,x8=/^[0-9A-HJKMNP-TV-Z]{26}$/i,w8=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,C8=/^[a-z0-9_-]{21}$/i,_8=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,E8=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,S8=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,N8="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Wp;const $8=/^(?:(?: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])$/,k8=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,P8=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,I8=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,A8=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,T8=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Cx="((\\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])))",O8=new RegExp(`^${Cx}$`);function _x(n){let t="[0-5]\\d";n.precision?t=`${t}\\.\\d{${n.precision}}`:n.precision==null&&(t=`${t}(\\.\\d+)?`);const e=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e}`}function D8(n){return new RegExp(`^${_x(n)}$`)}function M8(n){let t=`${Cx}T${_x(n)}`;const e=[];return e.push(n.local?"Z?":"Z"),n.offset&&e.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${e.join("|")})`,new RegExp(`^${t}$`)}function F8(n,t){return!!((t==="v4"||!t)&&$8.test(n)||(t==="v6"||!t)&&P8.test(n))}function R8(n,t){if(!_8.test(n))return!1;try{const[e]=n.split(".");if(!e)return!1;const r=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),o=JSON.parse(atob(r));return!(typeof o!="object"||o===null||"typ"in o&&(o==null?void 0:o.typ)!=="JWT"||!o.alg||t&&o.alg!==t)}catch{return!1}}function L8(n,t){return!!((t==="v4"||!t)&&k8.test(n)||(t==="v6"||!t)&&I8.test(n))}class Xo extends tt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Ee.string){const a=this._getOrReturnCtx(t);return be(a,{code:fe.invalid_type,expected:Ee.string,received:a.parsedType}),Re}const r=new Hn;let o;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(o=this._getOrReturnCtx(t,o),be(o,{code:fe.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")t.data.length>a.value&&(o=this._getOrReturnCtx(t,o),be(o,{code:fe.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const i=t.data.length>a.value,s=t.data.length<a.value;(i||s)&&(o=this._getOrReturnCtx(t,o),i?be(o,{code:fe.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&be(o,{code:fe.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")S8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"email",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")Wp||(Wp=new RegExp(N8,"u")),Wp.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"emoji",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")w8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"uuid",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")C8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"nanoid",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")y8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"cuid",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")b8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"cuid2",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")x8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"ulid",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),be(o,{validation:"url",code:fe.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"regex",code:fe.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?M8(a).test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?O8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?D8(a).test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?E8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"duration",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?F8(t.data,a.version)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"ip",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?R8(t.data,a.alg)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"jwt",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?L8(t.data,a.version)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"cidr",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?A8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"base64",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?T8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"base64url",code:fe.invalid_string,message:a.message}),r.dirty()):rt.assertNever(a);return{status:r.value,value:t.data}}_regex(t,e,r){return this.refinement(o=>t.test(o),{validation:e,code:fe.invalid_string,...Pe.errToObj(r)})}_addCheck(t){return new Xo({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Pe.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Pe.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Pe.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Pe.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Pe.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Pe.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Pe.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Pe.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Pe.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Pe.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Pe.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Pe.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Pe.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...Pe.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Pe.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Pe.errToObj(t)})}regex(t,e){return this._addCheck({kind:"regex",regex:t,...Pe.errToObj(e)})}includes(t,e){return this._addCheck({kind:"includes",value:t,position:e==null?void 0:e.position,...Pe.errToObj(e==null?void 0:e.message)})}startsWith(t,e){return this._addCheck({kind:"startsWith",value:t,...Pe.errToObj(e)})}endsWith(t,e){return this._addCheck({kind:"endsWith",value:t,...Pe.errToObj(e)})}min(t,e){return this._addCheck({kind:"min",value:t,...Pe.errToObj(e)})}max(t,e){return this._addCheck({kind:"max",value:t,...Pe.errToObj(e)})}length(t,e){return this._addCheck({kind:"length",value:t,...Pe.errToObj(e)})}nonempty(t){return this.min(1,Pe.errToObj(t))}trim(){return new Xo({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Xo({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Xo({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxLength(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}Xo.create=n=>new Xo({checks:[],typeName:Le.ZodString,coerce:(n==null?void 0:n.coerce)??!1,...Ke(n)});function B8(n,t){const e=(n.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,o=e>r?e:r,a=Number.parseInt(n.toFixed(o).replace(".","")),i=Number.parseInt(t.toFixed(o).replace(".",""));return a%i/10**o}class hu extends tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Ee.number){const a=this._getOrReturnCtx(t);return be(a,{code:fe.invalid_type,expected:Ee.number,received:a.parsedType}),Re}let r;const o=new Hn;for(const a of this._def.checks)a.kind==="int"?rt.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{code:fe.invalid_type,expected:"integer",received:"float",message:a.message}),o.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="multipleOf"?B8(t.data,a.value)!==0&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{code:fe.not_finite,message:a.message}),o.dirty()):rt.assertNever(a);return{status:o.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,Pe.toString(e))}gt(t,e){return this.setLimit("min",t,!1,Pe.toString(e))}lte(t,e){return this.setLimit("max",t,!0,Pe.toString(e))}lt(t,e){return this.setLimit("max",t,!1,Pe.toString(e))}setLimit(t,e,r,o){return new hu({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:Pe.toString(o)}]})}_addCheck(t){return new hu({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Pe.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Pe.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Pe.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Pe.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Pe.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:Pe.toString(e)})}finite(t){return this._addCheck({kind:"finite",message:Pe.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Pe.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Pe.toString(t)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&rt.isInteger(t.value))}get isFinite(){let t=null,e=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(e===null||r.value>e)&&(e=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(e)&&Number.isFinite(t)}}hu.create=n=>new hu({checks:[],typeName:Le.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...Ke(n)});class pu extends tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Ee.bigint)return this._getInvalidInput(t);let r;const o=new Hn;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):rt.assertNever(a);return{status:o.value,value:t.data}}_getInvalidInput(t){const e=this._getOrReturnCtx(t);return be(e,{code:fe.invalid_type,expected:Ee.bigint,received:e.parsedType}),Re}gte(t,e){return this.setLimit("min",t,!0,Pe.toString(e))}gt(t,e){return this.setLimit("min",t,!1,Pe.toString(e))}lte(t,e){return this.setLimit("max",t,!0,Pe.toString(e))}lt(t,e){return this.setLimit("max",t,!1,Pe.toString(e))}setLimit(t,e,r,o){return new pu({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:Pe.toString(o)}]})}_addCheck(t){return new pu({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Pe.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Pe.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Pe.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Pe.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:Pe.toString(e)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}pu.create=n=>new pu({checks:[],typeName:Le.ZodBigInt,coerce:(n==null?void 0:n.coerce)??!1,...Ke(n)});class Ex extends tt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Ee.boolean){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.boolean,received:r.parsedType}),Re}return Qn(t.data)}}Ex.create=n=>new Ex({typeName:Le.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...Ke(n)});class vu extends tt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Ee.date){const a=this._getOrReturnCtx(t);return be(a,{code:fe.invalid_type,expected:Ee.date,received:a.parsedType}),Re}if(Number.isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return be(a,{code:fe.invalid_date}),Re}const r=new Hn;let o;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(o=this._getOrReturnCtx(t,o),be(o,{code:fe.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(o=this._getOrReturnCtx(t,o),be(o,{code:fe.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):rt.assertNever(a);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new vu({...this._def,checks:[...this._def.checks,t]})}min(t,e){return this._addCheck({kind:"min",value:t.getTime(),message:Pe.toString(e)})}max(t,e){return this._addCheck({kind:"max",value:t.getTime(),message:Pe.toString(e)})}get minDate(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t!=null?new Date(t):null}}vu.create=n=>new vu({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:Le.ZodDate,...Ke(n)});class Sx extends tt{_parse(t){if(this._getType(t)!==Ee.symbol){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.symbol,received:r.parsedType}),Re}return Qn(t.data)}}Sx.create=n=>new Sx({typeName:Le.ZodSymbol,...Ke(n)});class Nx extends tt{_parse(t){if(this._getType(t)!==Ee.undefined){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.undefined,received:r.parsedType}),Re}return Qn(t.data)}}Nx.create=n=>new Nx({typeName:Le.ZodUndefined,...Ke(n)});class $x extends tt{_parse(t){if(this._getType(t)!==Ee.null){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.null,received:r.parsedType}),Re}return Qn(t.data)}}$x.create=n=>new $x({typeName:Le.ZodNull,...Ke(n)});class mu extends tt{constructor(){super(...arguments),this._any=!0}_parse(t){return Qn(t.data)}}mu.create=n=>new mu({typeName:Le.ZodAny,...Ke(n)});class kx extends tt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Qn(t.data)}}kx.create=n=>new kx({typeName:Le.ZodUnknown,...Ke(n)});class Zo extends tt{_parse(t){const e=this._getOrReturnCtx(t);return be(e,{code:fe.invalid_type,expected:Ee.never,received:e.parsedType}),Re}}Zo.create=n=>new Zo({typeName:Le.ZodNever,...Ke(n)});class Px extends tt{_parse(t){if(this._getType(t)!==Ee.undefined){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.void,received:r.parsedType}),Re}return Qn(t.data)}}Px.create=n=>new Px({typeName:Le.ZodVoid,...Ke(n)});class Hr extends tt{_parse(t){const{ctx:e,status:r}=this._processInputParams(t),o=this._def;if(e.parsedType!==Ee.array)return be(e,{code:fe.invalid_type,expected:Ee.array,received:e.parsedType}),Re;if(o.exactLength!==null){const i=e.data.length>o.exactLength.value,s=e.data.length<o.exactLength.value;(i||s)&&(be(e,{code:i?fe.too_big:fe.too_small,minimum:s?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),r.dirty())}if(o.minLength!==null&&e.data.length<o.minLength.value&&(be(e,{code:fe.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&e.data.length>o.maxLength.value&&(be(e,{code:fe.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),r.dirty()),e.common.async)return Promise.all([...e.data].map((i,s)=>o.type._parseAsync(new Yo(e,i,e.path,s)))).then(i=>Hn.mergeArray(r,i));const a=[...e.data].map((i,s)=>o.type._parseSync(new Yo(e,i,e.path,s)));return Hn.mergeArray(r,a)}get element(){return this._def.type}min(t,e){return new Hr({...this._def,minLength:{value:t,message:Pe.toString(e)}})}max(t,e){return new Hr({...this._def,maxLength:{value:t,message:Pe.toString(e)}})}length(t,e){return new Hr({...this._def,exactLength:{value:t,message:Pe.toString(e)}})}nonempty(t){return this.min(1,t)}}Hr.create=(n,t)=>new Hr({type:n,minLength:null,maxLength:null,exactLength:null,typeName:Le.ZodArray,...Ke(t)});function zi(n){if(n instanceof Ft){const t={};for(const e in n.shape){const r=n.shape[e];t[e]=Qo.create(zi(r))}return new Ft({...n._def,shape:()=>t})}else return n instanceof Hr?new Hr({...n._def,type:zi(n.element)}):n instanceof Qo?Qo.create(zi(n.unwrap())):n instanceof qi?qi.create(zi(n.unwrap())):n instanceof ja?ja.create(n.items.map(t=>zi(t))):n}class Ft extends tt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),e=rt.objectKeys(t);return this._cached={shape:t,keys:e},this._cached}_parse(t){if(this._getType(t)!==Ee.object){const c=this._getOrReturnCtx(t);return be(c,{code:fe.invalid_type,expected:Ee.object,received:c.parsedType}),Re}const{status:r,ctx:o}=this._processInputParams(t),{shape:a,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof Zo&&this._def.unknownKeys==="strip"))for(const c in o.data)i.includes(c)||s.push(c);const u=[];for(const c of i){const l=a[c],d=o.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new Yo(o,d,o.path,c)),alwaysSet:c in o.data})}if(this._def.catchall instanceof Zo){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of s)u.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(c==="strict")s.length>0&&(be(o,{code:fe.unrecognized_keys,keys:s}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of s){const d=o.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new Yo(o,d,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of u){const d=await l.key,f=await l.value;c.push({key:d,value:f,alwaysSet:l.alwaysSet})}return c}).then(c=>Hn.mergeObjectSync(r,c)):Hn.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(t){return Pe.errToObj,new Ft({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(e,r)=>{var a,i;const o=((i=(a=this._def).errorMap)==null?void 0:i.call(a,e,r).message)??r.defaultError;return e.code==="unrecognized_keys"?{message:Pe.errToObj(t).message??o}:{message:o}}}:{}})}strip(){return new Ft({...this._def,unknownKeys:"strip"})}passthrough(){return new Ft({...this._def,unknownKeys:"passthrough"})}extend(t){return new Ft({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Ft({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Le.ZodObject})}setKey(t,e){return this.augment({[t]:e})}catchall(t){return new Ft({...this._def,catchall:t})}pick(t){const e={};for(const r of rt.objectKeys(t))t[r]&&this.shape[r]&&(e[r]=this.shape[r]);return new Ft({...this._def,shape:()=>e})}omit(t){const e={};for(const r of rt.objectKeys(this.shape))t[r]||(e[r]=this.shape[r]);return new Ft({...this._def,shape:()=>e})}deepPartial(){return zi(this)}partial(t){const e={};for(const r of rt.objectKeys(this.shape)){const o=this.shape[r];t&&!t[r]?e[r]=o:e[r]=o.optional()}return new Ft({...this._def,shape:()=>e})}required(t){const e={};for(const r of rt.objectKeys(this.shape))if(t&&!t[r])e[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof Qo;)a=a._def.innerType;e[r]=a}return new Ft({...this._def,shape:()=>e})}keyof(){return Tx(rt.objectKeys(this.shape))}}Ft.create=(n,t)=>new Ft({shape:()=>n,unknownKeys:"strip",catchall:Zo.create(),typeName:Le.ZodObject,...Ke(t)}),Ft.strictCreate=(n,t)=>new Ft({shape:()=>n,unknownKeys:"strict",catchall:Zo.create(),typeName:Le.ZodObject,...Ke(t)}),Ft.lazycreate=(n,t)=>new Ft({shape:n,unknownKeys:"strip",catchall:Zo.create(),typeName:Le.ZodObject,...Ke(t)});class Fl extends tt{_parse(t){const{ctx:e}=this._processInputParams(t),r=this._def.options;function o(a){for(const s of a)if(s.result.status==="valid")return s.result;for(const s of a)if(s.result.status==="dirty")return e.common.issues.push(...s.ctx.common.issues),s.result;const i=a.map(s=>new vo(s.ctx.common.issues));return be(e,{code:fe.invalid_union,unionErrors:i}),Re}if(e.common.async)return Promise.all(r.map(async a=>{const i={...e,common:{...e.common,issues:[]},parent:null};return{result:await a._parseAsync({data:e.data,path:e.path,parent:i}),ctx:i}})).then(o);{let a;const i=[];for(const u of r){const c={...e,common:{...e.common,issues:[]},parent:null},l=u._parseSync({data:e.data,path:e.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(a)return e.common.issues.push(...a.ctx.common.issues),a.result;const s=i.map(u=>new vo(u));return be(e,{code:fe.invalid_union,unionErrors:s}),Re}}get options(){return this._def.options}}Fl.create=(n,t)=>new Fl({options:n,typeName:Le.ZodUnion,...Ke(t)});function Vp(n,t){const e=Ko(n),r=Ko(t);if(n===t)return{valid:!0,data:n};if(e===Ee.object&&r===Ee.object){const o=rt.objectKeys(t),a=rt.objectKeys(n).filter(s=>o.indexOf(s)!==-1),i={...n,...t};for(const s of a){const u=Vp(n[s],t[s]);if(!u.valid)return{valid:!1};i[s]=u.data}return{valid:!0,data:i}}else if(e===Ee.array&&r===Ee.array){if(n.length!==t.length)return{valid:!1};const o=[];for(let a=0;a<n.length;a++){const i=n[a],s=t[a],u=Vp(i,s);if(!u.valid)return{valid:!1};o.push(u.data)}return{valid:!0,data:o}}else return e===Ee.date&&r===Ee.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}class Rl extends tt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t),o=(a,i)=>{if(bx(a)||bx(i))return Re;const s=Vp(a.value,i.value);return s.valid?((xx(a)||xx(i))&&e.dirty(),{status:e.value,value:s.data}):(be(r,{code:fe.invalid_intersection_types}),Re)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>o(a,i)):o(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Rl.create=(n,t,e)=>new Rl({left:n,right:t,typeName:Le.ZodIntersection,...Ke(e)});class ja extends tt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Ee.array)return be(r,{code:fe.invalid_type,expected:Ee.array,received:r.parsedType}),Re;if(r.data.length<this._def.items.length)return be(r,{code:fe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Re;!this._def.rest&&r.data.length>this._def.items.length&&(be(r,{code:fe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());const a=[...r.data].map((i,s)=>{const u=this._def.items[s]||this._def.rest;return u?u._parse(new Yo(r,i,r.path,s)):null}).filter(i=>!!i);return r.common.async?Promise.all(a).then(i=>Hn.mergeArray(e,i)):Hn.mergeArray(e,a)}get items(){return this._def.items}rest(t){return new ja({...this._def,rest:t})}}ja.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ja({items:n,typeName:Le.ZodTuple,rest:null,...Ke(t)})};class Ix extends tt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Ee.map)return be(r,{code:fe.invalid_type,expected:Ee.map,received:r.parsedType}),Re;const o=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([s,u],c)=>({key:o._parse(new Yo(r,s,r.path,[c,"key"])),value:a._parse(new Yo(r,u,r.path,[c,"value"]))}));if(r.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const u of i){const c=await u.key,l=await u.value;if(c.status==="aborted"||l.status==="aborted")return Re;(c.status==="dirty"||l.status==="dirty")&&e.dirty(),s.set(c.value,l.value)}return{status:e.value,value:s}})}else{const s=new Map;for(const u of i){const c=u.key,l=u.value;if(c.status==="aborted"||l.status==="aborted")return Re;(c.status==="dirty"||l.status==="dirty")&&e.dirty(),s.set(c.value,l.value)}return{status:e.value,value:s}}}}Ix.create=(n,t,e)=>new Ix({valueType:t,keyType:n,typeName:Le.ZodMap,...Ke(e)});class gu extends tt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Ee.set)return be(r,{code:fe.invalid_type,expected:Ee.set,received:r.parsedType}),Re;const o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(be(r,{code:fe.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),e.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(be(r,{code:fe.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),e.dirty());const a=this._def.valueType;function i(u){const c=new Set;for(const l of u){if(l.status==="aborted")return Re;l.status==="dirty"&&e.dirty(),c.add(l.value)}return{status:e.value,value:c}}const s=[...r.data.values()].map((u,c)=>a._parse(new Yo(r,u,r.path,c)));return r.common.async?Promise.all(s).then(u=>i(u)):i(s)}min(t,e){return new gu({...this._def,minSize:{value:t,message:Pe.toString(e)}})}max(t,e){return new gu({...this._def,maxSize:{value:t,message:Pe.toString(e)}})}size(t,e){return this.min(t,e).max(t,e)}nonempty(t){return this.min(1,t)}}gu.create=(n,t)=>new gu({valueType:n,minSize:null,maxSize:null,typeName:Le.ZodSet,...Ke(t)});class Ax extends tt{get schema(){return this._def.getter()}_parse(t){const{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}}Ax.create=(n,t)=>new Ax({getter:n,typeName:Le.ZodLazy,...Ke(t)});class jp extends tt{_parse(t){if(t.data!==this._def.value){const e=this._getOrReturnCtx(t);return be(e,{received:e.data,code:fe.invalid_literal,expected:this._def.value}),Re}return{status:"valid",value:t.data}}get value(){return this._def.value}}jp.create=(n,t)=>new jp({value:n,typeName:Le.ZodLiteral,...Ke(t)});function Tx(n,t){return new Hi({values:n,typeName:Le.ZodEnum,...Ke(t)})}class Hi extends tt{_parse(t){if(typeof t.data!="string"){const e=this._getOrReturnCtx(t),r=this._def.values;return be(e,{expected:rt.joinValues(r),received:e.parsedType,code:fe.invalid_type}),Re}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const e=this._getOrReturnCtx(t),r=this._def.values;return be(e,{received:e.data,code:fe.invalid_enum_value,options:r}),Re}return Qn(t.data)}get options(){return this._def.values}get enum(){const t={};for(const e of this._def.values)t[e]=e;return t}get Values(){const t={};for(const e of this._def.values)t[e]=e;return t}get Enum(){const t={};for(const e of this._def.values)t[e]=e;return t}extract(t,e=this._def){return Hi.create(t,{...this._def,...e})}exclude(t,e=this._def){return Hi.create(this.options.filter(r=>!t.includes(r)),{...this._def,...e})}}Hi.create=Tx;class Ox extends tt{_parse(t){const e=rt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==Ee.string&&r.parsedType!==Ee.number){const o=rt.objectValues(e);return be(r,{expected:rt.joinValues(o),received:r.parsedType,code:fe.invalid_type}),Re}if(this._cache||(this._cache=new Set(rt.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const o=rt.objectValues(e);return be(r,{received:r.data,code:fe.invalid_enum_value,options:o}),Re}return Qn(t.data)}get enum(){return this._def.values}}Ox.create=(n,t)=>new Ox({values:n,typeName:Le.ZodNativeEnum,...Ke(t)});class Ll extends tt{unwrap(){return this._def.type}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==Ee.promise&&e.common.async===!1)return be(e,{code:fe.invalid_type,expected:Ee.promise,received:e.parsedType}),Re;const r=e.parsedType===Ee.promise?e.data:Promise.resolve(e.data);return Qn(r.then(o=>this._def.type.parseAsync(o,{path:e.path,errorMap:e.common.contextualErrorMap})))}}Ll.create=(n,t)=>new Ll({type:n,typeName:Le.ZodPromise,...Ke(t)});class Gi extends tt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Le.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:e,ctx:r}=this._processInputParams(t),o=this._def.effect||null,a={addIssue:i=>{be(r,i),i.fatal?e.abort():e.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),o.type==="preprocess"){const i=o.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(async s=>{if(e.value==="aborted")return Re;const u=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return u.status==="aborted"?Re:u.status==="dirty"||e.value==="dirty"?fu(u.value):u});{if(e.value==="aborted")return Re;const s=this._def.schema._parseSync({data:i,path:r.path,parent:r});return s.status==="aborted"?Re:s.status==="dirty"||e.value==="dirty"?fu(s.value):s}}if(o.type==="refinement"){const i=s=>{const u=o.refinement(s,a);if(r.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Re:(s.status==="dirty"&&e.dirty(),i(s.value),{status:e.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?Re:(s.status==="dirty"&&e.dirty(),i(s.value).then(()=>({status:e.value,value:s.value}))))}if(o.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ui(i))return Re;const s=o.transform(i.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>Ui(i)?Promise.resolve(o.transform(i.value,a)).then(s=>({status:e.value,value:s})):Re);rt.assertNever(o)}}Gi.create=(n,t,e)=>new Gi({schema:n,typeName:Le.ZodEffects,effect:t,...Ke(e)}),Gi.createWithPreprocess=(n,t,e)=>new Gi({schema:t,effect:{type:"preprocess",transform:n},typeName:Le.ZodEffects,...Ke(e)});class Qo extends tt{_parse(t){return this._getType(t)===Ee.undefined?Qn(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Qo.create=(n,t)=>new Qo({innerType:n,typeName:Le.ZodOptional,...Ke(t)});class qi extends tt{_parse(t){return this._getType(t)===Ee.null?Qn(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}qi.create=(n,t)=>new qi({innerType:n,typeName:Le.ZodNullable,...Ke(t)});class Up extends tt{_parse(t){const{ctx:e}=this._processInputParams(t);let r=e.data;return e.parsedType===Ee.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:e.path,parent:e})}removeDefault(){return this._def.innerType}}Up.create=(n,t)=>new Up({innerType:n,typeName:Le.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ke(t)});class zp extends tt{_parse(t){const{ctx:e}=this._processInputParams(t),r={...e,common:{...e.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ml(o)?o.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new vo(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new vo(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}zp.create=(n,t)=>new zp({innerType:n,typeName:Le.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ke(t)});class Dx extends tt{_parse(t){if(this._getType(t)!==Ee.nan){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.nan,received:r.parsedType}),Re}return{status:"valid",value:t.data}}}Dx.create=n=>new Dx({typeName:Le.ZodNaN,...Ke(n)});class W8 extends tt{_parse(t){const{ctx:e}=this._processInputParams(t),r=e.data;return this._def.type._parse({data:r,path:e.path,parent:e})}unwrap(){return this._def.type}}class Hp extends tt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Re:a.status==="dirty"?(e.dirty(),fu(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?Re:o.status==="dirty"?(e.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(t,e){return new Hp({in:t,out:e,typeName:Le.ZodPipeline})}}class Gp extends tt{_parse(t){const e=this._def.innerType._parse(t),r=o=>(Ui(o)&&(o.value=Object.freeze(o.value)),o);return Ml(e)?e.then(o=>r(o)):r(e)}unwrap(){return this._def.innerType}}Gp.create=(n,t)=>new Gp({innerType:n,typeName:Le.ZodReadonly,...Ke(t)});function Mx(n,t){const e=typeof n=="function"?n(t):typeof n=="string"?{message:n}:n;return typeof e=="string"?{message:e}:e}function V8(n,t={},e){return n?mu.create().superRefine((r,o)=>{const a=n(r);if(a instanceof Promise)return a.then(i=>{if(!i){const s=Mx(t,r),u=s.fatal??e??!0;o.addIssue({code:"custom",...s,fatal:u})}});if(!a){const i=Mx(t,r),s=i.fatal??e??!0;o.addIssue({code:"custom",...i,fatal:s})}}):mu.create()}var Le;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(Le||(Le={}));const qp=(n,t={message:`Input not instance of ${n.name}`})=>V8(e=>e instanceof n,t),Xt=Xo.create,Fx=vu.create;mu.create,Zo.create,Hr.create;const yu=Ft.create;Fl.create,Rl.create,ja.create;const j8=jp.create;Hi.create,Ll.create,Qo.create,qi.create;const bu=KD,Rx=k.createContext({}),Tt=({...n})=>b.jsx(Rx.Provider,{value:{name:n.name},children:b.jsx(ZD,{...n})}),Bl=()=>{const n=k.useContext(Rx),t=k.useContext(Lx),{getFieldState:e,formState:r}=Tl(),o=e(n.name,r);if(!n)throw new Error("useFormField should be used within <FormField>");const{id:a}=t;return{id:a,name:n.name,formItemId:`${a}-form-item`,formDescriptionId:`${a}-form-item-description`,formMessageId:`${a}-form-item-message`,...o}},Lx=k.createContext({}),St=k.forwardRef(({className:n,...t},e)=>{const r=k.useId();return b.jsx(Lx.Provider,{value:{id:r},children:b.jsx("div",{ref:e,className:Be("space-y-2",n),...t})})});St.displayName="FormItem";const Nt=k.forwardRef(({className:n,...t},e)=>{const{error:r,formItemId:o}=Bl();return b.jsx(Ea,{ref:e,className:Be(r&&"text-destructive",n),htmlFor:o,...t})});Nt.displayName="FormLabel";const $t=k.forwardRef(({...n},t)=>{const{error:e,formItemId:r,formDescriptionId:o,formMessageId:a}=Bl();return b.jsx(Vm,{ref:t,id:r,"aria-describedby":e?`${o} ${a}`:`${o}`,"aria-invalid":!!e,...n})});$t.displayName="FormControl";const U8=k.forwardRef(({className:n,...t},e)=>{const{formDescriptionId:r}=Bl();return b.jsx("p",{ref:e,id:r,className:Be("text-sm text-muted-foreground",n),...t})});U8.displayName="FormDescription";const kt=k.forwardRef(({className:n,children:t,...e},r)=>{const{error:o,formMessageId:a}=Bl(),i=o?String(o==null?void 0:o.message):t;return i?b.jsx("p",{ref:r,id:a,className:Be("text-sm font-medium text-destructive",n),...e,children:i}):null});kt.displayName="FormMessage";const z8=yu({bank_statement:qp(File).optional().refine(n=>n!==void 0,"Bank statement is required"),company_structure:qp(File).optional().refine(n=>n!==void 0,"Company structure document is required"),certificate_of_registration:qp(File).optional().refine(n=>n!==void 0,"Certificate of registration is required")}),H8=({data:n,onDataChange:t,onContinue:e,onBack:r,renderProgress:o})=>{const a=D.useRef(null),i=D.useRef(null),s=D.useRef(null),u=lu({resolver:du(z8),defaultValues:{bank_statement:n.bank_statement||void 0,company_structure:n.company_structure||void 0,certificate_of_registration:n.certificate_of_registration||void 0}}),c=f=>{t(f),e()},l=(f,h)=>{u.setValue(f,h),t({[f]:h})},d=({field:f,label:h,description:m,inputRef:p})=>{const v=u.watch(f);return b.jsx(Tt,{control:u.control,name:f,render:()=>b.jsxs(St,{children:[b.jsx(Nt,{children:h}),b.jsx($t,{children:b.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-6",children:[b.jsx("input",{ref:p,type:"file",accept:".pdf,.jpg,.jpeg,.png,.doc,.docx",className:"hidden",onChange:g=>{var w;const y=((w=g.target.files)==null?void 0:w[0])||null;l(f,y)}}),v?b.jsxs("div",{className:"flex items-center justify-between",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(nE,{className:"w-5 h-5 text-primary"}),b.jsx("span",{className:"text-sm font-medium",children:v.name})]}),b.jsx(_t,{type:"button",variant:"ghost",size:"sm",onClick:()=>{l(f,null),p.current&&(p.current.value="")},children:b.jsx(Md,{className:"w-4 h-4"})})]}):b.jsxs("div",{className:"text-center cursor-pointer",onClick:()=>{var g;return(g=p.current)==null?void 0:g.click()},children:[b.jsx(oE,{className:"w-8 h-8 mx-auto mb-2 text-muted-foreground"}),b.jsx("p",{className:"font-medium",children:h}),b.jsx("p",{className:"text-sm text-muted-foreground",children:m}),b.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Supported: PDF, JPG, PNG, DOC, DOCX"})]})]})}),b.jsx(kt,{})]})})};return b.jsxs(hn,{className:"w-full max-w-2xl mx-auto",children:[b.jsx(Oo,{children:b.jsx(Do,{title:"Company Documents",subTitle:"Please upload the required company documents",onBack:r})}),b.jsxs(pn,{children:[b.jsx(bu,{...u,children:b.jsxs("form",{onSubmit:u.handleSubmit(c),className:"space-y-6",children:[b.jsx(d,{field:"bank_statement",label:"Bank Statement",description:"Upload your latest bank statement",inputRef:a}),b.jsx(d,{field:"company_structure",label:"Company Structure",description:"Upload document showing directors & legal representatives",inputRef:i}),b.jsx(d,{field:"certificate_of_registration",label:"Certificate of Registration",description:"Upload your company's certificate of registration",inputRef:s}),b.jsx(_t,{type:"submit",className:"w-full",children:"Complete Verification"})]})}),b.jsx("div",{className:"mt-6",children:o()})]})]})};function Bx(n,[t,e]){return Math.min(e,Math.max(t,n))}var G8=k.createContext(void 0);function q8(n){const t=k.useContext(G8);return n||t||"ltr"}var Kp=0;function Wx(){k.useEffect(()=>{const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",n[0]??Vx()),document.body.insertAdjacentElement("beforeend",n[1]??Vx()),Kp++,()=>{Kp===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Kp--}},[])}function Vx(){const n=document.createElement("span");return n.setAttribute("data-radix-focus-guard",""),n.tabIndex=0,n.style.outline="none",n.style.opacity="0",n.style.position="fixed",n.style.pointerEvents="none",n}var Yp="focusScope.autoFocusOnMount",Xp="focusScope.autoFocusOnUnmount",jx={bubbles:!1,cancelable:!0},K8="FocusScope",Zp=k.forwardRef((n,t)=>{const{loop:e=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=n,[s,u]=k.useState(null),c=tr(o),l=tr(a),d=k.useRef(null),f=mt(t,p=>u(p)),h=k.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;k.useEffect(()=>{if(r){let p=function(w){if(h.paused||!s)return;const x=w.target;s.contains(x)?d.current=x:Jo(d.current,{select:!0})},v=function(w){if(h.paused||!s)return;const x=w.relatedTarget;x!==null&&(s.contains(x)||Jo(d.current,{select:!0}))},g=function(w){if(document.activeElement===document.body)for(const C of w)C.removedNodes.length>0&&Jo(s)};document.addEventListener("focusin",p),document.addEventListener("focusout",v);const y=new MutationObserver(g);return s&&y.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",v),y.disconnect()}}},[r,s,h.paused]),k.useEffect(()=>{if(s){Hx.add(h);const p=document.activeElement;if(!s.contains(p)){const g=new CustomEvent(Yp,jx);s.addEventListener(Yp,c),s.dispatchEvent(g),g.defaultPrevented||(Y8(eM(Ux(s)),{select:!0}),document.activeElement===p&&Jo(s))}return()=>{s.removeEventListener(Yp,c),setTimeout(()=>{const g=new CustomEvent(Xp,jx);s.addEventListener(Xp,l),s.dispatchEvent(g),g.defaultPrevented||Jo(p??document.body,{select:!0}),s.removeEventListener(Xp,l),Hx.remove(h)},0)}}},[s,c,l,h]);const m=k.useCallback(p=>{if(!e&&!r||h.paused)return;const v=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,g=document.activeElement;if(v&&g){const y=p.currentTarget,[w,x]=X8(y);w&&x?!p.shiftKey&&g===x?(p.preventDefault(),e&&Jo(w,{select:!0})):p.shiftKey&&g===w&&(p.preventDefault(),e&&Jo(x,{select:!0})):g===y&&p.preventDefault()}},[e,r,h.paused]);return b.jsx(et.div,{tabIndex:-1,...i,ref:f,onKeyDown:m})});Zp.displayName=K8;function Y8(n,{select:t=!1}={}){const e=document.activeElement;for(const r of n)if(Jo(r,{select:t}),document.activeElement!==e)return}function X8(n){const t=Ux(n),e=zx(t,n),r=zx(t.reverse(),n);return[e,r]}function Ux(n){const t=[],e=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;e.nextNode();)t.push(e.currentNode);return t}function zx(n,t){for(const e of n)if(!Z8(e,{upTo:t}))return e}function Z8(n,{upTo:t}){if(getComputedStyle(n).visibility==="hidden")return!0;for(;n;){if(t!==void 0&&n===t)return!1;if(getComputedStyle(n).display==="none")return!0;n=n.parentElement}return!1}function Q8(n){return n instanceof HTMLInputElement&&"select"in n}function Jo(n,{select:t=!1}={}){if(n&&n.focus){const e=document.activeElement;n.focus({preventScroll:!0}),n!==e&&Q8(n)&&t&&n.select()}}var Hx=J8();function J8(){let n=[];return{add(t){const e=n[0];t!==e&&(e==null||e.pause()),n=Gx(n,t),n.unshift(t)},remove(t){var e;n=Gx(n,t),(e=n[0])==null||e.resume()}}}function Gx(n,t){const e=[...n],r=e.indexOf(t);return r!==-1&&e.splice(r,1),e}function eM(n){return n.filter(t=>t.tagName!=="A")}function tM(n){const t=k.useRef({value:n,previous:n});return k.useMemo(()=>(t.current.value!==n&&(t.current.previous=t.current.value,t.current.value=n),t.current.previous),[n])}var nM=function(n){if(typeof document>"u")return null;var t=Array.isArray(n)?n[0]:n;return t.ownerDocument.body},Ki=new WeakMap,Wl=new WeakMap,Vl={},Qp=0,qx=function(n){return n&&(n.host||qx(n.parentNode))},rM=function(n,t){return t.map(function(e){if(n.contains(e))return e;var r=qx(e);return r&&n.contains(r)?r:(console.error("aria-hidden",e,"in not contained inside",n,". Doing nothing"),null)}).filter(function(e){return!!e})},oM=function(n,t,e,r){var o=rM(t,Array.isArray(n)?n:[n]);Vl[e]||(Vl[e]=new WeakMap);var a=Vl[e],i=[],s=new Set,u=new Set(o),c=function(d){!d||s.has(d)||(s.add(d),c(d.parentNode))};o.forEach(c);var l=function(d){!d||u.has(d)||Array.prototype.forEach.call(d.children,function(f){if(s.has(f))l(f);else try{var h=f.getAttribute(r),m=h!==null&&h!=="false",p=(Ki.get(f)||0)+1,v=(a.get(f)||0)+1;Ki.set(f,p),a.set(f,v),i.push(f),p===1&&m&&Wl.set(f,!0),v===1&&f.setAttribute(e,"true"),m||f.setAttribute(r,"true")}catch(g){console.error("aria-hidden: cannot operate on ",f,g)}})};return l(t),s.clear(),Qp++,function(){i.forEach(function(d){var f=Ki.get(d)-1,h=a.get(d)-1;Ki.set(d,f),a.set(d,h),f||(Wl.has(d)||d.removeAttribute(r),Wl.delete(d)),h||d.removeAttribute(e)}),Qp--,Qp||(Ki=new WeakMap,Ki=new WeakMap,Wl=new WeakMap,Vl={})}},Kx=function(n,t,e){e===void 0&&(e="data-aria-hidden");var r=Array.from(Array.isArray(n)?n:[n]),o=nM(n);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),oM(r,o,e,"aria-hidden")):function(){return null}},Gr=function(){return Gr=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},Gr.apply(this,arguments)};function Yx(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(n);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(n,r[o])&&(e[r[o]]=n[r[o]]);return e}function aM(n,t,e){if(e||arguments.length===2)for(var r=0,o=t.length,a;r<o;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return n.concat(a||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var jl="right-scroll-bar-position",Ul="width-before-scroll-bar",iM="with-scroll-bars-hidden",sM="--removed-body-scroll-bar-size";function Jp(n,t){return typeof n=="function"?n(t):n&&(n.current=t),n}function uM(n,t){var e=D.useState(function(){return{value:n,callback:t,facade:{get current(){return e.value},set current(r){var o=e.value;o!==r&&(e.value=r,e.callback(r,o))}}}})[0];return e.callback=t,e.facade}var cM=typeof window<"u"?k.useLayoutEffect:k.useEffect,Xx=new WeakMap;function lM(n,t){var e=uM(null,function(r){return n.forEach(function(o){return Jp(o,r)})});return cM(function(){var r=Xx.get(e);if(r){var o=new Set(r),a=new Set(n),i=e.current;o.forEach(function(s){a.has(s)||Jp(s,null)}),a.forEach(function(s){o.has(s)||Jp(s,i)})}Xx.set(e,n)},[n]),e}function dM(n){return n}function fM(n,t){t===void 0&&(t=dM);var e=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return e.length?e[e.length-1]:n},useMedium:function(a){var i=t(a,r);return e.push(i),function(){e=e.filter(function(s){return s!==i})}},assignSyncMedium:function(a){for(r=!0;e.length;){var i=e;e=[],i.forEach(a)}e={push:function(s){return a(s)},filter:function(){return e}}},assignMedium:function(a){r=!0;var i=[];if(e.length){var s=e;e=[],s.forEach(a),i=e}var u=function(){var l=i;i=[],l.forEach(a)},c=function(){return Promise.resolve().then(u)};c(),e={push:function(l){i.push(l),c()},filter:function(l){return i=i.filter(l),e}}}};return o}function hM(n){n===void 0&&(n={});var t=fM(null);return t.options=Gr({async:!0,ssr:!1},n),t}var Zx=function(n){var t=n.sideCar,e=Yx(n,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return k.createElement(r,Gr({},e))};Zx.isSideCarExport=!0;function pM(n,t){return n.useMedium(t),Zx}var Qx=hM(),ev=function(){},zl=k.forwardRef(function(n,t){var e=k.useRef(null),r=k.useState({onScrollCapture:ev,onWheelCapture:ev,onTouchMoveCapture:ev}),o=r[0],a=r[1],i=n.forwardProps,s=n.children,u=n.className,c=n.removeScrollBar,l=n.enabled,d=n.shards,f=n.sideCar,h=n.noRelative,m=n.noIsolation,p=n.inert,v=n.allowPinchZoom,g=n.as,y=g===void 0?"div":g,w=n.gapMode,x=Yx(n,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=f,_=lM([e,t]),E=Gr(Gr({},x),o);return k.createElement(k.Fragment,null,l&&k.createElement(C,{sideCar:Qx,removeScrollBar:c,shards:d,noRelative:h,noIsolation:m,inert:p,setCallbacks:a,allowPinchZoom:!!v,lockRef:e,gapMode:w}),i?k.cloneElement(k.Children.only(s),Gr(Gr({},E),{ref:_})):k.createElement(y,Gr({},E,{className:u,ref:_}),s))});zl.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},zl.classNames={fullWidth:Ul,zeroRight:jl};var vM=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function mM(){if(!document)return null;var n=document.createElement("style");n.type="text/css";var t=vM();return t&&n.setAttribute("nonce",t),n}function gM(n,t){n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}function yM(n){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(n)}var bM=function(){var n=0,t=null;return{add:function(e){n==0&&(t=mM())&&(gM(t,e),yM(t)),n++},remove:function(){n--,!n&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},xM=function(){var n=bM();return function(t,e){k.useEffect(function(){return n.add(t),function(){n.remove()}},[t&&e])}},Jx=function(){var n=xM(),t=function(e){var r=e.styles,o=e.dynamic;return n(r,o),null};return t},wM={left:0,top:0,right:0,gap:0},tv=function(n){return parseInt(n||"",10)||0},CM=function(n){var t=window.getComputedStyle(document.body),e=t[n==="padding"?"paddingLeft":"marginLeft"],r=t[n==="padding"?"paddingTop":"marginTop"],o=t[n==="padding"?"paddingRight":"marginRight"];return[tv(e),tv(r),tv(o)]},_M=function(n){if(n===void 0&&(n="margin"),typeof window>"u")return wM;var t=CM(n),e=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-e+t[2]-t[0])}},EM=Jx(),Yi="data-scroll-locked",SM=function(n,t,e,r){var o=n.left,a=n.top,i=n.right,s=n.gap;return e===void 0&&(e="margin"),`
|
|
3929
|
+
***************************************************************************** */var Wh=function(n,t){return Wh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var o in r)r.hasOwnProperty(o)&&(e[o]=r[o])},Wh(n,t)};function De(n,t){Wh(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var dn=function(){return dn=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},dn.apply(this,arguments)};function $e(n,t,e,r){function o(a){return a instanceof e?a:new e(function(i){i(a)})}return new(e||(e=Promise))(function(a,i){function s(l){try{c(r.next(l))}catch(d){i(d)}}function u(l){try{c(r.throw(l))}catch(d){i(d)}}function c(l){l.done?a(l.value):o(l.value).then(s,u)}c((r=r.apply(n,[])).next())})}function ke(n,t){var e={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,o,a,i;return i={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(c){return function(l){return u([c,l])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;e;)try{if(r=1,o&&(a=c[0]&2?o.return:c[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,c[1])).done)return a;switch(o=0,a&&(c=[c[0]&2,a.value]),c[0]){case 0:case 1:a=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,o=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(a=e.trys,!(a=a.length>0&&a[a.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){e.label=c[1];break}if(c[0]===6&&e.label<a[1]){e.label=a[1],a=c;break}if(a&&e.label<a[2]){e.label=a[2],e.ops.push(c);break}a[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(l){c=[6,l],o=0}finally{r=a=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function eu(){for(var n=0,t=0,e=arguments.length;t<e;t++)n+=arguments[t].length;for(var r=Array(n),o=0,t=0;t<e;t++)for(var a=arguments[t],i=0,s=a.length;i<s;i++,o++)r[o]=a[i];return r}var Fi=function(){function n(t,e){if(!La(t)||!La(e))throw new Error("Dimensions.constructor - expected width and height to be valid numbers, instead have "+JSON.stringify({width:t,height:e}));this._width=t,this._height=e}return Object.defineProperty(n.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),n.prototype.reverse=function(){return new n(1/this.width,1/this.height)},n}();function fl(n,t){return n instanceof bt&&n.shape.length===t}function l5(n){return fl(n,2)}function hl(n){return fl(n,3)}function jo(n){return fl(n,4)}function d5(n){return n%1!==0}function Bb(n){return n%2===0}function f5(n,t){t===void 0&&(t=2);var e=Math.pow(10,t);return Math.floor(n*e)/e}function Wb(n){return n&&n.width&&n.height}function h5(n,t){var e=n.width,r=n.height,o=t/Math.max(r,e);return new Fi(Math.round(e*o),Math.round(r*o))}function Vh(n){return n.reduce(function(t,e){return t.add(e)},new ot(0,0)).div(new ot(n.length,n.length))}function tu(n,t,e){return Array(n).fill(0).map(function(r,o){return t+o*e})}function La(n){return!!n&&n!==1/0&&n!==-1/0&&!isNaN(n)||n===0}function Vb(n){return La(n)&&0<=n&&n<=1}var ot=function(){function n(t,e){this._x=t,this._y=e}return Object.defineProperty(n.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),n.prototype.add=function(t){return new n(this.x+t.x,this.y+t.y)},n.prototype.sub=function(t){return new n(this.x-t.x,this.y-t.y)},n.prototype.mul=function(t){return new n(this.x*t.x,this.y*t.y)},n.prototype.div=function(t){return new n(this.x/t.x,this.y/t.y)},n.prototype.abs=function(){return new n(Math.abs(this.x),Math.abs(this.y))},n.prototype.magnitude=function(){return Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2))},n.prototype.floor=function(){return new n(Math.floor(this.x),Math.floor(this.y))},n}(),Uo=function(){function n(t,e){e===void 0&&(e=!0);var r=t||{},o=[r.left,r.top,r.right,r.bottom].every(La),a=[r.x,r.y,r.width,r.height].every(La);if(!a&&!o)throw new Error("Box.constructor - expected box to be IBoundingBox | IRect, instead have "+JSON.stringify(r));var i=a?[r.x,r.y,r.width,r.height]:[r.left,r.top,r.right-r.left,r.bottom-r.top],s=i[0],u=i[1],c=i[2],l=i[3];n.assertIsValidBox({x:s,y:u,width:c,height:l},"Box.constructor",e),this._x=s,this._y=u,this._width=c,this._height=l}return n.isRect=function(t){return!!t&&[t.x,t.y,t.width,t.height].every(La)},n.assertIsValidBox=function(t,e,r){if(r===void 0&&(r=!1),!n.isRect(t))throw new Error(e+" - invalid box: "+JSON.stringify(t)+", expected object with properties x, y, width, height");if(!r&&(t.width<0||t.height<0))throw new Error(e+" - width ("+t.width+") and height ("+t.height+") must be positive numbers")},Object.defineProperty(n.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"left",{get:function(){return this.x},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"top",{get:function(){return this.y},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"right",{get:function(){return this.x+this.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"area",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"topLeft",{get:function(){return new ot(this.left,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"topRight",{get:function(){return new ot(this.right,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bottomLeft",{get:function(){return new ot(this.left,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bottomRight",{get:function(){return new ot(this.right,this.bottom)},enumerable:!0,configurable:!0}),n.prototype.round=function(){var t=[this.x,this.y,this.width,this.height].map(function(i){return Math.round(i)}),e=t[0],r=t[1],o=t[2],a=t[3];return new n({x:e,y:r,width:o,height:a})},n.prototype.floor=function(){var t=[this.x,this.y,this.width,this.height].map(function(i){return Math.floor(i)}),e=t[0],r=t[1],o=t[2],a=t[3];return new n({x:e,y:r,width:o,height:a})},n.prototype.toSquare=function(){var t=this,e=t.x,r=t.y,o=t.width,a=t.height,i=Math.abs(o-a);return o<a&&(e-=i/2,o+=i),a<o&&(r-=i/2,a+=i),new n({x:e,y:r,width:o,height:a})},n.prototype.rescale=function(t){var e=Wb(t)?t.width:t,r=Wb(t)?t.height:t;return new n({x:this.x*e,y:this.y*r,width:this.width*e,height:this.height*r})},n.prototype.pad=function(t,e){var r=[this.x-t/2,this.y-e/2,this.width+t,this.height+e],o=r[0],a=r[1],i=r[2],s=r[3];return new n({x:o,y:a,width:i,height:s})},n.prototype.clipAtImageBorders=function(t,e){var r=this,o=r.x,a=r.y,i=r.right,s=r.bottom,u=Math.max(o,0),c=Math.max(a,0),l=i-u,d=s-c,f=Math.min(l,t-u),h=Math.min(d,e-c);return new n({x:u,y:c,width:f,height:h}).floor()},n.prototype.shift=function(t,e){var r=this,o=r.width,a=r.height,i=this.x+t,s=this.y+e;return new n({x:i,y:s,width:o,height:a})},n.prototype.padAtBorders=function(t,e){var r=this.width+1,o=this.height+1,a=1,i=1,s=r,u=o,c=this.left,l=this.top,d=this.right,f=this.bottom;return d>e&&(s=-d+e+r,d=e),f>t&&(u=-f+t+o,f=t),c<1&&(u=2-c,c=1),l<1&&(u=2-l,l=1),{dy:i,edy:u,dx:a,edx:s,y:l,ey:f,x:c,ex:d,w:r,h:o}},n.prototype.calibrate=function(t){return new n({left:this.left+t.left*this.width,top:this.top+t.top*this.height,right:this.right+t.right*this.width,bottom:this.bottom+t.bottom*this.height}).toSquare().round()},n}(),pl=function(n){De(t,n);function t(e,r,o,a,i){return i===void 0&&(i=!1),n.call(this,{left:e,top:r,right:o,bottom:a},i)||this}return t}(Uo),jb=function(){function n(t,e,r,o,a){this._imageDims=new Fi(a.width,a.height),this._score=t,this._classScore=e,this._className=r,this._box=new Uo(o).rescale(this._imageDims)}return Object.defineProperty(n.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"className",{get:function(){return this._className},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"box",{get:function(){return this._box},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageDims",{get:function(){return this._imageDims},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageWidth",{get:function(){return this.imageDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageHeight",{get:function(){return this.imageDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"relativeBox",{get:function(){return new Uo(this._box).rescale(this.imageDims.reverse())},enumerable:!0,configurable:!0}),n.prototype.forSize=function(t,e){return new n(this.score,this.classScore,this.className,this.relativeBox,{width:t,height:e})},n}(),Wr=function(n){De(t,n);function t(e,r,o){return n.call(this,e,e,"",r,o)||this}return t.prototype.forSize=function(e,r){var o=n.prototype.forSize.call(this,e,r),a=o.score,i=o.relativeBox,s=o.imageDims;return new t(a,i,s)},t}(jb);function p5(n,t,e){e===void 0&&(e=!0);var r=Math.max(0,Math.min(n.right,t.right)-Math.max(n.left,t.left)),o=Math.max(0,Math.min(n.bottom,t.bottom)-Math.max(n.top,t.top)),a=r*o;return e?a/(n.area+t.area-a):a/Math.min(n.area,t.area)}function v5(n){var t=n.map(function(s){return s.x}),e=n.map(function(s){return s.y}),r=t.reduce(function(s,u){return u<s?u:s},1/0),o=e.reduce(function(s,u){return u<s?u:s},1/0),a=t.reduce(function(s,u){return s<u?u:s},0),i=e.reduce(function(s,u){return s<u?u:s},0);return new pl(r,o,a,i)}function nu(n,t,e,r){r===void 0&&(r=!0);for(var o=t.map(function(s,u){return{score:s,boxIndex:u}}).sort(function(s,u){return s.score-u.score}).map(function(s){return s.boxIndex}),a=[],i=function(){var s=o.pop();a.push(s);for(var u=o,c=[],l=0;l<u.length;l++){var d=u[l],f=n[s],h=n[d];c.push(p5(f,h,r))}o=o.filter(function(m,p){return c[p]<=e})};o.length>0;)i();return a}function ru(n,t){return xe(function(){var e=t[0],r=t[1],o=t[2],a=Lr(eu(n.shape.slice(0,3),[1]),e),i=Lr(eu(n.shape.slice(0,3),[1]),r),s=Lr(eu(n.shape.slice(0,3),[1]),o),u=Vt([a,i,s],3);return zt(n,u)})}function m5(n,t){return t===void 0&&(t=!1),xe(function(){var e=n.shape.slice(1),r=e[0],o=e[1];if(r===o)return n;var a=Math.abs(r-o),i=Math.round(a*(t?.5:1)),s=r>o?2:1,u=function(h){var m=n.shape.slice();return m[s]=h,Lr(m,0)},c=u(i),l=a-c.shape[s],d=t&&l?u(l):null,f=[d,n,c].filter(function(h){return!!h}).map(function(h){return h.toFloat()});return Vt(f,s)})}function jh(n){return 1/(1+Math.exp(-n))}var Uh=function(n){De(t,n);function t(e,r,o,a,i){return i===void 0&&(i=!1),n.call(this,{x:e,y:r,width:o,height:a},i)||this}return t}(Uo),g5=.5,y5=.43,b5=.45,vl=function(){function n(t,e,r){r===void 0&&(r=new ot(0,0));var o=e.width,a=e.height;this._imgDims=new Fi(o,a),this._shift=r,this._positions=t.map(function(i){return i.mul(new ot(o,a)).add(r)})}return Object.defineProperty(n.prototype,"shift",{get:function(){return new ot(this._shift.x,this._shift.y)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageWidth",{get:function(){return this._imgDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageHeight",{get:function(){return this._imgDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"positions",{get:function(){return this._positions},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"relativePositions",{get:function(){var t=this;return this._positions.map(function(e){return e.sub(t._shift).div(new ot(t.imageWidth,t.imageHeight))})},enumerable:!0,configurable:!0}),n.prototype.forSize=function(t,e){return new this.constructor(this.relativePositions,{width:t,height:e})},n.prototype.shiftBy=function(t,e){return new this.constructor(this.relativePositions,this._imgDims,new ot(t,e))},n.prototype.shiftByPoint=function(t){return this.shiftBy(t.x,t.y)},n.prototype.align=function(t,e){if(e===void 0&&(e={}),t){var r=t instanceof Wr?t.box.floor():new Uo(t);return this.shiftBy(r.x,r.y).align(null,e)}var o=Object.assign({},{useDlibAlignment:!1,minBoxPadding:.2},e),a=o.useDlibAlignment,i=o.minBoxPadding;return a?this.alignDlib():this.alignMinBbox(i)},n.prototype.alignDlib=function(){var t=this.getRefPointsForAlignment(),e=t[0],r=t[1],o=t[2],a=function(d){return o.sub(d).magnitude()},i=(a(e)+a(r))/2,s=Math.floor(i/b5),u=Vh(t),c=Math.floor(Math.max(0,u.x-g5*s)),l=Math.floor(Math.max(0,u.y-y5*s));return new Uh(c,l,Math.min(s,this.imageWidth+c),Math.min(s,this.imageHeight+l))},n.prototype.alignMinBbox=function(t){var e=v5(this.positions);return e.pad(e.width*t,e.height*t)},n.prototype.getRefPointsForAlignment=function(){throw new Error("getRefPointsForAlignment not implemented by base class")},n}(),x5=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getRefPointsForAlignment=function(){var e=this.positions;return[e[0],e[1],Vh([e[3],e[4]])]},t}(vl),w5=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getJawOutline=function(){return this.positions.slice(0,17)},t.prototype.getLeftEyeBrow=function(){return this.positions.slice(17,22)},t.prototype.getRightEyeBrow=function(){return this.positions.slice(22,27)},t.prototype.getNose=function(){return this.positions.slice(27,36)},t.prototype.getLeftEye=function(){return this.positions.slice(36,42)},t.prototype.getRightEye=function(){return this.positions.slice(42,48)},t.prototype.getMouth=function(){return this.positions.slice(48,68)},t.prototype.getRefPointsForAlignment=function(){return[this.getLeftEye(),this.getRightEye(),this.getMouth()].map(Vh)},t}(vl),Ub=function(){function n(t,e){this._label=t,this._distance=e}return Object.defineProperty(n.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"distance",{get:function(){return this._distance},enumerable:!0,configurable:!0}),n.prototype.toString=function(t){return t===void 0&&(t=!0),""+this.label+(t?" ("+f5(this.distance)+")":"")},n}(),zb=function(n){De(t,n);function t(e,r){var o=n.call(this,e)||this;return o._label=r,o}return t.assertIsValidLabeledBox=function(e,r){if(Uo.assertIsValidBox(e,r),!La(e.label))throw new Error(r+" - expected property label ("+e.label+") to be a number")},Object.defineProperty(t.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),t}(Uo),ml=function(){function n(t,e){if(typeof t!="string")throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(e)||e.some(function(r){return!(r instanceof Float32Array)}))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=t,this._descriptors=e}return Object.defineProperty(n.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"descriptors",{get:function(){return this._descriptors},enumerable:!0,configurable:!0}),n.prototype.toJSON=function(){return{label:this.label,descriptors:this.descriptors.map(function(t){return Array.from(t)})}},n.fromJSON=function(t){var e=t.descriptors.map(function(r){return new Float32Array(r)});return new n(t.label,e)},n}();(function(n){De(t,n);function t(e,r,o,a){var i=n.call(this,e,r)||this;return i._score=o,i._classScore=a,i}return t.assertIsValidPredictedBox=function(e,r){if(zb.assertIsValidLabeledBox(e,r),!Vb(e.score)||!Vb(e.classScore))throw new Error(r+" - expected properties score ("+e.score+") and ("+e.classScore+") to be a number between [0, 1]")},Object.defineProperty(t.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),t})(zb);function C5(n){return n.detection instanceof Wr}function zh(n,t){var e={detection:t};return Object.assign({},n,e)}function Hb(){var n=window.fetch||function(){throw new Error("fetch - missing fetch implementation for browser environment")},t=function(){throw new Error("readFile - filesystem not available for browser environment")};return{Canvas:HTMLCanvasElement,CanvasRenderingContext2D,Image:HTMLImageElement,ImageData,Video:HTMLVideoElement,createCanvasElement:function(){return document.createElement("canvas")},createImageElement:function(){return document.createElement("img")},fetch:n,readFile:t}}function Gb(n){var t="";if(!n)try{n=require("fs")}catch(r){t=r.toString()}var e=n?function(r){return new Promise(function(o,a){n.readFile(r,function(i,s){return i?a(i):o(s)})})}:function(){throw new Error("readFile - failed to require fs in nodejs environment with error: "+t)};return{readFile:e}}function qb(){var n=global.Canvas||global.HTMLCanvasElement,t=global.Image||global.HTMLImageElement,e=function(){if(n)return new n;throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment")},r=function(){if(t)return new t;throw new Error("createImageElement - missing Image implementation for nodejs environment")},o=global.fetch||function(){throw new Error("fetch - missing fetch implementation for nodejs environment")},a=Gb();return dn({Canvas:n||function(){function i(){}return i}(),CanvasRenderingContext2D:global.CanvasRenderingContext2D||function(){function i(){}return i}(),Image:t||function(){function i(){}return i}(),ImageData:global.ImageData||function(){function i(){}return i}(),Video:global.HTMLVideoElement||function(){function i(){}return i}(),createCanvasElement:e,createImageElement:r,fetch:o},a)}function Kb(){return typeof window=="object"&&typeof document<"u"&&typeof HTMLImageElement<"u"&&typeof HTMLCanvasElement<"u"&&typeof HTMLVideoElement<"u"&&typeof ImageData<"u"&&typeof CanvasRenderingContext2D<"u"}function Yb(){return typeof global=="object"&&typeof require=="function"&&typeof module<"u"&&typeof process<"u"&&!!process.version}var Ht;function _5(){if(!Ht)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return Ht}function Hh(n){Ht=n}function Gh(){Kb()&&Hh(Hb()),Yb()&&Hh(qb())}function E5(n){if(Ht||Gh(),!Ht)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");var t=n.Canvas,e=t===void 0?Ht.Canvas:t,r=n.Image,o=r===void 0?Ht.Image:r;Ht.Canvas=e,Ht.Image=o,Ht.createCanvasElement=n.createCanvasElement||function(){return new e},Ht.createImageElement=n.createImageElement||function(){return new o},Ht.ImageData=n.ImageData||Ht.ImageData,Ht.Video=n.Video||Ht.Video,Ht.fetch=n.fetch||Ht.fetch,Ht.readFile=n.readFile||Ht.readFile}var rn={getEnv:_5,setEnv:Hh,initialize:Gh,createBrowserEnv:Hb,createFileSystem:Gb,createNodejsEnv:qb,monkeyPatch:E5,isBrowser:Kb,isNodejs:Yb};Gh();function Xb(n){return!rn.isNodejs()&&typeof n=="string"?document.getElementById(n):n}function Ba(n){var t=rn.getEnv(),e=t.Canvas,r=t.CanvasRenderingContext2D;if(n instanceof r)return n;var o=Xb(n);if(!(o instanceof e))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");var a=o.getContext("2d");if(!a)throw new Error("resolveContext2d - canvas 2d context is null");return a}var Zb;(function(n){n.TOP_LEFT="TOP_LEFT",n.TOP_RIGHT="TOP_RIGHT",n.BOTTOM_LEFT="BOTTOM_LEFT",n.BOTTOM_RIGHT="BOTTOM_RIGHT"})(Zb||(Zb={}));function Qb(n){var t=rn.getEnv(),e=t.Image,r=t.Video;return n instanceof e&&n.complete||n instanceof r&&n.readyState>=3}function S5(n){return new Promise(function(t,e){if(n instanceof rn.getEnv().Canvas||Qb(n))return t();function r(a){a.currentTarget&&(a.currentTarget.removeEventListener("load",r),a.currentTarget.removeEventListener("error",o),t(a))}function o(a){a.currentTarget&&(a.currentTarget.removeEventListener("load",r),a.currentTarget.removeEventListener("error",o),e(a))}n.addEventListener("load",r),n.addEventListener("error",o)})}function Jb(n){var t=rn.getEnv(),e=t.Image,r=t.Video;return n instanceof e?new Fi(n.naturalWidth,n.naturalHeight):n instanceof r?new Fi(n.videoWidth,n.videoHeight):new Fi(n.width,n.height)}function gl(n){var t=n.width,e=n.height,r=rn.getEnv().createCanvasElement,o=r();return o.width=t,o.height=e,o}function qh(n,t){var e=rn.getEnv().ImageData;if(!(n instanceof e)&&!Qb(n))throw new Error("createCanvasFromMedia - media has not finished loading yet");var r=Jb(n),o=r.width,a=r.height,i=gl({width:o,height:a});return n instanceof e?Ba(i).putImageData(n,0,0):Ba(i).drawImage(n,0,0,o,a),i}function N5(n,t){return $e(this,void 0,void 0,function(){var e,r,o,a,i,s;return ke(this,function(u){switch(u.label){case 0:return e=rn.getEnv().createCanvasElement(),r=n.shape.slice(jo(n)?1:0),o=r[0],a=r[1],i=r[2],s=xe(function(){return n.as3D(o,a,i).toInt()}),[4,Bh.toPixels(s,e)];case 1:return u.sent(),s.dispose(),[2,e]}})})}function e2(n){var t=rn.getEnv(),e=t.Image,r=t.Canvas,o=t.Video;return n instanceof e||n instanceof r||n instanceof o}function $5(n,t,e){e===void 0&&(e=!1);var r=rn.getEnv(),o=r.Image,a=r.Canvas;if(!(n instanceof o||n instanceof a))throw new Error("imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement");var i=Jb(n),s=t/Math.max(i.height,i.width),u=s*i.width,c=s*i.height,l=gl({width:t,height:t}),d=n instanceof a?n:qh(n),f=Math.abs(u-c)/2,h=e&&u<c?f:0,m=e&&c<u?f:0;return Ba(l).drawImage(d,h,m,u,c),l}var yl=function(){function n(t,e){var r=this;if(e===void 0&&(e=!1),this._imageTensors=[],this._canvases=[],this._treatAsBatchInput=!1,this._inputDimensions=[],!Array.isArray(t))throw new Error("NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have "+t);this._treatAsBatchInput=e,this._batchSize=t.length,t.forEach(function(o,a){if(hl(o)){r._imageTensors[a]=o,r._inputDimensions[a]=o.shape;return}if(jo(o)){var i=o.shape[0];if(i!==1)throw new Error("NetInput - tf.Tensor4D with batchSize "+i+" passed, but not supported in input array");r._imageTensors[a]=o,r._inputDimensions[a]=o.shape.slice(1);return}var s=o instanceof rn.getEnv().Canvas?o:qh(o);r._canvases[a]=s,r._inputDimensions[a]=[s.height,s.width,3]})}return Object.defineProperty(n.prototype,"imageTensors",{get:function(){return this._imageTensors},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"canvases",{get:function(){return this._canvases},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isBatchInput",{get:function(){return this.batchSize>1||this._treatAsBatchInput},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"batchSize",{get:function(){return this._batchSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"inputDimensions",{get:function(){return this._inputDimensions},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"reshapedInputDimensions",{get:function(){var t=this;return tu(this.batchSize,0,1).map(function(e,r){return t.getReshapedInputDimensions(r)})},enumerable:!0,configurable:!0}),n.prototype.getInput=function(t){return this.canvases[t]||this.imageTensors[t]},n.prototype.getInputDimensions=function(t){return this._inputDimensions[t]},n.prototype.getInputHeight=function(t){return this._inputDimensions[t][0]},n.prototype.getInputWidth=function(t){return this._inputDimensions[t][1]},n.prototype.getReshapedInputDimensions=function(t){if(typeof this.inputSize!="number")throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");var e=this.getInputWidth(t),r=this.getInputHeight(t);return h5({width:e,height:r},this.inputSize)},n.prototype.toBatchTensor=function(t,e){var r=this;return e===void 0&&(e=!0),this._inputSize=t,xe(function(){var o=tu(r.batchSize,0,1).map(function(i){var s=r.getInput(i);if(s instanceof bt){var u=jo(s)?s:s.expandDims();return u=m5(u,e),(u.shape[1]!==t||u.shape[2]!==t)&&(u=wh.resizeBilinear(u,[t,t])),u.as3D(t,t,3)}if(s instanceof rn.getEnv().Canvas)return Bh.fromPixels($5(s,t,e));throw new Error("toBatchTensor - at batchIdx "+i+", expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have "+s)}),a=Bn(o.map(function(i){return i.toFloat()})).as4D(r.batchSize,t,t,3);return a})},n}();function Yt(n){return $e(this,void 0,void 0,function(){var t,e,r;return ke(this,function(o){switch(o.label){case 0:if(n instanceof yl)return[2,n];if(t=Array.isArray(n)?n:[n],!t.length)throw new Error("toNetInput - empty array passed as input");return e=function(a){return Array.isArray(n)?" at input index "+a+":":""},r=t.map(Xb),r.forEach(function(a,i){if(!e2(a)&&!hl(a)&&!jo(a))throw typeof t[i]=="string"?new Error("toNetInput -"+e(i)+" string passed, but could not resolve HTMLElement for element id "+t[i]):new Error("toNetInput -"+e(i)+" expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id");if(jo(a)){var s=a.shape[0];if(s!==1)throw new Error("toNetInput -"+e(i)+" tf.Tensor4D with batchSize "+s+" passed, but not supported in input array")}}),[4,Promise.all(r.map(function(a){return e2(a)&&S5(a)}))];case 1:return o.sent(),[2,new yl(r,Array.isArray(n))]}})})}function Kh(n,t){return $e(this,void 0,void 0,function(){var e,r,o,a,i,s,u;return ke(this,function(c){switch(c.label){case 0:return e=rn.getEnv().Canvas,r=n,n instanceof e?[3,5]:[4,Yt(n)];case 1:if(o=c.sent(),o.batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");return a=o.getInput(0),a instanceof e?(i=a,[3,4]):[3,2];case 2:return[4,N5(a)];case 3:i=c.sent(),c.label=4;case 4:r=i,c.label=5;case 5:return s=Ba(r),u=t.map(function(l){return l instanceof Wr?l.forSize(r.width,r.height).box.floor():l}).map(function(l){return l.clipAtImageBorders(r.width,r.height)}),[2,u.map(function(l){var d=l.x,f=l.y,h=l.width,m=l.height,p=gl({width:h,height:m});return Ba(p).putImageData(s.getImageData(d,f,h,m),0,0),p})]}})})}function Yh(n,t){return $e(this,void 0,void 0,function(){return ke(this,function(e){if(!hl(n)&&!jo(n))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(jo(n)&&n.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return[2,xe(function(){var r=n.shape.slice(jo(n)?1:0),o=r[0],a=r[1],i=r[2],s=t.map(function(c){return c instanceof Wr?c.forSize(a,o).box:c}).map(function(c){return c.clipAtImageBorders(a,o)}),u=s.map(function(c){var l=c.x,d=c.y,f=c.width,h=c.height;return sb(n.as3D(o,a,i),[d,l,0],[h,f,i])});return u})]})})}function k5(n,t){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return e=rn.getEnv().fetch,[4,e(n,t)];case 1:if(r=o.sent(),!(r.status<400))throw new Error("failed to fetch: ("+r.status+") "+r.statusText+", from url: "+r.url);return[2,r]}})})}function P5(n){return $e(this,void 0,void 0,function(){return ke(this,function(t){switch(t.label){case 0:return[4,k5(n)];case 1:return[2,t.sent().json()]}})})}function t2(n,t){var e=t+"-weights_manifest.json";if(!n)return{modelBaseUri:"",manifestUri:e};if(n==="/")return{modelBaseUri:"/",manifestUri:"/"+e};var r=n.startsWith("http://")?"http://":n.startsWith("https://")?"https://":"";n=n.replace(r,"");var o=n.split("/").filter(function(s){return s}),a=n.endsWith(".json")?o[o.length-1]:e,i=r+(n.endsWith(".json")?o.slice(0,o.length-1):o).join("/");return i=n.startsWith("/")?"/"+i:i,{modelBaseUri:i,manifestUri:i==="/"?"/"+a:i+"/"+a}}function I5(n,t){return $e(this,void 0,void 0,function(){var e,r,o,a;return ke(this,function(i){switch(i.label){case 0:return e=t2(n,t),r=e.manifestUri,o=e.modelBaseUri,[4,P5(r)];case 1:return a=i.sent(),[2,Rb.loadWeights(a,o)]}})})}var uo=function(){function n(t){this._name=t,this._params=void 0,this._paramMappings=[]}return Object.defineProperty(n.prototype,"params",{get:function(){return this._params},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"paramMappings",{get:function(){return this._paramMappings},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isLoaded",{get:function(){return!!this.params},enumerable:!0,configurable:!0}),n.prototype.getParamFromPath=function(t){var e=this.traversePropertyPath(t),r=e.obj,o=e.objProp;return r[o]},n.prototype.reassignParamFromPath=function(t,e){var r=this.traversePropertyPath(t),o=r.obj,a=r.objProp;o[a].dispose(),o[a]=e},n.prototype.getParamList=function(){var t=this;return this._paramMappings.map(function(e){var r=e.paramPath;return{path:r,tensor:t.getParamFromPath(r)}})},n.prototype.getTrainableParams=function(){return this.getParamList().filter(function(t){return t.tensor instanceof xi})},n.prototype.getFrozenParams=function(){return this.getParamList().filter(function(t){return!(t.tensor instanceof xi)})},n.prototype.variable=function(){var t=this;this.getFrozenParams().forEach(function(e){var r=e.path,o=e.tensor;t.reassignParamFromPath(r,o.variable())})},n.prototype.freeze=function(){var t=this;this.getTrainableParams().forEach(function(e){var r=e.path,o=e.tensor,a=nn(o.dataSync());o.dispose(),t.reassignParamFromPath(r,a)})},n.prototype.dispose=function(t){t===void 0&&(t=!0),this.getParamList().forEach(function(e){if(t&&e.tensor.isDisposed)throw new Error("param tensor has already been disposed for path "+e.path);e.tensor.dispose()}),this._params=void 0},n.prototype.serializeParams=function(){return new Float32Array(this.getParamList().map(function(t){var e=t.tensor;return Array.from(e.dataSync())}).reduce(function(t,e){return t.concat(e)}))},n.prototype.load=function(t){return $e(this,void 0,void 0,function(){return ke(this,function(e){switch(e.label){case 0:return t instanceof Float32Array?(this.extractWeights(t),[2]):[4,this.loadFromUri(t)];case 1:return e.sent(),[2]}})})},n.prototype.loadFromUri=function(t){return $e(this,void 0,void 0,function(){var e;return ke(this,function(r){switch(r.label){case 0:if(t&&typeof t!="string")throw new Error(this._name+".loadFromUri - expected model uri");return[4,I5(t,this.getDefaultModelName())];case 1:return e=r.sent(),this.loadFromWeightMap(e),[2]}})})},n.prototype.loadFromDisk=function(t){return $e(this,void 0,void 0,function(){var e,r,o,a,i,s,u,c,l,d;return ke(this,function(f){switch(f.label){case 0:if(t&&typeof t!="string")throw new Error(this._name+".loadFromDisk - expected model file path");return e=rn.getEnv().readFile,r=t2(t,this.getDefaultModelName()),o=r.manifestUri,a=r.modelBaseUri,i=function(h){return Promise.all(h.map(function(m){return e(m).then(function(p){return p.buffer})}))},s=Rb.weightsLoaderFactory(i),l=(c=JSON).parse,[4,e(o)];case 1:return u=l.apply(c,[f.sent().toString()]),[4,s(u,a)];case 2:return d=f.sent(),this.loadFromWeightMap(d),[2]}})})},n.prototype.loadFromWeightMap=function(t){var e=this.extractParamsFromWeigthMap(t),r=e.paramMappings,o=e.params;this._paramMappings=r,this._params=o},n.prototype.extractWeights=function(t){var e=this.extractParams(t),r=e.paramMappings,o=e.params;this._paramMappings=r,this._params=o},n.prototype.traversePropertyPath=function(t){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");var e=t.split("/").reduce(function(a,i){if(!a.nextObj.hasOwnProperty(i))throw new Error("traversePropertyPath - object does not have property "+i+", for path "+t);return{obj:a.nextObj,objProp:i,nextObj:a.nextObj[i]}},{nextObj:this.params}),r=e.obj,o=e.objProp;if(!r||!o||!(r[o]instanceof bt))throw new Error("traversePropertyPath - parameter is not a tensor, for path "+t);return{obj:r,objProp:o}},n}();function Vn(n,t,e){return xe(function(){var r=mh(n,t.depthwise_filter,t.pointwise_filter,e,"same");return r=qe(r,t.bias),r})}function Xh(n,t,e){return e===void 0&&(e=!1),xe(function(){var r=wt(e?qe(Zn(n,t.conv0.filters,[2,2],"same"),t.conv0.bias):Vn(n,t.conv0,[2,2])),o=Vn(r,t.conv1,[1,1]),a=wt(qe(r,o)),i=Vn(a,t.conv2,[1,1]);return wt(qe(r,qe(o,i)))})}function bl(n,t,e,r){return e===void 0&&(e=!1),r===void 0&&(r=!0),xe(function(){var o=wt(e?qe(Zn(n,t.conv0.filters,r?[2,2]:[1,1],"same"),t.conv0.bias):Vn(n,t.conv0,r?[2,2]:[1,1])),a=Vn(o,t.conv1,[1,1]),i=wt(qe(o,a)),s=Vn(i,t.conv2,[1,1]),u=wt(qe(o,qe(a,s))),c=Vn(u,t.conv3,[1,1]);return wt(qe(o,qe(a,qe(s,c))))})}function cr(n,t,e,r){return e===void 0&&(e="same"),r===void 0&&(r=!1),xe(function(){var o=qe(Zn(n,t.filters,[1,1],e),t.bias);return r?wt(o):o})}function co(n,t){Object.keys(n).forEach(function(e){t.some(function(r){return r.originalPath===e})||n[e].dispose()})}function xl(n,t){return function(e,r,o,a){var i=Sn(n(e*r*o*o),[o,o,e,r]),s=Ot(n(r));return t.push({paramPath:a+"/filters"},{paramPath:a+"/bias"}),{filters:i,bias:s}}}function Zh(n,t){return function(e,r,o){var a=Ro(n(e*r),[e,r]),i=Ot(n(r));return t.push({paramPath:o+"/weights"},{paramPath:o+"/bias"}),{weights:a,bias:i}}}var n2=function(){function n(t,e,r){this.depthwise_filter=t,this.pointwise_filter=e,this.bias=r}return n}();function Qh(n,t){return function(e,r,o){var a=Sn(n(9*e),[3,3,e,1]),i=Sn(n(e*r),[1,1,e,r]),s=Ot(n(r));return t.push({paramPath:o+"/depthwise_filter"},{paramPath:o+"/pointwise_filter"},{paramPath:o+"/bias"}),new n2(a,i,s)}}function Jh(n){return function(t){var e=n(t+"/depthwise_filter",4),r=n(t+"/pointwise_filter",4),o=n(t+"/bias",1);return new n2(e,r,o)}}function zo(n,t){return function(e,r,o){var a=n[e];if(!fl(a,r))throw new Error("expected weightMap["+e+"] to be a Tensor"+r+"D, instead have "+a);return t.push({originalPath:e,paramPath:o||e}),a}}function lo(n){var t=n;function e(o){var a=t.slice(0,o);return t=t.slice(o),a}function r(){return t}return{extractWeights:e,getRemainingWeights:r}}function r2(n,t){var e=xl(n,t),r=Qh(n,t);function o(i,s,u,c){c===void 0&&(c=!1);var l=c?e(i,s,3,u+"/conv0"):r(i,s,u+"/conv0"),d=r(s,s,u+"/conv1"),f=r(s,s,u+"/conv2");return{conv0:l,conv1:d,conv2:f}}function a(i,s,u,c){c===void 0&&(c=!1);var l=o(i,s,u,c),d=l.conv0,f=l.conv1,h=l.conv2,m=r(s,s,u+"/conv3");return{conv0:d,conv1:f,conv2:h,conv3:m}}return{extractDenseBlock3Params:o,extractDenseBlock4Params:a}}function A5(n){var t=[],e=lo(n),r=e.extractWeights,o=e.getRemainingWeights,a=r2(r,t).extractDenseBlock4Params,i=a(3,32,"dense0",!0),s=a(32,64,"dense1"),u=a(64,128,"dense2"),c=a(128,256,"dense3");if(o().length!==0)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:t,params:{dense0:i,dense1:s,dense2:u,dense3:c}}}function o2(n){return function(t){var e=n(t+"/filters",4),r=n(t+"/bias",1);return{filters:e,bias:r}}}function a2(n,t){var e=zo(n,t),r=o2(e),o=Jh(e);function a(s,u){u===void 0&&(u=!1);var c=u?r(s+"/conv0"):o(s+"/conv0"),l=o(s+"/conv1"),d=o(s+"/conv2");return{conv0:c,conv1:l,conv2:d}}function i(s,u){u===void 0&&(u=!1);var c=u?r(s+"/conv0"):o(s+"/conv0"),l=o(s+"/conv1"),d=o(s+"/conv2"),f=o(s+"/conv3");return{conv0:c,conv1:l,conv2:d,conv3:f}}return{extractDenseBlock3Params:a,extractDenseBlock4Params:i}}function T5(n){var t=[],e=a2(n,t).extractDenseBlock4Params,r={dense0:e("dense0",!0),dense1:e("dense1"),dense2:e("dense2"),dense3:e("dense3")};return co(n,t),{params:r,paramMappings:t}}var i2=function(n){De(t,n);function t(){return n.call(this,"FaceFeatureExtractor")||this}return t.prototype.forwardInput=function(e){var r=this.params;if(!r)throw new Error("FaceFeatureExtractor - load model before inference");return xe(function(){var o=e.toBatchTensor(112,!0),a=[122.782,117.001,104.298],i=ru(o,a).div(ve(255)),s=bl(i,r.dense0,!0);return s=bl(s,r.dense1),s=bl(s,r.dense2),s=bl(s,r.dense3),s=Qs(s,[7,7],[2,2],"valid"),s})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.getDefaultModelName=function(){return"face_feature_extractor_model"},t.prototype.extractParamsFromWeigthMap=function(e){return T5(e)},t.prototype.extractParams=function(e){return A5(e)},t}(uo);function Vr(n,t){return xe(function(){return qe(il(n,t.weights),t.bias)})}function O5(n,t,e){var r=[],o=lo(n),a=o.extractWeights,i=o.getRemainingWeights,s=Zh(a,r),u=s(t,e,"fc");if(i().length!==0)throw new Error("weights remaing after extract: "+i().length);return{paramMappings:r,params:{fc:u}}}function D5(n){var t=[],e=zo(n,t);function r(a){var i=e(a+"/weights",2),s=e(a+"/bias",1);return{weights:i,bias:s}}var o={fc:r("fc")};return co(n,t),{params:o,paramMappings:t}}function s2(n){var t={},e={};return Object.keys(n).forEach(function(r){var o=r.startsWith("fc")?e:t;o[r]=n[r]}),{featureExtractorMap:t,classifierMap:e}}var u2=function(n){De(t,n);function t(e,r){var o=n.call(this,e)||this;return o._faceFeatureExtractor=r,o}return Object.defineProperty(t.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),t.prototype.runNet=function(e){var r=this,o=this.params;if(!o)throw new Error(this._name+" - load model before inference");return xe(function(){var a=e instanceof yl?r.faceFeatureExtractor.forwardInput(e):e;return Vr(a.as2D(a.shape[0],-1),o.fc)})},t.prototype.dispose=function(e){e===void 0&&(e=!0),this.faceFeatureExtractor.dispose(e),n.prototype.dispose.call(this,e)},t.prototype.loadClassifierParams=function(e){var r=this.extractClassifierParams(e),o=r.params,a=r.paramMappings;this._params=o,this._paramMappings=a},t.prototype.extractClassifierParams=function(e){return O5(e,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())},t.prototype.extractParamsFromWeigthMap=function(e){var r=s2(e),o=r.featureExtractorMap,a=r.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(o),D5(a)},t.prototype.extractParams=function(e){var r=this.getClassifierChannelsIn(),o=this.getClassifierChannelsOut(),a=o*r+o,i=e.slice(0,e.length-a),s=e.slice(e.length-a);return this.faceFeatureExtractor.extractWeights(i),this.extractClassifierParams(s)},t}(uo),c2=["neutral","happy","sad","angry","fearful","disgusted","surprised"],M5=function(){function n(t){var e=this;if(t.length!==7)throw new Error("FaceExpressions.constructor - expected probabilities.length to be 7, have: "+t.length);c2.forEach(function(r,o){e[r]=t[o]})}return n.prototype.asSortedArray=function(){var t=this;return c2.map(function(e){return{expression:e,probability:t[e]}}).sort(function(e,r){return r.probability-e.probability})},n}(),F5=function(n){De(t,n);function t(e){return e===void 0&&(e=new i2),n.call(this,"FaceExpressionNet",e)||this}return t.prototype.forwardInput=function(e){var r=this;return xe(function(){return oo(r.runNet(e))})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.predictExpressions=function(e){return $e(this,void 0,void 0,function(){var r,o,a,i,s=this;return ke(this,function(u){switch(u.label){case 0:return[4,Yt(e)];case 1:return r=u.sent(),[4,this.forwardInput(r)];case 2:return o=u.sent(),[4,Promise.all(jt(o).map(function(c){return $e(s,void 0,void 0,function(){var l;return ke(this,function(d){switch(d.label){case 0:return[4,c.data()];case 1:return l=d.sent(),c.dispose(),[2,l]}})})}))];case 3:return a=u.sent(),o.dispose(),i=a.map(function(c){return new M5(c)}),[2,r.isBatchInput?i:i[0]]}})})},t.prototype.getDefaultModelName=function(){return"face_expression_model"},t.prototype.getClassifierChannelsIn=function(){return 256},t.prototype.getClassifierChannelsOut=function(){return 7},t}(u2);function l2(n,t){var e={expressions:t};return Object.assign({},n,e)}function R5(n){return C5(n)&&n.landmarks instanceof vl&&n.unshiftedLandmarks instanceof vl&&n.alignedRect instanceof Wr}function ep(n,t){var e=n.detection.box,r=t.shiftBy(e.x,e.y),o=r.align(),a=n.detection.imageDims,i=new Wr(n.detection.score,o.rescale(a.reverse()),a),s={landmarks:r,unshiftedLandmarks:t,alignedRect:i};return Object.assign({},n,s)}function L5(n,t){var e=xl(n,t),r=Qh(n,t);function o(i,s,u){var c=r(i,s,u+"/separable_conv0"),l=r(s,s,u+"/separable_conv1"),d=e(i,s,1,u+"/expansion_conv");return{separable_conv0:c,separable_conv1:l,expansion_conv:d}}function a(i,s){var u=r(i,i,s+"/separable_conv0"),c=r(i,i,s+"/separable_conv1"),l=r(i,i,s+"/separable_conv2");return{separable_conv0:u,separable_conv1:c,separable_conv2:l}}return{extractConvParams:e,extractSeparableConvParams:r,extractReductionBlockParams:o,extractMainBlockParams:a}}function B5(n,t){var e=[],r=lo(n),o=r.extractWeights,a=r.getRemainingWeights,i=L5(o,e),s=i.extractConvParams,u=i.extractSeparableConvParams,c=i.extractReductionBlockParams,l=i.extractMainBlockParams,d=s(3,32,3,"entry_flow/conv_in"),f=c(32,64,"entry_flow/reduction_block_0"),h=c(64,128,"entry_flow/reduction_block_1"),m={conv_in:d,reduction_block_0:f,reduction_block_1:h},p={};tu(t,0,1).forEach(function(w){p["main_block_"+w]=l(128,"middle_flow/main_block_"+w)});var v=c(128,256,"exit_flow/reduction_block"),g=u(256,512,"exit_flow/separable_conv"),y={reduction_block:v,separable_conv:g};if(a().length!==0)throw new Error("weights remaing after extract: "+a().length);return{paramMappings:e,params:{entry_flow:m,middle_flow:p,exit_flow:y}}}function W5(n,t){var e=zo(n,t),r=o2(e),o=Jh(e);function a(s){var u=o(s+"/separable_conv0"),c=o(s+"/separable_conv1"),l=r(s+"/expansion_conv");return{separable_conv0:u,separable_conv1:c,expansion_conv:l}}function i(s){var u=o(s+"/separable_conv0"),c=o(s+"/separable_conv1"),l=o(s+"/separable_conv2");return{separable_conv0:u,separable_conv1:c,separable_conv2:l}}return{extractConvParams:r,extractSeparableConvParams:o,extractReductionBlockParams:a,extractMainBlockParams:i}}function V5(n,t){var e=[],r=W5(n,e),o=r.extractConvParams,a=r.extractSeparableConvParams,i=r.extractReductionBlockParams,s=r.extractMainBlockParams,u=o("entry_flow/conv_in"),c=i("entry_flow/reduction_block_0"),l=i("entry_flow/reduction_block_1"),d={conv_in:u,reduction_block_0:c,reduction_block_1:l},f={};tu(t,0,1).forEach(function(v){f["main_block_"+v]=s("middle_flow/main_block_"+v)});var h=i("exit_flow/reduction_block"),m=a("exit_flow/separable_conv"),p={reduction_block:h,separable_conv:m};return co(n,e),{params:{entry_flow:d,middle_flow:f,exit_flow:p},paramMappings:e}}function d2(n,t,e){return qe(Zn(n,t.filters,e,"same"),t.bias)}function tp(n,t,e){e===void 0&&(e=!0);var r=e?wt(n):n;return r=Vn(r,t.separable_conv0,[1,1]),r=Vn(wt(r),t.separable_conv1,[1,1]),r=Kt(r,[3,3],[2,2],"same"),r=qe(r,d2(n,t.expansion_conv,[2,2])),r}function j5(n,t){var e=Vn(wt(n),t.separable_conv0,[1,1]);return e=Vn(wt(e),t.separable_conv1,[1,1]),e=Vn(wt(e),t.separable_conv2,[1,1]),e=qe(e,n),e}var U5=function(n){De(t,n);function t(e){var r=n.call(this,"TinyXception")||this;return r._numMainBlocks=e,r}return t.prototype.forwardInput=function(e){var r=this,o=this.params;if(!o)throw new Error("TinyXception - load model before inference");return xe(function(){var a=e.toBatchTensor(112,!0),i=[122.782,117.001,104.298],s=ru(a,i).div(ve(256)),u=wt(d2(s,o.entry_flow.conv_in,[2,2]));return u=tp(u,o.entry_flow.reduction_block_0,!1),u=tp(u,o.entry_flow.reduction_block_1),tu(r._numMainBlocks,0,1).forEach(function(c){u=j5(u,o.middle_flow["main_block_"+c])}),u=tp(u,o.exit_flow.reduction_block),u=wt(Vn(u,o.exit_flow.separable_conv,[1,1])),u})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.getDefaultModelName=function(){return"tiny_xception_model"},t.prototype.extractParamsFromWeigthMap=function(e){return V5(e,this._numMainBlocks)},t.prototype.extractParams=function(e){return B5(e,this._numMainBlocks)},t}(uo);function z5(n){var t=[],e=lo(n),r=e.extractWeights,o=e.getRemainingWeights,a=Zh(r,t),i=a(512,1,"fc/age"),s=a(512,2,"fc/gender");if(o().length!==0)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:t,params:{fc:{age:i,gender:s}}}}function H5(n){var t=[],e=zo(n,t);function r(a){var i=e(a+"/weights",2),s=e(a+"/bias",1);return{weights:i,bias:s}}var o={fc:{age:r("fc/age"),gender:r("fc/gender")}};return co(n,t),{params:o,paramMappings:t}}var wl;(function(n){n.FEMALE="female",n.MALE="male"})(wl||(wl={}));var G5=function(n){De(t,n);function t(e){e===void 0&&(e=new U5(2));var r=n.call(this,"AgeGenderNet")||this;return r._faceFeatureExtractor=e,r}return Object.defineProperty(t.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),t.prototype.runNet=function(e){var r=this,o=this.params;if(!o)throw new Error(this._name+" - load model before inference");return xe(function(){var a=e instanceof yl?r.faceFeatureExtractor.forwardInput(e):e,i=Qs(a,[7,7],[2,2],"valid").as2D(a.shape[0],-1),s=Vr(i,o.fc.age).as1D(),u=Vr(i,o.fc.gender);return{age:s,gender:u}})},t.prototype.forwardInput=function(e){var r=this;return xe(function(){var o=r.runNet(e),a=o.age,i=o.gender;return{age:a,gender:oo(i)}})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.predictAgeAndGender=function(e){return $e(this,void 0,void 0,function(){var r,o,a,i,s,u,c=this;return ke(this,function(l){switch(l.label){case 0:return[4,Yt(e)];case 1:return r=l.sent(),[4,this.forwardInput(r)];case 2:return o=l.sent(),a=jt(o.age),i=jt(o.gender),s=a.map(function(d,f){return{ageTensor:d,genderTensor:i[f]}}),[4,Promise.all(s.map(function(d){var f=d.ageTensor,h=d.genderTensor;return $e(c,void 0,void 0,function(){var m,p,v,g,y;return ke(this,function(w){switch(w.label){case 0:return[4,f.data()];case 1:return m=w.sent()[0],[4,h.data()];case 2:return p=w.sent()[0],v=p>.5,g=v?wl.MALE:wl.FEMALE,y=v?p:1-p,f.dispose(),h.dispose(),[2,{age:m,gender:g,genderProbability:y}]}})})}))];case 3:return u=l.sent(),o.age.dispose(),o.gender.dispose(),[2,r.isBatchInput?u:u[0]]}})})},t.prototype.getDefaultModelName=function(){return"age_gender_model"},t.prototype.dispose=function(e){e===void 0&&(e=!0),this.faceFeatureExtractor.dispose(e),n.prototype.dispose.call(this,e)},t.prototype.loadClassifierParams=function(e){var r=this.extractClassifierParams(e),o=r.params,a=r.paramMappings;this._params=o,this._paramMappings=a},t.prototype.extractClassifierParams=function(e){return z5(e)},t.prototype.extractParamsFromWeigthMap=function(e){var r=s2(e),o=r.featureExtractorMap,a=r.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(o),H5(a)},t.prototype.extractParams=function(e){var r=1539,o=e.slice(0,e.length-r),a=e.slice(e.length-r);return this.faceFeatureExtractor.extractWeights(o),this.extractClassifierParams(a)},t}(uo),f2=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.postProcess=function(e,r,o){var a=o.map(function(s){var u=s.width,c=s.height,l=r/Math.max(c,u);return{width:u*l,height:c*l}}),i=a.length;return xe(function(){var s=function(f,h){return Bn([Lr([68],f),Lr([68],h)],1).as2D(1,136).as1D()},u=function(f,h){var m=a[f],p=m.width,v=m.height;return h(p,v)?Math.abs(p-v)/2:0},c=function(f){return u(f,function(h,m){return h<m})},l=function(f){return u(f,function(h,m){return m<h})},d=e.mul(Lr([i,136],r)).sub(Bn(Array.from(Array(i),function(f,h){return s(c(h),l(h))}))).div(Bn(Array.from(Array(i),function(f,h){return s(a[h].width,a[h].height)})));return d})},t.prototype.forwardInput=function(e){var r=this;return xe(function(){var o=r.runNet(e);return r.postProcess(o,e.inputSize,e.inputDimensions.map(function(a){var i=a[0],s=a[1];return{height:i,width:s}}))})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.detectLandmarks=function(e){return $e(this,void 0,void 0,function(){var r,o,a,i=this;return ke(this,function(s){switch(s.label){case 0:return[4,Yt(e)];case 1:return r=s.sent(),o=xe(function(){return jt(i.forwardInput(r))}),[4,Promise.all(o.map(function(u,c){return $e(i,void 0,void 0,function(){var l,d,f,h,m;return ke(this,function(p){switch(p.label){case 0:return f=(d=Array).from,[4,u.data()];case 1:return l=f.apply(d,[p.sent()]),h=l.filter(function(v,g){return Bb(g)}),m=l.filter(function(v,g){return!Bb(g)}),[2,new w5(Array(68).fill(0).map(function(v,g){return new ot(h[g],m[g])}),{height:r.getInputHeight(c),width:r.getInputWidth(c)})]}})})}))];case 2:return a=s.sent(),o.forEach(function(u){return u.dispose()}),[2,r.isBatchInput?a:a[0]]}})})},t.prototype.getClassifierChannelsOut=function(){return 136},t}(u2),h2=function(n){De(t,n);function t(e){return e===void 0&&(e=new i2),n.call(this,"FaceLandmark68Net",e)||this}return t.prototype.getDefaultModelName=function(){return"face_landmark_68_model"},t.prototype.getClassifierChannelsIn=function(){return 256},t}(f2);function q5(n){var t=[],e=a2(n,t).extractDenseBlock3Params,r={dense0:e("dense0",!0),dense1:e("dense1"),dense2:e("dense2")};return co(n,t),{params:r,paramMappings:t}}function K5(n){var t=[],e=lo(n),r=e.extractWeights,o=e.getRemainingWeights,a=r2(r,t).extractDenseBlock3Params,i=a(3,32,"dense0",!0),s=a(32,64,"dense1"),u=a(64,128,"dense2");if(o().length!==0)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:t,params:{dense0:i,dense1:s,dense2:u}}}var Y5=function(n){De(t,n);function t(){return n.call(this,"TinyFaceFeatureExtractor")||this}return t.prototype.forwardInput=function(e){var r=this.params;if(!r)throw new Error("TinyFaceFeatureExtractor - load model before inference");return xe(function(){var o=e.toBatchTensor(112,!0),a=[122.782,117.001,104.298],i=ru(o,a).div(ve(255)),s=Xh(i,r.dense0,!0);return s=Xh(s,r.dense1),s=Xh(s,r.dense2),s=Qs(s,[14,14],[2,2],"valid"),s})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.getDefaultModelName=function(){return"face_feature_extractor_tiny_model"},t.prototype.extractParamsFromWeigthMap=function(e){return q5(e)},t.prototype.extractParams=function(e){return K5(e)},t}(uo),X5=function(n){De(t,n);function t(e){return e===void 0&&(e=new Y5),n.call(this,"FaceLandmark68TinyNet",e)||this}return t.prototype.getDefaultModelName=function(){return"face_landmark_68_tiny_model"},t.prototype.getClassifierChannelsIn=function(){return 128},t}(f2);(function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t})(h2);function Z5(n,t){return qe(cn(n,t.weights),t.biases)}function np(n,t,e,r,o){o===void 0&&(o="same");var a=t.conv,i=a.filters,s=a.bias,u=Zn(n,i,e,o);return u=qe(u,s),u=Z5(u,t.scale),r?wt(u):u}function Q5(n,t){return np(n,t,[1,1],!0)}function p2(n,t){return np(n,t,[1,1],!1)}function v2(n,t){return np(n,t,[2,2],!0,"valid")}function J5(n,t){function e(s,u,c){var l=n(s),d=l.length/(u*c*c);if(d5(d))throw new Error("depth has to be an integer: "+d+", weights.length: "+l.length+", numFilters: "+u+", filterSize: "+c);return xe(function(){return Bo(Sn(l,[u,d,c,c]),[2,3,1,0])})}function r(s,u,c,l){var d=e(s,u,c),f=Ot(n(u));return t.push({paramPath:l+"/filters"},{paramPath:l+"/bias"}),{filters:d,bias:f}}function o(s,u){var c=Ot(n(s)),l=Ot(n(s));return t.push({paramPath:u+"/weights"},{paramPath:u+"/biases"}),{weights:c,biases:l}}function a(s,u,c,l){var d=r(s,u,c,l+"/conv"),f=o(u,l+"/scale");return{conv:d,scale:f}}function i(s,u,c,l,d){d===void 0&&(d=!1);var f=a((d?.5:1)*s,u,c,l+"/conv1"),h=a(s,u,c,l+"/conv2");return{conv1:f,conv2:h}}return{extractConvLayerParams:a,extractResidualLayerParams:i}}function e9(n){var t=lo(n),e=t.extractWeights,r=t.getRemainingWeights,o=[],a=J5(e,o),i=a.extractConvLayerParams,s=a.extractResidualLayerParams,u=i(4704,32,7,"conv32_down"),c=s(9216,32,3,"conv32_1"),l=s(9216,32,3,"conv32_2"),d=s(9216,32,3,"conv32_3"),f=s(36864,64,3,"conv64_down",!0),h=s(36864,64,3,"conv64_1"),m=s(36864,64,3,"conv64_2"),p=s(36864,64,3,"conv64_3"),v=s(147456,128,3,"conv128_down",!0),g=s(147456,128,3,"conv128_1"),y=s(147456,128,3,"conv128_2"),w=s(589824,256,3,"conv256_down",!0),x=s(589824,256,3,"conv256_1"),C=s(589824,256,3,"conv256_2"),_=s(589824,256,3,"conv256_down_out"),E=xe(function(){return Bo(Ro(e(256*128),[128,256]),[1,0])});if(o.push({paramPath:"fc"}),r().length!==0)throw new Error("weights remaing after extract: "+r().length);var S={conv32_down:u,conv32_1:c,conv32_2:l,conv32_3:d,conv64_down:f,conv64_1:h,conv64_2:m,conv64_3:p,conv128_down:v,conv128_1:g,conv128_2:y,conv256_down:w,conv256_1:x,conv256_2:C,conv256_down_out:_,fc:E};return{params:S,paramMappings:o}}function t9(n,t){var e=zo(n,t);function r(i){var s=e(i+"/scale/weights",1),u=e(i+"/scale/biases",1);return{weights:s,biases:u}}function o(i){var s=e(i+"/conv/filters",4),u=e(i+"/conv/bias",1),c=r(i);return{conv:{filters:s,bias:u},scale:c}}function a(i){return{conv1:o(i+"/conv1"),conv2:o(i+"/conv2")}}return{extractConvLayerParams:o,extractResidualLayerParams:a}}function n9(n){var t=[],e=t9(n,t),r=e.extractConvLayerParams,o=e.extractResidualLayerParams,a=r("conv32_down"),i=o("conv32_1"),s=o("conv32_2"),u=o("conv32_3"),c=o("conv64_down"),l=o("conv64_1"),d=o("conv64_2"),f=o("conv64_3"),h=o("conv128_down"),m=o("conv128_1"),p=o("conv128_2"),v=o("conv256_down"),g=o("conv256_1"),y=o("conv256_2"),w=o("conv256_down_out"),x=n.fc;if(t.push({originalPath:"fc",paramPath:"fc"}),!l5(x))throw new Error("expected weightMap[fc] to be a Tensor2D, instead have "+x);var C={conv32_down:a,conv32_1:i,conv32_2:s,conv32_3:u,conv64_down:c,conv64_1:l,conv64_2:d,conv64_3:f,conv128_down:h,conv128_1:m,conv128_2:p,conv256_down:v,conv256_1:g,conv256_2:y,conv256_down_out:w,fc:x};return co(n,t),{params:C,paramMappings:t}}function jr(n,t){var e=Q5(n,t.conv1);return e=p2(e,t.conv2),e=qe(e,n),e=wt(e),e}function Cl(n,t){var e=v2(n,t.conv1);e=p2(e,t.conv2);var r=Qs(n,2,2,"valid"),o=vt(r.shape),a=r.shape[3]!==e.shape[3],i=r.shape[1]!==e.shape[1]||r.shape[2]!==e.shape[2];if(i){var s=eu(e.shape);s[1]=1;var u=vt(s);e=Vt([e,u],1);var c=eu(e.shape);c[2]=1;var l=vt(c);e=Vt([e,l],2)}return r=a?Vt([r,o],3):r,e=qe(r,e),e=wt(e),e}var r9=function(n){De(t,n);function t(){return n.call(this,"FaceRecognitionNet")||this}return t.prototype.forwardInput=function(e){var r=this.params;if(!r)throw new Error("FaceRecognitionNet - load model before inference");return xe(function(){var o=e.toBatchTensor(150,!0).toFloat(),a=[122.782,117.001,104.298],i=ru(o,a).div(ve(256)),s=v2(i,r.conv32_down);s=Kt(s,3,2,"valid"),s=jr(s,r.conv32_1),s=jr(s,r.conv32_2),s=jr(s,r.conv32_3),s=Cl(s,r.conv64_down),s=jr(s,r.conv64_1),s=jr(s,r.conv64_2),s=jr(s,r.conv64_3),s=Cl(s,r.conv128_down),s=jr(s,r.conv128_1),s=jr(s,r.conv128_2),s=Cl(s,r.conv256_down),s=jr(s,r.conv256_1),s=jr(s,r.conv256_2),s=Cl(s,r.conv256_down_out);var u=s.mean([1,2]),c=il(u,r.fc);return c})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.computeFaceDescriptor=function(e){return $e(this,void 0,void 0,function(){var r,o,a,i=this;return ke(this,function(s){switch(s.label){case 0:return[4,Yt(e)];case 1:return r=s.sent(),o=xe(function(){return jt(i.forwardInput(r))}),[4,Promise.all(o.map(function(u){return u.data()}))];case 2:return a=s.sent(),o.forEach(function(u){return u.dispose()}),[2,r.isBatchInput?a:a[0]]}})})},t.prototype.getDefaultModelName=function(){return"face_recognition_model"},t.prototype.extractParamsFromWeigthMap=function(e){return n9(e)},t.prototype.extractParams=function(e){return e9(e)},t}(uo);function m2(n,t){var e={descriptor:t};return Object.assign({},n,e)}function g2(n,t){var e={age:t};return Object.assign({},n,e)}function y2(n,t,e){var r={gender:t,genderProbability:e};return Object.assign({},n,r)}var b2=function(){function n(t){var e=t===void 0?{}:t,r=e.minFaceSize,o=e.scaleFactor,a=e.maxNumScales,i=e.scoreThresholds,s=e.scaleSteps;if(this._name="MtcnnOptions",this._minFaceSize=r||20,this._scaleFactor=o||.709,this._maxNumScales=a||10,this._scoreThresholds=i||[.6,.7,.7],this._scaleSteps=s,typeof this._minFaceSize!="number"||this._minFaceSize<0)throw new Error(this._name+" - expected minFaceSize to be a number > 0");if(typeof this._scaleFactor!="number"||this._scaleFactor<=0||this._scaleFactor>=1)throw new Error(this._name+" - expected scaleFactor to be a number between 0 and 1");if(typeof this._maxNumScales!="number"||this._maxNumScales<0)throw new Error(this._name+" - expected maxNumScales to be a number > 0");if(!Array.isArray(this._scoreThresholds)||this._scoreThresholds.length!==3||this._scoreThresholds.some(function(u){return typeof u!="number"}))throw new Error(this._name+" - expected scoreThresholds to be an array of numbers of length 3");if(this._scaleSteps&&(!Array.isArray(this._scaleSteps)||this._scaleSteps.some(function(u){return typeof u!="number"})))throw new Error(this._name+" - expected scaleSteps to be an array of numbers")}return Object.defineProperty(n.prototype,"minFaceSize",{get:function(){return this._minFaceSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scaleFactor",{get:function(){return this._scaleFactor},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"maxNumScales",{get:function(){return this._maxNumScales},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scoreThresholds",{get:function(){return this._scoreThresholds},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scaleSteps",{get:function(){return this._scaleSteps},enumerable:!0,configurable:!0}),n}();function o9(n,t){function e(u,c){var l=Sn(n(9*u),[3,3,u,1]),d=Ot(n(u)),f=Ot(n(u)),h=Ot(n(u)),m=Ot(n(u));return t.push({paramPath:c+"/filters"},{paramPath:c+"/batch_norm_scale"},{paramPath:c+"/batch_norm_offset"},{paramPath:c+"/batch_norm_mean"},{paramPath:c+"/batch_norm_variance"}),{filters:l,batch_norm_scale:d,batch_norm_offset:f,batch_norm_mean:h,batch_norm_variance:m}}function r(u,c,l,d,f){var h=Sn(n(u*c*l*l),[l,l,u,c]),m=Ot(n(c));return t.push({paramPath:d+"/filters"},{paramPath:d+"/"+(f?"batch_norm_offset":"bias")}),{filters:h,bias:m}}function o(u,c,l,d){var f=r(u,c,l,d,!0),h=f.filters,m=f.bias;return{filters:h,batch_norm_offset:m}}function a(u,c,l){var d=e(u,l+"/depthwise_conv"),f=o(u,c,1,l+"/pointwise_conv");return{depthwise_conv:d,pointwise_conv:f}}function i(){var u=o(3,32,3,"mobilenetv1/conv_0"),c=a(32,64,"mobilenetv1/conv_1"),l=a(64,128,"mobilenetv1/conv_2"),d=a(128,128,"mobilenetv1/conv_3"),f=a(128,256,"mobilenetv1/conv_4"),h=a(256,256,"mobilenetv1/conv_5"),m=a(256,512,"mobilenetv1/conv_6"),p=a(512,512,"mobilenetv1/conv_7"),v=a(512,512,"mobilenetv1/conv_8"),g=a(512,512,"mobilenetv1/conv_9"),y=a(512,512,"mobilenetv1/conv_10"),w=a(512,512,"mobilenetv1/conv_11"),x=a(512,1024,"mobilenetv1/conv_12"),C=a(1024,1024,"mobilenetv1/conv_13");return{conv_0:u,conv_1:c,conv_2:l,conv_3:d,conv_4:f,conv_5:h,conv_6:m,conv_7:p,conv_8:v,conv_9:g,conv_10:y,conv_11:w,conv_12:x,conv_13:C}}function s(){var u=o(1024,256,1,"prediction_layer/conv_0"),c=o(256,512,3,"prediction_layer/conv_1"),l=o(512,128,1,"prediction_layer/conv_2"),d=o(128,256,3,"prediction_layer/conv_3"),f=o(256,128,1,"prediction_layer/conv_4"),h=o(128,256,3,"prediction_layer/conv_5"),m=o(256,64,1,"prediction_layer/conv_6"),p=o(64,128,3,"prediction_layer/conv_7"),v=r(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),g=r(512,9,1,"prediction_layer/box_predictor_0/class_predictor"),y=r(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),w=r(1024,18,1,"prediction_layer/box_predictor_1/class_predictor"),x=r(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),C=r(512,18,1,"prediction_layer/box_predictor_2/class_predictor"),_=r(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),E=r(256,18,1,"prediction_layer/box_predictor_3/class_predictor"),S=r(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),N=r(256,18,1,"prediction_layer/box_predictor_4/class_predictor"),$=r(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),A=r(128,18,1,"prediction_layer/box_predictor_5/class_predictor"),P={box_encoding_predictor:v,class_predictor:g},j={box_encoding_predictor:y,class_predictor:w},B={box_encoding_predictor:x,class_predictor:C},z={box_encoding_predictor:_,class_predictor:E},H={box_encoding_predictor:S,class_predictor:N},F={box_encoding_predictor:$,class_predictor:A};return{conv_0:u,conv_1:c,conv_2:l,conv_3:d,conv_4:f,conv_5:h,conv_6:m,conv_7:p,box_predictor_0:P,box_predictor_1:j,box_predictor_2:B,box_predictor_3:z,box_predictor_4:H,box_predictor_5:F}}return{extractMobilenetV1Params:i,extractPredictionLayerParams:s}}function a9(n){var t=[],e=lo(n),r=e.extractWeights,o=e.getRemainingWeights,a=o9(r,t),i=a.extractMobilenetV1Params,s=a.extractPredictionLayerParams,u=i(),c=s(),l=jf(r(5118*4),[1,5118,4]),d={extra_dim:l};if(t.push({paramPath:"output_layer/extra_dim"}),o().length!==0)throw new Error("weights remaing after extract: "+o().length);return{params:{mobilenetv1:u,prediction_layer:c,output_layer:d},paramMappings:t}}function i9(n,t){var e=zo(n,t);function r(c,l,d){var f=e(c+"/Conv2d_"+l+"_pointwise/weights",4,d+"/filters"),h=e(c+"/Conv2d_"+l+"_pointwise/convolution_bn_offset",1,d+"/batch_norm_offset");return{filters:f,batch_norm_offset:h}}function o(c){var l="mobilenetv1/conv_"+c,d="MobilenetV1/Conv2d_"+c+"_depthwise",f=l+"/depthwise_conv",h=l+"/pointwise_conv",m=e(d+"/depthwise_weights",4,f+"/filters"),p=e(d+"/BatchNorm/gamma",1,f+"/batch_norm_scale"),v=e(d+"/BatchNorm/beta",1,f+"/batch_norm_offset"),g=e(d+"/BatchNorm/moving_mean",1,f+"/batch_norm_mean"),y=e(d+"/BatchNorm/moving_variance",1,f+"/batch_norm_variance");return{depthwise_conv:{filters:m,batch_norm_scale:p,batch_norm_offset:v,batch_norm_mean:g,batch_norm_variance:y},pointwise_conv:r("MobilenetV1",c,h)}}function a(){return{conv_0:r("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:o(1),conv_2:o(2),conv_3:o(3),conv_4:o(4),conv_5:o(5),conv_6:o(6),conv_7:o(7),conv_8:o(8),conv_9:o(9),conv_10:o(10),conv_11:o(11),conv_12:o(12),conv_13:o(13)}}function i(c,l){var d=e(c+"/weights",4,l+"/filters"),f=e(c+"/biases",1,l+"/bias");return{filters:d,bias:f}}function s(c){var l=i("Prediction/BoxPredictor_"+c+"/BoxEncodingPredictor","prediction_layer/box_predictor_"+c+"/box_encoding_predictor"),d=i("Prediction/BoxPredictor_"+c+"/ClassPredictor","prediction_layer/box_predictor_"+c+"/class_predictor");return{box_encoding_predictor:l,class_predictor:d}}function u(){return{conv_0:r("Prediction",0,"prediction_layer/conv_0"),conv_1:r("Prediction",1,"prediction_layer/conv_1"),conv_2:r("Prediction",2,"prediction_layer/conv_2"),conv_3:r("Prediction",3,"prediction_layer/conv_3"),conv_4:r("Prediction",4,"prediction_layer/conv_4"),conv_5:r("Prediction",5,"prediction_layer/conv_5"),conv_6:r("Prediction",6,"prediction_layer/conv_6"),conv_7:r("Prediction",7,"prediction_layer/conv_7"),box_predictor_0:s(0),box_predictor_1:s(1),box_predictor_2:s(2),box_predictor_3:s(3),box_predictor_4:s(4),box_predictor_5:s(5)}}return{extractMobilenetV1Params:a,extractPredictionLayerParams:u}}function s9(n){var t=[],e=i9(n,t),r=e.extractMobilenetV1Params,o=e.extractPredictionLayerParams,a=n["Output/extra_dim"];if(t.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!hl(a))throw new Error("expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have "+a);var i={mobilenetv1:r(),prediction_layer:o(),output_layer:{extra_dim:a}};return co(n,t),{params:i,paramMappings:t}}function Ur(n,t,e){return xe(function(){var r=Zn(n,t.filters,e,"same");return r=qe(r,t.batch_norm_offset),lh(r,0,6)})}var u9=.0010000000474974513;function c9(n,t,e){return xe(function(){var r=al(n,t.filters,e,"same");return r=z1(r,t.batch_norm_mean,t.batch_norm_variance,t.batch_norm_offset,t.batch_norm_scale,u9),lh(r,0,6)})}function l9(n){return[2,4,6,12].some(function(t){return t===n})?[2,2]:[1,1]}function d9(n,t){return xe(function(){var e=null,r=Ur(n,t.conv_0,[2,2]),o=[t.conv_1,t.conv_2,t.conv_3,t.conv_4,t.conv_5,t.conv_6,t.conv_7,t.conv_8,t.conv_9,t.conv_10,t.conv_11,t.conv_12,t.conv_13];if(o.forEach(function(a,i){var s=i+1,u=l9(s);r=c9(r,a.depthwise_conv,u),r=Ur(r,a.pointwise_conv,[1,1]),s===11&&(e=r)}),e===null)throw new Error("mobileNetV1 - output of conv layer 11 is null");return{out:r,conv11:e}})}function f9(n,t,e,r,o){var a=n.shape[0],i=Math.min(e,a),s=t.map(function(l,d){return{score:l,boxIndex:d}}).filter(function(l){return l.score>o}).sort(function(l,d){return d.score-l.score}),u=function(l){return l<=r?1:0},c=[];return s.forEach(function(l){if(!(c.length>=i)){for(var d=l.score,f=c.length-1;f>=0;--f){var h=h9(n,l.boxIndex,c[f]);if(h!==0&&(l.score*=u(h),l.score<=o))break}d===l.score&&c.push(l.boxIndex)}}),c}function h9(n,t,e){var r=n.arraySync(),o=Math.min(r[t][0],r[t][2]),a=Math.min(r[t][1],r[t][3]),i=Math.max(r[t][0],r[t][2]),s=Math.max(r[t][1],r[t][3]),u=Math.min(r[e][0],r[e][2]),c=Math.min(r[e][1],r[e][3]),l=Math.max(r[e][0],r[e][2]),d=Math.max(r[e][1],r[e][3]),f=(i-o)*(s-a),h=(l-u)*(d-c);if(f<=0||h<=0)return 0;var m=Math.max(o,u),p=Math.max(a,c),v=Math.min(i,l),g=Math.min(s,d),y=Math.max(v-m,0)*Math.max(g-p,0);return y/(f+h-y)}function p9(n){var t=jt(Bo(n,[1,0])),e=[zt(t[2],t[0]),zt(t[3],t[1])],r=[qe(t[0],ur(e[0],ve(2))),qe(t[1],ur(e[1],ve(2)))];return{sizes:e,centers:r}}function v9(n,t){var e=p9(n),r=e.sizes,o=e.centers,a=jt(Bo(t,[1,0])),i=ur(cn(dh(ur(a[2],ve(5))),r[0]),ve(2)),s=qe(cn(ur(a[0],ve(10)),r[0]),o[0]),u=ur(cn(dh(ur(a[3],ve(5))),r[1]),ve(2)),c=qe(cn(ur(a[1],ve(10)),r[1]),o[1]);return Bo(Bn([zt(s,i),zt(c,u),qe(s,i),qe(c,u)]),[1,0])}function m9(n,t,e){return xe(function(){var r=n.shape[0],o=v9(ir(_i(e.extra_dim,[r,1,1]),[-1,4]),ir(n,[-1,4]));o=ir(o,[r,o.shape[0]/r,4]);var a=W1(Br(t,[0,0,1],[-1,-1,-1])),i=Br(a,[0,0,0],[-1,-1,1]);i=ir(i,[r,i.shape[1]]);var s=jt(o),u=jt(i);return{boxes:s,scores:u}})}function Ri(n,t){return xe(function(){var e=n.shape[0],r=ir(cr(n,t.box_encoding_predictor),[e,-1,1,4]),o=ir(cr(n,t.class_predictor),[e,-1,3]);return{boxPredictionEncoding:r,classPrediction:o}})}function g9(n,t,e){return xe(function(){var r=Ur(n,e.conv_0,[1,1]),o=Ur(r,e.conv_1,[2,2]),a=Ur(o,e.conv_2,[1,1]),i=Ur(a,e.conv_3,[2,2]),s=Ur(i,e.conv_4,[1,1]),u=Ur(s,e.conv_5,[2,2]),c=Ur(u,e.conv_6,[1,1]),l=Ur(c,e.conv_7,[2,2]),d=Ri(t,e.box_predictor_0),f=Ri(n,e.box_predictor_1),h=Ri(o,e.box_predictor_2),m=Ri(i,e.box_predictor_3),p=Ri(u,e.box_predictor_4),v=Ri(l,e.box_predictor_5),g=Vt([d.boxPredictionEncoding,f.boxPredictionEncoding,h.boxPredictionEncoding,m.boxPredictionEncoding,p.boxPredictionEncoding,v.boxPredictionEncoding],1),y=Vt([d.classPrediction,f.classPrediction,h.classPrediction,m.classPrediction,p.classPrediction,v.classPrediction],1);return{boxPredictions:g,classPredictions:y}})}var ou=function(){function n(t){var e=t===void 0?{}:t,r=e.minConfidence,o=e.maxResults;if(this._name="SsdMobilenetv1Options",this._minConfidence=r||.5,this._maxResults=o||100,typeof this._minConfidence!="number"||this._minConfidence<=0||this._minConfidence>=1)throw new Error(this._name+" - expected minConfidence to be a number between 0 and 1");if(typeof this._maxResults!="number")throw new Error(this._name+" - expected maxResults to be a number")}return Object.defineProperty(n.prototype,"minConfidence",{get:function(){return this._minConfidence},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"maxResults",{get:function(){return this._maxResults},enumerable:!0,configurable:!0}),n}(),x2=function(n){De(t,n);function t(){return n.call(this,"SsdMobilenetv1")||this}return t.prototype.forwardInput=function(e){var r=this.params;if(!r)throw new Error("SsdMobilenetv1 - load model before inference");return xe(function(){var o=e.toBatchTensor(512,!1).toFloat(),a=zt(cn(o,ve(.007843137718737125)),ve(1)),i=d9(a,r.mobilenetv1),s=g9(i.out,i.conv11,r.prediction_layer),u=s.boxPredictions,c=s.classPredictions;return m9(u,c,r.output_layer)})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.locateFaces=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o,a,i,s,u,c,l,d,f,h,m,p,v,g,y,w,x,C,_,E,S;return ke(this,function(N){switch(N.label){case 0:return o=new ou(r),a=o.maxResults,i=o.minConfidence,[4,Yt(e)];case 1:for(s=N.sent(),u=this.forwardInput(s),c=u.boxes,l=u.scores,d=c[0],f=l[0],h=1;h<c.length;h++)c[h].dispose(),l[h].dispose();return v=(p=Array).from,[4,f.data()];case 2:return m=v.apply(p,[N.sent()]),g=.5,y=f9(d,m,a,g,i),w=s.getReshapedInputDimensions(0),x=s.inputSize,C=x/w.width,_=x/w.height,E=d.arraySync(),S=y.map(function($){var A=[Math.max(0,E[$][0]),Math.min(1,E[$][2])].map(function(F){return F*_}),P=A[0],j=A[1],B=[Math.max(0,E[$][1]),Math.min(1,E[$][3])].map(function(F){return F*C}),z=B[0],H=B[1];return new Wr(m[$],new Uh(z,P,H-z,j-P),{height:s.getInputHeight(0),width:s.getInputWidth(0)})}),d.dispose(),f.dispose(),[2,S]}})})},t.prototype.getDefaultModelName=function(){return"ssd_mobilenetv1_model"},t.prototype.extractParamsFromWeigthMap=function(e){return s9(e)},t.prototype.extractParams=function(e){return a9(e)},t}(uo);(function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t})(x2);var y9=.4,b9=[new ot(.738768,.874946),new ot(2.42204,2.65704),new ot(4.30971,7.04493),new ot(10.246,4.59428),new ot(12.6868,11.8741)],x9=[new ot(1.603231,2.094468),new ot(6.041143,7.080126),new ot(2.882459,3.518061),new ot(4.266906,5.178857),new ot(9.041765,10.66308)],w9=[117.001,114.697,97.404],C9="tiny_yolov2_model",_9="tiny_yolov2_separable_conv_model",_l=function(n){return typeof n=="number"};function E9(n){if(!n)throw new Error("invalid config: "+n);if(typeof n.withSeparableConvs!="boolean")throw new Error("config.withSeparableConvs has to be a boolean, have: "+n.withSeparableConvs);if(!_l(n.iouThreshold)||n.iouThreshold<0||n.iouThreshold>1)throw new Error("config.iouThreshold has to be a number between [0, 1], have: "+n.iouThreshold);if(!Array.isArray(n.classes)||!n.classes.length||!n.classes.every(function(t){return typeof t=="string"}))throw new Error("config.classes has to be an array class names: string[], have: "+JSON.stringify(n.classes));if(!Array.isArray(n.anchors)||!n.anchors.length||!n.anchors.map(function(t){return t||{}}).every(function(t){return _l(t.x)&&_l(t.y)}))throw new Error("config.anchors has to be an array of { x: number, y: number }, have: "+JSON.stringify(n.anchors));if(n.meanRgb&&(!Array.isArray(n.meanRgb)||n.meanRgb.length!==3||!n.meanRgb.every(_l)))throw new Error("config.meanRgb has to be an array of shape [number, number, number], have: "+JSON.stringify(n.meanRgb))}function rp(n){return xe(function(){var t=cn(n,ve(.10000000149011612));return qe(wt(zt(n,t)),t)})}function Ho(n,t){return xe(function(){var e=Ia(n,[[0,0],[1,1],[1,1],[0,0]]);return e=Zn(e,t.conv.filters,[1,1],"valid"),e=zt(e,t.bn.sub),e=cn(e,t.bn.truediv),e=qe(e,t.conv.bias),rp(e)})}function Go(n,t){return xe(function(){var e=Ia(n,[[0,0],[1,1],[1,1],[0,0]]);return e=mh(e,t.depthwise_filter,t.pointwise_filter,[1,1],"valid"),e=qe(e,t.bias),rp(e)})}function S9(n,t){var e=xl(n,t);function r(i,s){var u=Ot(n(i)),c=Ot(n(i));return t.push({paramPath:s+"/sub"},{paramPath:s+"/truediv"}),{sub:u,truediv:c}}function o(i,s,u){var c=e(i,s,3,u+"/conv"),l=r(s,u+"/bn");return{conv:c,bn:l}}var a=Qh(n,t);return{extractConvParams:e,extractConvWithBatchNormParams:o,extractSeparableConvParams:a}}function N9(n,t,e,r){var o=lo(n),a=o.extractWeights,i=o.getRemainingWeights,s=[],u=S9(a,s),c=u.extractConvParams,l=u.extractConvWithBatchNormParams,d=u.extractSeparableConvParams,f;if(t.withSeparableConvs){var h=r[0],m=r[1],p=r[2],v=r[3],g=r[4],y=r[5],w=r[6],x=r[7],C=r[8],_=t.isFirstLayerConv2d?c(h,m,3,"conv0"):d(h,m,"conv0"),E=d(m,p,"conv1"),S=d(p,v,"conv2"),N=d(v,g,"conv3"),$=d(g,y,"conv4"),A=d(y,w,"conv5"),P=x?d(w,x,"conv6"):void 0,j=C?d(x,C,"conv7"):void 0,B=c(C||x||w,5*e,1,"conv8");f={conv0:_,conv1:E,conv2:S,conv3:N,conv4:$,conv5:A,conv6:P,conv7:j,conv8:B}}else{var h=r[0],m=r[1],p=r[2],v=r[3],g=r[4],y=r[5],w=r[6],x=r[7],C=r[8],_=l(h,m,"conv0"),E=l(m,p,"conv1"),S=l(p,v,"conv2"),N=l(v,g,"conv3"),$=l(g,y,"conv4"),A=l(y,w,"conv5"),P=l(w,x,"conv6"),j=l(x,C,"conv7"),B=c(C,5*e,1,"conv8");f={conv0:_,conv1:E,conv2:S,conv3:N,conv4:$,conv5:A,conv6:P,conv7:j,conv8:B}}if(i().length!==0)throw new Error("weights remaing after extract: "+i().length);return{params:f,paramMappings:s}}function $9(n,t){var e=zo(n,t);function r(s){var u=e(s+"/sub",1),c=e(s+"/truediv",1);return{sub:u,truediv:c}}function o(s){var u=e(s+"/filters",4),c=e(s+"/bias",1);return{filters:u,bias:c}}function a(s){var u=o(s+"/conv"),c=r(s+"/bn");return{conv:u,bn:c}}var i=Jh(e);return{extractConvParams:o,extractConvWithBatchNormParams:a,extractSeparableConvParams:i}}function k9(n,t){var e=[],r=$9(n,e),o=r.extractConvParams,a=r.extractConvWithBatchNormParams,i=r.extractSeparableConvParams,s;if(t.withSeparableConvs){var u=t.filterSizes&&t.filterSizes.length||9;s={conv0:t.isFirstLayerConv2d?o("conv0"):i("conv0"),conv1:i("conv1"),conv2:i("conv2"),conv3:i("conv3"),conv4:i("conv4"),conv5:i("conv5"),conv6:u>7?i("conv6"):void 0,conv7:u>8?i("conv7"):void 0,conv8:o("conv8")}}else s={conv0:a("conv0"),conv1:a("conv1"),conv2:a("conv2"),conv3:a("conv3"),conv4:a("conv4"),conv5:a("conv5"),conv6:a("conv6"),conv7:a("conv7"),conv8:o("conv8")};return co(n,e),{params:s,paramMappings:e}}var w2;(function(n){n[n.XS=224]="XS",n[n.SM=320]="SM",n[n.MD=416]="MD",n[n.LG=608]="LG"})(w2||(w2={}));var op=function(){function n(t){var e=t===void 0?{}:t,r=e.inputSize,o=e.scoreThreshold;if(this._name="TinyYolov2Options",this._inputSize=r||416,this._scoreThreshold=o||.5,typeof this._inputSize!="number"||this._inputSize%32!==0)throw new Error(this._name+" - expected inputSize to be a number divisible by 32");if(typeof this._scoreThreshold!="number"||this._scoreThreshold<=0||this._scoreThreshold>=1)throw new Error(this._name+" - expected scoreThreshold to be a number between 0 and 1")}return Object.defineProperty(n.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scoreThreshold",{get:function(){return this._scoreThreshold},enumerable:!0,configurable:!0}),n}(),C2=function(n){De(t,n);function t(e){var r=n.call(this,"TinyYolov2")||this;return E9(e),r._config=e,r}return Object.defineProperty(t.prototype,"config",{get:function(){return this._config},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"withClassScores",{get:function(){return this.config.withClassScores||this.config.classes.length>1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"boxEncodingSize",{get:function(){return 5+(this.withClassScores?this.config.classes.length:0)},enumerable:!0,configurable:!0}),t.prototype.runTinyYolov2=function(e,r){var o=Ho(e,r.conv0);return o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv1),o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv2),o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv3),o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv4),o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv5),o=Kt(o,[2,2],[1,1],"same"),o=Ho(o,r.conv6),o=Ho(o,r.conv7),cr(o,r.conv8,"valid",!1)},t.prototype.runMobilenet=function(e,r){var o=this.config.isFirstLayerConv2d?rp(cr(e,r.conv0,"valid",!1)):Go(e,r.conv0);return o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv1),o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv2),o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv3),o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv4),o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv5),o=Kt(o,[2,2],[1,1],"same"),o=r.conv6?Go(o,r.conv6):o,o=r.conv7?Go(o,r.conv7):o,cr(o,r.conv8,"valid",!1)},t.prototype.forwardInput=function(e,r){var o=this,a=this.params;if(!a)throw new Error("TinyYolov2 - load model before inference");return xe(function(){var i=e.toBatchTensor(r,!1).toFloat();return i=o.config.meanRgb?ru(i,o.config.meanRgb):i,i=i.div(ve(256)),o.config.withSeparableConvs?o.runMobilenet(i,a):o.runTinyYolov2(i,a)})},t.prototype.forward=function(e,r){return $e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return o=this.forwardInput,[4,Yt(e)];case 1:return[4,o.apply(this,[a.sent(),r])];case 2:return[2,a.sent()]}})})},t.prototype.detect=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o,a,i,s,u,c,l,d,f,h,m,p,v,g,y=this;return ke(this,function(w){switch(w.label){case 0:return o=new op(r),a=o.inputSize,i=o.scoreThreshold,[4,Yt(e)];case 1:return s=w.sent(),[4,this.forwardInput(s,a)];case 2:return u=w.sent(),c=xe(function(){return jt(u)[0].expandDims()}),l={width:s.getInputWidth(0),height:s.getInputHeight(0)},[4,this.extractBoxes(c,s.getReshapedInputDimensions(0),i)];case 3:return d=w.sent(),u.dispose(),c.dispose(),f=d.map(function(x){return x.box}),h=d.map(function(x){return x.score}),m=d.map(function(x){return x.classScore}),p=d.map(function(x){return y.config.classes[x.label]}),v=nu(f.map(function(x){return x.rescale(a)}),h,this.config.iouThreshold,!0),g=v.map(function(x){return new jb(h[x],m[x],p[x],f[x],l)}),[2,g]}})})},t.prototype.getDefaultModelName=function(){return""},t.prototype.extractParamsFromWeigthMap=function(e){return k9(e,this.config)},t.prototype.extractParams=function(e){var r=this.config.filterSizes||t.DEFAULT_FILTER_SIZES,o=r?r.length:void 0;if(o!==7&&o!==8&&o!==9)throw new Error("TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found "+o+" filterSizes in config");return N9(e,this.config,this.boxEncodingSize,r)},t.prototype.extractBoxes=function(e,r,o){return $e(this,void 0,void 0,function(){var a,i,s,u,c,l,d,f,h,m,p,v,g,y,w,x,C,_,E,S,N,$,A,P,j,B,z,H,F,M=this;return ke(this,function(O){switch(O.label){case 0:return a=r.width,i=r.height,s=Math.max(a,i),u=s/a,c=s/i,l=e.shape[1],d=this.config.anchors.length,f=xe(function(){var I=e.reshape([l,l,d,M.boxEncodingSize]),L=I.slice([0,0,0,0],[l,l,d,4]),K=I.slice([0,0,0,4],[l,l,d,1]),q=M.withClassScores?oo(I.slice([0,0,0,5],[l,l,d,M.config.classes.length]),3):ve(0);return[L,K,q]}),h=f[0],m=f[1],p=f[2],v=[],[4,m.array()];case 1:return g=O.sent(),[4,h.array()];case 2:y=O.sent(),w=0,O.label=3;case 3:if(!(w<l))return[3,12];x=0,O.label=4;case 4:if(!(x<l))return[3,11];C=0,O.label=5;case 5:return C<d?(_=jh(g[w][x][C][0]),!o||_>o?(E=(x+jh(y[w][x][C][0]))/l*u,S=(w+jh(y[w][x][C][1]))/l*c,N=Math.exp(y[w][x][C][2])*this.config.anchors[C].x/l*u,$=Math.exp(y[w][x][C][3])*this.config.anchors[C].y/l*c,A=E-N/2,P=S-$/2,j={row:w,col:x,anchor:C},this.withClassScores?[4,this.extractPredictedClass(p,j)]:[3,7]):[3,9]):[3,10];case 6:return F=O.sent(),[3,8];case 7:F={classScore:1,label:0},O.label=8;case 8:B=F,z=B.classScore,H=B.label,v.push(dn({box:new pl(A,P,A+N,P+$),score:_,classScore:_*z,label:H},j)),O.label=9;case 9:return C++,[3,5];case 10:return x++,[3,4];case 11:return w++,[3,3];case 12:return h.dispose(),m.dispose(),p.dispose(),[2,v]}})})},t.prototype.extractPredictedClass=function(e,r){return $e(this,void 0,void 0,function(){var o,a,i,s;return ke(this,function(u){switch(u.label){case 0:return o=r.row,a=r.col,i=r.anchor,[4,e.array()];case 1:return s=u.sent(),[2,Array(this.config.classes.length).fill(0).map(function(c,l){return s[o][a][i][l]}).map(function(c,l){return{classScore:c,label:l}}).reduce(function(c,l){return c.classScore>l.classScore?c:l})]}})})},t.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024],t}(uo),P9=function(n){De(t,n);function t(e){e===void 0&&(e=!0);var r=this,o=Object.assign({},{withSeparableConvs:e,iouThreshold:y9,classes:["face"]},e?{anchors:x9,meanRgb:w9}:{anchors:b9,withClassScores:!0});return r=n.call(this,o)||this,r}return Object.defineProperty(t.prototype,"withSeparableConvs",{get:function(){return this.config.withSeparableConvs},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),t.prototype.locateFaces=function(e,r){return $e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return[4,this.detect(e,r)];case 1:return o=a.sent(),[2,o.map(function(i){return new Wr(i.score,i.relativeBox,{width:i.imageWidth,height:i.imageHeight})})]}})})},t.prototype.getDefaultModelName=function(){return this.withSeparableConvs?_9:C9},t.prototype.extractParamsFromWeigthMap=function(e){return n.prototype.extractParamsFromWeigthMap.call(this,e)},t}(C2),I9=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e._name="TinyFaceDetectorOptions",e}return t}(op),au=function(){function n(){}return n.prototype.then=function(t){return $e(this,void 0,void 0,function(){var e;return ke(this,function(r){switch(r.label){case 0:return e=t,[4,this.run()];case 1:return[2,e.apply(void 0,[r.sent()])]}})})},n.prototype.run=function(){return $e(this,void 0,void 0,function(){return ke(this,function(t){throw new Error("ComposableTask - run is not implemented")})})},n}();function El(n,t,e,r,o){return o===void 0&&(o=function(a){var i=a.alignedRect;return i}),$e(this,void 0,void 0,function(){var a,i,s,u,c;return ke(this,function(l){switch(l.label){case 0:return a=n.map(function(d){return R5(d)?o(d):d.detection}),s=r,s?[3,5]:t instanceof bt?[4,Yh(t,a)]:[3,2];case 1:return u=l.sent(),[3,4];case 2:return[4,Kh(t,a)];case 3:u=l.sent(),l.label=4;case 4:s=u,l.label=5;case 5:return i=s,[4,e(i)];case 6:return c=l.sent(),i.forEach(function(d){return d instanceof bt&&d.dispose()}),[2,c]}})})}function ap(n,t,e,r,o){return $e(this,void 0,void 0,function(){var a=this;return ke(this,function(i){return[2,El([n],t,function(s){return $e(a,void 0,void 0,function(){return ke(this,function(u){return[2,e(s[0])]})})},r,o)]})})}function A9(n){return xe(function(){return Bn(jt(n,3).reverse(),3)})}var Sl=2,Nl=12;function T9(n,t){var e=xl(n,t),r=Zh(n,t);function o(c,l){var d=Ot(n(c));return t.push({paramPath:l}),d}function a(c,l,d){d===void 0&&(d=!1);var f=e(c[0],c[1],3,l+"/conv1"),h=o(c[1],l+"/prelu1_alpha"),m=e(c[1],c[2],3,l+"/conv2"),p=o(c[2],l+"/prelu2_alpha"),v=e(c[2],c[3],d?2:3,l+"/conv3"),g=o(c[3],l+"/prelu3_alpha");return{conv1:f,prelu1_alpha:h,conv2:m,prelu2_alpha:p,conv3:v,prelu3_alpha:g}}function i(){var c=a([3,10,16,32],"pnet"),l=e(32,2,1,"pnet/conv4_1"),d=e(32,4,1,"pnet/conv4_2");return dn(dn({},c),{conv4_1:l,conv4_2:d})}function s(){var c=a([3,28,48,64],"rnet",!0),l=r(576,128,"rnet/fc1"),d=o(128,"rnet/prelu4_alpha"),f=r(128,2,"rnet/fc2_1"),h=r(128,4,"rnet/fc2_2");return dn(dn({},c),{fc1:l,prelu4_alpha:d,fc2_1:f,fc2_2:h})}function u(){var c=a([3,32,64,64],"onet"),l=e(64,128,2,"onet/conv4"),d=o(128,"onet/prelu4_alpha"),f=r(1152,256,"onet/fc1"),h=o(256,"onet/prelu5_alpha"),m=r(256,2,"onet/fc2_1"),p=r(256,4,"onet/fc2_2"),v=r(256,10,"onet/fc2_3");return dn(dn({},c),{conv4:l,prelu4_alpha:d,fc1:f,prelu5_alpha:h,fc2_1:m,fc2_2:p,fc2_3:v})}return{extractPNetParams:i,extractRNetParams:s,extractONetParams:u}}function O9(n){var t=lo(n),e=t.extractWeights,r=t.getRemainingWeights,o=[],a=T9(e,o),i=a.extractPNetParams,s=a.extractRNetParams,u=a.extractONetParams,c=i(),l=s(),d=u();if(r().length!==0)throw new Error("weights remaing after extract: "+r().length);return{params:{pnet:c,rnet:l,onet:d},paramMappings:o}}function D9(n,t){var e=zo(n,t);function r(l){var d=e(l+"/weights",4,l+"/filters"),f=e(l+"/bias",1);return{filters:d,bias:f}}function o(l){var d=e(l+"/weights",2),f=e(l+"/bias",1);return{weights:d,bias:f}}function a(l){return e(l,1)}function i(l){var d=r(l+"/conv1"),f=a(l+"/prelu1_alpha"),h=r(l+"/conv2"),m=a(l+"/prelu2_alpha"),p=r(l+"/conv3"),v=a(l+"/prelu3_alpha");return{conv1:d,prelu1_alpha:f,conv2:h,prelu2_alpha:m,conv3:p,prelu3_alpha:v}}function s(){var l=i("pnet"),d=r("pnet/conv4_1"),f=r("pnet/conv4_2");return dn(dn({},l),{conv4_1:d,conv4_2:f})}function u(){var l=i("rnet"),d=o("rnet/fc1"),f=a("rnet/prelu4_alpha"),h=o("rnet/fc2_1"),m=o("rnet/fc2_2");return dn(dn({},l),{fc1:d,prelu4_alpha:f,fc2_1:h,fc2_2:m})}function c(){var l=i("onet"),d=r("onet/conv4"),f=a("onet/prelu4_alpha"),h=o("onet/fc1"),m=a("onet/prelu5_alpha"),p=o("onet/fc2_1"),v=o("onet/fc2_2"),g=o("onet/fc2_3");return dn(dn({},l),{conv4:d,prelu4_alpha:f,fc1:h,prelu5_alpha:m,fc2_1:p,fc2_2:v,fc2_3:g})}return{extractPNetParams:s,extractRNetParams:u,extractONetParams:c}}function M9(n){var t=[],e=D9(n,t),r=e.extractPNetParams,o=e.extractRNetParams,a=e.extractONetParams,i=r(),s=o(),u=a();return co(n,t),{params:{pnet:i,rnet:s,onet:u},paramMappings:t}}function ip(n,t){var e=t[0],r=t[1];return{height:Math.floor(e*n),width:Math.floor(r*n)}}function F9(n,t,e){for(var r=e[0],o=e[1],a=Nl/n,i=[],s=Math.min(r,o)*a,u=0;s>=12;)i.push(a*Math.pow(t,u)),s=s*t,u+=1;return i}var sp=function(n){De(t,n);function t(e,r,o,a){return n.call(this,{left:e,top:r,right:o,bottom:a},!0)||this}return t}(Uo);function _2(n){return xe(function(){return cn(zt(n,ve(127.5)),ve(.0078125))})}function Li(n,t){return xe(function(){return qe(wt(n),cn(t,el(wt(el(n)))))})}function up(n,t,e){return e===void 0&&(e=!1),xe(function(){var r=cr(n,t.conv1,"valid");return r=Li(r,t.prelu1_alpha),r=Kt(r,e?[2,2]:[3,3],[2,2],"same"),r=cr(r,t.conv2,"valid"),r=Li(r,t.prelu2_alpha),r=e?r:Kt(r,[3,3],[2,2],"valid"),r=cr(r,t.conv3,"valid"),r=Li(r,t.prelu3_alpha),r})}function R9(n,t){return xe(function(){var e=up(n,t,!0),r=cr(e,t.conv4_1,"valid"),o=Xn(sl(r,3),3),a=oo(zt(r,o),3),i=cr(e,t.conv4_2,"valid");return{prob:a,regions:i}})}function L9(n,t){return xe(function(){var e=ip(t,n.shape.slice(1)),r=e.height,o=e.width,a=wh.resizeBilinear(n,[r,o]),i=_2(a);return Bo(i,[0,2,1,3])})}function B9(n,t,e,r){for(var o=[],a=n.arraySync(),i=0;i<n.shape[0];i++)for(var s=0;s<n.shape[1];s++)a[i][s]>=r&&o.push(new ot(s,i));var u=o.map(function(c){var l=new pl(Math.round((c.y*Sl+1)/e),Math.round((c.x*Sl+1)/e),Math.round((c.y*Sl+Nl)/e),Math.round((c.x*Sl+Nl)/e)),d=a[c.y][c.x],f=t.arraySync(),h=new sp(f[c.y][c.x][0],f[c.y][c.x][1],f[c.y][c.x][2],f[c.y][c.x][3]);return{cell:l,score:d,region:h}});return u}function W9(n,t,e,r,o){o.stage1=[];var a=t.map(function(f){return xe(function(){var h={scale:f},m=L9(n,f),p=Date.now(),v=R9(m,r),g=v.prob,y=v.regions;h.pnet=Date.now()-p;var w=jt(jt(g,3)[1])[0],x=jt(y)[0];return{scoresTensor:w,regionsTensor:x,scale:f,statsForScale:h}})}),i=a.map(function(f){var h=f.scoresTensor,m=f.regionsTensor,p=f.scale,v=f.statsForScale,g=B9(h,m,p,e);if(h.dispose(),m.dispose(),!g.length)return o.stage1.push(v),[];var y=Date.now(),w=nu(g.map(function(x){return x.cell}),g.map(function(x){return x.score}),.5);return v.nms=Date.now()-y,v.numBoxes=w.length,o.stage1.push(v),w.map(function(x){return g[x]})}),s=i.reduce(function(f,h){return f.concat(h)},[]),u=[],c=[];if(s.length>0){var l=Date.now(),d=nu(s.map(function(f){return f.cell}),s.map(function(f){return f.score}),.7);o.stage1_nms=Date.now()-l,c=d.map(function(f){return s[f].score}),u=d.map(function(f){return s[f]}).map(function(f){var h=f.cell,m=f.region;return new pl(h.left+m.left*h.width,h.top+m.top*h.height,h.right+m.right*h.width,h.bottom+m.bottom*h.height).toSquare().round()})}return{boxes:u,scores:c}}function E2(n,t,e){var r=e.width,o=e.height;return $e(this,void 0,void 0,function(){var a,i,s,u=this;return ke(this,function(c){switch(c.label){case 0:return a=Ba(n),[4,Promise.all(t.map(function(l){return $e(u,void 0,void 0,function(){var d,f,h,m,p,v,g,y;return ke(this,function(w){return d=l.padAtBorders(n.height,n.width),f=d.y,h=d.ey,m=d.x,p=d.ex,v=m-1,g=f-1,y=a.getImageData(v,g,p-v,h-g),[2,rn.isNodejs()?qh(y):createImageBitmap(y)]})})}))];case 1:return i=c.sent(),s=[],i.forEach(function(l){var d=gl({width:r,height:o}),f=Ba(d);f.drawImage(l,0,0,r,o);for(var h=f.getImageData(0,0,r,o).data,m=[],p=0;p<h.length;p+=4)m.push(h[p+2]),m.push(h[p+1]),m.push(h[p]);s.push(m)}),[2,s.map(function(l){var d=xe(function(){var f=Bo(Sn(l,[1,r,o,3]),[0,2,1,3]).toFloat();return _2(f)});return d})]}})})}function V9(n,t){return xe(function(){var e=up(n,t),r=ir(e,[e.shape[0],t.fc1.weights.shape[0]]),o=Vr(r,t.fc1),a=Li(o,t.prelu4_alpha),i=Vr(a,t.fc2_1),s=Xn(sl(i,1),1),u=oo(zt(i,s),1),c=Vr(a,t.fc2_2),l=jt(u,1)[1];return{scores:l,regions:c}})}function j9(n,t,e,r,o){return $e(this,void 0,void 0,function(){var a,i,s,u,c,l,d,f,h,m,p,v,g,y;return ke(this,function(w){switch(w.label){case 0:return a=Date.now(),[4,E2(n,t,{width:24,height:24})];case 1:return i=w.sent(),o.stage2_extractImagePatches=Date.now()-a,a=Date.now(),s=i.map(function(x){var C=V9(x,r);return x.dispose(),C}),o.stage2_rnet=Date.now()-a,u=s.length>1?Vt(s.map(function(x){return x.scores})):s[0].scores,d=(l=Array).from,[4,u.data()];case 2:return c=d.apply(l,[w.sent()]),u.dispose(),f=c.map(function(x,C){return{score:x,idx:C}}).filter(function(x){return x.score>e}).map(function(x){var C=x.idx;return C}),h=f.map(function(x){return t[x]}),m=f.map(function(x){return c[x]}),p=[],v=[],h.length>0&&(a=Date.now(),g=nu(h,m,.7),o.stage2_nms=Date.now()-a,y=g.map(function(x){var C=s[f[x]].regions.arraySync();return new sp(C[0][0],C[0][1],C[0][2],C[0][3])}),v=g.map(function(x){return m[x]}),p=g.map(function(x,C){return h[x].calibrate(y[C])})),s.forEach(function(x){x.regions.dispose(),x.scores.dispose()}),[2,{boxes:p,scores:v}]}})})}function U9(n,t){return xe(function(){var e=up(n,t);e=Kt(e,[2,2],[2,2],"same"),e=cr(e,t.conv4,"valid"),e=Li(e,t.prelu4_alpha);var r=ir(e,[e.shape[0],t.fc1.weights.shape[0]]),o=Vr(r,t.fc1),a=Li(o,t.prelu5_alpha),i=Vr(a,t.fc2_1),s=Xn(sl(i,1),1),u=oo(zt(i,s),1),c=Vr(a,t.fc2_2),l=Vr(a,t.fc2_3),d=jt(u,1)[1];return{scores:d,regions:c,points:l}})}function z9(n,t,e,r,o){return $e(this,void 0,void 0,function(){var a,i,s,u,c,l,d,f,h,m,p,v,g,y,w;return ke(this,function(x){switch(x.label){case 0:return a=Date.now(),[4,E2(n,t,{width:48,height:48})];case 1:return i=x.sent(),o.stage3_extractImagePatches=Date.now()-a,a=Date.now(),s=i.map(function(C){var _=U9(C,r);return C.dispose(),_}),o.stage3_onet=Date.now()-a,u=s.length>1?Vt(s.map(function(C){return C.scores})):s[0].scores,d=(l=Array).from,[4,u.data()];case 2:return c=d.apply(l,[x.sent()]),u.dispose(),f=c.map(function(C,_){return{score:C,idx:_}}).filter(function(C){return C.score>e}).map(function(C){var _=C.idx;return _}),h=f.map(function(C){var _=s[C].regions.arraySync();return new sp(_[0][0],_[0][1],_[0][2],_[0][3])}),m=f.map(function(C,_){return t[C].calibrate(h[_])}),p=f.map(function(C){return c[C]}),v=[],g=[],y=[],m.length>0&&(a=Date.now(),w=nu(m,p,.7,!1),o.stage3_nms=Date.now()-a,v=w.map(function(C){return m[C]}),g=w.map(function(C){return p[C]}),y=w.map(function(C,_){return Array(5).fill(0).map(function(E,S){var N=s[C].points.arraySync();return new ot(N[0][S]*(v[_].width+1)+v[_].left,N[0][S+5]*(v[_].height+1)+v[_].top)})})),s.forEach(function(C){C.regions.dispose(),C.scores.dispose(),C.points.dispose()}),[2,{boxes:v,scores:g,points:y}]}})})}var H9=function(n){De(t,n);function t(){return n.call(this,"Mtcnn")||this}return t.prototype.load=function(e){return $e(this,void 0,void 0,function(){return ke(this,function(r){return console.warn("mtcnn is deprecated and will be removed soon"),[2,n.prototype.load.call(this,e)]})})},t.prototype.loadFromDisk=function(e){return $e(this,void 0,void 0,function(){return ke(this,function(r){return console.warn("mtcnn is deprecated and will be removed soon"),[2,n.prototype.loadFromDisk.call(this,e)]})})},t.prototype.forwardInput=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o,a,i,s,u,c,l,d,f,h,m,p,v,g,y,w,x,C,_,E,S;return ke(this,function(N){switch(N.label){case 0:if(o=this.params,!o)throw new Error("Mtcnn - load model before inference");if(a=e.canvases[0],!a)throw new Error("Mtcnn - inputCanvas is not defined, note that passing tensors into Mtcnn.forwardInput is not supported yet.");return i={},s=Date.now(),u=xe(function(){return A9(Xn(Bh.fromPixels(a)).toFloat())}),c=function($){return u.dispose(),i.total=Date.now()-s,$},l=u.shape.slice(1),d=l[0],f=l[1],h=new b2(r),m=h.minFaceSize,p=h.scaleFactor,v=h.maxNumScales,g=h.scoreThresholds,y=h.scaleSteps,w=(y||F9(m,p,[d,f])).filter(function($){var A=ip($,[d,f]);return Math.min(A.width,A.height)>Nl}).slice(0,v),i.scales=w,i.pyramid=w.map(function($){return ip($,[d,f])}),x=Date.now(),[4,W9(u,w,g[0],o.pnet,i)];case 1:return C=N.sent(),i.total_stage1=Date.now()-x,C.boxes.length?(i.stage2_numInputBoxes=C.boxes.length,x=Date.now(),[4,j9(a,C.boxes,g[1],o.rnet,i)]):[2,c({results:[],stats:i})];case 2:return _=N.sent(),i.total_stage2=Date.now()-x,_.boxes.length?(i.stage3_numInputBoxes=_.boxes.length,x=Date.now(),[4,z9(a,_.boxes,g[2],o.onet,i)]):[2,c({results:[],stats:i})];case 3:return E=N.sent(),i.total_stage3=Date.now()-x,S=E.boxes.map(function($,A){return ep(zh({},new Wr(E.scores[A],new Uh($.left/f,$.top/d,$.width/f,$.height/d),{height:d,width:f})),new x5(E.points[A].map(function(P){return P.sub(new ot($.left,$.top)).div(new ot($.width,$.height))}),{width:$.width,height:$.height}))}),[2,c({results:S,stats:i})]}})})},t.prototype.forward=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return o=this.forwardInput,[4,Yt(e)];case 1:return[4,o.apply(this,[a.sent(),r])];case 2:return[2,a.sent().results]}})})},t.prototype.forwardWithStats=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return o=this.forwardInput,[4,Yt(e)];case 1:return[2,o.apply(this,[a.sent(),r])]}})})},t.prototype.getDefaultModelName=function(){return"mtcnn_model"},t.prototype.extractParamsFromWeigthMap=function(e){return M9(e)},t.prototype.extractParams=function(e){return O9(e)},t}(uo),G9=.4,q9=[new ot(1.603231,2.094468),new ot(6.041143,7.080126),new ot(2.882459,3.518061),new ot(4.266906,5.178857),new ot(9.041765,10.66308)],K9=[117.001,114.697,97.404],Y9=function(n){De(t,n);function t(){var e=this,r={withSeparableConvs:!0,iouThreshold:G9,classes:["face"],anchors:q9,meanRgb:K9,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]};return e=n.call(this,r)||this,e}return Object.defineProperty(t.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),t.prototype.locateFaces=function(e,r){return $e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return[4,this.detect(e,r)];case 1:return o=a.sent(),[2,o.map(function(i){return new Wr(i.score,i.relativeBox,{width:i.imageWidth,height:i.imageHeight})})]}})})},t.prototype.getDefaultModelName=function(){return"tiny_face_detector_model"},t.prototype.extractParamsFromWeigthMap=function(e){return n.prototype.extractParamsFromWeigthMap.call(this,e)},t}(C2),mn={ssdMobilenetv1:new x2,tinyFaceDetector:new Y9,tinyYolov2:new P9,mtcnn:new H9,faceLandmark68Net:new h2,faceLandmark68TinyNet:new X5,faceRecognitionNet:new r9,faceExpressionNet:new F5,ageGenderNet:new G5},S2=function(n){De(t,n);function t(e,r,o){var a=n.call(this)||this;return a.parentTask=e,a.input=r,a.extractedFaces=o,a}return t}(au),cp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o=this;return ke(this,function(a){switch(a.label){case 0:return[4,this.parentTask];case 1:return e=a.sent(),[4,El(e,this.input,function(i){return $e(o,void 0,void 0,function(){return ke(this,function(s){switch(s.label){case 0:return[4,Promise.all(i.map(function(u){return mn.faceExpressionNet.predictExpressions(u)}))];case 1:return[2,s.sent()]}})})},this.extractedFaces)];case 2:return r=a.sent(),[2,e.map(function(i,s){return l2(i,r[s])})]}})})},t.prototype.withAgeAndGender=function(){return new hp(this,this.input)},t}(S2),lp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return[4,this.parentTask];case 1:return e=o.sent(),e?[4,ap(e,this.input,function(a){return mn.faceExpressionNet.predictExpressions(a)},this.extractedFaces)]:[2];case 2:return r=o.sent(),[2,l2(e,r)]}})})},t.prototype.withAgeAndGender=function(){return new pp(this,this.input)},t}(S2),dp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.withAgeAndGender=function(){return new vp(this,this.input)},t.prototype.withFaceDescriptors=function(){return new gp(this,this.input)},t}(cp),fp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.withAgeAndGender=function(){return new mp(this,this.input)},t.prototype.withFaceDescriptor=function(){return new yp(this,this.input)},t}(lp),N2=function(n){De(t,n);function t(e,r,o){var a=n.call(this)||this;return a.parentTask=e,a.input=r,a.extractedFaces=o,a}return t}(au),hp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o=this;return ke(this,function(a){switch(a.label){case 0:return[4,this.parentTask];case 1:return e=a.sent(),[4,El(e,this.input,function(i){return $e(o,void 0,void 0,function(){return ke(this,function(s){switch(s.label){case 0:return[4,Promise.all(i.map(function(u){return mn.ageGenderNet.predictAgeAndGender(u)}))];case 1:return[2,s.sent()]}})})},this.extractedFaces)];case 2:return r=a.sent(),[2,e.map(function(i,s){var u=r[s],c=u.age,l=u.gender,d=u.genderProbability;return g2(y2(i,l,d),c)})]}})})},t.prototype.withFaceExpressions=function(){return new cp(this,this.input)},t}(N2),pp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o,a,i;return ke(this,function(s){switch(s.label){case 0:return[4,this.parentTask];case 1:return e=s.sent(),e?[4,ap(e,this.input,function(u){return mn.ageGenderNet.predictAgeAndGender(u)},this.extractedFaces)]:[2];case 2:return r=s.sent(),o=r.age,a=r.gender,i=r.genderProbability,[2,g2(y2(e,a,i),o)]}})})},t.prototype.withFaceExpressions=function(){return new lp(this,this.input)},t}(N2),vp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.withFaceExpressions=function(){return new dp(this,this.input)},t.prototype.withFaceDescriptors=function(){return new gp(this,this.input)},t}(hp),mp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.withFaceExpressions=function(){return new fp(this,this.input)},t.prototype.withFaceDescriptor=function(){return new yp(this,this.input)},t}(pp),$2=function(n){De(t,n);function t(e,r){var o=n.call(this)||this;return o.parentTask=e,o.input=r,o}return t}(au),gp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return[4,this.parentTask];case 1:return e=o.sent(),[4,El(e,this.input,function(a){return Promise.all(a.map(function(i){return mn.faceRecognitionNet.computeFaceDescriptor(i)}))},null,function(a){return a.landmarks.align(null,{useDlibAlignment:!0})})];case 2:return r=o.sent(),[2,r.map(function(a,i){return m2(e[i],a)})]}})})},t.prototype.withFaceExpressions=function(){return new dp(this,this.input)},t.prototype.withAgeAndGender=function(){return new vp(this,this.input)},t}($2),yp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return[4,this.parentTask];case 1:return e=o.sent(),e?[4,ap(e,this.input,function(a){return mn.faceRecognitionNet.computeFaceDescriptor(a)},null,function(a){return a.landmarks.align(null,{useDlibAlignment:!0})})]:[2];case 2:return r=o.sent(),[2,m2(e,r)]}})})},t.prototype.withFaceExpressions=function(){return new fp(this,this.input)},t.prototype.withAgeAndGender=function(){return new mp(this,this.input)},t}($2),k2=function(n){De(t,n);function t(e,r,o){var a=n.call(this)||this;return a.parentTask=e,a.input=r,a.useTinyLandmarkNet=o,a}return Object.defineProperty(t.prototype,"landmarkNet",{get:function(){return this.useTinyLandmarkNet?mn.faceLandmark68TinyNet:mn.faceLandmark68Net},enumerable:!0,configurable:!0}),t}(au),X9=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o,a,i,s=this;return ke(this,function(u){switch(u.label){case 0:return[4,this.parentTask];case 1:return e=u.sent(),r=e.map(function(c){return c.detection}),this.input instanceof bt?[4,Yh(this.input,r)]:[3,3];case 2:return a=u.sent(),[3,5];case 3:return[4,Kh(this.input,r)];case 4:a=u.sent(),u.label=5;case 5:return o=a,[4,Promise.all(o.map(function(c){return s.landmarkNet.detectLandmarks(c)}))];case 6:return i=u.sent(),o.forEach(function(c){return c instanceof bt&&c.dispose()}),[2,e.map(function(c,l){return ep(c,i[l])})]}})})},t.prototype.withFaceExpressions=function(){return new dp(this,this.input)},t.prototype.withAgeAndGender=function(){return new vp(this,this.input)},t.prototype.withFaceDescriptors=function(){return new gp(this,this.input)},t}(k2),Z9=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o,a,i;return ke(this,function(s){switch(s.label){case 0:return[4,this.parentTask];case 1:return e=s.sent(),e?(r=e.detection,this.input instanceof bt?[4,Yh(this.input,[r])]:[3,3]):[2];case 2:return a=s.sent(),[3,5];case 3:return[4,Kh(this.input,[r])];case 4:a=s.sent(),s.label=5;case 5:return o=a,[4,this.landmarkNet.detectLandmarks(o[0])];case 6:return i=s.sent(),o.forEach(function(u){return u instanceof bt&&u.dispose()}),[2,ep(e,i)]}})})},t.prototype.withFaceExpressions=function(){return new fp(this,this.input)},t.prototype.withAgeAndGender=function(){return new mp(this,this.input)},t.prototype.withFaceDescriptor=function(){return new yp(this,this.input)},t}(k2),P2=function(n){De(t,n);function t(e,r){r===void 0&&(r=new ou);var o=n.call(this)||this;return o.input=e,o.options=r,o}return t}(au),I2=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o,a;return ke(this,function(i){switch(i.label){case 0:return e=this,r=e.input,o=e.options,o instanceof b2?[4,mn.mtcnn.forward(r,o)]:[3,2];case 1:return[2,i.sent().map(function(s){return s.detection})];case 2:if(a=o instanceof I9?function(s){return mn.tinyFaceDetector.locateFaces(s,o)}:o instanceof ou?function(s){return mn.ssdMobilenetv1.locateFaces(s,o)}:o instanceof op?function(s){return mn.tinyYolov2.locateFaces(s,o)}:null,!a)throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TinyYolov2Options");return[2,a(r)]}})})},t.prototype.runAndExtendWithFaceDetections=function(){var e=this;return new Promise(function(r){return $e(e,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return[4,this.run()];case 1:return o=a.sent(),[2,r(o.map(function(i){return zh({},i)}))]}})})})},t.prototype.withFaceLandmarks=function(e){return e===void 0&&(e=!1),new X9(this.runAndExtendWithFaceDetections(),this.input,e)},t.prototype.withFaceExpressions=function(){return new cp(this.runAndExtendWithFaceDetections(),this.input)},t.prototype.withAgeAndGender=function(){return new hp(this.runAndExtendWithFaceDetections(),this.input)},t}(P2);(function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return[4,new I2(this.input,this.options)];case 1:return e=o.sent(),r=e[0],e.forEach(function(a){a.score>r.score&&(r=a)}),[2,r]}})})},t.prototype.runAndExtendWithFaceDetection=function(){var e=this;return new Promise(function(r){return $e(e,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return[4,this.run()];case 1:return o=a.sent(),[2,r(o?zh({},o):void 0)]}})})})},t.prototype.withFaceLandmarks=function(e){return e===void 0&&(e=!1),new Z9(this.runAndExtendWithFaceDetection(),this.input,e)},t.prototype.withFaceExpressions=function(){return new lp(this.runAndExtendWithFaceDetection(),this.input)},t.prototype.withAgeAndGender=function(){return new pp(this.runAndExtendWithFaceDetection(),this.input)},t})(P2);function Q9(n,t){return t===void 0&&(t=new ou),new I2(n,t)}function J9(n,t){if(n.length!==t.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");var e=Array.from(n),r=Array.from(t);return Math.sqrt(e.map(function(o,a){return o-r[a]}).reduce(function(o,a){return o+Math.pow(a,2)},0))}(function(){function n(t,e){e===void 0&&(e=.6),this._distanceThreshold=e;var r=Array.isArray(t)?t:[t];if(!r.length)throw new Error("FaceRecognizer.constructor - expected atleast one input");var o=1,a=function(){return"person "+o++};this._labeledDescriptors=r.map(function(i){if(i instanceof ml)return i;if(i instanceof Float32Array)return new ml(a(),[i]);if(i.descriptor&&i.descriptor instanceof Float32Array)return new ml(a(),[i.descriptor]);throw new Error("FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>")})}return Object.defineProperty(n.prototype,"labeledDescriptors",{get:function(){return this._labeledDescriptors},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"distanceThreshold",{get:function(){return this._distanceThreshold},enumerable:!0,configurable:!0}),n.prototype.computeMeanDistance=function(t,e){return e.map(function(r){return J9(r,t)}).reduce(function(r,o){return r+o},0)/(e.length||1)},n.prototype.matchDescriptor=function(t){var e=this;return this.labeledDescriptors.map(function(r){var o=r.descriptors,a=r.label;return new Ub(a,e.computeMeanDistance(t,o))}).reduce(function(r,o){return r.distance<o.distance?r:o})},n.prototype.findBestMatch=function(t){var e=this.matchDescriptor(t);return e.distance<this.distanceThreshold?e:new Ub("unknown",e.distance)},n.prototype.toJSON=function(){return{distanceThreshold:this.distanceThreshold,labeledDescriptors:this.labeledDescriptors.map(function(t){return t.toJSON()})}},n.fromJSON=function(t){var e=t.labeledDescriptors.map(function(r){return ml.fromJSON(r)});return new n(e,t.distanceThreshold)},n})();function fo(n){return Array.isArray?Array.isArray(n):O2(n)==="[object Array]"}function eD(n){if(typeof n=="string")return n;let t=n+"";return t=="0"&&1/n==-1/0?"-0":t}function tD(n){return n==null?"":eD(n)}function zr(n){return typeof n=="string"}function A2(n){return typeof n=="number"}function nD(n){return n===!0||n===!1||rD(n)&&O2(n)=="[object Boolean]"}function T2(n){return typeof n=="object"}function rD(n){return T2(n)&&n!==null}function jn(n){return n!=null}function bp(n){return!n.trim().length}function O2(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}const oD="Incorrect 'index' type",aD=n=>`Invalid value for key ${n}`,iD=n=>`Pattern length exceeds max of ${n}.`,sD=n=>`Missing ${n} property in key`,uD=n=>`Property 'weight' in key '${n}' must be a positive integer`,D2=Object.prototype.hasOwnProperty;class cD{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(r=>{let o=M2(r);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(r=>{r.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function M2(n){let t=null,e=null,r=null,o=1,a=null;if(zr(n)||fo(n))r=n,t=F2(n),e=xp(n);else{if(!D2.call(n,"name"))throw new Error(sD("name"));const i=n.name;if(r=i,D2.call(n,"weight")&&(o=n.weight,o<=0))throw new Error(uD(i));t=F2(i),e=xp(i),a=n.getFn}return{path:t,id:e,weight:o,src:r,getFn:a}}function F2(n){return fo(n)?n:n.split(".")}function xp(n){return fo(n)?n.join("."):n}function lD(n,t){let e=[],r=!1;const o=(a,i,s)=>{if(jn(a))if(!i[s])e.push(a);else{let u=i[s];const c=a[u];if(!jn(c))return;if(s===i.length-1&&(zr(c)||A2(c)||nD(c)))e.push(tD(c));else if(fo(c)){r=!0;for(let l=0,d=c.length;l<d;l+=1)o(c[l],i,s+1)}else i.length&&o(c,i,s+1)}};return o(n,zr(t)?t.split("."):t,0),r?e:e[0]}var Ae={...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(n,t)=>n.score===t.score?n.idx<t.idx?-1:1:n.score<t.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,getFn:lD,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const dD=/[^ ]+/g;function fD(n=1,t=3){const e=new Map,r=Math.pow(10,t);return{get(o){const a=o.match(dD).length;if(e.has(a))return e.get(a);const i=1/Math.pow(a,.5*n),s=parseFloat(Math.round(i*r)/r);return e.set(a,s),s},clear(){e.clear()}}}class wp{constructor({getFn:t=Ae.getFn,fieldNormWeight:e=Ae.fieldNormWeight}={}){this.norm=fD(e,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,r)=>{this._keysMap[e.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,zr(this.docs[0])?this.docs.forEach((t,e)=>{this._addString(t,e)}):this.docs.forEach((t,e)=>{this._addObject(t,e)}),this.norm.clear())}add(t){const e=this.size();zr(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,r=this.size();e<r;e+=1)this.records[e].i-=1}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!jn(t)||bp(t))return;let r={v:t,i:e,n:this.norm.get(t)};this.records.push(r)}_addObject(t,e){let r={i:e,$:{}};this.keys.forEach((o,a)=>{let i=o.getFn?o.getFn(t):this.getFn(t,o.path);if(jn(i)){if(fo(i)){let s=[];const u=[{nestedArrIndex:-1,value:i}];for(;u.length;){const{nestedArrIndex:c,value:l}=u.pop();if(jn(l))if(zr(l)&&!bp(l)){let d={v:l,i:c,n:this.norm.get(l)};s.push(d)}else fo(l)&&l.forEach((d,f)=>{u.push({nestedArrIndex:f,value:d})})}r.$[a]=s}else if(zr(i)&&!bp(i)){let s={v:i,n:this.norm.get(i)};r.$[a]=s}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function R2(n,t,{getFn:e=Ae.getFn,fieldNormWeight:r=Ae.fieldNormWeight}={}){const o=new wp({getFn:e,fieldNormWeight:r});return o.setKeys(n.map(M2)),o.setSources(t),o.create(),o}function hD(n,{getFn:t=Ae.getFn,fieldNormWeight:e=Ae.fieldNormWeight}={}){const{keys:r,records:o}=n,a=new wp({getFn:t,fieldNormWeight:e});return a.setKeys(r),a.setIndexRecords(o),a}function $l(n,{errors:t=0,currentLocation:e=0,expectedLocation:r=0,distance:o=Ae.distance,ignoreLocation:a=Ae.ignoreLocation}={}){const i=t/n.length;if(a)return i;const s=Math.abs(r-e);return o?i+s/o:s?1:i}function pD(n=[],t=Ae.minMatchCharLength){let e=[],r=-1,o=-1,a=0;for(let i=n.length;a<i;a+=1){let s=n[a];s&&r===-1?r=a:!s&&r!==-1&&(o=a-1,o-r+1>=t&&e.push([r,o]),r=-1)}return n[a-1]&&a-r>=t&&e.push([r,a-1]),e}const Wa=32;function vD(n,t,e,{location:r=Ae.location,distance:o=Ae.distance,threshold:a=Ae.threshold,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:s=Ae.minMatchCharLength,includeMatches:u=Ae.includeMatches,ignoreLocation:c=Ae.ignoreLocation}={}){if(t.length>Wa)throw new Error(iD(Wa));const l=t.length,d=n.length,f=Math.max(0,Math.min(r,d));let h=a,m=f;const p=s>1||u,v=p?Array(d):[];let g;for(;(g=n.indexOf(t,m))>-1;){let E=$l(t,{currentLocation:g,expectedLocation:f,distance:o,ignoreLocation:c});if(h=Math.min(E,h),m=g+l,p){let S=0;for(;S<l;)v[g+S]=1,S+=1}}m=-1;let y=[],w=1,x=l+d;const C=1<<l-1;for(let E=0;E<l;E+=1){let S=0,N=x;for(;S<N;)$l(t,{errors:E,currentLocation:f+N,expectedLocation:f,distance:o,ignoreLocation:c})<=h?S=N:x=N,N=Math.floor((x-S)/2+S);x=N;let $=Math.max(1,f-N+1),A=i?d:Math.min(f+N,d)+l,P=Array(A+2);P[A+1]=(1<<E)-1;for(let B=A;B>=$;B-=1){let z=B-1,H=e[n.charAt(z)];if(p&&(v[z]=+!!H),P[B]=(P[B+1]<<1|1)&H,E&&(P[B]|=(y[B+1]|y[B])<<1|1|y[B+1]),P[B]&C&&(w=$l(t,{errors:E,currentLocation:z,expectedLocation:f,distance:o,ignoreLocation:c}),w<=h)){if(h=w,m=z,m<=f)break;$=Math.max(1,2*f-m)}}if($l(t,{errors:E+1,currentLocation:f,expectedLocation:f,distance:o,ignoreLocation:c})>h)break;y=P}const _={isMatch:m>=0,score:Math.max(.001,w)};if(p){const E=pD(v,s);E.length?u&&(_.indices=E):_.isMatch=!1}return _}function mD(n){let t={};for(let e=0,r=n.length;e<r;e+=1){const o=n.charAt(e);t[o]=(t[o]||0)|1<<r-e-1}return t}const kl=String.prototype.normalize?n=>n.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,""):n=>n;class L2{constructor(t,{location:e=Ae.location,threshold:r=Ae.threshold,distance:o=Ae.distance,includeMatches:a=Ae.includeMatches,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:s=Ae.minMatchCharLength,isCaseSensitive:u=Ae.isCaseSensitive,ignoreDiacritics:c=Ae.ignoreDiacritics,ignoreLocation:l=Ae.ignoreLocation}={}){if(this.options={location:e,threshold:r,distance:o,includeMatches:a,findAllMatches:i,minMatchCharLength:s,isCaseSensitive:u,ignoreDiacritics:c,ignoreLocation:l},t=u?t:t.toLowerCase(),t=c?kl(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const d=(h,m)=>{this.chunks.push({pattern:h,alphabet:mD(h),startIndex:m})},f=this.pattern.length;if(f>Wa){let h=0;const m=f%Wa,p=f-m;for(;h<p;)d(this.pattern.substr(h,Wa),h),h+=Wa;if(m){const v=f-Wa;d(this.pattern.substr(v),v)}}else d(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:r,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=r?kl(t):t,this.pattern===t){let p={isMatch:!0,score:0};return o&&(p.indices=[[0,t.length-1]]),p}const{location:a,distance:i,threshold:s,findAllMatches:u,minMatchCharLength:c,ignoreLocation:l}=this.options;let d=[],f=0,h=!1;this.chunks.forEach(({pattern:p,alphabet:v,startIndex:g})=>{const{isMatch:y,score:w,indices:x}=vD(t,p,v,{location:a+g,distance:i,threshold:s,findAllMatches:u,minMatchCharLength:c,includeMatches:o,ignoreLocation:l});y&&(h=!0),f+=w,y&&x&&(d=[...d,...x])});let m={isMatch:h,score:h?f/this.chunks.length:1};return h&&o&&(m.indices=d),m}}class qo{constructor(t){this.pattern=t}static isMultiMatch(t){return B2(t,this.multiRegex)}static isSingleMatch(t){return B2(t,this.singleRegex)}search(){}}function B2(n,t){const e=n.match(t);return e?e[1]:null}class gD extends qo{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class yD extends qo{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const r=t.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,t.length-1]}}}class bD extends qo{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class xD extends qo{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class wD extends qo{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class CD extends qo{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class W2 extends qo{constructor(t,{location:e=Ae.location,threshold:r=Ae.threshold,distance:o=Ae.distance,includeMatches:a=Ae.includeMatches,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:s=Ae.minMatchCharLength,isCaseSensitive:u=Ae.isCaseSensitive,ignoreDiacritics:c=Ae.ignoreDiacritics,ignoreLocation:l=Ae.ignoreLocation}={}){super(t),this._bitapSearch=new L2(t,{location:e,threshold:r,distance:o,includeMatches:a,findAllMatches:i,minMatchCharLength:s,isCaseSensitive:u,ignoreDiacritics:c,ignoreLocation:l})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class V2 extends qo{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,r;const o=[],a=this.pattern.length;for(;(r=t.indexOf(this.pattern,e))>-1;)e=r+a,o.push([r,e-1]);const i=!!o.length;return{isMatch:i,score:i?0:1,indices:o}}}const Cp=[gD,V2,bD,xD,CD,wD,yD,W2],j2=Cp.length,_D=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,ED="|";function SD(n,t={}){return n.split(ED).map(e=>{let r=e.trim().split(_D).filter(a=>a&&!!a.trim()),o=[];for(let a=0,i=r.length;a<i;a+=1){const s=r[a];let u=!1,c=-1;for(;!u&&++c<j2;){const l=Cp[c];let d=l.isMultiMatch(s);d&&(o.push(new l(d,t)),u=!0)}if(!u)for(c=-1;++c<j2;){const l=Cp[c];let d=l.isSingleMatch(s);if(d){o.push(new l(d,t));break}}}return o})}const ND=new Set([W2.type,V2.type]);class $D{constructor(t,{isCaseSensitive:e=Ae.isCaseSensitive,ignoreDiacritics:r=Ae.ignoreDiacritics,includeMatches:o=Ae.includeMatches,minMatchCharLength:a=Ae.minMatchCharLength,ignoreLocation:i=Ae.ignoreLocation,findAllMatches:s=Ae.findAllMatches,location:u=Ae.location,threshold:c=Ae.threshold,distance:l=Ae.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:r,includeMatches:o,minMatchCharLength:a,findAllMatches:s,ignoreLocation:i,location:u,threshold:c,distance:l},t=e?t:t.toLowerCase(),t=r?kl(t):t,this.pattern=t,this.query=SD(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:o,ignoreDiacritics:a}=this.options;t=o?t:t.toLowerCase(),t=a?kl(t):t;let i=0,s=[],u=0;for(let c=0,l=e.length;c<l;c+=1){const d=e[c];s.length=0,i=0;for(let f=0,h=d.length;f<h;f+=1){const m=d[f],{isMatch:p,indices:v,score:g}=m.search(t);if(p){if(i+=1,u+=g,r){const y=m.constructor.type;ND.has(y)?s=[...s,...v]:s.push(v)}}else{u=0,i=0,s.length=0;break}}if(i){let f={isMatch:!0,score:u/i};return r&&(f.indices=s),f}}return{isMatch:!1,score:1}}}const _p=[];function kD(...n){_p.push(...n)}function Ep(n,t){for(let e=0,r=_p.length;e<r;e+=1){let o=_p[e];if(o.condition(n,t))return new o(n,t)}return new L2(n,t)}const Pl={AND:"$and",OR:"$or"},Sp={PATH:"$path",PATTERN:"$val"},Np=n=>!!(n[Pl.AND]||n[Pl.OR]),PD=n=>!!n[Sp.PATH],ID=n=>!fo(n)&&T2(n)&&!Np(n),U2=n=>({[Pl.AND]:Object.keys(n).map(t=>({[t]:n[t]}))});function z2(n,t,{auto:e=!0}={}){const r=o=>{let a=Object.keys(o);const i=PD(o);if(!i&&a.length>1&&!Np(o))return r(U2(o));if(ID(o)){const u=i?o[Sp.PATH]:a[0],c=i?o[Sp.PATTERN]:o[u];if(!zr(c))throw new Error(aD(u));const l={keyId:xp(u),pattern:c};return e&&(l.searcher=Ep(c,t)),l}let s={children:[],operator:a[0]};return a.forEach(u=>{const c=o[u];fo(c)&&c.forEach(l=>{s.children.push(r(l))})}),s};return Np(n)||(n=U2(n)),r(n)}function AD(n,{ignoreFieldNorm:t=Ae.ignoreFieldNorm}){n.forEach(e=>{let r=1;e.matches.forEach(({key:o,norm:a,score:i})=>{const s=o?o.weight:null;r*=Math.pow(i===0&&s?Number.EPSILON:i,(s||1)*(t?1:a))}),e.score=r})}function TD(n,t){const e=n.matches;t.matches=[],jn(e)&&e.forEach(r=>{if(!jn(r.indices)||!r.indices.length)return;const{indices:o,value:a}=r;let i={indices:o,value:a};r.key&&(i.key=r.key.src),r.idx>-1&&(i.refIndex=r.idx),t.matches.push(i)})}function OD(n,t){t.score=n.score}function DD(n,t,{includeMatches:e=Ae.includeMatches,includeScore:r=Ae.includeScore}={}){const o=[];return e&&o.push(TD),r&&o.push(OD),n.map(a=>{const{idx:i}=a,s={item:t[i],refIndex:i};return o.length&&o.forEach(u=>{u(a,s)}),s})}class Bi{constructor(t,e={},r){this.options={...Ae,...e},this.options.useExtendedSearch,this._keyStore=new cD(this.options.keys),this.setCollection(t,r)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof wp))throw new Error(oD);this._myIndex=e||R2(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){jn(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let r=0,o=this._docs.length;r<o;r+=1){const a=this._docs[r];t(a,r)&&(this.removeAt(r),r-=1,o-=1,e.push(a))}return e}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:e=-1}={}){const{includeMatches:r,includeScore:o,shouldSort:a,sortFn:i,ignoreFieldNorm:s}=this.options;let u=zr(t)?zr(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return AD(u,{ignoreFieldNorm:s}),a&&u.sort(i),A2(e)&&e>-1&&(u=u.slice(0,e)),DD(u,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(t){const e=Ep(t,this.options),{records:r}=this._myIndex,o=[];return r.forEach(({v:a,i,n:s})=>{if(!jn(a))return;const{isMatch:u,score:c,indices:l}=e.searchIn(a);u&&o.push({item:a,idx:i,matches:[{score:c,value:a,norm:s,indices:l}]})}),o}_searchLogical(t){const e=z2(t,this.options),r=(s,u,c)=>{if(!s.children){const{keyId:d,searcher:f}=s,h=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(u,d),searcher:f});return h&&h.length?[{idx:c,item:u,matches:h}]:[]}const l=[];for(let d=0,f=s.children.length;d<f;d+=1){const h=s.children[d],m=r(h,u,c);if(m.length)l.push(...m);else if(s.operator===Pl.AND)return[]}return l},o=this._myIndex.records,a={},i=[];return o.forEach(({$:s,i:u})=>{if(jn(s)){let c=r(e,s,u);c.length&&(a[u]||(a[u]={idx:u,item:s,matches:[]},i.push(a[u])),c.forEach(({matches:l})=>{a[u].matches.push(...l)}))}}),i}_searchObjectList(t){const e=Ep(t,this.options),{keys:r,records:o}=this._myIndex,a=[];return o.forEach(({$:i,i:s})=>{if(!jn(i))return;let u=[];r.forEach((c,l)=>{u.push(...this._findMatches({key:c,value:i[l],searcher:e}))}),u.length&&a.push({idx:s,item:i,matches:u})}),a}_findMatches({key:t,value:e,searcher:r}){if(!jn(e))return[];let o=[];if(fo(e))e.forEach(({v:a,i,n:s})=>{if(!jn(a))return;const{isMatch:u,score:c,indices:l}=r.searchIn(a);u&&o.push({score:c,key:t,value:a,idx:i,norm:s,indices:l})});else{const{v:a,n:i}=e,{isMatch:s,score:u,indices:c}=r.searchIn(a);s&&o.push({score:u,key:t,value:a,norm:i,indices:c})}return o}}Bi.version="7.1.0",Bi.createIndex=R2,Bi.parseIndex=hD,Bi.config=Ae,Bi.parseQuery=z2,kD($D);const MD=D.createContext(void 0);let $p;const FD=({apiEndpoint:n,children:t})=>(D.useEffect(()=>{$p=n},[n]),b.jsx(MD.Provider,{value:{apiEndpoint:n},children:t})),RD=()=>{if(!$p)throw new Error("ApiEndpoint not initialized. Make sure ApiProvider is mounted.");return $p};typeof window>"u"&&(async()=>{const{Canvas:n,Image:t,ImageData:e,loadImage:r}=await Promise.resolve().then(()=>dz);global.Image=t,global.HTMLImageElement=t,global.ImageData=e,global.HTMLCanvasElement=n,global.CanvasRenderingContext2D=n,global.loadImage=r,rn.monkeyPatch({Canvas:n,Image:t,ImageData:e,createCanvasElement:()=>new n(1,1),createImageElement:()=>new t})})();class LD{constructor(){km(this,"signalMap");km(this,"modelsLoaded",!1);this.signalMap={id:["date of birth","birth date","place of birth","id","identification","identity card","permit","valid until","expiration date","given name","surname","sex","gender","height","weight","address","issuing authority","issued by","card number","personal number","nationality"],passport:["passport","passport number","country code","issuing country","issuing state","place of issue","place of birth","date of issue","date of expiry","expiry date","valid until","authority","surname","given name","name","sex","nationality","type","holder","mrz","document","travel","abroad","citizen"],license:["license","driver","driver license","dl number","licence number","permit","valid until","date of birth","birth date","issue date","expiration date","holder's signature","authority","class","restrictions","endorsements","sex","eyes","hair","height","weight","organ donor","address"],voterId:["voter","voting","voter id","voter card","elector","elector's name","father's name","electoral roll","polling station","constituency","elector id","serial number","sex","age","dob","date of birth","part number","section","epic","identity card","address"],default:["name","id","date","dob","expiry","number","document","issued"]}}async toBase64(t){if(typeof window>"u")return(await(await Promise.resolve().then(()=>fz)).readFile(t)).toString("base64");if(t instanceof File)return new Promise((e,r)=>{const o=new FileReader;o.onload=()=>{const i=o.result.split(",")[1];e(i)},o.onerror=r,o.readAsDataURL(t)});throw new Error("Unsupported input type for base64 conversion")}async validateIdCard(t,e){let r=t;if(typeof t!="string"){const s=await this.toBase64(t);r=`data:${t.type||"image/jpeg"};base64,${s}`}const{data:{text:o}}=await Ak.recognize(r,"eng"),a=this.signalMap[e]||this.signalMap.default;console.log("OCR Result:",{text:o});let i=a.some(s=>{const u=o.toLowerCase().includes(s);return u&&console.log(`Found ${e} match:`,s),u});if(!i){const u=new Bi(a,{includeScore:!0,threshold:.6}).search(o.toLowerCase());i=u.length>0,i&&console.log("Found fuzzy match:",u[0].item,u[0].score,{found:u})}return{type:e,passed:i,textSnippet:o.slice(0,200),fullText:o}}async loadModels(){if(this.modelsLoaded)return;const e=`${RD()}/api/models`;await Promise.all([mn.ssdMobilenetv1.loadFromUri(e),mn.faceLandmark68Net.loadFromUri(e),mn.faceRecognitionNet.loadFromUri(e)]),this.modelsLoaded=!0}async validateFace(t){await this.loadModels();let e=t;if(typeof t!="string"){const i=await this.toBase64(t);e=`data:${t.type||"image/jpeg"};base64,${i}`}const r=await this.fileToImage(e),o=await Q9(r,new ou);return{type:"face",passed:o.length===1,facesDetected:o.length}}async fileToImage(t){return new Promise((e,r)=>{const o=new Image;if(o.onload=()=>e(o),o.onerror=r,typeof t=="string")o.src=t;else{const a=new FileReader;a.onload=()=>{o.src=a.result},a.onerror=r,a.readAsDataURL(t)}})}}const H2=new LD,BD=(n,t,e,r,o,a,i)=>{const[s,u]=D.useState(null),[c,l]=D.useState(null),[d,f]=D.useState({x:0,y:0,w:320,h:192}),h=D.useRef(`frameMask-${Math.random().toString(36).slice(2)}`),{toast:m}=Qu(),p=D.useMemo(()=>c?URL.createObjectURL(c):null,[c]),v=vi.find(x=>x.id===i);D.useEffect(()=>{e.current&&s&&(e.current.srcObject=s)},[s]),D.useEffect(()=>()=>{p&&URL.revokeObjectURL(p)},[p]);const g=D.useCallback(async()=>{try{const x=await navigator.mediaDevices.getUserMedia({video:{facingMode:n==="selfie"?"user":"environment",width:{ideal:9999},height:{ideal:9999}}});u(x)}catch{try{const x=await navigator.mediaDevices.getUserMedia({video:{facingMode:n==="selfie"?"user":"environment",width:{ideal:1280},height:{ideal:720}}});u(x)}catch{m({title:"Camera Error",description:"Unable to access camera. Please check permissions.",variant:"destructive"})}}},[n,m]),y=D.useCallback(()=>{s&&(s.getTracks().forEach(x=>x.stop()),u(null))},[s]),w=D.useCallback(async()=>{if(!e.current||!r.current||!o.current)return;const x=e.current,C=r.current,_=C.getContext("2d");if(!_)return;const E=x.videoWidth,S=x.videoHeight;if(n==="selfie"){C.width=E,C.height=S,_.drawImage(x,0,0,E,S),C.toBlob(async L=>{if(!L)return;const K=new File([L],`${n}-${Date.now()}.jpg`,{type:"image/jpeg"});try{const q=document.createElement("canvas"),Z=q.getContext("2d");if(!Z)return;const oe=x.getBoundingClientRect(),ae=E/oe.width,X=S/oe.height,re=10,ce=(d.x-re)*ae,ue=(d.y-re)*X,se=(d.w+2*re)*ae,ee=(d.h+2*re)*X;q.width=se,q.height=ee,Z.drawImage(x,ce,ue,se,ee,0,0,se,ee);const _e=await new Promise(Ze=>q.toBlob(Ze,"image/jpeg",.8));if(!_e)return;const Me=new File([_e],`crop-${Date.now()}.jpg`,{type:"image/jpeg"});if(m({title:"Validating...",description:"Checking if the photo has a face..."}),!(await H2.validateFace(Me)).passed){m({title:"Validation Failed",description:"No face detected. Please retake your selfie.",variant:"destructive"});return}m({title:"Photo Captured",description:"Selfie captured successfully"}),l(K),y()}catch(q){console.error("Face validation error:",q),m({title:"Validation Error",description:"We couldn’t process the selfie. Please try again.",variant:"destructive"})}},"image/jpeg",.8);return}const N=x.getBoundingClientRect(),$=E/N.width,A=S/N.height,P=10,j=(d.x-P)*$,B=(d.y-P)*A,z=(d.w+2*P)*$,H=(d.h+2*P)*A,F=Math.max(0,Math.min(j,E-z)),M=Math.max(0,Math.min(B,S-H)),O=Math.min(z,E-F),I=Math.min(H,S-M);if(C.width=t==="circular"?Math.max(O,I):O,C.height=t==="circular"?Math.max(O,I):I,t==="circular"){const L=Math.min(O,I)/2;_.beginPath(),_.arc(C.width/2,C.height/2,L+P*$,0,Math.PI*2),_.clip(),_.drawImage(x,F-(C.width-O)/2,M-(C.height-I)/2,C.width,C.height,0,0,C.width,C.height)}else _.drawImage(x,F,M,O,I,0,0,C.width,C.height);C.toBlob(async L=>{if(!L)return;const K=new File([L],`${n}-${Date.now()}.jpg`,{type:"image/jpeg"});try{if(m({title:"Validating...",description:`Checking if the photo looks like ${v.title} ...`}),!(await H2.validateIdCard(K,i)).passed){m({title:"Validation Failed",description:`This doesn’t look like ${v.title} card. Try again.`,variant:"destructive"});return}l(K),y(),m({title:"Photo Captured",description:`${v.title} validated successfully`})}catch(q){console.error(q),m({title:"OCR Error",description:"We couldn’t process the photo. Please try again.",variant:"destructive"})}},"image/jpeg",.8)},[n,y,m,t,d,e,r,o]);return D.useEffect(()=>(!c&&!s&&g(),()=>{y()}),[c,s,g,y]),D.useEffect(()=>{if(!o.current||!a.current)return;const x=()=>{const _=o.current.getBoundingClientRect(),E=a.current.getBoundingClientRect();f({x:Math.round(E.left-_.left),y:Math.round(E.top-_.top),w:Math.round(E.width),h:Math.round(E.height)})};x();const C=new ResizeObserver(x);return C.observe(a.current),C.observe(o.current),window.addEventListener("resize",x),window.addEventListener("scroll",x,!0),()=>{C.disconnect(),window.removeEventListener("resize",x),window.removeEventListener("scroll",x,!0)}},[t,s,o,a]),{stream:s,photo:c,setPhoto:l,hole:d,maskId:h.current,photoUrl:p,capturePhoto:w}},kp=768;function WD(){const[n,t]=k.useState(void 0);return k.useEffect(()=>{const e=window.matchMedia(`(max-width: ${kp-1}px)`),r=()=>{t(window.innerWidth<kp)};return e.addEventListener("change",r),t(window.innerWidth<kp),()=>e.removeEventListener("change",r)},[]),!!n}const VD={"id-front":"ID Front","id-back":"ID Back",selfie:"Selfie"},Wi=({currentStep:n,onRetake:t,onConfirm:e,onBack:r,title:o,description:a,frameType:i,documentTypeId:s})=>{const u=D.useRef(null),c=D.useRef(null),l=D.useRef(null),d=D.useRef(null),f=WD(),{stream:h,photo:m,setPhoto:p,hole:v,maskId:g,photoUrl:y,capturePhoto:w}=BD(n,i,u,c,l,d,s),x=!!h,C=()=>{p(null),r()},_=()=>{p(null),t()},E=()=>{m&&e(m),m&&e(m),p(null)},S=v.x+v.w/2,N=v.y+v.h/2,$=Math.max(v.w,v.h)/2,A=()=>{const P=VD[n]||"Photo";return b.jsx(hn,{className:"w-full max-w-md mx-auto",children:b.jsxs(pn,{className:"p-6",children:[b.jsx(Do,{title:`Review ${P}`,subTitle:"Make sure the information is seen clearly, with no blur or glare.",onBack:C}),b.jsx("div",{className:"mb-8",children:b.jsx("div",{className:"relative",children:y&&b.jsx("img",{src:y,alt:"Captured photo",className:`w-full h-64 object-cover ${n==="selfie"?"":i==="circular"?"rounded-full":"rounded-2xl"} bg-muted`})})}),b.jsxs("div",{className:"flex gap-4",children:[b.jsx(_t,{variant:"outline",onClick:_,className:"flex-1 text-md",children:"Take again"}),b.jsx(_t,{onClick:E,className:"flex-1 text-md",children:"Looks good"})]})]})})};return m?A():b.jsxs(hn,{className:"relative w-full max-w-md mx-auto bg-gray-900 border-gray-900 overflow-hidden",children:[x&&b.jsx("video",{ref:u,autoPlay:!0,playsInline:!0,muted:!0,loop:!0,className:`absolute inset-0 w-full h-full object-cover z-0 ${!f&&"scale-x-[-1]"}`}),b.jsx("div",{ref:l,className:"absolute inset-0 z-5 pointer-events-none","aria-hidden":!0,children:b.jsxs("svg",{className:"w-full h-full",children:[b.jsx("defs",{children:b.jsxs("mask",{id:g,children:[b.jsx("rect",{width:"100%",height:"100%",fill:"white"}),i==="circular"?b.jsx("circle",{cx:S,cy:N,r:$,fill:"black"}):b.jsx("rect",{x:v.x,y:v.y,width:v.w,height:v.h,fill:"black"})]})}),b.jsx("rect",{width:"100%",height:"100%",fill:"rgba(17,24,39,0.7)",mask:`url(#${g})`})]})}),b.jsx("canvas",{ref:c,className:"hidden"}),b.jsxs(pn,{className:"relative z-10 text-white flex flex-col h-full",children:[b.jsxs("div",{className:"flex items-center p-6",children:[b.jsx(_t,{variant:"ghost",size:"sm",onClick:C,className:"text-white hover:bg-gray-600",children:b.jsx(Cg,{className:"h-6 w-6"})}),b.jsx("h1",{className:"text-xl font-semibold ml-4",children:o})]}),b.jsx("div",{className:"px-6 mb-8",children:b.jsx("p",{className:"text-gray-300 text-center",children:a})}),b.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6",children:[b.jsx("div",{className:"relative mb-16",children:x?b.jsxs("div",{ref:d,className:`relative z-20 ${i==="circular"?"w-80 h-80 rounded-full":s==="passport"?"w-80 h-[350px]":"w-80 h-48"}`,children:[b.jsx("div",{className:`absolute inset-0 opacity-0 ${i==="circular"?"rounded-full":""} z-10`}),i==="circular"?null:b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"absolute w-6 h-6 border-t-4 border-l-4 border-white z-30",style:{top:"-4px",left:"-4px"}}),b.jsx("div",{className:"absolute w-6 h-6 border-t-4 border-r-4 border-white z-30",style:{top:"-4px",right:"-4px"}}),b.jsx("div",{className:"absolute w-6 h-6 border-b-4 border-l-4 border-white z-30",style:{bottom:"-4px",left:"-4px"}}),b.jsx("div",{className:"absolute w-6 h-6 border-b-4 border-r-4 border-white z-30",style:{bottom:"-4px",right:"-4px"}})]})]}):b.jsx("div",{className:`bg-gray-700 flex items-center justify-center ${i==="circular"?"w-80 h-80 rounded-full":s==="passport"?"w-80 h-[350px]":"w-80 h-48"}`,children:b.jsx("p",{className:"text-gray-400",children:"Camera loading..."})})}),b.jsx(_t,{onClick:w,size:"lg",className:"w-16 h-16 rounded-full bg-white hover:bg-gray-100 border-4 border-gray-600 p-0",disabled:!x,children:b.jsx("div",{className:"w-8 h-8 rounded-full bg-white"})})]})]})]})},jD=({apiEndpoint:n,apiKey:t,onComplete:e,onDoneClick:r})=>{const[o,a]=D.useState("landing"),[i,s]=D.useState(""),[u,c]=D.useState(""),[l,d]=D.useState(null),[f,h]=D.useState(null),[m,p]=D.useState(null),{data:v}=HD(n,t),g=X0({mutationFn:UD}),{toast:y}=Qu(),w=D.useMemo(()=>[...v!=null&&v.hide_name_step?[]:["name"],...v!=null&&v.hide_document_selection_step?[]:["document-selection"],"selfie","pre-selfie","id-front","id-back","verify"],[v]),x=()=>v.hide_name_step?v.hide_document_selection_step?"id-front":"document-selection":"name",C=async()=>{if((v.hide_name_step||!!i)&&l&&f&&m){const N={full_name:i,selfie_photo:l,id_photo:f,id_photo_back:m},$=await g.mutateAsync({apiEndpoint:n,apiKey:t,data:N});e($.data.token,N),y({title:"KYC Complete",description:"Identity verification completed successfully"}),s(""),d(null),h(null),p(null),a("done")}},_=()=>b.jsx(b.Fragment,{children:o!=="landing"&&b.jsx("div",{className:"flex justify-center",children:b.jsx("div",{className:"flex space-x-2",children:w.map((S,N)=>b.jsx("div",{className:`w-3 h-3 rounded-full ${w.indexOf(o)>=N?"bg-primary":"bg-muted"}`},S))})})}),E=()=>{switch(console.log("currentStep",o),o){case"landing":return b.jsx(Z0,{onContinue:()=>a(x())});case"name":return b.jsx(G$,{fullName:i,onNameChange:s,onContinue:()=>a(v.hide_document_selection_step?"id-front":"document-selection"),renderProgress:_});case"document-selection":return b.jsx(ey,{selectedDocumentType:u,onDocumentTypeChange:c,onContinue:()=>a("id-front"),onBack:()=>a(v.hide_name_step?"landing":"name"),renderProgress:_});case"id-front":return b.jsx(Wi,{title:"Upload ID",description:"Place your ID inside the frame and take a picture. Make sure it is not cut or has any glare.",frameType:"rectangular",documentTypeId:u,currentStep:o,onRetake:()=>{h(null)},onConfirm:S=>{h(S),a(u==="passport"?"pre-selfie":"id-back")},onBack:()=>{h(null),a(v.hide_document_selection_step?v.hide_name_step?"landing":"name":"document-selection")}});case"id-back":return b.jsx(Wi,{title:"Upload ID Back",description:"Place the back of your ID inside the frame and take a picture. Make sure it is not cut or has any glare.",frameType:"rectangular",documentTypeId:u,currentStep:o,onRetake:()=>{p(null)},onConfirm:S=>{p(S),a("pre-selfie")},onBack:()=>{p(null),a("id-front")}});case"pre-selfie":return b.jsx(ty,{onContinue:()=>a("selfie"),onBack:()=>a("id-back")});case"selfie":return b.jsx(Wi,{title:"Selfie",description:"Place your face inside the frame and take a picture. Make sure it is clearly visible.",frameType:"circular",documentTypeId:u,currentStep:o,onRetake:()=>{d(null)},onConfirm:S=>{d(S),a("verify")},onBack:()=>{d(null),a("id-back")}});case"verify":return b.jsx(q$,{fullName:i,onComplete:()=>a("processing"),onStartOver:()=>a("landing")});case"processing":return b.jsx(ny,{onComplete:C});case"done":return b.jsx(ry,{onDoneClick:r});default:return null}};return b.jsx("div",{className:"w-[430px]",children:E()})};async function UD({apiEndpoint:n,apiKey:t,data:e}){const r=new FormData;r.append("full_name",e.full_name),r.append("selfie_photo",e.selfie_photo,e.selfie_photo.name),r.append("id_photo",e.id_photo,e.id_photo.name),r.append("id_photo_back",e.id_photo_back,e.id_photo_back.name);const o=await fetch(`${n}/api/kyc`,{method:"POST",headers:{"X-API-Key":t},body:r});if(!o.ok)throw new Error("Network response was not ok");return o.json()}const zD=async(n,t)=>{const e=await fetch(`${n}/api/settings`,{method:"GET",headers:{"X-API-Key":t,"Content-Type":"application/json"}});if(!e.ok)throw new Error("Network response was not ok");return(await e.json()).data},HD=(n,t)=>V$({queryKey:["settings",n,t],queryFn:()=>zD(n,t),enabled:!!n&&!!t});var iu=n=>n.type==="checkbox",Va=n=>n instanceof Date,gn=n=>n==null;const G2=n=>typeof n=="object";var Dt=n=>!gn(n)&&!Array.isArray(n)&&G2(n)&&!Va(n),q2=n=>Dt(n)&&n.target?iu(n.target)?n.target.checked:n.target.value:n,GD=n=>n.substring(0,n.search(/\.\d+(\.|$)/))||n,K2=(n,t)=>n.has(GD(t)),qD=n=>{const t=n.constructor&&n.constructor.prototype;return Dt(t)&&t.hasOwnProperty("isPrototypeOf")},Pp=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Gt(n){let t;const e=Array.isArray(n),r=typeof FileList<"u"?n instanceof FileList:!1;if(n instanceof Date)t=new Date(n);else if(!(Pp&&(n instanceof Blob||r))&&(e||Dt(n)))if(t=e?[]:Object.create(Object.getPrototypeOf(n)),!e&&!qD(n))t=n;else for(const o in n)n.hasOwnProperty(o)&&(t[o]=Gt(n[o]));else return n;return t}var Il=n=>/^\w*$/.test(n),At=n=>n===void 0,Ip=n=>Array.isArray(n)?n.filter(Boolean):[],Ap=n=>Ip(n.replace(/["|']|\]/g,"").split(/\.|\[/)),me=(n,t,e)=>{if(!t||!Dt(n))return e;const r=(Il(t)?[t]:Ap(t)).reduce((o,a)=>gn(o)?o:o[a],n);return At(r)||r===n?At(n[t])?e:n[t]:r},Un=n=>typeof n=="boolean",ct=(n,t,e)=>{let r=-1;const o=Il(t)?[t]:Ap(t),a=o.length,i=a-1;for(;++r<a;){const s=o[r];let u=e;if(r!==i){const c=n[s];u=Dt(c)||Array.isArray(c)?c:isNaN(+o[r+1])?{}:[]}if(s==="__proto__"||s==="constructor"||s==="prototype")return;n[s]=u,n=n[s]}};const Al={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},lr={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ho={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Tp=D.createContext(null);Tp.displayName="HookFormContext";const Tl=()=>D.useContext(Tp),KD=n=>{const{children:t,...e}=n;return D.createElement(Tp.Provider,{value:e},t)};var Y2=(n,t,e,r=!0)=>{const o={defaultValues:t._defaultValues};for(const a in n)Object.defineProperty(o,a,{get:()=>{const i=a;return t._proxyFormState[i]!==lr.all&&(t._proxyFormState[i]=!r||lr.all),e&&(e[i]=!0),n[i]}});return o};const Op=typeof window<"u"?D.useLayoutEffect:D.useEffect;function YD(n){const t=Tl(),{control:e=t.control,disabled:r,name:o,exact:a}=n||{},[i,s]=D.useState(e._formState),u=D.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Op(()=>e._subscribe({name:o,formState:u.current,exact:a,callback:c=>{!r&&s({...e._formState,...c})}}),[o,r,a]),D.useEffect(()=>{u.current.isValid&&e._setValid(!0)},[e]),D.useMemo(()=>Y2(i,e,u.current,!1),[i,e])}var zn=n=>typeof n=="string",X2=(n,t,e,r,o)=>zn(n)?(r&&t.watch.add(n),me(e,n,o)):Array.isArray(n)?n.map(a=>(r&&t.watch.add(a),me(e,a))):(r&&(t.watchAll=!0),e),Dp=n=>gn(n)||!G2(n);function po(n,t,e=new WeakSet){if(Dp(n)||Dp(t))return n===t;if(Va(n)&&Va(t))return n.getTime()===t.getTime();const r=Object.keys(n),o=Object.keys(t);if(r.length!==o.length)return!1;if(e.has(n)||e.has(t))return!0;e.add(n),e.add(t);for(const a of r){const i=n[a];if(!o.includes(a))return!1;if(a!=="ref"){const s=t[a];if(Va(i)&&Va(s)||Dt(i)&&Dt(s)||Array.isArray(i)&&Array.isArray(s)?!po(i,s,e):i!==s)return!1}}return!0}function XD(n){const t=Tl(),{control:e=t.control,name:r,defaultValue:o,disabled:a,exact:i,compute:s}=n||{},u=D.useRef(o),c=D.useRef(s),l=D.useRef(void 0);c.current=s;const d=D.useMemo(()=>e._getWatch(r,u.current),[e,r]),[f,h]=D.useState(c.current?c.current(d):d);return Op(()=>e._subscribe({name:r,formState:{values:!0},exact:i,callback:m=>{if(!a){const p=X2(r,e._names,m.values||e._formValues,!1,u.current);if(c.current){const v=c.current(p);po(v,l.current)||(h(v),l.current=v)}else h(p)}}}),[e,a,r,i]),D.useEffect(()=>e._removeUnmounted()),f}function Z2(n){const t=Tl(),{name:e,disabled:r,control:o=t.control,shouldUnregister:a,defaultValue:i}=n,s=K2(o._names.array,e),u=D.useMemo(()=>me(o._formValues,e,me(o._defaultValues,e,i)),[o,e,i]),c=XD({control:o,name:e,defaultValue:u,exact:!0}),l=YD({control:o,name:e,exact:!0}),d=D.useRef(n),f=D.useRef(void 0),h=D.useRef(o.register(e,{...n.rules,value:c,...Un(n.disabled)?{disabled:n.disabled}:{}}));d.current=n;const m=D.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!me(l.errors,e)},isDirty:{enumerable:!0,get:()=>!!me(l.dirtyFields,e)},isTouched:{enumerable:!0,get:()=>!!me(l.touchedFields,e)},isValidating:{enumerable:!0,get:()=>!!me(l.validatingFields,e)},error:{enumerable:!0,get:()=>me(l.errors,e)}}),[l,e]),p=D.useCallback(w=>h.current.onChange({target:{value:q2(w),name:e},type:Al.CHANGE}),[e]),v=D.useCallback(()=>h.current.onBlur({target:{value:me(o._formValues,e),name:e},type:Al.BLUR}),[e,o._formValues]),g=D.useCallback(w=>{const x=me(o._fields,e);x&&w&&(x._f.ref={focus:()=>w.focus&&w.focus(),select:()=>w.select&&w.select(),setCustomValidity:C=>w.setCustomValidity(C),reportValidity:()=>w.reportValidity()})},[o._fields,e]),y=D.useMemo(()=>({name:e,value:c,...Un(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:p,onBlur:v,ref:g}),[e,r,l.disabled,p,v,g,c]);return D.useEffect(()=>{const w=o._options.shouldUnregister||a,x=f.current;x&&x!==e&&!s&&o.unregister(x),o.register(e,{...d.current.rules,...Un(d.current.disabled)?{disabled:d.current.disabled}:{}});const C=(_,E)=>{const S=me(o._fields,_);S&&S._f&&(S._f.mount=E)};if(C(e,!0),w){const _=Gt(me(o._options.defaultValues,e));ct(o._defaultValues,e,_),At(me(o._formValues,e))&&ct(o._formValues,e,_)}return!s&&o.register(e),f.current=e,()=>{(s?w&&!o._state.action:w)?o.unregister(e):C(e,!1)}},[e,o,s,a]),D.useEffect(()=>{o._setDisabledField({disabled:r,name:e})},[r,e,o]),D.useMemo(()=>({field:y,formState:l,fieldState:m}),[y,l,m])}const ZD=n=>n.render(Z2(n));var Q2=(n,t,e,r,o)=>t?{...e[n],types:{...e[n]&&e[n].types?e[n].types:{},[r]:o||!0}}:{},su=n=>Array.isArray(n)?n:[n],J2=()=>{let n=[];return{get observers(){return n},next:o=>{for(const a of n)a.next&&a.next(o)},subscribe:o=>(n.push(o),{unsubscribe:()=>{n=n.filter(a=>a!==o)}}),unsubscribe:()=>{n=[]}}};function ex(n,t){const e={};for(const r in n)if(n.hasOwnProperty(r)){const o=n[r],a=t[r];if(o&&Dt(o)&&a){const i=ex(o,a);Dt(i)&&(e[r]=i)}else n[r]&&(e[r]=a)}return e}var kn=n=>Dt(n)&&!Object.keys(n).length,Mp=n=>n.type==="file",dr=n=>typeof n=="function",Ol=n=>{if(!Pp)return!1;const t=n?n.ownerDocument:0;return n instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},tx=n=>n.type==="select-multiple",Fp=n=>n.type==="radio",QD=n=>Fp(n)||iu(n),Rp=n=>Ol(n)&&n.isConnected;function JD(n,t){const e=t.slice(0,-1).length;let r=0;for(;r<e;)n=At(n)?r++:n[t[r++]];return n}function e8(n){for(const t in n)if(n.hasOwnProperty(t)&&!At(n[t]))return!1;return!0}function Mt(n,t){const e=Array.isArray(t)?t:Il(t)?[t]:Ap(t),r=e.length===1?n:JD(n,e),o=e.length-1,a=e[o];return r&&delete r[a],o!==0&&(Dt(r)&&kn(r)||Array.isArray(r)&&e8(r))&&Mt(n,e.slice(0,-1)),n}var t8=n=>{for(const t in n)if(dr(n[t]))return!0;return!1};function nx(n){return Array.isArray(n)||Dt(n)&&!t8(n)}function Lp(n,t={}){for(const e in n)nx(n[e])?(t[e]=Array.isArray(n[e])?[]:{},Lp(n[e],t[e])):gn(n[e])||(t[e]=!0);return t}function Vi(n,t,e){e||(e=Lp(t));for(const r in n)nx(n[r])?At(t)||Dp(e[r])?e[r]=Lp(n[r],Array.isArray(n[r])?[]:{}):Vi(n[r],gn(t)?{}:t[r],e[r]):e[r]=!po(n[r],t[r]);return e}const rx={value:!1,isValid:!1},ox={value:!0,isValid:!0};var ax=n=>{if(Array.isArray(n)){if(n.length>1){const t=n.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return n[0].checked&&!n[0].disabled?n[0].attributes&&!At(n[0].attributes.value)?At(n[0].value)||n[0].value===""?ox:{value:n[0].value,isValid:!0}:ox:rx}return rx},ix=(n,{valueAsNumber:t,valueAsDate:e,setValueAs:r})=>At(n)?n:t?n===""?NaN:n&&+n:e&&zn(n)?new Date(n):r?r(n):n;const sx={isValid:!1,value:null};var ux=n=>Array.isArray(n)?n.reduce((t,e)=>e&&e.checked&&!e.disabled?{isValid:!0,value:e.value}:t,sx):sx;function cx(n){const t=n.ref;return Mp(t)?t.files:Fp(t)?ux(n.refs).value:tx(t)?[...t.selectedOptions].map(({value:e})=>e):iu(t)?ax(n.refs).value:ix(At(t.value)?n.ref.value:t.value,n)}var n8=(n,t,e,r)=>{const o={};for(const a of n){const i=me(t,a);i&&ct(o,a,i._f)}return{criteriaMode:e,names:[...n],fields:o,shouldUseNativeValidation:r}},Dl=n=>n instanceof RegExp,uu=n=>At(n)?n:Dl(n)?n.source:Dt(n)?Dl(n.value)?n.value.source:n.value:n,lx=n=>({isOnSubmit:!n||n===lr.onSubmit,isOnBlur:n===lr.onBlur,isOnChange:n===lr.onChange,isOnAll:n===lr.all,isOnTouch:n===lr.onTouched});const dx="AsyncFunction";var r8=n=>!!n&&!!n.validate&&!!(dr(n.validate)&&n.validate.constructor.name===dx||Dt(n.validate)&&Object.values(n.validate).find(t=>t.constructor.name===dx)),o8=n=>n.mount&&(n.required||n.min||n.max||n.maxLength||n.minLength||n.pattern||n.validate),fx=(n,t,e)=>!e&&(t.watchAll||t.watch.has(n)||[...t.watch].some(r=>n.startsWith(r)&&/^\.\w+/.test(n.slice(r.length))));const cu=(n,t,e,r)=>{for(const o of e||Object.keys(n)){const a=me(n,o);if(a){const{_f:i,...s}=a;if(i){if(i.refs&&i.refs[0]&&t(i.refs[0],o)&&!r)return!0;if(i.ref&&t(i.ref,i.name)&&!r)return!0;if(cu(s,t))break}else if(Dt(s)&&cu(s,t))break}}};function hx(n,t,e){const r=me(n,e);if(r||Il(e))return{error:r,name:e};const o=e.split(".");for(;o.length;){const a=o.join("."),i=me(t,a),s=me(n,a);if(i&&!Array.isArray(i)&&e!==a)return{name:e};if(s&&s.type)return{name:a,error:s};if(s&&s.root&&s.root.type)return{name:`${a}.root`,error:s.root};o.pop()}return{name:e}}var a8=(n,t,e,r)=>{e(n);const{name:o,...a}=n;return kn(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(i=>t[i]===(!r||lr.all))},i8=(n,t,e)=>!n||!t||n===t||su(n).some(r=>r&&(e?r===t:r.startsWith(t)||t.startsWith(r))),s8=(n,t,e,r,o)=>o.isOnAll?!1:!e&&o.isOnTouch?!(t||n):(e?r.isOnBlur:o.isOnBlur)?!n:(e?r.isOnChange:o.isOnChange)?n:!0,u8=(n,t)=>!Ip(me(n,t)).length&&Mt(n,t),c8=(n,t,e)=>{const r=su(me(n,e));return ct(r,"root",t[e]),ct(n,e,r),n};function px(n,t,e="validate"){if(zn(n)||Array.isArray(n)&&n.every(zn)||Un(n)&&!n)return{type:e,message:zn(n)?n:"",ref:t}}var ji=n=>Dt(n)&&!Dl(n)?n:{value:n,message:""},vx=async(n,t,e,r,o,a)=>{const{ref:i,refs:s,required:u,maxLength:c,minLength:l,min:d,max:f,pattern:h,validate:m,name:p,valueAsNumber:v,mount:g}=n._f,y=me(e,p);if(!g||t.has(p))return{};const w=s?s[0]:i,x=P=>{o&&w.reportValidity&&(w.setCustomValidity(Un(P)?"":P||""),w.reportValidity())},C={},_=Fp(i),E=iu(i),S=_||E,N=(v||Mp(i))&&At(i.value)&&At(y)||Ol(i)&&i.value===""||y===""||Array.isArray(y)&&!y.length,$=Q2.bind(null,p,r,C),A=(P,j,B,z=ho.maxLength,H=ho.minLength)=>{const F=P?j:B;C[p]={type:P?z:H,message:F,ref:i,...$(P?z:H,F)}};if(a?!Array.isArray(y)||!y.length:u&&(!S&&(N||gn(y))||Un(y)&&!y||E&&!ax(s).isValid||_&&!ux(s).isValid)){const{value:P,message:j}=zn(u)?{value:!!u,message:u}:ji(u);if(P&&(C[p]={type:ho.required,message:j,ref:w,...$(ho.required,j)},!r))return x(j),C}if(!N&&(!gn(d)||!gn(f))){let P,j;const B=ji(f),z=ji(d);if(!gn(y)&&!isNaN(y)){const H=i.valueAsNumber||y&&+y;gn(B.value)||(P=H>B.value),gn(z.value)||(j=H<z.value)}else{const H=i.valueAsDate||new Date(y),F=I=>new Date(new Date().toDateString()+" "+I),M=i.type=="time",O=i.type=="week";zn(B.value)&&y&&(P=M?F(y)>F(B.value):O?y>B.value:H>new Date(B.value)),zn(z.value)&&y&&(j=M?F(y)<F(z.value):O?y<z.value:H<new Date(z.value))}if((P||j)&&(A(!!P,B.message,z.message,ho.max,ho.min),!r))return x(C[p].message),C}if((c||l)&&!N&&(zn(y)||a&&Array.isArray(y))){const P=ji(c),j=ji(l),B=!gn(P.value)&&y.length>+P.value,z=!gn(j.value)&&y.length<+j.value;if((B||z)&&(A(B,P.message,j.message),!r))return x(C[p].message),C}if(h&&!N&&zn(y)){const{value:P,message:j}=ji(h);if(Dl(P)&&!y.match(P)&&(C[p]={type:ho.pattern,message:j,ref:i,...$(ho.pattern,j)},!r))return x(j),C}if(m){if(dr(m)){const P=await m(y,e),j=px(P,w);if(j&&(C[p]={...j,...$(ho.validate,j.message)},!r))return x(j.message),C}else if(Dt(m)){let P={};for(const j in m){if(!kn(P)&&!r)break;const B=px(await m[j](y,e),w,j);B&&(P={...B,...$(j,B.message)},x(B.message),r&&(C[p]=P))}if(!kn(P)&&(C[p]={ref:w,...P},!r))return C}}return x(!0),C};const l8={mode:lr.onSubmit,reValidateMode:lr.onChange,shouldFocusError:!0};function d8(n={}){let t={...l8,...n},e={submitCount:0,isDirty:!1,isReady:!1,isLoading:dr(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},o=Dt(t.defaultValues)||Dt(t.values)?Gt(t.defaultValues||t.values)||{}:{},a=t.shouldUnregister?{}:Gt(o),i={action:!1,mount:!1,watch:!1},s={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},u,c=0;const l={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let d={...l};const f={array:J2(),state:J2()},h=t.criteriaMode===lr.all,m=V=>Y=>{clearTimeout(c),c=setTimeout(V,Y)},p=async V=>{if(!t.disabled&&(l.isValid||d.isValid||V)){const Y=t.resolver?kn((await E()).errors):await N(r,!0);Y!==e.isValid&&f.state.next({isValid:Y})}},v=(V,Y)=>{!t.disabled&&(l.isValidating||l.validatingFields||d.isValidating||d.validatingFields)&&((V||Array.from(s.mount)).forEach(te=>{te&&(Y?ct(e.validatingFields,te,Y):Mt(e.validatingFields,te))}),f.state.next({validatingFields:e.validatingFields,isValidating:!kn(e.validatingFields)}))},g=(V,Y=[],te,he,pe=!0,le=!0)=>{if(he&&te&&!t.disabled){if(i.action=!0,le&&Array.isArray(me(r,V))){const ye=te(me(r,V),he.argA,he.argB);pe&&ct(r,V,ye)}if(le&&Array.isArray(me(e.errors,V))){const ye=te(me(e.errors,V),he.argA,he.argB);pe&&ct(e.errors,V,ye),u8(e.errors,V)}if((l.touchedFields||d.touchedFields)&&le&&Array.isArray(me(e.touchedFields,V))){const ye=te(me(e.touchedFields,V),he.argA,he.argB);pe&&ct(e.touchedFields,V,ye)}(l.dirtyFields||d.dirtyFields)&&(e.dirtyFields=Vi(o,a)),f.state.next({name:V,isDirty:A(V,Y),dirtyFields:e.dirtyFields,errors:e.errors,isValid:e.isValid})}else ct(a,V,Y)},y=(V,Y)=>{ct(e.errors,V,Y),f.state.next({errors:e.errors})},w=V=>{e.errors=V,f.state.next({errors:e.errors,isValid:!1})},x=(V,Y,te,he)=>{const pe=me(r,V);if(pe){const le=me(a,V,At(te)?me(o,V):te);At(le)||he&&he.defaultChecked||Y?ct(a,V,Y?le:cx(pe._f)):B(V,le),i.mount&&p()}},C=(V,Y,te,he,pe)=>{let le=!1,ye=!1;const We={name:V};if(!t.disabled){if(!te||he){(l.isDirty||d.isDirty)&&(ye=e.isDirty,e.isDirty=We.isDirty=A(),le=ye!==We.isDirty);const Ge=po(me(o,V),Y);ye=!!me(e.dirtyFields,V),Ge?Mt(e.dirtyFields,V):ct(e.dirtyFields,V,!0),We.dirtyFields=e.dirtyFields,le=le||(l.dirtyFields||d.dirtyFields)&&ye!==!Ge}if(te){const Ge=me(e.touchedFields,V);Ge||(ct(e.touchedFields,V,te),We.touchedFields=e.touchedFields,le=le||(l.touchedFields||d.touchedFields)&&Ge!==te)}le&&pe&&f.state.next(We)}return le?We:{}},_=(V,Y,te,he)=>{const pe=me(e.errors,V),le=(l.isValid||d.isValid)&&Un(Y)&&e.isValid!==Y;if(t.delayError&&te?(u=m(()=>y(V,te)),u(t.delayError)):(clearTimeout(c),u=null,te?ct(e.errors,V,te):Mt(e.errors,V)),(te?!po(pe,te):pe)||!kn(he)||le){const ye={...he,...le&&Un(Y)?{isValid:Y}:{},errors:e.errors,name:V};e={...e,...ye},f.state.next(ye)}},E=async V=>{v(V,!0);const Y=await t.resolver(a,t.context,n8(V||s.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return v(V),Y},S=async V=>{const{errors:Y}=await E(V);if(V)for(const te of V){const he=me(Y,te);he?ct(e.errors,te,he):Mt(e.errors,te)}else e.errors=Y;return Y},N=async(V,Y,te={valid:!0})=>{for(const he in V){const pe=V[he];if(pe){const{_f:le,...ye}=pe;if(le){const We=s.array.has(le.name),Ge=pe._f&&r8(pe._f);Ge&&l.validatingFields&&v([le.name],!0);const Qt=await vx(pe,s.disabled,a,h,t.shouldUseNativeValidation&&!Y,We);if(Ge&&l.validatingFields&&v([le.name]),Qt[le.name]&&(te.valid=!1,Y))break;!Y&&(me(Qt,le.name)?We?c8(e.errors,Qt,le.name):ct(e.errors,le.name,Qt[le.name]):Mt(e.errors,le.name))}!kn(ye)&&await N(ye,Y,te)}}return te.valid},$=()=>{for(const V of s.unMount){const Y=me(r,V);Y&&(Y._f.refs?Y._f.refs.every(te=>!Rp(te)):!Rp(Y._f.ref))&&X(V)}s.unMount=new Set},A=(V,Y)=>!t.disabled&&(V&&Y&&ct(a,V,Y),!po(I(),o)),P=(V,Y,te)=>X2(V,s,{...i.mount?a:At(Y)?o:zn(V)?{[V]:Y}:Y},te,Y),j=V=>Ip(me(i.mount?a:o,V,t.shouldUnregister?me(o,V,[]):[])),B=(V,Y,te={})=>{const he=me(r,V);let pe=Y;if(he){const le=he._f;le&&(!le.disabled&&ct(a,V,ix(Y,le)),pe=Ol(le.ref)&&gn(Y)?"":Y,tx(le.ref)?[...le.ref.options].forEach(ye=>ye.selected=pe.includes(ye.value)):le.refs?iu(le.ref)?le.refs.forEach(ye=>{(!ye.defaultChecked||!ye.disabled)&&(Array.isArray(pe)?ye.checked=!!pe.find(We=>We===ye.value):ye.checked=pe===ye.value||!!pe)}):le.refs.forEach(ye=>ye.checked=ye.value===pe):Mp(le.ref)?le.ref.value="":(le.ref.value=pe,le.ref.type||f.state.next({name:V,values:Gt(a)})))}(te.shouldDirty||te.shouldTouch)&&C(V,pe,te.shouldTouch,te.shouldDirty,!0),te.shouldValidate&&O(V)},z=(V,Y,te)=>{for(const he in Y){if(!Y.hasOwnProperty(he))return;const pe=Y[he],le=V+"."+he,ye=me(r,le);(s.array.has(V)||Dt(pe)||ye&&!ye._f)&&!Va(pe)?z(le,pe,te):B(le,pe,te)}},H=(V,Y,te={})=>{const he=me(r,V),pe=s.array.has(V),le=Gt(Y);ct(a,V,le),pe?(f.array.next({name:V,values:Gt(a)}),(l.isDirty||l.dirtyFields||d.isDirty||d.dirtyFields)&&te.shouldDirty&&f.state.next({name:V,dirtyFields:Vi(o,a),isDirty:A(V,le)})):he&&!he._f&&!gn(le)?z(V,le,te):B(V,le,te),fx(V,s)&&f.state.next({...e,name:V}),f.state.next({name:i.mount?V:void 0,values:Gt(a)})},F=async V=>{i.mount=!0;const Y=V.target;let te=Y.name,he=!0;const pe=me(r,te),le=Ge=>{he=Number.isNaN(Ge)||Va(Ge)&&isNaN(Ge.getTime())||po(Ge,me(a,te,Ge))},ye=lx(t.mode),We=lx(t.reValidateMode);if(pe){let Ge,Qt;const xr=Y.type?cx(pe._f):q2(V),er=V.type===Al.BLUR||V.type===Al.FOCUS_OUT,_s=!o8(pe._f)&&!t.resolver&&!me(e.errors,te)&&!pe._f.deps||s8(er,me(e.touchedFields,te),e.isSubmitted,We,ye),wr=fx(te,s,er);ct(a,te,xr),er?(!Y||!Y.readOnly)&&(pe._f.onBlur&&pe._f.onBlur(V),u&&u(0)):pe._f.onChange&&pe._f.onChange(V);const On=C(te,xr,er),ha=!kn(On)||wr;if(!er&&f.state.next({name:te,type:V.type,values:Gt(a)}),_s)return(l.isValid||d.isValid)&&(t.mode==="onBlur"?er&&p():er||p()),ha&&f.state.next({name:te,...wr?{}:On});if(!er&&wr&&f.state.next({...e}),t.resolver){const{errors:No}=await E([te]);if(le(xr),he){const Nm=hx(e.errors,r,te),xd=hx(No,r,Nm.name||te);Ge=xd.error,te=xd.name,Qt=kn(No)}}else v([te],!0),Ge=(await vx(pe,s.disabled,a,h,t.shouldUseNativeValidation))[te],v([te]),le(xr),he&&(Ge?Qt=!1:(l.isValid||d.isValid)&&(Qt=await N(r,!0)));he&&(pe._f.deps&&(!Array.isArray(pe._f.deps)||pe._f.deps.length>0)&&O(pe._f.deps),_(te,Qt,Ge,On))}},M=(V,Y)=>{if(me(e.errors,Y)&&V.focus)return V.focus(),1},O=async(V,Y={})=>{let te,he;const pe=su(V);if(t.resolver){const le=await S(At(V)?V:pe);te=kn(le),he=V?!pe.some(ye=>me(le,ye)):te}else V?(he=(await Promise.all(pe.map(async le=>{const ye=me(r,le);return await N(ye&&ye._f?{[le]:ye}:ye)}))).every(Boolean),!(!he&&!e.isValid)&&p()):he=te=await N(r);return f.state.next({...!zn(V)||(l.isValid||d.isValid)&&te!==e.isValid?{}:{name:V},...t.resolver||!V?{isValid:te}:{},errors:e.errors}),Y.shouldFocus&&!he&&cu(r,M,V?pe:s.mount),he},I=(V,Y)=>{let te={...i.mount?a:o};return Y&&(te=ex(Y.dirtyFields?e.dirtyFields:e.touchedFields,te)),At(V)?te:zn(V)?me(te,V):V.map(he=>me(te,he))},L=(V,Y)=>({invalid:!!me((Y||e).errors,V),isDirty:!!me((Y||e).dirtyFields,V),error:me((Y||e).errors,V),isValidating:!!me(e.validatingFields,V),isTouched:!!me((Y||e).touchedFields,V)}),K=V=>{V&&su(V).forEach(Y=>Mt(e.errors,Y)),f.state.next({errors:V?e.errors:{}})},q=(V,Y,te)=>{const he=(me(r,V,{_f:{}})._f||{}).ref,pe=me(e.errors,V)||{},{ref:le,message:ye,type:We,...Ge}=pe;ct(e.errors,V,{...Ge,...Y,ref:he}),f.state.next({name:V,errors:e.errors,isValid:!1}),te&&te.shouldFocus&&he&&he.focus&&he.focus()},Z=(V,Y)=>dr(V)?f.state.subscribe({next:te=>"values"in te&&V(P(void 0,Y),te)}):P(V,Y,!0),oe=V=>f.state.subscribe({next:Y=>{i8(V.name,Y.name,V.exact)&&a8(Y,V.formState||l,Lt,V.reRenderRoot)&&V.callback({values:{...a},...e,...Y,defaultValues:o})}}).unsubscribe,ae=V=>(i.mount=!0,d={...d,...V.formState},oe({...V,formState:d})),X=(V,Y={})=>{for(const te of V?su(V):s.mount)s.mount.delete(te),s.array.delete(te),Y.keepValue||(Mt(r,te),Mt(a,te)),!Y.keepError&&Mt(e.errors,te),!Y.keepDirty&&Mt(e.dirtyFields,te),!Y.keepTouched&&Mt(e.touchedFields,te),!Y.keepIsValidating&&Mt(e.validatingFields,te),!t.shouldUnregister&&!Y.keepDefaultValue&&Mt(o,te);f.state.next({values:Gt(a)}),f.state.next({...e,...Y.keepDirty?{isDirty:A()}:{}}),!Y.keepIsValid&&p()},re=({disabled:V,name:Y})=>{(Un(V)&&i.mount||V||s.disabled.has(Y))&&(V?s.disabled.add(Y):s.disabled.delete(Y))},ce=(V,Y={})=>{let te=me(r,V);const he=Un(Y.disabled)||Un(t.disabled);return ct(r,V,{...te||{},_f:{...te&&te._f?te._f:{ref:{name:V}},name:V,mount:!0,...Y}}),s.mount.add(V),te?re({disabled:Un(Y.disabled)?Y.disabled:t.disabled,name:V}):x(V,!0,Y.value),{...he?{disabled:Y.disabled||t.disabled}:{},...t.progressive?{required:!!Y.required,min:uu(Y.min),max:uu(Y.max),minLength:uu(Y.minLength),maxLength:uu(Y.maxLength),pattern:uu(Y.pattern)}:{},name:V,onChange:F,onBlur:F,ref:pe=>{if(pe){ce(V,Y),te=me(r,V);const le=At(pe.value)&&pe.querySelectorAll&&pe.querySelectorAll("input,select,textarea")[0]||pe,ye=QD(le),We=te._f.refs||[];if(ye?We.find(Ge=>Ge===le):le===te._f.ref)return;ct(r,V,{_f:{...te._f,...ye?{refs:[...We.filter(Rp),le,...Array.isArray(me(o,V))?[{}]:[]],ref:{type:le.type,name:V}}:{ref:le}}}),x(V,!1,void 0,le)}else te=me(r,V,{}),te._f&&(te._f.mount=!1),(t.shouldUnregister||Y.shouldUnregister)&&!(K2(s.array,V)&&i.action)&&s.unMount.add(V)}}},ue=()=>t.shouldFocusError&&cu(r,M,s.mount),se=V=>{Un(V)&&(f.state.next({disabled:V}),cu(r,(Y,te)=>{const he=me(r,te);he&&(Y.disabled=he._f.disabled||V,Array.isArray(he._f.refs)&&he._f.refs.forEach(pe=>{pe.disabled=he._f.disabled||V}))},0,!1))},ee=(V,Y)=>async te=>{let he;te&&(te.preventDefault&&te.preventDefault(),te.persist&&te.persist());let pe=Gt(a);if(f.state.next({isSubmitting:!0}),t.resolver){const{errors:le,values:ye}=await E();e.errors=le,pe=Gt(ye)}else await N(r);if(s.disabled.size)for(const le of s.disabled)Mt(pe,le);if(Mt(e.errors,"root"),kn(e.errors)){f.state.next({errors:{}});try{await V(pe,te)}catch(le){he=le}}else Y&&await Y({...e.errors},te),ue(),setTimeout(ue);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:kn(e.errors)&&!he,submitCount:e.submitCount+1,errors:e.errors}),he)throw he},_e=(V,Y={})=>{me(r,V)&&(At(Y.defaultValue)?H(V,Gt(me(o,V))):(H(V,Y.defaultValue),ct(o,V,Gt(Y.defaultValue))),Y.keepTouched||Mt(e.touchedFields,V),Y.keepDirty||(Mt(e.dirtyFields,V),e.isDirty=Y.defaultValue?A(V,Gt(me(o,V))):A()),Y.keepError||(Mt(e.errors,V),l.isValid&&p()),f.state.next({...e}))},Me=(V,Y={})=>{const te=V?Gt(V):o,he=Gt(te),pe=kn(V),le=pe?o:he;if(Y.keepDefaultValues||(o=te),!Y.keepValues){if(Y.keepDirtyValues){const ye=new Set([...s.mount,...Object.keys(Vi(o,a))]);for(const We of Array.from(ye))me(e.dirtyFields,We)?ct(le,We,me(a,We)):H(We,me(le,We))}else{if(Pp&&At(V))for(const ye of s.mount){const We=me(r,ye);if(We&&We._f){const Ge=Array.isArray(We._f.refs)?We._f.refs[0]:We._f.ref;if(Ol(Ge)){const Qt=Ge.closest("form");if(Qt){Qt.reset();break}}}}if(Y.keepFieldsRef)for(const ye of s.mount)H(ye,me(le,ye));else r={}}a=t.shouldUnregister?Y.keepDefaultValues?Gt(o):{}:Gt(le),f.array.next({values:{...le}}),f.state.next({values:{...le}})}s={mount:Y.keepDirtyValues?s.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!l.isValid||!!Y.keepIsValid||!!Y.keepDirtyValues,i.watch=!!t.shouldUnregister,f.state.next({submitCount:Y.keepSubmitCount?e.submitCount:0,isDirty:pe?!1:Y.keepDirty?e.isDirty:!!(Y.keepDefaultValues&&!po(V,o)),isSubmitted:Y.keepIsSubmitted?e.isSubmitted:!1,dirtyFields:pe?{}:Y.keepDirtyValues?Y.keepDefaultValues&&a?Vi(o,a):e.dirtyFields:Y.keepDefaultValues&&V?Vi(o,V):Y.keepDirty?e.dirtyFields:{},touchedFields:Y.keepTouched?e.touchedFields:{},errors:Y.keepErrors?e.errors:{},isSubmitSuccessful:Y.keepIsSubmitSuccessful?e.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:o})},Ye=(V,Y)=>Me(dr(V)?V(a):V,Y),Ze=(V,Y={})=>{const te=me(r,V),he=te&&te._f;if(he){const pe=he.refs?he.refs[0]:he.ref;pe.focus&&(pe.focus(),Y.shouldSelect&&dr(pe.select)&&pe.select())}},Lt=V=>{e={...e,...V}},Ct={control:{register:ce,unregister:X,getFieldState:L,handleSubmit:ee,setError:q,_subscribe:oe,_runSchema:E,_focusError:ue,_getWatch:P,_getDirty:A,_setValid:p,_setFieldArray:g,_setDisabledField:re,_setErrors:w,_getFieldArray:j,_reset:Me,_resetDefaultValues:()=>dr(t.defaultValues)&&t.defaultValues().then(V=>{Ye(V,t.resetOptions),f.state.next({isLoading:!1})}),_removeUnmounted:$,_disableForm:se,_subjects:f,_proxyFormState:l,get _fields(){return r},get _formValues(){return a},get _state(){return i},set _state(V){i=V},get _defaultValues(){return o},get _names(){return s},set _names(V){s=V},get _formState(){return e},get _options(){return t},set _options(V){t={...t,...V}}},subscribe:ae,trigger:O,register:ce,handleSubmit:ee,watch:Z,setValue:H,getValues:I,reset:Ye,resetField:_e,clearErrors:K,unregister:X,setError:q,setFocus:Ze,getFieldState:L};return{...Ct,formControl:Ct}}function lu(n={}){const t=D.useRef(void 0),e=D.useRef(void 0),[r,o]=D.useState({isDirty:!1,isValidating:!1,isLoading:dr(n.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:n.errors||{},disabled:n.disabled||!1,isReady:!1,defaultValues:dr(n.defaultValues)?void 0:n.defaultValues});if(!t.current)if(n.formControl)t.current={...n.formControl,formState:r},n.defaultValues&&!dr(n.defaultValues)&&n.formControl.reset(n.defaultValues,n.resetOptions);else{const{formControl:i,...s}=d8(n);t.current={...s,formState:r}}const a=t.current.control;return a._options=n,Op(()=>{const i=a._subscribe({formState:a._proxyFormState,callback:()=>o({...a._formState}),reRenderRoot:!0});return o(s=>({...s,isReady:!0})),a._formState.isReady=!0,i},[a]),D.useEffect(()=>a._disableForm(n.disabled),[a,n.disabled]),D.useEffect(()=>{n.mode&&(a._options.mode=n.mode),n.reValidateMode&&(a._options.reValidateMode=n.reValidateMode)},[a,n.mode,n.reValidateMode]),D.useEffect(()=>{n.errors&&(a._setErrors(n.errors),a._focusError())},[a,n.errors]),D.useEffect(()=>{n.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,n.shouldUnregister]),D.useEffect(()=>{if(a._proxyFormState.isDirty){const i=a._getDirty();i!==r.isDirty&&a._subjects.state.next({isDirty:i})}},[a,r.isDirty]),D.useEffect(()=>{n.values&&!po(n.values,e.current)?(a._reset(n.values,{keepFieldsRef:!0,...a._options.resetOptions}),e.current=n.values,o(i=>({...i}))):a._resetDefaultValues()},[a,n.values]),D.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=Y2(r,a),t.current}const mx=(n,t,e)=>{if(n&&"reportValidity"in n){const r=me(e,t);n.setCustomValidity(r&&r.message||""),n.reportValidity()}},gx=(n,t)=>{for(const e in t.fields){const r=t.fields[e];r&&r.ref&&"reportValidity"in r.ref?mx(r.ref,e,n):r.refs&&r.refs.forEach(o=>mx(o,e,n))}},f8=(n,t)=>{t.shouldUseNativeValidation&&gx(n,t);const e={};for(const r in n){const o=me(t.fields,r),a=Object.assign(n[r]||{},{ref:o&&o.ref});if(h8(t.names||Object.keys(n),r)){const i=Object.assign({},me(e,r));ct(i,"root",a),ct(e,r,i)}else ct(e,r,a)}return e},h8=(n,t)=>n.some(e=>e.startsWith(t+"."));var p8=function(n,t){for(var e={};n.length;){var r=n[0],o=r.code,a=r.message,i=r.path.join(".");if(!e[i])if("unionErrors"in r){var s=r.unionErrors[0].errors[0];e[i]={message:s.message,type:s.code}}else e[i]={message:a,type:o};if("unionErrors"in r&&r.unionErrors.forEach(function(l){return l.errors.forEach(function(d){return n.push(d)})}),t){var u=e[i].types,c=u&&u[r.code];e[i]=Q2(i,t,e,o,c?[].concat(c,r.message):r.message)}n.shift()}return e},du=function(n,t,e){return e===void 0&&(e={}),function(r,o,a){try{return Promise.resolve(function(i,s){try{var u=Promise.resolve(n[e.mode==="sync"?"parse":"parseAsync"](r,t)).then(function(c){return a.shouldUseNativeValidation&&gx({},a),{errors:{},values:e.raw?r:c}})}catch(c){return s(c)}return u&&u.then?u.then(void 0,s):u}(0,function(i){if(function(s){return Array.isArray(s==null?void 0:s.errors)}(i))return{values:{},errors:f8(p8(i.errors,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw i}))}catch(i){return Promise.reject(i)}}},rt;(function(n){n.assertEqual=o=>{};function t(o){}n.assertIs=t;function e(o){throw new Error}n.assertNever=e,n.arrayToEnum=o=>{const a={};for(const i of o)a[i]=i;return a},n.getValidEnumValues=o=>{const a=n.objectKeys(o).filter(s=>typeof o[o[s]]!="number"),i={};for(const s of a)i[s]=o[s];return n.objectValues(i)},n.objectValues=o=>n.objectKeys(o).map(function(a){return o[a]}),n.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{const a=[];for(const i in o)Object.prototype.hasOwnProperty.call(o,i)&&a.push(i);return a},n.find=(o,a)=>{for(const i of o)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function r(o,a=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(o,a)=>typeof a=="bigint"?a.toString():a})(rt||(rt={}));var yx;(function(n){n.mergeShapes=(t,e)=>({...t,...e})})(yx||(yx={}));const Ee=rt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ko=n=>{switch(typeof n){case"undefined":return Ee.undefined;case"string":return Ee.string;case"number":return Number.isNaN(n)?Ee.nan:Ee.number;case"boolean":return Ee.boolean;case"function":return Ee.function;case"bigint":return Ee.bigint;case"symbol":return Ee.symbol;case"object":return Array.isArray(n)?Ee.array:n===null?Ee.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Ee.promise:typeof Map<"u"&&n instanceof Map?Ee.map:typeof Set<"u"&&n instanceof Set?Ee.set:typeof Date<"u"&&n instanceof Date?Ee.date:Ee.object;default:return Ee.unknown}},fe=rt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class vo extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=t}format(t){const e=t||function(a){return a.message},r={_errors:[]},o=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)r._errors.push(e(i));else{let s=r,u=0;for(;u<i.path.length;){const c=i.path[u];u===i.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(e(i))):s[c]=s[c]||{_errors:[]},s=s[c],u++}}};return o(this),r}static assert(t){if(!(t instanceof vo))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,rt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=e=>e.message){const e={},r=[];for(const o of this.issues)if(o.path.length>0){const a=o.path[0];e[a]=e[a]||[],e[a].push(t(o))}else r.push(t(o));return{formErrors:r,fieldErrors:e}}get formErrors(){return this.flatten()}}vo.create=n=>new vo(n);const Bp=(n,t)=>{let e;switch(n.code){case fe.invalid_type:n.received===Ee.undefined?e="Required":e=`Expected ${n.expected}, received ${n.received}`;break;case fe.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(n.expected,rt.jsonStringifyReplacer)}`;break;case fe.unrecognized_keys:e=`Unrecognized key(s) in object: ${rt.joinValues(n.keys,", ")}`;break;case fe.invalid_union:e="Invalid input";break;case fe.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${rt.joinValues(n.options)}`;break;case fe.invalid_enum_value:e=`Invalid enum value. Expected ${rt.joinValues(n.options)}, received '${n.received}'`;break;case fe.invalid_arguments:e="Invalid function arguments";break;case fe.invalid_return_type:e="Invalid function return type";break;case fe.invalid_date:e="Invalid date";break;case fe.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(e=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(e=`${e} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?e=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?e=`Invalid input: must end with "${n.validation.endsWith}"`:rt.assertNever(n.validation):n.validation!=="regex"?e=`Invalid ${n.validation}`:e="Invalid";break;case fe.too_small:n.type==="array"?e=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?e=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?e=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?e=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?e=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:e="Invalid input";break;case fe.too_big:n.type==="array"?e=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?e=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?e=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?e=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?e=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:e="Invalid input";break;case fe.custom:e="Invalid input";break;case fe.invalid_intersection_types:e="Intersection results could not be merged";break;case fe.not_multiple_of:e=`Number must be a multiple of ${n.multipleOf}`;break;case fe.not_finite:e="Number must be finite";break;default:e=t.defaultError,rt.assertNever(n)}return{message:e}};let v8=Bp;function m8(){return v8}const g8=n=>{const{data:t,path:e,errorMaps:r,issueData:o}=n,a=[...e,...o.path||[]],i={...o,path:a};if(o.message!==void 0)return{...o,path:a,message:o.message};let s="";const u=r.filter(c=>!!c).slice().reverse();for(const c of u)s=c(i,{data:t,defaultError:s}).message;return{...o,path:a,message:s}};function be(n,t){const e=m8(),r=g8({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,e,e===Bp?void 0:Bp].filter(o=>!!o)});n.common.issues.push(r)}class Hn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,e){const r=[];for(const o of e){if(o.status==="aborted")return Re;o.status==="dirty"&&t.dirty(),r.push(o.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,e){const r=[];for(const o of e){const a=await o.key,i=await o.value;r.push({key:a,value:i})}return Hn.mergeObjectSync(t,r)}static mergeObjectSync(t,e){const r={};for(const o of e){const{key:a,value:i}=o;if(a.status==="aborted"||i.status==="aborted")return Re;a.status==="dirty"&&t.dirty(),i.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(r[a.value]=i.value)}return{status:t.value,value:r}}}const Re=Object.freeze({status:"aborted"}),fu=n=>({status:"dirty",value:n}),Qn=n=>({status:"valid",value:n}),bx=n=>n.status==="aborted",xx=n=>n.status==="dirty",Ui=n=>n.status==="valid",Ml=n=>typeof Promise<"u"&&n instanceof Promise;var Pe;(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Pe||(Pe={}));class Yo{constructor(t,e,r,o){this._cachedPath=[],this.parent=t,this.data=e,this._path=r,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const wx=(n,t)=>{if(Ui(t))return{success:!0,data:t.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const e=new vo(n.common.issues);return this._error=e,this._error}}};function Ke(n){if(!n)return{};const{errorMap:t,invalid_type_error:e,required_error:r,description:o}=n;if(t&&(e||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:(i,s)=>{const{message:u}=n;return i.code==="invalid_enum_value"?{message:u??s.defaultError}:typeof s.data>"u"?{message:u??r??s.defaultError}:i.code!=="invalid_type"?{message:s.defaultError}:{message:u??e??s.defaultError}},description:o}}class tt{get description(){return this._def.description}_getType(t){return Ko(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:Ko(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Hn,ctx:{common:t.parent.common,data:t.data,parsedType:Ko(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const e=this._parse(t);if(Ml(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){const e=this._parse(t);return Promise.resolve(e)}parse(t,e){const r=this.safeParse(t,e);if(r.success)return r.data;throw r.error}safeParse(t,e){const r={common:{issues:[],async:(e==null?void 0:e.async)??!1,contextualErrorMap:e==null?void 0:e.errorMap},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ko(t)},o=this._parseSync({data:t,path:r.path,parent:r});return wx(r,o)}"~validate"(t){var r,o;const e={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ko(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:e});return Ui(a)?{value:a.value}:{issues:e.common.issues}}catch(a){(o=(r=a==null?void 0:a.message)==null?void 0:r.toLowerCase())!=null&&o.includes("encountered")&&(this["~standard"].async=!0),e.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:e}).then(a=>Ui(a)?{value:a.value}:{issues:e.common.issues})}async parseAsync(t,e){const r=await this.safeParseAsync(t,e);if(r.success)return r.data;throw r.error}async safeParseAsync(t,e){const r={common:{issues:[],contextualErrorMap:e==null?void 0:e.errorMap,async:!0},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ko(t)},o=this._parse({data:t,path:r.path,parent:r}),a=await(Ml(o)?o:Promise.resolve(o));return wx(r,a)}refine(t,e){const r=o=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(o):e;return this._refinement((o,a)=>{const i=t(o),s=()=>a.addIssue({code:fe.custom,...r(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(s(),!1)):i?!0:(s(),!1)})}refinement(t,e){return this._refinement((r,o)=>t(r)?!0:(o.addIssue(typeof e=="function"?e(r,o):e),!1))}_refinement(t){return new Gi({schema:this,typeName:Le.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Qo.create(this,this._def)}nullable(){return qi.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Hr.create(this)}promise(){return Ll.create(this,this._def)}or(t){return Fl.create([this,t],this._def)}and(t){return Rl.create(this,t,this._def)}transform(t){return new Gi({...Ke(this._def),schema:this,typeName:Le.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const e=typeof t=="function"?t:()=>t;return new Up({...Ke(this._def),innerType:this,defaultValue:e,typeName:Le.ZodDefault})}brand(){return new W8({typeName:Le.ZodBranded,type:this,...Ke(this._def)})}catch(t){const e=typeof t=="function"?t:()=>t;return new zp({...Ke(this._def),innerType:this,catchValue:e,typeName:Le.ZodCatch})}describe(t){const e=this.constructor;return new e({...this._def,description:t})}pipe(t){return Hp.create(this,t)}readonly(){return Gp.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const y8=/^c[^\s-]{8,}$/i,b8=/^[0-9a-z]+$/,x8=/^[0-9A-HJKMNP-TV-Z]{26}$/i,w8=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,C8=/^[a-z0-9_-]{21}$/i,_8=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,E8=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,S8=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,N8="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Wp;const $8=/^(?:(?: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])$/,k8=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,P8=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,I8=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,A8=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,T8=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Cx="((\\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])))",O8=new RegExp(`^${Cx}$`);function _x(n){let t="[0-5]\\d";n.precision?t=`${t}\\.\\d{${n.precision}}`:n.precision==null&&(t=`${t}(\\.\\d+)?`);const e=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e}`}function D8(n){return new RegExp(`^${_x(n)}$`)}function M8(n){let t=`${Cx}T${_x(n)}`;const e=[];return e.push(n.local?"Z?":"Z"),n.offset&&e.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${e.join("|")})`,new RegExp(`^${t}$`)}function F8(n,t){return!!((t==="v4"||!t)&&$8.test(n)||(t==="v6"||!t)&&P8.test(n))}function R8(n,t){if(!_8.test(n))return!1;try{const[e]=n.split(".");if(!e)return!1;const r=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),o=JSON.parse(atob(r));return!(typeof o!="object"||o===null||"typ"in o&&(o==null?void 0:o.typ)!=="JWT"||!o.alg||t&&o.alg!==t)}catch{return!1}}function L8(n,t){return!!((t==="v4"||!t)&&k8.test(n)||(t==="v6"||!t)&&I8.test(n))}class Xo extends tt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Ee.string){const a=this._getOrReturnCtx(t);return be(a,{code:fe.invalid_type,expected:Ee.string,received:a.parsedType}),Re}const r=new Hn;let o;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(o=this._getOrReturnCtx(t,o),be(o,{code:fe.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")t.data.length>a.value&&(o=this._getOrReturnCtx(t,o),be(o,{code:fe.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const i=t.data.length>a.value,s=t.data.length<a.value;(i||s)&&(o=this._getOrReturnCtx(t,o),i?be(o,{code:fe.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&be(o,{code:fe.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")S8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"email",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")Wp||(Wp=new RegExp(N8,"u")),Wp.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"emoji",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")w8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"uuid",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")C8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"nanoid",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")y8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"cuid",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")b8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"cuid2",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")x8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"ulid",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),be(o,{validation:"url",code:fe.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"regex",code:fe.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?M8(a).test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?O8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?D8(a).test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?E8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"duration",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?F8(t.data,a.version)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"ip",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?R8(t.data,a.alg)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"jwt",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?L8(t.data,a.version)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"cidr",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?A8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"base64",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?T8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"base64url",code:fe.invalid_string,message:a.message}),r.dirty()):rt.assertNever(a);return{status:r.value,value:t.data}}_regex(t,e,r){return this.refinement(o=>t.test(o),{validation:e,code:fe.invalid_string,...Pe.errToObj(r)})}_addCheck(t){return new Xo({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Pe.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Pe.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Pe.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Pe.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Pe.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Pe.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Pe.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Pe.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Pe.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Pe.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Pe.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Pe.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Pe.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...Pe.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Pe.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Pe.errToObj(t)})}regex(t,e){return this._addCheck({kind:"regex",regex:t,...Pe.errToObj(e)})}includes(t,e){return this._addCheck({kind:"includes",value:t,position:e==null?void 0:e.position,...Pe.errToObj(e==null?void 0:e.message)})}startsWith(t,e){return this._addCheck({kind:"startsWith",value:t,...Pe.errToObj(e)})}endsWith(t,e){return this._addCheck({kind:"endsWith",value:t,...Pe.errToObj(e)})}min(t,e){return this._addCheck({kind:"min",value:t,...Pe.errToObj(e)})}max(t,e){return this._addCheck({kind:"max",value:t,...Pe.errToObj(e)})}length(t,e){return this._addCheck({kind:"length",value:t,...Pe.errToObj(e)})}nonempty(t){return this.min(1,Pe.errToObj(t))}trim(){return new Xo({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Xo({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Xo({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxLength(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}Xo.create=n=>new Xo({checks:[],typeName:Le.ZodString,coerce:(n==null?void 0:n.coerce)??!1,...Ke(n)});function B8(n,t){const e=(n.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,o=e>r?e:r,a=Number.parseInt(n.toFixed(o).replace(".","")),i=Number.parseInt(t.toFixed(o).replace(".",""));return a%i/10**o}class hu extends tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Ee.number){const a=this._getOrReturnCtx(t);return be(a,{code:fe.invalid_type,expected:Ee.number,received:a.parsedType}),Re}let r;const o=new Hn;for(const a of this._def.checks)a.kind==="int"?rt.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{code:fe.invalid_type,expected:"integer",received:"float",message:a.message}),o.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="multipleOf"?B8(t.data,a.value)!==0&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{code:fe.not_finite,message:a.message}),o.dirty()):rt.assertNever(a);return{status:o.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,Pe.toString(e))}gt(t,e){return this.setLimit("min",t,!1,Pe.toString(e))}lte(t,e){return this.setLimit("max",t,!0,Pe.toString(e))}lt(t,e){return this.setLimit("max",t,!1,Pe.toString(e))}setLimit(t,e,r,o){return new hu({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:Pe.toString(o)}]})}_addCheck(t){return new hu({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Pe.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Pe.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Pe.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Pe.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Pe.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:Pe.toString(e)})}finite(t){return this._addCheck({kind:"finite",message:Pe.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Pe.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Pe.toString(t)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&rt.isInteger(t.value))}get isFinite(){let t=null,e=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(e===null||r.value>e)&&(e=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(e)&&Number.isFinite(t)}}hu.create=n=>new hu({checks:[],typeName:Le.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...Ke(n)});class pu extends tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Ee.bigint)return this._getInvalidInput(t);let r;const o=new Hn;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):rt.assertNever(a);return{status:o.value,value:t.data}}_getInvalidInput(t){const e=this._getOrReturnCtx(t);return be(e,{code:fe.invalid_type,expected:Ee.bigint,received:e.parsedType}),Re}gte(t,e){return this.setLimit("min",t,!0,Pe.toString(e))}gt(t,e){return this.setLimit("min",t,!1,Pe.toString(e))}lte(t,e){return this.setLimit("max",t,!0,Pe.toString(e))}lt(t,e){return this.setLimit("max",t,!1,Pe.toString(e))}setLimit(t,e,r,o){return new pu({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:Pe.toString(o)}]})}_addCheck(t){return new pu({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Pe.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Pe.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Pe.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Pe.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:Pe.toString(e)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}pu.create=n=>new pu({checks:[],typeName:Le.ZodBigInt,coerce:(n==null?void 0:n.coerce)??!1,...Ke(n)});class Ex extends tt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Ee.boolean){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.boolean,received:r.parsedType}),Re}return Qn(t.data)}}Ex.create=n=>new Ex({typeName:Le.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...Ke(n)});class vu extends tt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Ee.date){const a=this._getOrReturnCtx(t);return be(a,{code:fe.invalid_type,expected:Ee.date,received:a.parsedType}),Re}if(Number.isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return be(a,{code:fe.invalid_date}),Re}const r=new Hn;let o;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(o=this._getOrReturnCtx(t,o),be(o,{code:fe.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(o=this._getOrReturnCtx(t,o),be(o,{code:fe.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):rt.assertNever(a);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new vu({...this._def,checks:[...this._def.checks,t]})}min(t,e){return this._addCheck({kind:"min",value:t.getTime(),message:Pe.toString(e)})}max(t,e){return this._addCheck({kind:"max",value:t.getTime(),message:Pe.toString(e)})}get minDate(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t!=null?new Date(t):null}}vu.create=n=>new vu({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:Le.ZodDate,...Ke(n)});class Sx extends tt{_parse(t){if(this._getType(t)!==Ee.symbol){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.symbol,received:r.parsedType}),Re}return Qn(t.data)}}Sx.create=n=>new Sx({typeName:Le.ZodSymbol,...Ke(n)});class Nx extends tt{_parse(t){if(this._getType(t)!==Ee.undefined){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.undefined,received:r.parsedType}),Re}return Qn(t.data)}}Nx.create=n=>new Nx({typeName:Le.ZodUndefined,...Ke(n)});class $x extends tt{_parse(t){if(this._getType(t)!==Ee.null){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.null,received:r.parsedType}),Re}return Qn(t.data)}}$x.create=n=>new $x({typeName:Le.ZodNull,...Ke(n)});class mu extends tt{constructor(){super(...arguments),this._any=!0}_parse(t){return Qn(t.data)}}mu.create=n=>new mu({typeName:Le.ZodAny,...Ke(n)});class kx extends tt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Qn(t.data)}}kx.create=n=>new kx({typeName:Le.ZodUnknown,...Ke(n)});class Zo extends tt{_parse(t){const e=this._getOrReturnCtx(t);return be(e,{code:fe.invalid_type,expected:Ee.never,received:e.parsedType}),Re}}Zo.create=n=>new Zo({typeName:Le.ZodNever,...Ke(n)});class Px extends tt{_parse(t){if(this._getType(t)!==Ee.undefined){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.void,received:r.parsedType}),Re}return Qn(t.data)}}Px.create=n=>new Px({typeName:Le.ZodVoid,...Ke(n)});class Hr extends tt{_parse(t){const{ctx:e,status:r}=this._processInputParams(t),o=this._def;if(e.parsedType!==Ee.array)return be(e,{code:fe.invalid_type,expected:Ee.array,received:e.parsedType}),Re;if(o.exactLength!==null){const i=e.data.length>o.exactLength.value,s=e.data.length<o.exactLength.value;(i||s)&&(be(e,{code:i?fe.too_big:fe.too_small,minimum:s?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),r.dirty())}if(o.minLength!==null&&e.data.length<o.minLength.value&&(be(e,{code:fe.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&e.data.length>o.maxLength.value&&(be(e,{code:fe.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),r.dirty()),e.common.async)return Promise.all([...e.data].map((i,s)=>o.type._parseAsync(new Yo(e,i,e.path,s)))).then(i=>Hn.mergeArray(r,i));const a=[...e.data].map((i,s)=>o.type._parseSync(new Yo(e,i,e.path,s)));return Hn.mergeArray(r,a)}get element(){return this._def.type}min(t,e){return new Hr({...this._def,minLength:{value:t,message:Pe.toString(e)}})}max(t,e){return new Hr({...this._def,maxLength:{value:t,message:Pe.toString(e)}})}length(t,e){return new Hr({...this._def,exactLength:{value:t,message:Pe.toString(e)}})}nonempty(t){return this.min(1,t)}}Hr.create=(n,t)=>new Hr({type:n,minLength:null,maxLength:null,exactLength:null,typeName:Le.ZodArray,...Ke(t)});function zi(n){if(n instanceof Ft){const t={};for(const e in n.shape){const r=n.shape[e];t[e]=Qo.create(zi(r))}return new Ft({...n._def,shape:()=>t})}else return n instanceof Hr?new Hr({...n._def,type:zi(n.element)}):n instanceof Qo?Qo.create(zi(n.unwrap())):n instanceof qi?qi.create(zi(n.unwrap())):n instanceof ja?ja.create(n.items.map(t=>zi(t))):n}class Ft extends tt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),e=rt.objectKeys(t);return this._cached={shape:t,keys:e},this._cached}_parse(t){if(this._getType(t)!==Ee.object){const c=this._getOrReturnCtx(t);return be(c,{code:fe.invalid_type,expected:Ee.object,received:c.parsedType}),Re}const{status:r,ctx:o}=this._processInputParams(t),{shape:a,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof Zo&&this._def.unknownKeys==="strip"))for(const c in o.data)i.includes(c)||s.push(c);const u=[];for(const c of i){const l=a[c],d=o.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new Yo(o,d,o.path,c)),alwaysSet:c in o.data})}if(this._def.catchall instanceof Zo){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of s)u.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(c==="strict")s.length>0&&(be(o,{code:fe.unrecognized_keys,keys:s}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of s){const d=o.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new Yo(o,d,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of u){const d=await l.key,f=await l.value;c.push({key:d,value:f,alwaysSet:l.alwaysSet})}return c}).then(c=>Hn.mergeObjectSync(r,c)):Hn.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(t){return Pe.errToObj,new Ft({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(e,r)=>{var a,i;const o=((i=(a=this._def).errorMap)==null?void 0:i.call(a,e,r).message)??r.defaultError;return e.code==="unrecognized_keys"?{message:Pe.errToObj(t).message??o}:{message:o}}}:{}})}strip(){return new Ft({...this._def,unknownKeys:"strip"})}passthrough(){return new Ft({...this._def,unknownKeys:"passthrough"})}extend(t){return new Ft({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Ft({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Le.ZodObject})}setKey(t,e){return this.augment({[t]:e})}catchall(t){return new Ft({...this._def,catchall:t})}pick(t){const e={};for(const r of rt.objectKeys(t))t[r]&&this.shape[r]&&(e[r]=this.shape[r]);return new Ft({...this._def,shape:()=>e})}omit(t){const e={};for(const r of rt.objectKeys(this.shape))t[r]||(e[r]=this.shape[r]);return new Ft({...this._def,shape:()=>e})}deepPartial(){return zi(this)}partial(t){const e={};for(const r of rt.objectKeys(this.shape)){const o=this.shape[r];t&&!t[r]?e[r]=o:e[r]=o.optional()}return new Ft({...this._def,shape:()=>e})}required(t){const e={};for(const r of rt.objectKeys(this.shape))if(t&&!t[r])e[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof Qo;)a=a._def.innerType;e[r]=a}return new Ft({...this._def,shape:()=>e})}keyof(){return Tx(rt.objectKeys(this.shape))}}Ft.create=(n,t)=>new Ft({shape:()=>n,unknownKeys:"strip",catchall:Zo.create(),typeName:Le.ZodObject,...Ke(t)}),Ft.strictCreate=(n,t)=>new Ft({shape:()=>n,unknownKeys:"strict",catchall:Zo.create(),typeName:Le.ZodObject,...Ke(t)}),Ft.lazycreate=(n,t)=>new Ft({shape:n,unknownKeys:"strip",catchall:Zo.create(),typeName:Le.ZodObject,...Ke(t)});class Fl extends tt{_parse(t){const{ctx:e}=this._processInputParams(t),r=this._def.options;function o(a){for(const s of a)if(s.result.status==="valid")return s.result;for(const s of a)if(s.result.status==="dirty")return e.common.issues.push(...s.ctx.common.issues),s.result;const i=a.map(s=>new vo(s.ctx.common.issues));return be(e,{code:fe.invalid_union,unionErrors:i}),Re}if(e.common.async)return Promise.all(r.map(async a=>{const i={...e,common:{...e.common,issues:[]},parent:null};return{result:await a._parseAsync({data:e.data,path:e.path,parent:i}),ctx:i}})).then(o);{let a;const i=[];for(const u of r){const c={...e,common:{...e.common,issues:[]},parent:null},l=u._parseSync({data:e.data,path:e.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(a)return e.common.issues.push(...a.ctx.common.issues),a.result;const s=i.map(u=>new vo(u));return be(e,{code:fe.invalid_union,unionErrors:s}),Re}}get options(){return this._def.options}}Fl.create=(n,t)=>new Fl({options:n,typeName:Le.ZodUnion,...Ke(t)});function Vp(n,t){const e=Ko(n),r=Ko(t);if(n===t)return{valid:!0,data:n};if(e===Ee.object&&r===Ee.object){const o=rt.objectKeys(t),a=rt.objectKeys(n).filter(s=>o.indexOf(s)!==-1),i={...n,...t};for(const s of a){const u=Vp(n[s],t[s]);if(!u.valid)return{valid:!1};i[s]=u.data}return{valid:!0,data:i}}else if(e===Ee.array&&r===Ee.array){if(n.length!==t.length)return{valid:!1};const o=[];for(let a=0;a<n.length;a++){const i=n[a],s=t[a],u=Vp(i,s);if(!u.valid)return{valid:!1};o.push(u.data)}return{valid:!0,data:o}}else return e===Ee.date&&r===Ee.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}class Rl extends tt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t),o=(a,i)=>{if(bx(a)||bx(i))return Re;const s=Vp(a.value,i.value);return s.valid?((xx(a)||xx(i))&&e.dirty(),{status:e.value,value:s.data}):(be(r,{code:fe.invalid_intersection_types}),Re)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>o(a,i)):o(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Rl.create=(n,t,e)=>new Rl({left:n,right:t,typeName:Le.ZodIntersection,...Ke(e)});class ja extends tt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Ee.array)return be(r,{code:fe.invalid_type,expected:Ee.array,received:r.parsedType}),Re;if(r.data.length<this._def.items.length)return be(r,{code:fe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Re;!this._def.rest&&r.data.length>this._def.items.length&&(be(r,{code:fe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());const a=[...r.data].map((i,s)=>{const u=this._def.items[s]||this._def.rest;return u?u._parse(new Yo(r,i,r.path,s)):null}).filter(i=>!!i);return r.common.async?Promise.all(a).then(i=>Hn.mergeArray(e,i)):Hn.mergeArray(e,a)}get items(){return this._def.items}rest(t){return new ja({...this._def,rest:t})}}ja.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ja({items:n,typeName:Le.ZodTuple,rest:null,...Ke(t)})};class Ix extends tt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Ee.map)return be(r,{code:fe.invalid_type,expected:Ee.map,received:r.parsedType}),Re;const o=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([s,u],c)=>({key:o._parse(new Yo(r,s,r.path,[c,"key"])),value:a._parse(new Yo(r,u,r.path,[c,"value"]))}));if(r.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const u of i){const c=await u.key,l=await u.value;if(c.status==="aborted"||l.status==="aborted")return Re;(c.status==="dirty"||l.status==="dirty")&&e.dirty(),s.set(c.value,l.value)}return{status:e.value,value:s}})}else{const s=new Map;for(const u of i){const c=u.key,l=u.value;if(c.status==="aborted"||l.status==="aborted")return Re;(c.status==="dirty"||l.status==="dirty")&&e.dirty(),s.set(c.value,l.value)}return{status:e.value,value:s}}}}Ix.create=(n,t,e)=>new Ix({valueType:t,keyType:n,typeName:Le.ZodMap,...Ke(e)});class gu extends tt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Ee.set)return be(r,{code:fe.invalid_type,expected:Ee.set,received:r.parsedType}),Re;const o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(be(r,{code:fe.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),e.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(be(r,{code:fe.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),e.dirty());const a=this._def.valueType;function i(u){const c=new Set;for(const l of u){if(l.status==="aborted")return Re;l.status==="dirty"&&e.dirty(),c.add(l.value)}return{status:e.value,value:c}}const s=[...r.data.values()].map((u,c)=>a._parse(new Yo(r,u,r.path,c)));return r.common.async?Promise.all(s).then(u=>i(u)):i(s)}min(t,e){return new gu({...this._def,minSize:{value:t,message:Pe.toString(e)}})}max(t,e){return new gu({...this._def,maxSize:{value:t,message:Pe.toString(e)}})}size(t,e){return this.min(t,e).max(t,e)}nonempty(t){return this.min(1,t)}}gu.create=(n,t)=>new gu({valueType:n,minSize:null,maxSize:null,typeName:Le.ZodSet,...Ke(t)});class Ax extends tt{get schema(){return this._def.getter()}_parse(t){const{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}}Ax.create=(n,t)=>new Ax({getter:n,typeName:Le.ZodLazy,...Ke(t)});class jp extends tt{_parse(t){if(t.data!==this._def.value){const e=this._getOrReturnCtx(t);return be(e,{received:e.data,code:fe.invalid_literal,expected:this._def.value}),Re}return{status:"valid",value:t.data}}get value(){return this._def.value}}jp.create=(n,t)=>new jp({value:n,typeName:Le.ZodLiteral,...Ke(t)});function Tx(n,t){return new Hi({values:n,typeName:Le.ZodEnum,...Ke(t)})}class Hi extends tt{_parse(t){if(typeof t.data!="string"){const e=this._getOrReturnCtx(t),r=this._def.values;return be(e,{expected:rt.joinValues(r),received:e.parsedType,code:fe.invalid_type}),Re}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const e=this._getOrReturnCtx(t),r=this._def.values;return be(e,{received:e.data,code:fe.invalid_enum_value,options:r}),Re}return Qn(t.data)}get options(){return this._def.values}get enum(){const t={};for(const e of this._def.values)t[e]=e;return t}get Values(){const t={};for(const e of this._def.values)t[e]=e;return t}get Enum(){const t={};for(const e of this._def.values)t[e]=e;return t}extract(t,e=this._def){return Hi.create(t,{...this._def,...e})}exclude(t,e=this._def){return Hi.create(this.options.filter(r=>!t.includes(r)),{...this._def,...e})}}Hi.create=Tx;class Ox extends tt{_parse(t){const e=rt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==Ee.string&&r.parsedType!==Ee.number){const o=rt.objectValues(e);return be(r,{expected:rt.joinValues(o),received:r.parsedType,code:fe.invalid_type}),Re}if(this._cache||(this._cache=new Set(rt.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const o=rt.objectValues(e);return be(r,{received:r.data,code:fe.invalid_enum_value,options:o}),Re}return Qn(t.data)}get enum(){return this._def.values}}Ox.create=(n,t)=>new Ox({values:n,typeName:Le.ZodNativeEnum,...Ke(t)});class Ll extends tt{unwrap(){return this._def.type}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==Ee.promise&&e.common.async===!1)return be(e,{code:fe.invalid_type,expected:Ee.promise,received:e.parsedType}),Re;const r=e.parsedType===Ee.promise?e.data:Promise.resolve(e.data);return Qn(r.then(o=>this._def.type.parseAsync(o,{path:e.path,errorMap:e.common.contextualErrorMap})))}}Ll.create=(n,t)=>new Ll({type:n,typeName:Le.ZodPromise,...Ke(t)});class Gi extends tt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Le.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:e,ctx:r}=this._processInputParams(t),o=this._def.effect||null,a={addIssue:i=>{be(r,i),i.fatal?e.abort():e.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),o.type==="preprocess"){const i=o.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(async s=>{if(e.value==="aborted")return Re;const u=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return u.status==="aborted"?Re:u.status==="dirty"||e.value==="dirty"?fu(u.value):u});{if(e.value==="aborted")return Re;const s=this._def.schema._parseSync({data:i,path:r.path,parent:r});return s.status==="aborted"?Re:s.status==="dirty"||e.value==="dirty"?fu(s.value):s}}if(o.type==="refinement"){const i=s=>{const u=o.refinement(s,a);if(r.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Re:(s.status==="dirty"&&e.dirty(),i(s.value),{status:e.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?Re:(s.status==="dirty"&&e.dirty(),i(s.value).then(()=>({status:e.value,value:s.value}))))}if(o.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ui(i))return Re;const s=o.transform(i.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>Ui(i)?Promise.resolve(o.transform(i.value,a)).then(s=>({status:e.value,value:s})):Re);rt.assertNever(o)}}Gi.create=(n,t,e)=>new Gi({schema:n,typeName:Le.ZodEffects,effect:t,...Ke(e)}),Gi.createWithPreprocess=(n,t,e)=>new Gi({schema:t,effect:{type:"preprocess",transform:n},typeName:Le.ZodEffects,...Ke(e)});class Qo extends tt{_parse(t){return this._getType(t)===Ee.undefined?Qn(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Qo.create=(n,t)=>new Qo({innerType:n,typeName:Le.ZodOptional,...Ke(t)});class qi extends tt{_parse(t){return this._getType(t)===Ee.null?Qn(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}qi.create=(n,t)=>new qi({innerType:n,typeName:Le.ZodNullable,...Ke(t)});class Up extends tt{_parse(t){const{ctx:e}=this._processInputParams(t);let r=e.data;return e.parsedType===Ee.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:e.path,parent:e})}removeDefault(){return this._def.innerType}}Up.create=(n,t)=>new Up({innerType:n,typeName:Le.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ke(t)});class zp extends tt{_parse(t){const{ctx:e}=this._processInputParams(t),r={...e,common:{...e.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ml(o)?o.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new vo(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new vo(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}zp.create=(n,t)=>new zp({innerType:n,typeName:Le.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ke(t)});class Dx extends tt{_parse(t){if(this._getType(t)!==Ee.nan){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.nan,received:r.parsedType}),Re}return{status:"valid",value:t.data}}}Dx.create=n=>new Dx({typeName:Le.ZodNaN,...Ke(n)});class W8 extends tt{_parse(t){const{ctx:e}=this._processInputParams(t),r=e.data;return this._def.type._parse({data:r,path:e.path,parent:e})}unwrap(){return this._def.type}}class Hp extends tt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Re:a.status==="dirty"?(e.dirty(),fu(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?Re:o.status==="dirty"?(e.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(t,e){return new Hp({in:t,out:e,typeName:Le.ZodPipeline})}}class Gp extends tt{_parse(t){const e=this._def.innerType._parse(t),r=o=>(Ui(o)&&(o.value=Object.freeze(o.value)),o);return Ml(e)?e.then(o=>r(o)):r(e)}unwrap(){return this._def.innerType}}Gp.create=(n,t)=>new Gp({innerType:n,typeName:Le.ZodReadonly,...Ke(t)});function Mx(n,t){const e=typeof n=="function"?n(t):typeof n=="string"?{message:n}:n;return typeof e=="string"?{message:e}:e}function V8(n,t={},e){return n?mu.create().superRefine((r,o)=>{const a=n(r);if(a instanceof Promise)return a.then(i=>{if(!i){const s=Mx(t,r),u=s.fatal??e??!0;o.addIssue({code:"custom",...s,fatal:u})}});if(!a){const i=Mx(t,r),s=i.fatal??e??!0;o.addIssue({code:"custom",...i,fatal:s})}}):mu.create()}var Le;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(Le||(Le={}));const qp=(n,t={message:`Input not instance of ${n.name}`})=>V8(e=>e instanceof n,t),Xt=Xo.create,Fx=vu.create;mu.create,Zo.create,Hr.create;const yu=Ft.create;Fl.create,Rl.create,ja.create;const j8=jp.create;Hi.create,Ll.create,Qo.create,qi.create;const bu=KD,Rx=k.createContext({}),Tt=({...n})=>b.jsx(Rx.Provider,{value:{name:n.name},children:b.jsx(ZD,{...n})}),Bl=()=>{const n=k.useContext(Rx),t=k.useContext(Lx),{getFieldState:e,formState:r}=Tl(),o=e(n.name,r);if(!n)throw new Error("useFormField should be used within <FormField>");const{id:a}=t;return{id:a,name:n.name,formItemId:`${a}-form-item`,formDescriptionId:`${a}-form-item-description`,formMessageId:`${a}-form-item-message`,...o}},Lx=k.createContext({}),St=k.forwardRef(({className:n,...t},e)=>{const r=k.useId();return b.jsx(Lx.Provider,{value:{id:r},children:b.jsx("div",{ref:e,className:Be("space-y-2",n),...t})})});St.displayName="FormItem";const Nt=k.forwardRef(({className:n,...t},e)=>{const{error:r,formItemId:o}=Bl();return b.jsx(Ea,{ref:e,className:Be(r&&"text-destructive",n),htmlFor:o,...t})});Nt.displayName="FormLabel";const $t=k.forwardRef(({...n},t)=>{const{error:e,formItemId:r,formDescriptionId:o,formMessageId:a}=Bl();return b.jsx(Vm,{ref:t,id:r,"aria-describedby":e?`${o} ${a}`:`${o}`,"aria-invalid":!!e,...n})});$t.displayName="FormControl";const U8=k.forwardRef(({className:n,...t},e)=>{const{formDescriptionId:r}=Bl();return b.jsx("p",{ref:e,id:r,className:Be("text-sm text-muted-foreground",n),...t})});U8.displayName="FormDescription";const kt=k.forwardRef(({className:n,children:t,...e},r)=>{const{error:o,formMessageId:a}=Bl(),i=o?String(o==null?void 0:o.message):t;return i?b.jsx("p",{ref:r,id:a,className:Be("text-sm font-medium text-destructive",n),...e,children:i}):null});kt.displayName="FormMessage";const z8=yu({bank_statement:qp(File).optional().refine(n=>n!==void 0,"Bank statement is required"),company_structure:qp(File).optional().refine(n=>n!==void 0,"Company structure document is required"),certificate_of_registration:qp(File).optional().refine(n=>n!==void 0,"Certificate of registration is required")}),H8=({data:n,onDataChange:t,onContinue:e,onBack:r,renderProgress:o})=>{const a=D.useRef(null),i=D.useRef(null),s=D.useRef(null),u=lu({resolver:du(z8),defaultValues:{bank_statement:n.bank_statement||void 0,company_structure:n.company_structure||void 0,certificate_of_registration:n.certificate_of_registration||void 0}}),c=f=>{t(f),e()},l=(f,h)=>{u.setValue(f,h),t({[f]:h})},d=({field:f,label:h,description:m,inputRef:p})=>{const v=u.watch(f);return b.jsx(Tt,{control:u.control,name:f,render:()=>b.jsxs(St,{children:[b.jsx(Nt,{children:h}),b.jsx($t,{children:b.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-6",children:[b.jsx("input",{ref:p,type:"file",accept:".pdf,.jpg,.jpeg,.png,.doc,.docx",className:"hidden",onChange:g=>{var w;const y=((w=g.target.files)==null?void 0:w[0])||null;l(f,y)}}),v?b.jsxs("div",{className:"flex items-center justify-between",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(nE,{className:"w-5 h-5 text-primary"}),b.jsx("span",{className:"text-sm font-medium",children:v.name})]}),b.jsx(_t,{type:"button",variant:"ghost",size:"sm",onClick:()=>{l(f,null),p.current&&(p.current.value="")},children:b.jsx(Md,{className:"w-4 h-4"})})]}):b.jsxs("div",{className:"text-center cursor-pointer",onClick:()=>{var g;return(g=p.current)==null?void 0:g.click()},children:[b.jsx(oE,{className:"w-8 h-8 mx-auto mb-2 text-muted-foreground"}),b.jsx("p",{className:"font-medium",children:h}),b.jsx("p",{className:"text-sm text-muted-foreground",children:m}),b.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Supported: PDF, JPG, PNG, DOC, DOCX"})]})]})}),b.jsx(kt,{})]})})};return b.jsxs(hn,{className:"w-full max-w-2xl mx-auto",children:[b.jsx(Oo,{children:b.jsx(Do,{title:"Company Documents",subTitle:"Please upload the required company documents",onBack:r})}),b.jsxs(pn,{children:[b.jsx(bu,{...u,children:b.jsxs("form",{onSubmit:u.handleSubmit(c),className:"space-y-6",children:[b.jsx(d,{field:"bank_statement",label:"Bank Statement",description:"Upload your latest bank statement",inputRef:a}),b.jsx(d,{field:"company_structure",label:"Company Structure",description:"Upload document showing directors & legal representatives",inputRef:i}),b.jsx(d,{field:"certificate_of_registration",label:"Certificate of Registration",description:"Upload your company's certificate of registration",inputRef:s}),b.jsx(_t,{type:"submit",className:"w-full",children:"Complete Verification"})]})}),b.jsx("div",{className:"mt-6",children:o()})]})]})};function Bx(n,[t,e]){return Math.min(e,Math.max(t,n))}var G8=k.createContext(void 0);function q8(n){const t=k.useContext(G8);return n||t||"ltr"}var Kp=0;function Wx(){k.useEffect(()=>{const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",n[0]??Vx()),document.body.insertAdjacentElement("beforeend",n[1]??Vx()),Kp++,()=>{Kp===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Kp--}},[])}function Vx(){const n=document.createElement("span");return n.setAttribute("data-radix-focus-guard",""),n.tabIndex=0,n.style.outline="none",n.style.opacity="0",n.style.position="fixed",n.style.pointerEvents="none",n}var Yp="focusScope.autoFocusOnMount",Xp="focusScope.autoFocusOnUnmount",jx={bubbles:!1,cancelable:!0},K8="FocusScope",Zp=k.forwardRef((n,t)=>{const{loop:e=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=n,[s,u]=k.useState(null),c=tr(o),l=tr(a),d=k.useRef(null),f=mt(t,p=>u(p)),h=k.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;k.useEffect(()=>{if(r){let p=function(w){if(h.paused||!s)return;const x=w.target;s.contains(x)?d.current=x:Jo(d.current,{select:!0})},v=function(w){if(h.paused||!s)return;const x=w.relatedTarget;x!==null&&(s.contains(x)||Jo(d.current,{select:!0}))},g=function(w){if(document.activeElement===document.body)for(const C of w)C.removedNodes.length>0&&Jo(s)};document.addEventListener("focusin",p),document.addEventListener("focusout",v);const y=new MutationObserver(g);return s&&y.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",v),y.disconnect()}}},[r,s,h.paused]),k.useEffect(()=>{if(s){Hx.add(h);const p=document.activeElement;if(!s.contains(p)){const g=new CustomEvent(Yp,jx);s.addEventListener(Yp,c),s.dispatchEvent(g),g.defaultPrevented||(Y8(eM(Ux(s)),{select:!0}),document.activeElement===p&&Jo(s))}return()=>{s.removeEventListener(Yp,c),setTimeout(()=>{const g=new CustomEvent(Xp,jx);s.addEventListener(Xp,l),s.dispatchEvent(g),g.defaultPrevented||Jo(p??document.body,{select:!0}),s.removeEventListener(Xp,l),Hx.remove(h)},0)}}},[s,c,l,h]);const m=k.useCallback(p=>{if(!e&&!r||h.paused)return;const v=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,g=document.activeElement;if(v&&g){const y=p.currentTarget,[w,x]=X8(y);w&&x?!p.shiftKey&&g===x?(p.preventDefault(),e&&Jo(w,{select:!0})):p.shiftKey&&g===w&&(p.preventDefault(),e&&Jo(x,{select:!0})):g===y&&p.preventDefault()}},[e,r,h.paused]);return b.jsx(et.div,{tabIndex:-1,...i,ref:f,onKeyDown:m})});Zp.displayName=K8;function Y8(n,{select:t=!1}={}){const e=document.activeElement;for(const r of n)if(Jo(r,{select:t}),document.activeElement!==e)return}function X8(n){const t=Ux(n),e=zx(t,n),r=zx(t.reverse(),n);return[e,r]}function Ux(n){const t=[],e=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;e.nextNode();)t.push(e.currentNode);return t}function zx(n,t){for(const e of n)if(!Z8(e,{upTo:t}))return e}function Z8(n,{upTo:t}){if(getComputedStyle(n).visibility==="hidden")return!0;for(;n;){if(t!==void 0&&n===t)return!1;if(getComputedStyle(n).display==="none")return!0;n=n.parentElement}return!1}function Q8(n){return n instanceof HTMLInputElement&&"select"in n}function Jo(n,{select:t=!1}={}){if(n&&n.focus){const e=document.activeElement;n.focus({preventScroll:!0}),n!==e&&Q8(n)&&t&&n.select()}}var Hx=J8();function J8(){let n=[];return{add(t){const e=n[0];t!==e&&(e==null||e.pause()),n=Gx(n,t),n.unshift(t)},remove(t){var e;n=Gx(n,t),(e=n[0])==null||e.resume()}}}function Gx(n,t){const e=[...n],r=e.indexOf(t);return r!==-1&&e.splice(r,1),e}function eM(n){return n.filter(t=>t.tagName!=="A")}function tM(n){const t=k.useRef({value:n,previous:n});return k.useMemo(()=>(t.current.value!==n&&(t.current.previous=t.current.value,t.current.value=n),t.current.previous),[n])}var nM=function(n){if(typeof document>"u")return null;var t=Array.isArray(n)?n[0]:n;return t.ownerDocument.body},Ki=new WeakMap,Wl=new WeakMap,Vl={},Qp=0,qx=function(n){return n&&(n.host||qx(n.parentNode))},rM=function(n,t){return t.map(function(e){if(n.contains(e))return e;var r=qx(e);return r&&n.contains(r)?r:(console.error("aria-hidden",e,"in not contained inside",n,". Doing nothing"),null)}).filter(function(e){return!!e})},oM=function(n,t,e,r){var o=rM(t,Array.isArray(n)?n:[n]);Vl[e]||(Vl[e]=new WeakMap);var a=Vl[e],i=[],s=new Set,u=new Set(o),c=function(d){!d||s.has(d)||(s.add(d),c(d.parentNode))};o.forEach(c);var l=function(d){!d||u.has(d)||Array.prototype.forEach.call(d.children,function(f){if(s.has(f))l(f);else try{var h=f.getAttribute(r),m=h!==null&&h!=="false",p=(Ki.get(f)||0)+1,v=(a.get(f)||0)+1;Ki.set(f,p),a.set(f,v),i.push(f),p===1&&m&&Wl.set(f,!0),v===1&&f.setAttribute(e,"true"),m||f.setAttribute(r,"true")}catch(g){console.error("aria-hidden: cannot operate on ",f,g)}})};return l(t),s.clear(),Qp++,function(){i.forEach(function(d){var f=Ki.get(d)-1,h=a.get(d)-1;Ki.set(d,f),a.set(d,h),f||(Wl.has(d)||d.removeAttribute(r),Wl.delete(d)),h||d.removeAttribute(e)}),Qp--,Qp||(Ki=new WeakMap,Ki=new WeakMap,Wl=new WeakMap,Vl={})}},Kx=function(n,t,e){e===void 0&&(e="data-aria-hidden");var r=Array.from(Array.isArray(n)?n:[n]),o=nM(n);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),oM(r,o,e,"aria-hidden")):function(){return null}},Gr=function(){return Gr=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},Gr.apply(this,arguments)};function Yx(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(n);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(n,r[o])&&(e[r[o]]=n[r[o]]);return e}function aM(n,t,e){if(e||arguments.length===2)for(var r=0,o=t.length,a;r<o;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return n.concat(a||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var jl="right-scroll-bar-position",Ul="width-before-scroll-bar",iM="with-scroll-bars-hidden",sM="--removed-body-scroll-bar-size";function Jp(n,t){return typeof n=="function"?n(t):n&&(n.current=t),n}function uM(n,t){var e=D.useState(function(){return{value:n,callback:t,facade:{get current(){return e.value},set current(r){var o=e.value;o!==r&&(e.value=r,e.callback(r,o))}}}})[0];return e.callback=t,e.facade}var cM=typeof window<"u"?k.useLayoutEffect:k.useEffect,Xx=new WeakMap;function lM(n,t){var e=uM(null,function(r){return n.forEach(function(o){return Jp(o,r)})});return cM(function(){var r=Xx.get(e);if(r){var o=new Set(r),a=new Set(n),i=e.current;o.forEach(function(s){a.has(s)||Jp(s,null)}),a.forEach(function(s){o.has(s)||Jp(s,i)})}Xx.set(e,n)},[n]),e}function dM(n){return n}function fM(n,t){t===void 0&&(t=dM);var e=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return e.length?e[e.length-1]:n},useMedium:function(a){var i=t(a,r);return e.push(i),function(){e=e.filter(function(s){return s!==i})}},assignSyncMedium:function(a){for(r=!0;e.length;){var i=e;e=[],i.forEach(a)}e={push:function(s){return a(s)},filter:function(){return e}}},assignMedium:function(a){r=!0;var i=[];if(e.length){var s=e;e=[],s.forEach(a),i=e}var u=function(){var l=i;i=[],l.forEach(a)},c=function(){return Promise.resolve().then(u)};c(),e={push:function(l){i.push(l),c()},filter:function(l){return i=i.filter(l),e}}}};return o}function hM(n){n===void 0&&(n={});var t=fM(null);return t.options=Gr({async:!0,ssr:!1},n),t}var Zx=function(n){var t=n.sideCar,e=Yx(n,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return k.createElement(r,Gr({},e))};Zx.isSideCarExport=!0;function pM(n,t){return n.useMedium(t),Zx}var Qx=hM(),ev=function(){},zl=k.forwardRef(function(n,t){var e=k.useRef(null),r=k.useState({onScrollCapture:ev,onWheelCapture:ev,onTouchMoveCapture:ev}),o=r[0],a=r[1],i=n.forwardProps,s=n.children,u=n.className,c=n.removeScrollBar,l=n.enabled,d=n.shards,f=n.sideCar,h=n.noRelative,m=n.noIsolation,p=n.inert,v=n.allowPinchZoom,g=n.as,y=g===void 0?"div":g,w=n.gapMode,x=Yx(n,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=f,_=lM([e,t]),E=Gr(Gr({},x),o);return k.createElement(k.Fragment,null,l&&k.createElement(C,{sideCar:Qx,removeScrollBar:c,shards:d,noRelative:h,noIsolation:m,inert:p,setCallbacks:a,allowPinchZoom:!!v,lockRef:e,gapMode:w}),i?k.cloneElement(k.Children.only(s),Gr(Gr({},E),{ref:_})):k.createElement(y,Gr({},E,{className:u,ref:_}),s))});zl.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},zl.classNames={fullWidth:Ul,zeroRight:jl};var vM=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function mM(){if(!document)return null;var n=document.createElement("style");n.type="text/css";var t=vM();return t&&n.setAttribute("nonce",t),n}function gM(n,t){n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}function yM(n){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(n)}var bM=function(){var n=0,t=null;return{add:function(e){n==0&&(t=mM())&&(gM(t,e),yM(t)),n++},remove:function(){n--,!n&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},xM=function(){var n=bM();return function(t,e){k.useEffect(function(){return n.add(t),function(){n.remove()}},[t&&e])}},Jx=function(){var n=xM(),t=function(e){var r=e.styles,o=e.dynamic;return n(r,o),null};return t},wM={left:0,top:0,right:0,gap:0},tv=function(n){return parseInt(n||"",10)||0},CM=function(n){var t=window.getComputedStyle(document.body),e=t[n==="padding"?"paddingLeft":"marginLeft"],r=t[n==="padding"?"paddingTop":"marginTop"],o=t[n==="padding"?"paddingRight":"marginRight"];return[tv(e),tv(r),tv(o)]},_M=function(n){if(n===void 0&&(n="margin"),typeof window>"u")return wM;var t=CM(n),e=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-e+t[2]-t[0])}},EM=Jx(),Yi="data-scroll-locked",SM=function(n,t,e,r){var o=n.left,a=n.top,i=n.right,s=n.gap;return e===void 0&&(e="margin"),`
|
|
3930
3930
|
.`.concat(iM,` {
|
|
3931
3931
|
overflow: hidden `).concat(r,`;
|
|
3932
3932
|
padding-right: `).concat(s,"px ").concat(r,`;
|
|
@@ -4011,4 +4011,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
4011
4011
|
- less than the value passed to \`max\` (or ${Sm} if no \`max\` prop is set)
|
|
4012
4012
|
- \`null\` or \`undefined\` if the progress is indeterminate.
|
|
4013
4013
|
|
|
4014
|
-
Defaulting to \`null\`.`}var L_=T_,oz=D_;const B_=k.forwardRef(({className:n,value:t,...e},r)=>b.jsx(L_,{ref:r,className:Be("relative h-4 w-full overflow-hidden rounded-full bg-secondary",n),...e,children:b.jsx(oz,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));B_.displayName=L_.displayName;const az=({apiEndpoint:n,apiKey:t,onComplete:e,onDoneClick:r})=>{const[o,a]=D.useState("landing"),i=D.useRef(!1),[s,u]=D.useState({full_name:"",title:"",birth:null,phone_number:"",selfie_photo:null,id_photo:null,id_photo_back:null}),[c,l]=D.useState(""),[d,f]=D.useState({registration_number:"",country:"",company_name:"",tax_identity_number:"",corporate_type:"",date_of_establishment:null}),[h,m]=D.useState({street:"",number:"",postal_code:"",city:"",address_country:"",state:""}),[p,v]=D.useState({industry:"",business_model:"",annual_sales_volume:"",website_url:""}),[g,y]=D.useState({bank_statement:null,company_structure:null,certificate_of_registration:null}),w=["personal-details","id-front","id-back","pre-selfie","selfie","business-information","business-address","company-activity","company-documents"],x=X0({mutationFn:iz}),{toast:C}=Qu(),_=()=>o==="landing"||o==="processing"?-1:w.indexOf(o),E=()=>{const A=_();return A===-1?0:(A+1)/w.length*100},S=async()=>{if(x.isPending||i.current){console.log("return");return}const A={personal_details:s,business_information:d,business_address:h,company_activity:p,company_documents:g},P=await x.mutateAsync({apiEndpoint:n,apiKey:t,data:A});i.current=!0,e(P.data.token,A),C({title:"Business verification submitted!",description:"Your business verification request has been submitted successfully."}),u({full_name:"",title:"",birth:null,phone_number:"",selfie_photo:null,id_photo:null,id_photo_back:null}),f({registration_number:"",country:"",company_name:"",tax_identity_number:"",corporate_type:"",date_of_establishment:null}),m({street:"",number:"",postal_code:"",city:"",address_country:""}),v({industry:"",business_model:"",annual_sales_volume:"",website_url:""}),y({bank_statement:null,company_structure:null,certificate_of_registration:null}),a("done")},N=()=>{const A=_();return A===-1?null:b.jsxs("div",{className:"space-y-2",children:[b.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[b.jsxs("span",{children:["Step ",A+1," of ",w.length]}),b.jsxs("span",{children:[Math.round(E()),"%"]})]}),b.jsx(B_,{value:E(),className:"h-2"})]})},$=()=>{switch(o){case"landing":return b.jsx(Z0,{title:"Business Verification",subtitle:"Complete your business verification to access all features",onContinue:()=>a("personal-details")});case"personal-details":return b.jsx(ZU,{data:s,onDataChange:A=>u(P=>({...P,...A})),onContinue:()=>a("document-selection"),onBack:()=>a("landing"),renderProgress:N});case"document-selection":return b.jsx(ey,{selectedDocumentType:c,onDocumentTypeChange:l,onContinue:()=>a("id-front"),onBack:()=>a("personal-details"),renderProgress:N});case"id-front":return b.jsx(Wi,{title:`Upload ${vi.find(A=>A.id===c).title}`,description:`Place your ${vi.find(A=>A.id===c).title.toLowerCase()} inside the frame and take a picture. Make sure it is not cut or has any glare.`,frameType:"rectangular",documentTypeId:c,currentStep:o,onRetake:()=>{u(A=>({...A,id_photo:null}))},onConfirm:A=>{u(P=>({...P,id_photo:A})),a(c==="passport"?"pre-selfie":"id-back")},onBack:()=>{a("document-selection")}});case"id-back":return b.jsx(Wi,{title:`Upload ${vi.find(A=>A.id===c).title} Back`,description:`Place the back or your ${vi.find(A=>A.id===c).title.toLowerCase()} inside the frame and take a picture. Make sure it is not cut or has any glare.`,frameType:"rectangular",documentTypeId:c,currentStep:o,onRetake:()=>{u(A=>({...A,id_photo_back:null}))},onConfirm:A=>{u(P=>({...P,id_photo_back:A})),a("pre-selfie")},onBack:()=>{a("id-front")}});case"pre-selfie":return b.jsx(ty,{onContinue:()=>a("selfie"),onBack:()=>a("id-back")});case"selfie":return b.jsx(Wi,{title:"Selfie",description:"Place your face inside the frame and take a picture. Make sure it is clearly visible.",frameType:"circular",currentStep:o,onRetake:()=>{u(A=>({...A,selfie_photo:null}))},onConfirm:A=>{u(P=>({...P,selfie_photo:A})),a("business-information")},onBack:()=>{a("id-back")}});case"business-information":return b.jsx(xL,{data:d,onDataChange:A=>f(P=>({...P,...A})),onContinue:()=>a("business-address"),onBack:()=>a("selfie"),renderProgress:N});case"business-address":return b.jsx(vF,{data:h,onDataChange:A=>m(P=>({...P,...A})),onContinue:()=>a("company-activity"),onBack:()=>a("business-information"),renderProgress:N});case"company-activity":return b.jsx(fF,{data:p,onDataChange:A=>v(P=>({...P,...A})),onContinue:()=>a("company-documents"),onBack:()=>a("business-address"),renderProgress:N});case"company-documents":return b.jsx(H8,{data:g,onDataChange:A=>y(P=>({...P,...A})),onContinue:()=>a("processing"),onBack:()=>a("company-activity"),renderProgress:N});case"processing":return b.jsx(ny,{onComplete:S});case"done":return b.jsx(ry,{onDoneClick:r});default:return null}};return b.jsx("div",{className:"w-[430px]",children:$()})};async function iz({apiEndpoint:n,apiKey:t,data:e}){const{company_documents:r,personal_details:o,...a}=e,i={...o};delete i.selfie_photo,delete i.id_photo,delete i.id_photo_back;const s=new FormData;s.append("payload",sz({...a,personal_details:i})),s.append("bank_statement",r.bank_statement,r.bank_statement.name),s.append("company_structure",r.company_structure,r.company_structure.name),s.append("certificate_of_registration",r.certificate_of_registration,r.certificate_of_registration.name),s.append("selfie_photo",o.selfie_photo,o.selfie_photo.name),s.append("id_photo",o.id_photo,o.id_photo.name),s.append("id_photo_back",o.id_photo_back,o.id_photo_back.name);const u=await fetch(`${n}/api/kyb`,{method:"POST",headers:{"X-API-Key":t},body:s});if(!u.ok)throw new Error("Network response was not ok");return u.json()}function sz(n){return JSON.stringify(n,(t,e)=>e instanceof Date?e.toISOString():e)}const uz=new k$,cz=n=>b.jsx(P$,{client:uz,children:b.jsx(FD,{apiEndpoint:n.apiEndpoint,children:b.jsxs(o$,{children:[b.jsx(VE,{}),b.jsx(bS,{}),n.isKYB?b.jsx(az,{...n}):b.jsx(jD,{...n})]})})});var Uu={};Uu.createCanvas=function(n,t){return Object.assign(document.createElement("canvas"),{width:n,height:t})},Uu.createImageData=function(n,t,e){switch(arguments.length){case 0:return new ImageData;case 1:return new ImageData(n);case 2:return new ImageData(n,t);default:return new ImageData(n,t,e)}};var lz=Uu.loadImage=function(n,t){return new Promise(function(e,r){const o=Object.assign(document.createElement("img"),t);function a(){o.onload=null,o.onerror=null}o.onload=function(){a(),e(o)},o.onerror=function(){a(),r(new Error('Failed to load the image "'+n+'"'))},o.src=n})};const dz=_d({__proto__:null,default:Uu,loadImage:lz},[Uu]);return cz});
|
|
4014
|
+
Defaulting to \`null\`.`}var L_=T_,oz=D_;const B_=k.forwardRef(({className:n,value:t,...e},r)=>b.jsx(L_,{ref:r,className:Be("relative h-4 w-full overflow-hidden rounded-full bg-secondary",n),...e,children:b.jsx(oz,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));B_.displayName=L_.displayName;const az=({apiEndpoint:n,apiKey:t,onComplete:e,onDoneClick:r})=>{const[o,a]=D.useState("landing"),i=D.useRef(!1),[s,u]=D.useState({full_name:"",title:"",birth:null,phone_number:"",selfie_photo:null,id_photo:null,id_photo_back:null}),[c,l]=D.useState(""),[d,f]=D.useState({registration_number:"",country:"",company_name:"",tax_identity_number:"",corporate_type:"",date_of_establishment:null}),[h,m]=D.useState({street:"",number:"",postal_code:"",city:"",address_country:"",state:""}),[p,v]=D.useState({industry:"",business_model:"",annual_sales_volume:"",website_url:""}),[g,y]=D.useState({bank_statement:null,company_structure:null,certificate_of_registration:null}),w=["personal-details","id-front","id-back","pre-selfie","selfie","business-information","business-address","company-activity","company-documents"],x=X0({mutationFn:iz}),{toast:C}=Qu(),_=()=>o==="landing"||o==="processing"?-1:w.indexOf(o),E=()=>{const A=_();return A===-1?0:(A+1)/w.length*100},S=async()=>{if(x.isPending||i.current){console.log("return");return}const A={personal_details:s,business_information:d,business_address:h,company_activity:p,company_documents:g},P=await x.mutateAsync({apiEndpoint:n,apiKey:t,data:A});i.current=!0,e(P.data.token,A),C({title:"Business verification submitted!",description:"Your business verification request has been submitted successfully."}),u({full_name:"",title:"",birth:null,phone_number:"",selfie_photo:null,id_photo:null,id_photo_back:null}),f({registration_number:"",country:"",company_name:"",tax_identity_number:"",corporate_type:"",date_of_establishment:null}),m({street:"",number:"",postal_code:"",city:"",address_country:""}),v({industry:"",business_model:"",annual_sales_volume:"",website_url:""}),y({bank_statement:null,company_structure:null,certificate_of_registration:null}),a("done")},N=()=>{const A=_();return A===-1?null:b.jsxs("div",{className:"space-y-2",children:[b.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[b.jsxs("span",{children:["Step ",A+1," of ",w.length]}),b.jsxs("span",{children:[Math.round(E()),"%"]})]}),b.jsx(B_,{value:E(),className:"h-2"})]})},$=()=>{switch(o){case"landing":return b.jsx(Z0,{title:"Business Verification",subtitle:"Complete your business verification to access all features",onContinue:()=>a("personal-details")});case"personal-details":return b.jsx(ZU,{data:s,onDataChange:A=>u(P=>({...P,...A})),onContinue:()=>a("document-selection"),onBack:()=>a("landing"),renderProgress:N});case"document-selection":return b.jsx(ey,{selectedDocumentType:c,onDocumentTypeChange:l,onContinue:()=>a("id-front"),onBack:()=>a("personal-details"),renderProgress:N});case"id-front":return b.jsx(Wi,{title:`Upload ${vi.find(A=>A.id===c).title}`,description:`Place your ${vi.find(A=>A.id===c).title.toLowerCase()} inside the frame and take a picture. Make sure it is not cut or has any glare.`,frameType:"rectangular",documentTypeId:c,currentStep:o,onRetake:()=>{u(A=>({...A,id_photo:null}))},onConfirm:A=>{u(P=>({...P,id_photo:A})),a(c==="passport"?"pre-selfie":"id-back")},onBack:()=>{a("document-selection")}});case"id-back":return b.jsx(Wi,{title:`Upload ${vi.find(A=>A.id===c).title} Back`,description:`Place the back or your ${vi.find(A=>A.id===c).title.toLowerCase()} inside the frame and take a picture. Make sure it is not cut or has any glare.`,frameType:"rectangular",documentTypeId:c,currentStep:o,onRetake:()=>{u(A=>({...A,id_photo_back:null}))},onConfirm:A=>{u(P=>({...P,id_photo_back:A})),a("pre-selfie")},onBack:()=>{a("id-front")}});case"pre-selfie":return b.jsx(ty,{onContinue:()=>a("selfie"),onBack:()=>a("id-back")});case"selfie":return b.jsx(Wi,{title:"Selfie",description:"Place your face inside the frame and take a picture. Make sure it is clearly visible.",frameType:"circular",currentStep:o,onRetake:()=>{u(A=>({...A,selfie_photo:null}))},onConfirm:A=>{u(P=>({...P,selfie_photo:A})),a("business-information")},onBack:()=>{a("id-back")}});case"business-information":return b.jsx(xL,{data:d,onDataChange:A=>f(P=>({...P,...A})),onContinue:()=>a("business-address"),onBack:()=>a("selfie"),renderProgress:N});case"business-address":return b.jsx(vF,{data:h,onDataChange:A=>m(P=>({...P,...A})),onContinue:()=>a("company-activity"),onBack:()=>a("business-information"),renderProgress:N});case"company-activity":return b.jsx(fF,{data:p,onDataChange:A=>v(P=>({...P,...A})),onContinue:()=>a("company-documents"),onBack:()=>a("business-address"),renderProgress:N});case"company-documents":return b.jsx(H8,{data:g,onDataChange:A=>y(P=>({...P,...A})),onContinue:()=>a("processing"),onBack:()=>a("company-activity"),renderProgress:N});case"processing":return b.jsx(ny,{onComplete:S});case"done":return b.jsx(ry,{onDoneClick:r});default:return null}};return b.jsx("div",{className:"w-[430px]",children:$()})};async function iz({apiEndpoint:n,apiKey:t,data:e}){const{company_documents:r,personal_details:o,...a}=e,i={...o};delete i.selfie_photo,delete i.id_photo,delete i.id_photo_back;const s=new FormData;s.append("payload",sz({...a,personal_details:i})),s.append("bank_statement",r.bank_statement,r.bank_statement.name),s.append("company_structure",r.company_structure,r.company_structure.name),s.append("certificate_of_registration",r.certificate_of_registration,r.certificate_of_registration.name),s.append("selfie_photo",o.selfie_photo,o.selfie_photo.name),s.append("id_photo",o.id_photo,o.id_photo.name),s.append("id_photo_back",o.id_photo_back,o.id_photo_back.name);const u=await fetch(`${n}/api/kyb`,{method:"POST",headers:{"X-API-Key":t},body:s});if(!u.ok)throw new Error("Network response was not ok");return u.json()}function sz(n){return JSON.stringify(n,(t,e)=>e instanceof Date?e.toISOString():e)}const uz=new k$,cz=n=>b.jsx(P$,{client:uz,children:b.jsx(FD,{apiEndpoint:n.apiEndpoint,children:b.jsxs(o$,{children:[b.jsx(VE,{}),b.jsx(bS,{}),n.isKYB?b.jsx(az,{...n}):b.jsx(jD,{...n})]})})});var Uu={};Uu.createCanvas=function(n,t){return Object.assign(document.createElement("canvas"),{width:n,height:t})},Uu.createImageData=function(n,t,e){switch(arguments.length){case 0:return new ImageData;case 1:return new ImageData(n);case 2:return new ImageData(n,t);default:return new ImageData(n,t,e)}};var lz=Uu.loadImage=function(n,t){return new Promise(function(e,r){const o=Object.assign(document.createElement("img"),t);function a(){o.onload=null,o.onerror=null}o.onload=function(){a(),e(o)},o.onerror=function(){a(),r(new Error('Failed to load the image "'+n+'"'))},o.src=n})};const dz=_d({__proto__:null,default:Uu,loadImage:lz},[Uu]),fz=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));return cz});
|