@naisys/erp 3.0.0-beta.7 → 3.0.0-beta.8

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.
@@ -60,7 +60,7 @@ ${o?`${s(`light`)}{${o}}`:``}`}function Tr({color:e,theme:t,autoContrast:n}){ret
60
60
  allowNegative: `+a+`
61
61
  `),a=!1),Object.assign(Object.assign({},e),{allowNegative:a})}function Tg(e){e=wg(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,n=e.allowNegative,r=e.allowLeadingZeros,i=e.onKeyDown;i===void 0&&(i=Bh);var a=e.onBlur;a===void 0&&(a=Bh);var o=e.thousandSeparator,s=e.decimalScale,c=e.fixedDecimalScale,l=e.prefix;l===void 0&&(l=``);var u=e.defaultValue,d=e.value,f=e.valueIsNumericString,p=e.onValueChange,m=Rh(e,[`decimalSeparator`,`allowedDecimalSeparators`,`thousandsGroupStyle`,`suffix`,`allowNegative`,`allowLeadingZeros`,`onKeyDown`,`onBlur`,`thousandSeparator`,`decimalScale`,`fixedDecimalScale`,`prefix`,`defaultValue`,`value`,`valueIsNumericString`,`onValueChange`]),h=vg(e),g=h.decimalSeparator,_=h.allowedDecimalSeparators,v=function(t){return _g(t,e)},y=function(t,n){return Sg(t,n,e)},b=Uh(d)?u:d,x=f??xg(b,l,t);Uh(d)?Uh(u)||(x||=typeof u==`number`):x||=typeof d==`number`;var S=function(e){return Gh(e)?e:(typeof e==`number`&&(e=eg(e)),x&&typeof s==`number`?tg(e,s,!!c):e)},C=pg(S(d),S(u),!!x,v,y,p),w=C[0],T=w.numAsString,E=w.formattedValue,D=C[1];return Object.assign(Object.assign({},m),{value:E,valueIsNumericString:!1,isValidInputCharacter:function(e){return e===g?!0:Hh(e)},isCharacterSame:function(e){var t=e.currentValue,n=e.lastValue,r=e.formattedValue,i=e.currentValueIndex,a=e.formattedValueIndex,o=t[i],u=r[a],f=rg(n,t).to,p=function(e){return y(e).indexOf(`.`)+l.length};return d===0&&c&&s&&t[f.start]===g&&p(t)<i&&p(r)>a?!1:i>=f.start&&i<f.end&&_&&_.includes(o)&&u===g?!0:o===u},onValueChange:D,format:v,removeFormatting:y,getCaretBoundary:function(t){return Cg(t,e)},onKeyDown:function(e){var t=e.target,r=e.key,a=t.selectionStart,u=t.selectionEnd,d=t.value;if(d===void 0&&(d=``),(r===`Backspace`||r===`Delete`)&&u<l.length){e.preventDefault();return}if(a!==u){i(e);return}r===`Backspace`&&d[0]===`-`&&a===l.length+1&&n&&ng(t,1),s&&c&&(r===`Backspace`&&d[a-1]===g?(ng(t,a-1),e.preventDefault()):r===`Delete`&&d[a]===g&&e.preventDefault()),_?.includes(r)&&d[a]===g&&ng(t,a+1);var f=o===!0?`,`:o;r===`Backspace`&&d[a-1]===f&&ng(t,a-1),r===`Delete`&&d[a]===f&&ng(t,a+1),i(e)},onBlur:function(t){var n=T;n.match(/\d/g)||(n=``),r||(n=Zh(n)),c&&s&&(n=tg(n,s,c)),n!==T&&D({formattedValue:_g(n,e),value:n,floatValue:parseFloat(n)},{event:t,source:zh.event}),a(t)}})}function Eg(e){var t=Tg(e);return v.createElement(gg,Object.assign({},t))}var Dg={root:`m_e2f5cd4e`,controls:`m_95e17d22`,control:`m_80b4b171`};function Og({direction:e,style:t,...n}){return(0,I.jsx)(`svg`,{style:{width:`var(--ni-chevron-size)`,height:`var(--ni-chevron-size)`,transform:e===`up`?`rotate(180deg)`:void 0,...t},viewBox:`0 0 15 15`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...n,children:(0,I.jsx)(`path`,{d:`M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`})})}var kg=/^(0\.0*|-0(\.0*)?)$/,Ag=/^-?0\d+(\.\d+)?\.?$/,jg=/\.\d*0$/,Mg=/^-?\d+\.$/;function Ng(e){return typeof e==`string`&&e!==``&&!Number.isNaN(Number(e))}function Pg(e){return typeof e==`number`?e<2**53-1:e===``||Ng(e)&&Number(e)<2**53-1}function Fg(e){return e.toString().replace(`.`,``).length}function Ig(e,t){return(typeof e==`number`?e<2**53-1:!Number.isNaN(Number(e)))&&!Number.isNaN(e)&&Fg(t)<14&&t!==``}function Lg(e,t,n){return e===void 0?!0:(t===void 0||e>=t)&&(n===void 0||e<=n)}var Rg={step:1,clampBehavior:`blur`,allowDecimal:!0,allowNegative:!0,withKeyboardEvents:!0,allowLeadingZeros:!0,trimLeadingZeroesOnBlur:!0,startValue:0,allowedDecimalSeparators:[`.`,`,`]},zg=On((e,{size:t})=>({controls:{"--ni-chevron-size":vt(t,`ni-chevron-size`)}}));function Bg(e,t,n){let r=e.toString(),i=Mg.test(r),a=r.replace(/^0+(?=\d)/,``),o=parseFloat(a);if(Number.isNaN(o))return a;if(o>2**53-1)return t===void 0?a:t;let s=kt(o,n,t);return i?`${s.toString().replace(/^0+(?=\d)/,``)}.`:s}var Vg=z((e,t)=>{let n=L(`NumberInput`,Rg,e),{className:r,classNames:i,styles:a,unstyled:o,vars:s,onChange:c,onValueChange:l,value:u,defaultValue:d,max:f,min:p,step:m,hideControls:h,rightSection:g,isAllowed:_,clampBehavior:y,onBlur:b,allowDecimal:x,decimalScale:S,onKeyDown:C,onKeyDownCapture:w,handlersRef:T,startValue:E,disabled:D,rightSectionPointerEvents:O,allowNegative:k,readOnly:A,size:j,rightSectionWidth:ee,stepHoldInterval:te,stepHoldDelay:ne,allowLeadingZeros:re,withKeyboardEvents:M,trimLeadingZeroesOnBlur:N,allowedDecimalSeparators:ie,attributes:ae,...oe}=n,se=ii({name:`NumberInput`,classes:Dg,props:n,classNames:i,styles:a,unstyled:o,attributes:ae,vars:s,varsResolver:zg}),{resolvedClassNames:ce,resolvedStyles:le}=Vr({classNames:i,styles:a,props:n}),[ue,de]=ln({value:u,defaultValue:d,finalValue:``,onChange:c}),fe=ne!==void 0&&te!==void 0,pe=(0,v.useRef)(null),me=(0,v.useRef)(null),he=(0,v.useRef)(0),ge=(e,t)=>{t.source===`event`&&de(Ig(e.floatValue,e.value)&&!kg.test(e.value)&&!(re&&Ag.test(e.value))&&!jg.test(e.value)&&!Mg.test(e.value)?e.floatValue:e.value),l?.(e,t)},_e=e=>{let t=String(e).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return t?Math.max(0,(t[1]?t[1].length:0)-(t[2]?+t[2]:0)):0},ve=e=>{pe.current&&e!==void 0&&pe.current.setSelectionRange(e,e)},ye=(0,v.useRef)(gt);ye.current=()=>{if(!Pg(ue))return;let e,t=_e(ue),n=_e(m),r=Math.max(t,n),i=10**r;if(!Ng(ue)&&(typeof ue!=`number`||Number.isNaN(ue)))e=kt(E,p,f);else if(f!==void 0){let t=(Math.round(Number(ue)*i)+Math.round(m*i))/i;e=t<=f?t:f}else e=(Math.round(Number(ue)*i)+Math.round(m*i))/i;let a=e.toFixed(r);de(parseFloat(a)),l?.({floatValue:parseFloat(a),formattedValue:a,value:a},{source:`increment`}),setTimeout(()=>ve(pe.current?.value.length),0)};let be=(0,v.useRef)(gt);be.current=()=>{if(!Pg(ue))return;let e,t=p===void 0?k?-(2**53-1):0:p,n=_e(ue),r=_e(m),i=Math.max(n,r),a=10**i;if(!Ng(ue)&&typeof ue!=`number`||Number.isNaN(ue))e=kt(E,t,f);else{let n=(Math.round(Number(ue)*a)-Math.round(m*a))/a;e=t!==void 0&&n<t?t:n}let o=e.toFixed(i);de(parseFloat(o)),l?.({floatValue:parseFloat(o),formattedValue:o,value:o},{source:`decrement`}),setTimeout(()=>ve(pe.current?.value.length),0)};let xe=e=>{let t=e.clipboardData.getData(`text`),n=oe.decimalSeparator||`.`,r=(ie||[`.`,`,`]).filter(e=>e!==n);if(r.some(e=>t.includes(e))){e.preventDefault();let i=t;r.forEach(e=>{i=i.split(e).join(n)});let a=pe.current;if(a){let e=a.selectionStart??0,t=a.selectionEnd??0,n=a.value,r=n.substring(0,e)+i+n.substring(t);(Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,`value`)?.set)?.call(a,r),a.dispatchEvent(new Event(`change`,{bubbles:!0}));let o=e+i.length;setTimeout(()=>ve(o),0)}}oe.onPaste?.(e)},Se=e=>{C?.(e),!(A||!M)&&(e.key===`ArrowUp`&&(e.preventDefault(),ye.current?.()),e.key===`ArrowDown`&&(e.preventDefault(),be.current?.()))},Ce=e=>{if(w?.(e),e.key===`Backspace`){let t=pe.current;t&&t.selectionStart===0&&t.selectionStart===t.selectionEnd&&(e.preventDefault(),window.setTimeout(()=>ve(0),0))}},we=e=>{let t=ue;y===`blur`&&typeof t==`number`&&(t=kt(t,p,f)),N&&typeof t==`string`&&_e(t)<15&&(t=Bg(t,f,p)),ue!==t&&de(t),b?.(e)};on(T,{increment:ye.current,decrement:be.current});let Te=e=>{e?ye.current?.():be.current?.(),he.current+=1},Ee=e=>{if(Te(e),fe){let t=typeof te==`number`?te:te(he.current);me.current=window.setTimeout(()=>Ee(e),t)}},De=(e,t)=>{e.preventDefault(),pe.current?.focus(),Te(t),fe&&(me.current=window.setTimeout(()=>Ee(t),ne))},Oe=()=>{me.current&&window.clearTimeout(me.current),me.current=null,he.current=0},ke=(0,I.jsxs)(`div`,{...se(`controls`),children:[(0,I.jsx)(gl,{...se(`control`),tabIndex:-1,"aria-hidden":!0,disabled:D||typeof ue==`number`&&f!==void 0&&ue>=f,mod:{direction:`up`},onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{De(e,!0)},onPointerUp:Oe,onPointerLeave:Oe,children:(0,I.jsx)(Og,{direction:`up`})}),(0,I.jsx)(gl,{...se(`control`),tabIndex:-1,"aria-hidden":!0,disabled:D||typeof ue==`number`&&p!==void 0&&ue<=p,mod:{direction:`down`},onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{De(e,!1)},onPointerUp:Oe,onPointerLeave:Oe,children:(0,I.jsx)(Og,{direction:`down`})})]});return(0,I.jsx)(gd,{component:Eg,allowNegative:k,className:An(Dg.root,r),size:j,inputMode:`decimal`,...oe,readOnly:A,disabled:D,value:ue,getInputRef:cn(t,pe),onValueChange:ge,rightSection:h||A||!Pg(ue)?g:g||ke,classNames:ce,styles:le,unstyled:o,__staticSelector:`NumberInput`,decimalScale:x?S:0,onPaste:xe,onKeyDown:Se,onKeyDownCapture:Ce,rightSectionPointerEvents:O??(D?`none`:void 0),rightSectionWidth:ee??`var(--ni-right-section-width-${j||`sm`})`,allowLeadingZeros:re,allowedDecimalSeparators:ie,onBlur:we,attributes:ae,isAllowed:e=>y===`strict`?_?_(e)&&Lg(e.floatValue,p,f):Lg(e.floatValue,p,f):_?_(e):!0})});Vg.classes={...gd.classes,...Dg},Vg.displayName=`@mantine/core/NumberInput`;var Hg={root:`m_4addd315`,control:`m_326d024a`,dots:`m_4ad7767d`},[Ug,Wg]=ot(`Pagination.Root component was not found in tree`),Gg={withPadding:!0},Kg=z((e,t)=>{let{classNames:n,className:r,style:i,styles:a,vars:o,active:s,disabled:c,withPadding:l,mod:u,...d}=L(`PaginationControl`,Gg,e),f=Wg(),p=c||f.disabled;return(0,I.jsx)(gl,{ref:t,disabled:p,mod:[{active:s,disabled:p,"with-padding":l},u],...f.getStyles(`control`,{className:r,style:i,classNames:n,styles:a,active:!p}),...d})});Kg.classes=Hg,Kg.displayName=`@mantine/core/PaginationControl`;function qg({style:e,children:t,path:n,...r}){return(0,I.jsx)(`svg`,{viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`,style:{width:`calc(var(--pagination-control-size) / 1.8)`,height:`calc(var(--pagination-control-size) / 1.8)`,...e},...r,children:(0,I.jsx)(`path`,{d:n,fill:`currentColor`})})}var Jg=e=>(0,I.jsx)(qg,{...e,path:`M8.781 8l-3.3-3.3.943-.943L10.667 8l-4.243 4.243-.943-.943 3.3-3.3z`}),Yg=e=>(0,I.jsx)(qg,{...e,path:`M7.219 8l3.3 3.3-.943.943L5.333 8l4.243-4.243.943.943-3.3 3.3z`}),Xg=e=>(0,I.jsx)(qg,{...e,path:`M6.85355 3.85355C7.04882 3.65829 7.04882 3.34171 6.85355 3.14645C6.65829 2.95118 6.34171 2.95118 6.14645 3.14645L2.14645 7.14645C1.95118 7.34171 1.95118 7.65829 2.14645 7.85355L6.14645 11.8536C6.34171 12.0488 6.65829 12.0488 6.85355 11.8536C7.04882 11.6583 7.04882 11.3417 6.85355 11.1464L3.20711 7.5L6.85355 3.85355ZM12.8536 3.85355C13.0488 3.65829 13.0488 3.34171 12.8536 3.14645C12.6583 2.95118 12.3417 2.95118 12.1464 3.14645L8.14645 7.14645C7.95118 7.34171 7.95118 7.65829 8.14645 7.85355L12.1464 11.8536C12.3417 12.0488 12.6583 12.0488 12.8536 11.8536C13.0488 11.6583 13.0488 11.3417 12.8536 11.1464L9.20711 7.5L12.8536 3.85355Z`}),Zg=e=>(0,I.jsx)(qg,{...e,path:`M2.14645 11.1464C1.95118 11.3417 1.95118 11.6583 2.14645 11.8536C2.34171 12.0488 2.65829 12.0488 2.85355 11.8536L6.85355 7.85355C7.04882 7.65829 7.04882 7.34171 6.85355 7.14645L2.85355 3.14645C2.65829 2.95118 2.34171 2.95118 2.14645 3.14645C1.95118 3.34171 1.95118 3.65829 2.14645 3.85355L5.79289 7.5L2.14645 11.1464ZM8.14645 11.1464C7.95118 11.3417 7.95118 11.6583 8.14645 11.8536C8.34171 12.0488 8.65829 12.0488 8.85355 11.8536L12.8536 7.85355C13.0488 7.65829 13.0488 7.34171 12.8536 7.14645L8.85355 3.14645C8.65829 2.95118 8.34171 2.95118 8.14645 3.14645C7.95118 3.34171 7.95118 3.65829 8.14645 3.85355L11.7929 7.5L8.14645 11.1464Z`}),Qg={icon:e=>(0,I.jsx)(qg,{...e,path:`M2 8c0-.733.6-1.333 1.333-1.333.734 0 1.334.6 1.334 1.333s-.6 1.333-1.334 1.333C2.6 9.333 2 8.733 2 8zm9.333 0c0-.733.6-1.333 1.334-1.333C13.4 6.667 14 7.267 14 8s-.6 1.333-1.333 1.333c-.734 0-1.334-.6-1.334-1.333zM6.667 8c0-.733.6-1.333 1.333-1.333s1.333.6 1.333 1.333S8.733 9.333 8 9.333 6.667 8.733 6.667 8z`})},$g=z((e,t)=>{let{classNames:n,className:r,style:i,styles:a,vars:o,icon:s,...c}=L(`PaginationDots`,Qg,e);return(0,I.jsx)(R,{ref:t,...Wg().getStyles(`dots`,{className:r,style:i,styles:a,classNames:n}),...c,children:(0,I.jsx)(s,{style:{width:`calc(var(--pagination-control-size) / 1.8)`,height:`calc(var(--pagination-control-size) / 1.8)`}})})});$g.classes=Hg,$g.displayName=`@mantine/core/PaginationDots`;function e_({icon:e,name:t,action:n,type:r}){let i={icon:e},a=(0,v.forwardRef)((e,a)=>{let{icon:o,...s}=L(t,i,e),c=Wg(),l=r===`next`?c.active===c.total:c.active===1;return(0,I.jsx)(Kg,{disabled:c.disabled||l,ref:a,onClick:c[n],withPadding:!1,...s,children:(0,I.jsx)(o,{className:`mantine-rotate-rtl`,style:{width:`calc(var(--pagination-control-size) / 1.8)`,height:`calc(var(--pagination-control-size) / 1.8)`}})})});return a.displayName=`@mantine/core/${t}`,Pi(a)}var t_=e_({icon:Jg,name:`PaginationNext`,action:`onNext`,type:`next`}),n_=e_({icon:Yg,name:`PaginationPrevious`,action:`onPrevious`,type:`previous`}),r_=e_({icon:Xg,name:`PaginationFirst`,action:`onFirst`,type:`previous`}),i_=e_({icon:Zg,name:`PaginationLast`,action:`onLast`,type:`next`});function a_({dotsIcon:e}){let t=Wg();return(0,I.jsx)(I.Fragment,{children:t.range.map((n,r)=>n===`dots`?(0,I.jsx)($g,{icon:e},r):(0,I.jsx)(Kg,{active:n===t.active,"aria-current":n===t.active?`page`:void 0,onClick:()=>t.onChange(n),disabled:t.disabled,...t.getItemProps?.(n),children:t.getItemProps?.(n)?.children??n},r))})}a_.displayName=`@mantine/core/PaginationItems`;var o_={siblings:1,boundaries:1},s_=On((e,{size:t,radius:n,color:r,autoContrast:i})=>({root:{"--pagination-control-radius":n===void 0?void 0:bt(n),"--pagination-control-size":vt(t,`pagination-control-size`),"--pagination-control-fz":xt(t),"--pagination-active-bg":r?rr(r,e):void 0,"--pagination-active-color":ai(i,e)?Tr({color:r,theme:e,autoContrast:i}):void 0}})),c_=z((e,t)=>{let n=L(`PaginationRoot`,o_,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,total:l,value:u,defaultValue:d,onChange:f,disabled:p,siblings:m,boundaries:h,color:g,radius:_,onNextPage:v,onPreviousPage:y,onFirstPage:b,onLastPage:x,getItemProps:S,autoContrast:C,attributes:w,...T}=n,E=ii({name:`Pagination`,classes:Hg,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:w,vars:c,varsResolver:s_}),{range:D,setPage:O,next:k,previous:A,active:j,first:ee,last:te}=fn({page:u,initialPage:d,onChange:f,total:l,siblings:m,boundaries:h});return(0,I.jsx)(Ug,{value:{total:l,range:D,active:j,disabled:p,getItemProps:S,onChange:O,onNext:wt(v,k),onPrevious:wt(y,A),onFirst:wt(b,ee),onLast:wt(x,te),getStyles:E},children:(0,I.jsx)(R,{ref:t,...E(`root`),...T})})});c_.classes=Hg,c_.displayName=`@mantine/core/PaginationRoot`;var l_={withControls:!0,withPages:!0,siblings:1,boundaries:1,gap:8},u_=z((e,t)=>{let{withEdges:n,withControls:r,getControlProps:i,nextIcon:a,previousIcon:o,lastIcon:s,firstIcon:c,dotsIcon:l,total:u,gap:d,hideWithOnePage:f,withPages:p,...m}=L(`Pagination`,l_,e);return u<=0||f&&u===1?null:(0,I.jsx)(c_,{ref:t,total:u,...m,children:(0,I.jsxs)(B,{gap:d,children:[n&&(0,I.jsx)(r_,{icon:c,...i?.(`first`)}),r&&(0,I.jsx)(n_,{icon:o,...i?.(`previous`)}),p&&(0,I.jsx)(a_,{dotsIcon:l}),r&&(0,I.jsx)(t_,{icon:a,...i?.(`next`)}),n&&(0,I.jsx)(i_,{icon:s,...i?.(`last`)})]})})});u_.classes=Hg,u_.displayName=`@mantine/core/Pagination`,u_.Root=c_,u_.Control=Kg,u_.Dots=$g,u_.First=r_,u_.Last=i_,u_.Next=t_,u_.Previous=n_,u_.Items=a_;var d_={root:`m_f61ca620`,input:`m_ccf8da4c`,innerInput:`m_f2d85dd2`,visibilityToggle:`m_b1072d44`},f_={visibilityToggleIcon:({reveal:e})=>(0,I.jsx)(`svg`,{viewBox:`0 0 15 15`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:{width:`var(--psi-icon-size)`,height:`var(--psi-icon-size)`},children:(0,I.jsx)(`path`,{d:e?`M13.3536 2.35355C13.5488 2.15829 13.5488 1.84171 13.3536 1.64645C13.1583 1.45118 12.8417 1.45118 12.6464 1.64645L10.6828 3.61012C9.70652 3.21671 8.63759 3 7.5 3C4.30786 3 1.65639 4.70638 0.0760002 7.23501C-0.0253338 7.39715 -0.0253334 7.60288 0.0760014 7.76501C0.902945 9.08812 2.02314 10.1861 3.36061 10.9323L1.64645 12.6464C1.45118 12.8417 1.45118 13.1583 1.64645 13.3536C1.84171 13.5488 2.15829 13.5488 2.35355 13.3536L4.31723 11.3899C5.29348 11.7833 6.36241 12 7.5 12C10.6921 12 13.3436 10.2936 14.924 7.76501C15.0253 7.60288 15.0253 7.39715 14.924 7.23501C14.0971 5.9119 12.9769 4.81391 11.6394 4.06771L13.3536 2.35355ZM9.90428 4.38861C9.15332 4.1361 8.34759 4 7.5 4C4.80285 4 2.52952 5.37816 1.09622 7.50001C1.87284 8.6497 2.89609 9.58106 4.09974 10.1931L9.90428 4.38861ZM5.09572 10.6114L10.9003 4.80685C12.1039 5.41894 13.1272 6.35031 13.9038 7.50001C12.4705 9.62183 10.1971 11 7.5 11C6.65241 11 5.84668 10.8639 5.09572 10.6114Z`:`M7.5 11C4.80285 11 2.52952 9.62184 1.09622 7.50001C2.52952 5.37816 4.80285 4 7.5 4C10.1971 4 12.4705 5.37816 13.9038 7.50001C12.4705 9.62183 10.1971 11 7.5 11ZM7.5 3C4.30786 3 1.65639 4.70638 0.0760002 7.23501C-0.0253338 7.39715 -0.0253334 7.60288 0.0760014 7.76501C1.65639 10.2936 4.30786 12 7.5 12C10.6921 12 13.3436 10.2936 14.924 7.76501C15.0253 7.60288 15.0253 7.39715 14.924 7.23501C13.3436 4.70638 10.6921 3 7.5 3ZM7.5 9.5C8.60457 9.5 9.5 8.60457 9.5 7.5C9.5 6.39543 8.60457 5.5 7.5 5.5C6.39543 5.5 5.5 6.39543 5.5 7.5C5.5 8.60457 6.39543 9.5 7.5 9.5Z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`})})},p_=On((e,{size:t})=>({root:{"--psi-icon-size":vt(t,`psi-icon-size`),"--psi-button-size":vt(t,`psi-button-size`)}})),m_=z((e,t)=>{let n=L(`PasswordInput`,f_,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,required:l,error:u,leftSection:d,disabled:f,id:p,variant:m,inputContainer:h,description:g,label:_,size:v,errorProps:y,descriptionProps:b,labelProps:x,withAsterisk:S,inputWrapperOrder:C,wrapperProps:w,radius:T,rightSection:E,rightSectionWidth:D,rightSectionPointerEvents:O,leftSectionWidth:k,visible:A,defaultVisible:j,onVisibilityChange:ee,visibilityToggleIcon:te,visibilityToggleButtonProps:ne,rightSectionProps:re,leftSectionProps:M,leftSectionPointerEvents:N,withErrorStyles:ie,mod:ae,attributes:oe,...se}=n,ce=rn(p),[le,ue]=ln({value:A,defaultValue:j,finalValue:!1,onChange:ee}),de=()=>ue(!le),fe=ii({name:`PasswordInput`,classes:d_,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:oe,vars:c,varsResolver:p_}),{resolvedClassNames:pe,resolvedStyles:me}=Vr({classNames:r,styles:o,props:n}),{styleProps:he,rest:ge}=li(se),_e=y?.id||`${ce}-error`,ve=b?.id||`${ce}-description`,ye=`${u&&typeof u!=`boolean`?_e:``} ${g?ve:``}`,be=ye.trim().length>0?ye.trim():void 0,xe=(0,I.jsx)(vu,{...fe(`visibilityToggle`),disabled:f,radius:T,"aria-hidden":!ne,"aria-pressed":le,tabIndex:-1,...ne,variant:ne?.variant??`subtle`,color:`gray`,unstyled:s,onTouchEnd:e=>{e.preventDefault(),ne?.onTouchEnd?.(e),de()},onMouseDown:e=>{e.preventDefault(),ne?.onMouseDown?.(e),de()},onKeyDown:e=>{ne?.onKeyDown?.(e),e.key===` `&&(e.preventDefault(),de())},children:(0,I.jsx)(te,{reveal:le})});return(0,I.jsx)(pd.Wrapper,{required:l,id:ce,label:_,error:u,description:g,size:v,classNames:pe,styles:me,__staticSelector:`PasswordInput`,__stylesApiProps:n,unstyled:s,withAsterisk:S,inputWrapperOrder:C,inputContainer:h,variant:m,labelProps:{...x,htmlFor:ce},descriptionProps:{...b,id:ve},errorProps:{...y,id:_e},mod:ae,attributes:oe,...fe(`root`),...he,...w,children:(0,I.jsx)(pd,{component:`div`,error:u,leftSection:d,size:v,classNames:{...pe,input:An(d_.input,pe.input)},styles:me,radius:T,disabled:f,__staticSelector:`PasswordInput`,__stylesApiProps:n,rightSectionWidth:D,rightSection:E??xe,variant:m,unstyled:s,leftSectionWidth:k,rightSectionPointerEvents:O||`all`,rightSectionProps:re,leftSectionProps:M,leftSectionPointerEvents:N,withAria:!1,withErrorStyles:ie,attributes:oe,children:(0,I.jsx)(`input`,{required:l,"data-invalid":!!u||void 0,"data-with-left-section":!!d||void 0,...fe(`innerInput`),disabled:f,id:ce,ref:t,...ge,"aria-describedby":be,autoComplete:ge.autoComplete||`off`,type:le?`text`:`password`})})})});m_.classes={...gd.classes,...d_},m_.displayName=`@mantine/core/PasswordInput`;var h_={duration:100,transition:`fade`};function g_(e,t){return{...h_,...t,...e}}var __={tooltip:`m_1b3c8819`,arrow:`m_f898399f`};function v_({offset:e,position:t,defaultOpened:n}){let[r,i]=(0,v.useState)(n),a=(0,v.useRef)(null),{x:o,y:s,elements:c,refs:l,update:u,placement:d}=Ec({placement:t,middleware:[Is({crossAxis:!0,padding:5,rootBoundary:`document`})]}),f=d.includes(`right`)?e:t.includes(`left`)?e*-1:0,p=d.includes(`bottom`)?e:t.includes(`top`)?e*-1:0,m=(0,v.useCallback)(({clientX:e,clientY:t})=>{l.setPositionReference({getBoundingClientRect(){return{width:0,height:0,x:e,y:t,left:e+f,top:t+p,right:e,bottom:t}}})},[c.reference]);return(0,v.useEffect)(()=>{if(l.floating.current){let e=a.current;e.addEventListener(`mousemove`,m);let t=wa(l.floating.current);return t.forEach(e=>{e.addEventListener(`scroll`,u)}),()=>{e.removeEventListener(`mousemove`,m),t.forEach(e=>{e.removeEventListener(`scroll`,u)})}}},[c.reference,l.floating.current,u,m,r]),{handleMouseMove:m,x:o,y:s,opened:r,setOpened:i,boundaryRef:a,floating:l.setFloating}}var y_={refProp:`ref`,withinPortal:!0,offset:10,position:`right`,zIndex:ht(`popover`)},b_=On((e,{radius:t,color:n})=>({tooltip:{"--tooltip-radius":t===void 0?void 0:bt(t),"--tooltip-bg":n?rr(n,e):void 0,"--tooltip-color":n?`var(--mantine-color-white)`:void 0}})),x_=z((e,t)=>{let n=L(`TooltipFloating`,y_,e),{children:r,refProp:i,withinPortal:a,style:o,className:s,classNames:c,styles:l,unstyled:u,radius:d,color:f,label:p,offset:m,position:h,multiline:g,zIndex:_,disabled:y,defaultOpened:b,variant:x,vars:S,portalProps:C,attributes:w,...T}=n,E=br(),D=ii({name:`TooltipFloating`,props:n,classes:__,className:s,style:o,classNames:c,styles:l,unstyled:u,attributes:w,rootSelector:`tooltip`,vars:S,varsResolver:b_}),{handleMouseMove:O,x:k,y:A,opened:j,boundaryRef:ee,floating:te,setOpened:ne}=v_({offset:m,position:h,defaultOpened:b}),re=Dn(r);if(!re)throw Error(`[@mantine/core] Tooltip.Floating component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported`);let M=cn(ee,Cn(re),t),N=re.props,ie=e=>{N.onMouseEnter?.(e),O(e),ne(!0)},ae=e=>{N.onMouseLeave?.(e),ne(!1)};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Il,{...C,withinPortal:a,children:(0,I.jsx)(R,{...T,...D(`tooltip`,{style:{...Ni(o,E),zIndex:_,display:!y&&j?`block`:`none`,top:(A&&Math.round(A))??``,left:(k&&Math.round(k))??``}}),variant:x,ref:te,mod:{multiline:g},children:p})}),(0,v.cloneElement)(re,{...N,[i]:M,onMouseEnter:ie,onMouseLeave:ae})]})});x_.classes=__,x_.displayName=`@mantine/core/TooltipFloating`;var S_=(0,v.createContext)(!1),C_=S_.Provider,w_=()=>(0,v.useContext)(S_),T_={openDelay:0,closeDelay:0};function E_(e){let{openDelay:t,closeDelay:n,children:r}=L(`TooltipGroup`,T_,e);return(0,I.jsx)(C_,{value:!0,children:(0,I.jsx)(yc,{delay:{open:t,close:n},children:r})})}E_.displayName=`@mantine/core/TooltipGroup`,E_.extend=e=>e;function D_(e){if(e===void 0)return{shift:!0,flip:!0};let t={...e};return e.shift===void 0&&(t.shift=!0),e.flip===void 0&&(t.flip=!0),t}function O_(e){let t=D_(e.middlewares),n=[Fs(e.offset)];return t.shift&&n.push(Is(typeof t.shift==`boolean`?{padding:8}:{padding:8,...t.shift})),t.flip&&n.push(typeof t.flip==`boolean`?Rs():Rs(t.flip)),n.push(Hs({element:e.arrowRef,padding:e.arrowOffset})),t.inline?n.push(typeof t.inline==`boolean`?Vs():Vs(t.inline)):e.inline&&n.push(Vs()),n}function k_(e){let[t,n]=(0,v.useState)(e.defaultOpened),r=typeof e.opened==`boolean`?e.opened:t,i=w_(),a=rn(),o=(0,v.useCallback)(e=>{n(e),e&&g(a)},[a]),{x:s,y:c,context:l,refs:u,placement:d,middlewareData:{arrow:{x:f,y:p}={}}}=Ec({strategy:e.strategy,placement:e.position,open:r,onOpenChange:o,middleware:O_(e),whileElementsMounted:vs}),{delay:m,currentId:h,setCurrentId:g}=bc(l,{id:a}),{getReferenceProps:_,getFloatingProps:y}=Ac([hc(l,{enabled:e.events?.hover,delay:i?m:{open:e.openDelay,close:e.closeDelay},mouseOnly:!e.events?.touch}),Oc(l,{enabled:e.events?.focus,visibleOnly:!0}),Mc(l,{role:`tooltip`}),wc(l,{enabled:e.opened===void 0})]);Vt(()=>{e.onPositionChange?.(d)},[d]);let b=r&&h&&h!==a;return{x:s,y:c,arrowX:f,arrowY:p,reference:u.setReference,floating:u.setFloating,getFloatingProps:y,getReferenceProps:_,isGroupPhase:b,opened:r,placement:d}}var A_={position:`top`,refProp:`ref`,withinPortal:!0,arrowSize:4,arrowOffset:5,arrowRadius:0,arrowPosition:`side`,offset:5,transitionProps:{duration:100,transition:`fade`},events:{hover:!0,focus:!1,touch:!1},zIndex:ht(`popover`),positionDependencies:[],middlewares:{flip:!0,shift:!0,inline:!1}},j_=On((e,{radius:t,color:n,variant:r,autoContrast:i})=>{let a=e.variantColorResolver({theme:e,color:n||e.primaryColor,autoContrast:i,variant:r||`filled`});return{tooltip:{"--tooltip-radius":t===void 0?void 0:bt(t),"--tooltip-bg":n?a.background:void 0,"--tooltip-color":n?a.color:void 0}}}),M_=z((e,t)=>{let n=L(`Tooltip`,A_,e),{children:r,position:i,refProp:a,label:o,openDelay:s,closeDelay:c,onPositionChange:l,opened:u,defaultOpened:d,withinPortal:f,radius:p,color:m,classNames:h,styles:g,unstyled:_,style:y,className:b,withArrow:x,arrowSize:S,arrowOffset:C,arrowRadius:w,arrowPosition:T,offset:E,transitionProps:D,multiline:O,events:k,zIndex:A,disabled:j,positionDependencies:ee,onClick:te,onMouseEnter:ne,onMouseLeave:re,inline:M,variant:N,keepMounted:ie,vars:ae,portalProps:oe,mod:se,floatingStrategy:ce,middlewares:le,autoContrast:ue,attributes:de,target:fe,...pe}=L(`Tooltip`,A_,n),{dir:me}=Gi(),he=(0,v.useRef)(null),ge=k_({position:Dl(me,i),closeDelay:c,openDelay:s,onPositionChange:l,opened:u,defaultOpened:d,events:k,arrowRef:he,arrowOffset:C,offset:typeof E==`number`?E+(x?S/2:0):E,positionDependencies:[...ee,fe??r],inline:M,strategy:ce,middlewares:le});(0,v.useEffect)(()=>{let e=fe instanceof HTMLElement?fe:typeof fe==`string`?document.querySelector(fe):fe?.current||null;e&&ge.reference(e)},[fe,ge]);let _e=ii({name:`Tooltip`,props:n,classes:__,className:b,style:y,classNames:h,styles:g,unstyled:_,attributes:de,rootSelector:`tooltip`,vars:ae,varsResolver:j_}),ve=Dn(r);if(!fe&&!ve)throw Error(`[@mantine/core] Tooltip component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported`);if(fe){let e=g_(D,{duration:100,transition:`fade`});return(0,I.jsx)(I.Fragment,{children:(0,I.jsx)(Il,{...oe,withinPortal:f,children:(0,I.jsx)(Hl,{...e,keepMounted:ie,mounted:!j&&!!ge.opened,duration:ge.isGroupPhase?10:e.duration,children:e=>(0,I.jsxs)(R,{...pe,"data-fixed":ce===`fixed`||void 0,variant:N,mod:[{multiline:O},se],...ge.getFloatingProps({ref:ge.floating,className:_e(`tooltip`).className,style:{..._e(`tooltip`).style,...e,zIndex:A,top:ge.y??0,left:ge.x??0}}),children:[o,(0,I.jsx)(El,{ref:he,arrowX:ge.arrowX,arrowY:ge.arrowY,visible:x,position:ge.placement,arrowSize:S,arrowOffset:C,arrowRadius:w,arrowPosition:T,..._e(`arrow`)})]})})})})}let ye=ve.props,be=cn(ge.reference,Cn(ve),t),xe=g_(D,{duration:100,transition:`fade`});return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Il,{...oe,withinPortal:f,children:(0,I.jsx)(Hl,{...xe,keepMounted:ie,mounted:!j&&!!ge.opened,duration:ge.isGroupPhase?10:xe.duration,children:e=>(0,I.jsxs)(R,{...pe,"data-fixed":ce===`fixed`||void 0,variant:N,mod:[{multiline:O},se],...ge.getFloatingProps({ref:ge.floating,className:_e(`tooltip`).className,style:{..._e(`tooltip`).style,...e,zIndex:A,top:ge.y??0,left:ge.x??0}}),children:[o,(0,I.jsx)(El,{ref:he,arrowX:ge.arrowX,arrowY:ge.arrowY,visible:x,position:ge.placement,arrowSize:S,arrowOffset:C,arrowRadius:w,arrowPosition:T,..._e(`arrow`)})]})})}),(0,v.cloneElement)(ve,ge.getReferenceProps({onClick:te,onMouseEnter:ne,onMouseLeave:re,onMouseMove:n.onMouseMove,onPointerDown:n.onPointerDown,onPointerEnter:n.onPointerEnter,...ye,className:An(b,ye.className),[a]:be}))]})});M_.classes=__,M_.displayName=`@mantine/core/Tooltip`,M_.Floating=x_,M_.Group=E_;var N_={root:`m_cf365364`,indicator:`m_9e182ccd`,label:`m_1738fcb2`,input:`m_1714d588`,control:`m_69686b9b`,innerLabel:`m_78882f40`},P_={withItemsBorders:!0},F_=On((e,{radius:t,color:n,transitionDuration:r,size:i,transitionTimingFunction:a})=>({root:{"--sc-radius":t===void 0?void 0:bt(t),"--sc-color":n?rr(n,e):void 0,"--sc-shadow":n?void 0:`var(--mantine-shadow-xs)`,"--sc-transition-duration":r===void 0?void 0:`${r}ms`,"--sc-transition-timing-function":a,"--sc-padding":vt(i,`sc-padding`),"--sc-font-size":xt(i)}})),I_=z((e,t)=>{let n=L(`SegmentedControl`,P_,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,data:l,value:u,defaultValue:d,onChange:f,size:p,name:m,disabled:h,readOnly:g,fullWidth:_,orientation:y,radius:b,color:x,transitionDuration:S,transitionTimingFunction:C,variant:w,autoContrast:T,withItemsBorders:E,mod:D,attributes:O,...k}=n,A=ii({name:`SegmentedControl`,props:n,classes:N_,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:O,vars:c,varsResolver:F_}),j=br(),ee=l.map(e=>typeof e==`string`?{label:e,value:e}:e),te=xn(),[ne,re]=(0,v.useState)(At()),[M,N]=(0,v.useState)(null),[ie,ae]=(0,v.useState)({}),oe=(e,t)=>{ie[t]=e,ae(ie)},[se,ce]=ln({value:u,defaultValue:d,finalValue:Array.isArray(l)?ee.find(e=>!e.disabled)?.value??l[0]?.value??null:null,onChange:f}),le=rn(m),ue=ee.map(e=>(0,v.createElement)(R,{...A(`control`),mod:{active:se===e.value,orientation:y},key:e.value},(0,v.createElement)(`input`,{...A(`input`),disabled:h||e.disabled,type:`radio`,name:le,value:e.value,id:`${le}-${e.value}`,checked:se===e.value,onChange:()=>!g&&ce(e.value),"data-focus-ring":j.focusRing,key:`${e.value}-input`}),(0,v.createElement)(R,{component:`label`,...A(`label`),mod:{active:se===e.value&&!(h||e.disabled),disabled:h||e.disabled,"read-only":g},htmlFor:`${le}-${e.value}`,ref:t=>oe(t,e.value),__vars:{"--sc-label-color":x===void 0?void 0:Tr({color:x,theme:j,autoContrast:T})},key:`${e.value}-label`},(0,I.jsx)(`span`,{...A(`innerLabel`),children:e.label})))),de=cn(t,e=>N(e));return gn(()=>{re(At())},[l.length]),l.length===0?null:(0,I.jsxs)(R,{...A(`root`),variant:w,size:p,ref:de,mod:[{"full-width":_,orientation:y,initialized:te,"with-items-borders":E},D],...k,role:`radiogroup`,"data-disabled":h,children:[typeof se==`string`&&(0,I.jsx)(xd,{target:ie[se],parent:M,component:`span`,transitionDuration:`var(--sc-transition-duration)`,...A(`indicator`)},ne),ue]})});I_.classes=N_,I_.displayName=`@mantine/core/SegmentedControl`;var L_={withCheckIcon:!0,allowDeselect:!0,checkIconPosition:`left`,openOnFocus:!0},R_=z((e,t)=>{let n=L(`Select`,L_,e),{classNames:r,styles:i,unstyled:a,vars:o,dropdownOpened:s,defaultDropdownOpened:c,onDropdownClose:l,onDropdownOpen:u,onFocus:d,onBlur:f,onClick:p,onChange:m,data:h,value:g,defaultValue:_,selectFirstOptionOnChange:y,selectFirstOptionOnDropdownOpen:b,onOptionSubmit:x,comboboxProps:S,readOnly:C,disabled:w,filter:T,limit:E,withScrollArea:D,maxDropdownHeight:O,size:k,searchable:A,rightSection:j,checkIconPosition:ee,withCheckIcon:te,withAlignedLabels:ne,nothingFoundMessage:re,name:M,form:N,searchValue:ie,defaultSearchValue:ae,onSearchChange:oe,allowDeselect:se,error:ce,rightSectionPointerEvents:le,id:ue,clearable:de,clearButtonProps:fe,hiddenInputProps:pe,renderOption:me,onClear:he,autoComplete:ge,scrollAreaProps:_e,__defaultRightSection:ve,__clearSection:ye,__clearable:be,chevronColor:xe,autoSelectOnBlur:Se,openOnFocus:Ce,attributes:we,...Te}=n,Ee=(0,v.useMemo)(()=>_f(h),[h]),De=(0,v.useRef)({}),Oe=(0,v.useMemo)(()=>vf(Ee),[Ee]),ke=rn(ue),[P,Ae,je]=ln({value:g,defaultValue:_,finalValue:null,onChange:m}),Me=typeof P==`string`?P in Oe?Oe[P]:De.current[P]:void 0,Ne=yn(Me),[Pe,Fe,Ie]=ln({value:ie,defaultValue:ae,finalValue:Me?Me.label:``,onChange:oe}),Le=Kf({opened:s,defaultOpened:c,onDropdownOpen:()=>{u?.(),b?Le.selectFirstOption():Le.updateSelectedOptionIndex(`active`,{scrollIntoView:!0})},onDropdownClose:()=>{l?.(),setTimeout(Le.resetSelectedOption,0)}}),Re=e=>{Fe(e),Le.resetSelectedOption()},{resolvedClassNames:ze,resolvedStyles:Be}=Vr({props:n,styles:i,classNames:r});(0,v.useEffect)(()=>{y&&Le.selectFirstOption()},[y,Pe]),(0,v.useEffect)(()=>{g===null&&Re(``),typeof g==`string`&&Me&&(Ne?.value!==Me.value||Ne?.label!==Me.label)&&Re(Me.label)},[g,Me]),(0,v.useEffect)(()=>{!je&&!Ie&&Re(typeof P==`string`?P in Oe?Oe[P]?.label:De.current[P]?.label||``:``)},[Oe,P]),(0,v.useEffect)(()=>{P&&P in Oe&&(De.current[P]=Oe[P])},[Oe,P]);let Ve=(0,I.jsx)(Yf.ClearButton,{...fe,onClear:()=>{Ae(null,null),Re(``),he?.()}}),He=de&&!!P&&!w&&!C;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(Yf,{store:Le,__staticSelector:`Select`,classNames:ze,styles:Be,unstyled:a,readOnly:C,size:k,attributes:we,keepMounted:Se,onOptionSubmit:e=>{x?.(e);let t=se&&Oe[e].value===P?null:Oe[e],n=t?t.value:null;n!==P&&Ae(n,t),!je&&Re(typeof n==`string`&&t?.label||``),Le.closeDropdown()},...S,children:[(0,I.jsx)(Yf.Target,{targetType:A?`input`:`button`,autoComplete:ge,children:(0,I.jsx)(gd,{id:ke,ref:t,__defaultRightSection:(0,I.jsx)(Yf.Chevron,{size:k,error:ce,unstyled:a,color:xe}),__clearSection:Ve,__clearable:He,rightSection:j,rightSectionPointerEvents:le||`none`,...Te,size:k,__staticSelector:`Select`,disabled:w,readOnly:C||!A,value:Pe,onChange:e=>{Re(e.currentTarget.value),Le.openDropdown(),y&&Le.selectFirstOption()},onFocus:e=>{Ce&&A&&Le.openDropdown(),d?.(e)},onBlur:e=>{Se&&Le.clickSelectedOption(),A&&Le.closeDropdown();let t=typeof P==`string`&&(P in Oe?Oe[P]:De.current[P]);Re(t&&t.label||``),f?.(e)},onClick:e=>{A?Le.openDropdown():Le.toggleDropdown(),p?.(e)},classNames:ze,styles:Be,unstyled:a,pointer:!A,error:ce,attributes:we})}),(0,I.jsx)(Ep,{data:Ee,hidden:C||w,filter:T,search:Pe,limit:E,hiddenWhenEmpty:!re,withScrollArea:D,maxDropdownHeight:O,filterOptions:!!A&&Me?.label!==Pe,value:P,checkIconPosition:ee,withCheckIcon:te,withAlignedLabels:ne,nothingFoundMessage:re,unstyled:a,labelId:Te.label?`${ke}-label`:void 0,"aria-label":Te.label?void 0:Te[`aria-label`],renderOption:me,scrollAreaProps:_e})]}),(0,I.jsx)(Yf.HiddenInput,{value:P,name:M,form:N,disabled:w,...pe})]})});R_.classes={...gd.classes,...Yf.classes},R_.displayName=`@mantine/core/Select`;var z_={container:`m_925c2d2c`,root:`m_2415a157`};function B_({spacing:e,verticalSpacing:t,cols:n,selector:r}){let i=br(),a=t===void 0?e:t,o=nt({"--sg-spacing-x":yt(Dt(e)),"--sg-spacing-y":yt(Dt(a)),"--sg-cols":Dt(n)?.toString()}),s=qe(i.breakpoints).reduce((t,r)=>(t[r]||(t[r]={}),typeof e==`object`&&e[r]!==void 0&&(t[r][`--sg-spacing-x`]=yt(e[r])),typeof a==`object`&&a[r]!==void 0&&(t[r][`--sg-spacing-y`]=yt(a[r])),typeof n==`object`&&n[r]!==void 0&&(t[r][`--sg-cols`]=n[r]),t),{});return(0,I.jsx)(ci,{styles:o,media:Et(qe(s),i.breakpoints).filter(e=>qe(s[e.value]).length>0).map(e=>({query:`(min-width: ${i.breakpoints[e.value]})`,styles:s[e.value]})),selector:r})}function V_(e){return typeof e==`object`&&e?qe(e):[]}function H_(e){return e.sort((e,t)=>Qe(e)-Qe(t))}function U_({spacing:e,verticalSpacing:t,cols:n}){return H_(Array.from(new Set([...V_(e),...V_(t),...V_(n)])))}function W_({spacing:e,verticalSpacing:t,cols:n,selector:r}){let i=t===void 0?e:t,a=nt({"--sg-spacing-x":yt(Dt(e)),"--sg-spacing-y":yt(Dt(i)),"--sg-cols":Dt(n)?.toString()}),o=U_({spacing:e,verticalSpacing:t,cols:n}),s=o.reduce((t,r)=>(t[r]||(t[r]={}),typeof e==`object`&&e[r]!==void 0&&(t[r][`--sg-spacing-x`]=yt(e[r])),typeof i==`object`&&i[r]!==void 0&&(t[r][`--sg-spacing-y`]=yt(i[r])),typeof n==`object`&&n[r]!==void 0&&(t[r][`--sg-cols`]=n[r]),t),{});return(0,I.jsx)(ci,{styles:a,container:o.map(e=>({query:`simple-grid (min-width: ${e})`,styles:s[e]})),selector:r})}var G_={cols:1,spacing:`md`,type:`media`},K_=z((e,t)=>{let n=L(`SimpleGrid`,G_,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,cols:l,verticalSpacing:u,spacing:d,type:f,attributes:p,...m}=n,h=ii({name:`SimpleGrid`,classes:z_,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:p,vars:c}),g=Mi();return f===`container`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(W_,{...n,selector:`.${g}`}),(0,I.jsx)(`div`,{...h(`container`),children:(0,I.jsx)(R,{ref:t,...h(`root`,{className:g}),...m})})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(B_,{...n,selector:`.${g}`}),(0,I.jsx)(R,{ref:t,...h(`root`,{className:g}),...m})]})});K_.classes=z_,K_.displayName=`@mantine/core/SimpleGrid`;var q_={root:`m_6d731127`},J_={gap:`md`,align:`stretch`,justify:`flex-start`},Y_=On((e,{gap:t,align:n,justify:r})=>({root:{"--stack-gap":yt(t),"--stack-align":n,"--stack-justify":r}})),U=z((e,t)=>{let n=L(`Stack`,J_,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,align:l,justify:u,gap:d,variant:f,attributes:p,...m}=n;return(0,I.jsx)(R,{ref:t,...ii({name:`Stack`,props:n,classes:q_,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:p,vars:c,varsResolver:Y_})(`root`),variant:f,...m})});U.classes=q_,U.displayName=`@mantine/core/Stack`;var X_={root:`m_5f93f3bb`,input:`m_926b4011`,track:`m_9307d992`,thumb:`m_93039a1d`,trackLabel:`m_8277e082`},Z_=(0,v.createContext)(null),Q_=Z_.Provider,$_=()=>(0,v.useContext)(Z_),ev=z((e,t)=>{let{value:n,defaultValue:r,onChange:i,size:a,wrapperProps:o,children:s,readOnly:c,disabled:l,...u}=L(`SwitchGroup`,null,e),[d,f]=ln({value:n,defaultValue:r,finalValue:[],onChange:i});return(0,I.jsx)(Q_,{value:{value:d,onChange:e=>{let t=e.currentTarget.value;!c&&f(d.includes(t)?d.filter(e=>e!==t):[...d,t])},size:a,disabled:l},children:(0,I.jsx)(pd.Wrapper,{size:a,ref:t,...o,...u,labelElement:`div`,__staticSelector:`SwitchGroup`,children:(0,I.jsx)(lp,{role:`group`,children:s})})})});ev.classes=pd.Wrapper.classes,ev.displayName=`@mantine/core/SwitchGroup`;var tv={labelPosition:`right`,withThumbIndicator:!0},nv=On((e,{radius:t,color:n,size:r})=>({root:{"--switch-radius":t===void 0?void 0:bt(t),"--switch-height":vt(r,`switch-height`),"--switch-width":vt(r,`switch-width`),"--switch-thumb-size":vt(r,`switch-thumb-size`),"--switch-label-font-size":vt(r,`switch-label-font-size`),"--switch-track-label-padding":vt(r,`switch-track-label-padding`),"--switch-color":n?rr(n,e):void 0}})),rv=z((e,t)=>{let n=L(`Switch`,tv,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,color:l,label:u,offLabel:d,onLabel:f,id:p,size:m,radius:h,wrapperProps:g,thumbIcon:_,checked:v,defaultChecked:y,onChange:b,labelPosition:x,description:S,error:C,disabled:w,variant:T,rootRef:E,mod:D,withThumbIndicator:O,attributes:k,...A}=n,j=$_(),ee=m||j?.size,te=ii({name:`Switch`,props:n,classes:X_,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:k,vars:c,varsResolver:nv}),{styleProps:ne,rest:re}=li(A),M=rn(p),N={checked:j?.value.includes(re.value)??v,onChange:e=>{j?.onChange(e),b?.(e)},disabled:j?.disabled??w},[ie,ae]=ln({value:N.checked??v,defaultValue:y,finalValue:!1});return(0,I.jsxs)(Qf,{...te(`root`),__staticSelector:`Switch`,__stylesApiProps:n,id:M,size:ee,labelPosition:x,label:u,description:S,error:C,disabled:N.disabled,bodyElement:`label`,labelElement:`span`,classNames:r,styles:o,unstyled:s,"data-checked":N.checked,variant:T,ref:E,mod:D,inert:re.inert,...ne,...g,children:[(0,I.jsx)(`input`,{...re,...N,checked:ie,"data-checked":N.checked,onChange:e=>{N.onChange?.(e),ae(e.currentTarget.checked)},id:M,ref:t,type:`checkbox`,role:`switch`,inert:re.inert,...te(`input`)}),(0,I.jsxs)(R,{"aria-hidden":`true`,component:`span`,mod:{error:C,"label-position":x,"without-labels":!f&&!d},...te(`track`),children:[(0,I.jsx)(R,{component:`span`,mod:{"reduce-motion":!0,"with-thumb-indicator":O&&!_},...te(`thumb`),children:_}),(0,I.jsx)(`span`,{...te(`trackLabel`),children:ie?f:d})]})]})});rv.classes={...X_,...Zf},rv.displayName=`@mantine/core/Switch`,rv.Group=ev;var[iv,av]=ot(`Table component was not found in the tree`),ov={table:`m_b23fa0ef`,th:`m_4e7aa4f3`,tr:`m_4e7aa4fd`,td:`m_4e7aa4ef`,tbody:`m_b2404537`,thead:`m_b242d975`,caption:`m_9e5a3ac7`,scrollContainer:`m_a100c15`,scrollContainerInner:`m_62259741`};function sv(e,t){if(!t)return;let n={};return t.columnBorder&&e.withColumnBorders&&(n[`data-with-column-border`]=!0),t.rowBorder&&e.withRowBorders&&(n[`data-with-row-border`]=!0),t.striped&&e.striped&&(n[`data-striped`]=e.striped),t.highlightOnHover&&e.highlightOnHover&&(n[`data-hover`]=!0),t.captionSide&&e.captionSide&&(n[`data-side`]=e.captionSide),t.stickyHeader&&e.stickyHeader&&(n[`data-sticky`]=!0),n}function cv(e,t){let n=`Table${e.charAt(0).toUpperCase()}${e.slice(1)}`,r=z((r,i)=>{let a=L(n,{},r),{classNames:o,className:s,style:c,styles:l,...u}=a,d=av();return(0,I.jsx)(R,{component:e,ref:i,...sv(d,t),...d.getStyles(e,{className:s,classNames:o,style:c,styles:l,props:a}),...u})});return r.displayName=`@mantine/core/${n}`,r.classes=ov,r}var lv=cv(`th`,{columnBorder:!0}),uv=cv(`td`,{columnBorder:!0}),dv=cv(`tr`,{rowBorder:!0,striped:!0,highlightOnHover:!0}),fv=cv(`thead`,{stickyHeader:!0}),pv=cv(`tbody`),mv=cv(`tfoot`),hv=cv(`caption`,{captionSide:!0});function gv({data:e}){return(0,I.jsxs)(I.Fragment,{children:[e.caption&&(0,I.jsx)(hv,{children:e.caption}),e.head&&(0,I.jsx)(fv,{children:(0,I.jsx)(dv,{children:e.head.map((e,t)=>(0,I.jsx)(lv,{children:e},t))})}),e.body&&(0,I.jsx)(pv,{children:e.body.map((e,t)=>(0,I.jsx)(dv,{children:e.map((e,t)=>(0,I.jsx)(uv,{children:e},t))},t))}),e.foot&&(0,I.jsx)(mv,{children:(0,I.jsx)(dv,{children:e.foot.map((e,t)=>(0,I.jsx)(lv,{children:e},t))})})]})}gv.displayName=`@mantine/core/TableDataRenderer`;var _v={type:`scrollarea`},vv=On((e,{minWidth:t,maxHeight:n,type:r})=>({scrollContainer:{"--table-min-width":F(t),"--table-max-height":F(n),"--table-overflow":r===`native`?`auto`:void 0}})),yv=z((e,t)=>{let n=L(`TableScrollContainer`,_v,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,children:l,minWidth:u,maxHeight:d,type:f,scrollAreaProps:p,attributes:m,...h}=n,g=ii({name:`TableScrollContainer`,classes:ov,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:m,vars:c,varsResolver:vv,rootSelector:`scrollContainer`});return(0,I.jsx)(R,{component:f===`scrollarea`?fl:`div`,...f===`scrollarea`?d?{offsetScrollbars:`xy`,...p}:{offsetScrollbars:`x`,...p}:{},ref:t,...g(`scrollContainer`),...h,children:(0,I.jsx)(`div`,{...g(`scrollContainerInner`),children:l})})});yv.classes=ov,yv.displayName=`@mantine/core/TableScrollContainer`;var bv={withRowBorders:!0,verticalSpacing:7},xv=On((e,{layout:t,captionSide:n,horizontalSpacing:r,verticalSpacing:i,borderColor:a,stripedColor:o,highlightOnHoverColor:s,striped:c,highlightOnHover:l,stickyHeaderOffset:u,stickyHeader:d})=>({table:{"--table-layout":t,"--table-caption-side":n,"--table-horizontal-spacing":yt(r),"--table-vertical-spacing":yt(i),"--table-border-color":a?rr(a,e):void 0,"--table-striped-color":c&&o?rr(o,e):void 0,"--table-highlight-on-hover-color":l&&s?rr(s,e):void 0,"--table-sticky-header-offset":d?F(u):void 0}})),W=z((e,t)=>{let n=L(`Table`,bv,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,horizontalSpacing:l,verticalSpacing:u,captionSide:d,stripedColor:f,highlightOnHoverColor:p,striped:m,highlightOnHover:h,withColumnBorders:g,withRowBorders:_,withTableBorder:v,borderColor:y,layout:b,variant:x,data:S,children:C,stickyHeader:w,stickyHeaderOffset:T,mod:E,tabularNums:D,attributes:O,...k}=n,A=ii({name:`Table`,props:n,className:i,style:a,classes:ov,classNames:r,styles:o,unstyled:s,attributes:O,rootSelector:`table`,vars:c,varsResolver:xv});return(0,I.jsx)(iv,{value:{getStyles:A,stickyHeader:w,striped:m===!0?`odd`:m||void 0,highlightOnHover:h,withColumnBorders:g,withRowBorders:_,captionSide:d||`bottom`},children:(0,I.jsx)(R,{component:`table`,variant:x,ref:t,mod:[{"data-with-table-border":v,"data-tabular-nums":D},E],...A(`table`),...k,children:C||!!S&&(0,I.jsx)(gv,{data:S})})})});W.classes=ov,W.displayName=`@mantine/core/Table`,W.Td=uv,W.Th=lv,W.Tr=dv,W.Thead=fv,W.Tbody=pv,W.Tfoot=mv,W.Caption=hv,W.ScrollContainer=yv,W.DataRenderer=gv;var[Sv,Cv]=ot(`Tabs component was not found in the tree`),wv={root:`m_89d60db1`,"list--default":`m_576c9d4`,list:`m_89d33d6d`,tab:`m_4ec4dce6`,panel:`m_b0c91715`,tabSection:`m_fc420b1f`,tabLabel:`m_42bbd1ae`,"tab--default":`m_539e827b`,"list--outline":`m_6772fbd5`,"tab--outline":`m_b59ab47c`,"tab--pills":`m_c3381914`},Tv=z((e,t)=>{let n=L(`TabsList`,null,e),{children:r,className:i,grow:a,justify:o,classNames:s,styles:c,style:l,mod:u,...d}=n,f=Cv();return(0,I.jsx)(R,{...d,...f.getStyles(`list`,{className:i,style:l,classNames:s,styles:c,props:n,variant:f.variant}),ref:t,role:`tablist`,variant:f.variant,mod:[{grow:a,orientation:f.orientation,placement:f.orientation===`vertical`&&f.placement,inverted:f.inverted},u],"aria-orientation":f.orientation,__vars:{"--tabs-justify":o},children:r})});Tv.classes=wv,Tv.displayName=`@mantine/core/TabsList`;var Ev=z((e,t)=>{let n=L(`TabsPanel`,null,e),{children:r,className:i,value:a,classNames:o,styles:s,style:c,mod:l,keepMounted:u,...d}=n,f=Cv(),p=f.value===a,m=f.keepMounted||u||p?r:null;return(0,I.jsx)(R,{...f.getStyles(`panel`,{className:i,classNames:o,styles:s,style:[c,p?void 0:{display:`none`}],props:n}),ref:t,mod:[{orientation:f.orientation},l],role:`tabpanel`,id:f.getPanelId(a),"aria-labelledby":f.getTabId(a),...d,children:m})});Ev.classes=wv,Ev.displayName=`@mantine/core/TabsPanel`;var Dv=z((e,t)=>{let n=L(`TabsTab`,null,e),{className:r,children:i,rightSection:a,leftSection:o,value:s,onClick:c,onKeyDown:l,disabled:u,color:d,style:f,classNames:p,styles:m,vars:h,mod:g,tabIndex:_,...v}=n,y=br(),{dir:b}=Gi(),x=Cv(),S=s===x.value,C=e=>{x.onChange(x.allowTabDeactivation&&s===x.value?null:s),c?.(e)},w={classNames:p,styles:m,props:n};return(0,I.jsxs)(gl,{...x.getStyles(`tab`,{className:r,style:f,variant:x.variant,...w}),disabled:u,unstyled:x.unstyled,variant:x.variant,mod:[{active:S,disabled:u,orientation:x.orientation,inverted:x.inverted,placement:x.orientation===`vertical`&&x.placement},g],ref:t,role:`tab`,id:x.getTabId(s),"aria-selected":S,tabIndex:_===void 0?S||x.value===null?0:-1:_,"aria-controls":x.getPanelId(s),onClick:C,__vars:{"--tabs-color":d?rr(d,y):void 0},onKeyDown:pt({siblingSelector:`[role="tab"]`,parentSelector:`[role="tablist"]`,activateOnFocus:x.activateTabWithKeyboard,loop:x.loop,orientation:x.orientation||`horizontal`,dir:b,onKeyDown:l}),...v,children:[o&&(0,I.jsx)(`span`,{...x.getStyles(`tabSection`,w),"data-position":`left`,children:o}),i&&(0,I.jsx)(`span`,{...x.getStyles(`tabLabel`,w),children:i}),a&&(0,I.jsx)(`span`,{...x.getStyles(`tabSection`,w),"data-position":`right`,children:a})]})});Dv.classes=wv,Dv.displayName=`@mantine/core/TabsTab`;var Ov=`Tabs.Tab or Tabs.Panel component was rendered with invalid value or without value`,kv={keepMounted:!0,orientation:`horizontal`,loop:!0,activateTabWithKeyboard:!0,variant:`default`,placement:`left`},Av=On((e,{radius:t,color:n,autoContrast:r})=>({root:{"--tabs-radius":bt(t),"--tabs-color":rr(n,e),"--tabs-text-color":ai(r,e)?Tr({color:n,theme:e,autoContrast:r}):void 0}})),jv=z((e,t)=>{let n=L(`Tabs`,kv,e),{defaultValue:r,value:i,onChange:a,orientation:o,children:s,loop:c,id:l,activateTabWithKeyboard:u,allowTabDeactivation:d,variant:f,color:p,radius:m,inverted:h,placement:g,keepMounted:_,classNames:v,styles:y,unstyled:b,className:x,style:S,vars:C,autoContrast:w,mod:T,attributes:E,...D}=n,O=rn(l),[k,A]=ln({value:i,defaultValue:r,finalValue:null,onChange:a}),j=ii({name:`Tabs`,props:n,classes:wv,className:x,style:S,classNames:v,styles:y,unstyled:b,attributes:E,vars:C,varsResolver:Av});return(0,I.jsx)(Sv,{value:{placement:g,value:k,orientation:o,id:O,loop:c,activateTabWithKeyboard:u,getTabId:ct(`${O}-tab`,Ov),getPanelId:ct(`${O}-panel`,Ov),onChange:A,allowTabDeactivation:d,variant:f,color:p,radius:m,inverted:h,keepMounted:_,unstyled:b,getStyles:j},children:(0,I.jsx)(R,{ref:t,id:O,variant:f,mod:[{orientation:o,inverted:o===`horizontal`&&h,placement:o===`vertical`&&g},T],...j(`root`),...D,children:s})})});jv.classes=wv,jv.displayName=`@mantine/core/Tabs`,jv.Tab=Dv,jv.Panel=Ev,jv.List=Tv;var Mv=z((e,t)=>(0,I.jsx)(gd,{component:`input`,ref:t,...L(`TextInput`,null,e),__staticSelector:`TextInput`}));Mv.classes=gd.classes,Mv.displayName=`@mantine/core/TextInput`;var Nv=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`],Pv=[`xs`,`sm`,`md`,`lg`,`xl`];function Fv(e,t){let n=t===void 0?`h${e}`:t;return Nv.includes(n)?{fontSize:`var(--mantine-${n}-font-size)`,fontWeight:`var(--mantine-${n}-font-weight)`,lineHeight:`var(--mantine-${n}-line-height)`}:Pv.includes(n)?{fontSize:`var(--mantine-font-size-${n})`,fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}:{fontSize:F(n),fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}}var Iv={root:`m_8a5d1357`},Lv={order:1},Rv=On((e,{order:t,size:n,lineClamp:r,textWrap:i})=>{let a=Fv(t||1,n);return{root:{"--title-fw":a.fontWeight,"--title-lh":a.lineHeight,"--title-fz":a.fontSize,"--title-line-clamp":typeof r==`number`?r.toString():void 0,"--title-text-wrap":i}}}),zv=z((e,t)=>{let n=L(`Title`,Lv,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,order:c,vars:l,size:u,variant:d,lineClamp:f,textWrap:p,mod:m,attributes:h,...g}=n,_=ii({name:`Title`,props:n,classes:Iv,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:h,vars:l,varsResolver:Rv});return[1,2,3,4,5,6].includes(c)?(0,I.jsx)(R,{..._(`root`),component:`h${c}`,variant:d,ref:t,mod:[{order:c,"data-line-clamp":typeof f==`number`},m],size:u,...g}):null});zv.classes=Iv,zv.displayName=`@mantine/core/Title`;var Bv=o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs=r()})(e,(function(){var e=1e3,t=6e4,n=36e5,r=`millisecond`,i=`second`,a=`minute`,o=`hour`,s=`day`,c=`week`,l=`month`,u=`quarter`,d=`year`,f=`date`,p=`Invalid Date`,m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:`en`,weekdays:`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),months:`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),ordinal:function(e){var t=[`th`,`st`,`nd`,`rd`],n=e%100;return`[`+e+(t[(n-20)%10]||t[n]||t[0])+`]`}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:``+Array(t+1-r.length).join(n)+e},v={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?`+`:`-`)+_(r,2,`0`)+`:`+_(i,2,`0`)},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,l),a=n-i<0,o=t.clone().add(r+(a?-1:1),l);return+(-(r+(n-i)/(a?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:d,w:c,d:s,D:f,h:o,m:a,s:i,ms:r,Q:u}[e]||String(e||``).toLowerCase().replace(/s$/,``)},u:function(e){return e===void 0}},y=`en`,b={};b[y]=g;var x=`$isDayjsObject`,S=function(e){return e instanceof E||!(!e||!e[x])},C=function e(t,n,r){var i;if(!t)return y;if(typeof t==`string`){var a=t.toLowerCase();b[a]&&(i=a),n&&(b[a]=n,i=a);var o=t.split(`-`);if(!i&&o.length>1)return e(o[0])}else{var s=t.name;b[s]=t,i=s}return!r&&i&&(y=i),i||!r&&y},w=function(e,t){if(S(e))return e.clone();var n=typeof t==`object`?t:{};return n.date=e,n.args=arguments,new E(n)},T=v;T.l=C,T.i=S,T.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=C(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[x]=!0}var _=g.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(t===null)return new Date(NaN);if(T.u(t))return new Date;if(t instanceof Date)return new Date(t);if(typeof t==`string`&&!/Z$/i.test(t)){var r=t.match(m);if(r){var i=r[2]-1||0,a=(r[7]||`0`).substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return T},_.isValid=function(){return this.$d.toString()!==p},_.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return w(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<w(e)},_.$g=function(e,t,n){return T.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,r=!!T.u(t)||t,u=T.p(e),p=function(e,t){var i=T.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(s)},m=function(e,t){return T.w(n.toDate()[e].apply(n.toDate(`s`),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},h=this.$W,g=this.$M,_=this.$D,v=`set`+(this.$u?`UTC`:``);switch(u){case d:return r?p(1,0):p(31,11);case l:return r?p(1,g):p(0,g+1);case c:var y=this.$locale().weekStart||0,b=(h<y?h+7:h)-y;return p(r?_-b:_+(6-b),g);case s:case f:return m(v+`Hours`,0);case o:return m(v+`Minutes`,1);case a:return m(v+`Seconds`,2);case i:return m(v+`Milliseconds`,3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var n,c=T.p(e),u=`set`+(this.$u?`UTC`:``),p=(n={},n[s]=u+`Date`,n[f]=u+`Date`,n[l]=u+`Month`,n[d]=u+`FullYear`,n[o]=u+`Hours`,n[a]=u+`Minutes`,n[i]=u+`Seconds`,n[r]=u+`Milliseconds`,n)[c],m=c===s?this.$D+(t-this.$W):t;if(c===l||c===d){var h=this.clone().set(f,1);h.$d[p](m),h.init(),this.$d=h.set(f,Math.min(this.$D,h.daysInMonth())).$d}else p&&this.$d[p](m);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[T.p(e)]()},_.add=function(r,u){var f,p=this;r=Number(r);var m=T.p(u),h=function(e){var t=w(p);return T.w(t.date(t.date()+Math.round(e*r)),p)};if(m===l)return this.set(l,this.$M+r);if(m===d)return this.set(d,this.$y+r);if(m===s)return h(1);if(m===c)return h(7);var g=(f={},f[a]=t,f[o]=n,f[i]=e,f)[m]||1,_=this.$d.getTime()+r*g;return T.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var r=e||`YYYY-MM-DDTHH:mm:ssZ`,i=T.z(this),a=this.$H,o=this.$m,s=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,d=function(e,n,i,a){return e&&(e[n]||e(t,r))||i[n].slice(0,a)},f=function(e){return T.s(a%12||12,e,`0`)},m=u||function(e,t,n){var r=e<12?`AM`:`PM`;return n?r.toLowerCase():r};return r.replace(h,(function(e,r){return r||function(e){switch(e){case`YY`:return String(t.$y).slice(-2);case`YYYY`:return T.s(t.$y,4,`0`);case`M`:return s+1;case`MM`:return T.s(s+1,2,`0`);case`MMM`:return d(n.monthsShort,s,l,3);case`MMMM`:return d(l,s);case`D`:return t.$D;case`DD`:return T.s(t.$D,2,`0`);case`d`:return String(t.$W);case`dd`:return d(n.weekdaysMin,t.$W,c,2);case`ddd`:return d(n.weekdaysShort,t.$W,c,3);case`dddd`:return c[t.$W];case`H`:return String(a);case`HH`:return T.s(a,2,`0`);case`h`:return f(1);case`hh`:return f(2);case`a`:return m(a,o,!0);case`A`:return m(a,o,!1);case`m`:return String(o);case`mm`:return T.s(o,2,`0`);case`s`:return String(t.$s);case`ss`:return T.s(t.$s,2,`0`);case`SSS`:return T.s(t.$ms,3,`0`);case`Z`:return i}return null}(e)||i.replace(`:`,``)}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(r,f,p){var m,h=this,g=T.p(f),_=w(r),v=(_.utcOffset()-this.utcOffset())*t,y=this-_,b=function(){return T.m(h,_)};switch(g){case d:m=b()/12;break;case l:m=b();break;case u:m=b()/3;break;case c:m=(y-v)/6048e5;break;case s:m=(y-v)/864e5;break;case o:m=y/n;break;case a:m=y/t;break;case i:m=y/e;break;default:m=y}return p?m:T.a(m)},_.daysInMonth=function(){return this.endOf(l).$D},_.$locale=function(){return b[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=C(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return T.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},g}(),D=E.prototype;return w.prototype=D,[[`$ms`,r],[`$s`,i],[`$m`,a],[`$H`,o],[`$W`,s],[`$M`,l],[`$y`,d],[`$D`,f]].forEach((function(e){D[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),w.extend=function(e,t){return e.$i||=(e(t,E,w),!0),w},w.locale=C,w.isDayjs=S,w.unix=function(e){return w(1e3*e)},w.en=b[y],w.Ls=b,w.p={},w}))}));function Vv({direction:e,levelIndex:t,rowIndex:n,cellIndex:r,size:i}){switch(e){case`up`:return t===0&&n===0?null:n===0?{levelIndex:t-1,rowIndex:r<=i[t-1][i[t-1].length-1]-1?i[t-1].length-1:i[t-1].length-2,cellIndex:r}:{levelIndex:t,rowIndex:n-1,cellIndex:r};case`down`:return n===i[t].length-1||n===i[t].length-2&&r>=i[t][i[t].length-1]?{levelIndex:t+1,rowIndex:0,cellIndex:r}:{levelIndex:t,rowIndex:n+1,cellIndex:r};case`left`:return t===0&&n===0&&r===0?null:n===0&&r===0?{levelIndex:t-1,rowIndex:i[t-1].length-1,cellIndex:i[t-1][i[t-1].length-1]-1}:r===0?{levelIndex:t,rowIndex:n-1,cellIndex:i[t][n-1]-1}:{levelIndex:t,rowIndex:n,cellIndex:r-1};case`right`:return n===i[t].length-1&&r===i[t][n]-1?{levelIndex:t+1,rowIndex:0,cellIndex:0}:r===i[t][n]-1?{levelIndex:t,rowIndex:n+1,cellIndex:0}:{levelIndex:t,rowIndex:n,cellIndex:r+1};default:return{levelIndex:t,rowIndex:n,cellIndex:r}}}function Hv({controlsRef:e,direction:t,levelIndex:n,rowIndex:r,cellIndex:i,size:a}){let o=Vv({direction:t,size:a,rowIndex:r,cellIndex:i,levelIndex:n});if(!o)return;let s=e.current?.[o.levelIndex]?.[o.rowIndex]?.[o.cellIndex];s&&(s.disabled||s.getAttribute(`data-hidden`)||s.getAttribute(`data-outside`)?Hv({controlsRef:e,direction:t,levelIndex:o.levelIndex,cellIndex:o.cellIndex,rowIndex:o.rowIndex,size:a}):s.focus())}function Uv(e){switch(e){case`ArrowDown`:return`down`;case`ArrowUp`:return`up`;case`ArrowRight`:return`right`;case`ArrowLeft`:return`left`;default:return null}}function Wv(e){return e.current?.map(e=>e.map(e=>e.length))}function Gv({controlsRef:e,levelIndex:t,rowIndex:n,cellIndex:r,event:i}){let a=Uv(i.key);a&&(i.preventDefault(),Hv({controlsRef:e,direction:a,levelIndex:t,rowIndex:n,cellIndex:r,size:Wv(e)}))}var G=l(Bv(),1);function Kv(e,t){let n=e?(0,G.default)(e):(0,G.default)();if(t===``)return n.format(`YYYY-MM-DD HH:mm:ss`);let[r,i,a=0]=t.split(`:`).map(Number);return n=n.set(`hour`,r),n=n.set(`minute`,i),n=n.set(`second`,a),n=n.set(`millisecond`,0),n.format(`YYYY-MM-DD HH:mm:ss`)}function qv(e){return e==null||e===``?e:(0,G.default)(e).format(`YYYY-MM-DD`)}function Jv(e){return e==null||e===``?e:(0,G.default)(e).format(`YYYY-MM-DD HH:mm:ss`)}function Yv({minDate:e,maxDate:t}){let n=(0,G.default)();return!e&&!t?qv(n):e&&(0,G.default)(n).isBefore(e)?qv(e):t&&(0,G.default)(n).isAfter(t)?qv(t):qv(n)}function Xv(e,t,n){return!e&&!t?Jv(n):e&&(0,G.default)(n).isBefore(e)?Jv(e):t&&(0,G.default)(n).isAfter(t)?Jv(t):Jv(n)}var Zv={locale:`en`,firstDayOfWeek:1,weekendDays:[0,6],labelSeparator:`–`,consistentWeeks:!1},Qv=(0,v.createContext)(Zv);function $v({settings:e,children:t}){return(0,I.jsx)(Qv.Provider,{value:{...Zv,...e},children:t})}function ey(){let e=(0,v.useContext)(Qv),t=(0,v.useCallback)(t=>t||e.locale,[e.locale]),n=(0,v.useCallback)(t=>typeof t==`number`?t:e.firstDayOfWeek,[e.firstDayOfWeek]),r=(0,v.useCallback)(t=>Array.isArray(t)?t:e.weekendDays,[e.weekendDays]),i=(0,v.useCallback)(t=>typeof t==`string`?t:e.labelSeparator,[e.labelSeparator]);return{...e,getLocale:t,getFirstDayOfWeek:n,getWeekendDays:r,getLabelSeparator:i}}function ty({value:e,type:t,withTime:n}){let r=n?Jv:qv;if(t===`range`&&Array.isArray(e)){let t=r(e[0]),n=r(e[1]);return t?n?`${t} \u2013 ${n}`:`${t} \u2013`:``}return t===`multiple`&&Array.isArray(e)?e.filter(Boolean).join(`, `):!Array.isArray(e)&&e?r(e):``}function ny({value:e,type:t,name:n,form:r,withTime:i=!1}){return(0,I.jsx)(`input`,{type:`hidden`,value:ty({value:e,type:t,withTime:i}),name:n,form:r})}ny.displayName=`@mantine/dates/HiddenDatesInput`;function ry(e){return e<10?`0${e}`:`${e}`}var iy=e=>Number(e.toFixed(0)[0]),ay=(0,v.forwardRef)(({value:e,min:t,max:n,onChange:r,focusable:i,step:a,onNextInput:o,onPreviousInput:s,onFocus:c,readOnly:l,allowTemporaryZero:u=!1,placeholder:d=`--`,...f},p)=>{let m=iy(n),h=n+1-a,g=e=>{if(l)return;let i=e.replace(/\D/g,``);if(i!==``){let a=parseInt(i,10),s=u&&a===0&&t>0?0:kt(a,t,n);r(s),(s>m||e.startsWith(`00`))&&o?.()}},_=i=>{l||((i.key===`0`||i.key===`Num0`)&&e===0&&(i.preventDefault(),o?.()),i.key===`Home`&&(i.preventDefault(),r(t)),i.key===`End`&&(i.preventDefault(),r(n)),(i.key===`Backspace`||i.key===`Delete`)&&(i.preventDefault(),e===null?s?.():r(null)),i.key===`ArrowRight`&&(i.preventDefault(),o?.()),i.key===`ArrowLeft`&&(i.preventDefault(),s?.()),i.key===`ArrowUp`&&(i.preventDefault(),r(e===null?t:kt(e+a,t,h))),i.key===`ArrowDown`&&(i.preventDefault(),r(e===null?h:kt(e-a,t,h))))};return(0,I.jsx)(`input`,{ref:p,type:`text`,role:`spinbutton`,"aria-valuemin":t,"aria-valuemax":n,"aria-valuenow":e===null?0:e,"data-empty":e===null||void 0,inputMode:`numeric`,placeholder:d,value:e===null?``:ry(e),onChange:e=>g(e.currentTarget.value),onKeyDown:_,onFocus:e=>{e.currentTarget.select(),c?.(e)},onClick:e=>{e.stopPropagation(),e.currentTarget.select()},onMouseDown:e=>e.stopPropagation(),...f})});ay.displayName=`@mantine/dates/SpinInput`;var[oy,sy]=ot(`TimeInput component was not found in the component tree`),cy=(0,v.forwardRef)(({labels:e,value:t,onChange:n,className:r,style:i,onPreviousInput:a,readOnly:o,onMouseDown:s,onTouchStart:c,inputType:l,...u},d)=>{let f=sy(),p=r=>{o||(r.key===`Home`&&(r.preventDefault(),n(e.am)),r.key===`End`&&(r.preventDefault(),n(e.pm)),(r.key===`Backspace`||r.key===`Delete`)&&(r.preventDefault(),t===null?a?.():n(null)),r.key===`ArrowLeft`&&(r.preventDefault(),a?.()),(r.key===`ArrowUp`||r.key===`ArrowDown`)&&(r.preventDefault(),n(t===e.am?e.pm:e.am)),r.code===`KeyA`&&(r.preventDefault(),n(e.am)),r.code===`KeyP`&&(r.preventDefault(),n(e.pm)))};if(l===`input`){let e=t||`--`,n=e.length+1;return(0,I.jsx)(`input`,{...f.getStyles(`field`,{className:r,style:i}),ref:d,value:e,size:n,readOnly:!0,onChange:()=>{},onClick:(e=>e.stopPropagation()),onKeyDown:p,onMouseDown:e=>{e.stopPropagation(),s?.(e)},"data-am-pm":!0,...u})}return(0,I.jsxs)(`select`,{...f.getStyles(`field`,{className:r,style:i}),ref:d,value:t||``,onChange:e=>!o&&n(e.target.value||null),onClick:e=>e.stopPropagation(),onKeyDown:p,onMouseDown:e=>{e.stopPropagation(),s?.(e)},"data-am-pm":!0,...u,children:[(0,I.jsx)(`option`,{value:``,children:`--`}),(0,I.jsx)(`option`,{value:e.am,children:e.am}),(0,I.jsx)(`option`,{value:e.pm,children:e.pm})]})});cy.displayName=`@mantine/dates/AmPmInput`;function ly({value:e,active:t,onSelect:n}){let r=sy();return(0,I.jsx)(gl,{mod:{active:t},onClick:()=>n(e),onMouseDown:e=>e.preventDefault(),"data-value":e,tabIndex:-1,...r.getStyles(`control`),children:typeof e==`number`?ry(e):e})}ly.displayName=`@mantine/dates/TimeControl`;function uy({labels:e,value:t,onSelect:n}){let r=sy(),i=[e.am,e.pm].map(e=>(0,I.jsx)(ly,{value:e,active:t===e,onSelect:n},e));return(0,I.jsx)(`div`,{...r.getStyles(`controlsList`),children:i})}uy.displayName=`@mantine/dates/AmPmControlsList`;function dy(e,t){if(!e||!t)return!1;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top>=r.top&&n.bottom<=r.bottom&&n.left>=r.left&&n.right<=r.right}function fy(e,t,n){let r=[];for(let i=e;i<=t;i+=n)r.push(i);return r}function py({min:e,max:t,step:n,value:r,onSelect:i,reversed:a}){let o=sy(),s=(0,v.useRef)(null),c=fy(e,t,n),l=(a?c.reverse():c).map(e=>(0,I.jsx)(ly,{value:e,active:r===e,onSelect:i},e));return(0,v.useEffect)(()=>{r!==null&&requestAnimationFrame(()=>{let e=s.current?.querySelector(`[data-value="${r}"]`);dy(e,s.current)||e?.scrollIntoView({block:`nearest`})})},[r]),(0,I.jsx)(fl,{h:o.maxDropdownContentHeight,type:`never`,viewportRef:s,...o.getStyles(`scrollarea`),...o.scrollAreaProps,children:(0,I.jsx)(`div`,{...o.getStyles(`controlsList`),children:l})})}py.displayName=`@mantine/dates/TimeControlsList`;var my={fieldsRoot:`m_7a8f1e6d`,fieldsGroup:`m_d6bb0a54`,controlsList:`m_b97ecb26`,controlsListGroup:`m_31fe42f9`,dropdown:`m_9c4817c3`,control:`m_154c536b`,presetControl:`m_7be09d0c`,presetsGroup:`m_7d00001d`,presetsGroupLabel:`m_d8d918d7`,field:`m_6b43ba88`};function hy(e){let[t=null,n=null,r=null]=e.split(`:`).map(Number);return{hours:t,minutes:n,seconds:r}}function gy({time:e,compare:t,withSeconds:n}){let r=hy(e),i=hy(t);return n?r.hours===i.hours&&r.minutes===i.minutes&&r.seconds===i.seconds:r.hours===i.hours&&r.minutes===i.minutes}function _y(e,t){return`${e.getHours()}:${e.getMinutes()}${t?`:${e.getSeconds()}`:``}`}function vy({value:e,format:t,amPmLabels:n,withSeconds:r}){let i=hy(typeof e==`string`?e:_y(e,r));if(i.hours===null||i.minutes===null)return null;if(t===`24h`)return`${ry(i.hours)}:${ry(i.minutes)}${r?`:${ry(i.seconds||0)}`:``}`;let a=i.hours>=12;return`${i.hours%12==0?12:i.hours%12}:${ry(i.minutes)}${r?`:${ry(i.seconds||0)}`:``} ${a?n.pm:n.am}`}function yy({value:e,format:t=`24h`,amPmLabels:n={am:`AM`,pm:`PM`},withSeconds:r=!1}){return(0,I.jsx)(I.Fragment,{children:vy({value:e,format:t,amPmLabels:n,withSeconds:r})})}yy.displayName=`@mantine/dates/TimeValue`;function by({value:e,active:t,onChange:n,format:r,amPmLabels:i,withSeconds:a}){let o=sy();return(0,I.jsx)(gl,{mod:{active:t},onClick:()=>n(e),...o.getStyles(`presetControl`),children:(0,I.jsx)(yy,{withSeconds:a,value:e,format:r,amPmLabels:i})})}by.displayName=`@mantine/dates/TimePresetControl`;function xy({value:e,data:t,onChange:n,format:r,amPmLabels:i,withSeconds:a}){let o=sy(),s=t.values.map(t=>(0,I.jsx)(by,{value:t,format:r,amPmLabels:i,withSeconds:a,active:gy({time:t,compare:e,withSeconds:a}),onChange:n},t));return(0,I.jsxs)(`div`,{...o.getStyles(`presetsGroup`),children:[(0,I.jsx)(`div`,{...o.getStyles(`presetsGroupLabel`),children:t.label}),(0,I.jsx)(K_,{cols:a?2:3,spacing:4,children:s})]})}xy.displayName=`@mantine/dates/TimePresetGroup`;function Sy({presets:e,format:t,amPmLabels:n,withSeconds:r,value:i,onChange:a}){let o=sy();if(e.length===0)return null;if(typeof e[0]==`string`){let s=e.map(e=>(0,I.jsx)(by,{value:e,format:t,amPmLabels:n,withSeconds:r,active:gy({time:e,compare:i,withSeconds:r}),onChange:a},e));return(0,I.jsx)(fl.Autosize,{mah:o.maxDropdownContentHeight,type:`never`,...o.getStyles(`scrollarea`),...o.scrollAreaProps,children:(0,I.jsx)(`div`,{...o.getStyles(`presetsRoot`),children:(0,I.jsx)(K_,{cols:r?2:3,spacing:4,children:s})})})}let s=e.map((e,o)=>(0,I.jsx)(xy,{data:e,value:i,format:t,amPmLabels:n,withSeconds:r,onChange:a},o));return(0,I.jsx)(fl.Autosize,{mah:o.maxDropdownContentHeight,type:`never`,...o.getStyles(`scrollarea`),...o.scrollAreaProps,children:(0,I.jsx)(`div`,{...o.getStyles(`presetsRoot`),children:s})})}Sy.displayName=`@mantine/dates/TimePresets`;function Cy(e){let[t=0,n=0,r=0]=e.split(`:`).map(Number);return t*3600+n*60+r}function wy(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return{timeString:`${ry(t)}:${ry(n)}:${ry(r)}`,hours:t,minutes:n,seconds:r}}function Ty(e,t,n){let r=Cy(e),i=t?Cy(t):-1/0,a=n?Cy(n):1/0;return wy(Math.max(i,Math.min(r,a)))}function Ey({hours:e,minutes:t,seconds:n,amPmLabels:r}){if(e===null)return{hours:null,minutes:null,seconds:null,amPm:null};let i=e>=12?r.pm:r.am;return{hours:e%12==0?12:e%12,minutes:typeof t==`number`?t:null,seconds:typeof n==`number`?n:null,amPm:i}}function Dy({time:e,format:t,amPmLabels:n}){if(e===``)return{hours:null,minutes:null,seconds:null,amPm:null};let{hours:r,minutes:i,seconds:a}=hy(e),o={hours:r,minutes:i,seconds:a};return t===`12h`?Ey({...o,amPmLabels:n}):{...o,amPm:null}}function Oy({hours:e,minutes:t,seconds:n,amPm:r,amPmLabels:i,withSeconds:a}){let o=e;return r===i.pm&&e!==12?o+=12:r===i.am&&e===12&&(o=0),`${ry(o)}:${ry(t)}${a?`:${ry(n||0)}`:``}`}function ky({hours:e,minutes:t,seconds:n,format:r,withSeconds:i,amPm:a,amPmLabels:o}){return e===null||t===null||i&&n===null?{valid:!1,value:``}:r===`24h`?{valid:!0,value:`${ry(e)}:${ry(t)}${i?`:${ry(n)}`:``}`}:a===null?{valid:!1,value:``}:{valid:!0,value:Oy({hours:e,minutes:t,seconds:n,amPm:a,amPmLabels:o,withSeconds:i})}}function Ay({value:e,defaultValue:t,onChange:n,format:r,amPmLabels:i,withSeconds:a=!1,min:o,max:s,clearable:c,readOnly:l,disabled:u,pasteSplit:d}){let f=Dy({time:e||t||``,amPmLabels:i,format:r}),p=ky({hours:f.hours,minutes:f.minutes,seconds:f.seconds,format:r,withSeconds:a,amPm:f.amPm,amPmLabels:i}),m=(0,v.useRef)(!0),h=(0,v.useRef)(!p.valid),[g,_]=(0,v.useState)(f.hours),[y,b]=(0,v.useState)(f.minutes),[x,S]=(0,v.useState)(f.seconds),[C,w]=(0,v.useState)(f.amPm),T=c&&!l&&!u&&(g!==null||y!==null||x!==null||C!==null),E=(0,v.useRef)(null),D=(0,v.useRef)(null),O=(0,v.useRef)(null),k=(0,v.useRef)(null),A=e=>{e===`hours`&&E.current?.focus(),e===`minutes`&&D.current?.focus(),e===`seconds`&&O.current?.focus(),e===`amPm`&&k.current?.focus()},j=(e,t)=>{let o=ky({hours:g,minutes:y,seconds:x,amPm:C,[e]:t,format:r,withSeconds:a,amPmLabels:i});o.valid?(m.current=!1,h.current=!1,e===`hours`&&_(t),e===`minutes`&&b(t),e===`seconds`&&S(t),e===`amPm`&&w(t),n?.(o.value)):(m.current=!1,h.current||=(n?.(``),!0))},ee=e=>{m.current=!1;let t=Dy({time:e,amPmLabels:i,format:r});_(t.hours),b(t.minutes),S(t.seconds),w(t.amPm),h.current=!ky({...t,format:r,withSeconds:a,amPmLabels:i}).valid,n?.(e)},te=e=>{let t=e;r===`12h`&&typeof e==`number`&&e>12&&(t=(e-1)%12+1),_(t),j(`hours`,t),A(`hours`)},ne=e=>{b(e),j(`minutes`,e),A(`minutes`)},re=e=>{S(e),j(`seconds`,e),A(`seconds`)},M=e=>{w(e),j(`amPm`,e),A(`amPm`)},N=()=>{m.current=!1,_(null),b(null),S(null),w(null),n?.(``),h.current=!0,A(`hours`)},ie=e=>{e.preventDefault();let t=e.clipboardData.getData(`text`),c=(d||Dy)({time:t,format:r,amPmLabels:i}),l=ky({...c,format:r,withSeconds:a,amPmLabels:i});if(l.valid){m.current=!1;let e=Ty(l.value,o||`00:00:00`,s||`23:59:59`);n?.(e.timeString),_(c.hours),b(c.minutes),S(c.seconds),w(c.amPm)}},ae=ky({hours:g,minutes:y,seconds:x,format:r,withSeconds:a,amPm:C,amPmLabels:i});return Vt(()=>{if(e===``){m.current=!1,_(null),b(null),S(null),w(null),m.current=!0;return}if(m.current&&typeof e==`string`){let t=Dy({time:e||``,amPmLabels:i,format:r});_(t.hours),b(t.minutes),S(t.seconds),w(t.amPm)}m.current=!0},[e]),{refs:{hours:E,minutes:D,seconds:O,amPm:k},values:{hours:g,minutes:y,seconds:x,amPm:C},setHours:te,setMinutes:ne,setSeconds:re,setAmPm:M,focus:A,clear:N,onPaste:ie,setTimeString:ee,isClearable:T,hiddenInputValue:ae.value}}var jy={hoursStep:1,minutesStep:1,secondsStep:1,format:`24h`,amPmLabels:{am:`AM`,pm:`PM`},pasteSplit:Dy,maxDropdownContentHeight:200,hoursPlaceholder:`--`,minutesPlaceholder:`--`,secondsPlaceholder:`--`},My=On((e,{size:t})=>({dropdown:{"--control-font-size":xt(t)}})),Ny=z((e,t)=>{let n=L(`TimePicker`,jy,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,onClick:l,format:u,value:d,defaultValue:f,onChange:p,hoursStep:m,minutesStep:h,secondsStep:g,withSeconds:_,hoursInputLabel:y,minutesInputLabel:b,secondsInputLabel:x,amPmInputLabel:S,amPmLabels:C,clearable:w,onMouseDown:T,onFocusCapture:E,onBlurCapture:D,min:O,max:k,popoverProps:A,withDropdown:j,rightSection:ee,onFocus:te,onBlur:ne,clearButtonProps:re,hoursInputProps:M,minutesInputProps:N,secondsInputProps:ie,amPmSelectProps:ae,readOnly:oe,disabled:se,size:ce,name:le,form:ue,hiddenInputProps:de,labelProps:fe,pasteSplit:pe,hoursRef:me,minutesRef:he,secondsRef:ge,amPmRef:_e,presets:ve,maxDropdownContentHeight:ye,scrollAreaProps:be,attributes:xe,reverseTimeControlsList:Se,hoursPlaceholder:Ce,minutesPlaceholder:we,secondsPlaceholder:Te,...Ee}=n,{resolvedClassNames:De,resolvedStyles:Oe}=Vr({classNames:r,styles:o,props:n}),ke=ii({name:`TimePicker`,classes:my,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:xe,vars:c,varsResolver:My}),P=Ay({value:d,defaultValue:f,onChange:p,format:u,amPmLabels:C,withSeconds:_,min:O,max:k,clearable:w,disabled:se,readOnly:oe,pasteSplit:pe}),Ae=cn(P.refs.hours,me),je=cn(P.refs.minutes,he),Me=cn(P.refs.seconds,ge),Ne=cn(P.refs.amPm,_e),Pe=rn(),Fe=(0,v.useRef)(!1),[Ie,Le]=(0,v.useState)(!1),Re=e=>{Fe.current||(Fe.current=!0,te?.(e))},ze=e=>{if(!e.currentTarget.contains(e.relatedTarget)){let t=P.values,n=ky({...t,format:u,amPmLabels:C,withSeconds:!!_});if(n.valid&&(O||k)){let e=Ty(n.value,O,k);e.timeString!==n.value&&P.setTimeString(e.timeString)}Fe.current=!1,ne?.(e)}};return(0,I.jsx)(oy,{value:{getStyles:ke,scrollAreaProps:be,maxDropdownContentHeight:ye},children:(0,I.jsxs)(nu,{opened:Ie,transitionProps:{duration:0},position:`bottom-start`,withRoles:!1,disabled:se||oe||!j,...A,children:[(0,I.jsx)(nu.Target,{children:(0,I.jsxs)(gd,{component:`div`,size:ce,disabled:se,ref:t,onClick:e=>{l?.(e),P.focus(`hours`)},onMouseDown:e=>{e.preventDefault(),T?.(e)},onFocusCapture:e=>{Le(!0),E?.(e)},onBlurCapture:e=>{Le(!1),D?.(e)},rightSection:ee||P.isClearable&&(0,I.jsx)(Cu,{...re,size:ce,onClick:e=>{P.clear(),re?.onClick?.(e)},onMouseDown:e=>{e.preventDefault(),re?.onMouseDown?.(e)}}),labelProps:{htmlFor:Pe,...fe},style:a,className:i,classNames:De,styles:Oe,__staticSelector:`TimePicker`,...Ee,children:[(0,I.jsx)(`div`,{...ke(`fieldsRoot`),dir:`ltr`,children:(0,I.jsxs)(`div`,{...ke(`fieldsGroup`),onBlur:ze,children:[(0,I.jsx)(ay,{id:Pe,...M,...ke(`field`,{className:M?.className,style:M?.style}),value:P.values.hours,onChange:P.setHours,onNextInput:()=>P.focus(`minutes`),min:u===`12h`?1:0,max:u===`12h`?12:23,allowTemporaryZero:u===`12h`,focusable:!0,step:m,ref:Ae,"aria-label":y,readOnly:oe,disabled:se,onPaste:P.onPaste,onFocus:e=>{Re(e),M?.onFocus?.(e)},onBlur:e=>{let t=e.currentTarget.value;u===`12h`&&(t?parseInt(t,10):null)===0&&P.setHours(12),M?.onBlur?.(e)},placeholder:Ce}),(0,I.jsx)(`span`,{children:`:`}),(0,I.jsx)(ay,{...N,...ke(`field`,{className:N?.className,style:N?.style}),value:P.values.minutes,onChange:P.setMinutes,min:0,max:59,focusable:!0,step:h,ref:je,onPreviousInput:()=>P.focus(`hours`),onNextInput:()=>_?P.focus(`seconds`):P.focus(`amPm`),"aria-label":b,tabIndex:-1,readOnly:oe,disabled:se,onPaste:P.onPaste,onFocus:e=>{Re(e),N?.onFocus?.(e)},placeholder:we}),_&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{children:`:`}),(0,I.jsx)(ay,{...ie,...ke(`field`,{className:ie?.className,style:ie?.style}),value:P.values.seconds,onChange:P.setSeconds,min:0,max:59,focusable:!0,step:g,ref:Me,onPreviousInput:()=>P.focus(`minutes`),onNextInput:()=>P.focus(`amPm`),"aria-label":x,tabIndex:-1,readOnly:oe,disabled:se,onPaste:P.onPaste,onFocus:e=>{Re(e),ie?.onFocus?.(e)},placeholder:Te})]}),u===`12h`&&(0,I.jsx)(cy,{...ae,inputType:j?`input`:`select`,labels:C,value:P.values.amPm,onChange:P.setAmPm,ref:Ne,"aria-label":S,onPreviousInput:()=>_?P.focus(`seconds`):P.focus(`minutes`),readOnly:oe,disabled:se,tabIndex:-1,onPaste:P.onPaste,onFocus:e=>{Re(e),ae?.onFocus?.(e)}})]})}),(0,I.jsx)(`input`,{type:`hidden`,name:le,form:ue,value:P.hiddenInputValue,...de})]})}),(0,I.jsx)(nu.Dropdown,{...ke(`dropdown`),onMouseDown:e=>e.preventDefault(),children:ve?(0,I.jsx)(Sy,{value:P.hiddenInputValue,onChange:P.setTimeString,format:u,presets:ve,amPmLabels:C,withSeconds:_||!1}):(0,I.jsxs)(`div`,{...ke(`controlsListGroup`),children:[(0,I.jsx)(py,{min:u===`12h`?1:0,max:u===`12h`?12:23,step:m,value:P.values.hours,onSelect:P.setHours,reversed:Se}),(0,I.jsx)(py,{min:0,max:59,step:h,value:P.values.minutes,onSelect:P.setMinutes,reversed:Se}),_&&(0,I.jsx)(py,{min:0,max:59,step:g,value:P.values.seconds,onSelect:P.setSeconds,reversed:Se}),u===`12h`&&(0,I.jsx)(uy,{labels:C,value:P.values.amPm,onSelect:P.setAmPm})]})})]})})});Ny.displayName=`@mantine/dates/TimePicker`,Ny.classes=my;var Py={day:`m_396ce5cb`},Fy=On((e,{size:t})=>({day:{"--day-size":vt(t,`day-size`)}})),Iy=z((e,t)=>{let n=L(`Day`,null,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,date:l,disabled:u,__staticSelector:d,weekend:f,outside:p,selected:m,renderDay:h,inRange:g,firstInRange:_,lastInRange:v,hidden:y,static:b,highlightToday:x,attributes:S,...C}=n;return(0,I.jsx)(gl,{...ii({name:d||`Day`,classes:Py,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:S,vars:c,varsResolver:Fy,rootSelector:`day`})(`day`,{style:y?{display:`none`}:void 0}),component:b?`div`:`button`,ref:t,disabled:u,"data-today":(0,G.default)(l).isSame(new Date,`day`)||void 0,"data-hidden":y||void 0,"data-highlight-today":x||void 0,"data-disabled":u||void 0,"data-weekend":!u&&!p&&f||void 0,"data-outside":!u&&p||void 0,"data-selected":!u&&m||void 0,"data-in-range":g&&!u||void 0,"data-first-in-range":_&&!u||void 0,"data-last-in-range":v&&!u||void 0,"data-static":b||void 0,unstyled:s,...C,children:h?.(l)||(0,G.default)(l).date()})});Iy.classes=Py,Iy.displayName=`@mantine/dates/Day`;function Ly({locale:e,format:t=`dd`,firstDayOfWeek:n=1}){let r=(0,G.default)().day(n),i=[];for(let n=0;n<7;n+=1)typeof t==`string`?i.push((0,G.default)(r).add(n,`days`).locale(e).format(t)):i.push(t((0,G.default)(r).add(n,`days`).format(`YYYY-MM-DD`)));return i}var Ry={weekday:`m_18a3eca`},zy=On((e,{size:t})=>({weekdaysRow:{"--wr-fz":xt(t),"--wr-spacing":yt(t)}})),By=z((e,t)=>{let n=L(`WeekdaysRow`,null,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,locale:l,firstDayOfWeek:u,weekdayFormat:d,cellComponent:f=`th`,__staticSelector:p,withWeekNumbers:m,attributes:h,...g}=n,_=ii({name:p||`WeekdaysRow`,classes:Ry,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:h,vars:c,varsResolver:zy,rootSelector:`weekdaysRow`}),v=ey(),y=Ly({locale:v.getLocale(l),format:d,firstDayOfWeek:v.getFirstDayOfWeek(u)}).map((e,t)=>(0,I.jsx)(f,{..._(`weekday`),children:e},t));return(0,I.jsxs)(R,{component:`tr`,ref:t,..._(`weekdaysRow`),...g,children:[m&&(0,I.jsx)(f,{..._(`weekday`),children:`#`}),y]})});By.classes=Ry,By.displayName=`@mantine/dates/WeekdaysRow`;function Vy(e,t=1){let n=(0,G.default)(e);if(!n.isValid())return n;let r=t===0?6:t-1;for(;n.day()!==r;)n=n.add(1,`day`);return n.format(`YYYY-MM-DD`)}function Hy(e,t=1){let n=(0,G.default)(e);for(;n.day()!==t;)n=n.subtract(1,`day`);return n.format(`YYYY-MM-DD`)}function Uy({month:e,firstDayOfWeek:t=1,consistentWeeks:n}){let r=(0,G.default)((0,G.default)(e).subtract((0,G.default)(e).date()-1,`day`).format(`YYYY-M-D`)),i=r.format(`YYYY-MM-DD`),a=Vy(r.add(r.daysInMonth()-1,`day`).format(`YYYY-MM-DD`),t),o=[],s=(0,G.default)(Hy(i,t));for(;(0,G.default)(s).isBefore(a,`day`);){let e=[];for(let t=0;t<7;t+=1)e.push(s.format(`YYYY-MM-DD`)),s=s.add(1,`day`);o.push(e)}if(n&&o.length<6){let e=o[o.length-1],t=e[e.length-1],n=(0,G.default)(t).add(1,`day`);for(;o.length<6;){let e=[];for(let t=0;t<7;t+=1)e.push(n.format(`YYYY-MM-DD`)),n=n.add(1,`day`);o.push(e)}}return o}function Wy(e,t){return(0,G.default)(e).format(`YYYY-MM`)===(0,G.default)(t).format(`YYYY-MM`)}function Gy(e,t){return t?(0,G.default)(e).isAfter((0,G.default)(t).subtract(1,`day`),`day`):!0}function Ky(e,t){return t?(0,G.default)(e).isBefore((0,G.default)(t).add(1,`day`),`day`):!0}function qy({dates:e,minDate:t,maxDate:n,getDayProps:r,excludeDate:i,hideOutsideDates:a,month:o}){let s=e.flat().filter(e=>Ky(e,n)&&Gy(e,t)&&!i?.(e)&&!r?.(e)?.disabled&&(!a||Wy(e,o)));return s.find(e=>r?.(e)?.selected)||s.find(e=>(0,G.default)().isSame(e,`date`))||s[0]}var Jy=l(o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs_plugin_isoWeek=r()})(e,(function(){var e=`day`;return function(t,n,r){var i=function(t){return t.add(4-t.isoWeekday(),e)},a=n.prototype;a.isoWeekYear=function(){return i(this).year()},a.isoWeek=function(t){if(!this.$utils().u(t))return this.add(7*(t-this.isoWeek()),e);var n,a,o,s,c=i(this),l=(n=this.isoWeekYear(),a=this.$u,o=(a?r.utc:r)().year(n).startOf(`year`),s=4-o.isoWeekday(),o.isoWeekday()>4&&(s+=7),o.add(s,e));return c.diff(l,`week`)+1},a.isoWeekday=function(e){return this.$utils().u(e)?this.day()||7:this.day(this.day()%7?e:e-7)};var o=a.startOf;a.startOf=function(e,t){var n=this.$utils(),r=!!n.u(t)||t;return n.p(e)===`isoweek`?r?this.date(this.date()-(this.isoWeekday()-1)).startOf(`day`):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf(`day`):o.bind(this)(e,t)}}}))}))(),1);G.default.extend(Jy.default);function Yy(e){return(0,G.default)(e.find(e=>(0,G.default)(e).day()===1)).isoWeek()}var Xy={month:`m_cc9820d3`,monthCell:`m_8f457cd5`,weekNumber:`m_6cff9dea`},Zy={withCellSpacing:!0},Qy=On((e,{size:t})=>({weekNumber:{"--wn-fz":xt(t),"--wn-size":vt(t,`wn-size`)}})),$y=z((e,t)=>{let n=L(`Month`,Zy,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,__staticSelector:l,locale:u,firstDayOfWeek:d,weekdayFormat:f,month:p,weekendDays:m,getDayProps:h,excludeDate:g,minDate:_,maxDate:v,renderDay:y,hideOutsideDates:b,hideWeekdays:x,getDayAriaLabel:S,static:C,__getDayRef:w,__onDayKeyDown:T,__onDayClick:E,__onDayMouseEnter:D,__preventFocus:O,__stopPropagation:k,withCellSpacing:A,size:j,highlightToday:ee,withWeekNumbers:te,attributes:ne,...re}=n,M=ii({name:l||`Month`,classes:Xy,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:ne,vars:c,varsResolver:Qy,rootSelector:`month`}),N=ey(),ie=Uy({month:p,firstDayOfWeek:N.getFirstDayOfWeek(d),consistentWeeks:N.consistentWeeks}),ae=qy({dates:ie,minDate:qv(_),maxDate:qv(v),getDayProps:h,excludeDate:g,hideOutsideDates:b,month:p}),{resolvedClassNames:oe,resolvedStyles:se}=Vr({classNames:r,styles:o,props:n}),ce=ie.map((e,t)=>{let n=e.map((e,n)=>{let r=!Wy(e,p),i=S?.(e)||(0,G.default)(e).locale(u||N.locale).format(`D MMMM YYYY`),a=h?.(e),o=(0,G.default)(e).isSame(ae,`date`);return(0,I.jsx)(`td`,{...M(`monthCell`),"data-with-spacing":A||void 0,children:(0,I.jsx)(Iy,{__staticSelector:l||`Month`,classNames:oe,styles:se,unstyled:s,"data-mantine-stop-propagation":k||void 0,highlightToday:ee,renderDay:y,date:e,size:j,weekend:N.getWeekendDays(m).includes((0,G.default)(e).get(`day`)),outside:r,hidden:b?r:!1,"aria-label":i,static:C,disabled:g?.(e)||!Ky(e,qv(v))||!Gy(e,qv(_)),ref:e=>{e&&w?.(t,n,e)},...a,onKeyDown:r=>{a?.onKeyDown?.(r),T?.(r,{rowIndex:t,cellIndex:n,date:e})},onMouseEnter:t=>{a?.onMouseEnter?.(t),D?.(t,e)},onClick:t=>{a?.onClick?.(t),E?.(t,e)},onMouseDown:e=>{a?.onMouseDown?.(e),O&&e.preventDefault()},tabIndex:O||!o?-1:0})},e.toString())});return(0,I.jsxs)(`tr`,{...M(`monthRow`),children:[te&&(0,I.jsx)(`td`,{...M(`weekNumber`),children:Yy(e)}),n]},t)});return(0,I.jsxs)(R,{component:`table`,...M(`month`),size:j,ref:t,...re,children:[!x&&(0,I.jsx)(`thead`,{...M(`monthThead`),children:(0,I.jsx)(By,{__staticSelector:l||`Month`,locale:u,firstDayOfWeek:d,weekdayFormat:f,size:j,classNames:oe,styles:se,unstyled:s,withWeekNumbers:te})}),(0,I.jsx)(`tbody`,{...M(`monthTbody`),children:ce})]})});$y.classes=Xy,$y.displayName=`@mantine/dates/Month`;var eb={pickerControl:`m_dc6a3c71`},tb=On((e,{size:t})=>({pickerControl:{"--dpc-fz":xt(t),"--dpc-size":vt(t,`dpc-size`)}})),nb=z((e,t)=>{let n=L(`PickerControl`,null,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,firstInRange:l,lastInRange:u,inRange:d,__staticSelector:f,selected:p,disabled:m,attributes:h,...g}=n;return(0,I.jsx)(gl,{...ii({name:f||`PickerControl`,classes:eb,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:h,vars:c,varsResolver:tb,rootSelector:`pickerControl`})(`pickerControl`),ref:t,unstyled:s,"data-picker-control":!0,"data-selected":p&&!m||void 0,"data-disabled":m||void 0,"data-in-range":d&&!m&&!p||void 0,"data-first-in-range":l&&!m||void 0,"data-last-in-range":u&&!m||void 0,disabled:m,...g})});nb.classes=eb,nb.displayName=`@mantine/dates/PickerControl`;function rb({year:e,minDate:t,maxDate:n}){return!t&&!n?!1:!!(t&&(0,G.default)(e).isBefore(t,`year`)||n&&(0,G.default)(e).isAfter(n,`year`))}function ib({years:e,minDate:t,maxDate:n,getYearControlProps:r}){let i=e.flat().filter(e=>!rb({year:e,minDate:t,maxDate:n})&&!r?.(e)?.disabled);return i.find(e=>r?.(e)?.selected)||i.find(e=>(0,G.default)().isSame(e,`year`))||i[0]}function ab(e){let t=(0,G.default)(e).year(),n=t-t%10,r=0,i=[[],[],[],[]];for(let e=0;e<4;e+=1){let t=e===3?1:3;for(let a=0;a<t;a+=1)i[e].push((0,G.default)(new Date(n+r,0)).format(`YYYY-MM-DD`)),r+=1}return i}var ob={yearsList:`m_9206547b`,yearsListCell:`m_c5a19c7d`},sb={yearsListFormat:`YYYY`,withCellSpacing:!0},cb=z((e,t)=>{let n=L(`YearsList`,sb,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,decade:l,yearsListFormat:u,locale:d,minDate:f,maxDate:p,getYearControlProps:m,__staticSelector:h,__getControlRef:g,__onControlKeyDown:_,__onControlClick:v,__onControlMouseEnter:y,__preventFocus:b,__stopPropagation:x,withCellSpacing:S,size:C,attributes:w,...T}=n,E=ii({name:h||`YearsList`,classes:ob,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:w,vars:c,rootSelector:`yearsList`}),D=ey(),O=ab(l),k=ib({years:O,minDate:f,maxDate:p,getYearControlProps:m}),A=O.map((e,t)=>{let n=e.map((e,n)=>{let r=m?.(e),i=(0,G.default)(e).isSame(k,`year`);return(0,I.jsx)(`td`,{...E(`yearsListCell`),"data-with-spacing":S||void 0,children:(0,I.jsx)(nb,{...E(`yearsListControl`),size:C,unstyled:s,"data-mantine-stop-propagation":x||void 0,disabled:rb({year:e,minDate:f,maxDate:p}),ref:e=>{e&&g?.(t,n,e)},...r,onKeyDown:i=>{r?.onKeyDown?.(i),_?.(i,{rowIndex:t,cellIndex:n,date:e})},onClick:t=>{r?.onClick?.(t),v?.(t,e)},onMouseEnter:t=>{r?.onMouseEnter?.(t),y?.(t,e)},onMouseDown:e=>{r?.onMouseDown?.(e),b&&e.preventDefault()},tabIndex:b||!i?-1:0,children:r?.children??(0,G.default)(e).locale(D.getLocale(d)).format(u)})},n)});return(0,I.jsx)(`tr`,{...E(`yearsListRow`),children:n},t)});return(0,I.jsx)(R,{component:`table`,ref:t,size:C,...E(`yearsList`),...T,children:(0,I.jsx)(`tbody`,{children:A})})});cb.classes=ob,cb.displayName=`@mantine/dates/YearsList`;function lb({month:e,minDate:t,maxDate:n}){return!t&&!n?!1:!!(t&&(0,G.default)(e).isBefore(t,`month`)||n&&(0,G.default)(e).isAfter(n,`month`))}function ub({months:e,minDate:t,maxDate:n,getMonthControlProps:r}){let i=e.flat().filter(e=>!lb({month:e,minDate:t,maxDate:n})&&!r?.(e)?.disabled);return i.find(e=>r?.(e)?.selected)||i.find(e=>(0,G.default)().isSame(e,`month`))||i[0]}function db(e){let t=(0,G.default)(e).startOf(`year`).toDate(),n=[[],[],[],[]],r=0;for(let e=0;e<4;e+=1)for(let i=0;i<3;i+=1)n[e].push((0,G.default)(t).add(r,`months`).format(`YYYY-MM-DD`)),r+=1;return n}var fb={monthsList:`m_2a6c32d`,monthsListCell:`m_fe27622f`},pb={monthsListFormat:`MMM`,withCellSpacing:!0},mb=z((e,t)=>{let n=L(`MonthsList`,pb,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,__staticSelector:l,year:u,monthsListFormat:d,locale:f,minDate:p,maxDate:m,getMonthControlProps:h,__getControlRef:g,__onControlKeyDown:_,__onControlClick:v,__onControlMouseEnter:y,__preventFocus:b,__stopPropagation:x,withCellSpacing:S,size:C,attributes:w,...T}=n,E=ii({name:l||`MonthsList`,classes:fb,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:w,vars:c,rootSelector:`monthsList`}),D=ey(),O=db(u),k=ub({months:O,minDate:qv(p),maxDate:qv(m),getMonthControlProps:h}),A=O.map((e,t)=>{let n=e.map((e,n)=>{let r=h?.(e),i=(0,G.default)(e).isSame(k,`month`);return(0,I.jsx)(`td`,{...E(`monthsListCell`),"data-with-spacing":S||void 0,children:(0,I.jsx)(nb,{...E(`monthsListControl`),size:C,unstyled:s,__staticSelector:l||`MonthsList`,"data-mantine-stop-propagation":x||void 0,disabled:lb({month:e,minDate:qv(p),maxDate:qv(m)}),ref:e=>{e&&g?.(t,n,e)},...r,onKeyDown:i=>{r?.onKeyDown?.(i),_?.(i,{rowIndex:t,cellIndex:n,date:e})},onClick:t=>{r?.onClick?.(t),v?.(t,e)},onMouseEnter:t=>{r?.onMouseEnter?.(t),y?.(t,e)},onMouseDown:e=>{r?.onMouseDown?.(e),b&&e.preventDefault()},tabIndex:b||!i?-1:0,children:r?.children??(0,G.default)(e).locale(D.getLocale(f)).format(d)})},n)});return(0,I.jsx)(`tr`,{...E(`monthsListRow`),children:n},t)});return(0,I.jsx)(R,{component:`table`,ref:t,size:C,...E(`monthsList`),...T,children:(0,I.jsx)(`tbody`,{children:A})})});mb.classes=fb,mb.displayName=`@mantine/dates/MonthsList`;var hb={calendarHeader:`m_730a79ed`,calendarHeaderLevel:`m_f6645d97`,calendarHeaderControl:`m_2351eeb0`,calendarHeaderControlIcon:`m_367dc749`},gb={hasNextLevel:!0,withNext:!0,withPrevious:!0,headerControlsOrder:[`previous`,`level`,`next`]},_b=On((e,{size:t})=>({calendarHeader:{"--dch-control-size":vt(t,`dch-control-size`),"--dch-fz":xt(t)}})),vb=z((e,t)=>{let n=L(`CalendarHeader`,gb,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,nextIcon:l,previousIcon:u,nextLabel:d,previousLabel:f,onNext:p,onPrevious:m,onLevelClick:h,label:g,nextDisabled:_,previousDisabled:y,hasNextLevel:b,levelControlAriaLabel:x,withNext:S,withPrevious:C,headerControlsOrder:w,__staticSelector:T,__preventFocus:E,__stopPropagation:D,attributes:O,...k}=n,A=ii({name:T||`CalendarHeader`,classes:hb,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:O,vars:c,varsResolver:_b,rootSelector:`calendarHeader`}),j=E?e=>e.preventDefault():void 0,ee=C&&(0,v.createElement)(gl,{...A(`calendarHeaderControl`),key:`previous`,"data-direction":`previous`,"aria-label":f,onClick:m,unstyled:s,onMouseDown:j,disabled:y,"data-disabled":y||void 0,tabIndex:E||y?-1:0,"data-mantine-stop-propagation":D||void 0},u||(0,I.jsx)(Ed,{...A(`calendarHeaderControlIcon`),"data-direction":`previous`,size:`45%`})),te=(0,v.createElement)(gl,{component:b?`button`:`div`,...A(`calendarHeaderLevel`),key:`level`,onClick:b?h:void 0,unstyled:s,onMouseDown:b?j:void 0,disabled:!b,"data-static":!b||void 0,"aria-label":x,tabIndex:E||!b?-1:0,"data-mantine-stop-propagation":D||void 0},g),ne=S&&(0,v.createElement)(gl,{...A(`calendarHeaderControl`),key:`next`,"data-direction":`next`,"aria-label":d,onClick:p,unstyled:s,onMouseDown:j,disabled:_,"data-disabled":_||void 0,tabIndex:E||_?-1:0,"data-mantine-stop-propagation":D||void 0},l||(0,I.jsx)(Ed,{...A(`calendarHeaderControlIcon`),"data-direction":`next`,size:`45%`})),re=w.map(e=>e===`previous`?ee:e===`level`?te:e===`next`?ne:null);return(0,I.jsx)(R,{...A(`calendarHeader`),ref:t,...k,children:re})});vb.classes=hb,vb.displayName=`@mantine/dates/CalendarHeader`;function yb(e){let t=ab(e);return[t[0][0],t[3][0]]}var bb={decadeLabelFormat:`YYYY`},xb=z((e,t)=>{let{decade:n,locale:r,minDate:i,maxDate:a,yearsListFormat:o,getYearControlProps:s,__getControlRef:c,__onControlKeyDown:l,__onControlClick:u,__onControlMouseEnter:d,withCellSpacing:f,__preventFocus:p,nextIcon:m,previousIcon:h,nextLabel:g,previousLabel:_,onNext:v,onPrevious:y,nextDisabled:b,previousDisabled:x,levelControlAriaLabel:S,withNext:C,withPrevious:w,headerControlsOrder:T,decadeLabelFormat:E,classNames:D,styles:O,unstyled:k,__staticSelector:A,__stopPropagation:j,size:ee,attributes:te,...ne}=L(`DecadeLevel`,bb,e),re=ey(),[M,N]=yb(n),ie={__staticSelector:A||`DecadeLevel`,classNames:D,styles:O,unstyled:k,size:ee,attributes:te},ae=typeof b==`boolean`?b:a?!(0,G.default)(N).endOf(`year`).isBefore(a):!1,oe=typeof x==`boolean`?x:i?!(0,G.default)(M).startOf(`year`).isAfter(i):!1,se=(e,t)=>(0,G.default)(e).locale(r||re.locale).format(t);return(0,I.jsxs)(R,{"data-decade-level":!0,size:ee,ref:t,...ne,children:[(0,I.jsx)(vb,{label:typeof E==`function`?E(M,N):`${se(M,E)} \u2013 ${se(N,E)}`,__preventFocus:p,__stopPropagation:j,nextIcon:m,previousIcon:h,nextLabel:g,previousLabel:_,onNext:v,onPrevious:y,nextDisabled:ae,previousDisabled:oe,hasNextLevel:!1,levelControlAriaLabel:S,withNext:C,withPrevious:w,headerControlsOrder:T,...ie}),(0,I.jsx)(cb,{decade:n,locale:r,minDate:i,maxDate:a,yearsListFormat:o,getYearControlProps:s,__getControlRef:c,__onControlKeyDown:l,__onControlClick:u,__onControlMouseEnter:d,__preventFocus:p,__stopPropagation:j,withCellSpacing:f,...ie})]})});xb.classes={...cb.classes,...vb.classes},xb.displayName=`@mantine/dates/DecadeLevel`;var Sb={yearLabelFormat:`YYYY`},Cb=z((e,t)=>{let{year:n,locale:r,minDate:i,maxDate:a,monthsListFormat:o,getMonthControlProps:s,__getControlRef:c,__onControlKeyDown:l,__onControlClick:u,__onControlMouseEnter:d,withCellSpacing:f,__preventFocus:p,nextIcon:m,previousIcon:h,nextLabel:g,previousLabel:_,onNext:v,onPrevious:y,onLevelClick:b,nextDisabled:x,previousDisabled:S,hasNextLevel:C,levelControlAriaLabel:w,withNext:T,withPrevious:E,headerControlsOrder:D,yearLabelFormat:O,__staticSelector:k,__stopPropagation:A,size:j,classNames:ee,styles:te,unstyled:ne,attributes:re,...M}=L(`YearLevel`,Sb,e),N=ey(),ie={__staticSelector:k||`YearLevel`,classNames:ee,styles:te,unstyled:ne,size:j,attributes:re},ae=typeof x==`boolean`?x:a?!(0,G.default)(n).endOf(`year`).isBefore(a):!1,oe=typeof S==`boolean`?S:i?!(0,G.default)(n).startOf(`year`).isAfter(i):!1;return(0,I.jsxs)(R,{"data-year-level":!0,size:j,ref:t,...M,children:[(0,I.jsx)(vb,{label:typeof O==`function`?O(n):(0,G.default)(n).locale(r||N.locale).format(O),__preventFocus:p,__stopPropagation:A,nextIcon:m,previousIcon:h,nextLabel:g,previousLabel:_,onNext:v,onPrevious:y,onLevelClick:b,nextDisabled:ae,previousDisabled:oe,hasNextLevel:C,levelControlAriaLabel:w,withNext:T,withPrevious:E,headerControlsOrder:D,...ie}),(0,I.jsx)(mb,{year:n,locale:r,minDate:i,maxDate:a,monthsListFormat:o,getMonthControlProps:s,__getControlRef:c,__onControlKeyDown:l,__onControlClick:u,__onControlMouseEnter:d,__preventFocus:p,__stopPropagation:A,withCellSpacing:f,...ie})]})});Cb.classes={...vb.classes,...mb.classes},Cb.displayName=`@mantine/dates/YearLevel`;var wb={monthLabelFormat:`MMMM YYYY`},Tb=z((e,t)=>{let{month:n,locale:r,firstDayOfWeek:i,weekdayFormat:a,weekendDays:o,getDayProps:s,excludeDate:c,minDate:l,maxDate:u,renderDay:d,hideOutsideDates:f,hideWeekdays:p,getDayAriaLabel:m,__getDayRef:h,__onDayKeyDown:g,__onDayClick:_,__onDayMouseEnter:v,withCellSpacing:y,highlightToday:b,withWeekNumbers:x,__preventFocus:S,__stopPropagation:C,nextIcon:w,previousIcon:T,nextLabel:E,previousLabel:D,onNext:O,onPrevious:k,onLevelClick:A,nextDisabled:j,previousDisabled:ee,hasNextLevel:te,levelControlAriaLabel:ne,withNext:re,withPrevious:M,headerControlsOrder:N,monthLabelFormat:ie,classNames:ae,styles:oe,unstyled:se,__staticSelector:ce,size:le,static:ue,attributes:de,...fe}=L(`MonthLevel`,wb,e),pe=ey(),me={__staticSelector:ce||`MonthLevel`,classNames:ae,styles:oe,unstyled:se,size:le,attributes:de},he=typeof j==`boolean`?j:u?!(0,G.default)(n).endOf(`month`).isBefore(u):!1,ge=typeof ee==`boolean`?ee:l?!(0,G.default)(n).startOf(`month`).isAfter(l):!1;return(0,I.jsxs)(R,{"data-month-level":!0,size:le,ref:t,...fe,children:[(0,I.jsx)(vb,{label:typeof ie==`function`?ie(n):(0,G.default)(n).locale(r||pe.locale).format(ie),__preventFocus:S,__stopPropagation:C,nextIcon:w,previousIcon:T,nextLabel:E,previousLabel:D,onNext:O,onPrevious:k,onLevelClick:A,nextDisabled:he,previousDisabled:ge,hasNextLevel:te,levelControlAriaLabel:ne,withNext:re,withPrevious:M,headerControlsOrder:N,...me}),(0,I.jsx)($y,{month:n,locale:r,firstDayOfWeek:i,weekdayFormat:a,weekendDays:o,getDayProps:s,excludeDate:c,minDate:l,maxDate:u,renderDay:d,hideOutsideDates:f,hideWeekdays:p,getDayAriaLabel:m,__getDayRef:h,__onDayKeyDown:g,__onDayClick:_,__onDayMouseEnter:v,__preventFocus:S,__stopPropagation:C,static:ue,withCellSpacing:y,highlightToday:b,withWeekNumbers:x,...me})]})});Tb.classes={...$y.classes,...vb.classes},Tb.displayName=`@mantine/dates/MonthLevel`;var Eb={levelsGroup:`m_30b26e33`},Db=z((e,t)=>{let n=L(`LevelsGroup`,null,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,__staticSelector:l,attributes:u,...d}=n;return(0,I.jsx)(R,{ref:t,...ii({name:l||`LevelsGroup`,classes:Eb,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:u,vars:c,rootSelector:`levelsGroup`})(`levelsGroup`),...d})});Db.classes=Eb,Db.displayName=`@mantine/dates/LevelsGroup`;var Ob={numberOfColumns:1},kb=z((e,t)=>{let{decade:n,locale:r,minDate:i,maxDate:a,yearsListFormat:o,getYearControlProps:s,__onControlClick:c,__onControlMouseEnter:l,withCellSpacing:u,__preventFocus:d,nextIcon:f,previousIcon:p,nextLabel:m,previousLabel:h,onNext:g,onPrevious:_,nextDisabled:y,previousDisabled:b,headerControlsOrder:x,classNames:S,styles:C,unstyled:w,__staticSelector:T,__stopPropagation:E,numberOfColumns:D,levelControlAriaLabel:O,decadeLabelFormat:k,size:A,vars:j,attributes:ee,...te}=L(`DecadeLevelGroup`,Ob,e),ne=(0,v.useRef)([]),re=Array(D).fill(0).map((e,t)=>{let v=(0,G.default)(n).add(t*10,`years`).format(`YYYY-MM-DD`);return(0,I.jsx)(xb,{size:A,yearsListFormat:o,decade:v,withNext:t===D-1,withPrevious:t===0,decadeLabelFormat:k,__onControlClick:c,__onControlMouseEnter:l,__onControlKeyDown:(e,n)=>Gv({levelIndex:t,rowIndex:n.rowIndex,cellIndex:n.cellIndex,event:e,controlsRef:ne}),__getControlRef:(e,n,r)=>{Array.isArray(ne.current[t])||(ne.current[t]=[]),Array.isArray(ne.current[t][e])||(ne.current[t][e]=[]),ne.current[t][e][n]=r},levelControlAriaLabel:typeof O==`function`?O(v):O,locale:r,minDate:i,maxDate:a,__preventFocus:d,__stopPropagation:E,nextIcon:f,previousIcon:p,nextLabel:m,previousLabel:h,onNext:g,onPrevious:_,nextDisabled:y,previousDisabled:b,getYearControlProps:s,__staticSelector:T||`DecadeLevelGroup`,classNames:S,styles:C,unstyled:w,withCellSpacing:u,headerControlsOrder:x,attributes:ee},t)});return(0,I.jsx)(Db,{classNames:S,styles:C,__staticSelector:T||`DecadeLevelGroup`,ref:t,size:A,unstyled:w,attributes:ee,...te,children:re})});kb.classes={...Db.classes,...xb.classes},kb.displayName=`@mantine/dates/DecadeLevelGroup`;var Ab={numberOfColumns:1},jb=z((e,t)=>{let{year:n,locale:r,minDate:i,maxDate:a,monthsListFormat:o,getMonthControlProps:s,__onControlClick:c,__onControlMouseEnter:l,withCellSpacing:u,__preventFocus:d,nextIcon:f,previousIcon:p,nextLabel:m,previousLabel:h,onNext:g,onPrevious:_,onLevelClick:y,nextDisabled:b,previousDisabled:x,hasNextLevel:S,headerControlsOrder:C,classNames:w,styles:T,unstyled:E,__staticSelector:D,__stopPropagation:O,numberOfColumns:k,levelControlAriaLabel:A,yearLabelFormat:j,size:ee,vars:te,attributes:ne,...re}=L(`YearLevelGroup`,Ab,e),M=(0,v.useRef)([]),N=Array(k).fill(0).map((e,t)=>{let v=(0,G.default)(n).add(t,`years`).format(`YYYY-MM-DD`);return(0,I.jsx)(Cb,{size:ee,monthsListFormat:o,year:v,withNext:t===k-1,withPrevious:t===0,yearLabelFormat:j,__stopPropagation:O,__onControlClick:c,__onControlMouseEnter:l,__onControlKeyDown:(e,n)=>Gv({levelIndex:t,rowIndex:n.rowIndex,cellIndex:n.cellIndex,event:e,controlsRef:M}),__getControlRef:(e,n,r)=>{Array.isArray(M.current[t])||(M.current[t]=[]),Array.isArray(M.current[t][e])||(M.current[t][e]=[]),M.current[t][e][n]=r},levelControlAriaLabel:typeof A==`function`?A(v):A,locale:r,minDate:i,maxDate:a,__preventFocus:d,nextIcon:f,previousIcon:p,nextLabel:m,previousLabel:h,onNext:g,onPrevious:_,onLevelClick:y,nextDisabled:b,previousDisabled:x,hasNextLevel:S,getMonthControlProps:s,classNames:w,styles:T,unstyled:E,__staticSelector:D||`YearLevelGroup`,withCellSpacing:u,headerControlsOrder:C,attributes:ne},t)});return(0,I.jsx)(Db,{classNames:w,styles:T,__staticSelector:D||`YearLevelGroup`,ref:t,size:ee,unstyled:E,attributes:ne,...re,children:N})});jb.classes={...Cb.classes,...Db.classes},jb.displayName=`@mantine/dates/YearLevelGroup`;var Mb={numberOfColumns:1},Nb=z((e,t)=>{let{month:n,locale:r,firstDayOfWeek:i,weekdayFormat:a,weekendDays:o,getDayProps:s,excludeDate:c,minDate:l,maxDate:u,renderDay:d,hideOutsideDates:f,hideWeekdays:p,getDayAriaLabel:m,__onDayClick:h,__onDayMouseEnter:g,withCellSpacing:_,highlightToday:y,withWeekNumbers:b,__preventFocus:x,nextIcon:S,previousIcon:C,nextLabel:w,previousLabel:T,onNext:E,onPrevious:D,onLevelClick:O,nextDisabled:k,previousDisabled:A,hasNextLevel:j,headerControlsOrder:ee,classNames:te,styles:ne,unstyled:re,numberOfColumns:M,levelControlAriaLabel:N,monthLabelFormat:ie,__staticSelector:ae,__stopPropagation:oe,size:se,static:ce,vars:le,attributes:ue,...de}=L(`MonthLevelGroup`,Mb,e),fe=(0,v.useRef)([]),pe=Array(M).fill(0).map((e,t)=>{let v=(0,G.default)(n).add(t,`months`).format(`YYYY-MM-DD`);return(0,I.jsx)(Tb,{month:v,withNext:t===M-1,withPrevious:t===0,monthLabelFormat:ie,__stopPropagation:oe,__onDayClick:h,__onDayMouseEnter:g,__onDayKeyDown:(e,n)=>Gv({levelIndex:t,rowIndex:n.rowIndex,cellIndex:n.cellIndex,event:e,controlsRef:fe}),__getDayRef:(e,n,r)=>{Array.isArray(fe.current[t])||(fe.current[t]=[]),Array.isArray(fe.current[t][e])||(fe.current[t][e]=[]),fe.current[t][e][n]=r},levelControlAriaLabel:typeof N==`function`?N(v):N,locale:r,firstDayOfWeek:i,weekdayFormat:a,weekendDays:o,getDayProps:s,excludeDate:c,minDate:l,maxDate:u,renderDay:d,hideOutsideDates:f,hideWeekdays:p,getDayAriaLabel:m,__preventFocus:x,nextIcon:S,previousIcon:C,nextLabel:w,previousLabel:T,onNext:E,onPrevious:D,onLevelClick:O,nextDisabled:k,previousDisabled:A,hasNextLevel:j,classNames:te,styles:ne,unstyled:re,__staticSelector:ae||`MonthLevelGroup`,size:se,static:ce,withCellSpacing:_,highlightToday:y,withWeekNumbers:b,headerControlsOrder:ee,attributes:ue},t)});return(0,I.jsx)(Db,{classNames:te,styles:ne,__staticSelector:ae||`MonthLevelGroup`,ref:t,size:se,attributes:ue,...de,children:pe})});Nb.classes={...Db.classes,...Tb.classes},Nb.displayName=`@mantine/dates/MonthLevelGroup`;var Pb={input:`m_6fa5e2aa`},Fb=z((e,t)=>{let{inputProps:n,wrapperProps:r,placeholder:i,classNames:a,styles:o,unstyled:s,popoverProps:c,modalProps:l,dropdownType:u,children:d,formattedValue:f,dropdownHandlers:p,dropdownOpened:m,onClick:h,clearable:g,onClear:_,clearButtonProps:v,rightSection:y,shouldClear:b,readOnly:x,disabled:S,value:C,name:w,form:T,type:E,onDropdownClose:D,withTime:O,...k}=md(`PickerInputBase`,{size:`sm`},e),A=(0,I.jsx)(pd.ClearButton,{onClick:_,unstyled:s,...v}),j=()=>{E===`range`&&Array.isArray(C)&&C[0]&&!C[1]&&_(),p.close()};return(0,I.jsxs)(I.Fragment,{children:[u===`modal`&&!x&&(0,I.jsx)(Nh,{opened:m,onClose:j,withCloseButton:!1,size:`auto`,"data-dates-modal":!0,unstyled:s,...l,children:d}),(0,I.jsx)(pd.Wrapper,{...r,children:(0,I.jsxs)(nu,{position:`bottom-start`,opened:m,trapFocus:!0,returnFocus:!1,unstyled:s,onClose:D,...c,disabled:c?.disabled||u===`modal`||x,onChange:e=>{e||(c?.onClose?.(),j())},children:[(0,I.jsx)(nu.Target,{children:(0,I.jsx)(pd,{"data-dates-input":!0,"data-read-only":x||void 0,disabled:S,component:`button`,type:`button`,multiline:!0,onClick:e=>{h?.(e),p.toggle()},__clearSection:A,__clearable:g&&b&&!x&&!S,rightSection:y,...n,ref:t,classNames:{...a,input:An(Pb.input,a?.input)},...k,children:f||(0,I.jsx)(pd.Placeholder,{error:n.error,unstyled:s,classNames:a,styles:o,__staticSelector:n.__staticSelector,children:i})})}),(0,I.jsx)(nu.Dropdown,{"data-dates-dropdown":!0,children:d})]})}),(0,I.jsx)(ny,{value:C,name:w,form:T,type:E,withTime:O})]})});Fb.classes=Pb,Fb.displayName=`@mantine/dates/PickerInputBase`;var Ib=e=>e===`range`?[null,null]:e===`multiple`?[]:null,Lb=(e,t)=>{let n=t?Jv:qv;return Array.isArray(e)?e.map(n):n(e)};function Rb({type:e,value:t,defaultValue:n,onChange:r,withTime:i=!1}){let a=(0,v.useRef)(e),[o,s,c]=ln({value:Lb(t,i),defaultValue:Lb(n,i),finalValue:Ib(e),onChange:r}),l=o;return a.current!==e&&(a.current=e,t===void 0&&(l=n===void 0?Ib(e):n,s(l))),[l,s,c]}function zb(e,t){return e?e===`month`?0:e===`year`?1:2:t||0}function Bb(e){return e===0?`month`:e===1?`year`:`decade`}function Vb(e,t,n){return Bb(kt(zb(e,0),zb(t,0),zb(n,2)))}var Hb={maxLevel:`decade`,minLevel:`month`,__updateDateOnYearSelect:!0,__updateDateOnMonthSelect:!0,enableKeyboardNavigation:!0},Ub=z((e,t)=>{let n=L(`Calendar`,Hb,e),{vars:r,maxLevel:i,minLevel:a,defaultLevel:o,level:s,onLevelChange:c,date:l,defaultDate:u,onDateChange:d,numberOfColumns:f,columnsToScroll:p,ariaLabels:m,nextLabel:h,previousLabel:g,onYearSelect:_,onMonthSelect:y,onYearMouseEnter:b,onMonthMouseEnter:x,headerControlsOrder:S,__updateDateOnYearSelect:C,__updateDateOnMonthSelect:w,__setDateRef:T,__setLevelRef:E,firstDayOfWeek:D,weekdayFormat:O,weekendDays:k,getDayProps:A,excludeDate:j,renderDay:ee,hideOutsideDates:te,hideWeekdays:ne,getDayAriaLabel:re,monthLabelFormat:M,nextIcon:N,previousIcon:ie,__onDayClick:ae,__onDayMouseEnter:oe,withCellSpacing:se,highlightToday:ce,withWeekNumbers:le,monthsListFormat:ue,getMonthControlProps:de,yearLabelFormat:fe,yearsListFormat:pe,getYearControlProps:me,decadeLabelFormat:he,classNames:ge,styles:_e,unstyled:ve,minDate:ye,maxDate:be,locale:xe,__staticSelector:Se,size:Ce,__preventFocus:we,__stopPropagation:Te,onNextDecade:Ee,onPreviousDecade:De,onNextYear:Oe,onPreviousYear:ke,onNextMonth:P,onPreviousMonth:Ae,static:je,enableKeyboardNavigation:Me,attributes:Ne,...Pe}=n,{resolvedClassNames:Fe,resolvedStyles:Ie}=Vr({classNames:ge,styles:_e,props:n}),[Le,Re]=ln({value:s?Vb(s,a,i):void 0,defaultValue:o?Vb(o,a,i):void 0,finalValue:Vb(void 0,a,i),onChange:c}),[ze,Be]=Rb({type:`default`,value:qv(l),defaultValue:qv(u),onChange:d});(0,v.useImperativeHandle)(T,()=>e=>{Be(e)}),(0,v.useImperativeHandle)(E,()=>e=>{Re(e)});let Ve={__staticSelector:Se||`Calendar`,styles:Ie,classNames:Fe,unstyled:ve,size:Ce,attributes:Ne},He=p||f||1,Ue=new Date,We=ye&&(0,G.default)(Ue).isAfter(ye)?ye:(0,G.default)(Ue).format(`YYYY-MM-DD`),Ge=ze||We,Ke=()=>{let e=(0,G.default)(Ge).add(He,`month`).format(`YYYY-MM-DD`);P?.(e),Be(e)},qe=()=>{let e=(0,G.default)(Ge).subtract(He,`month`).format(`YYYY-MM-DD`);Ae?.(e),Be(e)},Je=()=>{let e=(0,G.default)(Ge).add(He,`year`).format(`YYYY-MM-DD`);Oe?.(e),Be(e)},Ye=()=>{let e=(0,G.default)(Ge).subtract(He,`year`).format(`YYYY-MM-DD`);ke?.(e),Be(e)},Xe=()=>{let e=(0,G.default)(Ge).add(10*He,`year`).format(`YYYY-MM-DD`);Ee?.(e),Be(e)},Ze=()=>{let e=(0,G.default)(Ge).subtract(10*He,`year`).format(`YYYY-MM-DD`);De?.(e),Be(e)},Qe=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(!Me||je)return;let e=e=>{if(!Qe.current?.contains(document.activeElement))return;let t=e.ctrlKey||e.metaKey,n=e.shiftKey;switch(e.key){case`ArrowUp`:t&&n?(e.preventDefault(),Ze()):t&&(e.preventDefault(),Ye());break;case`ArrowDown`:t&&n?(e.preventDefault(),Xe()):t&&(e.preventDefault(),Je());break;case`y`:case`Y`:Le===`month`&&(e.preventDefault(),Re(`year`));break}};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[Me,je,Le,Je,Ye,Xe,Ze]),(0,I.jsxs)(R,{ref:e=>{Qe.current=e,typeof t==`function`?t(e):t&&(t.current=e)},size:Ce,"data-calendar":!0,...Pe,children:[Le===`month`&&(0,I.jsx)(Nb,{month:Ge,minDate:ye,maxDate:be,firstDayOfWeek:D,weekdayFormat:O,weekendDays:k,getDayProps:A,excludeDate:j,renderDay:ee,hideOutsideDates:te,hideWeekdays:ne,getDayAriaLabel:re,onNext:Ke,onPrevious:qe,hasNextLevel:i!==`month`,onLevelClick:()=>Re(`year`),numberOfColumns:f,locale:xe,levelControlAriaLabel:m?.monthLevelControl,nextLabel:m?.nextMonth??h,nextIcon:N,previousLabel:m?.previousMonth??g,previousIcon:ie,monthLabelFormat:M,__onDayClick:ae,__onDayMouseEnter:oe,__preventFocus:we,__stopPropagation:Te,static:je,withCellSpacing:se,highlightToday:ce,withWeekNumbers:le,headerControlsOrder:S,...Ve}),Le===`year`&&(0,I.jsx)(jb,{year:Ge,numberOfColumns:f,minDate:ye,maxDate:be,monthsListFormat:ue,getMonthControlProps:de,locale:xe,onNext:Je,onPrevious:Ye,hasNextLevel:i!==`month`&&i!==`year`,onLevelClick:()=>Re(`decade`),levelControlAriaLabel:m?.yearLevelControl,nextLabel:m?.nextYear??h,nextIcon:N,previousLabel:m?.previousYear??g,previousIcon:ie,yearLabelFormat:fe,__onControlMouseEnter:x,__onControlClick:(e,t)=>{w&&Be(t),Re(Vb(`month`,a,i)),y?.(t)},__preventFocus:we,__stopPropagation:Te,withCellSpacing:se,headerControlsOrder:S,...Ve}),Le===`decade`&&(0,I.jsx)(kb,{decade:Ge,minDate:ye,maxDate:be,yearsListFormat:pe,getYearControlProps:me,locale:xe,onNext:Xe,onPrevious:Ze,numberOfColumns:f,nextLabel:m?.nextDecade??h,nextIcon:N,previousLabel:m?.previousDecade??g,previousIcon:ie,decadeLabelFormat:he,__onControlMouseEnter:b,__onControlClick:(e,t)=>{C&&Be(t),Re(Vb(`year`,a,i)),_?.(t)},__preventFocus:we,__stopPropagation:Te,withCellSpacing:se,headerControlsOrder:S,...Ve})]})});Ub.classes={...kb.classes,...jb.classes,...Nb.classes},Ub.displayName=`@mantine/dates/Calendar`;function Wb(e){let{maxLevel:t,minLevel:n,defaultLevel:r,level:i,onLevelChange:a,nextIcon:o,previousIcon:s,date:c,defaultDate:l,onDateChange:u,numberOfColumns:d,columnsToScroll:f,ariaLabels:p,nextLabel:m,previousLabel:h,onYearSelect:g,onMonthSelect:_,onYearMouseEnter:v,onMonthMouseEnter:y,onNextMonth:b,onPreviousMonth:x,onNextYear:S,onPreviousYear:C,onNextDecade:w,onPreviousDecade:T,withCellSpacing:E,highlightToday:D,__updateDateOnYearSelect:O,__updateDateOnMonthSelect:k,__setDateRef:A,__setLevelRef:j,withWeekNumbers:ee,headerControlsOrder:te,firstDayOfWeek:ne,weekdayFormat:re,weekendDays:M,getDayProps:N,excludeDate:ie,renderDay:ae,hideOutsideDates:oe,hideWeekdays:se,getDayAriaLabel:ce,monthLabelFormat:le,monthsListFormat:ue,getMonthControlProps:de,yearLabelFormat:fe,yearsListFormat:pe,getYearControlProps:me,decadeLabelFormat:he,allowSingleDateInRange:ge,allowDeselect:_e,minDate:ve,maxDate:ye,locale:be,...xe}=e;return{calendarProps:{maxLevel:t,minLevel:n,defaultLevel:r,level:i,onLevelChange:a,nextIcon:o,previousIcon:s,date:c,defaultDate:l,onDateChange:u,numberOfColumns:d,columnsToScroll:f,ariaLabels:p,nextLabel:m,previousLabel:h,onYearSelect:g,onMonthSelect:_,onYearMouseEnter:v,onMonthMouseEnter:y,onNextMonth:b,onPreviousMonth:x,onNextYear:S,onPreviousYear:C,onNextDecade:w,onPreviousDecade:T,withCellSpacing:E,highlightToday:D,__updateDateOnYearSelect:O,__updateDateOnMonthSelect:k,__setDateRef:A,withWeekNumbers:ee,headerControlsOrder:te,firstDayOfWeek:ne,weekdayFormat:re,weekendDays:M,getDayProps:N,excludeDate:ie,renderDay:ae,hideOutsideDates:oe,hideWeekdays:se,getDayAriaLabel:ce,monthLabelFormat:le,monthsListFormat:ue,getMonthControlProps:de,yearLabelFormat:fe,yearsListFormat:pe,getYearControlProps:me,decadeLabelFormat:he,allowSingleDateInRange:ge,allowDeselect:_e,minDate:ve,maxDate:ye,locale:be},others:xe}}function Gb(e,t){let n=[...t].sort((e,t)=>(0,G.default)(e).isAfter((0,G.default)(t))?1:-1);return(0,G.default)(n[0]).startOf(`day`).subtract(1,`ms`).isBefore(e)&&(0,G.default)(n[1]).endOf(`day`).add(1,`ms`).isAfter(e)}function Kb({type:e,level:t,value:n,defaultValue:r,onChange:i,allowSingleDateInRange:a,allowDeselect:o,onMouseLeave:s}){let[c,l]=Rb({type:e,value:n,defaultValue:r,onChange:i}),[u,d]=(0,v.useState)(e===`range`&&c[0]&&!c[1]?c[0]:null),[f,p]=(0,v.useState)(null),m=n=>{if(e===`range`){if(u&&!c[1]){if((0,G.default)(n).isSame(u,t)&&!a){d(null),p(null),l([null,null]);return}let e=[n,u];e.sort((e,t)=>(0,G.default)(e).isAfter((0,G.default)(t))?1:-1),l(e),p(null),d(null);return}if(c[0]&&!c[1]&&(0,G.default)(n).isSame(c[0],t)&&!a){d(null),p(null),l([null,null]);return}l([n,null]),p(null),d(n);return}if(e===`multiple`){c.some(e=>(0,G.default)(e).isSame(n,t))?l(c.filter(e=>!(0,G.default)(e).isSame(n,t))):l([...c,n]);return}c&&o&&(0,G.default)(n).isSame(c,t)?l(null):l(n)},h=e=>u&&f?Gb(e,[f,u]):c[0]&&c[1]?Gb(e,c):!1,g=e===`range`?e=>{s?.(e),p(null)}:s,_=e=>c[0]&&(0,G.default)(e).isSame(c[0],t)?!(f&&(0,G.default)(f).isBefore(c[0])):!1,y=e=>c[1]?(0,G.default)(e).isSame(c[1],t):!c[0]||!f?!1:(0,G.default)(f).isBefore(c[0])&&(0,G.default)(e).isSame(c[0],t),b=n=>{if(e===`range`)return{selected:c.some(e=>e&&(0,G.default)(e).isSame(n,t)),inRange:h(n),firstInRange:_(n),lastInRange:y(n),"data-autofocus":!!c[0]&&(0,G.default)(c[0]).isSame(n,t)||void 0};if(e===`multiple`)return{selected:c.some(e=>e&&(0,G.default)(e).isSame(n,t)),"data-autofocus":!!c[0]&&(0,G.default)(c[0]).isSame(n,t)||void 0};let r=(0,G.default)(c).isSame(n,t);return{selected:r,"data-autofocus":r||void 0}},x=e===`range`&&u?p:()=>{};return(0,v.useEffect)(()=>{if(e===`range`)if(c[0]&&!c[1])d(c[0]);else{let e=c[0]==null&&c[1]==null,t=c[0]!=null&&c[1]!=null;(e||t)&&(d(null),p(null))}},[c]),{onDateChange:m,onRootMouseLeave:g,onHoveredDateChange:x,getControlProps:b,_value:c,setValue:l}}var qb={datePickerRoot:`m_765a40cf`,presetsList:`m_d6a681e1`,presetButton:`m_acd30b22`},Jb=On((e,{size:t})=>({datePickerRoot:{"--preset-font-size":xt(t)}})),Yb={type:`default`,defaultLevel:`month`,numberOfColumns:1,size:`sm`},Xb=z((e,t)=>{let n=L(`DatePicker`,Yb,e),{allowDeselect:r,allowSingleDateInRange:i,value:a,defaultValue:o,onChange:s,onMouseLeave:c,classNames:l,styles:u,__staticSelector:d,__onDayClick:f,__onDayMouseEnter:p,__onPresetSelect:m,__stopPropagation:h,presets:g,className:_,style:y,unstyled:b,size:x,vars:S,attributes:C,...w}=n,{calendarProps:T,others:E}=Wb(w),D=(0,v.useRef)(null),O=(0,v.useRef)(null),k=ii({name:d||`DatePicker`,classes:qb,props:n,className:_,style:y,classNames:l,styles:u,unstyled:b,attributes:C,rootSelector:g?`datePickerRoot`:void 0,varsResolver:Jb,vars:S}),{onDateChange:A,onRootMouseLeave:j,onHoveredDateChange:ee,getControlProps:te,_value:ne,setValue:re}=Kb({type:E.type,level:`day`,allowDeselect:r,allowSingleDateInRange:i,value:a,defaultValue:o,onChange:s,onMouseLeave:c}),{resolvedClassNames:M,resolvedStyles:N}=Vr({classNames:l,styles:u,props:n}),ie=(0,I.jsx)(Ub,{ref:t,classNames:M,styles:N,__staticSelector:d||`DatePicker`,onMouseLeave:j,size:x,...T,...g?{}:E,__stopPropagation:h,__setDateRef:D,__setLevelRef:O,minLevel:T.minLevel||`month`,__onDayMouseEnter:(e,t)=>{ee(t),p?.(e,t)},__onDayClick:(e,t)=>{A(t),f?.(e,t)},getDayProps:e=>({...te(e),...T.getDayProps?.(e)}),getMonthControlProps:e=>({selected:typeof ne==`string`?Wy(e,ne):!1,...T.getMonthControlProps?.(e)}),getYearControlProps:e=>({selected:typeof ne==`string`?(0,G.default)(e).isSame(ne,`year`):!1,...T.getYearControlProps?.(e)}),hideOutsideDates:T.hideOutsideDates??T.numberOfColumns!==1,...g?{}:{className:_,style:y,attributes:C}});if(!g)return ie;let ae=e=>{let t=Array.isArray(e)?e[0]:e;t!==void 0&&(D.current?.(t),O.current?.(`month`),m?m(t):re(e))},oe=g.map((e,t)=>(0,I.jsx)(gl,{...k(`presetButton`),onClick:()=>ae(e.value),onMouseDown:e=>e.preventDefault(),"data-mantine-stop-propagation":h||void 0,children:e.label},t));return(0,I.jsxs)(R,{...k(`datePickerRoot`),size:x,...E,children:[(0,I.jsx)(`div`,{...k(`presetsList`),children:oe}),ie]})});Xb.classes=Ub.classes,Xb.displayName=`@mantine/dates/DatePicker`;function Zb(e){if(e===null)return null;let t=new Date(e);return Number.isNaN(t.getTime())||!e?null:(0,G.default)(t).format(`YYYY-MM-DD`)}function Qb({date:e,maxDate:t,minDate:n}){return!(e==null||Number.isNaN(new Date(e).getTime())||t&&(0,G.default)(e).isAfter(t,`date`)||n&&(0,G.default)(e).isBefore(n,`date`))}var $b={valueFormat:`MMMM D, YYYY`,fixOnBlur:!0,size:`sm`},ex=z((e,t)=>{let{inputProps:n,wrapperProps:r,value:i,defaultValue:a,onChange:o,clearable:s,clearButtonProps:c,popoverProps:l,getDayProps:u,locale:d,valueFormat:f,dateParser:p,minDate:m,maxDate:h,fixOnBlur:g,onFocus:_,onBlur:y,onClick:b,onKeyDown:x,readOnly:S,name:C,form:w,rightSection:T,unstyled:E,classNames:D,styles:O,allowDeselect:k,date:A,defaultDate:j,onDateChange:ee,getMonthControlProps:te,getYearControlProps:ne,disabled:re,...M}=md(`DateInput`,$b,e),N=(0,v.useRef)(null),ie=(0,v.useRef)(null),[ae,oe]=(0,v.useState)(!1),{calendarProps:se,others:ce}=Wb(M),le=ey(),ue=p||(e=>{let t=(0,G.default)(e,f,le.getLocale(d)).toDate();return Number.isNaN(t.getTime())?Zb(e):(0,G.default)(t).format(`YYYY-MM-DD`)}),de=k===void 0?s:k,fe=e=>e?(0,G.default)(e).locale(le.getLocale(d)).format(f):``,[pe,me,he]=Rb({type:`default`,value:i,defaultValue:a,onChange:o}),[ge,_e]=Rb({type:`default`,value:A,defaultValue:a||j,onChange:ee});(0,v.useEffect)(()=>{he&&i!==null&&_e(i)},[he,i]);let[ve,ye]=(0,v.useState)(fe(pe));(0,v.useEffect)(()=>{ye(fe(pe))},[le.getLocale(d)]);let be=e=>{let t=e.currentTarget.value;if(ye(t),oe(!0),t.trim()===``&&(k||s))me(null);else{let e=ue(t);e&&Qb({date:e,minDate:m,maxDate:h})&&(me(e),_e(e))}},xe=e=>{y?.(e),oe(!1),g&&ye(fe(pe))},Se=e=>{_?.(e),oe(!0)},Ce=e=>{b?.(e),oe(!0)},we=e=>{e.key===`Escape`&&oe(!1),x?.(e)},Te=e=>({...u?.(e),selected:(0,G.default)(pe).isSame(e,`day`),onClick:t=>{u?.(e).onClick?.(t);let n=de&&(0,G.default)(pe).isSame(e,`day`)?null:e;me(n),!he&&n&&ye(fe(n)),oe(!1)}}),Ee=(0,I.jsx)(pd.ClearButton,{onClick:()=>{me(null),!he&&ye(``),oe(!1)},unstyled:E,...c}),De=s&&!!pe&&!S&&!re;return Vt(()=>{pe!==void 0&&!ae&&ye(fe(pe))},[pe]),Ft(()=>oe(!1),void 0,[N.current,ie.current]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(pd.Wrapper,{...r,__staticSelector:`DateInput`,ref:N,children:(0,I.jsxs)(nu,{opened:ae,trapFocus:!1,position:`bottom-start`,disabled:S||re,withRoles:!1,unstyled:E,...l,children:[(0,I.jsx)(nu.Target,{children:(0,I.jsx)(pd,{"data-dates-input":!0,"data-read-only":S||void 0,autoComplete:`off`,ref:t,value:ve,onChange:be,onBlur:xe,onFocus:Se,onClick:Ce,onKeyDown:we,readOnly:S,rightSection:T,__clearSection:Ee,__clearable:De,...n,...ce,disabled:re,__staticSelector:`DateInput`})}),(0,I.jsx)(nu.Dropdown,{onMouseDown:e=>e.preventDefault(),"data-dates-dropdown":!0,ref:ie,children:(0,I.jsx)(Ub,{__staticSelector:`DateInput`,...se,classNames:D,styles:O,unstyled:E,__preventFocus:!0,minDate:m,maxDate:h,locale:d,getDayProps:Te,size:n.size,date:ge,onDateChange:_e,getMonthControlProps:e=>({selected:typeof pe==`string`?Wy(e,pe):!1,...te?.(e)}),getYearControlProps:e=>({selected:typeof pe==`string`?(0,G.default)(e).isSame(pe,`year`):!1,...ne?.(e)}),attributes:r.attributes})})]})}),(0,I.jsx)(ny,{name:C,form:w,value:pe,type:`default`})]})});ex.classes={...pd.classes,...Ub.classes},ex.displayName=`@mantine/dates/DateInput`;var tx={timeWrapper:`m_208d2562`,timeInput:`m_62ee059`};function nx({minDate:e,value:t}){let n=e?(0,G.default)(e).format(`HH:mm:ss`):null;return t&&e&&t===e?n??void 0:void 0}function rx({maxDate:e,value:t}){let n=e?(0,G.default)(e).format(`HH:mm:ss`):null;return t&&e&&t===e?n??void 0:void 0}var ix={dropdownType:`popover`,size:`sm`},ax=z((e,t)=>{let n=L(`DateTimePicker`,ix,e),{value:r,defaultValue:i,onChange:a,valueFormat:o,locale:s,classNames:c,styles:l,unstyled:u,timePickerProps:d,submitButtonProps:f,withSeconds:p,level:m,defaultLevel:h,size:g,variant:_,dropdownType:y,vars:b,minDate:x,maxDate:S,defaultDate:C,defaultTimeValue:w,presets:T,attributes:E,onDropdownClose:D,...O}=n,k=ii({name:`DateTimePicker`,classes:tx,props:n,classNames:c,styles:l,unstyled:u,attributes:E,vars:b}),{resolvedClassNames:A,resolvedStyles:j}=Vr({classNames:c,styles:l,props:n}),ee=o||(p?`DD/MM/YYYY HH:mm:ss`:`DD/MM/YYYY HH:mm`),te=(0,v.useRef)(null),ne=cn(te,d?.hoursRef),{calendarProps:{allowSingleDateInRange:re,...M},others:N}=Wb(O),ie=ey(),[ae,oe]=Rb({type:`default`,value:r,defaultValue:i,onChange:a,withTime:!0}),se=C||ae,ce=e=>e?(0,G.default)(e).format(p?`HH:mm:ss`:`HH:mm`):``,[le,ue]=(0,v.useState)(w||ce(ae)),[de,fe]=(0,v.useState)(m||h||`month`),[pe,me]=_n(!1),he=ae?(0,G.default)(ae).locale(ie.getLocale(s)).format(ee):``,ge=e=>{d?.onChange?.(e),ue(e),e&&oe(Kv(ae,e))},_e=e=>{e&&oe(Kv(Xv(x,S,e),le||w||``)),te.current?.focus()},ve=e=>{e.key===`Enter`&&(e.preventDefault(),me.close())};Vt(()=>{pe||ue(ce(ae))},[ae,pe]),Vt(()=>{pe&&fe(`month`)},[pe]);let ye=y===`popover`,be=()=>{let e=Xv(x,S,ae);ae&&ae!==e&&oe(Xv(x,S,ae)),D?.()};return(0,I.jsxs)(Fb,{formattedValue:he,dropdownOpened:O.disabled?!1:pe,dropdownHandlers:me,classNames:A,styles:j,unstyled:u,ref:t,onClear:()=>oe(null),shouldClear:!!ae,value:ae,size:g,variant:_,dropdownType:y,...N,type:`default`,__staticSelector:`DateTimePicker`,onDropdownClose:be,withTime:!0,attributes:E,children:[(0,I.jsx)(Xb,{...M,maxDate:S,minDate:x,size:g,variant:_,type:`default`,value:ae,defaultDate:se||Yv({maxDate:S,minDate:x}),onChange:_e,locale:s,classNames:A,styles:j,unstyled:u,__staticSelector:`DateTimePicker`,__stopPropagation:ye,level:m,defaultLevel:h,onLevelChange:e=>{fe(e),M.onLevelChange?.(e)},presets:T,__onPresetSelect:e=>{oe(e),e&&ue(ce(e))},attributes:E}),de===`month`&&(0,I.jsxs)(`div`,{...k(`timeWrapper`),children:[(0,I.jsx)(Ny,{value:le,withSeconds:p,unstyled:u,min:nx({minDate:x,value:ae}),max:rx({maxDate:S,value:ae}),...d,...k(`timeInput`,{className:d?.className,style:d?.style}),onChange:ge,onKeyDown:ve,size:g,"data-mantine-stop-propagation":ye||void 0,hoursRef:ne,attributes:E}),(0,I.jsx)(vu,{variant:`default`,size:`input-${g||`sm`}`,...k(`submitButton`,{className:f?.className,style:f?.style}),unstyled:u,"data-mantine-stop-propagation":ye||void 0,children:(0,I.jsx)(dp,{size:`30%`}),...f,onClick:e=>{f?.onClick?.(e),me.close(),be()}})]})]})});ax.classes={...tx,...Fb.classes,...Xb.classes},ax.displayName=`@mantine/dates/DateTimePicker`;function ox(e){let t=e,n=!1,r=new Set;return{getState(){return t},updateState(e){t=typeof e==`function`?e(t):e},setState(e){this.updateState(e),r.forEach(e=>e(t))},initialize(e){n||=(t=e,!0)},subscribe(e){return r.add(e),()=>r.delete(e)}}}function sx(e){return(0,v.useSyncExternalStore)(e.subscribe,()=>e.getState(),()=>e.getState())}function cx(e,t,n){let r=[],i=[],a={};for(let o of e){let e=o.position||t;a[e]=a[e]||0,a[e]+=1,a[e]<=n?i.push(o):r.push(o)}return{notifications:i,queue:r}}var lx=ox({notifications:[],queue:[],defaultPosition:`bottom-right`,limit:5}),ux=(e=lx)=>sx(e);function dx(e,t){let n=e.getState(),r=cx(t([...n.notifications,...n.queue]),n.defaultPosition,n.limit);e.setState({notifications:r.notifications,queue:r.queue,limit:n.limit,defaultPosition:n.defaultPosition})}function fx(e,t=lx){let n=e.id||At();return dx(t,t=>e.id&&t.some(t=>t.id===e.id)?t:[...t,{...e,id:n}]),n}function px(e,t=lx){return dx(t,t=>t.filter(t=>t.id===e?(t.onClose?.(t),!1):!0)),e}function mx(e,t=lx){return dx(t,t=>t.map(t=>t.id===e.id?{...t,...e}:t)),e.id}function hx(e=lx){dx(e,()=>[])}function gx(e=lx){dx(e,t=>t.slice(0,e.getState().limit))}var _x={show:fx,hide:px,update:mx,clean:hx,cleanQueue:gx,updateState:dx};function vx(e,t){return vx=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},vx(e,t)}function yx(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,vx(e,t)}var bx={disabled:!1},xx=v.createContext(null),Sx=function(e){return e.scrollTop},Cx=`unmounted`,wx=`exited`,Tx=`entering`,Ex=`entered`,Dx=`exiting`,Ox=function(e){yx(t,e);function t(t,n){var r=e.call(this,t,n)||this,i=n,a=i&&!i.isMounting?t.enter:t.appear,o;return r.appearStatus=null,t.in?a?(o=wx,r.appearStatus=Tx):o=Ex:o=t.unmountOnExit||t.mountOnEnter?Cx:wx,r.state={status:o},r.nextCallback=null,r}t.getDerivedStateFromProps=function(e,t){return e.in&&t.status===`unmounted`?{status:wx}:null};var n=t.prototype;return n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(e){var t=null;if(e!==this.props){var n=this.state.status;this.props.in?n!==`entering`&&n!==`entered`&&(t=Tx):(n===`entering`||n===`entered`)&&(t=Dx)}this.updateStatus(!1,t)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var e=this.props.timeout,t=n=r=e,n,r;return e!=null&&typeof e!=`number`&&(t=e.exit,n=e.enter,r=e.appear===void 0?n:e.appear),{exit:t,enter:n,appear:r}},n.updateStatus=function(e,t){if(e===void 0&&(e=!1),t!==null)if(this.cancelNextCallback(),t===`entering`){if(this.props.unmountOnExit||this.props.mountOnEnter){var n=this.props.nodeRef?this.props.nodeRef.current:Ki.default.findDOMNode(this);n&&Sx(n)}this.performEnter(e)}else this.performExit();else this.props.unmountOnExit&&this.state.status===`exited`&&this.setState({status:Cx})},n.performEnter=function(e){var t=this,n=this.props.enter,r=this.context?this.context.isMounting:e,i=this.props.nodeRef?[r]:[Ki.default.findDOMNode(this),r],a=i[0],o=i[1],s=this.getTimeouts(),c=r?s.appear:s.enter;if(!e&&!n||bx.disabled){this.safeSetState({status:Ex},function(){t.props.onEntered(a)});return}this.props.onEnter(a,o),this.safeSetState({status:Tx},function(){t.props.onEntering(a,o),t.onTransitionEnd(c,function(){t.safeSetState({status:Ex},function(){t.props.onEntered(a,o)})})})},n.performExit=function(){var e=this,t=this.props.exit,n=this.getTimeouts(),r=this.props.nodeRef?void 0:Ki.default.findDOMNode(this);if(!t||bx.disabled){this.safeSetState({status:wx},function(){e.props.onExited(r)});return}this.props.onExit(r),this.safeSetState({status:Dx},function(){e.props.onExiting(r),e.onTransitionEnd(n.exit,function(){e.safeSetState({status:wx},function(){e.props.onExited(r)})})})},n.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(e,t){t=this.setNextCallback(t),this.setState(e,t)},n.setNextCallback=function(e){var t=this,n=!0;return this.nextCallback=function(r){n&&(n=!1,t.nextCallback=null,e(r))},this.nextCallback.cancel=function(){n=!1},this.nextCallback},n.onTransitionEnd=function(e,t){this.setNextCallback(t);var n=this.props.nodeRef?this.props.nodeRef.current:Ki.default.findDOMNode(this),r=e==null&&!this.props.addEndListener;if(!n||r){setTimeout(this.nextCallback,0);return}if(this.props.addEndListener){var i=this.props.nodeRef?[this.nextCallback]:[n,this.nextCallback],a=i[0],o=i[1];this.props.addEndListener(a,o)}e!=null&&setTimeout(this.nextCallback,e)},n.render=function(){var e=this.state.status;if(e===`unmounted`)return null;var t=this.props,n=t.children;t.in,t.mountOnEnter,t.unmountOnExit,t.appear,t.enter,t.exit,t.timeout,t.addEndListener,t.onEnter,t.onEntering,t.onEntered,t.onExit,t.onExiting,t.onExited,t.nodeRef;var r=Am(t,[`children`,`in`,`mountOnEnter`,`unmountOnExit`,`appear`,`enter`,`exit`,`timeout`,`addEndListener`,`onEnter`,`onEntering`,`onEntered`,`onExit`,`onExiting`,`onExited`,`nodeRef`]);return v.createElement(xx.Provider,{value:null},typeof n==`function`?n(e,r):v.cloneElement(v.Children.only(n),r))},t}(v.Component);Ox.contextType=xx,Ox.propTypes={};function kx(){}Ox.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:kx,onEntering:kx,onEntered:kx,onExit:kx,onExiting:kx,onExited:kx},Ox.UNMOUNTED=Cx,Ox.EXITED=wx,Ox.ENTERING=Tx,Ox.ENTERED=Ex,Ox.EXITING=Dx;function Ax(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function jx(e,t){var n=function(e){return t&&(0,v.isValidElement)(e)?t(e):e},r=Object.create(null);return e&&v.Children.map(e,function(e){return e}).forEach(function(e){r[e.key]=n(e)}),r}function Mx(e,t){e||={},t||={};function n(n){return n in t?t[n]:e[n]}var r=Object.create(null),i=[];for(var a in e)a in t?i.length&&(r[a]=i,i=[]):i.push(a);var o,s={};for(var c in t){if(r[c])for(o=0;o<r[c].length;o++){var l=r[c][o];s[r[c][o]]=n(l)}s[c]=n(c)}for(o=0;o<i.length;o++)s[i[o]]=n(i[o]);return s}function Nx(e,t,n){return n[t]==null?e.props[t]:n[t]}function Px(e,t){return jx(e.children,function(n){return(0,v.cloneElement)(n,{onExited:t.bind(null,n),in:!0,appear:Nx(n,`appear`,e),enter:Nx(n,`enter`,e),exit:Nx(n,`exit`,e)})})}function Fx(e,t,n){var r=jx(e.children),i=Mx(t,r);return Object.keys(i).forEach(function(a){var o=i[a];if((0,v.isValidElement)(o)){var s=a in t,c=a in r,l=t[a],u=(0,v.isValidElement)(l)&&!l.props.in;c&&(!s||u)?i[a]=(0,v.cloneElement)(o,{onExited:n.bind(null,o),in:!0,exit:Nx(o,`exit`,e),enter:Nx(o,`enter`,e)}):!c&&s&&!u?i[a]=(0,v.cloneElement)(o,{in:!1}):c&&s&&(0,v.isValidElement)(l)&&(i[a]=(0,v.cloneElement)(o,{onExited:n.bind(null,o),in:l.props.in,exit:Nx(o,`exit`,e),enter:Nx(o,`enter`,e)}))}}),i}var Ix=Object.values||function(e){return Object.keys(e).map(function(t){return e[t]})},Lx={component:`div`,childFactory:function(e){return e}},Rx=function(e){yx(t,e);function t(t,n){var r=e.call(this,t,n)||this;return r.state={contextValue:{isMounting:!0},handleExited:r.handleExited.bind(Ax(r)),firstRender:!0},r}var n=t.prototype;return n.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},n.componentWillUnmount=function(){this.mounted=!1},t.getDerivedStateFromProps=function(e,t){var n=t.children,r=t.handleExited;return{children:t.firstRender?Px(e,r):Fx(e,n,r),firstRender:!1}},n.handleExited=function(e,t){var n=jx(this.props.children);e.key in n||(e.props.onExited&&e.props.onExited(t),this.mounted&&this.setState(function(t){var n=km({},t.children);return delete n[e.key],{children:n}}))},n.render=function(){var e=this.props,t=e.component,n=e.childFactory,r=Am(e,[`component`,`childFactory`]),i=this.state.contextValue,a=Ix(this.state.children).map(n);return delete r.appear,delete r.enter,delete r.exit,t===null?v.createElement(xx.Provider,{value:i},a):v.createElement(xx.Provider,{value:i},v.createElement(t,r,a))},t}(v.Component);Rx.propTypes={},Rx.defaultProps=Lx;var zx=[`bottom-center`,`bottom-left`,`bottom-right`,`top-center`,`top-left`,`top-right`];function Bx(e,t){return e.reduce((e,n)=>(e[n.position||t].push(n),e),zx.reduce((e,t)=>(e[t]=[],e),{}))}var Vx={left:`translateX(-100%)`,right:`translateX(100%)`,"top-center":`translateY(-100%)`,"bottom-center":`translateY(100%)`},Hx={left:`translateX(0)`,right:`translateX(0)`,"top-center":`translateY(0)`,"bottom-center":`translateY(0)`};function Ux({state:e,maxHeight:t,position:n,transitionDuration:r}){let[i,a]=n.split(`-`),o=a===`center`?`${i}-center`:a,s={opacity:0,maxHeight:t,transform:Vx[o],transitionDuration:`${r}ms, ${r}ms, ${r}ms`,transitionTimingFunction:`cubic-bezier(.51,.3,0,1.21), cubic-bezier(.51,.3,0,1.21), linear`,transitionProperty:`opacity, transform, max-height`},c={opacity:1,transform:Hx[o]},l={opacity:0,maxHeight:0,transform:Vx[o]},u={entering:c,entered:c,exiting:l,exited:l};return{...s,...u[e]}}function Wx(e,t){return typeof t==`number`?t:t===!1||e===!1?!1:e}var Gx=(0,v.forwardRef)(({data:e,onHide:t,autoClose:n,...r},i)=>{let{autoClose:a,message:o,...s}=e,c=Wx(n,e.autoClose),l=(0,v.useRef)(-1),u=()=>window.clearTimeout(l.current),d=()=>{t(e.id),u()},f=()=>{typeof c==`number`&&(l.current=window.setTimeout(d,c))};return(0,v.useEffect)(()=>{e.onOpen?.(e)},[]),(0,v.useEffect)(()=>(f(),u),[c]),(0,I.jsx)(Lh,{...r,...s,onClose:d,ref:i,onMouseEnter:u,onMouseLeave:f,children:o})});Gx.displayName=`@mantine/notifications/NotificationContainer`;var Kx={root:`m_b37d9ac7`,notification:`m_5ed0edd0`},qx=Ox,Jx={position:`bottom-right`,autoClose:4e3,transitionDuration:250,containerWidth:440,notificationMaxHeight:200,limit:5,zIndex:ht(`overlay`),store:lx,withinPortal:!0},Yx=On((e,{zIndex:t,containerWidth:n})=>({root:{"--notifications-z-index":t?.toString(),"--notifications-container-width":F(n)}})),Xx=z((e,t)=>{let n=L(`Notifications`,Jx,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,position:l,autoClose:u,transitionDuration:d,containerWidth:f,notificationMaxHeight:p,limit:m,zIndex:h,store:g,portalProps:_,withinPortal:y,...b}=n,x=br(),S=ux(g),C=en(),w=pn(),T=(0,v.useRef)({}),E=(0,v.useRef)(0),D=x.respectReducedMotion&&w?1:d,O=ii({name:`Notifications`,classes:Kx,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,vars:c,varsResolver:Yx});(0,v.useEffect)(()=>{g?.updateState(e=>({...e,limit:m||5,defaultPosition:l}))},[m,l]),Vt(()=>{S.notifications.length>E.current&&setTimeout(()=>C(),0),E.current=S.notifications.length},[S.notifications]);let k=Bx(S.notifications,l),A=zx.reduce((e,t)=>(e[t]=k[t].map(({style:e,...n})=>(0,I.jsx)(qx,{timeout:D,onEnter:()=>T.current[n.id].offsetHeight,nodeRef:{current:T.current[n.id]},children:r=>(0,I.jsx)(Gx,{ref:e=>{e&&(T.current[n.id]=e)},data:n,onHide:e=>px(e,g),autoClose:u,...O(`notification`,{style:{...Ux({state:r,position:t,transitionDuration:D,maxHeight:p}),...e}})})},n.id)),e),{});return(0,I.jsxs)(Il,{withinPortal:y,..._,children:[(0,I.jsx)(R,{...O(`root`),"data-position":`top-center`,ref:t,...b,children:(0,I.jsx)(Rx,{children:A[`top-center`]})}),(0,I.jsx)(R,{...O(`root`),"data-position":`top-left`,...b,children:(0,I.jsx)(Rx,{children:A[`top-left`]})}),(0,I.jsx)(R,{...O(`root`,{className:Ke.classNames.fullWidth}),"data-position":`top-right`,...b,children:(0,I.jsx)(Rx,{children:A[`top-right`]})}),(0,I.jsx)(R,{...O(`root`,{className:Ke.classNames.fullWidth}),"data-position":`bottom-right`,...b,children:(0,I.jsx)(Rx,{children:A[`bottom-right`]})}),(0,I.jsx)(R,{...O(`root`),"data-position":`bottom-left`,...b,children:(0,I.jsx)(Rx,{children:A[`bottom-left`]})}),(0,I.jsx)(R,{...O(`root`),"data-position":`bottom-center`,...b,children:(0,I.jsx)(Rx,{children:A[`bottom-center`]})})]})});Xx.classes=Kx,Xx.displayName=`@mantine/notifications/Notifications`,Xx.show=_x.show,Xx.hide=_x.hide,Xx.update=_x.update,Xx.clean=_x.clean,Xx.cleanQueue=_x.cleanQueue,Xx.updateState=_x.updateState;var Zx=`modulepreload`,Qx=function(e){return`/erp/`+e},$x={},eS=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Qx(t,n),t in $x)return;$x[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Zx,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},tS=`popstate`;function nS(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function rS(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return cS(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:lS(t)}return dS(t,n,null,e)}function iS(e,t){if(e===!1||e==null)throw Error(t)}function aS(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function oS(){return Math.random().toString(36).substring(2,10)}function sS(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function cS(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?uS(t):t,state:n,key:t&&t.key||r||oS(),unstable_mask:i}}function lS({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function uS(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function dS(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=nS(e)?e:cS(h.location,e,t);n&&n(r,e),l=u()+1;let d=sS(r,l),f=h.createHref(r.unstable_mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=nS(e)?e:cS(h.location,e,t);n&&n(r,e),l=u();let i=sS(r,l),d=h.createHref(r.unstable_mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return fS(e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(tS,d),c=e,()=>{i.removeEventListener(tS,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function fS(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),iS(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:lS(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function pS(e,t,n=`/`){return mS(e,t,n,!1)}function mS(e,t,n,r){let i=MS((typeof t==`string`?uS(t):t).pathname||`/`,n);if(i==null)return null;let a=gS(e);vS(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=jS(i);o=OS(a[e],t,r)}return o}function hS(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function gS(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;iS(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=BS([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(iS(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),gS(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:ES(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of _S(e.path))a(e,t,!0,n)}),t}function _S(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=_S(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function vS(e){e.sort((e,t)=>e.score===t.score?DS(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var yS=/^:[\w-]+$/,bS=3,xS=2,SS=1,CS=10,wS=-2,TS=e=>e===`*`;function ES(e,t){let n=e.split(`/`),r=n.length;return n.some(TS)&&(r+=wS),t&&(r+=xS),n.filter(e=>!TS(e)).reduce((e,t)=>e+(yS.test(t)?bS:t===``?SS:CS),r)}function DS(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function OS(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=kS({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=kS({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:BS([a,u.pathname]),pathnameBase:VS(BS([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=BS([a,u.pathnameBase]))}return o}function kS(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=AS(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function AS(e,t=!1,n=!0){aS(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function jS(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return aS(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function MS(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var NS=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function PS(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?uS(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?FS(n.substring(1),`/`):FS(n,t)):a=t,{pathname:a,search:HS(r),hash:US(i)}}function FS(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function IS(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function LS(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function RS(e){let t=LS(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function zS(e,t,n,r=!1){let i;typeof e==`string`?i=uS(e):(i={...e},iS(!i.pathname||!i.pathname.includes(`?`),IS(`?`,`pathname`,`search`,i)),iS(!i.pathname||!i.pathname.includes(`#`),IS(`#`,`pathname`,`hash`,i)),iS(!i.search||!i.search.includes(`#`),IS(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=PS(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var BS=e=>e.join(`/`).replace(/\/\/+/g,`/`),VS=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),HS=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,US=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,WS=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function GS(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function KS(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var qS=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function JS(e,t){let n=e;if(typeof n!=`string`||!NS.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(qS)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=MS(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{aS(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var YS=v.createContext(null);YS.displayName=`DataRouter`;var XS=v.createContext(null);XS.displayName=`DataRouterState`;var ZS=v.createContext(!1),QS=v.createContext({isTransitioning:!1});QS.displayName=`ViewTransition`;var $S=v.createContext(new Map);$S.displayName=`Fetchers`;var eC=v.createContext(null);eC.displayName=`Await`;var tC=v.createContext(null);tC.displayName=`Navigation`;var nC=v.createContext(null);nC.displayName=`Location`;var rC=v.createContext({outlet:null,matches:[],isDataRoute:!1});rC.displayName=`Route`;var iC=v.createContext(null);iC.displayName=`RouteError`;var aC=`REACT_ROUTER_ERROR`,oC=`REDIRECT`,sC=`ROUTE_ERROR_RESPONSE`;function cC(e){if(e.startsWith(`${aC}:${oC}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function lC(e){if(e.startsWith(`${aC}:${sC}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new WS(t.status,t.statusText,t.data)}catch{}}function uC(e,{relative:t}={}){iS(dC(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=v.useContext(tC),{hash:i,pathname:a,search:o}=xC(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:BS([n,a])),r.createHref({pathname:s,search:o,hash:i})}function dC(){return v.useContext(nC)!=null}function fC(){return iS(dC(),`useLocation() may be used only in the context of a <Router> component.`),v.useContext(nC).location}var pC=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function mC(e){v.useContext(tC).static||v.useLayoutEffect(e)}function hC(){let{isDataRoute:e}=v.useContext(rC);return e?BC():gC()}function gC(){iS(dC(),`useNavigate() may be used only in the context of a <Router> component.`);let e=v.useContext(YS),{basename:t,navigator:n}=v.useContext(tC),{matches:r}=v.useContext(rC),{pathname:i}=fC(),a=JSON.stringify(RS(r)),o=v.useRef(!1);return mC(()=>{o.current=!0}),v.useCallback((r,s={})=>{if(aS(o.current,pC),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=zS(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:BS([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var _C=v.createContext(null);function vC(){return v.useContext(_C)}function yC(e){let t=v.useContext(rC).outlet;return v.useMemo(()=>t&&v.createElement(_C.Provider,{value:e},t),[t,e])}function bC(){let{matches:e}=v.useContext(rC),t=e[e.length-1];return t?t.params:{}}function xC(e,{relative:t}={}){let{matches:n}=v.useContext(rC),{pathname:r}=fC(),i=JSON.stringify(RS(n));return v.useMemo(()=>zS(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function SC(e,t){return CC(e,t)}function CC(e,t,n){iS(dC(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=v.useContext(tC),{matches:i}=v.useContext(rC),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;HC(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
62
62
 
63
- Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let u=fC(),d;if(t){let e=typeof t==`string`?uS(t):t;iS(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,p=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);p=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let m=pS(e,{pathname:p});aS(l||m!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),aS(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let h=AC(m&&m.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:BS([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:BS([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&h?v.createElement(nC.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,unstable_mask:void 0,...d},navigationType:`POP`}},h):h}function wC(){let e=zC(),t=GS(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=v.createElement(v.Fragment,null,v.createElement(`p`,null,`💿 Hey developer 👋`),v.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,v.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,v.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),v.createElement(v.Fragment,null,v.createElement(`h2`,null,`Unexpected Application Error!`),v.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?v.createElement(`pre`,{style:i},n):null,o)}var TC=v.createElement(wC,null),EC=class extends v.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=lC(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:v.createElement(rC.Provider,{value:this.props.routeContext},v.createElement(iC.Provider,{value:e,children:this.props.component}));return this.context?v.createElement(OC,{error:e},t):t}};EC.contextType=ZS;var DC=new WeakMap;function OC({children:e,error:t}){let{basename:n}=v.useContext(tC);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=cC(t.digest);if(e){let r=DC.get(t);if(r)throw r;let i=JS(e.location,n);if(qS&&!DC.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw DC.set(t,n),n}return v.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function kC({routeContext:e,match:t,children:n}){let r=v.useContext(YS);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),v.createElement(rC.Provider,{value:e},n)}function AC(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);iS(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(s=e),t.route.id){let{loaderData:e,errors:a}=r,c=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||c){n.isStatic&&(o=!0),i=s>=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},unstable_pattern:KS(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let u,d=!1,f=null,p=null;r&&(u=a&&n.route.id?a[n.route.id]:void 0,f=n.route.errorElement||TC,o&&(s<0&&c===0?(HC(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):s===c&&(d=!0,p=n.route.hydrateFallbackElement||null)));let m=t.concat(i.slice(0,c+1)),h=()=>{let t;return t=u?f:d?p:n.route.Component?v.createElement(n.route.Component,null):n.route.element?n.route.element:e,v.createElement(kC,{match:n,routeContext:{outlet:e,matches:m,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?v.createElement(EC,{location:r.location,revalidation:r.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function jC(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function MC(e){let t=v.useContext(YS);return iS(t,jC(e)),t}function NC(e){let t=v.useContext(XS);return iS(t,jC(e)),t}function PC(e){let t=v.useContext(rC);return iS(t,jC(e)),t}function FC(e){let t=PC(e),n=t.matches[t.matches.length-1];return iS(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function IC(){return FC(`useRouteId`)}function LC(){return NC(`useNavigation`).navigation}function RC(){let{matches:e,loaderData:t}=NC(`useMatches`);return v.useMemo(()=>e.map(e=>hS(e,t)),[e,t])}function zC(){let e=v.useContext(iC),t=NC(`useRouteError`),n=FC(`useRouteError`);return e===void 0?t.errors?.[n]:e}function BC(){let{router:e}=MC(`useNavigate`),t=FC(`useNavigate`),n=v.useRef(!1);return mC(()=>{n.current=!0}),v.useCallback(async(r,i={})=>{aS(n.current,pC),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var VC={};function HC(e,t,n){!t&&!VC[e]&&(VC[e]=!0,aS(!1,n))}v.useOptimistic,v.memo(UC);function UC({routes:e,future:t,state:n,isStatic:r,onError:i}){return CC(e,void 0,{state:n,isStatic:r,onError:i,future:t})}function WC({to:e,replace:t,state:n,relative:r}){iS(dC(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=v.useContext(tC);aS(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=v.useContext(rC),{pathname:o}=fC(),s=hC(),c=zS(e,RS(a),o,r===`path`),l=JSON.stringify(c);return v.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function GC(e){return yC(e.context)}function KC(e){iS(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function qC({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:o}){iS(!dC(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=v.useMemo(()=>({basename:s,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=uS(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`,unstable_mask:m}=n,h=v.useMemo(()=>{let e=MS(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p,unstable_mask:m},navigationType:r}},[s,l,u,d,f,p,r,m]);return aS(h!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),h==null?null:v.createElement(tC.Provider,{value:c},v.createElement(nC.Provider,{children:t,value:h}))}function JC({children:e,location:t}){return SC(YC(e),t)}function YC(e,t=[]){let n=[];return v.Children.forEach(e,(e,r)=>{if(!v.isValidElement(e))return;let i=[...t,r];if(e.type===v.Fragment){n.push.apply(n,YC(e.props.children,i));return}iS(e.type===KC,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),iS(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=YC(e.props.children,i)),n.push(a)}),n}var XC=`get`,ZC=`application/x-www-form-urlencoded`;function QC(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function $C(e){return QC(e)&&e.tagName.toLowerCase()===`button`}function ew(e){return QC(e)&&e.tagName.toLowerCase()===`form`}function tw(e){return QC(e)&&e.tagName.toLowerCase()===`input`}function nw(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function rw(e,t){return e.button===0&&(!t||t===`_self`)&&!nw(e)}function iw(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function aw(e,t){let n=iw(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var ow=null;function sw(){if(ow===null)try{new FormData(document.createElement(`form`),0),ow=!1}catch{ow=!0}return ow}var cw=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function lw(e){return e!=null&&!cw.has(e)?(aS(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ZC}"`),null):e}function uw(e,t){let n,r,i,a,o;if(ew(e)){let o=e.getAttribute(`action`);r=o?MS(o,t):null,n=e.getAttribute(`method`)||XC,i=lw(e.getAttribute(`enctype`))||ZC,a=new FormData(e)}else if($C(e)||tw(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?MS(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||XC,i=lw(e.getAttribute(`formenctype`))||lw(o.getAttribute(`enctype`))||ZC,a=new FormData(o,e),!sw()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(QC(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=XC,r=null,i=ZC,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var dw={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},fw=/[&><\u2028\u2029]/g;function pw(e){return e.replace(fw,e=>dw[e])}function mw(e,t){if(e===!1||e==null)throw Error(t)}function hw(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&MS(i.pathname,t)===`/`?i.pathname=`${t.replace(/\/$/,``)}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,``)}.${r}`,i}async function gw(e,t){if(e.id in t)return t[e.id];try{let n=await eS(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function _w(e){return e!=null&&typeof e.page==`string`}function vw(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function yw(e,t,n){return ww((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await gw(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(vw).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function bw(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function xw(e,t,{includeHydrateFallback:n}={}){return Sw(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function Sw(e){return[...new Set(e)]}function Cw(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function ww(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!_w(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(Cw(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function Tw(){let e=v.useContext(YS);return mw(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function Ew(){let e=v.useContext(XS);return mw(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var Dw=v.createContext(void 0);Dw.displayName=`FrameworkContext`;function Ow(){let e=v.useContext(Dw);return mw(e,`You must render this element inside a <HydratedRouter> element`),e}function kw(e,t){let n=v.useContext(Dw),[r,i]=v.useState(!1),[a,o]=v.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=v.useRef(null);v.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),v.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:Aw(s,p),onBlur:Aw(c,m),onMouseEnter:Aw(l,p),onMouseLeave:Aw(u,m),onTouchStart:Aw(d,p)}]:[a,f,{}]:[!1,f,{}]}function Aw(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function jw({page:e,...t}){let{router:n}=Tw(),r=v.useMemo(()=>pS(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?v.createElement(Nw,{page:e,matches:r,...t}):null}function Mw(e){let{manifest:t,routeModules:n}=Ow(),[r,i]=v.useState([]);return v.useEffect(()=>{let r=!1;return yw(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function Nw({page:e,matches:t,...n}){let r=fC(),{future:i,manifest:a,routeModules:o}=Ow(),{basename:s}=Tw(),{loaderData:c,matches:l}=Ew(),u=v.useMemo(()=>bw(e,t,l,a,r,`data`),[e,t,l,a,r]),d=v.useMemo(()=>bw(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=v.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=hw(e,s,i.unstable_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.unstable_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=v.useMemo(()=>xw(d,a),[d,a]),m=Mw(d);return v.createElement(v.Fragment,null,f.map(e=>v.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>v.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>v.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function Pw(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}var Fw=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{Fw&&(window.__reactRouterVersion=`7.13.1`)}catch{}function Iw({basename:e,children:t,unstable_useTransitions:n,window:r}){let i=v.useRef();i.current??=rS({window:r,v5Compat:!0});let a=i.current,[o,s]=v.useState({action:a.action,location:a.location}),c=v.useCallback(e=>{n===!1?s(e):v.startTransition(()=>s(e))},[n]);return v.useLayoutEffect(()=>a.listen(c),[a,c]),v.createElement(qC,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}function Lw({basename:e,children:t,history:n,unstable_useTransitions:r}){let[i,a]=v.useState({action:n.action,location:n.location}),o=v.useCallback(e=>{r===!1?a(e):v.startTransition(()=>a(e))},[r]);return v.useLayoutEffect(()=>n.listen(o),[n,o]),v.createElement(qC,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,unstable_useTransitions:r})}Lw.displayName=`unstable_HistoryRouter`;var Rw=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,zw=v.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,unstable_mask:o,state:s,target:c,to:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m){let{basename:h,navigator:g,unstable_useTransitions:_}=v.useContext(tC),y=typeof l==`string`&&Rw.test(l),b=JS(l,h);l=b.to;let x=uC(l,{relative:r}),S=fC(),C=null;if(o){let e=zS(o,[],S.unstable_mask?S.unstable_mask.pathname:`/`,!0);h!==`/`&&(e.pathname=e.pathname===`/`?h:BS([h,e.pathname])),C=g.createHref(e)}let[w,T,E]=kw(n,p),D=Kw(l,{replace:a,unstable_mask:o,state:s,target:c,preventScrollReset:u,relative:r,viewTransition:d,unstable_defaultShouldRevalidate:f,unstable_useTransitions:_});function O(t){e&&e(t),t.defaultPrevented||D(t)}let k=!(b.isExternal||i),A=v.createElement(`a`,{...p,...E,href:(k?C:void 0)||b.absoluteURL||x,onClick:k?O:e,ref:Pw(m,T),target:c,"data-discover":!y&&t===`render`?`true`:void 0});return w&&!y?v.createElement(v.Fragment,null,A,v.createElement(jw,{page:x})):A});zw.displayName=`Link`;var Bw=v.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=xC(a,{relative:c.relative}),d=fC(),f=v.useContext(XS),{navigator:p,basename:m}=v.useContext(tC),h=f!=null&&rT(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,_=d.pathname,y=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(_=_.toLowerCase(),y=y?y.toLowerCase():null,g=g.toLowerCase()),y&&m&&(y=MS(y,m)||y);let b=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,x=_===g||!r&&_.startsWith(g)&&_.charAt(b)===`/`,S=y!=null&&(y===g||!r&&y.startsWith(g)&&y.charAt(g.length)===`/`),C={isActive:x,isPending:S,isTransitioning:h},w=x?e:void 0,T;T=typeof n==`function`?n(C):[n,x?`active`:null,S?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let E=typeof i==`function`?i(C):i;return v.createElement(zw,{...c,"aria-current":w,className:T,ref:l,style:E,to:a,viewTransition:o},typeof s==`function`?s(C):s)});Bw.displayName=`NavLink`;var Vw=v.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=XC,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m)=>{let{unstable_useTransitions:h}=v.useContext(tC),g=Xw(),_=Zw(s,{relative:l}),y=o.toLowerCase()===`get`?`get`:`post`,b=typeof s==`string`&&Rw.test(s);return v.createElement(`form`,{ref:m,method:y,action:_,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f});h&&n!==!1?v.startTransition(()=>p()):p()},...p,"data-discover":!b&&e===`render`?`true`:void 0})});Vw.displayName=`Form`;function Hw({getKey:e,storageKey:t,...n}){let r=v.useContext(Dw),{basename:i}=v.useContext(tC),a=fC(),o=RC();tT({getKey:e,storageKey:t});let s=v.useMemo(()=>{if(!r||!e)return null;let t=eT(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let c=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return v.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${pw(JSON.stringify(t||Qw))}, ${pw(JSON.stringify(s))})`}})}Hw.displayName=`ScrollRestoration`;function Uw(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ww(e){let t=v.useContext(YS);return iS(t,Uw(e)),t}function Gw(e){let t=v.useContext(XS);return iS(t,Uw(e)),t}function Kw(e,{target:t,replace:n,unstable_mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,unstable_defaultShouldRevalidate:c,unstable_useTransitions:l}={}){let u=hC(),d=fC(),f=xC(e,{relative:o});return v.useCallback(p=>{if(rw(p,t)){p.preventDefault();let t=n===void 0?lS(d)===lS(f):n,m=()=>u(e,{replace:t,unstable_mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,unstable_defaultShouldRevalidate:c});l?v.startTransition(()=>m()):m()}},[d,u,f,n,r,i,t,e,a,o,s,c,l])}function qw(e){aS(typeof URLSearchParams<`u`,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=v.useRef(iw(e)),n=v.useRef(!1),r=fC(),i=v.useMemo(()=>aw(r.search,n.current?null:t.current),[r.search]),a=hC();return[i,v.useCallback((e,t)=>{let r=iw(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var Jw=0,Yw=()=>`__${String(++Jw)}__`;function Xw(){let{router:e}=Ww(`useSubmit`),{basename:t}=v.useContext(tC),n=IC(),r=e.fetch,i=e.navigate;return v.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=uw(e,t);a.navigate===!1?await r(a.fetcherKey||Yw(),n,a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function Zw(e,{relative:t}={}){let{basename:n}=v.useContext(tC),r=v.useContext(rC);iS(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...xC(e||`.`,{relative:t})},o=fC();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:BS([n,a.pathname])),lS(a)}var Qw=`react-router-scroll-positions`,$w={};function eT(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:MS(e.pathname,n)||e.pathname},t)),i??=e.key,i}function tT({getKey:e,storageKey:t}={}){let{router:n}=Ww(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=Gw(`useScrollRestoration`),{basename:a}=v.useContext(tC),o=fC(),s=RC(),c=LC();v.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),nT(v.useCallback(()=>{if(c.state===`idle`){let t=eT(o,s,a,e);$w[t]=window.scrollY}try{sessionStorage.setItem(t||Qw,JSON.stringify($w))}catch(e){aS(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(v.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||Qw);e&&($w=JSON.parse(e))}catch{}},[t]),v.useLayoutEffect(()=>{let t=n?.enableScrollRestoration($w,()=>window.scrollY,e?(t,n)=>eT(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),v.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{aS(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function nT(e,t){let{capture:n}=t||{};v.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function rT(e,{relative:t}={}){let n=v.useContext(QS);iS(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Ww(`useViewTransitionState`),i=xC(e,{relative:t});if(!n.isTransitioning)return!1;let a=MS(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=MS(n.nextLocation.pathname,r)||n.nextLocation.pathname;return kS(i.pathname,o)!=null||kS(i.pathname,a)!=null}Object.freeze({status:`aborted`});function K(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var iT=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},aT=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},oT={};function sT(e){return e&&Object.assign(oT,e),oT}function cT(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function lT(e,t){return typeof t==`bigint`?t.toString():t}function uT(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function dT(e){return e==null}function fT(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function pT(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var mT=Symbol(`evaluating`);function hT(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==mT)return r===void 0&&(r=mT,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function gT(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function _T(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function vT(e){return JSON.stringify(e)}function yT(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var bT=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function xT(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ST=uT(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function CT(e){if(xT(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(xT(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function wT(e){return CT(e)?{...e}:Array.isArray(e)?[...e]:e}var TT=new Set([`string`,`number`,`symbol`]);function ET(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function DT(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function OT(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function kT(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var AT={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function jT(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return DT(e,_T(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return gT(this,`shape`,e),e},checks:[]}))}function MT(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return DT(e,_T(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return gT(this,`shape`,r),r},checks:[]}))}function NT(e,t){if(!CT(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return DT(e,_T(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return gT(this,`shape`,n),n}}))}function PT(e,t){if(!CT(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return DT(e,_T(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return gT(this,`shape`,n),n}}))}function FT(e,t){return DT(e,_T(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return gT(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function IT(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return DT(t,_T(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return gT(this,`shape`,i),i},checks:[]}))}function LT(e,t,n){return DT(t,_T(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return gT(this,`shape`,i),i}}))}function RT(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function zT(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function BT(e){return typeof e==`string`?e:e?.message}function VT(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=BT(e.inst?._zod.def?.error?.(e))??BT(t?.error?.(e))??BT(n.customError?.(e))??BT(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function HT(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function UT(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var WT=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,lT,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},GT=K(`$ZodError`,WT),KT=K(`$ZodError`,WT,{Parent:Error});function qT(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function JT(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}var YT=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new iT;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>VT(e,a,sT())));throw bT(t,i?.callee),t}return o.value},XT=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>VT(e,a,sT())));throw bT(t,i?.callee),t}return o.value},ZT=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new iT;return a.issues.length?{success:!1,error:new(e??GT)(a.issues.map(e=>VT(e,i,sT())))}:{success:!0,data:a.value}},QT=ZT(KT),$T=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>VT(e,i,sT())))}:{success:!0,data:a.value}},eE=$T(KT),tE=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return YT(e)(t,n,i)},nE=e=>(t,n,r)=>YT(e)(t,n,r),rE=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return XT(e)(t,n,i)},iE=e=>async(t,n,r)=>XT(e)(t,n,r),aE=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return ZT(e)(t,n,i)},oE=e=>(t,n,r)=>ZT(e)(t,n,r),sE=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return $T(e)(t,n,i)},cE=e=>async(t,n,r)=>$T(e)(t,n,r),lE=/^[cC][^\s-]{8,}$/,uE=/^[0-9a-z]+$/,dE=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,fE=/^[0-9a-vA-V]{20}$/,pE=/^[A-Za-z0-9]{27}$/,mE=/^[a-zA-Z0-9_-]{21}$/,hE=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,gE=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,_E=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,vE=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,yE=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function bE(){return new RegExp(yE,`u`)}var xE=/^(?:(?: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])$/,SE=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,CE=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,wE=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,TE=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,EE=/^[A-Za-z0-9_-]*$/,DE=/^\+[1-9]\d{6,14}$/,OE=`(?:(?:\\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])))`,kE=RegExp(`^${OE}$`);function AE(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function jE(e){return RegExp(`^${AE(e)}$`)}function ME(e){let t=AE({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${OE}T(?:${r})$`)}var NE=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},PE=/^-?\d+$/,FE=/^-?\d+(?:\.\d+)?$/,IE=/^(?:true|false)$/i,LE=/^[^A-Z]*$/,RE=/^[^a-z]*$/,zE=K(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),BE={number:`number`,bigint:`bigint`,object:`date`},VE=K(`$ZodCheckLessThan`,(e,t)=>{zE.init(e,t);let n=BE[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),HE=K(`$ZodCheckGreaterThan`,(e,t)=>{zE.init(e,t);let n=BE[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),UE=K(`$ZodCheckMultipleOf`,(e,t)=>{zE.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):pT(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),WE=K(`$ZodCheckNumberFormat`,(e,t)=>{zE.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=AT[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=PE)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),GE=K(`$ZodCheckMaxLength`,(e,t)=>{var n;zE.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!dT(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=HT(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),KE=K(`$ZodCheckMinLength`,(e,t)=>{var n;zE.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!dT(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=HT(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),qE=K(`$ZodCheckLengthEquals`,(e,t)=>{var n;zE.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!dT(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=HT(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),JE=K(`$ZodCheckStringFormat`,(e,t)=>{var n,r;zE.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),YE=K(`$ZodCheckRegex`,(e,t)=>{JE.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),XE=K(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=LE,JE.init(e,t)}),ZE=K(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=RE,JE.init(e,t)}),QE=K(`$ZodCheckIncludes`,(e,t)=>{zE.init(e,t);let n=ET(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),$E=K(`$ZodCheckStartsWith`,(e,t)=>{zE.init(e,t);let n=RegExp(`^${ET(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),eD=K(`$ZodCheckEndsWith`,(e,t)=>{zE.init(e,t);let n=RegExp(`.*${ET(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),tD=K(`$ZodCheckOverwrite`,(e,t)=>{zE.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),nD=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
63
+ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let u=fC(),d;if(t){let e=typeof t==`string`?uS(t):t;iS(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,p=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);p=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let m=pS(e,{pathname:p});aS(l||m!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),aS(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let h=AC(m&&m.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:BS([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:BS([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&h?v.createElement(nC.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,unstable_mask:void 0,...d},navigationType:`POP`}},h):h}function wC(){let e=zC(),t=GS(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=v.createElement(v.Fragment,null,v.createElement(`p`,null,`💿 Hey developer 👋`),v.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,v.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,v.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),v.createElement(v.Fragment,null,v.createElement(`h2`,null,`Unexpected Application Error!`),v.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?v.createElement(`pre`,{style:i},n):null,o)}var TC=v.createElement(wC,null),EC=class extends v.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=lC(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:v.createElement(rC.Provider,{value:this.props.routeContext},v.createElement(iC.Provider,{value:e,children:this.props.component}));return this.context?v.createElement(OC,{error:e},t):t}};EC.contextType=ZS;var DC=new WeakMap;function OC({children:e,error:t}){let{basename:n}=v.useContext(tC);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=cC(t.digest);if(e){let r=DC.get(t);if(r)throw r;let i=JS(e.location,n);if(qS&&!DC.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw DC.set(t,n),n}return v.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function kC({routeContext:e,match:t,children:n}){let r=v.useContext(YS);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),v.createElement(rC.Provider,{value:e},n)}function AC(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);iS(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(s=e),t.route.id){let{loaderData:e,errors:a}=r,c=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||c){n.isStatic&&(o=!0),i=s>=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},unstable_pattern:KS(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let u,d=!1,f=null,p=null;r&&(u=a&&n.route.id?a[n.route.id]:void 0,f=n.route.errorElement||TC,o&&(s<0&&c===0?(HC(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):s===c&&(d=!0,p=n.route.hydrateFallbackElement||null)));let m=t.concat(i.slice(0,c+1)),h=()=>{let t;return t=u?f:d?p:n.route.Component?v.createElement(n.route.Component,null):n.route.element?n.route.element:e,v.createElement(kC,{match:n,routeContext:{outlet:e,matches:m,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?v.createElement(EC,{location:r.location,revalidation:r.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function jC(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function MC(e){let t=v.useContext(YS);return iS(t,jC(e)),t}function NC(e){let t=v.useContext(XS);return iS(t,jC(e)),t}function PC(e){let t=v.useContext(rC);return iS(t,jC(e)),t}function FC(e){let t=PC(e),n=t.matches[t.matches.length-1];return iS(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function IC(){return FC(`useRouteId`)}function LC(){return NC(`useNavigation`).navigation}function RC(){let{matches:e,loaderData:t}=NC(`useMatches`);return v.useMemo(()=>e.map(e=>hS(e,t)),[e,t])}function zC(){let e=v.useContext(iC),t=NC(`useRouteError`),n=FC(`useRouteError`);return e===void 0?t.errors?.[n]:e}function BC(){let{router:e}=MC(`useNavigate`),t=FC(`useNavigate`),n=v.useRef(!1);return mC(()=>{n.current=!0}),v.useCallback(async(r,i={})=>{aS(n.current,pC),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var VC={};function HC(e,t,n){!t&&!VC[e]&&(VC[e]=!0,aS(!1,n))}v.useOptimistic,v.memo(UC);function UC({routes:e,future:t,state:n,isStatic:r,onError:i}){return CC(e,void 0,{state:n,isStatic:r,onError:i,future:t})}function WC({to:e,replace:t,state:n,relative:r}){iS(dC(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=v.useContext(tC);aS(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=v.useContext(rC),{pathname:o}=fC(),s=hC(),c=zS(e,RS(a),o,r===`path`),l=JSON.stringify(c);return v.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function GC(e){return yC(e.context)}function KC(e){iS(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function qC({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:o}){iS(!dC(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=v.useMemo(()=>({basename:s,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=uS(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`,unstable_mask:m}=n,h=v.useMemo(()=>{let e=MS(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p,unstable_mask:m},navigationType:r}},[s,l,u,d,f,p,r,m]);return aS(h!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),h==null?null:v.createElement(tC.Provider,{value:c},v.createElement(nC.Provider,{children:t,value:h}))}function JC({children:e,location:t}){return SC(YC(e),t)}function YC(e,t=[]){let n=[];return v.Children.forEach(e,(e,r)=>{if(!v.isValidElement(e))return;let i=[...t,r];if(e.type===v.Fragment){n.push.apply(n,YC(e.props.children,i));return}iS(e.type===KC,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),iS(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=YC(e.props.children,i)),n.push(a)}),n}var XC=`get`,ZC=`application/x-www-form-urlencoded`;function QC(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function $C(e){return QC(e)&&e.tagName.toLowerCase()===`button`}function ew(e){return QC(e)&&e.tagName.toLowerCase()===`form`}function tw(e){return QC(e)&&e.tagName.toLowerCase()===`input`}function nw(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function rw(e,t){return e.button===0&&(!t||t===`_self`)&&!nw(e)}function iw(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function aw(e,t){let n=iw(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var ow=null;function sw(){if(ow===null)try{new FormData(document.createElement(`form`),0),ow=!1}catch{ow=!0}return ow}var cw=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function lw(e){return e!=null&&!cw.has(e)?(aS(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ZC}"`),null):e}function uw(e,t){let n,r,i,a,o;if(ew(e)){let o=e.getAttribute(`action`);r=o?MS(o,t):null,n=e.getAttribute(`method`)||XC,i=lw(e.getAttribute(`enctype`))||ZC,a=new FormData(e)}else if($C(e)||tw(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?MS(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||XC,i=lw(e.getAttribute(`formenctype`))||lw(o.getAttribute(`enctype`))||ZC,a=new FormData(o,e),!sw()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(QC(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=XC,r=null,i=ZC,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var dw={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},fw=/[&><\u2028\u2029]/g;function pw(e){return e.replace(fw,e=>dw[e])}function mw(e,t){if(e===!1||e==null)throw Error(t)}function hw(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&MS(i.pathname,t)===`/`?i.pathname=`${t.replace(/\/$/,``)}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,``)}.${r}`,i}async function gw(e,t){if(e.id in t)return t[e.id];try{let n=await eS(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function _w(e){return e!=null&&typeof e.page==`string`}function vw(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function yw(e,t,n){return ww((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await gw(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(vw).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function bw(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function xw(e,t,{includeHydrateFallback:n}={}){return Sw(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function Sw(e){return[...new Set(e)]}function Cw(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function ww(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!_w(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(Cw(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function Tw(){let e=v.useContext(YS);return mw(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function Ew(){let e=v.useContext(XS);return mw(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var Dw=v.createContext(void 0);Dw.displayName=`FrameworkContext`;function Ow(){let e=v.useContext(Dw);return mw(e,`You must render this element inside a <HydratedRouter> element`),e}function kw(e,t){let n=v.useContext(Dw),[r,i]=v.useState(!1),[a,o]=v.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=v.useRef(null);v.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),v.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:Aw(s,p),onBlur:Aw(c,m),onMouseEnter:Aw(l,p),onMouseLeave:Aw(u,m),onTouchStart:Aw(d,p)}]:[a,f,{}]:[!1,f,{}]}function Aw(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function jw({page:e,...t}){let{router:n}=Tw(),r=v.useMemo(()=>pS(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?v.createElement(Nw,{page:e,matches:r,...t}):null}function Mw(e){let{manifest:t,routeModules:n}=Ow(),[r,i]=v.useState([]);return v.useEffect(()=>{let r=!1;return yw(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function Nw({page:e,matches:t,...n}){let r=fC(),{future:i,manifest:a,routeModules:o}=Ow(),{basename:s}=Tw(),{loaderData:c,matches:l}=Ew(),u=v.useMemo(()=>bw(e,t,l,a,r,`data`),[e,t,l,a,r]),d=v.useMemo(()=>bw(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=v.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=hw(e,s,i.unstable_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.unstable_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=v.useMemo(()=>xw(d,a),[d,a]),m=Mw(d);return v.createElement(v.Fragment,null,f.map(e=>v.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>v.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>v.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function Pw(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}var Fw=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{Fw&&(window.__reactRouterVersion=`7.13.1`)}catch{}function Iw({basename:e,children:t,unstable_useTransitions:n,window:r}){let i=v.useRef();i.current??=rS({window:r,v5Compat:!0});let a=i.current,[o,s]=v.useState({action:a.action,location:a.location}),c=v.useCallback(e=>{n===!1?s(e):v.startTransition(()=>s(e))},[n]);return v.useLayoutEffect(()=>a.listen(c),[a,c]),v.createElement(qC,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}function Lw({basename:e,children:t,history:n,unstable_useTransitions:r}){let[i,a]=v.useState({action:n.action,location:n.location}),o=v.useCallback(e=>{r===!1?a(e):v.startTransition(()=>a(e))},[r]);return v.useLayoutEffect(()=>n.listen(o),[n,o]),v.createElement(qC,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,unstable_useTransitions:r})}Lw.displayName=`unstable_HistoryRouter`;var Rw=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,zw=v.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,unstable_mask:o,state:s,target:c,to:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m){let{basename:h,navigator:g,unstable_useTransitions:_}=v.useContext(tC),y=typeof l==`string`&&Rw.test(l),b=JS(l,h);l=b.to;let x=uC(l,{relative:r}),S=fC(),C=null;if(o){let e=zS(o,[],S.unstable_mask?S.unstable_mask.pathname:`/`,!0);h!==`/`&&(e.pathname=e.pathname===`/`?h:BS([h,e.pathname])),C=g.createHref(e)}let[w,T,E]=kw(n,p),D=Kw(l,{replace:a,unstable_mask:o,state:s,target:c,preventScrollReset:u,relative:r,viewTransition:d,unstable_defaultShouldRevalidate:f,unstable_useTransitions:_});function O(t){e&&e(t),t.defaultPrevented||D(t)}let k=!(b.isExternal||i),A=v.createElement(`a`,{...p,...E,href:(k?C:void 0)||b.absoluteURL||x,onClick:k?O:e,ref:Pw(m,T),target:c,"data-discover":!y&&t===`render`?`true`:void 0});return w&&!y?v.createElement(v.Fragment,null,A,v.createElement(jw,{page:x})):A});zw.displayName=`Link`;var Bw=v.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=xC(a,{relative:c.relative}),d=fC(),f=v.useContext(XS),{navigator:p,basename:m}=v.useContext(tC),h=f!=null&&rT(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,_=d.pathname,y=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(_=_.toLowerCase(),y=y?y.toLowerCase():null,g=g.toLowerCase()),y&&m&&(y=MS(y,m)||y);let b=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,x=_===g||!r&&_.startsWith(g)&&_.charAt(b)===`/`,S=y!=null&&(y===g||!r&&y.startsWith(g)&&y.charAt(g.length)===`/`),C={isActive:x,isPending:S,isTransitioning:h},w=x?e:void 0,T;T=typeof n==`function`?n(C):[n,x?`active`:null,S?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let E=typeof i==`function`?i(C):i;return v.createElement(zw,{...c,"aria-current":w,className:T,ref:l,style:E,to:a,viewTransition:o},typeof s==`function`?s(C):s)});Bw.displayName=`NavLink`;var Vw=v.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=XC,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m)=>{let{unstable_useTransitions:h}=v.useContext(tC),g=Xw(),_=Zw(s,{relative:l}),y=o.toLowerCase()===`get`?`get`:`post`,b=typeof s==`string`&&Rw.test(s);return v.createElement(`form`,{ref:m,method:y,action:_,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f});h&&n!==!1?v.startTransition(()=>p()):p()},...p,"data-discover":!b&&e===`render`?`true`:void 0})});Vw.displayName=`Form`;function Hw({getKey:e,storageKey:t,...n}){let r=v.useContext(Dw),{basename:i}=v.useContext(tC),a=fC(),o=RC();tT({getKey:e,storageKey:t});let s=v.useMemo(()=>{if(!r||!e)return null;let t=eT(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let c=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return v.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${pw(JSON.stringify(t||Qw))}, ${pw(JSON.stringify(s))})`}})}Hw.displayName=`ScrollRestoration`;function Uw(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ww(e){let t=v.useContext(YS);return iS(t,Uw(e)),t}function Gw(e){let t=v.useContext(XS);return iS(t,Uw(e)),t}function Kw(e,{target:t,replace:n,unstable_mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,unstable_defaultShouldRevalidate:c,unstable_useTransitions:l}={}){let u=hC(),d=fC(),f=xC(e,{relative:o});return v.useCallback(p=>{if(rw(p,t)){p.preventDefault();let t=n===void 0?lS(d)===lS(f):n,m=()=>u(e,{replace:t,unstable_mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,unstable_defaultShouldRevalidate:c});l?v.startTransition(()=>m()):m()}},[d,u,f,n,r,i,t,e,a,o,s,c,l])}function qw(e){aS(typeof URLSearchParams<`u`,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=v.useRef(iw(e)),n=v.useRef(!1),r=fC(),i=v.useMemo(()=>aw(r.search,n.current?null:t.current),[r.search]),a=hC();return[i,v.useCallback((e,t)=>{let r=iw(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var Jw=0,Yw=()=>`__${String(++Jw)}__`;function Xw(){let{router:e}=Ww(`useSubmit`),{basename:t}=v.useContext(tC),n=IC(),r=e.fetch,i=e.navigate;return v.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=uw(e,t);a.navigate===!1?await r(a.fetcherKey||Yw(),n,a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function Zw(e,{relative:t}={}){let{basename:n}=v.useContext(tC),r=v.useContext(rC);iS(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...xC(e||`.`,{relative:t})},o=fC();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:BS([n,a.pathname])),lS(a)}var Qw=`react-router-scroll-positions`,$w={};function eT(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:MS(e.pathname,n)||e.pathname},t)),i??=e.key,i}function tT({getKey:e,storageKey:t}={}){let{router:n}=Ww(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=Gw(`useScrollRestoration`),{basename:a}=v.useContext(tC),o=fC(),s=RC(),c=LC();v.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),nT(v.useCallback(()=>{if(c.state===`idle`){let t=eT(o,s,a,e);$w[t]=window.scrollY}try{sessionStorage.setItem(t||Qw,JSON.stringify($w))}catch(e){aS(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(v.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||Qw);e&&($w=JSON.parse(e))}catch{}},[t]),v.useLayoutEffect(()=>{let t=n?.enableScrollRestoration($w,()=>window.scrollY,e?(t,n)=>eT(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),v.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{aS(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function nT(e,t){let{capture:n}=t||{};v.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function rT(e,{relative:t}={}){let n=v.useContext(QS);iS(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Ww(`useViewTransitionState`),i=xC(e,{relative:t});if(!n.isTransitioning)return!1;let a=MS(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=MS(n.nextLocation.pathname,r)||n.nextLocation.pathname;return kS(i.pathname,o)!=null||kS(i.pathname,a)!=null}Object.freeze({status:`aborted`});function K(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var iT=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},aT=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},oT={jitless:!0};function sT(e){return e&&Object.assign(oT,e),oT}function cT(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function lT(e,t){return typeof t==`bigint`?t.toString():t}function uT(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function dT(e){return e==null}function fT(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function pT(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var mT=Symbol(`evaluating`);function hT(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==mT)return r===void 0&&(r=mT,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function gT(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function _T(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function vT(e){return JSON.stringify(e)}function yT(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var bT=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function xT(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ST=uT(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function CT(e){if(xT(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(xT(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function wT(e){return CT(e)?{...e}:Array.isArray(e)?[...e]:e}var TT=new Set([`string`,`number`,`symbol`]);function ET(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function DT(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function OT(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function kT(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var AT={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function jT(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return DT(e,_T(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return gT(this,`shape`,e),e},checks:[]}))}function MT(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return DT(e,_T(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return gT(this,`shape`,r),r},checks:[]}))}function NT(e,t){if(!CT(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return DT(e,_T(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return gT(this,`shape`,n),n}}))}function PT(e,t){if(!CT(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return DT(e,_T(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return gT(this,`shape`,n),n}}))}function FT(e,t){return DT(e,_T(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return gT(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function IT(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return DT(t,_T(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return gT(this,`shape`,i),i},checks:[]}))}function LT(e,t,n){return DT(t,_T(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return gT(this,`shape`,i),i}}))}function RT(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function zT(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function BT(e){return typeof e==`string`?e:e?.message}function VT(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=BT(e.inst?._zod.def?.error?.(e))??BT(t?.error?.(e))??BT(n.customError?.(e))??BT(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function HT(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function UT(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var WT=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,lT,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},GT=K(`$ZodError`,WT),KT=K(`$ZodError`,WT,{Parent:Error});function qT(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function JT(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}var YT=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new iT;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>VT(e,a,sT())));throw bT(t,i?.callee),t}return o.value},XT=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>VT(e,a,sT())));throw bT(t,i?.callee),t}return o.value},ZT=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new iT;return a.issues.length?{success:!1,error:new(e??GT)(a.issues.map(e=>VT(e,i,sT())))}:{success:!0,data:a.value}},QT=ZT(KT),$T=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>VT(e,i,sT())))}:{success:!0,data:a.value}},eE=$T(KT),tE=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return YT(e)(t,n,i)},nE=e=>(t,n,r)=>YT(e)(t,n,r),rE=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return XT(e)(t,n,i)},iE=e=>async(t,n,r)=>XT(e)(t,n,r),aE=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return ZT(e)(t,n,i)},oE=e=>(t,n,r)=>ZT(e)(t,n,r),sE=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return $T(e)(t,n,i)},cE=e=>async(t,n,r)=>$T(e)(t,n,r),lE=/^[cC][^\s-]{8,}$/,uE=/^[0-9a-z]+$/,dE=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,fE=/^[0-9a-vA-V]{20}$/,pE=/^[A-Za-z0-9]{27}$/,mE=/^[a-zA-Z0-9_-]{21}$/,hE=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,gE=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,_E=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,vE=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,yE=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function bE(){return new RegExp(yE,`u`)}var xE=/^(?:(?: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])$/,SE=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,CE=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,wE=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,TE=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,EE=/^[A-Za-z0-9_-]*$/,DE=/^\+[1-9]\d{6,14}$/,OE=`(?:(?:\\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])))`,kE=RegExp(`^${OE}$`);function AE(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function jE(e){return RegExp(`^${AE(e)}$`)}function ME(e){let t=AE({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${OE}T(?:${r})$`)}var NE=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},PE=/^-?\d+$/,FE=/^-?\d+(?:\.\d+)?$/,IE=/^(?:true|false)$/i,LE=/^[^A-Z]*$/,RE=/^[^a-z]*$/,zE=K(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),BE={number:`number`,bigint:`bigint`,object:`date`},VE=K(`$ZodCheckLessThan`,(e,t)=>{zE.init(e,t);let n=BE[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),HE=K(`$ZodCheckGreaterThan`,(e,t)=>{zE.init(e,t);let n=BE[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),UE=K(`$ZodCheckMultipleOf`,(e,t)=>{zE.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):pT(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),WE=K(`$ZodCheckNumberFormat`,(e,t)=>{zE.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=AT[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=PE)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),GE=K(`$ZodCheckMaxLength`,(e,t)=>{var n;zE.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!dT(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=HT(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),KE=K(`$ZodCheckMinLength`,(e,t)=>{var n;zE.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!dT(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=HT(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),qE=K(`$ZodCheckLengthEquals`,(e,t)=>{var n;zE.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!dT(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=HT(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),JE=K(`$ZodCheckStringFormat`,(e,t)=>{var n,r;zE.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),YE=K(`$ZodCheckRegex`,(e,t)=>{JE.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),XE=K(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=LE,JE.init(e,t)}),ZE=K(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=RE,JE.init(e,t)}),QE=K(`$ZodCheckIncludes`,(e,t)=>{zE.init(e,t);let n=ET(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),$E=K(`$ZodCheckStartsWith`,(e,t)=>{zE.init(e,t);let n=RegExp(`^${ET(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),eD=K(`$ZodCheckEndsWith`,(e,t)=>{zE.init(e,t);let n=RegExp(`.*${ET(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),tD=K(`$ZodCheckOverwrite`,(e,t)=>{zE.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),nD=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
64
64
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
65
65
  `))}},rD={major:4,minor:3,patch:6},iD=K(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=rD;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=RT(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new iT;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=RT(e,t))});else{if(e.issues.length===t)continue;r||=RT(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(RT(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new iT;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new iT;return o.then(e=>t(e,r,a))}return t(o,r,a)}}hT(e,`~standard`,()=>({validate:t=>{try{let n=QT(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return eE(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),aD=K(`$ZodString`,(e,t)=>{iD.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??NE(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),oD=K(`$ZodStringFormat`,(e,t)=>{JE.init(e,t),aD.init(e,t)}),sD=K(`$ZodGUID`,(e,t)=>{t.pattern??=gE,oD.init(e,t)}),cD=K(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=_E(e)}else t.pattern??=_E();oD.init(e,t)}),lD=K(`$ZodEmail`,(e,t)=>{t.pattern??=vE,oD.init(e,t)}),uD=K(`$ZodURL`,(e,t)=>{oD.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),dD=K(`$ZodEmoji`,(e,t)=>{t.pattern??=bE(),oD.init(e,t)}),fD=K(`$ZodNanoID`,(e,t)=>{t.pattern??=mE,oD.init(e,t)}),pD=K(`$ZodCUID`,(e,t)=>{t.pattern??=lE,oD.init(e,t)}),mD=K(`$ZodCUID2`,(e,t)=>{t.pattern??=uE,oD.init(e,t)}),hD=K(`$ZodULID`,(e,t)=>{t.pattern??=dE,oD.init(e,t)}),gD=K(`$ZodXID`,(e,t)=>{t.pattern??=fE,oD.init(e,t)}),_D=K(`$ZodKSUID`,(e,t)=>{t.pattern??=pE,oD.init(e,t)}),vD=K(`$ZodISODateTime`,(e,t)=>{t.pattern??=ME(t),oD.init(e,t)}),yD=K(`$ZodISODate`,(e,t)=>{t.pattern??=kE,oD.init(e,t)}),bD=K(`$ZodISOTime`,(e,t)=>{t.pattern??=jE(t),oD.init(e,t)}),xD=K(`$ZodISODuration`,(e,t)=>{t.pattern??=hE,oD.init(e,t)}),SD=K(`$ZodIPv4`,(e,t)=>{t.pattern??=xE,oD.init(e,t),e._zod.bag.format=`ipv4`}),CD=K(`$ZodIPv6`,(e,t)=>{t.pattern??=SE,oD.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),wD=K(`$ZodCIDRv4`,(e,t)=>{t.pattern??=CE,oD.init(e,t)}),TD=K(`$ZodCIDRv6`,(e,t)=>{t.pattern??=wE,oD.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function ED(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var DD=K(`$ZodBase64`,(e,t)=>{t.pattern??=TE,oD.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{ED(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function OD(e){if(!EE.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return ED(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var kD=K(`$ZodBase64URL`,(e,t)=>{t.pattern??=EE,oD.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{OD(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),AD=K(`$ZodE164`,(e,t)=>{t.pattern??=DE,oD.init(e,t)});function jD(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var MD=K(`$ZodJWT`,(e,t)=>{oD.init(e,t),e._zod.check=n=>{jD(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),ND=K(`$ZodNumber`,(e,t)=>{iD.init(e,t),e._zod.pattern=e._zod.bag.pattern??FE,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),PD=K(`$ZodNumberFormat`,(e,t)=>{WE.init(e,t),ND.init(e,t)}),FD=K(`$ZodBoolean`,(e,t)=>{iD.init(e,t),e._zod.pattern=IE,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),ID=K(`$ZodUnknown`,(e,t)=>{iD.init(e,t),e._zod.parse=e=>e}),LD=K(`$ZodNever`,(e,t)=>{iD.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function RD(e,t,n){e.issues.length&&t.issues.push(...zT(n,e.issues)),t.value[n]=e.value}var zD=K(`$ZodArray`,(e,t)=>{iD.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>RD(t,n,e))):RD(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function BD(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...zT(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function VD(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=kT(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function HD(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optout===`optional`;for(let i in t){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>BD(e,n,i,t,u))):BD(a,n,i,t,u)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var UD=K(`$ZodObject`,(e,t)=>{if(iD.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=uT(()=>VD(t));hT(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=xT,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optout===`optional`,i=n._zod.run({value:s[e],issues:[]},o);i instanceof Promise?c.push(i.then(n=>BD(n,t,e,s,r))):BD(i,t,e,s,r)}return i?HD(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),WD=K(`$ZodObjectJIT`,(e,t)=>{UD.init(e,t);let n=e._zod.parse,r=uT(()=>VD(t)),i=e=>{let t=new nD([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=vT(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=vT(r),s=e[r]?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),s?t.write(`
66
66
  if (${n}.issues.length) {
@@ -99,7 +99,7 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
99
99
  `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=xT,s=!oT.jitless,c=s&&ST.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?HD([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function GD(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!RT(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>VT(e,r,sT())))}),t)}var KD=K(`$ZodUnion`,(e,t)=>{iD.init(e,t),hT(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),hT(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),hT(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),hT(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>fT(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>GD(t,i,e,a)):GD(s,i,e,a)}}),qD=K(`$ZodIntersection`,(e,t)=>{iD.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>YD(e,t,n)):YD(e,i,a)}});function JD(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(CT(e)&&CT(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=JD(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=JD(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function YD(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),RT(e))return e;let o=JD(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var XD=K(`$ZodRecord`,(e,t)=>{iD.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!CT(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){s.add(typeof e==`number`?e.toString():e);let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...zT(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...zT(e,o.issues)),n.value[e]=o.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&FE.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>VT(e,r,sT())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...zT(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...zT(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),ZD=K(`$ZodEnum`,(e,t)=>{iD.init(e,t);let n=cT(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>TT.has(typeof e)).map(e=>typeof e==`string`?ET(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),QD=K(`$ZodTransform`,(e,t)=>{iD.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new aT(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new iT;return n.value=i,n}});function $D(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var eO=K(`$ZodOptional`,(e,t)=>{iD.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,hT(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),hT(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${fT(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>$D(t,e.value)):$D(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),tO=K(`$ZodExactOptional`,(e,t)=>{eO.init(e,t),hT(e._zod,`values`,()=>t.innerType._zod.values),hT(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),nO=K(`$ZodNullable`,(e,t)=>{iD.init(e,t),hT(e._zod,`optin`,()=>t.innerType._zod.optin),hT(e._zod,`optout`,()=>t.innerType._zod.optout),hT(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${fT(e.source)}|null)$`):void 0}),hT(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),rO=K(`$ZodDefault`,(e,t)=>{iD.init(e,t),e._zod.optin=`optional`,hT(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>iO(e,t)):iO(r,t)}});function iO(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var aO=K(`$ZodPrefault`,(e,t)=>{iD.init(e,t),e._zod.optin=`optional`,hT(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),oO=K(`$ZodNonOptional`,(e,t)=>{iD.init(e,t),hT(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>sO(t,e)):sO(i,e)}});function sO(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var cO=K(`$ZodCatch`,(e,t)=>{iD.init(e,t),hT(e._zod,`optin`,()=>t.innerType._zod.optin),hT(e._zod,`optout`,()=>t.innerType._zod.optout),hT(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>VT(e,n,sT()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>VT(e,n,sT()))},input:e.value}),e.issues=[]),e)}}),lO=K(`$ZodPipe`,(e,t)=>{iD.init(e,t),hT(e._zod,`values`,()=>t.in._zod.values),hT(e._zod,`optin`,()=>t.in._zod.optin),hT(e._zod,`optout`,()=>t.out._zod.optout),hT(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>uO(e,t.in,n)):uO(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>uO(e,t.out,n)):uO(r,t.out,n)}});function uO(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var dO=K(`$ZodReadonly`,(e,t)=>{iD.init(e,t),hT(e._zod,`propValues`,()=>t.innerType._zod.propValues),hT(e._zod,`values`,()=>t.innerType._zod.values),hT(e._zod,`optin`,()=>t.innerType?._zod?.optin),hT(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(fO):fO(r)}});function fO(e){return e.value=Object.freeze(e.value),e}var pO=K(`$ZodCustom`,(e,t)=>{zE.init(e,t),iD.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>mO(t,n,r,e));mO(i,n,r,e)}});function mO(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(UT(e))}}var hO,gO=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function _O(){return new gO}(hO=globalThis).__zod_globalRegistry??(hO.__zod_globalRegistry=_O());var vO=globalThis.__zod_globalRegistry;function yO(e,t){return new e({type:`string`,...OT(t)})}function bO(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...OT(t)})}function xO(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...OT(t)})}function SO(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...OT(t)})}function CO(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...OT(t)})}function wO(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...OT(t)})}function TO(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...OT(t)})}function EO(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...OT(t)})}function DO(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...OT(t)})}function OO(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...OT(t)})}function kO(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...OT(t)})}function AO(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...OT(t)})}function jO(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...OT(t)})}function MO(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...OT(t)})}function NO(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...OT(t)})}function PO(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...OT(t)})}function FO(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...OT(t)})}function IO(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...OT(t)})}function LO(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...OT(t)})}function RO(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...OT(t)})}function zO(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...OT(t)})}function BO(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...OT(t)})}function VO(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...OT(t)})}function HO(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...OT(t)})}function UO(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...OT(t)})}function WO(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...OT(t)})}function GO(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...OT(t)})}function KO(e,t){return new e({type:`number`,checks:[],...OT(t)})}function qO(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...OT(t)})}function JO(e,t){return new e({type:`boolean`,...OT(t)})}function YO(e){return new e({type:`unknown`})}function XO(e,t){return new e({type:`never`,...OT(t)})}function ZO(e,t){return new VE({check:`less_than`,...OT(t),value:e,inclusive:!1})}function QO(e,t){return new VE({check:`less_than`,...OT(t),value:e,inclusive:!0})}function $O(e,t){return new HE({check:`greater_than`,...OT(t),value:e,inclusive:!1})}function ek(e,t){return new HE({check:`greater_than`,...OT(t),value:e,inclusive:!0})}function tk(e,t){return new UE({check:`multiple_of`,...OT(t),value:e})}function nk(e,t){return new GE({check:`max_length`,...OT(t),maximum:e})}function rk(e,t){return new KE({check:`min_length`,...OT(t),minimum:e})}function ik(e,t){return new qE({check:`length_equals`,...OT(t),length:e})}function ak(e,t){return new YE({check:`string_format`,format:`regex`,...OT(t),pattern:e})}function ok(e){return new XE({check:`string_format`,format:`lowercase`,...OT(e)})}function sk(e){return new ZE({check:`string_format`,format:`uppercase`,...OT(e)})}function ck(e,t){return new QE({check:`string_format`,format:`includes`,...OT(t),includes:e})}function lk(e,t){return new $E({check:`string_format`,format:`starts_with`,...OT(t),prefix:e})}function uk(e,t){return new eD({check:`string_format`,format:`ends_with`,...OT(t),suffix:e})}function dk(e){return new tD({check:`overwrite`,tx:e})}function fk(e){return dk(t=>t.normalize(e))}function pk(){return dk(e=>e.trim())}function mk(){return dk(e=>e.toLowerCase())}function hk(){return dk(e=>e.toUpperCase())}function gk(){return dk(e=>yT(e))}function _k(e,t,n){return new e({type:`array`,element:t,...OT(n)})}function vk(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...OT(n)})}function yk(e){let t=bk(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(UT(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(UT(r))}},e(n.value,n)));return t}function bk(e,t){let n=new zE({check:`custom`,...OT(t)});return n._zod.check=e,n}function xk(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??vO,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function Sk(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Sk(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Tk(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Ck(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
100
100
 
101
101
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function wk(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:Dk(t,`input`,e.processors),output:Dk(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Tk(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Tk(r.element,n);if(r.type===`set`)return Tk(r.valueType,n);if(r.type===`lazy`)return Tk(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return Tk(r.innerType,n);if(r.type===`intersection`)return Tk(r.left,n)||Tk(r.right,n);if(r.type===`record`||r.type===`map`)return Tk(r.keyType,n)||Tk(r.valueType,n);if(r.type===`pipe`)return Tk(r.in,n)||Tk(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Tk(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Tk(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Tk(e,n))return!0;return!!(r.rest&&Tk(r.rest,n))}return!1}var Ek=(e,t={})=>n=>{let r=xk({...n,processors:t});return Sk(e,r),Ck(r,e),wk(r,e)},Dk=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=xk({...i??{},target:a,io:t,processors:n});return Sk(e,o),Ck(o,e),wk(o,e)},Ok={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},kk=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Ok[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Ak=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},jk=(e,t,n,r)=>{n.type=`boolean`},Mk=(e,t,n,r)=>{n.not={}},Nk=(e,t,n,r)=>{let i=e._zod.def,a=cT(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Pk=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Fk=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Ik=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Sk(a.element,t,{...r,path:[...r.path,`items`]})},Lk=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Sk(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Sk(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Rk=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Sk(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},zk=(e,t,n,r)=>{let i=e._zod.def,a=Sk(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Sk(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Bk=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Sk(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Sk(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Sk(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Vk=(e,t,n,r)=>{let i=e._zod.def,a=Sk(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Hk=(e,t,n,r)=>{let i=e._zod.def;Sk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Uk=(e,t,n,r)=>{let i=e._zod.def;Sk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Wk=(e,t,n,r)=>{let i=e._zod.def;Sk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Gk=(e,t,n,r)=>{let i=e._zod.def;Sk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Kk=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;Sk(a,t,r);let o=t.seen.get(e);o.ref=a},qk=(e,t,n,r)=>{let i=e._zod.def;Sk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Jk=(e,t,n,r)=>{let i=e._zod.def;Sk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Yk=K(`ZodISODateTime`,(e,t)=>{vD.init(e,t),xA.init(e,t)});function Xk(e){return HO(Yk,e)}var Zk=K(`ZodISODate`,(e,t)=>{yD.init(e,t),xA.init(e,t)});function Qk(e){return UO(Zk,e)}var $k=K(`ZodISOTime`,(e,t)=>{bD.init(e,t),xA.init(e,t)});function eA(e){return WO($k,e)}var tA=K(`ZodISODuration`,(e,t)=>{xD.init(e,t),xA.init(e,t)});function nA(e){return GO(tA,e)}var rA=(e,t)=>{GT.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>JT(e,t)},flatten:{value:t=>qT(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,lT,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,lT,2)}},isEmpty:{get(){return e.issues.length===0}}})};K(`ZodError`,rA);var iA=K(`ZodError`,rA,{Parent:Error}),aA=YT(iA),oA=XT(iA),sA=ZT(iA),cA=$T(iA),lA=tE(iA),uA=nE(iA),dA=rE(iA),fA=iE(iA),pA=aE(iA),mA=oE(iA),hA=sE(iA),gA=cE(iA),_A=K(`ZodType`,(e,t)=>(iD.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Dk(e,`input`),output:Dk(e,`output`)}}),e.toJSONSchema=Ek(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(_T(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>DT(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>aA(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>sA(e,t,n),e.parseAsync=async(t,n)=>oA(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>cA(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>lA(e,t,n),e.decode=(t,n)=>uA(e,t,n),e.encodeAsync=async(t,n)=>dA(e,t,n),e.decodeAsync=async(t,n)=>fA(e,t,n),e.safeEncode=(t,n)=>pA(e,t,n),e.safeDecode=(t,n)=>mA(e,t,n),e.safeEncodeAsync=async(t,n)=>hA(e,t,n),e.safeDecodeAsync=async(t,n)=>gA(e,t,n),e.refine=(t,n)=>e.check(Aj(t,n)),e.superRefine=t=>e.check(jj(t)),e.overwrite=t=>e.check(dk(t)),e.optional=()=>fj(e),e.exactOptional=()=>mj(e),e.nullable=()=>gj(e),e.nullish=()=>fj(gj(e)),e.nonoptional=t=>Sj(e,t),e.array=()=>QA(e),e.or=t=>nj([e,t]),e.and=t=>ij(e,t),e.transform=t=>Ej(e,uj(t)),e.default=t=>vj(e,t),e.prefault=t=>bj(e,t),e.catch=t=>wj(e,t),e.pipe=t=>Ej(e,t),e.readonly=()=>Oj(e),e.describe=t=>{let n=e.clone();return vO.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return vO.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return vO.get(e);let n=e.clone();return vO.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),vA=K(`_ZodString`,(e,t)=>{aD.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kk(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(ak(...t)),e.includes=(...t)=>e.check(ck(...t)),e.startsWith=(...t)=>e.check(lk(...t)),e.endsWith=(...t)=>e.check(uk(...t)),e.min=(...t)=>e.check(rk(...t)),e.max=(...t)=>e.check(nk(...t)),e.length=(...t)=>e.check(ik(...t)),e.nonempty=(...t)=>e.check(rk(1,...t)),e.lowercase=t=>e.check(ok(t)),e.uppercase=t=>e.check(sk(t)),e.trim=()=>e.check(pk()),e.normalize=(...t)=>e.check(fk(...t)),e.toLowerCase=()=>e.check(mk()),e.toUpperCase=()=>e.check(hk()),e.slugify=()=>e.check(gk())}),yA=K(`ZodString`,(e,t)=>{aD.init(e,t),vA.init(e,t),e.email=t=>e.check(bO(SA,t)),e.url=t=>e.check(EO(TA,t)),e.jwt=t=>e.check(VO(BA,t)),e.emoji=t=>e.check(DO(EA,t)),e.guid=t=>e.check(xO(CA,t)),e.uuid=t=>e.check(SO(wA,t)),e.uuidv4=t=>e.check(CO(wA,t)),e.uuidv6=t=>e.check(wO(wA,t)),e.uuidv7=t=>e.check(TO(wA,t)),e.nanoid=t=>e.check(OO(DA,t)),e.guid=t=>e.check(xO(CA,t)),e.cuid=t=>e.check(kO(OA,t)),e.cuid2=t=>e.check(AO(kA,t)),e.ulid=t=>e.check(jO(AA,t)),e.base64=t=>e.check(RO(LA,t)),e.base64url=t=>e.check(zO(RA,t)),e.xid=t=>e.check(MO(jA,t)),e.ksuid=t=>e.check(NO(MA,t)),e.ipv4=t=>e.check(PO(NA,t)),e.ipv6=t=>e.check(FO(PA,t)),e.cidrv4=t=>e.check(IO(FA,t)),e.cidrv6=t=>e.check(LO(IA,t)),e.e164=t=>e.check(BO(zA,t)),e.datetime=t=>e.check(Xk(t)),e.date=t=>e.check(Qk(t)),e.time=t=>e.check(eA(t)),e.duration=t=>e.check(nA(t))});function bA(e){return yO(yA,e)}var xA=K(`ZodStringFormat`,(e,t)=>{oD.init(e,t),vA.init(e,t)}),SA=K(`ZodEmail`,(e,t)=>{lD.init(e,t),xA.init(e,t)}),CA=K(`ZodGUID`,(e,t)=>{sD.init(e,t),xA.init(e,t)}),wA=K(`ZodUUID`,(e,t)=>{cD.init(e,t),xA.init(e,t)}),TA=K(`ZodURL`,(e,t)=>{uD.init(e,t),xA.init(e,t)}),EA=K(`ZodEmoji`,(e,t)=>{dD.init(e,t),xA.init(e,t)}),DA=K(`ZodNanoID`,(e,t)=>{fD.init(e,t),xA.init(e,t)}),OA=K(`ZodCUID`,(e,t)=>{pD.init(e,t),xA.init(e,t)}),kA=K(`ZodCUID2`,(e,t)=>{mD.init(e,t),xA.init(e,t)}),AA=K(`ZodULID`,(e,t)=>{hD.init(e,t),xA.init(e,t)}),jA=K(`ZodXID`,(e,t)=>{gD.init(e,t),xA.init(e,t)}),MA=K(`ZodKSUID`,(e,t)=>{_D.init(e,t),xA.init(e,t)}),NA=K(`ZodIPv4`,(e,t)=>{SD.init(e,t),xA.init(e,t)}),PA=K(`ZodIPv6`,(e,t)=>{CD.init(e,t),xA.init(e,t)}),FA=K(`ZodCIDRv4`,(e,t)=>{wD.init(e,t),xA.init(e,t)}),IA=K(`ZodCIDRv6`,(e,t)=>{TD.init(e,t),xA.init(e,t)}),LA=K(`ZodBase64`,(e,t)=>{DD.init(e,t),xA.init(e,t)}),RA=K(`ZodBase64URL`,(e,t)=>{kD.init(e,t),xA.init(e,t)}),zA=K(`ZodE164`,(e,t)=>{AD.init(e,t),xA.init(e,t)}),BA=K(`ZodJWT`,(e,t)=>{MD.init(e,t),xA.init(e,t)}),VA=K(`ZodNumber`,(e,t)=>{ND.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ak(e,t,n,r),e.gt=(t,n)=>e.check($O(t,n)),e.gte=(t,n)=>e.check(ek(t,n)),e.min=(t,n)=>e.check(ek(t,n)),e.lt=(t,n)=>e.check(ZO(t,n)),e.lte=(t,n)=>e.check(QO(t,n)),e.max=(t,n)=>e.check(QO(t,n)),e.int=t=>e.check(WA(t)),e.safe=t=>e.check(WA(t)),e.positive=t=>e.check($O(0,t)),e.nonnegative=t=>e.check(ek(0,t)),e.negative=t=>e.check(ZO(0,t)),e.nonpositive=t=>e.check(QO(0,t)),e.multipleOf=(t,n)=>e.check(tk(t,n)),e.step=(t,n)=>e.check(tk(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function HA(e){return KO(VA,e)}var UA=K(`ZodNumberFormat`,(e,t)=>{PD.init(e,t),VA.init(e,t)});function WA(e){return qO(UA,e)}var GA=K(`ZodBoolean`,(e,t)=>{FD.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jk(e,t,n,r)});function KA(e){return JO(GA,e)}var qA=K(`ZodUnknown`,(e,t)=>{ID.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function JA(){return YO(qA)}var YA=K(`ZodNever`,(e,t)=>{LD.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mk(e,t,n,r)});function XA(e){return XO(YA,e)}var ZA=K(`ZodArray`,(e,t)=>{zD.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ik(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(rk(t,n)),e.nonempty=t=>e.check(rk(1,t)),e.max=(t,n)=>e.check(nk(t,n)),e.length=(t,n)=>e.check(ik(t,n)),e.unwrap=()=>e.element});function QA(e,t){return _k(ZA,e,t)}var $A=K(`ZodObject`,(e,t)=>{WD.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lk(e,t,n,r),hT(e,`shape`,()=>t.shape),e.keyof=()=>cj(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:JA()}),e.loose=()=>e.clone({...e._zod.def,catchall:JA()}),e.strict=()=>e.clone({...e._zod.def,catchall:XA()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>NT(e,t),e.safeExtend=t=>PT(e,t),e.merge=t=>FT(e,t),e.pick=t=>jT(e,t),e.omit=t=>MT(e,t),e.partial=(...t)=>IT(dj,e,t[0]),e.required=(...t)=>LT(xj,e,t[0])});function ej(e,t){return new $A({type:`object`,shape:e??{},...OT(t)})}var tj=K(`ZodUnion`,(e,t)=>{KD.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rk(e,t,n,r),e.options=t.options});function nj(e,t){return new tj({type:`union`,options:e,...OT(t)})}var rj=K(`ZodIntersection`,(e,t)=>{qD.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zk(e,t,n,r)});function ij(e,t){return new rj({type:`intersection`,left:e,right:t})}var aj=K(`ZodRecord`,(e,t)=>{XD.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bk(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function oj(e,t,n){return new aj({type:`record`,keyType:e,valueType:t,...OT(n)})}var sj=K(`ZodEnum`,(e,t)=>{ZD.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nk(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new sj({...t,checks:[],...OT(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new sj({...t,checks:[],...OT(r),entries:i})}});function cj(e,t){return new sj({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...OT(t)})}var lj=K(`ZodTransform`,(e,t)=>{QD.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fk(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new aT(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(UT(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(UT(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function uj(e){return new lj({type:`transform`,transform:e})}var dj=K(`ZodOptional`,(e,t)=>{eO.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jk(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fj(e){return new dj({type:`optional`,innerType:e})}var pj=K(`ZodExactOptional`,(e,t)=>{tO.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jk(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function mj(e){return new pj({type:`optional`,innerType:e})}var hj=K(`ZodNullable`,(e,t)=>{nO.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vk(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function gj(e){return new hj({type:`nullable`,innerType:e})}var _j=K(`ZodDefault`,(e,t)=>{rO.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uk(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function vj(e,t){return new _j({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():wT(t)}})}var yj=K(`ZodPrefault`,(e,t)=>{aO.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wk(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bj(e,t){return new yj({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():wT(t)}})}var xj=K(`ZodNonOptional`,(e,t)=>{oO.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hk(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Sj(e,t){return new xj({type:`nonoptional`,innerType:e,...OT(t)})}var Cj=K(`ZodCatch`,(e,t)=>{cO.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gk(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function wj(e,t){return new Cj({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Tj=K(`ZodPipe`,(e,t)=>{lO.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kk(e,t,n,r),e.in=t.in,e.out=t.out});function Ej(e,t){return new Tj({type:`pipe`,in:e,out:t})}var Dj=K(`ZodReadonly`,(e,t)=>{dO.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qk(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Oj(e){return new Dj({type:`readonly`,innerType:e})}var kj=K(`ZodCustom`,(e,t)=>{pO.init(e,t),_A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pk(e,t,n,r)});function Aj(e,t={}){return vk(kj,e,t)}function jj(e){return yk(e)}var Mj={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`},Nj;(function(e){})(Nj||={}),ej({username:bA().min(1,`Username is required`).regex(/^[a-zA-Z0-9_-]+$/,`Must contain only letters, numbers, hyphens, and underscores`).describe(`The name the agent identifies itself with when communicating with other agents`),title:bA().describe(`Displayed to other agents to give context about this agent's role in the system`),agentPrompt:bA().min(1,`Agent prompt is required`).describe("Gives the agent instructions and/or purpose when starting up. Supports ${agent.*} and ${env.*} template variables"),spendLimitDollars:HA().min(0,`Must be non-negative`).optional().describe(`Spend limit in dollars for this agent. When set, this agent is exempt from the global spend limit. Defaults to the SPEND_LIMIT_DOLLARS variable`),spendLimitHours:HA().min(0,`Must be non-negative`).optional().describe(`Rolling time window in hours for spend limit, defaults to the SPEND_LIMIT_HOURS variable. If neither are set then the spend limit is fixed and not rolling`),tokenMax:HA().int(`Must be a whole number`).min(1,`Must be at least 1`).describe(`How many tokens this agent is allocated per session before it must end or compact the context`),shellModel:bA().min(1,`Shell model is required`).describe(`Primary LLM used for shell interactions`),imageModel:bA().optional().describe(`Model used for image generation`),mailEnabled:KA().optional().describe(`Show mail commands to the agent. Mail encourages verbose communication which can be distracting`),chatEnabled:KA().optional().describe(`Show chat commands to the agent. Chat encourages more concise communication`),webEnabled:KA().optional().describe(`Allow agent to browse the web with Lynx, a text based browser`),completeSessionEnabled:KA().optional().describe(`Allow the agent to end its session. Once ended, it can only be restarted explicitly or via mail if wakeOnMessage is enabled. Disable on root agents to prevent the system from going unresponsive`),debugPauseSeconds:HA().int(`Must be a whole number`).min(0,`Must be non-negative`).optional().describe(`Seconds to wait at the debug prompt before auto-continuing, only applies when the agent's console is in focus. Unset waits indefinitely for manual input`),wakeOnMessage:KA().optional().describe(`When mail or chat is received, start the agent automatically, or wake it from its wait state`),commandProtection:cj([`none`,`manual`,`semi-auto`,`auto`]).optional().describe(`None allows the LLM to run any command, Manual requires user confirmation for each command, and Auto uses a secondary LLM to try to validate a command is safe`),initialCommands:QA(bA()).optional().describe(`Shell commands to run at session start before the first LLM prompt, providing additional context to the agent`),multipleCommandsEnabled:KA().optional().describe(`Allow the LLM to run multiple commands per turn. Faster but the LLM may get ahead of itself and produce errors`),workspacesEnabled:KA().optional().describe(`Experimental: Allows the LLM to pin files to the end of the context. Each turn the agent sees the latest version without old versions taking up context space`),controlDesktop:KA().optional().describe(`Allow the agent to operate the desktop GUI. Requires a model with supportsComputerUse. Ideal screen resolution <= 1.1MP to avoid downscaling`)});var Pj;(function(e){e.OpenAI=`openai`,e.Google=`google`,e.Anthropic=`anthropic`,e.Mock=`mock`,e.None=`none`})(Pj||={});var Fj=ej({key:bA().min(1),label:bA().min(1),versionName:bA().min(1),apiType:cj(Pj),maxTokens:HA().int().positive(),baseUrl:bA().optional(),apiKeyVar:bA(),inputCost:HA().default(0),outputCost:HA().default(0),cacheWriteCost:HA().optional(),cacheReadCost:HA().optional(),cacheTtlSeconds:HA().int().positive().optional(),supportsVision:KA().optional(),supportsHearing:KA().optional(),supportsComputerUse:KA().optional()}).superRefine((e,t)=>{e.baseUrl&&![Pj.OpenAI,Pj.Anthropic,Pj.Google].includes(e.apiType)&&t.addIssue({code:Mj.custom,message:`baseUrl is only supported for OpenAI, Anthropic, and Google API types (got "${e.apiType}")`,path:[`baseUrl`]})}),Ij=ej({key:bA().min(1),label:bA().min(1),versionName:bA().min(1),size:bA().min(1),baseUrl:bA().optional(),apiKeyVar:bA(),cost:HA(),quality:cj([`standard`,`hd`,`high`,`medium`,`low`]).optional()});ej({llmModels:QA(Fj).optional(),imageModels:QA(Ij).optional()}),ej({apiType:cj(Pj),maxTokens:HA().int().positive(),baseUrl:bA().optional(),apiKeyVar:bA(),inputCost:HA().default(0),outputCost:HA().default(0),cacheWriteCost:HA().optional(),cacheReadCost:HA().optional(),cacheTtlSeconds:HA().int().positive().optional(),supportsVision:KA().optional(),supportsHearing:KA().optional(),supportsComputerUse:KA().optional()}),ej({size:bA().min(1),baseUrl:bA().optional(),apiKeyVar:bA(),cost:HA(),quality:cj([`standard`,`hd`,`high`,`medium`,`low`]).optional()}),Pj.None,Pj.None,Pj.None,Pj.Mock,Pj.Mock,Pj.Mock,Pj.OpenAI,Pj.OpenAI,Pj.OpenAI,Pj.OpenAI,Pj.OpenAI,Pj.OpenAI,Pj.Google,Pj.Google,Pj.Google,Pj.Anthropic,Pj.Anthropic,Pj.Anthropic;function Lj(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Rj(e,t,n){let r=e?.find(e=>e.rel===t);if(r&&!(r.disabled&&!n?.includeDisabled))return r}function zj(e,t){return e?.find(e=>e.rel===t)}function Bj(e){if(e)return Array.isArray(e)?e.join(`
102
- `):e}var Vj=ej({rel:bA(),href:bA(),method:bA().optional(),title:bA().optional(),schema:bA().optional()}),Hj=ej({contentType:bA(),description:bA().optional(),fileFields:QA(bA())}),Uj=ej({rel:bA(),href:bA(),method:bA(),title:bA().optional(),schema:bA().optional(),body:oj(bA(),JA()).optional(),alternateEncoding:Hj.optional(),disabled:KA().optional(),disabledReason:nj([bA(),QA(bA())]).optional()}),Wj=ej({rel:bA(),hrefTemplate:bA(),method:bA(),title:bA().optional(),schema:bA().optional(),body:oj(bA(),JA()).optional(),alternateEncoding:Hj.optional()}),Gj=ej({rel:bA(),hrefTemplate:bA(),title:bA().optional()});ej({_links:QA(Vj),_actions:QA(Uj).optional()});var Kj=`/erp/assets/naisys-logo-CzoPnn5I.webp`,qj={outline:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},filled:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`currentColor`,stroke:`none`}},Jj=(e,t,n,r)=>{let i=(0,v.forwardRef)(({color:n=`currentColor`,size:i=24,stroke:a=2,title:o,className:s,children:c,...l},u)=>(0,v.createElement)(`svg`,{ref:u,...qj[e],width:i,height:i,className:[`tabler-icon`,`tabler-icon-${t}`,s].join(` `),...e===`filled`?{fill:n}:{strokeWidth:a,stroke:n},...l},[o&&(0,v.createElement)(`title`,{key:`svg-title`},o),...r.map(([e,t])=>(0,v.createElement)(e,t)),...Array.isArray(c)?c:[c]]));return i.displayName=`${n}`,i},Yj=Jj(`outline`,`alert-circle`,`AlertCircle`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0`,key:`svg-0`}],[`path`,{d:`M12 8v4`,key:`svg-1`}],[`path`,{d:`M12 16h.01`,key:`svg-2`}]]),Xj=Jj(`outline`,`alert-triangle`,`AlertTriangle`,[[`path`,{d:`M12 9v4`,key:`svg-0`}],[`path`,{d:`M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0`,key:`svg-1`}],[`path`,{d:`M12 16h.01`,key:`svg-2`}]]),Zj=Jj(`outline`,`api`,`Api`,[[`path`,{d:`M4 13h5`,key:`svg-0`}],[`path`,{d:`M12 16v-8h3a2 2 0 0 1 2 2v1a2 2 0 0 1 -2 2h-3`,key:`svg-1`}],[`path`,{d:`M20 8v8`,key:`svg-2`}],[`path`,{d:`M9 16v-5.5a2.5 2.5 0 0 0 -5 0v5.5`,key:`svg-3`}]]),Qj=Jj(`outline`,`arrow-back-up`,`ArrowBackUp`,[[`path`,{d:`M9 14l-4 -4l4 -4`,key:`svg-0`}],[`path`,{d:`M5 10h11a4 4 0 1 1 0 8h-1`,key:`svg-1`}]]),$j=Jj(`outline`,`check`,`Check`,[[`path`,{d:`M5 12l5 5l10 -10`,key:`svg-0`}]]),eM=Jj(`outline`,`chevron-down`,`ChevronDown`,[[`path`,{d:`M6 9l6 6l6 -6`,key:`svg-0`}]]),tM=Jj(`outline`,`eye`,`Eye`,[[`path`,{d:`M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0`,key:`svg-0`}],[`path`,{d:`M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6`,key:`svg-1`}]]),nM=Jj(`outline`,`file`,`File`,[[`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`,key:`svg-0`}],[`path`,{d:`M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2`,key:`svg-1`}]]),rM=Jj(`outline`,`info-circle`,`InfoCircle`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0`,key:`svg-0`}],[`path`,{d:`M12 9h.01`,key:`svg-1`}],[`path`,{d:`M11 12h1v4h1`,key:`svg-2`}]]),iM=Jj(`outline`,`layout-sidebar-left-collapse`,`LayoutSidebarLeftCollapse`,[[`path`,{d:`M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12`,key:`svg-0`}],[`path`,{d:`M9 4v16`,key:`svg-1`}],[`path`,{d:`M15 10l-2 2l2 2`,key:`svg-2`}]]),aM=Jj(`outline`,`layout-sidebar-left-expand`,`LayoutSidebarLeftExpand`,[[`path`,{d:`M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12`,key:`svg-0`}],[`path`,{d:`M9 4v16`,key:`svg-1`}],[`path`,{d:`M14 10l2 2l-2 2`,key:`svg-2`}]]),oM=Jj(`outline`,`list-details`,`ListDetails`,[[`path`,{d:`M13 5h8`,key:`svg-0`}],[`path`,{d:`M13 9h5`,key:`svg-1`}],[`path`,{d:`M13 15h8`,key:`svg-2`}],[`path`,{d:`M13 19h5`,key:`svg-3`}],[`path`,{d:`M3 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4`,key:`svg-4`}],[`path`,{d:`M3 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4`,key:`svg-5`}]]),sM=Jj(`outline`,`logout`,`Logout`,[[`path`,{d:`M14 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2`,key:`svg-0`}],[`path`,{d:`M9 12h12l-3 -3`,key:`svg-1`}],[`path`,{d:`M18 15l3 -3`,key:`svg-2`}]]),cM=Jj(`outline`,`note`,`Note`,[[`path`,{d:`M13 20l7 -7`,key:`svg-0`}],[`path`,{d:`M13 20v-6a1 1 0 0 1 1 -1h6v-7a2 2 0 0 0 -2 -2h-12a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7`,key:`svg-1`}]]),lM=Jj(`outline`,`plus`,`Plus`,[[`path`,{d:`M12 5l0 14`,key:`svg-0`}],[`path`,{d:`M5 12l14 0`,key:`svg-1`}]]),uM=Jj(`outline`,`trash`,`Trash`,[[`path`,{d:`M4 7l16 0`,key:`svg-0`}],[`path`,{d:`M10 11l0 6`,key:`svg-1`}],[`path`,{d:`M14 11l0 6`,key:`svg-2`}],[`path`,{d:`M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12`,key:`svg-3`}],[`path`,{d:`M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3`,key:`svg-4`}]]),dM=Jj(`outline`,`upload`,`Upload`,[[`path`,{d:`M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2`,key:`svg-0`}],[`path`,{d:`M7 9l5 -5l5 5`,key:`svg-1`}],[`path`,{d:`M12 4l0 12`,key:`svg-2`}]]),fM=Jj(`outline`,`user`,`User`,[[`path`,{d:`M8 7a4 4 0 1 0 8 0a4 4 0 0 0 -8 0`,key:`svg-0`}],[`path`,{d:`M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2`,key:`svg-1`}]]),pM=Jj(`outline`,`x`,`X`,[[`path`,{d:`M18 6l-12 12`,key:`svg-0`}],[`path`,{d:`M6 6l12 12`,key:`svg-1`}]]),mM=`/api/erp`,hM=class extends Error{statusCode;error;constructor(e,t,n){super(n),this.name=`ApiError`,this.statusCode=e,this.error=t}};function gM(e){let t=e instanceof Error?e.message:`An unexpected error occurred`;_x.show({title:`Error`,message:t,color:`red`,autoClose:5e3})}async function _M(e,t){let n=e.startsWith(`/`)?e:`${mM}/${e}`,r={...t?.headers};t?.body&&(r[`Content-Type`]=`application/json`);let i=await fetch(n,{...t,credentials:`include`,headers:r});if(i.status===204)return;i.status===401&&window.dispatchEvent(new CustomEvent(`erp:unauthorized`));let a=await i.json();if(!i.ok)throw new hM(a.statusCode??i.status,a.error??`Error`,a.message||`Request failed: ${i.status}`);return a}var q={get:e=>_M(e),post:(e,t)=>_M(e,{method:`POST`,body:JSON.stringify(t),headers:{Prefer:`return=representation`}}),put:(e,t)=>_M(e,{method:`PUT`,body:JSON.stringify(t),headers:{Prefer:`return=representation`}}),delete:e=>_M(e,{method:`DELETE`,headers:{Prefer:`return=representation`}}),upload:(e,t,n)=>{let r=new FormData;if(r.append(`file`,t),n)for(let[e,t]of Object.entries(n))r.append(e,t);let i=e.startsWith(`/`)?e:`${mM}/${e}`;return fetch(i,{method:`POST`,credentials:`include`,body:r}).then(async e=>{e.status===401&&window.dispatchEvent(new CustomEvent(`erp:unauthorized`));let t=await e.json();if(!e.ok)throw new hM(t.statusCode??e.status,t.error??`Error`,t.message||`Upload failed: ${e.status}`);return t})}},J={dispatch:`dispatch`,inventory:`inventory`,items:`items`,item:e=>`items/${e}`,itemFields:e=>`items/${e}/fields`,itemField:(e,t)=>`items/${e}/fields/${t}`,itemInstances:e=>`items/${e}/instances`,itemInstance:(e,t)=>`items/${e}/instances/${t}`,itemInstanceFieldValue:(e,t,n)=>`items/${e}/instances/${t}/fields/${n}`,itemInstanceDeleteSet:(e,t,n)=>`items/${e}/instances/${t}/sets/${n}`,orders:`orders`,order:e=>`orders/${e}`,orderRevs:e=>`orders/${e}/revs`,orderRev:(e,t)=>`orders/${e}/revs/${t}`,orderRevDiff:(e,t,n)=>`orders/${e}/revs/diff?from=${t}&to=${n}`,orderRevApprove:(e,t)=>`orders/${e}/revs/${t}/approve`,orderRevObsolete:(e,t)=>`orders/${e}/revs/${t}/obsolete`,orderRevOps:(e,t)=>`orders/${e}/revs/${t}/ops`,orderRevOp:(e,t,n)=>`orders/${e}/revs/${t}/ops/${n}`,orderRevOpSteps:(e,t,n)=>`orders/${e}/revs/${t}/ops/${n}/steps`,orderRevOpStep:(e,t,n,r)=>`orders/${e}/revs/${t}/ops/${n}/steps/${r}`,orderRevOpStepFields:(e,t,n,r)=>`orders/${e}/revs/${t}/ops/${n}/steps/${r}/fields`,orderRevOpStepField:(e,t,n,r,i)=>`orders/${e}/revs/${t}/ops/${n}/steps/${r}/fields/${i}`,orderRevOpFieldRefs:(e,t,n)=>`orders/${e}/revs/${t}/ops/${n}/field-refs`,orderRevOpFieldRef:(e,t,n,r)=>`orders/${e}/revs/${t}/ops/${n}/field-refs/${r}`,orderRevOpFieldRefAvailable:(e,t,n)=>`orders/${e}/revs/${t}/ops/${n}/field-refs/available`,orderRevOpDeps:(e,t,n)=>`orders/${e}/revs/${t}/ops/${n}/deps`,orderRevOpDep:(e,t,n,r)=>`orders/${e}/revs/${t}/ops/${n}/deps/${r}`,orderRuns:e=>`orders/${e}/runs`,orderRun:(e,t)=>`orders/${e}/runs/${t}`,orderRunStart:(e,t)=>`orders/${e}/runs/${t}/start`,orderRunClose:(e,t)=>`orders/${e}/runs/${t}/close`,orderRunCancel:(e,t)=>`orders/${e}/runs/${t}/cancel`,orderRunComplete:(e,t)=>`orders/${e}/runs/${t}/complete`,orderRunReopen:(e,t)=>`orders/${e}/runs/${t}/reopen`,users:`users`,user:e=>`users/${e}`,userPermissions:e=>`users/${e}/permissions`,userPermission:(e,t)=>`users/${e}/permissions/${t}`,operationRuns:(e,t)=>`orders/${e}/runs/${t}/ops`,operationRun:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}`,operationRunStart:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/start`,operationRunComplete:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/complete`,operationRunSkip:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/skip`,operationRunFail:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/fail`,operationRunReopen:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/reopen`,stepRuns:(e,t,n,r)=>`orders/${e}/runs/${t}/ops/${n}/steps${r?`?includeFields=true`:``}`,stepRun:(e,t,n,r)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}`,stepRunComplete:(e,t,n,r)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}/complete`,stepRunReopen:(e,t,n,r)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}/reopen`,stepRunFieldValue:(e,t,n,r,i)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}/fields/${i}`,stepRunSetFieldValue:(e,t,n,r,i,a)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}/sets/${i}/fields/${a}`,stepRunDeleteSet:(e,t,n,r,i)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}/sets/${i}`,stepFieldAttachments:(e,t,n,r,i)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}/fields/${i}/attachments`,stepFieldSetAttachments:(e,t,n,r,i,a)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}/sets/${i}/fields/${a}/attachments`,stepFieldAttachmentDownload:(e,t,n,r,i,a)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}/fields/${i}/attachments/${a}`,laborTickets:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/labor`,laborTicketClockIn:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/labor/clock-in`,laborTicketClockOut:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/labor/clock-out`,laborTicket:(e,t,n,r)=>`orders/${e}/runs/${t}/ops/${n}/labor/${r}`,operationRunComments:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/comments`,workCenters:`work-centers`,workCenter:e=>`work-centers/${e}`,workCenterUsers:e=>`work-centers/${e}/users`,workCenterUser:(e,t)=>`work-centers/${e}/users/${t}`,usersFromAgent:`users/from-agent`,userRotateKey:e=>`users/${e}/rotate-key`,changePassword:`users/me/password`,audit:(e,t)=>`audit?entityType=${e}&entityId=${t}`,admin:`admin`,adminAttachments:`admin/attachments`,adminAttachmentDownload:e=>`/api/erp/admin/attachments/${e}`,adminLogs:(e,t)=>{let n=new URLSearchParams;e!=null&&n.set(`lines`,String(e)),t!=null&&n.set(`minLevel`,String(t));let r=n.toString();return`admin/logs${r?`?${r}`:``}`}},vM={login:(e,t)=>q.post(`/api/erp/auth/login`,{username:e,password:t}),logout:()=>q.post(`/api/erp/auth/logout`,{}),me:()=>q.get(`/api/erp/auth/me`)},yM=(0,v.createContext)(null),bM=({children:e})=>{let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(!0);(0,v.useEffect)(()=>{vM.me().then(n).catch(()=>n(null)).finally(()=>i(!1))},[]),(0,v.useEffect)(()=>{let e=()=>n(null);return window.addEventListener(`erp:unauthorized`,e),()=>window.removeEventListener(`erp:unauthorized`,e)},[]);let a=(0,v.useCallback)(async(e,t)=>{n((await vM.login(e,t)).user)},[]),o=(0,v.useCallback)(async()=>{await vM.logout(),n(null)},[]);return(0,I.jsx)(yM.Provider,{value:{user:t,loading:r,login:a,logout:o},children:e})};function xM(){let e=(0,v.useContext)(yM);if(!e)throw Error(`useAuth must be used within AuthProvider`);return e}function SM(e){if(!/^[0-9a-zA-Z-]+$/.test(e))throw Error(`[@mantine/use-form] Form name "${e}" is invalid, it should contain only letters, numbers and dashes`)}var CM=typeof window<`u`?v.useLayoutEffect:v.useEffect;function wM(e,t){CM(()=>{if(e)return window.addEventListener(e,t),()=>window.removeEventListener(e,t)},[e])}function TM(e,t){e&&SM(e),wM(`mantine-form:${e}:set-field-value`,e=>t.setFieldValue(e.detail.path,e.detail.value)),wM(`mantine-form:${e}:set-values`,e=>t.setValues(e.detail)),wM(`mantine-form:${e}:set-initial-values`,e=>t.setInitialValues(e.detail)),wM(`mantine-form:${e}:set-errors`,e=>t.setErrors(e.detail)),wM(`mantine-form:${e}:set-field-error`,e=>t.setFieldError(e.detail.path,e.detail.error)),wM(`mantine-form:${e}:clear-field-error`,e=>t.clearFieldError(e.detail)),wM(`mantine-form:${e}:clear-errors`,t.clearErrors),wM(`mantine-form:${e}:reset`,t.reset),wM(`mantine-form:${e}:validate`,t.validate),wM(`mantine-form:${e}:validate-field`,e=>t.validateField(e.detail)),wM(`mantine-form:${e}:reorder-list-item`,e=>t.reorderListItem(e.detail.path,e.detail.payload)),wM(`mantine-form:${e}:remove-list-item`,e=>t.removeListItem(e.detail.path,e.detail.index)),wM(`mantine-form:${e}:insert-list-item`,e=>t.insertListItem(e.detail.path,e.detail.item,e.detail.index)),wM(`mantine-form:${e}:set-dirty`,e=>t.setDirty(e.detail)),wM(`mantine-form:${e}:set-touched`,e=>t.setTouched(e.detail)),wM(`mantine-form:${e}:reset-dirty`,e=>t.resetDirty(e.detail)),wM(`mantine-form:${e}:reset-touched`,t.resetTouched)}function EM(e){return t=>{if(!t)e(t);else if(typeof t==`function`)e(t);else if(typeof t==`object`&&`nativeEvent`in t){let{currentTarget:n}=t;n instanceof HTMLInputElement?n.type===`checkbox`?e(n.checked):e(n.value):(n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement)&&e(n.value)}else e(t)}}function DM(e){return typeof e!=`object`||!e?{}:Object.keys(e).reduce((t,n)=>{let r=e[n];return r!=null&&r!==!1&&(t[n]=r),t},{})}function OM(e){let[t,n]=(0,v.useState)(DM(e)),r=(0,v.useRef)(t),i=(0,v.useCallback)(e=>{n(t=>{let n=DM(typeof e==`function`?e(t):e);return r.current=n,n})},[]),a=(0,v.useCallback)(()=>i({}),[]),o=(0,v.useCallback)(e=>{r.current[e]!==void 0&&i(t=>{let n={...t};return delete n[e],n})},[t]);return{errorsState:t,setErrors:i,clearErrors:a,setFieldError:(0,v.useCallback)((e,t)=>{t==null||t===!1?o(e):r.current[e]!==t&&i(n=>({...n,[e]:t}))},[t]),clearFieldError:o}}function kM(e,t){if(typeof t!=`object`||!t)return{};let n={...t};return Object.keys(t).forEach(t=>{t.includes(`${String(e)}.`)&&delete n[t]}),n}function AM(e,t){let n=e.substring(t.length+1).split(`.`)[0];return parseInt(n,10)}function jM(e,t,n,r){if(t===void 0)return n;let i=`${String(e)}`,a=n;r===-1&&(a=kM(`${i}.${t}`,a));let o={...a},s=new Set;return Object.entries(a).filter(([e])=>{if(!e.startsWith(`${i}.`))return!1;let n=AM(e,i);return Number.isNaN(n)?!1:n>=t}).forEach(([e,t])=>{let n=AM(e,i),a=e.replace(`${i}.${n}`,`${i}.${n+r}`);o[a]=t,s.add(a),s.has(e)||delete o[e]}),o}function MM(e,{from:t,to:n},r){let i=`${e}.${t}`,a=`${e}.${n}`,o={...r},s=new Set;return Object.keys(r).forEach(e=>{if(s.has(e))return;let t,n;if(e.startsWith(i)?(t=e,n=e.replace(i,a)):e.startsWith(a)&&(t=e.replace(a,i),n=e),t&&n){let e=o[t],r=o[n];r===void 0?delete o[t]:o[t]=r,e===void 0?delete o[n]:o[n]=e,s.add(t),s.add(n)}}),o}function NM(e,t,n){typeof n.value==`object`&&(n.value=PM(n.value)),!n.enumerable||n.get||n.set||!n.configurable||!n.writable||t===`__proto__`?Object.defineProperty(e,t,n):e[t]=n.value}function PM(e){if(typeof e!=`object`)return e;var t=0,n,r,i,a=Object.prototype.toString.call(e);if(a===`[object Object]`?i=Object.create(e.__proto__||null):a===`[object Array]`?i=Array(e.length):a===`[object Set]`?(i=new Set,e.forEach(function(e){i.add(PM(e))})):a===`[object Map]`?(i=new Map,e.forEach(function(e,t){i.set(PM(t),PM(e))})):a===`[object Date]`?i=new Date(+e):a===`[object RegExp]`?i=new RegExp(e.source,e.flags):a===`[object DataView]`?i=new e.constructor(PM(e.buffer)):a===`[object ArrayBuffer]`?i=e.slice(0):a.slice(-6)===`Array]`&&(i=new e.constructor(e)),i){for(r=Object.getOwnPropertySymbols(e);t<r.length;t++)NM(i,r[t],Object.getOwnPropertyDescriptor(e,r[t]));for(t=0,r=Object.getOwnPropertyNames(e);t<r.length;t++)Object.hasOwnProperty.call(i,n=r[t])&&i[n]===e[n]||NM(i,n,Object.getOwnPropertyDescriptor(e,n))}return i||e}function FM(e){return typeof e==`string`?e.split(`.`):[]}function IM(e,t){let n=FM(e);if(n.length===0||typeof t!=`object`||!t)return;let r=t[n[0]];for(let e=1;e<n.length&&r!=null;e+=1)r=r[n[e]];return r}function LM(e,t,n){let r=FM(e);if(r.length===0)return n;let i=PM(n);if(r.length===1)return i[r[0]]=t,i;let a=i[r[0]];for(let e=1;e<r.length-1;e+=1){if(a===void 0)return i;a=a[r[e]]}return a[r[r.length-1]]=t,i}function RM(e,{from:t,to:n},r){let i=IM(e,r);if(!Array.isArray(i))return r;let a=[...i],o=i[t];return a.splice(t,1),a.splice(n,0,o),LM(e,a,r)}function zM(e,t,n,r){let i=IM(e,r);if(!Array.isArray(i))return r;let a=[...i];return a.splice(typeof n==`number`?n:a.length,0,t),LM(e,a,r)}function BM(e,t,n){let r=IM(e,n);return Array.isArray(r)?LM(e,r.filter((e,n)=>n!==t),n):n}function VM(e,t,n,r){let i=IM(e,r);if(!Array.isArray(i)||i.length<=n)return r;let a=[...i];return a[n]=t,LM(e,a,r)}function HM({$values:e,$errors:t,$status:n}){return{reorderListItem:(0,v.useCallback)((r,i)=>{n.clearFieldDirty(r),t.setErrors(e=>MM(r,i,e)),e.setValues({values:RM(r,i,e.refValues.current),updateState:!0})},[]),removeListItem:(0,v.useCallback)((r,i)=>{n.clearFieldDirty(r),t.setErrors(e=>jM(r,i,e,-1)),e.setValues({values:BM(r,i,e.refValues.current),updateState:!0})},[]),insertListItem:(0,v.useCallback)((r,i,a)=>{n.clearFieldDirty(r),t.setErrors(e=>jM(r,a,e,1)),e.setValues({values:zM(r,i,a,e.refValues.current),updateState:!0})},[]),replaceListItem:(0,v.useCallback)((t,r,i)=>{n.clearFieldDirty(t),e.setValues({values:VM(t,i,r,e.refValues.current),updateState:!0})},[])}}var UM=o(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}}));function WM(e,t){let n=Object.keys(e);if(typeof t==`string`){let r=n.filter(e=>e.startsWith(`${t}.`));return e[t]||r.some(t=>e[t])||!1}return n.some(t=>e[t])}var GM=l(UM(),1);function KM({initialDirty:e,initialTouched:t,mode:n,$values:r}){let[i,a]=(0,v.useState)(t),[o,s]=(0,v.useState)(e),c=(0,v.useRef)(t),l=(0,v.useRef)(e),u=(0,v.useCallback)(e=>{let t=typeof e==`function`?e(c.current):e;c.current=t,n===`controlled`&&a(t)},[]),d=(0,v.useCallback)((e,t=!1)=>{let r=typeof e==`function`?e(l.current):e;l.current=r,(n===`controlled`||t)&&s(r)},[]),f=(0,v.useCallback)(()=>u({}),[]),p=(0,v.useCallback)(e=>{let t=e?{...r.refValues.current,...e}:r.refValues.current;r.setValuesSnapshot(t),d({})},[]),m=(0,v.useCallback)((e,t)=>{u(n=>WM(n,e)===t?n:{...n,[e]:t})},[]),h=(0,v.useCallback)((e,t,n)=>{d(n=>WM(n,e)===t?n:{...n,[e]:t},n)},[]),g=(0,v.useCallback)((e,t)=>{let n=WM(l.current,e),i=!(0,GM.default)(IM(e,r.getValuesSnapshot()),t),a=kM(e,l.current);a[e]=i,d(a,n!==i)},[]);return{touchedState:i,dirtyState:o,touchedRef:c,dirtyRef:l,setTouched:u,setDirty:d,resetDirty:p,resetTouched:f,isTouched:(0,v.useCallback)(e=>WM(c.current,e),[]),setFieldTouched:m,setFieldDirty:h,setTouchedState:a,setDirtyState:s,clearFieldDirty:(0,v.useCallback)(e=>d(t=>{if(typeof e!=`string`)return t;let n=kM(e,t);return delete n[e],(0,GM.default)(n,t)?t:n}),[]),isDirty:(0,v.useCallback)(e=>{if(e){let t=IM(e,l.current);return typeof t==`boolean`?t:!(0,GM.default)(IM(e,r.refValues.current),IM(e,r.valuesSnapshot.current))}return Object.keys(l.current).length>0?WM(l.current):!(0,GM.default)(r.refValues.current,r.valuesSnapshot.current)},[]),getDirty:(0,v.useCallback)(()=>l.current,[]),getTouched:(0,v.useCallback)(()=>c.current,[]),setCalculatedFieldDirty:g}}function qM({initialValues:e,onValuesChange:t,mode:n}){let r=(0,v.useRef)(!1),[i,a]=(0,v.useState)(e||{}),o=(0,v.useRef)(i),s=(0,v.useRef)(i),c=(0,v.useCallback)(({values:e,subscribers:r,updateState:i=!0,mergeWithPreviousValues:s=!0})=>{let c=o.current,l=e instanceof Function?e(o.current):e,u=s?{...c,...l}:l;o.current=u,i&&(a(u),n===`uncontrolled`&&(o.current=u)),t?.(u,c),r?.filter(Boolean).forEach(e=>e({updatedValues:u,previousValues:c}))},[t]),l=(0,v.useCallback)(e=>{let t=IM(e.path,o.current),n=e.value instanceof Function?e.value(t):e.value;if(t!==n){let t=o.current,r=LM(e.path,n,o.current);c({values:r,updateState:e.updateState}),e.subscribers?.filter(Boolean).forEach(n=>n({path:e.path,updatedValues:r,previousValues:t}))}},[c]),u=(0,v.useCallback)(e=>{s.current=e},[]),d=(0,v.useCallback)((e,t)=>{r.current||(r.current=!0,c({values:e,updateState:n===`controlled`}),u(e),t())},[c]);return{initialized:r,stateValues:i,refValues:o,valuesSnapshot:s,setValues:c,setFieldValue:l,resetValues:(0,v.useCallback)(()=>{c({values:s.current,updateState:!0,mergeWithPreviousValues:!1})},[c]),setValuesSnapshot:u,initialize:d,getValues:(0,v.useCallback)(()=>o.current,[]),getValuesSnapshot:(0,v.useCallback)(()=>s.current,[]),resetField:(0,v.useCallback)((e,t)=>{let r=IM(e,s.current);r!==void 0&&l({path:e,value:r,updateState:n===`controlled`,subscribers:t})},[l,n])}}function JM({$status:e,cascadeUpdates:t}){let n=(0,v.useRef)({});return{subscribers:n,watch:(0,v.useCallback)((e,t)=>{(0,v.useEffect)(()=>(n.current[e]=n.current[e]||[],n.current[e].push(t),()=>{n.current[e]=n.current[e].filter(e=>e!==t)}),[t])},[]),getFieldSubscribers:(0,v.useCallback)(r=>{let i=n.current[r]?.map(t=>n=>t({previousValue:IM(r,n.previousValues),value:IM(r,n.updatedValues),touched:e.isTouched(r),dirty:e.isDirty(r)}))??[];if(t)for(let t in n.current)(t.startsWith(`${r}.`)||r.startsWith(`${t}.`))&&i.push(...n.current[t].map(n=>r=>n({previousValue:IM(t,r.previousValues),value:IM(t,r.updatedValues),touched:e.isTouched(t),dirty:e.isDirty(t)})));return i},[])}}function YM(e,t){return e?`${e}-${t.toString()}`:t.toString()}var XM=Symbol(`root-rule`);function ZM(e){let t=DM(e);return{hasErrors:Object.keys(t).length>0,errors:t}}function QM(e,t,n=``,r={}){return typeof e!=`object`||!e?r:Object.keys(e).reduce((r,i)=>{let a=e[i],o=`${n===``?``:`${n}.`}${i}`,s=IM(o,t),c=!1;return typeof a==`function`&&(r[o]=a(s,t,o)),typeof a==`object`&&Array.isArray(s)&&(c=!0,s.forEach((e,n)=>QM(a,t,`${o}.${n}`,r)),XM in a&&(r[o]=a[XM](s,t,o))),typeof a==`object`&&typeof s==`object`&&s&&(c||QM(a,t,o,r),XM in a&&(r[o]=a[XM](s,t,o))),r},r)}function $M(e,t){return ZM(typeof e==`function`?e(t):QM(e,t))}function eN(e,t,n){if(typeof e!=`string`)return{hasError:!1,error:null};let r=$M(t,n),i=Object.keys(r.errors).find(t=>e.split(`.`).every((e,n)=>e===t.split(`.`)[n]));return{hasError:!!i,error:i?r.errors[i]:null}}var tN=`__MANTINE_FORM_INDEX__`;function nN(e,t){return t?typeof t==`boolean`?t:Array.isArray(t)?t.includes(e.replace(/[.][0-9]+/g,`.${tN}`)):!1:!1}function rN({name:e,mode:t=`controlled`,initialValues:n,initialErrors:r={},initialDirty:i={},initialTouched:a={},clearInputErrorOnChange:o=!0,validateInputOnChange:s=!1,validateInputOnBlur:c=!1,onValuesChange:l,transformValues:u=(e=>e),enhanceGetInputProps:d,validate:f,onSubmitPreventDefault:p=`always`,touchTrigger:m=`change`,cascadeUpdates:h=!1}={}){let g=OM(r),_=qM({initialValues:n,onValuesChange:l,mode:t}),y=KM({initialDirty:i,initialTouched:a,$values:_,mode:t}),b=HM({$values:_,$errors:g,$status:y}),x=JM({$status:y,cascadeUpdates:h}),[S,C]=(0,v.useState)(0),[w,T]=(0,v.useState)({}),[E,D]=(0,v.useState)(!1),O=(0,v.useCallback)(()=>{_.resetValues(),g.clearErrors(),y.resetDirty(),y.resetTouched(),t===`uncontrolled`&&C(e=>e+1)},[]),k=(0,v.useCallback)(e=>{o&&g.clearErrors(),t===`uncontrolled`&&C(e=>e+1),Object.keys(x.subscribers.current).forEach(t=>{IM(t,_.refValues.current)!==IM(t,e)&&x.getFieldSubscribers(t).forEach(t=>t({previousValues:e,updatedValues:_.refValues.current}))})},[o]),A=(0,v.useCallback)(e=>{let n=_.refValues.current;_.initialize(e,()=>t===`uncontrolled`&&C(e=>e+1)),k(n)},[k]),j=(0,v.useCallback)((e,n,r)=>{let i=nN(e,s),a=n instanceof Function?n(IM(e,_.refValues.current)):n;y.setCalculatedFieldDirty(e,a),m===`change`&&y.setFieldTouched(e,!0),!i&&o&&g.clearFieldError(e),_.setFieldValue({path:e,value:n,updateState:t===`controlled`,subscribers:[...x.getFieldSubscribers(e),i?t=>{let n=eN(e,f,t.updatedValues);n.hasError?g.setFieldError(e,n.error):g.clearFieldError(e)}:null,r?.forceUpdate!==!1&&t!==`controlled`?()=>T(t=>({...t,[e]:(t[e]||0)+1})):null]})},[l,f]),ee=(0,v.useCallback)(e=>{let n=_.refValues.current;_.setValues({values:e,updateState:t===`controlled`}),k(n)},[l,k]),te=(0,v.useCallback)(()=>{let e=$M(f,_.refValues.current);return g.setErrors(e.errors),e},[f]),ne=(0,v.useCallback)(e=>{let t=eN(e,f,_.refValues.current);return t.hasError?g.setFieldError(e,t.error):g.clearFieldError(e),t},[f]),re=(n,{type:r=`input`,withError:i=!0,withFocus:a=!0,...o}={})=>{let s={onChange:EM(e=>j(n,e,{forceUpdate:!1})),"data-path":YM(e,n)};return i&&(s.error=g.errorsState[n]),r===`checkbox`?s[t===`controlled`?`checked`:`defaultChecked`]=IM(n,_.refValues.current):s[t===`controlled`?`value`:`defaultValue`]=IM(n,_.refValues.current),a&&(s.onFocus=()=>y.setFieldTouched(n,!0),s.onBlur=()=>{if(nN(n,c)){let e=eN(n,f,_.refValues.current);e.hasError?g.setFieldError(n,e.error):g.clearFieldError(n)}}),Object.assign(s,d?.({inputProps:s,field:n,options:{type:r,withError:i,withFocus:a,...o},form:le}))},M=(e,t)=>n=>{p===`always`&&n?.preventDefault();let r=te();if(r.hasErrors)p===`validation-failed`&&n?.preventDefault(),t?.(r.errors,_.refValues.current,n);else{let t=e?.(u(_.refValues.current),n);t instanceof Promise&&(D(!0),t.finally(()=>D(!1)))}},N=e=>u(e||_.refValues.current),ie=(0,v.useCallback)(e=>{e.preventDefault(),O()},[]),ae=(0,v.useCallback)(e=>e?!eN(e,f,_.refValues.current).hasError:!$M(f,_.refValues.current).hasErrors,[f]),oe=e=>`${S}-${String(e)}-${w[String(e)]||0}`,se=(0,v.useCallback)(t=>document.querySelector(`[data-path="${YM(e,t)}"]`),[]),ce=(0,v.useCallback)(e=>{_.resetField(e,[t===`controlled`?null:()=>T(t=>({...t,[e]:(t[e]||0)+1}))])},[_.resetField,t,T]),le={watch:x.watch,initialized:_.initialized.current,values:t===`uncontrolled`?_.refValues.current:_.stateValues,getValues:_.getValues,getInitialValues:_.getValuesSnapshot,setInitialValues:_.setValuesSnapshot,resetField:ce,initialize:A,setValues:ee,setFieldValue:j,submitting:E,setSubmitting:D,errors:g.errorsState,setErrors:g.setErrors,setFieldError:g.setFieldError,clearFieldError:g.clearFieldError,clearErrors:g.clearErrors,resetDirty:y.resetDirty,setTouched:y.setTouched,setDirty:y.setDirty,isTouched:y.isTouched,resetTouched:y.resetTouched,isDirty:y.isDirty,getTouched:y.getTouched,getDirty:y.getDirty,reorderListItem:b.reorderListItem,insertListItem:b.insertListItem,removeListItem:b.removeListItem,replaceListItem:b.replaceListItem,reset:O,validate:te,validateField:ne,getInputProps:re,onSubmit:M,onReset:ie,isValid:ae,getTransformedValues:N,key:oe,getInputNode:se};return TM(e,le),le}function iN({actions:e,rel:t,onClick:n,...r}){let i=Rj(e,t,{includeDisabled:!0});if(!i)return null;let a=(0,I.jsx)(H,{...r,disabled:i.disabled,onClick:i.disabled?void 0:n}),o=Bj(i.disabledReason);return o?(0,I.jsx)(M_,{label:o,multiline:!0,maw:350,style:{whiteSpace:`pre-line`},children:a}):a}var aN={outline:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},filled:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`currentColor`,stroke:`none`}},oN=(e,t,n,r)=>{let i=(0,v.forwardRef)(({color:n=`currentColor`,size:i=24,stroke:a=2,title:o,className:s,children:c,...l},u)=>(0,v.createElement)(`svg`,{ref:u,...aN[e],width:i,height:i,className:[`tabler-icon`,`tabler-icon-${t}`,s].join(` `),...e===`filled`?{fill:n}:{strokeWidth:a,stroke:n},...l},[o&&(0,v.createElement)(`title`,{key:`svg-title`},o),...r.map(([e,t])=>(0,v.createElement)(e,t)),...Array.isArray(c)?c:[c]]));return i.displayName=`${n}`,i},sN=oN(`outline`,`copy`,`Copy`,[[`path`,{d:`M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666`,key:`svg-0`}],[`path`,{d:`M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1`,key:`svg-1`}]]),cN=oN(`outline`,`download`,`Download`,[[`path`,{d:`M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2`,key:`svg-0`}],[`path`,{d:`M7 11l5 5l5 -5`,key:`svg-1`}],[`path`,{d:`M12 4l0 12`,key:`svg-2`}]]),lN=oN(`outline`,`eye-off`,`EyeOff`,[[`path`,{d:`M10.585 10.587a2 2 0 0 0 2.829 2.828`,key:`svg-0`}],[`path`,{d:`M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87`,key:`svg-1`}],[`path`,{d:`M3 3l18 18`,key:`svg-2`}]]),uN=oN(`outline`,`eye`,`Eye`,[[`path`,{d:`M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0`,key:`svg-0`}],[`path`,{d:`M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6`,key:`svg-1`}]]),dN=oN(`outline`,`refresh`,`Refresh`,[[`path`,{d:`M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4`,key:`svg-0`}],[`path`,{d:`M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4`,key:`svg-1`}]]),fN=50,pN=({fetchAttachments:e,getDownloadUrl:t,extraColumns:n})=>{let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(1),l=(0,v.useCallback)(async()=>{o(!0);try{i(await e(s,fN))}catch{i(null)}finally{o(!1)}},[s,e]);(0,v.useEffect)(()=>{l()},[l]);let u=(e,n)=>{let r=document.createElement(`a`);r.href=t(e),r.download=n,r.click()},d=r?Math.ceil(r.total/r.pageSize):0;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(zv,{order:3,mt:`xl`,children:`Attachments`}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{size:`xs`,variant:`light`,leftSection:(0,I.jsx)(dN,{size:14}),onClick:()=>l(),loading:a,children:`Refresh`}),r&&(0,I.jsxs)(V,{size:`sm`,c:`dimmed`,children:[r.total,` file`,r.total!==1&&`s`]})]}),a&&!r?(0,I.jsx)(U,{align:`center`,py:`md`,children:(0,I.jsx)(uu,{size:`sm`})}):r&&r.attachments.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Filename`}),(0,I.jsx)(W.Th,{children:`Size`}),n?.map(e=>(0,I.jsx)(W.Th,{children:e.header},e.header)),(0,I.jsx)(W.Th,{children:`Uploaded By`}),(0,I.jsx)(W.Th,{children:`Date`}),(0,I.jsx)(W.Th,{})]})}),(0,I.jsx)(W.Tbody,{children:r.attachments.map(e=>(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},onClick:()=>u(e.id,e.filename),children:[(0,I.jsx)(W.Td,{children:e.filename}),(0,I.jsx)(W.Td,{children:Lj(e.fileSize)}),n?.map(t=>(0,I.jsx)(W.Td,{children:t.render(e)},t.header)),(0,I.jsx)(W.Td,{children:e.uploadedBy}),(0,I.jsx)(W.Td,{children:new Date(e.createdAt).toLocaleString()}),(0,I.jsx)(W.Td,{children:(0,I.jsx)(cN,{size:16})})]},e.id))})]}),d>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:d,value:s,onChange:c})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`md`,children:`No attachments found`})]})};function mN(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var hN=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,gN=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_N={};function vN(e,t){return((t||_N).jsx?gN:hN).test(e)}var yN=/[ \t\n\f\r]/g;function bN(e){return typeof e==`object`?e.type===`text`?xN(e.value):!1:xN(e)}function xN(e){return e.replace(yN,``)===``}var SN=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};SN.prototype.normal={},SN.prototype.property={},SN.prototype.space=void 0;function CN(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new SN(n,r,t)}function wN(e){return e.toLowerCase()}var TN=class{constructor(e,t){this.attribute=t,this.property=e}};TN.prototype.attribute=``,TN.prototype.booleanish=!1,TN.prototype.boolean=!1,TN.prototype.commaOrSpaceSeparated=!1,TN.prototype.commaSeparated=!1,TN.prototype.defined=!1,TN.prototype.mustUseProperty=!1,TN.prototype.number=!1,TN.prototype.overloadedBoolean=!1,TN.prototype.property=``,TN.prototype.spaceSeparated=!1,TN.prototype.space=void 0;var EN=s({boolean:()=>ON,booleanish:()=>kN,commaOrSpaceSeparated:()=>PN,commaSeparated:()=>NN,number:()=>jN,overloadedBoolean:()=>AN,spaceSeparated:()=>MN}),DN=0,ON=FN(),kN=FN(),AN=FN(),jN=FN(),MN=FN(),NN=FN(),PN=FN();function FN(){return 2**++DN}var IN=Object.keys(EN),LN=class extends TN{constructor(e,t,n,r){let i=-1;if(super(e,t),RN(this,`space`,r),typeof n==`number`)for(;++i<IN.length;){let e=IN[i];RN(this,IN[i],(n&EN[e])===EN[e])}}};LN.prototype.defined=!0;function RN(e,t,n){n&&(e[t]=n)}function zN(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new LN(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[wN(r)]=r,n[wN(a.attribute)]=r}return new SN(t,n,e.space)}var BN=zN({properties:{ariaActiveDescendant:null,ariaAtomic:kN,ariaAutoComplete:null,ariaBusy:kN,ariaChecked:kN,ariaColCount:jN,ariaColIndex:jN,ariaColSpan:jN,ariaControls:MN,ariaCurrent:null,ariaDescribedBy:MN,ariaDetails:null,ariaDisabled:kN,ariaDropEffect:MN,ariaErrorMessage:null,ariaExpanded:kN,ariaFlowTo:MN,ariaGrabbed:kN,ariaHasPopup:null,ariaHidden:kN,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:MN,ariaLevel:jN,ariaLive:null,ariaModal:kN,ariaMultiLine:kN,ariaMultiSelectable:kN,ariaOrientation:null,ariaOwns:MN,ariaPlaceholder:null,ariaPosInSet:jN,ariaPressed:kN,ariaReadOnly:kN,ariaRelevant:null,ariaRequired:kN,ariaRoleDescription:MN,ariaRowCount:jN,ariaRowIndex:jN,ariaRowSpan:jN,ariaSelected:kN,ariaSetSize:jN,ariaSort:null,ariaValueMax:jN,ariaValueMin:jN,ariaValueNow:jN,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function VN(e,t){return t in e?e[t]:t}function HN(e,t){return VN(e,t.toLowerCase())}var UN=zN({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:NN,acceptCharset:MN,accessKey:MN,action:null,allow:null,allowFullScreen:ON,allowPaymentRequest:ON,allowUserMedia:ON,alt:null,as:null,async:ON,autoCapitalize:null,autoComplete:MN,autoFocus:ON,autoPlay:ON,blocking:MN,capture:null,charSet:null,checked:ON,cite:null,className:MN,cols:jN,colSpan:null,content:null,contentEditable:kN,controls:ON,controlsList:MN,coords:jN|NN,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ON,defer:ON,dir:null,dirName:null,disabled:ON,download:AN,draggable:kN,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ON,formTarget:null,headers:MN,height:jN,hidden:AN,high:jN,href:null,hrefLang:null,htmlFor:MN,httpEquiv:MN,id:null,imageSizes:null,imageSrcSet:null,inert:ON,inputMode:null,integrity:null,is:null,isMap:ON,itemId:null,itemProp:MN,itemRef:MN,itemScope:ON,itemType:MN,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ON,low:jN,manifest:null,max:null,maxLength:jN,media:null,method:null,min:null,minLength:jN,multiple:ON,muted:ON,name:null,nonce:null,noModule:ON,noValidate:ON,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ON,optimum:jN,pattern:null,ping:MN,placeholder:null,playsInline:ON,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ON,referrerPolicy:null,rel:MN,required:ON,reversed:ON,rows:jN,rowSpan:jN,sandbox:MN,scope:null,scoped:ON,seamless:ON,selected:ON,shadowRootClonable:ON,shadowRootDelegatesFocus:ON,shadowRootMode:null,shape:null,size:jN,sizes:null,slot:null,span:jN,spellCheck:kN,src:null,srcDoc:null,srcLang:null,srcSet:null,start:jN,step:null,style:null,tabIndex:jN,target:null,title:null,translate:null,type:null,typeMustMatch:ON,useMap:null,value:kN,width:jN,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:MN,axis:null,background:null,bgColor:null,border:jN,borderColor:null,bottomMargin:jN,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ON,declare:ON,event:null,face:null,frame:null,frameBorder:null,hSpace:jN,leftMargin:jN,link:null,longDesc:null,lowSrc:null,marginHeight:jN,marginWidth:jN,noResize:ON,noHref:ON,noShade:ON,noWrap:ON,object:null,profile:null,prompt:null,rev:null,rightMargin:jN,rules:null,scheme:null,scrolling:kN,standby:null,summary:null,text:null,topMargin:jN,valueType:null,version:null,vAlign:null,vLink:null,vSpace:jN,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ON,disableRemotePlayback:ON,prefix:null,property:null,results:jN,security:null,unselectable:null},space:`html`,transform:HN}),WN=zN({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:PN,accentHeight:jN,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:jN,amplitude:jN,arabicForm:null,ascent:jN,attributeName:null,attributeType:null,azimuth:jN,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:jN,by:null,calcMode:null,capHeight:jN,className:MN,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:jN,diffuseConstant:jN,direction:null,display:null,dur:null,divisor:jN,dominantBaseline:null,download:ON,dx:null,dy:null,edgeMode:null,editable:null,elevation:jN,enableBackground:null,end:null,event:null,exponent:jN,externalResourcesRequired:null,fill:null,fillOpacity:jN,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:NN,g2:NN,glyphName:NN,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:jN,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:jN,horizOriginX:jN,horizOriginY:jN,id:null,ideographic:jN,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:jN,k:jN,k1:jN,k2:jN,k3:jN,k4:jN,kernelMatrix:PN,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:jN,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:jN,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:jN,overlineThickness:jN,paintOrder:null,panose1:null,path:null,pathLength:jN,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:MN,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:jN,pointsAtY:jN,pointsAtZ:jN,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:PN,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:PN,rev:PN,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:PN,requiredFeatures:PN,requiredFonts:PN,requiredFormats:PN,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:jN,specularExponent:jN,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:jN,strikethroughThickness:jN,string:null,stroke:null,strokeDashArray:PN,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:jN,strokeOpacity:jN,strokeWidth:null,style:null,surfaceScale:jN,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:PN,tabIndex:jN,tableValues:null,target:null,targetX:jN,targetY:jN,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:PN,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:jN,underlineThickness:jN,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:jN,values:null,vAlphabetic:jN,vMathematical:jN,vectorEffect:null,vHanging:jN,vIdeographic:jN,version:null,vertAdvY:jN,vertOriginX:jN,vertOriginY:jN,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:jN,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:VN}),GN=zN({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),KN=zN({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:HN}),qN=zN({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),JN={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},YN=/[A-Z]/g,XN=/-[a-z]/g,ZN=/^data[-\w.:]+$/i;function QN(e,t){let n=wN(t),r=t,i=TN;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&ZN.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(XN,eP);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!XN.test(e)){let n=e.replace(YN,$N);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=LN}return new i(r,t)}function $N(e){return`-`+e.toLowerCase()}function eP(e){return e.charAt(1).toUpperCase()}var tP=CN([BN,UN,GN,KN,qN],`html`),nP=CN([BN,WN,GN,KN,qN],`svg`);function rP(e){return e.join(` `).trim()}var iP=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
102
+ `):e}var Vj=ej({rel:bA(),href:bA(),method:bA().optional(),title:bA().optional(),schema:bA().optional()}),Hj=ej({contentType:bA(),description:bA().optional(),fileFields:QA(bA())}),Uj=ej({rel:bA(),href:bA(),method:bA(),title:bA().optional(),schema:bA().optional(),body:oj(bA(),JA()).optional(),alternateEncoding:Hj.optional(),disabled:KA().optional(),disabledReason:nj([bA(),QA(bA())]).optional()}),Wj=ej({rel:bA(),hrefTemplate:bA(),method:bA(),title:bA().optional(),schema:bA().optional(),body:oj(bA(),JA()).optional(),alternateEncoding:Hj.optional()}),Gj=ej({rel:bA(),hrefTemplate:bA(),title:bA().optional()});ej({_links:QA(Vj),_actions:QA(Uj).optional()});var Kj=`/erp/assets/naisys-logo-CzoPnn5I.webp`,qj={outline:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},filled:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`currentColor`,stroke:`none`}},Jj=(e,t,n,r)=>{let i=(0,v.forwardRef)(({color:n=`currentColor`,size:i=24,stroke:a=2,title:o,className:s,children:c,...l},u)=>(0,v.createElement)(`svg`,{ref:u,...qj[e],width:i,height:i,className:[`tabler-icon`,`tabler-icon-${t}`,s].join(` `),...e===`filled`?{fill:n}:{strokeWidth:a,stroke:n},...l},[o&&(0,v.createElement)(`title`,{key:`svg-title`},o),...r.map(([e,t])=>(0,v.createElement)(e,t)),...Array.isArray(c)?c:[c]]));return i.displayName=`${n}`,i},Yj=Jj(`outline`,`alert-circle`,`AlertCircle`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0`,key:`svg-0`}],[`path`,{d:`M12 8v4`,key:`svg-1`}],[`path`,{d:`M12 16h.01`,key:`svg-2`}]]),Xj=Jj(`outline`,`alert-triangle`,`AlertTriangle`,[[`path`,{d:`M12 9v4`,key:`svg-0`}],[`path`,{d:`M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0`,key:`svg-1`}],[`path`,{d:`M12 16h.01`,key:`svg-2`}]]),Zj=Jj(`outline`,`api`,`Api`,[[`path`,{d:`M4 13h5`,key:`svg-0`}],[`path`,{d:`M12 16v-8h3a2 2 0 0 1 2 2v1a2 2 0 0 1 -2 2h-3`,key:`svg-1`}],[`path`,{d:`M20 8v8`,key:`svg-2`}],[`path`,{d:`M9 16v-5.5a2.5 2.5 0 0 0 -5 0v5.5`,key:`svg-3`}]]),Qj=Jj(`outline`,`arrow-back-up`,`ArrowBackUp`,[[`path`,{d:`M9 14l-4 -4l4 -4`,key:`svg-0`}],[`path`,{d:`M5 10h11a4 4 0 1 1 0 8h-1`,key:`svg-1`}]]),$j=Jj(`outline`,`check`,`Check`,[[`path`,{d:`M5 12l5 5l10 -10`,key:`svg-0`}]]),eM=Jj(`outline`,`chevron-down`,`ChevronDown`,[[`path`,{d:`M6 9l6 6l6 -6`,key:`svg-0`}]]),tM=Jj(`outline`,`eye`,`Eye`,[[`path`,{d:`M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0`,key:`svg-0`}],[`path`,{d:`M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6`,key:`svg-1`}]]),nM=Jj(`outline`,`file`,`File`,[[`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`,key:`svg-0`}],[`path`,{d:`M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2`,key:`svg-1`}]]),rM=Jj(`outline`,`info-circle`,`InfoCircle`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0`,key:`svg-0`}],[`path`,{d:`M12 9h.01`,key:`svg-1`}],[`path`,{d:`M11 12h1v4h1`,key:`svg-2`}]]),iM=Jj(`outline`,`layout-sidebar-left-collapse`,`LayoutSidebarLeftCollapse`,[[`path`,{d:`M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12`,key:`svg-0`}],[`path`,{d:`M9 4v16`,key:`svg-1`}],[`path`,{d:`M15 10l-2 2l2 2`,key:`svg-2`}]]),aM=Jj(`outline`,`layout-sidebar-left-expand`,`LayoutSidebarLeftExpand`,[[`path`,{d:`M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12`,key:`svg-0`}],[`path`,{d:`M9 4v16`,key:`svg-1`}],[`path`,{d:`M14 10l2 2l-2 2`,key:`svg-2`}]]),oM=Jj(`outline`,`list-details`,`ListDetails`,[[`path`,{d:`M13 5h8`,key:`svg-0`}],[`path`,{d:`M13 9h5`,key:`svg-1`}],[`path`,{d:`M13 15h8`,key:`svg-2`}],[`path`,{d:`M13 19h5`,key:`svg-3`}],[`path`,{d:`M3 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4`,key:`svg-4`}],[`path`,{d:`M3 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4`,key:`svg-5`}]]),sM=Jj(`outline`,`logout`,`Logout`,[[`path`,{d:`M14 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2`,key:`svg-0`}],[`path`,{d:`M9 12h12l-3 -3`,key:`svg-1`}],[`path`,{d:`M18 15l3 -3`,key:`svg-2`}]]),cM=Jj(`outline`,`note`,`Note`,[[`path`,{d:`M13 20l7 -7`,key:`svg-0`}],[`path`,{d:`M13 20v-6a1 1 0 0 1 1 -1h6v-7a2 2 0 0 0 -2 -2h-12a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7`,key:`svg-1`}]]),lM=Jj(`outline`,`plus`,`Plus`,[[`path`,{d:`M12 5l0 14`,key:`svg-0`}],[`path`,{d:`M5 12l14 0`,key:`svg-1`}]]),uM=Jj(`outline`,`trash`,`Trash`,[[`path`,{d:`M4 7l16 0`,key:`svg-0`}],[`path`,{d:`M10 11l0 6`,key:`svg-1`}],[`path`,{d:`M14 11l0 6`,key:`svg-2`}],[`path`,{d:`M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12`,key:`svg-3`}],[`path`,{d:`M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3`,key:`svg-4`}]]),dM=Jj(`outline`,`upload`,`Upload`,[[`path`,{d:`M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2`,key:`svg-0`}],[`path`,{d:`M7 9l5 -5l5 5`,key:`svg-1`}],[`path`,{d:`M12 4l0 12`,key:`svg-2`}]]),fM=Jj(`outline`,`user`,`User`,[[`path`,{d:`M8 7a4 4 0 1 0 8 0a4 4 0 0 0 -8 0`,key:`svg-0`}],[`path`,{d:`M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2`,key:`svg-1`}]]),pM=Jj(`outline`,`x`,`X`,[[`path`,{d:`M18 6l-12 12`,key:`svg-0`}],[`path`,{d:`M6 6l12 12`,key:`svg-1`}]]),mM=`/erp/api`,hM=class extends Error{statusCode;error;constructor(e,t,n){super(n),this.name=`ApiError`,this.statusCode=e,this.error=t}};function gM(e){let t=e instanceof Error?e.message:`An unexpected error occurred`;_x.show({title:`Error`,message:t,color:`red`,autoClose:5e3})}async function _M(e,t){let n=e.startsWith(`/`)?e:`${mM}/${e}`,r={...t?.headers};t?.body&&(r[`Content-Type`]=`application/json`);let i=await fetch(n,{...t,credentials:`include`,headers:r});if(i.status===204)return;i.status===401&&window.dispatchEvent(new CustomEvent(`erp:unauthorized`));let a=await i.json();if(!i.ok)throw new hM(a.statusCode??i.status,a.error??`Error`,a.message||`Request failed: ${i.status}`);return a}var q={get:e=>_M(e),post:(e,t)=>_M(e,{method:`POST`,body:JSON.stringify(t),headers:{Prefer:`return=representation`}}),put:(e,t)=>_M(e,{method:`PUT`,body:JSON.stringify(t),headers:{Prefer:`return=representation`}}),delete:e=>_M(e,{method:`DELETE`,headers:{Prefer:`return=representation`}}),upload:(e,t,n)=>{let r=new FormData;if(r.append(`file`,t),n)for(let[e,t]of Object.entries(n))r.append(e,t);let i=e.startsWith(`/`)?e:`${mM}/${e}`;return fetch(i,{method:`POST`,credentials:`include`,body:r}).then(async e=>{e.status===401&&window.dispatchEvent(new CustomEvent(`erp:unauthorized`));let t=await e.json();if(!e.ok)throw new hM(t.statusCode??e.status,t.error??`Error`,t.message||`Upload failed: ${e.status}`);return t})}},J={dispatch:`dispatch`,inventory:`inventory`,items:`items`,item:e=>`items/${e}`,itemFields:e=>`items/${e}/fields`,itemField:(e,t)=>`items/${e}/fields/${t}`,itemInstances:e=>`items/${e}/instances`,itemInstance:(e,t)=>`items/${e}/instances/${t}`,itemInstanceFieldValue:(e,t,n)=>`items/${e}/instances/${t}/fields/${n}`,itemInstanceDeleteSet:(e,t,n)=>`items/${e}/instances/${t}/sets/${n}`,orders:`orders`,order:e=>`orders/${e}`,orderRevs:e=>`orders/${e}/revs`,orderRev:(e,t)=>`orders/${e}/revs/${t}`,orderRevDiff:(e,t,n)=>`orders/${e}/revs/diff?from=${t}&to=${n}`,orderRevApprove:(e,t)=>`orders/${e}/revs/${t}/approve`,orderRevObsolete:(e,t)=>`orders/${e}/revs/${t}/obsolete`,orderRevOps:(e,t)=>`orders/${e}/revs/${t}/ops`,orderRevOp:(e,t,n)=>`orders/${e}/revs/${t}/ops/${n}`,orderRevOpSteps:(e,t,n)=>`orders/${e}/revs/${t}/ops/${n}/steps`,orderRevOpStep:(e,t,n,r)=>`orders/${e}/revs/${t}/ops/${n}/steps/${r}`,orderRevOpStepFields:(e,t,n,r)=>`orders/${e}/revs/${t}/ops/${n}/steps/${r}/fields`,orderRevOpStepField:(e,t,n,r,i)=>`orders/${e}/revs/${t}/ops/${n}/steps/${r}/fields/${i}`,orderRevOpFieldRefs:(e,t,n)=>`orders/${e}/revs/${t}/ops/${n}/field-refs`,orderRevOpFieldRef:(e,t,n,r)=>`orders/${e}/revs/${t}/ops/${n}/field-refs/${r}`,orderRevOpFieldRefAvailable:(e,t,n)=>`orders/${e}/revs/${t}/ops/${n}/field-refs/available`,orderRevOpDeps:(e,t,n)=>`orders/${e}/revs/${t}/ops/${n}/deps`,orderRevOpDep:(e,t,n,r)=>`orders/${e}/revs/${t}/ops/${n}/deps/${r}`,orderRuns:e=>`orders/${e}/runs`,orderRun:(e,t)=>`orders/${e}/runs/${t}`,orderRunStart:(e,t)=>`orders/${e}/runs/${t}/start`,orderRunClose:(e,t)=>`orders/${e}/runs/${t}/close`,orderRunCancel:(e,t)=>`orders/${e}/runs/${t}/cancel`,orderRunComplete:(e,t)=>`orders/${e}/runs/${t}/complete`,orderRunReopen:(e,t)=>`orders/${e}/runs/${t}/reopen`,users:`users`,user:e=>`users/${e}`,userPermissions:e=>`users/${e}/permissions`,userPermission:(e,t)=>`users/${e}/permissions/${t}`,operationRuns:(e,t)=>`orders/${e}/runs/${t}/ops`,operationRun:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}`,operationRunStart:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/start`,operationRunComplete:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/complete`,operationRunSkip:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/skip`,operationRunFail:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/fail`,operationRunReopen:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/reopen`,stepRuns:(e,t,n,r)=>`orders/${e}/runs/${t}/ops/${n}/steps${r?`?includeFields=true`:``}`,stepRun:(e,t,n,r)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}`,stepRunComplete:(e,t,n,r)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}/complete`,stepRunReopen:(e,t,n,r)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}/reopen`,stepRunFieldValue:(e,t,n,r,i)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}/fields/${i}`,stepRunSetFieldValue:(e,t,n,r,i,a)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}/sets/${i}/fields/${a}`,stepRunDeleteSet:(e,t,n,r,i)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}/sets/${i}`,stepFieldAttachments:(e,t,n,r,i)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}/fields/${i}/attachments`,stepFieldSetAttachments:(e,t,n,r,i,a)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}/sets/${i}/fields/${a}/attachments`,stepFieldAttachmentDownload:(e,t,n,r,i,a)=>`orders/${e}/runs/${t}/ops/${n}/steps/${r}/fields/${i}/attachments/${a}`,laborTickets:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/labor`,laborTicketClockIn:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/labor/clock-in`,laborTicketClockOut:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/labor/clock-out`,laborTicket:(e,t,n,r)=>`orders/${e}/runs/${t}/ops/${n}/labor/${r}`,operationRunComments:(e,t,n)=>`orders/${e}/runs/${t}/ops/${n}/comments`,workCenters:`work-centers`,workCenter:e=>`work-centers/${e}`,workCenterUsers:e=>`work-centers/${e}/users`,workCenterUser:(e,t)=>`work-centers/${e}/users/${t}`,usersFromAgent:`users/from-agent`,userRotateKey:e=>`users/${e}/rotate-key`,changePassword:`users/me/password`,audit:(e,t)=>`audit?entityType=${e}&entityId=${t}`,admin:`admin`,adminAttachments:`admin/attachments`,adminAttachmentDownload:e=>`/erp/api/admin/attachments/${e}`,adminLogs:(e,t)=>{let n=new URLSearchParams;e!=null&&n.set(`lines`,String(e)),t!=null&&n.set(`minLevel`,String(t));let r=n.toString();return`admin/logs${r?`?${r}`:``}`}},vM={login:(e,t)=>q.post(`/erp/api/auth/login`,{username:e,password:t}),logout:()=>q.post(`/erp/api/auth/logout`,{}),me:()=>q.get(`/erp/api/auth/me`)},yM=(0,v.createContext)(null),bM=({children:e})=>{let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(!0);(0,v.useEffect)(()=>{vM.me().then(n).catch(()=>n(null)).finally(()=>i(!1))},[]),(0,v.useEffect)(()=>{let e=()=>n(null);return window.addEventListener(`erp:unauthorized`,e),()=>window.removeEventListener(`erp:unauthorized`,e)},[]);let a=(0,v.useCallback)(async(e,t)=>{n((await vM.login(e,t)).user)},[]),o=(0,v.useCallback)(async()=>{await vM.logout(),n(null)},[]);return(0,I.jsx)(yM.Provider,{value:{user:t,loading:r,login:a,logout:o},children:e})};function xM(){let e=(0,v.useContext)(yM);if(!e)throw Error(`useAuth must be used within AuthProvider`);return e}function SM(e){if(!/^[0-9a-zA-Z-]+$/.test(e))throw Error(`[@mantine/use-form] Form name "${e}" is invalid, it should contain only letters, numbers and dashes`)}var CM=typeof window<`u`?v.useLayoutEffect:v.useEffect;function wM(e,t){CM(()=>{if(e)return window.addEventListener(e,t),()=>window.removeEventListener(e,t)},[e])}function TM(e,t){e&&SM(e),wM(`mantine-form:${e}:set-field-value`,e=>t.setFieldValue(e.detail.path,e.detail.value)),wM(`mantine-form:${e}:set-values`,e=>t.setValues(e.detail)),wM(`mantine-form:${e}:set-initial-values`,e=>t.setInitialValues(e.detail)),wM(`mantine-form:${e}:set-errors`,e=>t.setErrors(e.detail)),wM(`mantine-form:${e}:set-field-error`,e=>t.setFieldError(e.detail.path,e.detail.error)),wM(`mantine-form:${e}:clear-field-error`,e=>t.clearFieldError(e.detail)),wM(`mantine-form:${e}:clear-errors`,t.clearErrors),wM(`mantine-form:${e}:reset`,t.reset),wM(`mantine-form:${e}:validate`,t.validate),wM(`mantine-form:${e}:validate-field`,e=>t.validateField(e.detail)),wM(`mantine-form:${e}:reorder-list-item`,e=>t.reorderListItem(e.detail.path,e.detail.payload)),wM(`mantine-form:${e}:remove-list-item`,e=>t.removeListItem(e.detail.path,e.detail.index)),wM(`mantine-form:${e}:insert-list-item`,e=>t.insertListItem(e.detail.path,e.detail.item,e.detail.index)),wM(`mantine-form:${e}:set-dirty`,e=>t.setDirty(e.detail)),wM(`mantine-form:${e}:set-touched`,e=>t.setTouched(e.detail)),wM(`mantine-form:${e}:reset-dirty`,e=>t.resetDirty(e.detail)),wM(`mantine-form:${e}:reset-touched`,t.resetTouched)}function EM(e){return t=>{if(!t)e(t);else if(typeof t==`function`)e(t);else if(typeof t==`object`&&`nativeEvent`in t){let{currentTarget:n}=t;n instanceof HTMLInputElement?n.type===`checkbox`?e(n.checked):e(n.value):(n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement)&&e(n.value)}else e(t)}}function DM(e){return typeof e!=`object`||!e?{}:Object.keys(e).reduce((t,n)=>{let r=e[n];return r!=null&&r!==!1&&(t[n]=r),t},{})}function OM(e){let[t,n]=(0,v.useState)(DM(e)),r=(0,v.useRef)(t),i=(0,v.useCallback)(e=>{n(t=>{let n=DM(typeof e==`function`?e(t):e);return r.current=n,n})},[]),a=(0,v.useCallback)(()=>i({}),[]),o=(0,v.useCallback)(e=>{r.current[e]!==void 0&&i(t=>{let n={...t};return delete n[e],n})},[t]);return{errorsState:t,setErrors:i,clearErrors:a,setFieldError:(0,v.useCallback)((e,t)=>{t==null||t===!1?o(e):r.current[e]!==t&&i(n=>({...n,[e]:t}))},[t]),clearFieldError:o}}function kM(e,t){if(typeof t!=`object`||!t)return{};let n={...t};return Object.keys(t).forEach(t=>{t.includes(`${String(e)}.`)&&delete n[t]}),n}function AM(e,t){let n=e.substring(t.length+1).split(`.`)[0];return parseInt(n,10)}function jM(e,t,n,r){if(t===void 0)return n;let i=`${String(e)}`,a=n;r===-1&&(a=kM(`${i}.${t}`,a));let o={...a},s=new Set;return Object.entries(a).filter(([e])=>{if(!e.startsWith(`${i}.`))return!1;let n=AM(e,i);return Number.isNaN(n)?!1:n>=t}).forEach(([e,t])=>{let n=AM(e,i),a=e.replace(`${i}.${n}`,`${i}.${n+r}`);o[a]=t,s.add(a),s.has(e)||delete o[e]}),o}function MM(e,{from:t,to:n},r){let i=`${e}.${t}`,a=`${e}.${n}`,o={...r},s=new Set;return Object.keys(r).forEach(e=>{if(s.has(e))return;let t,n;if(e.startsWith(i)?(t=e,n=e.replace(i,a)):e.startsWith(a)&&(t=e.replace(a,i),n=e),t&&n){let e=o[t],r=o[n];r===void 0?delete o[t]:o[t]=r,e===void 0?delete o[n]:o[n]=e,s.add(t),s.add(n)}}),o}function NM(e,t,n){typeof n.value==`object`&&(n.value=PM(n.value)),!n.enumerable||n.get||n.set||!n.configurable||!n.writable||t===`__proto__`?Object.defineProperty(e,t,n):e[t]=n.value}function PM(e){if(typeof e!=`object`)return e;var t=0,n,r,i,a=Object.prototype.toString.call(e);if(a===`[object Object]`?i=Object.create(e.__proto__||null):a===`[object Array]`?i=Array(e.length):a===`[object Set]`?(i=new Set,e.forEach(function(e){i.add(PM(e))})):a===`[object Map]`?(i=new Map,e.forEach(function(e,t){i.set(PM(t),PM(e))})):a===`[object Date]`?i=new Date(+e):a===`[object RegExp]`?i=new RegExp(e.source,e.flags):a===`[object DataView]`?i=new e.constructor(PM(e.buffer)):a===`[object ArrayBuffer]`?i=e.slice(0):a.slice(-6)===`Array]`&&(i=new e.constructor(e)),i){for(r=Object.getOwnPropertySymbols(e);t<r.length;t++)NM(i,r[t],Object.getOwnPropertyDescriptor(e,r[t]));for(t=0,r=Object.getOwnPropertyNames(e);t<r.length;t++)Object.hasOwnProperty.call(i,n=r[t])&&i[n]===e[n]||NM(i,n,Object.getOwnPropertyDescriptor(e,n))}return i||e}function FM(e){return typeof e==`string`?e.split(`.`):[]}function IM(e,t){let n=FM(e);if(n.length===0||typeof t!=`object`||!t)return;let r=t[n[0]];for(let e=1;e<n.length&&r!=null;e+=1)r=r[n[e]];return r}function LM(e,t,n){let r=FM(e);if(r.length===0)return n;let i=PM(n);if(r.length===1)return i[r[0]]=t,i;let a=i[r[0]];for(let e=1;e<r.length-1;e+=1){if(a===void 0)return i;a=a[r[e]]}return a[r[r.length-1]]=t,i}function RM(e,{from:t,to:n},r){let i=IM(e,r);if(!Array.isArray(i))return r;let a=[...i],o=i[t];return a.splice(t,1),a.splice(n,0,o),LM(e,a,r)}function zM(e,t,n,r){let i=IM(e,r);if(!Array.isArray(i))return r;let a=[...i];return a.splice(typeof n==`number`?n:a.length,0,t),LM(e,a,r)}function BM(e,t,n){let r=IM(e,n);return Array.isArray(r)?LM(e,r.filter((e,n)=>n!==t),n):n}function VM(e,t,n,r){let i=IM(e,r);if(!Array.isArray(i)||i.length<=n)return r;let a=[...i];return a[n]=t,LM(e,a,r)}function HM({$values:e,$errors:t,$status:n}){return{reorderListItem:(0,v.useCallback)((r,i)=>{n.clearFieldDirty(r),t.setErrors(e=>MM(r,i,e)),e.setValues({values:RM(r,i,e.refValues.current),updateState:!0})},[]),removeListItem:(0,v.useCallback)((r,i)=>{n.clearFieldDirty(r),t.setErrors(e=>jM(r,i,e,-1)),e.setValues({values:BM(r,i,e.refValues.current),updateState:!0})},[]),insertListItem:(0,v.useCallback)((r,i,a)=>{n.clearFieldDirty(r),t.setErrors(e=>jM(r,a,e,1)),e.setValues({values:zM(r,i,a,e.refValues.current),updateState:!0})},[]),replaceListItem:(0,v.useCallback)((t,r,i)=>{n.clearFieldDirty(t),e.setValues({values:VM(t,i,r,e.refValues.current),updateState:!0})},[])}}var UM=o(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}}));function WM(e,t){let n=Object.keys(e);if(typeof t==`string`){let r=n.filter(e=>e.startsWith(`${t}.`));return e[t]||r.some(t=>e[t])||!1}return n.some(t=>e[t])}var GM=l(UM(),1);function KM({initialDirty:e,initialTouched:t,mode:n,$values:r}){let[i,a]=(0,v.useState)(t),[o,s]=(0,v.useState)(e),c=(0,v.useRef)(t),l=(0,v.useRef)(e),u=(0,v.useCallback)(e=>{let t=typeof e==`function`?e(c.current):e;c.current=t,n===`controlled`&&a(t)},[]),d=(0,v.useCallback)((e,t=!1)=>{let r=typeof e==`function`?e(l.current):e;l.current=r,(n===`controlled`||t)&&s(r)},[]),f=(0,v.useCallback)(()=>u({}),[]),p=(0,v.useCallback)(e=>{let t=e?{...r.refValues.current,...e}:r.refValues.current;r.setValuesSnapshot(t),d({})},[]),m=(0,v.useCallback)((e,t)=>{u(n=>WM(n,e)===t?n:{...n,[e]:t})},[]),h=(0,v.useCallback)((e,t,n)=>{d(n=>WM(n,e)===t?n:{...n,[e]:t},n)},[]),g=(0,v.useCallback)((e,t)=>{let n=WM(l.current,e),i=!(0,GM.default)(IM(e,r.getValuesSnapshot()),t),a=kM(e,l.current);a[e]=i,d(a,n!==i)},[]);return{touchedState:i,dirtyState:o,touchedRef:c,dirtyRef:l,setTouched:u,setDirty:d,resetDirty:p,resetTouched:f,isTouched:(0,v.useCallback)(e=>WM(c.current,e),[]),setFieldTouched:m,setFieldDirty:h,setTouchedState:a,setDirtyState:s,clearFieldDirty:(0,v.useCallback)(e=>d(t=>{if(typeof e!=`string`)return t;let n=kM(e,t);return delete n[e],(0,GM.default)(n,t)?t:n}),[]),isDirty:(0,v.useCallback)(e=>{if(e){let t=IM(e,l.current);return typeof t==`boolean`?t:!(0,GM.default)(IM(e,r.refValues.current),IM(e,r.valuesSnapshot.current))}return Object.keys(l.current).length>0?WM(l.current):!(0,GM.default)(r.refValues.current,r.valuesSnapshot.current)},[]),getDirty:(0,v.useCallback)(()=>l.current,[]),getTouched:(0,v.useCallback)(()=>c.current,[]),setCalculatedFieldDirty:g}}function qM({initialValues:e,onValuesChange:t,mode:n}){let r=(0,v.useRef)(!1),[i,a]=(0,v.useState)(e||{}),o=(0,v.useRef)(i),s=(0,v.useRef)(i),c=(0,v.useCallback)(({values:e,subscribers:r,updateState:i=!0,mergeWithPreviousValues:s=!0})=>{let c=o.current,l=e instanceof Function?e(o.current):e,u=s?{...c,...l}:l;o.current=u,i&&(a(u),n===`uncontrolled`&&(o.current=u)),t?.(u,c),r?.filter(Boolean).forEach(e=>e({updatedValues:u,previousValues:c}))},[t]),l=(0,v.useCallback)(e=>{let t=IM(e.path,o.current),n=e.value instanceof Function?e.value(t):e.value;if(t!==n){let t=o.current,r=LM(e.path,n,o.current);c({values:r,updateState:e.updateState}),e.subscribers?.filter(Boolean).forEach(n=>n({path:e.path,updatedValues:r,previousValues:t}))}},[c]),u=(0,v.useCallback)(e=>{s.current=e},[]),d=(0,v.useCallback)((e,t)=>{r.current||(r.current=!0,c({values:e,updateState:n===`controlled`}),u(e),t())},[c]);return{initialized:r,stateValues:i,refValues:o,valuesSnapshot:s,setValues:c,setFieldValue:l,resetValues:(0,v.useCallback)(()=>{c({values:s.current,updateState:!0,mergeWithPreviousValues:!1})},[c]),setValuesSnapshot:u,initialize:d,getValues:(0,v.useCallback)(()=>o.current,[]),getValuesSnapshot:(0,v.useCallback)(()=>s.current,[]),resetField:(0,v.useCallback)((e,t)=>{let r=IM(e,s.current);r!==void 0&&l({path:e,value:r,updateState:n===`controlled`,subscribers:t})},[l,n])}}function JM({$status:e,cascadeUpdates:t}){let n=(0,v.useRef)({});return{subscribers:n,watch:(0,v.useCallback)((e,t)=>{(0,v.useEffect)(()=>(n.current[e]=n.current[e]||[],n.current[e].push(t),()=>{n.current[e]=n.current[e].filter(e=>e!==t)}),[t])},[]),getFieldSubscribers:(0,v.useCallback)(r=>{let i=n.current[r]?.map(t=>n=>t({previousValue:IM(r,n.previousValues),value:IM(r,n.updatedValues),touched:e.isTouched(r),dirty:e.isDirty(r)}))??[];if(t)for(let t in n.current)(t.startsWith(`${r}.`)||r.startsWith(`${t}.`))&&i.push(...n.current[t].map(n=>r=>n({previousValue:IM(t,r.previousValues),value:IM(t,r.updatedValues),touched:e.isTouched(t),dirty:e.isDirty(t)})));return i},[])}}function YM(e,t){return e?`${e}-${t.toString()}`:t.toString()}var XM=Symbol(`root-rule`);function ZM(e){let t=DM(e);return{hasErrors:Object.keys(t).length>0,errors:t}}function QM(e,t,n=``,r={}){return typeof e!=`object`||!e?r:Object.keys(e).reduce((r,i)=>{let a=e[i],o=`${n===``?``:`${n}.`}${i}`,s=IM(o,t),c=!1;return typeof a==`function`&&(r[o]=a(s,t,o)),typeof a==`object`&&Array.isArray(s)&&(c=!0,s.forEach((e,n)=>QM(a,t,`${o}.${n}`,r)),XM in a&&(r[o]=a[XM](s,t,o))),typeof a==`object`&&typeof s==`object`&&s&&(c||QM(a,t,o,r),XM in a&&(r[o]=a[XM](s,t,o))),r},r)}function $M(e,t){return ZM(typeof e==`function`?e(t):QM(e,t))}function eN(e,t,n){if(typeof e!=`string`)return{hasError:!1,error:null};let r=$M(t,n),i=Object.keys(r.errors).find(t=>e.split(`.`).every((e,n)=>e===t.split(`.`)[n]));return{hasError:!!i,error:i?r.errors[i]:null}}var tN=`__MANTINE_FORM_INDEX__`;function nN(e,t){return t?typeof t==`boolean`?t:Array.isArray(t)?t.includes(e.replace(/[.][0-9]+/g,`.${tN}`)):!1:!1}function rN({name:e,mode:t=`controlled`,initialValues:n,initialErrors:r={},initialDirty:i={},initialTouched:a={},clearInputErrorOnChange:o=!0,validateInputOnChange:s=!1,validateInputOnBlur:c=!1,onValuesChange:l,transformValues:u=(e=>e),enhanceGetInputProps:d,validate:f,onSubmitPreventDefault:p=`always`,touchTrigger:m=`change`,cascadeUpdates:h=!1}={}){let g=OM(r),_=qM({initialValues:n,onValuesChange:l,mode:t}),y=KM({initialDirty:i,initialTouched:a,$values:_,mode:t}),b=HM({$values:_,$errors:g,$status:y}),x=JM({$status:y,cascadeUpdates:h}),[S,C]=(0,v.useState)(0),[w,T]=(0,v.useState)({}),[E,D]=(0,v.useState)(!1),O=(0,v.useCallback)(()=>{_.resetValues(),g.clearErrors(),y.resetDirty(),y.resetTouched(),t===`uncontrolled`&&C(e=>e+1)},[]),k=(0,v.useCallback)(e=>{o&&g.clearErrors(),t===`uncontrolled`&&C(e=>e+1),Object.keys(x.subscribers.current).forEach(t=>{IM(t,_.refValues.current)!==IM(t,e)&&x.getFieldSubscribers(t).forEach(t=>t({previousValues:e,updatedValues:_.refValues.current}))})},[o]),A=(0,v.useCallback)(e=>{let n=_.refValues.current;_.initialize(e,()=>t===`uncontrolled`&&C(e=>e+1)),k(n)},[k]),j=(0,v.useCallback)((e,n,r)=>{let i=nN(e,s),a=n instanceof Function?n(IM(e,_.refValues.current)):n;y.setCalculatedFieldDirty(e,a),m===`change`&&y.setFieldTouched(e,!0),!i&&o&&g.clearFieldError(e),_.setFieldValue({path:e,value:n,updateState:t===`controlled`,subscribers:[...x.getFieldSubscribers(e),i?t=>{let n=eN(e,f,t.updatedValues);n.hasError?g.setFieldError(e,n.error):g.clearFieldError(e)}:null,r?.forceUpdate!==!1&&t!==`controlled`?()=>T(t=>({...t,[e]:(t[e]||0)+1})):null]})},[l,f]),ee=(0,v.useCallback)(e=>{let n=_.refValues.current;_.setValues({values:e,updateState:t===`controlled`}),k(n)},[l,k]),te=(0,v.useCallback)(()=>{let e=$M(f,_.refValues.current);return g.setErrors(e.errors),e},[f]),ne=(0,v.useCallback)(e=>{let t=eN(e,f,_.refValues.current);return t.hasError?g.setFieldError(e,t.error):g.clearFieldError(e),t},[f]),re=(n,{type:r=`input`,withError:i=!0,withFocus:a=!0,...o}={})=>{let s={onChange:EM(e=>j(n,e,{forceUpdate:!1})),"data-path":YM(e,n)};return i&&(s.error=g.errorsState[n]),r===`checkbox`?s[t===`controlled`?`checked`:`defaultChecked`]=IM(n,_.refValues.current):s[t===`controlled`?`value`:`defaultValue`]=IM(n,_.refValues.current),a&&(s.onFocus=()=>y.setFieldTouched(n,!0),s.onBlur=()=>{if(nN(n,c)){let e=eN(n,f,_.refValues.current);e.hasError?g.setFieldError(n,e.error):g.clearFieldError(n)}}),Object.assign(s,d?.({inputProps:s,field:n,options:{type:r,withError:i,withFocus:a,...o},form:le}))},M=(e,t)=>n=>{p===`always`&&n?.preventDefault();let r=te();if(r.hasErrors)p===`validation-failed`&&n?.preventDefault(),t?.(r.errors,_.refValues.current,n);else{let t=e?.(u(_.refValues.current),n);t instanceof Promise&&(D(!0),t.finally(()=>D(!1)))}},N=e=>u(e||_.refValues.current),ie=(0,v.useCallback)(e=>{e.preventDefault(),O()},[]),ae=(0,v.useCallback)(e=>e?!eN(e,f,_.refValues.current).hasError:!$M(f,_.refValues.current).hasErrors,[f]),oe=e=>`${S}-${String(e)}-${w[String(e)]||0}`,se=(0,v.useCallback)(t=>document.querySelector(`[data-path="${YM(e,t)}"]`),[]),ce=(0,v.useCallback)(e=>{_.resetField(e,[t===`controlled`?null:()=>T(t=>({...t,[e]:(t[e]||0)+1}))])},[_.resetField,t,T]),le={watch:x.watch,initialized:_.initialized.current,values:t===`uncontrolled`?_.refValues.current:_.stateValues,getValues:_.getValues,getInitialValues:_.getValuesSnapshot,setInitialValues:_.setValuesSnapshot,resetField:ce,initialize:A,setValues:ee,setFieldValue:j,submitting:E,setSubmitting:D,errors:g.errorsState,setErrors:g.setErrors,setFieldError:g.setFieldError,clearFieldError:g.clearFieldError,clearErrors:g.clearErrors,resetDirty:y.resetDirty,setTouched:y.setTouched,setDirty:y.setDirty,isTouched:y.isTouched,resetTouched:y.resetTouched,isDirty:y.isDirty,getTouched:y.getTouched,getDirty:y.getDirty,reorderListItem:b.reorderListItem,insertListItem:b.insertListItem,removeListItem:b.removeListItem,replaceListItem:b.replaceListItem,reset:O,validate:te,validateField:ne,getInputProps:re,onSubmit:M,onReset:ie,isValid:ae,getTransformedValues:N,key:oe,getInputNode:se};return TM(e,le),le}function iN({actions:e,rel:t,onClick:n,...r}){let i=Rj(e,t,{includeDisabled:!0});if(!i)return null;let a=(0,I.jsx)(H,{...r,disabled:i.disabled,onClick:i.disabled?void 0:n}),o=Bj(i.disabledReason);return o?(0,I.jsx)(M_,{label:o,multiline:!0,maw:350,style:{whiteSpace:`pre-line`},children:a}):a}var aN={outline:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},filled:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`currentColor`,stroke:`none`}},oN=(e,t,n,r)=>{let i=(0,v.forwardRef)(({color:n=`currentColor`,size:i=24,stroke:a=2,title:o,className:s,children:c,...l},u)=>(0,v.createElement)(`svg`,{ref:u,...aN[e],width:i,height:i,className:[`tabler-icon`,`tabler-icon-${t}`,s].join(` `),...e===`filled`?{fill:n}:{strokeWidth:a,stroke:n},...l},[o&&(0,v.createElement)(`title`,{key:`svg-title`},o),...r.map(([e,t])=>(0,v.createElement)(e,t)),...Array.isArray(c)?c:[c]]));return i.displayName=`${n}`,i},sN=oN(`outline`,`copy`,`Copy`,[[`path`,{d:`M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666`,key:`svg-0`}],[`path`,{d:`M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1`,key:`svg-1`}]]),cN=oN(`outline`,`download`,`Download`,[[`path`,{d:`M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2`,key:`svg-0`}],[`path`,{d:`M7 11l5 5l5 -5`,key:`svg-1`}],[`path`,{d:`M12 4l0 12`,key:`svg-2`}]]),lN=oN(`outline`,`eye-off`,`EyeOff`,[[`path`,{d:`M10.585 10.587a2 2 0 0 0 2.829 2.828`,key:`svg-0`}],[`path`,{d:`M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87`,key:`svg-1`}],[`path`,{d:`M3 3l18 18`,key:`svg-2`}]]),uN=oN(`outline`,`eye`,`Eye`,[[`path`,{d:`M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0`,key:`svg-0`}],[`path`,{d:`M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6`,key:`svg-1`}]]),dN=oN(`outline`,`refresh`,`Refresh`,[[`path`,{d:`M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4`,key:`svg-0`}],[`path`,{d:`M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4`,key:`svg-1`}]]),fN=50,pN=({fetchAttachments:e,getDownloadUrl:t,extraColumns:n})=>{let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(1),l=(0,v.useCallback)(async()=>{o(!0);try{i(await e(s,fN))}catch{i(null)}finally{o(!1)}},[s,e]);(0,v.useEffect)(()=>{l()},[l]);let u=(e,n)=>{let r=document.createElement(`a`);r.href=t(e),r.download=n,r.click()},d=r?Math.ceil(r.total/r.pageSize):0;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(zv,{order:3,mt:`xl`,children:`Attachments`}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{size:`xs`,variant:`light`,leftSection:(0,I.jsx)(dN,{size:14}),onClick:()=>l(),loading:a,children:`Refresh`}),r&&(0,I.jsxs)(V,{size:`sm`,c:`dimmed`,children:[r.total,` file`,r.total!==1&&`s`]})]}),a&&!r?(0,I.jsx)(U,{align:`center`,py:`md`,children:(0,I.jsx)(uu,{size:`sm`})}):r&&r.attachments.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Filename`}),(0,I.jsx)(W.Th,{children:`Size`}),n?.map(e=>(0,I.jsx)(W.Th,{children:e.header},e.header)),(0,I.jsx)(W.Th,{children:`Uploaded By`}),(0,I.jsx)(W.Th,{children:`Date`}),(0,I.jsx)(W.Th,{})]})}),(0,I.jsx)(W.Tbody,{children:r.attachments.map(e=>(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},onClick:()=>u(e.id,e.filename),children:[(0,I.jsx)(W.Td,{children:e.filename}),(0,I.jsx)(W.Td,{children:Lj(e.fileSize)}),n?.map(t=>(0,I.jsx)(W.Td,{children:t.render(e)},t.header)),(0,I.jsx)(W.Td,{children:e.uploadedBy}),(0,I.jsx)(W.Td,{children:new Date(e.createdAt).toLocaleString()}),(0,I.jsx)(W.Td,{children:(0,I.jsx)(cN,{size:16})})]},e.id))})]}),d>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:d,value:s,onChange:c})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`md`,children:`No attachments found`})]})};function mN(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var hN=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,gN=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_N={};function vN(e,t){return((t||_N).jsx?gN:hN).test(e)}var yN=/[ \t\n\f\r]/g;function bN(e){return typeof e==`object`?e.type===`text`?xN(e.value):!1:xN(e)}function xN(e){return e.replace(yN,``)===``}var SN=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};SN.prototype.normal={},SN.prototype.property={},SN.prototype.space=void 0;function CN(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new SN(n,r,t)}function wN(e){return e.toLowerCase()}var TN=class{constructor(e,t){this.attribute=t,this.property=e}};TN.prototype.attribute=``,TN.prototype.booleanish=!1,TN.prototype.boolean=!1,TN.prototype.commaOrSpaceSeparated=!1,TN.prototype.commaSeparated=!1,TN.prototype.defined=!1,TN.prototype.mustUseProperty=!1,TN.prototype.number=!1,TN.prototype.overloadedBoolean=!1,TN.prototype.property=``,TN.prototype.spaceSeparated=!1,TN.prototype.space=void 0;var EN=s({boolean:()=>ON,booleanish:()=>kN,commaOrSpaceSeparated:()=>PN,commaSeparated:()=>NN,number:()=>jN,overloadedBoolean:()=>AN,spaceSeparated:()=>MN}),DN=0,ON=FN(),kN=FN(),AN=FN(),jN=FN(),MN=FN(),NN=FN(),PN=FN();function FN(){return 2**++DN}var IN=Object.keys(EN),LN=class extends TN{constructor(e,t,n,r){let i=-1;if(super(e,t),RN(this,`space`,r),typeof n==`number`)for(;++i<IN.length;){let e=IN[i];RN(this,IN[i],(n&EN[e])===EN[e])}}};LN.prototype.defined=!0;function RN(e,t,n){n&&(e[t]=n)}function zN(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new LN(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[wN(r)]=r,n[wN(a.attribute)]=r}return new SN(t,n,e.space)}var BN=zN({properties:{ariaActiveDescendant:null,ariaAtomic:kN,ariaAutoComplete:null,ariaBusy:kN,ariaChecked:kN,ariaColCount:jN,ariaColIndex:jN,ariaColSpan:jN,ariaControls:MN,ariaCurrent:null,ariaDescribedBy:MN,ariaDetails:null,ariaDisabled:kN,ariaDropEffect:MN,ariaErrorMessage:null,ariaExpanded:kN,ariaFlowTo:MN,ariaGrabbed:kN,ariaHasPopup:null,ariaHidden:kN,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:MN,ariaLevel:jN,ariaLive:null,ariaModal:kN,ariaMultiLine:kN,ariaMultiSelectable:kN,ariaOrientation:null,ariaOwns:MN,ariaPlaceholder:null,ariaPosInSet:jN,ariaPressed:kN,ariaReadOnly:kN,ariaRelevant:null,ariaRequired:kN,ariaRoleDescription:MN,ariaRowCount:jN,ariaRowIndex:jN,ariaRowSpan:jN,ariaSelected:kN,ariaSetSize:jN,ariaSort:null,ariaValueMax:jN,ariaValueMin:jN,ariaValueNow:jN,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function VN(e,t){return t in e?e[t]:t}function HN(e,t){return VN(e,t.toLowerCase())}var UN=zN({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:NN,acceptCharset:MN,accessKey:MN,action:null,allow:null,allowFullScreen:ON,allowPaymentRequest:ON,allowUserMedia:ON,alt:null,as:null,async:ON,autoCapitalize:null,autoComplete:MN,autoFocus:ON,autoPlay:ON,blocking:MN,capture:null,charSet:null,checked:ON,cite:null,className:MN,cols:jN,colSpan:null,content:null,contentEditable:kN,controls:ON,controlsList:MN,coords:jN|NN,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ON,defer:ON,dir:null,dirName:null,disabled:ON,download:AN,draggable:kN,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ON,formTarget:null,headers:MN,height:jN,hidden:AN,high:jN,href:null,hrefLang:null,htmlFor:MN,httpEquiv:MN,id:null,imageSizes:null,imageSrcSet:null,inert:ON,inputMode:null,integrity:null,is:null,isMap:ON,itemId:null,itemProp:MN,itemRef:MN,itemScope:ON,itemType:MN,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ON,low:jN,manifest:null,max:null,maxLength:jN,media:null,method:null,min:null,minLength:jN,multiple:ON,muted:ON,name:null,nonce:null,noModule:ON,noValidate:ON,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ON,optimum:jN,pattern:null,ping:MN,placeholder:null,playsInline:ON,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ON,referrerPolicy:null,rel:MN,required:ON,reversed:ON,rows:jN,rowSpan:jN,sandbox:MN,scope:null,scoped:ON,seamless:ON,selected:ON,shadowRootClonable:ON,shadowRootDelegatesFocus:ON,shadowRootMode:null,shape:null,size:jN,sizes:null,slot:null,span:jN,spellCheck:kN,src:null,srcDoc:null,srcLang:null,srcSet:null,start:jN,step:null,style:null,tabIndex:jN,target:null,title:null,translate:null,type:null,typeMustMatch:ON,useMap:null,value:kN,width:jN,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:MN,axis:null,background:null,bgColor:null,border:jN,borderColor:null,bottomMargin:jN,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ON,declare:ON,event:null,face:null,frame:null,frameBorder:null,hSpace:jN,leftMargin:jN,link:null,longDesc:null,lowSrc:null,marginHeight:jN,marginWidth:jN,noResize:ON,noHref:ON,noShade:ON,noWrap:ON,object:null,profile:null,prompt:null,rev:null,rightMargin:jN,rules:null,scheme:null,scrolling:kN,standby:null,summary:null,text:null,topMargin:jN,valueType:null,version:null,vAlign:null,vLink:null,vSpace:jN,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ON,disableRemotePlayback:ON,prefix:null,property:null,results:jN,security:null,unselectable:null},space:`html`,transform:HN}),WN=zN({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:PN,accentHeight:jN,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:jN,amplitude:jN,arabicForm:null,ascent:jN,attributeName:null,attributeType:null,azimuth:jN,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:jN,by:null,calcMode:null,capHeight:jN,className:MN,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:jN,diffuseConstant:jN,direction:null,display:null,dur:null,divisor:jN,dominantBaseline:null,download:ON,dx:null,dy:null,edgeMode:null,editable:null,elevation:jN,enableBackground:null,end:null,event:null,exponent:jN,externalResourcesRequired:null,fill:null,fillOpacity:jN,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:NN,g2:NN,glyphName:NN,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:jN,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:jN,horizOriginX:jN,horizOriginY:jN,id:null,ideographic:jN,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:jN,k:jN,k1:jN,k2:jN,k3:jN,k4:jN,kernelMatrix:PN,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:jN,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:jN,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:jN,overlineThickness:jN,paintOrder:null,panose1:null,path:null,pathLength:jN,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:MN,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:jN,pointsAtY:jN,pointsAtZ:jN,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:PN,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:PN,rev:PN,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:PN,requiredFeatures:PN,requiredFonts:PN,requiredFormats:PN,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:jN,specularExponent:jN,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:jN,strikethroughThickness:jN,string:null,stroke:null,strokeDashArray:PN,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:jN,strokeOpacity:jN,strokeWidth:null,style:null,surfaceScale:jN,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:PN,tabIndex:jN,tableValues:null,target:null,targetX:jN,targetY:jN,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:PN,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:jN,underlineThickness:jN,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:jN,values:null,vAlphabetic:jN,vMathematical:jN,vectorEffect:null,vHanging:jN,vIdeographic:jN,version:null,vertAdvY:jN,vertOriginX:jN,vertOriginY:jN,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:jN,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:VN}),GN=zN({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),KN=zN({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:HN}),qN=zN({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),JN={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},YN=/[A-Z]/g,XN=/-[a-z]/g,ZN=/^data[-\w.:]+$/i;function QN(e,t){let n=wN(t),r=t,i=TN;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&ZN.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(XN,eP);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!XN.test(e)){let n=e.replace(YN,$N);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=LN}return new i(r,t)}function $N(e){return`-`+e.toLowerCase()}function eP(e){return e.charAt(1).toUpperCase()}var tP=CN([BN,UN,GN,KN,qN],`html`),nP=CN([BN,WN,GN,KN,qN],`svg`);function rP(e){return e.join(` `).trim()}var iP=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
103
103
  `,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function D(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),D()}function _(e){return e?e.replace(l,p):p}t.exports=g})),aP=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=r;var n=t(iP());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),oP=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),sP=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(aP()),r=oP();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),cP=uP(`end`),lP=uP(`start`);function uP(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function dP(e){let t=lP(e),n=cP(e);if(t&&n)return{start:t,end:n}}function fP(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?mP(e.position):`start`in e||`end`in e?mP(e):`line`in e||`column`in e?pP(e):``}function pP(e){return hP(e&&e.line)+`:`+hP(e&&e.column)}function mP(e){return pP(e&&e.start)+`-`+pP(e&&e.end)}function hP(e){return e&&typeof e==`number`?e:1}var gP=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=fP(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};gP.prototype.file=``,gP.prototype.name=``,gP.prototype.reason=``,gP.prototype.message=``,gP.prototype.stack=``,gP.prototype.column=void 0,gP.prototype.line=void 0,gP.prototype.ancestors=void 0,gP.prototype.cause=void 0,gP.prototype.fatal=void 0,gP.prototype.place=void 0,gP.prototype.ruleId=void 0,gP.prototype.source=void 0;var _P=l(sP(),1),vP={}.hasOwnProperty,yP=new Map,bP=/[A-Z]/g,xP=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),SP=new Set([`td`,`th`]),CP=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function wP(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=FP(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=PP(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?nP:tP,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=TP(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function TP(e,t,n){if(t.type===`element`)return EP(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return DP(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return kP(e,t,n);if(t.type===`mdxjsEsm`)return OP(e,t);if(t.type===`root`)return AP(e,t,n);if(t.type===`text`)return jP(e,t)}function EP(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=nP,e.schema=i),e.ancestors.push(t);let a=VP(e,t.tagName,!1),o=IP(e,t),s=RP(e,t);return xP.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!bN(e):!0})),MP(e,o,a,t),NP(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function DP(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}HP(e,t.position)}function OP(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);HP(e,t.position)}function kP(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=nP,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:VP(e,t.name,!0),o=LP(e,t),s=RP(e,t);return MP(e,o,a,t),NP(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function AP(e,t,n){let r={};return NP(r,RP(e,t)),e.create(t,e.Fragment,r,n)}function jP(e,t){return t.value}function MP(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function NP(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function PP(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function FP(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=lP(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function IP(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&vP.call(t.properties,i)){let a=zP(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&SP.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function LP(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else HP(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else HP(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function RP(e,t){let n=[],r=-1,i=e.passKeys?new Map:yP;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=TP(e,a,o);s!==void 0&&n.push(s)}return n}function zP(e,t,n){let r=QN(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?mN(n):rP(n)),r.property===`style`){let t=typeof n==`object`?n:BP(e,String(n));return e.stylePropertyNameCase===`css`&&(t=UP(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?JN[r.property]||r.property:r.attribute,n]}}function BP(e,t){try{return(0,_P.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new gP("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=CP+`#cannot-parse-style-attribute`,r}}function VP(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=vN(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=vN(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return vP.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);HP(e)}function HP(e,t){let n=new gP("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=CP+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function UP(e){let t={},n;for(n in e)vP.call(e,n)&&(t[WP(n)]=e[n]);return t}function WP(e){let t=e.replace(bP,GP);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function GP(e){return`-`+e.toLowerCase()}var KP={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},qP={};function JP(e,t){let n=t||qP;return YP(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function YP(e,t,n){if(ZP(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return XP(e.children,t,n)}return Array.isArray(e)?XP(e,t,n):``}function XP(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=YP(e[i],t,n);return r.join(``)}function ZP(e){return!!(e&&typeof e==`object`)}var QP=document.createElement(`i`);function $P(e){let t=`&`+e+`;`;QP.innerHTML=t;let n=QP.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function eF(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function tF(e,t){return e.length>0?(eF(e,e.length,0,t),e):t}var nF={}.hasOwnProperty;function rF(e){let t={},n=-1;for(;++n<e.length;)iF(t,e[n]);return t}function iF(e,t){let n;for(n in t){let r=(nF.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){nF.call(r,a)||(r[a]=[]);let e=i[a];aF(r[a],Array.isArray(e)?e:e?[e]:[])}}}function aF(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);eF(e,0,0,r)}function oF(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function sF(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var cF=bF(/[A-Za-z]/),lF=bF(/[\dA-Za-z]/),uF=bF(/[#-'*+\--9=?A-Z^-~]/);function dF(e){return e!==null&&(e<32||e===127)}var fF=bF(/\d/),pF=bF(/[\dA-Fa-f]/),mF=bF(/[!-/:-@[-`{-~]/);function hF(e){return e!==null&&e<-2}function gF(e){return e!==null&&(e<0||e===32)}function _F(e){return e===-2||e===-1||e===32}var vF=bF(/\p{P}|\p{S}/u),yF=bF(/\s/);function bF(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function xF(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&lF(e.charCodeAt(n+1))&&lF(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function SF(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return _F(r)?(e.enter(n),s(r)):t(r)}function s(r){return _F(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var CF={tokenize:wF};function wF(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),SF(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return hF(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var TF={tokenize:DF},EF={tokenize:OF};function DF(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return eF(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(EF,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(EF,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return hF(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;eF(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function OF(e,t,n){return SF(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function kF(e){if(e===null||gF(e)||yF(e))return 1;if(vF(e))return 2}function AF(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var jF={name:`attention`,resolveAll:MF,tokenize:NF};function MF(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};PF(d,-c),PF(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=tF(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=tF(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=tF(l,AF(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=tF(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=tF(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,eF(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function NF(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=kF(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=kF(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function PF(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var FF={name:`autolink`,tokenize:IF};function IF(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return cF(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||lF(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||lF(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||dF(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):uF(t)?(e.consume(t),l):n(t)}function u(e){return lF(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||lF(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var LF={partial:!0,tokenize:RF};function RF(e,t,n){return r;function r(t){return _F(t)?SF(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||hF(e)?t(e):n(e)}}var zF={continuation:{tokenize:VF},exit:HF,name:`blockQuote`,tokenize:BF};function BF(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return _F(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function VF(e,t,n){let r=this;return i;function i(t){return _F(t)?SF(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(zF,t,n)(r)}}function HF(e){e.exit(`blockQuote`)}var UF={name:`characterEscape`,tokenize:WF};function WF(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return mF(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var GF={name:`characterReference`,tokenize:KF};function KF(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=lF,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=pF,u):(e.enter(`characterReferenceValue`),a=7,o=fF,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===lF&&!$P(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var qF={partial:!0,tokenize:XF},JF={concrete:!0,name:`codeFenced`,tokenize:YF};function YF(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),_F(t)?SF(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||hF(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(qF,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||hF(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):_F(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),SF(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||hF(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||hF(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&_F(t)?SF(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||hF(t)?e.check(qF,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||hF(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),_F(t)?SF(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),_F(t)?SF(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||hF(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function XF(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var ZF={name:`codeIndented`,tokenize:$F},QF={partial:!0,tokenize:eI};function $F(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),SF(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):hF(t)?e.attempt(QF,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||hF(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function eI(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):hF(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):SF(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):hF(e)?i(e):n(e)}}var tI={name:`codeText`,previous:rI,resolve:nI,tokenize:iI};function nI(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function rI(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function iI(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):hF(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||hF(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var aI=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&oI(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),oI(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),oI(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);oI(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);oI(this.left,t.reverse())}}};function oI(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function sI(e){let t={},n=-1,r,i,a,o,s,c,l,u=new aI(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,cI(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return eF(e,0,1/0,u.slice(0)),!l}function cI(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var lI={resolve:dI,tokenize:fI},uI={partial:!0,tokenize:pI};function dI(e){return sI(e),e}function fI(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):hF(t)?e.check(uI,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function pI(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),SF(e,a,`linePrefix`)}function a(i){if(i===null||hF(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function mI(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||dF(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||hF(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||gF(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||dF(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function hI(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):hF(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||hF(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!_F(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function gI(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):hF(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),SF(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||hF(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function _I(e,t){let n;return r;function r(i){return hF(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):_F(i)?SF(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var vI={name:`definition`,tokenize:bI},yI={partial:!0,tokenize:xI};function bI(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return hI.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=sF(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return gF(t)?_I(e,l)(t):l(t)}function l(t){return mI(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(yI,d,d)(t)}function d(t){return _F(t)?SF(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||hF(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function xI(e,t,n){return r;function r(t){return gF(t)?_I(e,i)(t):n(t)}function i(t){return gI(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return _F(t)?SF(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||hF(e)?t(e):n(e)}}var SI={name:`hardBreakEscape`,tokenize:CI};function CI(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return hF(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var wI={name:`headingAtx`,resolve:TI,tokenize:EI};function TI(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},eF(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function EI(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||gF(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||hF(n)?(e.exit(`atxHeading`),t(n)):_F(n)?SF(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||gF(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var DI=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),OI=[`pre`,`script`,`style`,`textarea`],kI={concrete:!0,name:`htmlFlow`,resolveTo:MI,tokenize:NI},AI={partial:!0,tokenize:FI},jI={partial:!0,tokenize:PI};function MI(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function NI(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:M):cF(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):cF(a)?(e.consume(a),i=4,r.interrupt?t:M):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:M):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return cF(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||gF(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&OI.includes(l)?(i=1,r.interrupt?t(s):O(s)):DI.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||lF(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return _F(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||cF(t)?(e.consume(t),b):_F(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||lF(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):_F(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):_F(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||hF(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||gF(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||_F(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||hF(t)?O(t):_F(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),ee):t===60&&i===1?(e.consume(t),te):t===62&&i===4?(e.consume(t),N):t===63&&i===3?(e.consume(t),M):t===93&&i===5?(e.consume(t),re):hF(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(AI,ie,k)(t)):t===null||hF(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(jI,A,ie)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||hF(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function ee(t){return t===45?(e.consume(t),M):O(t)}function te(t){return t===47?(e.consume(t),o=``,ne):O(t)}function ne(t){if(t===62){let n=o.toLowerCase();return OI.includes(n)?(e.consume(t),N):O(t)}return cF(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ne):O(t)}function re(t){return t===93?(e.consume(t),M):O(t)}function M(t){return t===62?(e.consume(t),N):t===45&&i===2?(e.consume(t),M):O(t)}function N(t){return t===null||hF(t)?(e.exit(`htmlFlowData`),ie(t)):(e.consume(t),N)}function ie(n){return e.exit(`htmlFlow`),t(n)}}function PI(e,t,n){let r=this;return i;function i(t){return hF(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function FI(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(LF,t,n)}}var II={name:`htmlText`,tokenize:LI};function LI(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):cF(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):cF(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):hF(t)?(o=d,te(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?ee(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):hF(t)?(o=h,te(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?ee(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?ee(t):hF(t)?(o=v,te(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):hF(t)?(o=y,te(t)):(e.consume(t),y)}function b(e){return e===62?ee(e):y(e)}function x(t){return cF(t)?(e.consume(t),S):n(t)}function S(t){return t===45||lF(t)?(e.consume(t),S):C(t)}function C(t){return hF(t)?(o=C,te(t)):_F(t)?(e.consume(t),C):ee(t)}function w(t){return t===45||lF(t)?(e.consume(t),w):t===47||t===62||gF(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),ee):t===58||t===95||cF(t)?(e.consume(t),E):hF(t)?(o=T,te(t)):_F(t)?(e.consume(t),T):ee(t)}function E(t){return t===45||t===46||t===58||t===95||lF(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):hF(t)?(o=D,te(t)):_F(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):hF(t)?(o=O,te(t)):_F(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):hF(t)?(o=k,te(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||gF(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||gF(e)?T(e):n(e)}function ee(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function te(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ne}function ne(t){return _F(t)?SF(e,re,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):re(t)}function re(t){return e.enter(`htmlTextData`),o(t)}}var RI={name:`labelEnd`,resolveAll:HI,resolveTo:UI,tokenize:WI},zI={tokenize:GI},BI={tokenize:KI},VI={tokenize:qI};function HI(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&eF(e,0,e.length,n),e}function UI(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=tF(s,e.slice(a+1,a+r+3)),s=tF(s,[[`enter`,u,t]]),s=tF(s,AF(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=tF(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=tF(s,e.slice(o+1)),s=tF(s,[[`exit`,c,t]]),eF(e,a,e.length,s),e}function WI(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(sF(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(zI,u,o?u:d)(t):t===91?e.attempt(BI,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(VI,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function GI(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return gF(t)?_I(e,a)(t):a(t)}function a(t){return t===41?u(t):mI(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return gF(t)?_I(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?gI(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return gF(t)?_I(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function KI(e,t,n){let r=this;return i;function i(t){return hI.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(sF(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function qI(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var JI={name:`labelStartImage`,resolveAll:RI.resolveAll,tokenize:YI};function YI(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var XI={name:`labelStartLink`,resolveAll:RI.resolveAll,tokenize:ZI};function ZI(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var QI={name:`lineEnding`,tokenize:$I};function $I(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),SF(e,t,`linePrefix`)}}var eL={name:`thematicBreak`,tokenize:tL};function tL(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||hF(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),_F(t)?SF(e,s,`whitespace`)(t):s(t))}}var nL={continuation:{tokenize:oL},exit:cL,name:`list`,tokenize:aL},rL={partial:!0,tokenize:lL},iL={partial:!0,tokenize:sL};function aL(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:fF(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(eL,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return fF(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(LF,r.interrupt?n:u,e.attempt(rL,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return _F(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function oL(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(LF,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,SF(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!_F(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(iL,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,SF(e,e.attempt(nL,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function sL(e,t,n){let r=this;return SF(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function cL(e){e.exit(this.containerState.type)}function lL(e,t,n){let r=this;return SF(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!_F(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var uL={name:`setextUnderline`,resolveTo:dL,tokenize:fL};function dL(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function fL(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),_F(t)?SF(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||hF(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var pL={tokenize:mL};function mL(e){let t=this,n=e.attempt(LF,r,e.attempt(this.parser.constructs.flowInitial,i,SF(e,e.attempt(this.parser.constructs.flow,i,e.attempt(lI,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var hL={resolveAll:yL()},gL=vL(`string`),_L=vL(`text`);function vL(e){return{resolveAll:yL(e===`text`?bL:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function yL(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function bL(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var xL=s({attentionMarkers:()=>kL,contentInitial:()=>CL,disable:()=>AL,document:()=>SL,flow:()=>TL,flowInitial:()=>wL,insideSpan:()=>OL,string:()=>EL,text:()=>DL}),SL={42:nL,43:nL,45:nL,48:nL,49:nL,50:nL,51:nL,52:nL,53:nL,54:nL,55:nL,56:nL,57:nL,62:zF},CL={91:vI},wL={[-2]:ZF,[-1]:ZF,32:ZF},TL={35:wI,42:eL,45:[uL,eL],60:kI,61:uL,95:eL,96:JF,126:JF},EL={38:GF,92:UF},DL={[-5]:QI,[-4]:QI,[-3]:QI,33:JI,38:GF,42:jF,60:[FF,II],91:XI,92:[SI,UF],93:RI,95:jF,96:tI},OL={null:[jF,hL]},kL={null:[42,95]},AL={null:[]};function jL(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=tF(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=AF(a,l.events,l),l.events):[]}function f(e,t){return NL(p(e),t)}function p(e){return ML(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){hF(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&eF(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function ML(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function NL(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
104
104
  `;break;case-3:o=`\r
105
105
  `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function PL(e){let t={constructs:rF([xL,...(e||{}).extensions||[]]),content:n(CF),defined:[],document:n(TF),flow:n(pL),lazy:{},string:n(gL),text:n(_L)};return t;function n(e){return n;function n(n){return jL(t,e,n)}}}function FL(e){for(;!sI(e););return e}var IL=/[\0\t\n\r]/g;function LL(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(IL.lastIndex=u,c=IL.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var RL=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function zL(e){return e.replace(RL,BL)}function BL(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return oF(n.slice(t?2:1),t?16:10)}return $P(n)||e}var VL={}.hasOwnProperty;function HL(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),UL(n)(FL(PL(n).document().write(LL()(e,t,!0))))}function UL(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(xe),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(_e),blockQuote:a(fe),characterEscape:T,characterReference:T,codeFenced:a(pe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(pe,o),codeText:a(me,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(he),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(ge),hardBreakEscape:a(ve),hardBreakTrailing:a(ve),htmlFlow:a(ye,o),htmlFlowData:T,htmlText:a(ye,o),htmlTextData:T,image:a(be),label:o,link:a(xe),listItem:a(Ce),listItemValue:f,listOrdered:a(Se,d),listUnordered:a(Se),paragraph:a(we),reference:ae,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(_e),strong:a(Te),thematicBreak:a(De)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:de,autolinkProtocol:ue,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:se,characterReferenceMarkerNumeric:se,characterReferenceValue:ce,characterReference:le,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(te),label:re,labelText:ne,lineEnding:D,link:c(ee),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:oe,resourceDestinationString:M,resourceTitleString:N,resource:ie,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};GL(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];VL.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||qL).call(a,void 0,e[0])}for(r.position={start:WL(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:WL(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:WL(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||qL).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+fP({start:e.start,end:e.end})+`): it’s not open`);n.position.end=WL(e.end)}function u(){return JP(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=sF(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Ee(),n.position={start:WL(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=WL(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=WL(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ee(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function te(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function ne(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=zL(t),n.identifier=sF(t).toLowerCase()}function re(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function M(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function N(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ie(){this.data.inReference=void 0}function ae(){this.data.referenceType=`collapsed`}function oe(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=sF(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function se(e){this.data.characterReferenceType=e.type}function ce(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=oF(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=$P(t);let i=this.stack[this.stack.length-1];i.value+=r}function le(e){let t=this.stack.pop();t.position.end=WL(e.end)}function ue(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function de(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function fe(){return{type:`blockquote`,children:[]}}function pe(){return{type:`code`,lang:null,meta:null,value:``}}function me(){return{type:`inlineCode`,value:``}}function he(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function ge(){return{type:`emphasis`,children:[]}}function _e(){return{type:`heading`,depth:0,children:[]}}function ve(){return{type:`break`}}function ye(){return{type:`html`,value:``}}function be(){return{type:`image`,title:null,url:``,alt:null}}function xe(){return{type:`link`,title:null,url:``,children:[]}}function Se(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function Ce(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function we(){return{type:`paragraph`,children:[]}}function Te(){return{type:`strong`,children:[]}}function Ee(){return{type:`text`,value:``}}function De(){return{type:`thematicBreak`}}}function WL(e){return{line:e.line,column:e.column,offset:e.offset}}function GL(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?GL(e,r):KL(e,r)}}function KL(e,t){let n;for(n in t)if(VL.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function qL(e,t){throw e?Error("Cannot close `"+e.type+"` ("+fP({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+fP({start:t.start,end:t.end})+`) is open`):Error("Cannot close document, a token (`"+t.type+"`, "+fP({start:t.start,end:t.end})+`) is still open`)}function JL(e){let t=this;t.parser=n;function n(n){return HL(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function YL(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function XL(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
@@ -127,7 +127,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
127
127
  `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
128
128
  `,...a.current()});return/^[\t ]/.test(l)&&(l=sV(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}pV.peek=mV;function pV(e){return e.value||``}function mV(){return`<`}hV.peek=gV;function hV(e,t,n,r){let i=iV(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function gV(){return`!`}_V.peek=vV;function _V(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function vV(){return`!`}yV.peek=bV;function yV(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function bV(){return"`"}function xV(e,t){let n=JP(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}SV.peek=CV;function SV(e,t,n,r){let i=iV(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(xV(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function CV(e,t,n){return xV(e,n)?`<`:`[`}wV.peek=TV;function wV(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function TV(){return`[`}function EV(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function DV(e){let t=EV(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function OV(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function kV(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function AV(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?OV(n):EV(n),s=e.ordered?o===`.`?`)`:`.`:DV(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),kV(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function jV(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function MV(e,t,n,r){let i=jV(n),a=n.bulletCurrent||EV(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function NV(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var PV=VR([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function FV(e,t,n,r){return(e.children.some(function(e){return PV(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function IV(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}LV.peek=RV;function LV(e,t,n,r){let i=IV(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=cV(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=sV(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=cV(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+sV(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function RV(e,t,n){return n.options.strong||`*`}function zV(e,t,n,r){return n.safe(e.value,r)}function BV(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function VV(e,t,n){let r=(kV(n)+(n.options.ruleSpaces?` `:``)).repeat(BV(n));return n.options.ruleSpaces?r.slice(0,-1):r}var HV={blockquote:JB,break:QB,code:nV,definition:aV,emphasis:lV,hardBreak:QB,heading:fV,html:pV,image:hV,imageReference:_V,inlineCode:yV,link:SV,linkReference:wV,list:AV,listItem:MV,paragraph:NV,root:FV,strong:LV,text:zV,thematicBreak:VV};function UV(){return{enter:{table:WV,tableData:JV,tableHeader:JV,tableRow:KV},exit:{codeText:YV,table:GV,tableData:qV,tableHeader:qV,tableRow:qV}}}function WV(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function GV(e){this.exit(e),this.data.inTable=void 0}function KV(e){this.enter({type:`tableRow`,children:[]},e)}function qV(e){this.exit(e)}function JV(e){this.enter({type:`tableCell`,children:[]},e)}function YV(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,XV));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function XV(e,t){return t===`|`?t:e}function ZV(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
129
129
  `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
130
- `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return GB(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=HV.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function QV(){return{exit:{taskListCheckValueChecked:eH,taskListCheckValueUnchecked:eH,paragraph:tH}}}function $V(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:nH}}}function eH(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function tH(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function nH(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=HV.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function rH(){return[lB(),NB(),RB(),UV(),QV()]}function iH(e){return{extensions:[uB(),PB(e),zB(),ZV(e),$V()]}}var aH={tokenize:yH,partial:!0},oH={tokenize:bH,partial:!0},sH={tokenize:xH,partial:!0},cH={tokenize:SH,partial:!0},lH={tokenize:CH,partial:!0},uH={name:`wwwAutolink`,tokenize:_H,previous:wH},dH={name:`protocolAutolink`,tokenize:vH,previous:TH},fH={name:`emailAutolink`,tokenize:gH,previous:EH},pH={};function mH(){return{text:pH}}for(var hH=48;hH<123;)pH[hH]=fH,hH++,hH===58?hH=65:hH===91&&(hH=97);pH[43]=fH,pH[45]=fH,pH[46]=fH,pH[95]=fH,pH[72]=[fH,dH],pH[104]=[fH,dH],pH[87]=[fH,uH],pH[119]=[fH,uH];function gH(e,t,n){let r=this,i,a;return o;function o(t){return!DH(t)||!EH.call(r,r.previous)||OH(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return DH(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(lH,u,l)(t):t===45||t===95||lF(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&cF(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function _H(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!wH.call(r,r.previous)||OH(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(aH,e.attempt(oH,e.attempt(sH,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function vH(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&TH.call(r,r.previous)&&!OH(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(cF(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||dF(t)||gF(t)||yF(t)||vF(t)?n(t):e.attempt(oH,e.attempt(sH,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function yH(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function bH(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(cH,c,s)(t):t===null||gF(t)||yF(t)||t!==45&&vF(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function xH(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(cH,t,a)(o):o===null||gF(o)||yF(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function SH(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||gF(o)||yF(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||gF(e)||yF(e)?t(e):r(e)}function a(e){return cF(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):cF(t)?(e.consume(t),o):n(t)}}function CH(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return lF(e)?n(e):t(e)}}function wH(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||gF(e)}function TH(e){return!cF(e)}function EH(e){return!(e===47||DH(e))}function DH(e){return e===43||e===45||e===46||e===95||lF(e)}function OH(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var kH={tokenize:LH,partial:!0};function AH(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:PH,continuation:{tokenize:FH},exit:IH}},text:{91:{name:`gfmFootnoteCall`,tokenize:NH},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:jH,resolveTo:MH}}}}function jH(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=sF(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function MH(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function NH(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||gF(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(sF(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return gF(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function PH(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||gF(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=sF(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return gF(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),SF(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function FH(e,t,n){return e.check(LF,t,e.attempt(kH,t,n))}function IH(e){e.exit(`gfmFootnoteDefinition`)}function LH(e,t,n){let r=this;return SF(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function RH(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&eF(o,o.length,0,AF(s,e.slice(r+1,n),t)),eF(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),eF(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=kF(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=kF(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var zH=class{constructor(){this.map=[]}add(e,t,n){BH(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function BH(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function VH(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function HH(){return{flow:{null:{name:`table`,tokenize:UH,resolveAll:WH}}}}function UH(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):hF(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):_F(t)?SF(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||gF(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,_F(t)?SF(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return _F(t)?SF(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||hF(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return _F(t)?SF(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||hF(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||hF(n)?(e.exit(`tableRow`),t(n)):_F(n)?SF(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||gF(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function WH(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new zH;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(KH(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=GH(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=GH(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=GH(f,t,o,i,n,d)):(o[0]=o[1],d=GH(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&KH(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=VH(t.events,n))}return e}function GH(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},qH(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=qH(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=qH(t.events,n[2]),a=qH(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},qH(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function KH(e,t,n,r,i){let a=[],o=qH(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function qH(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var JH={name:`tasklistCheck`,tokenize:XH};function YH(){return{text:{91:JH}}}function XH(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return gF(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return hF(r)?t(r):_F(r)?e.check({tokenize:ZH},t,n)(r):n(r)}}function ZH(e,t,n){return SF(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function QH(e){return rF([mH(),AH(),RH(e),HH(),YH()])}var $H={};function eU(e){let t=this,n=e||$H,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(QH(n)),a.push(rH()),o.push(iH(n))}var tU={p:({children:e})=>(0,I.jsx)(`p`,{style:{marginBlockStart:`0.5em`,marginBlockEnd:`0.5em`},children:e}),blockquote:({children:e})=>(0,I.jsx)(`blockquote`,{style:{marginBlockStart:`0em`,marginBlockEnd:`0em`},children:e}),ul:({children:e})=>(0,I.jsx)(`ul`,{style:{margin:`0.25em 0`,paddingLeft:`1.5em`},children:e}),ol:({children:e})=>(0,I.jsx)(`ol`,{style:{margin:`0.25em 0`,paddingLeft:`1.5em`},children:e})},nU=({children:e})=>(0,I.jsx)(Xz,{remarkPlugins:[eU],components:tU,children:e}),rU=({value:e,onRotate:t,rotating:n})=>{let[r,i]=(0,v.useState)(!1);return(0,I.jsxs)(B,{gap:`xs`,align:`center`,children:[e?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Yp,{children:r?e:`••••••••••••••••`}),(0,I.jsx)(M_,{label:r?`Hide`:`Show`,children:(0,I.jsx)(vu,{variant:`subtle`,size:`sm`,onClick:()=>i(e=>!e),children:r?(0,I.jsx)(lN,{size:14}):(0,I.jsx)(uN,{size:14})})}),(0,I.jsx)(M_,{label:`Copy to clipboard`,children:(0,I.jsx)(vu,{variant:`subtle`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(e),_x.show({title:`Copied`,message:`Copied to clipboard`,color:`green`})},children:(0,I.jsx)(sN,{size:14})})})]}):(0,I.jsx)(V,{c:`dimmed`,size:`sm`,children:`Not set`}),t&&(0,I.jsx)(M_,{label:e?`Rotate key`:`Generate API key`,children:(0,I.jsx)(vu,{variant:`subtle`,size:`sm`,loading:n,onClick:t,children:(0,I.jsx)(dN,{size:14})})})]})};function iU(e){return e>=60?{label:`FATAL`,color:`red`}:e>=50?{label:`ERROR`,color:`red`}:e>=40?{label:`WARN`,color:`yellow`}:e>=30?{label:`INFO`,color:`blue`}:e>=20?{label:`DEBUG`,color:`gray`}:{label:`TRACE`,color:`gray`}}var aU=({fetchLogs:e,logFiles:t})=>{let[n,r]=(0,v.useState)(t?.[0]?.value),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(`all`),u=(0,v.useCallback)(async(t,n)=>{s(!0);try{a(await e(t,n===`errors`?50:void 0))}catch{a(null)}finally{s(!1)}},[e]);return(0,v.useEffect)(()=>{u(n,c)},[n,c,u]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(zv,{order:3,mt:`xl`,children:`Server Logs`}),t&&(0,I.jsx)(jv,{value:n,onChange:e=>e&&r(e),children:(0,I.jsx)(jv.List,{children:t.map(e=>(0,I.jsx)(jv.Tab,{value:e.value,children:e.label},e.value))})}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{size:`xs`,variant:`light`,leftSection:(0,I.jsx)(dN,{size:14}),onClick:()=>u(n,c),loading:o,children:`Refresh`}),(0,I.jsx)(I_,{size:`xs`,value:c,onChange:l,data:[{value:`all`,label:`All`},{value:`errors`,label:`Errors`}]}),i?.fileSize!=null&&(0,I.jsxs)(V,{size:`sm`,c:`dimmed`,children:[`File size: `,Lj(i.fileSize)]})]}),o&&!i?(0,I.jsx)(U,{align:`center`,py:`md`,children:(0,I.jsx)(uu,{size:`sm`})}):i&&i.entries.length>0?(0,I.jsx)(fl,{h:600,children:(0,I.jsx)(R,{style:{backgroundColor:`#1a1a1a`,borderRadius:4,padding:12,fontFamily:`monospace`,fontSize:13},children:[...i.entries].reverse().map((e,t)=>{let{label:n,color:r}=iU(e.level);return(0,I.jsxs)(B,{gap:`xs`,wrap:`nowrap`,align:`flex-start`,style:{lineHeight:1.6},children:[(0,I.jsx)(V,{size:`xs`,c:`dimmed`,style:{fontFamily:`monospace`,whiteSpace:`nowrap`},children:new Date(e.time).toLocaleString()}),(0,I.jsx)(Ap,{size:`xs`,color:r,variant:`filled`,style:{flexShrink:0},children:n}),(0,I.jsxs)(V,{size:`xs`,c:`gray.3`,style:{fontFamily:`monospace`,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:[e.msg,e.detail&&(0,I.jsxs)(`span`,{style:{color:`var(--mantine-color-dimmed)`},children:[` `,e.detail]})]})]},t)})})}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`md`,children:`No log entries found`})]})};function oU(e){return t=>{let n=e.safeParse(t);if(n.success)return{};let r={};for(let e of n.error.issues){let t=e.path.map(String).join(`.`);t&&(r[t]||(r[t]=e.message))}return r}}Object.freeze({status:`aborted`});function Y(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var sU=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},cU=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},lU={};function uU(e){return e&&Object.assign(lU,e),lU}function dU(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function fU(e,t){return typeof t==`bigint`?t.toString():t}function pU(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function mU(e){return e==null}function hU(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function gU(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var _U=Symbol(`evaluating`);function vU(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==_U)return r===void 0&&(r=_U,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function yU(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function bU(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function xU(e){return JSON.stringify(e)}function SU(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var CU=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function wU(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var TU=pU(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function EU(e){if(wU(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(wU(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function DU(e){return EU(e)?{...e}:Array.isArray(e)?[...e]:e}var OU=new Set([`string`,`number`,`symbol`]);function kU(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function AU(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function jU(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function MU(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var NU={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function PU(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return AU(e,bU(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return yU(this,`shape`,e),e},checks:[]}))}function FU(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return AU(e,bU(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return yU(this,`shape`,r),r},checks:[]}))}function IU(e,t){if(!EU(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return AU(e,bU(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return yU(this,`shape`,n),n}}))}function LU(e,t){if(!EU(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return AU(e,bU(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return yU(this,`shape`,n),n}}))}function RU(e,t){return AU(e,bU(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return yU(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function zU(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return AU(t,bU(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return yU(this,`shape`,i),i},checks:[]}))}function BU(e,t,n){return AU(t,bU(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return yU(this,`shape`,i),i}}))}function VU(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function HU(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function UU(e){return typeof e==`string`?e:e?.message}function WU(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=UU(e.inst?._zod.def?.error?.(e))??UU(t?.error?.(e))??UU(n.customError?.(e))??UU(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function GU(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function KU(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var qU=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,fU,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},JU=Y(`$ZodError`,qU),YU=Y(`$ZodError`,qU,{Parent:Error});function XU(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function ZU(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}var QU=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new sU;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>WU(e,a,uU())));throw CU(t,i?.callee),t}return o.value},$U=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>WU(e,a,uU())));throw CU(t,i?.callee),t}return o.value},eW=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new sU;return a.issues.length?{success:!1,error:new(e??JU)(a.issues.map(e=>WU(e,i,uU())))}:{success:!0,data:a.value}},tW=eW(YU),nW=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>WU(e,i,uU())))}:{success:!0,data:a.value}},rW=nW(YU),iW=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return QU(e)(t,n,i)},aW=e=>(t,n,r)=>QU(e)(t,n,r),oW=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return $U(e)(t,n,i)},sW=e=>async(t,n,r)=>$U(e)(t,n,r),cW=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return eW(e)(t,n,i)},lW=e=>(t,n,r)=>eW(e)(t,n,r),uW=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return nW(e)(t,n,i)},dW=e=>async(t,n,r)=>nW(e)(t,n,r),fW=/^[cC][^\s-]{8,}$/,pW=/^[0-9a-z]+$/,mW=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,hW=/^[0-9a-vA-V]{20}$/,gW=/^[A-Za-z0-9]{27}$/,_W=/^[a-zA-Z0-9_-]{21}$/,vW=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,yW=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,bW=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,xW=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,SW=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function CW(){return new RegExp(SW,`u`)}var wW=/^(?:(?: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])$/,TW=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,EW=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,DW=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,OW=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,kW=/^[A-Za-z0-9_-]*$/,AW=/^\+[1-9]\d{6,14}$/,jW=`(?:(?:\\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])))`,MW=RegExp(`^${jW}$`);function NW(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function PW(e){return RegExp(`^${NW(e)}$`)}function FW(e){let t=NW({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${jW}T(?:${r})$`)}var IW=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},LW=/^-?\d+$/,RW=/^-?\d+(?:\.\d+)?$/,zW=/^(?:true|false)$/i,BW=/^null$/i,VW=/^undefined$/i,HW=/^[^A-Z]*$/,UW=/^[^a-z]*$/,WW=Y(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),GW={number:`number`,bigint:`bigint`,object:`date`},KW=Y(`$ZodCheckLessThan`,(e,t)=>{WW.init(e,t);let n=GW[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),qW=Y(`$ZodCheckGreaterThan`,(e,t)=>{WW.init(e,t);let n=GW[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),JW=Y(`$ZodCheckMultipleOf`,(e,t)=>{WW.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):gU(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),YW=Y(`$ZodCheckNumberFormat`,(e,t)=>{WW.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=NU[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=LW)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),XW=Y(`$ZodCheckMaxLength`,(e,t)=>{var n;WW.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!mU(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=GU(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ZW=Y(`$ZodCheckMinLength`,(e,t)=>{var n;WW.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!mU(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=GU(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),QW=Y(`$ZodCheckLengthEquals`,(e,t)=>{var n;WW.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!mU(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=GU(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),$W=Y(`$ZodCheckStringFormat`,(e,t)=>{var n,r;WW.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),eG=Y(`$ZodCheckRegex`,(e,t)=>{$W.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),tG=Y(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=HW,$W.init(e,t)}),nG=Y(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=UW,$W.init(e,t)}),rG=Y(`$ZodCheckIncludes`,(e,t)=>{WW.init(e,t);let n=kU(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),iG=Y(`$ZodCheckStartsWith`,(e,t)=>{WW.init(e,t);let n=RegExp(`^${kU(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),aG=Y(`$ZodCheckEndsWith`,(e,t)=>{WW.init(e,t);let n=RegExp(`.*${kU(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),oG=Y(`$ZodCheckOverwrite`,(e,t)=>{WW.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),sG=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
130
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return GB(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=HV.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function QV(){return{exit:{taskListCheckValueChecked:eH,taskListCheckValueUnchecked:eH,paragraph:tH}}}function $V(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:nH}}}function eH(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function tH(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function nH(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=HV.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function rH(){return[lB(),NB(),RB(),UV(),QV()]}function iH(e){return{extensions:[uB(),PB(e),zB(),ZV(e),$V()]}}var aH={tokenize:yH,partial:!0},oH={tokenize:bH,partial:!0},sH={tokenize:xH,partial:!0},cH={tokenize:SH,partial:!0},lH={tokenize:CH,partial:!0},uH={name:`wwwAutolink`,tokenize:_H,previous:wH},dH={name:`protocolAutolink`,tokenize:vH,previous:TH},fH={name:`emailAutolink`,tokenize:gH,previous:EH},pH={};function mH(){return{text:pH}}for(var hH=48;hH<123;)pH[hH]=fH,hH++,hH===58?hH=65:hH===91&&(hH=97);pH[43]=fH,pH[45]=fH,pH[46]=fH,pH[95]=fH,pH[72]=[fH,dH],pH[104]=[fH,dH],pH[87]=[fH,uH],pH[119]=[fH,uH];function gH(e,t,n){let r=this,i,a;return o;function o(t){return!DH(t)||!EH.call(r,r.previous)||OH(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return DH(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(lH,u,l)(t):t===45||t===95||lF(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&cF(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function _H(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!wH.call(r,r.previous)||OH(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(aH,e.attempt(oH,e.attempt(sH,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function vH(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&TH.call(r,r.previous)&&!OH(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(cF(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||dF(t)||gF(t)||yF(t)||vF(t)?n(t):e.attempt(oH,e.attempt(sH,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function yH(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function bH(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(cH,c,s)(t):t===null||gF(t)||yF(t)||t!==45&&vF(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function xH(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(cH,t,a)(o):o===null||gF(o)||yF(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function SH(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||gF(o)||yF(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||gF(e)||yF(e)?t(e):r(e)}function a(e){return cF(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):cF(t)?(e.consume(t),o):n(t)}}function CH(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return lF(e)?n(e):t(e)}}function wH(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||gF(e)}function TH(e){return!cF(e)}function EH(e){return!(e===47||DH(e))}function DH(e){return e===43||e===45||e===46||e===95||lF(e)}function OH(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var kH={tokenize:LH,partial:!0};function AH(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:PH,continuation:{tokenize:FH},exit:IH}},text:{91:{name:`gfmFootnoteCall`,tokenize:NH},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:jH,resolveTo:MH}}}}function jH(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=sF(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function MH(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function NH(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||gF(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(sF(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return gF(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function PH(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||gF(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=sF(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return gF(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),SF(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function FH(e,t,n){return e.check(LF,t,e.attempt(kH,t,n))}function IH(e){e.exit(`gfmFootnoteDefinition`)}function LH(e,t,n){let r=this;return SF(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function RH(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&eF(o,o.length,0,AF(s,e.slice(r+1,n),t)),eF(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),eF(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=kF(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=kF(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var zH=class{constructor(){this.map=[]}add(e,t,n){BH(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function BH(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function VH(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function HH(){return{flow:{null:{name:`table`,tokenize:UH,resolveAll:WH}}}}function UH(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):hF(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):_F(t)?SF(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||gF(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,_F(t)?SF(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return _F(t)?SF(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||hF(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return _F(t)?SF(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||hF(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||hF(n)?(e.exit(`tableRow`),t(n)):_F(n)?SF(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||gF(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function WH(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new zH;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(KH(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=GH(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=GH(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=GH(f,t,o,i,n,d)):(o[0]=o[1],d=GH(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&KH(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=VH(t.events,n))}return e}function GH(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},qH(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=qH(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=qH(t.events,n[2]),a=qH(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},qH(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function KH(e,t,n,r,i){let a=[],o=qH(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function qH(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var JH={name:`tasklistCheck`,tokenize:XH};function YH(){return{text:{91:JH}}}function XH(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return gF(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return hF(r)?t(r):_F(r)?e.check({tokenize:ZH},t,n)(r):n(r)}}function ZH(e,t,n){return SF(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function QH(e){return rF([mH(),AH(),RH(e),HH(),YH()])}var $H={};function eU(e){let t=this,n=e||$H,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(QH(n)),a.push(rH()),o.push(iH(n))}var tU={p:({children:e})=>(0,I.jsx)(`p`,{style:{marginBlockStart:`0.5em`,marginBlockEnd:`0.5em`},children:e}),blockquote:({children:e})=>(0,I.jsx)(`blockquote`,{style:{marginBlockStart:`0em`,marginBlockEnd:`0em`},children:e}),ul:({children:e})=>(0,I.jsx)(`ul`,{style:{margin:`0.25em 0`,paddingLeft:`1.5em`},children:e}),ol:({children:e})=>(0,I.jsx)(`ol`,{style:{margin:`0.25em 0`,paddingLeft:`1.5em`},children:e})},nU=({children:e})=>(0,I.jsx)(Xz,{remarkPlugins:[eU],components:tU,children:e}),rU=({value:e,onRotate:t,rotating:n})=>{let[r,i]=(0,v.useState)(!1);return(0,I.jsxs)(B,{gap:`xs`,align:`center`,children:[e?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Yp,{children:r?e:`••••••••••••••••`}),(0,I.jsx)(M_,{label:r?`Hide`:`Show`,children:(0,I.jsx)(vu,{variant:`subtle`,size:`sm`,onClick:()=>i(e=>!e),children:r?(0,I.jsx)(lN,{size:14}):(0,I.jsx)(uN,{size:14})})}),(0,I.jsx)(M_,{label:`Copy to clipboard`,children:(0,I.jsx)(vu,{variant:`subtle`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(e),_x.show({title:`Copied`,message:`Copied to clipboard`,color:`green`})},children:(0,I.jsx)(sN,{size:14})})})]}):(0,I.jsx)(V,{c:`dimmed`,size:`sm`,children:`Not set`}),t&&(0,I.jsx)(M_,{label:e?`Rotate key`:`Generate API key`,children:(0,I.jsx)(vu,{variant:`subtle`,size:`sm`,loading:n,onClick:t,children:(0,I.jsx)(dN,{size:14})})})]})};function iU(e){return e>=60?{label:`FATAL`,color:`red`}:e>=50?{label:`ERROR`,color:`red`}:e>=40?{label:`WARN`,color:`yellow`}:e>=30?{label:`INFO`,color:`blue`}:e>=20?{label:`DEBUG`,color:`gray`}:{label:`TRACE`,color:`gray`}}var aU=({fetchLogs:e,logFiles:t})=>{let[n,r]=(0,v.useState)(t?.[0]?.value),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(`all`),u=(0,v.useCallback)(async(t,n)=>{s(!0);try{a(await e(t,n===`errors`?50:void 0))}catch{a(null)}finally{s(!1)}},[e]);return(0,v.useEffect)(()=>{u(n,c)},[n,c,u]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(zv,{order:3,mt:`xl`,children:`Server Logs`}),t&&(0,I.jsx)(jv,{value:n,onChange:e=>e&&r(e),children:(0,I.jsx)(jv.List,{children:t.map(e=>(0,I.jsx)(jv.Tab,{value:e.value,children:e.label},e.value))})}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{size:`xs`,variant:`light`,leftSection:(0,I.jsx)(dN,{size:14}),onClick:()=>u(n,c),loading:o,children:`Refresh`}),(0,I.jsx)(I_,{size:`xs`,value:c,onChange:l,data:[{value:`all`,label:`All`},{value:`errors`,label:`Errors`}]}),i?.fileSize!=null&&(0,I.jsxs)(V,{size:`sm`,c:`dimmed`,children:[`File size: `,Lj(i.fileSize)]})]}),o&&!i?(0,I.jsx)(U,{align:`center`,py:`md`,children:(0,I.jsx)(uu,{size:`sm`})}):i&&i.entries.length>0?(0,I.jsx)(fl,{h:600,children:(0,I.jsx)(R,{style:{backgroundColor:`#1a1a1a`,borderRadius:4,padding:12,fontFamily:`monospace`,fontSize:13},children:[...i.entries].reverse().map((e,t)=>{let{label:n,color:r}=iU(e.level);return(0,I.jsxs)(B,{gap:`xs`,wrap:`nowrap`,align:`flex-start`,style:{lineHeight:1.6},children:[(0,I.jsx)(V,{size:`xs`,c:`dimmed`,style:{fontFamily:`monospace`,whiteSpace:`nowrap`},children:new Date(e.time).toLocaleString()}),(0,I.jsx)(Ap,{size:`xs`,color:r,variant:`filled`,style:{flexShrink:0},children:n}),(0,I.jsxs)(V,{size:`xs`,c:`gray.3`,style:{fontFamily:`monospace`,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:[e.msg,e.detail&&(0,I.jsxs)(`span`,{style:{color:`var(--mantine-color-dimmed)`},children:[` `,e.detail]})]})]},t)})})}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`md`,children:`No log entries found`})]})};function oU(e){return t=>{let n=e.safeParse(t);if(n.success)return{};let r={};for(let e of n.error.issues){let t=e.path.map(String).join(`.`);t&&(r[t]||(r[t]=e.message))}return r}}Object.freeze({status:`aborted`});function Y(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var sU=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},cU=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},lU={jitless:!0};function uU(e){return e&&Object.assign(lU,e),lU}function dU(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function fU(e,t){return typeof t==`bigint`?t.toString():t}function pU(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function mU(e){return e==null}function hU(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function gU(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var _U=Symbol(`evaluating`);function vU(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==_U)return r===void 0&&(r=_U,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function yU(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function bU(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function xU(e){return JSON.stringify(e)}function SU(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var CU=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function wU(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var TU=pU(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function EU(e){if(wU(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(wU(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function DU(e){return EU(e)?{...e}:Array.isArray(e)?[...e]:e}var OU=new Set([`string`,`number`,`symbol`]);function kU(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function AU(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function jU(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function MU(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var NU={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function PU(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return AU(e,bU(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return yU(this,`shape`,e),e},checks:[]}))}function FU(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return AU(e,bU(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return yU(this,`shape`,r),r},checks:[]}))}function IU(e,t){if(!EU(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return AU(e,bU(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return yU(this,`shape`,n),n}}))}function LU(e,t){if(!EU(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return AU(e,bU(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return yU(this,`shape`,n),n}}))}function RU(e,t){return AU(e,bU(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return yU(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function zU(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return AU(t,bU(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return yU(this,`shape`,i),i},checks:[]}))}function BU(e,t,n){return AU(t,bU(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return yU(this,`shape`,i),i}}))}function VU(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function HU(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function UU(e){return typeof e==`string`?e:e?.message}function WU(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=UU(e.inst?._zod.def?.error?.(e))??UU(t?.error?.(e))??UU(n.customError?.(e))??UU(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function GU(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function KU(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var qU=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,fU,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},JU=Y(`$ZodError`,qU),YU=Y(`$ZodError`,qU,{Parent:Error});function XU(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function ZU(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}var QU=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new sU;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>WU(e,a,uU())));throw CU(t,i?.callee),t}return o.value},$U=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>WU(e,a,uU())));throw CU(t,i?.callee),t}return o.value},eW=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new sU;return a.issues.length?{success:!1,error:new(e??JU)(a.issues.map(e=>WU(e,i,uU())))}:{success:!0,data:a.value}},tW=eW(YU),nW=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>WU(e,i,uU())))}:{success:!0,data:a.value}},rW=nW(YU),iW=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return QU(e)(t,n,i)},aW=e=>(t,n,r)=>QU(e)(t,n,r),oW=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return $U(e)(t,n,i)},sW=e=>async(t,n,r)=>$U(e)(t,n,r),cW=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return eW(e)(t,n,i)},lW=e=>(t,n,r)=>eW(e)(t,n,r),uW=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return nW(e)(t,n,i)},dW=e=>async(t,n,r)=>nW(e)(t,n,r),fW=/^[cC][^\s-]{8,}$/,pW=/^[0-9a-z]+$/,mW=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,hW=/^[0-9a-vA-V]{20}$/,gW=/^[A-Za-z0-9]{27}$/,_W=/^[a-zA-Z0-9_-]{21}$/,vW=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,yW=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,bW=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,xW=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,SW=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function CW(){return new RegExp(SW,`u`)}var wW=/^(?:(?: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])$/,TW=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,EW=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,DW=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,OW=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,kW=/^[A-Za-z0-9_-]*$/,AW=/^\+[1-9]\d{6,14}$/,jW=`(?:(?:\\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])))`,MW=RegExp(`^${jW}$`);function NW(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function PW(e){return RegExp(`^${NW(e)}$`)}function FW(e){let t=NW({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${jW}T(?:${r})$`)}var IW=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},LW=/^-?\d+$/,RW=/^-?\d+(?:\.\d+)?$/,zW=/^(?:true|false)$/i,BW=/^null$/i,VW=/^undefined$/i,HW=/^[^A-Z]*$/,UW=/^[^a-z]*$/,WW=Y(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),GW={number:`number`,bigint:`bigint`,object:`date`},KW=Y(`$ZodCheckLessThan`,(e,t)=>{WW.init(e,t);let n=GW[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),qW=Y(`$ZodCheckGreaterThan`,(e,t)=>{WW.init(e,t);let n=GW[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),JW=Y(`$ZodCheckMultipleOf`,(e,t)=>{WW.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):gU(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),YW=Y(`$ZodCheckNumberFormat`,(e,t)=>{WW.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=NU[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=LW)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),XW=Y(`$ZodCheckMaxLength`,(e,t)=>{var n;WW.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!mU(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=GU(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ZW=Y(`$ZodCheckMinLength`,(e,t)=>{var n;WW.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!mU(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=GU(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),QW=Y(`$ZodCheckLengthEquals`,(e,t)=>{var n;WW.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!mU(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=GU(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),$W=Y(`$ZodCheckStringFormat`,(e,t)=>{var n,r;WW.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),eG=Y(`$ZodCheckRegex`,(e,t)=>{$W.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),tG=Y(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=HW,$W.init(e,t)}),nG=Y(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=UW,$W.init(e,t)}),rG=Y(`$ZodCheckIncludes`,(e,t)=>{WW.init(e,t);let n=kU(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),iG=Y(`$ZodCheckStartsWith`,(e,t)=>{WW.init(e,t);let n=RegExp(`^${kU(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),aG=Y(`$ZodCheckEndsWith`,(e,t)=>{WW.init(e,t);let n=RegExp(`.*${kU(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),oG=Y(`$ZodCheckOverwrite`,(e,t)=>{WW.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),sG=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
131
131
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
132
132
  `))}},cG={major:4,minor:3,patch:6},lG=Y(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=cG;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=VU(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new sU;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=VU(e,t))});else{if(e.issues.length===t)continue;r||=VU(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(VU(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new sU;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new sU;return o.then(e=>t(e,r,a))}return t(o,r,a)}}vU(e,`~standard`,()=>({validate:t=>{try{let n=tW(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return rW(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),uG=Y(`$ZodString`,(e,t)=>{lG.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??IW(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),dG=Y(`$ZodStringFormat`,(e,t)=>{$W.init(e,t),uG.init(e,t)}),fG=Y(`$ZodGUID`,(e,t)=>{t.pattern??=yW,dG.init(e,t)}),pG=Y(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=bW(e)}else t.pattern??=bW();dG.init(e,t)}),mG=Y(`$ZodEmail`,(e,t)=>{t.pattern??=xW,dG.init(e,t)}),hG=Y(`$ZodURL`,(e,t)=>{dG.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),gG=Y(`$ZodEmoji`,(e,t)=>{t.pattern??=CW(),dG.init(e,t)}),_G=Y(`$ZodNanoID`,(e,t)=>{t.pattern??=_W,dG.init(e,t)}),vG=Y(`$ZodCUID`,(e,t)=>{t.pattern??=fW,dG.init(e,t)}),yG=Y(`$ZodCUID2`,(e,t)=>{t.pattern??=pW,dG.init(e,t)}),bG=Y(`$ZodULID`,(e,t)=>{t.pattern??=mW,dG.init(e,t)}),xG=Y(`$ZodXID`,(e,t)=>{t.pattern??=hW,dG.init(e,t)}),SG=Y(`$ZodKSUID`,(e,t)=>{t.pattern??=gW,dG.init(e,t)}),CG=Y(`$ZodISODateTime`,(e,t)=>{t.pattern??=FW(t),dG.init(e,t)}),wG=Y(`$ZodISODate`,(e,t)=>{t.pattern??=MW,dG.init(e,t)}),TG=Y(`$ZodISOTime`,(e,t)=>{t.pattern??=PW(t),dG.init(e,t)}),EG=Y(`$ZodISODuration`,(e,t)=>{t.pattern??=vW,dG.init(e,t)}),DG=Y(`$ZodIPv4`,(e,t)=>{t.pattern??=wW,dG.init(e,t),e._zod.bag.format=`ipv4`}),OG=Y(`$ZodIPv6`,(e,t)=>{t.pattern??=TW,dG.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),kG=Y(`$ZodCIDRv4`,(e,t)=>{t.pattern??=EW,dG.init(e,t)}),AG=Y(`$ZodCIDRv6`,(e,t)=>{t.pattern??=DW,dG.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function jG(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var MG=Y(`$ZodBase64`,(e,t)=>{t.pattern??=OW,dG.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{jG(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function NG(e){if(!kW.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return jG(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var PG=Y(`$ZodBase64URL`,(e,t)=>{t.pattern??=kW,dG.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{NG(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),FG=Y(`$ZodE164`,(e,t)=>{t.pattern??=AW,dG.init(e,t)});function IG(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var LG=Y(`$ZodJWT`,(e,t)=>{dG.init(e,t),e._zod.check=n=>{IG(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),RG=Y(`$ZodNumber`,(e,t)=>{lG.init(e,t),e._zod.pattern=e._zod.bag.pattern??RW,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),zG=Y(`$ZodNumberFormat`,(e,t)=>{YW.init(e,t),RG.init(e,t)}),BG=Y(`$ZodBoolean`,(e,t)=>{lG.init(e,t),e._zod.pattern=zW,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),VG=Y(`$ZodUndefined`,(e,t)=>{lG.init(e,t),e._zod.pattern=VW,e._zod.values=new Set([void 0]),e._zod.optin=`optional`,e._zod.optout=`optional`,e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),HG=Y(`$ZodNull`,(e,t)=>{lG.init(e,t),e._zod.pattern=BW,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),UG=Y(`$ZodAny`,(e,t)=>{lG.init(e,t),e._zod.parse=e=>e}),WG=Y(`$ZodUnknown`,(e,t)=>{lG.init(e,t),e._zod.parse=e=>e}),GG=Y(`$ZodNever`,(e,t)=>{lG.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function KG(e,t,n){e.issues.length&&t.issues.push(...HU(n,e.issues)),t.value[n]=e.value}var qG=Y(`$ZodArray`,(e,t)=>{lG.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>KG(t,n,e))):KG(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function JG(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...HU(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function YG(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=MU(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function XG(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optout===`optional`;for(let i in t){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>JG(e,n,i,t,u))):JG(a,n,i,t,u)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var ZG=Y(`$ZodObject`,(e,t)=>{if(lG.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=pU(()=>YG(t));vU(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=wU,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optout===`optional`,i=n._zod.run({value:s[e],issues:[]},o);i instanceof Promise?c.push(i.then(n=>JG(n,t,e,s,r))):JG(i,t,e,s,r)}return i?XG(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),QG=Y(`$ZodObjectJIT`,(e,t)=>{ZG.init(e,t);let n=e._zod.parse,r=pU(()=>YG(t)),i=e=>{let t=new sG([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=xU(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=xU(r),s=e[r]?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),s?t.write(`
133
133
  if (${n}.issues.length) {
@@ -165,4 +165,4 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
165
165
 
166
166
  `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=wU,s=!lU.jitless,c=s&&TU.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?XG([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function $G(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!VU(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>WU(e,r,uU())))}),t)}var eK=Y(`$ZodUnion`,(e,t)=>{lG.init(e,t),vU(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),vU(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),vU(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),vU(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>hU(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>$G(t,i,e,a)):$G(s,i,e,a)}}),tK=Y(`$ZodIntersection`,(e,t)=>{lG.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>rK(e,t,n)):rK(e,i,a)}});function nK(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(EU(e)&&EU(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=nK(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=nK(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function rK(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),VU(e))return e;let o=nK(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var iK=Y(`$ZodEnum`,(e,t)=>{lG.init(e,t);let n=dU(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>OU.has(typeof e)).map(e=>typeof e==`string`?kU(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),aK=Y(`$ZodLiteral`,(e,t)=>{if(lG.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?kU(e):e?kU(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),oK=Y(`$ZodTransform`,(e,t)=>{lG.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new cU(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new sU;return n.value=i,n}});function sK(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var cK=Y(`$ZodOptional`,(e,t)=>{lG.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,vU(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),vU(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${hU(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>sK(t,e.value)):sK(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),lK=Y(`$ZodExactOptional`,(e,t)=>{cK.init(e,t),vU(e._zod,`values`,()=>t.innerType._zod.values),vU(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),uK=Y(`$ZodNullable`,(e,t)=>{lG.init(e,t),vU(e._zod,`optin`,()=>t.innerType._zod.optin),vU(e._zod,`optout`,()=>t.innerType._zod.optout),vU(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${hU(e.source)}|null)$`):void 0}),vU(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),dK=Y(`$ZodDefault`,(e,t)=>{lG.init(e,t),e._zod.optin=`optional`,vU(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>fK(e,t)):fK(r,t)}});function fK(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var pK=Y(`$ZodPrefault`,(e,t)=>{lG.init(e,t),e._zod.optin=`optional`,vU(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),mK=Y(`$ZodNonOptional`,(e,t)=>{lG.init(e,t),vU(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>hK(t,e)):hK(i,e)}});function hK(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var gK=Y(`$ZodCatch`,(e,t)=>{lG.init(e,t),vU(e._zod,`optin`,()=>t.innerType._zod.optin),vU(e._zod,`optout`,()=>t.innerType._zod.optout),vU(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>WU(e,n,uU()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>WU(e,n,uU()))},input:e.value}),e.issues=[]),e)}}),_K=Y(`$ZodPipe`,(e,t)=>{lG.init(e,t),vU(e._zod,`values`,()=>t.in._zod.values),vU(e._zod,`optin`,()=>t.in._zod.optin),vU(e._zod,`optout`,()=>t.out._zod.optout),vU(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>vK(e,t.in,n)):vK(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>vK(e,t.out,n)):vK(r,t.out,n)}});function vK(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var yK=Y(`$ZodReadonly`,(e,t)=>{lG.init(e,t),vU(e._zod,`propValues`,()=>t.innerType._zod.propValues),vU(e._zod,`values`,()=>t.innerType._zod.values),vU(e._zod,`optin`,()=>t.innerType?._zod?.optin),vU(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(bK):bK(r)}});function bK(e){return e.value=Object.freeze(e.value),e}var xK=Y(`$ZodCustom`,(e,t)=>{WW.init(e,t),lG.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>SK(t,n,r,e));SK(i,n,r,e)}});function SK(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(KU(e))}}var CK,wK=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function TK(){return new wK}(CK=globalThis).__zod_globalRegistry??(CK.__zod_globalRegistry=TK());var EK=globalThis.__zod_globalRegistry;function DK(e,t){return new e({type:`string`,...jU(t)})}function OK(e,t){return new e({type:`string`,coerce:!0,...jU(t)})}function kK(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...jU(t)})}function AK(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...jU(t)})}function jK(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...jU(t)})}function MK(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...jU(t)})}function NK(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...jU(t)})}function PK(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...jU(t)})}function FK(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...jU(t)})}function IK(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...jU(t)})}function LK(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...jU(t)})}function RK(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...jU(t)})}function zK(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...jU(t)})}function BK(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...jU(t)})}function VK(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...jU(t)})}function HK(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...jU(t)})}function UK(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...jU(t)})}function WK(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...jU(t)})}function GK(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...jU(t)})}function KK(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...jU(t)})}function qK(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...jU(t)})}function JK(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...jU(t)})}function YK(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...jU(t)})}function XK(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...jU(t)})}function ZK(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...jU(t)})}function QK(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...jU(t)})}function $K(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...jU(t)})}function eq(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...jU(t)})}function tq(e,t){return new e({type:`number`,checks:[],...jU(t)})}function nq(e,t){return new e({type:`number`,coerce:!0,checks:[],...jU(t)})}function rq(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...jU(t)})}function iq(e,t){return new e({type:`boolean`,...jU(t)})}function aq(e,t){return new e({type:`undefined`,...jU(t)})}function oq(e,t){return new e({type:`null`,...jU(t)})}function sq(e){return new e({type:`any`})}function cq(e){return new e({type:`unknown`})}function lq(e,t){return new e({type:`never`,...jU(t)})}function uq(e,t){return new KW({check:`less_than`,...jU(t),value:e,inclusive:!1})}function dq(e,t){return new KW({check:`less_than`,...jU(t),value:e,inclusive:!0})}function fq(e,t){return new qW({check:`greater_than`,...jU(t),value:e,inclusive:!1})}function pq(e,t){return new qW({check:`greater_than`,...jU(t),value:e,inclusive:!0})}function mq(e,t){return new JW({check:`multiple_of`,...jU(t),value:e})}function hq(e,t){return new XW({check:`max_length`,...jU(t),maximum:e})}function gq(e,t){return new ZW({check:`min_length`,...jU(t),minimum:e})}function _q(e,t){return new QW({check:`length_equals`,...jU(t),length:e})}function vq(e,t){return new eG({check:`string_format`,format:`regex`,...jU(t),pattern:e})}function yq(e){return new tG({check:`string_format`,format:`lowercase`,...jU(e)})}function bq(e){return new nG({check:`string_format`,format:`uppercase`,...jU(e)})}function xq(e,t){return new rG({check:`string_format`,format:`includes`,...jU(t),includes:e})}function Sq(e,t){return new iG({check:`string_format`,format:`starts_with`,...jU(t),prefix:e})}function Cq(e,t){return new aG({check:`string_format`,format:`ends_with`,...jU(t),suffix:e})}function wq(e){return new oG({check:`overwrite`,tx:e})}function Tq(e){return wq(t=>t.normalize(e))}function Eq(){return wq(e=>e.trim())}function Dq(){return wq(e=>e.toLowerCase())}function Oq(){return wq(e=>e.toUpperCase())}function kq(){return wq(e=>SU(e))}function Aq(e,t,n){return new e({type:`array`,element:t,...jU(n)})}function jq(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...jU(n)})}function Mq(e){let t=Nq(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(KU(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(KU(r))}},e(n.value,n)));return t}function Nq(e,t){let n=new WW({check:`custom`,...jU(t)});return n._zod.check=e,n}function Pq(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??EK,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function Fq(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Fq(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Rq(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Iq(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
167
167
 
168
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Lq(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:Bq(t,`input`,e.processors),output:Bq(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Rq(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Rq(r.element,n);if(r.type===`set`)return Rq(r.valueType,n);if(r.type===`lazy`)return Rq(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return Rq(r.innerType,n);if(r.type===`intersection`)return Rq(r.left,n)||Rq(r.right,n);if(r.type===`record`||r.type===`map`)return Rq(r.keyType,n)||Rq(r.valueType,n);if(r.type===`pipe`)return Rq(r.in,n)||Rq(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Rq(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Rq(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Rq(e,n))return!0;return!!(r.rest&&Rq(r.rest,n))}return!1}var zq=(e,t={})=>n=>{let r=Pq({...n,processors:t});return Fq(e,r),Iq(r,e),Lq(r,e)},Bq=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Pq({...i??{},target:a,io:t,processors:n});return Fq(e,o),Iq(o,e),Lq(o,e)},Vq={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Hq=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Vq[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Uq=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},Wq=(e,t,n,r)=>{n.type=`boolean`},Gq=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Kq=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},qq=(e,t,n,r)=>{n.not={}},Jq=(e,t,n,r)=>{let i=e._zod.def,a=dU(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Yq=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Xq=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Zq=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Qq=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Fq(a.element,t,{...r,path:[...r.path,`items`]})},$q=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Fq(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Fq(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},eJ=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Fq(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},tJ=(e,t,n,r)=>{let i=e._zod.def,a=Fq(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Fq(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},nJ=(e,t,n,r)=>{let i=e._zod.def,a=Fq(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},rJ=(e,t,n,r)=>{let i=e._zod.def;Fq(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},iJ=(e,t,n,r)=>{let i=e._zod.def;Fq(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},aJ=(e,t,n,r)=>{let i=e._zod.def;Fq(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},oJ=(e,t,n,r)=>{let i=e._zod.def;Fq(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},sJ=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;Fq(a,t,r);let o=t.seen.get(e);o.ref=a},cJ=(e,t,n,r)=>{let i=e._zod.def;Fq(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},lJ=(e,t,n,r)=>{let i=e._zod.def;Fq(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},uJ=Y(`ZodISODateTime`,(e,t)=>{CG.init(e,t),FJ.init(e,t)});function dJ(e){return ZK(uJ,e)}var fJ=Y(`ZodISODate`,(e,t)=>{wG.init(e,t),FJ.init(e,t)});function pJ(e){return QK(fJ,e)}var mJ=Y(`ZodISOTime`,(e,t)=>{TG.init(e,t),FJ.init(e,t)});function hJ(e){return $K(mJ,e)}var gJ=Y(`ZodISODuration`,(e,t)=>{EG.init(e,t),FJ.init(e,t)});function _J(e){return eq(gJ,e)}var vJ=(e,t)=>{JU.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>ZU(e,t)},flatten:{value:t=>XU(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,fU,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,fU,2)}},isEmpty:{get(){return e.issues.length===0}}})};Y(`ZodError`,vJ);var yJ=Y(`ZodError`,vJ,{Parent:Error}),bJ=QU(yJ),xJ=$U(yJ),SJ=eW(yJ),CJ=nW(yJ),wJ=iW(yJ),TJ=aW(yJ),EJ=oW(yJ),DJ=sW(yJ),OJ=cW(yJ),kJ=lW(yJ),AJ=uW(yJ),jJ=dW(yJ),MJ=Y(`ZodType`,(e,t)=>(lG.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Bq(e,`input`),output:Bq(e,`output`)}}),e.toJSONSchema=zq(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(bU(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>AU(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>bJ(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>SJ(e,t,n),e.parseAsync=async(t,n)=>xJ(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>CJ(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>wJ(e,t,n),e.decode=(t,n)=>TJ(e,t,n),e.encodeAsync=async(t,n)=>EJ(e,t,n),e.decodeAsync=async(t,n)=>DJ(e,t,n),e.safeEncode=(t,n)=>OJ(e,t,n),e.safeDecode=(t,n)=>kJ(e,t,n),e.safeEncodeAsync=async(t,n)=>AJ(e,t,n),e.safeDecodeAsync=async(t,n)=>jJ(e,t,n),e.refine=(t,n)=>e.check(qY(t,n)),e.superRefine=t=>e.check(JY(t)),e.overwrite=t=>e.check(wq(t)),e.optional=()=>kY(e),e.exactOptional=()=>jY(e),e.nullable=()=>NY(e),e.nullish=()=>kY(NY(e)),e.nonoptional=t=>zY(e,t),e.array=()=>Q(e),e.or=t=>yY([e,t]),e.and=t=>xY(e,t),e.transform=t=>UY(e,DY(t)),e.default=t=>FY(e,t),e.prefault=t=>LY(e,t),e.catch=t=>VY(e,t),e.pipe=t=>UY(e,t),e.readonly=()=>GY(e),e.describe=t=>{let n=e.clone();return EK.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return EK.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return EK.get(e);let n=e.clone();return EK.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),NJ=Y(`_ZodString`,(e,t)=>{uG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hq(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(vq(...t)),e.includes=(...t)=>e.check(xq(...t)),e.startsWith=(...t)=>e.check(Sq(...t)),e.endsWith=(...t)=>e.check(Cq(...t)),e.min=(...t)=>e.check(gq(...t)),e.max=(...t)=>e.check(hq(...t)),e.length=(...t)=>e.check(_q(...t)),e.nonempty=(...t)=>e.check(gq(1,...t)),e.lowercase=t=>e.check(yq(t)),e.uppercase=t=>e.check(bq(t)),e.trim=()=>e.check(Eq()),e.normalize=(...t)=>e.check(Tq(...t)),e.toLowerCase=()=>e.check(Dq()),e.toUpperCase=()=>e.check(Oq()),e.slugify=()=>e.check(kq())}),PJ=Y(`ZodString`,(e,t)=>{uG.init(e,t),NJ.init(e,t),e.email=t=>e.check(kK(IJ,t)),e.url=t=>e.check(FK(zJ,t)),e.jwt=t=>e.check(XK(eY,t)),e.emoji=t=>e.check(IK(BJ,t)),e.guid=t=>e.check(AK(LJ,t)),e.uuid=t=>e.check(jK(RJ,t)),e.uuidv4=t=>e.check(MK(RJ,t)),e.uuidv6=t=>e.check(NK(RJ,t)),e.uuidv7=t=>e.check(PK(RJ,t)),e.nanoid=t=>e.check(LK(VJ,t)),e.guid=t=>e.check(AK(LJ,t)),e.cuid=t=>e.check(RK(HJ,t)),e.cuid2=t=>e.check(zK(UJ,t)),e.ulid=t=>e.check(BK(WJ,t)),e.base64=t=>e.check(qK(ZJ,t)),e.base64url=t=>e.check(JK(QJ,t)),e.xid=t=>e.check(VK(GJ,t)),e.ksuid=t=>e.check(HK(KJ,t)),e.ipv4=t=>e.check(UK(qJ,t)),e.ipv6=t=>e.check(WK(JJ,t)),e.cidrv4=t=>e.check(GK(YJ,t)),e.cidrv6=t=>e.check(KK(XJ,t)),e.e164=t=>e.check(YK($J,t)),e.datetime=t=>e.check(dJ(t)),e.date=t=>e.check(pJ(t)),e.time=t=>e.check(hJ(t)),e.duration=t=>e.check(_J(t))});function X(e){return DK(PJ,e)}var FJ=Y(`ZodStringFormat`,(e,t)=>{dG.init(e,t),NJ.init(e,t)}),IJ=Y(`ZodEmail`,(e,t)=>{mG.init(e,t),FJ.init(e,t)}),LJ=Y(`ZodGUID`,(e,t)=>{fG.init(e,t),FJ.init(e,t)}),RJ=Y(`ZodUUID`,(e,t)=>{pG.init(e,t),FJ.init(e,t)}),zJ=Y(`ZodURL`,(e,t)=>{hG.init(e,t),FJ.init(e,t)}),BJ=Y(`ZodEmoji`,(e,t)=>{gG.init(e,t),FJ.init(e,t)}),VJ=Y(`ZodNanoID`,(e,t)=>{_G.init(e,t),FJ.init(e,t)}),HJ=Y(`ZodCUID`,(e,t)=>{vG.init(e,t),FJ.init(e,t)}),UJ=Y(`ZodCUID2`,(e,t)=>{yG.init(e,t),FJ.init(e,t)}),WJ=Y(`ZodULID`,(e,t)=>{bG.init(e,t),FJ.init(e,t)}),GJ=Y(`ZodXID`,(e,t)=>{xG.init(e,t),FJ.init(e,t)}),KJ=Y(`ZodKSUID`,(e,t)=>{SG.init(e,t),FJ.init(e,t)}),qJ=Y(`ZodIPv4`,(e,t)=>{DG.init(e,t),FJ.init(e,t)}),JJ=Y(`ZodIPv6`,(e,t)=>{OG.init(e,t),FJ.init(e,t)}),YJ=Y(`ZodCIDRv4`,(e,t)=>{kG.init(e,t),FJ.init(e,t)}),XJ=Y(`ZodCIDRv6`,(e,t)=>{AG.init(e,t),FJ.init(e,t)}),ZJ=Y(`ZodBase64`,(e,t)=>{MG.init(e,t),FJ.init(e,t)}),QJ=Y(`ZodBase64URL`,(e,t)=>{PG.init(e,t),FJ.init(e,t)}),$J=Y(`ZodE164`,(e,t)=>{FG.init(e,t),FJ.init(e,t)}),eY=Y(`ZodJWT`,(e,t)=>{LG.init(e,t),FJ.init(e,t)}),tY=Y(`ZodNumber`,(e,t)=>{RG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uq(e,t,n,r),e.gt=(t,n)=>e.check(fq(t,n)),e.gte=(t,n)=>e.check(pq(t,n)),e.min=(t,n)=>e.check(pq(t,n)),e.lt=(t,n)=>e.check(uq(t,n)),e.lte=(t,n)=>e.check(dq(t,n)),e.max=(t,n)=>e.check(dq(t,n)),e.int=t=>e.check(rY(t)),e.safe=t=>e.check(rY(t)),e.positive=t=>e.check(fq(0,t)),e.nonnegative=t=>e.check(pq(0,t)),e.negative=t=>e.check(uq(0,t)),e.nonpositive=t=>e.check(dq(0,t)),e.multipleOf=(t,n)=>e.check(mq(t,n)),e.step=(t,n)=>e.check(mq(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Z(e){return tq(tY,e)}var nY=Y(`ZodNumberFormat`,(e,t)=>{zG.init(e,t),tY.init(e,t)});function rY(e){return rq(nY,e)}var iY=Y(`ZodBoolean`,(e,t)=>{BG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wq(e,t,n,r)});function aY(e){return iq(iY,e)}var oY=Y(`ZodUndefined`,(e,t)=>{VG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kq(e,t,n,r)});function sY(e){return aq(oY,e)}var cY=Y(`ZodNull`,(e,t)=>{HG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gq(e,t,n,r)});function lY(e){return oq(cY,e)}var uY=Y(`ZodAny`,(e,t)=>{UG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function dY(){return sq(uY)}var fY=Y(`ZodUnknown`,(e,t)=>{WG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function pY(){return cq(fY)}var mY=Y(`ZodNever`,(e,t)=>{GG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qq(e,t,n,r)});function hY(e){return lq(mY,e)}var gY=Y(`ZodArray`,(e,t)=>{qG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qq(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(gq(t,n)),e.nonempty=t=>e.check(gq(1,t)),e.max=(t,n)=>e.check(hq(t,n)),e.length=(t,n)=>e.check(_q(t,n)),e.unwrap=()=>e.element});function Q(e,t){return Aq(gY,e,t)}var _Y=Y(`ZodObject`,(e,t)=>{QG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$q(e,t,n,r),vU(e,`shape`,()=>t.shape),e.keyof=()=>CY(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:pY()}),e.loose=()=>e.clone({...e._zod.def,catchall:pY()}),e.strict=()=>e.clone({...e._zod.def,catchall:hY()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>IU(e,t),e.safeExtend=t=>LU(e,t),e.merge=t=>RU(e,t),e.pick=t=>PU(e,t),e.omit=t=>FU(e,t),e.partial=(...t)=>zU(OY,e,t[0]),e.required=(...t)=>BU(RY,e,t[0])});function $(e,t){return new _Y({type:`object`,shape:e??{},...jU(t)})}var vY=Y(`ZodUnion`,(e,t)=>{eK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eJ(e,t,n,r),e.options=t.options});function yY(e,t){return new vY({type:`union`,options:e,...jU(t)})}var bY=Y(`ZodIntersection`,(e,t)=>{tK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tJ(e,t,n,r)});function xY(e,t){return new bY({type:`intersection`,left:e,right:t})}var SY=Y(`ZodEnum`,(e,t)=>{iK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jq(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new SY({...t,checks:[],...jU(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new SY({...t,checks:[],...jU(r),entries:i})}});function CY(e,t){return new SY({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...jU(t)})}var wY=Y(`ZodLiteral`,(e,t)=>{aK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yq(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function TY(e,t){return new wY({type:`literal`,values:Array.isArray(e)?e:[e],...jU(t)})}var EY=Y(`ZodTransform`,(e,t)=>{oK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zq(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new cU(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(KU(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(KU(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function DY(e){return new EY({type:`transform`,transform:e})}var OY=Y(`ZodOptional`,(e,t)=>{cK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lJ(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function kY(e){return new OY({type:`optional`,innerType:e})}var AY=Y(`ZodExactOptional`,(e,t)=>{lK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lJ(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function jY(e){return new AY({type:`optional`,innerType:e})}var MY=Y(`ZodNullable`,(e,t)=>{uK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nJ(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function NY(e){return new MY({type:`nullable`,innerType:e})}var PY=Y(`ZodDefault`,(e,t)=>{dK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>iJ(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function FY(e,t){return new PY({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():DU(t)}})}var IY=Y(`ZodPrefault`,(e,t)=>{pK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>aJ(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function LY(e,t){return new IY({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():DU(t)}})}var RY=Y(`ZodNonOptional`,(e,t)=>{mK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rJ(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zY(e,t){return new RY({type:`nonoptional`,innerType:e,...jU(t)})}var BY=Y(`ZodCatch`,(e,t)=>{gK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oJ(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function VY(e,t){return new BY({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var HY=Y(`ZodPipe`,(e,t)=>{_K.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sJ(e,t,n,r),e.in=t.in,e.out=t.out});function UY(e,t){return new HY({type:`pipe`,in:e,out:t})}var WY=Y(`ZodReadonly`,(e,t)=>{yK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cJ(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function GY(e){return new WY({type:`readonly`,innerType:e})}var KY=Y(`ZodCustom`,(e,t)=>{xK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xq(e,t,n,r)});function qY(e,t={}){return jq(KY,e,t)}function JY(e){return Mq(e)}function YY(e){return OK(PJ,e)}function XY(e){return nq(tY,e)}$({erpDbPath:X(),erpDbSize:Z().optional(),_actions:Q(Uj).optional()});var ZY=$({id:X(),filename:X(),fileSize:Z(),fileHash:X(),uploadedBy:X(),createdAt:X()});$({page:XY().optional().default(1),pageSize:XY().optional().default(50)}),$({attachments:Q(ZY),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj)});var QY=$({level:Z(),time:Z(),msg:X(),detail:X().optional()});$({lines:XY().optional().default(200),minLevel:XY().optional()}),$({entries:Q(QY),fileName:X(),fileSize:Z().optional()}),$({message:X()}),$({items:Q($({id:Z(),entityType:X(),entityId:Z(),action:X(),field:X(),oldValue:X().nullable(),newValue:X().nullable(),userId:Z(),createdAt:dJ()}))}),$({entityType:X(),entityId:XY().int()});var $Y=$({username:X().min(1),password:X().min(1)}).strict();$({user:$({id:Z(),username:X(),permissions:Q(X()).optional()})}),$({statusCode:Z().int(),error:X(),message:X()});var eX=CY([`string`,`number`,`date`,`datetime`,`yesNo`,`checkbox`,`attachment`]),tX=eX.enum,nX=$({id:Z(),fieldSetId:Z(),seqNo:Z(),label:X(),type:eX,isArray:aY(),required:aY(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()}),rX=$({seqNo:Z().int().min(1).optional(),label:X().min(1).max(200),type:eX.optional(),isArray:aY().optional(),required:aY().optional()}).strict();$({items:Q(rX).min(1).max(100)});var iX=$({seqNo:Z().int().min(1).optional(),label:X().min(1).max(200).optional(),type:eX.optional(),isArray:aY().optional(),required:aY().optional()}).strict(),aX=$({items:Q(nX),total:Z(),nextSeqNo:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()}),oX=$({valid:aY(),error:X().optional()}),sX=$({id:X(),filename:X(),fileSize:Z(),downloadHref:X().optional()}),cX=YY(),lX=yY([Q(cX),cX]),uX=$({fieldId:Z(),fieldSeqNo:Z(),label:X(),type:X(),valueFormat:X(),required:aY(),setIndex:Z(),value:lX,attachments:Q(sX).optional(),validation:oX});$({attachmentId:X(),filename:X(),fileSize:Z()});var dX=$({id:Z(),operationRunId:Z(),stepId:Z(),seqNo:Z(),title:X(),instructions:X(),multiSet:aY(),completed:aY(),note:X().nullable(),fieldCount:Z().optional(),fieldValues:Q(uX).optional(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),_links:Q(Vj).optional(),_actions:Q(Uj).optional(),_actionTemplates:Q(Wj).optional()}),fX=YY().max(2e3);$({value:yY([Q(fX),fX])}).strict(),$({fieldValues:Q($({fieldSeqNo:Z().int(),value:yY([Q(fX),fX])}))}).strict();var pX=$({items:Q(uX),total:Z()});uX.extend({_actions:Q(Uj).optional(),_actionTemplates:Q(Wj).optional()}),pX.extend({_actions:Q(Uj).optional(),_actionTemplates:Q(Wj).optional()}),$({setCount:Z(),_actions:Q(Uj).optional(),_actionTemplates:Q(Wj).optional()}),$({id:Z(),completed:aY(),note:X().nullable(),updatedAt:dJ(),updatedBy:X(),_actions:Q(Uj).optional(),_actionTemplates:Q(Wj).optional()}),$({includeFields:yY([TY(`true`),TY(`false`)]).transform(e=>e===`true`).optional()}),$({items:Q(dX),total:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var mX=$({seqNo:Z(),label:X(),type:eX}),hX=$({id:Z(),seqNo:Z(),title:X(),sourceOpSeqNo:Z(),sourceOpTitle:X(),sourceStepSeqNo:Z(),sourceStepTitle:X(),fields:Q(mX),createdAt:dJ(),createdBy:X(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()});$({seqNo:Z().int().min(1).optional(),title:X().min(1).max(200),sourceOpSeqNo:Z().int().min(1),sourceStepSeqNo:Z().int().min(1)}).strict(),$({items:Q(hX),total:Z(),nextSeqNo:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var gX=$({seqNo:Z(),title:X(),sourceOpSeqNo:Z(),sourceOpTitle:X(),sourceStepSeqNo:Z(),sourceStepTitle:X(),multiSet:aY(),fieldValues:Q(uX)});$({page:XY().int().min(1).optional().default(1),pageSize:XY().int().min(1).max(100).optional().default(20),search:X().optional()}),$({items:Q($({id:Z(),itemKey:X(),key:X(),quantity:Z().nullable(),orderKey:X().nullable(),orderRunNo:Z().nullable(),createdAt:dJ()})),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj),_actionTemplates:Q(Wj).optional()});var _X=$({id:Z(),itemKey:X(),orderKey:X().nullable(),orderRunNo:Z().nullable(),key:X(),quantity:Z().nullable(),fieldValues:Q(uX),createdBy:X(),createdAt:dJ(),updatedBy:X(),updatedAt:dJ(),_links:Q(Vj).optional(),_actions:Q(Uj).optional(),_actionTemplates:Q(Wj).optional()});$({key:X().min(1).max(200),quantity:Z().nullable().optional(),orderRunId:Z().nullable().optional()}).strict(),$({key:X().min(1).max(200).optional(),quantity:Z().nullable().optional(),orderRunId:Z().nullable().optional()}).strict(),$({page:XY().int().min(1).optional().default(1),pageSize:XY().int().min(1).max(100).optional().default(20),search:X().optional()}),$({items:Q(_X),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var vX=$({id:Z(),key:X(),description:X(),fields:aX,createdBy:X(),createdAt:dJ(),updatedBy:X(),updatedAt:dJ(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()});$({key:X().min(1).max(100).regex(/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/,`Key must be alphanumeric with hyphens`),description:X().max(2e3).optional().default(``)}).strict(),$({key:X().min(1).max(100).regex(/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/,`Key must be alphanumeric with hyphens`).optional(),description:X().max(2e3).optional()}).strict(),$({page:XY().int().min(1).optional().default(1),pageSize:XY().int().min(1).max(100).optional().default(20),search:X().optional()}),$({items:Q(vX),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var yX=$({id:Z(),operationRunId:Z(),userId:Z(),username:X(),runId:Z().nullable(),clockIn:dJ(),clockOut:dJ().nullable(),cost:Z().nullable(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),_links:Q(Vj).optional()});$({userId:Z().int().optional(),ticketId:Z().int().optional()}).strict(),$({items:Q(yX),total:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional(),_actionTemplates:Q(Wj).optional()});var bX=$({seqNo:Z(),title:X()}),xX=$({seqNo:Z(),title:X()}),SX=$({id:Z(),orderRevId:Z(),seqNo:Z(),title:X(),description:X(),workCenterKey:X().nullable(),stepCount:Z().optional(),stepSummary:Q(xX).optional(),predecessors:Q(bX).optional(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()}),CX=$({seqNo:Z().int().min(1).optional(),title:X().min(1).max(200),description:X().max(2e3).optional(),workCenterKey:X().max(100).nullable().optional(),predecessorSeqNos:Q(Z().int().min(1)).optional()}).strict(),wX=$({title:X().min(1).max(200).optional(),description:X().max(2e3).optional(),workCenterKey:X().max(100).nullable().optional(),seqNo:Z().int().min(1).optional()}).strict();$({items:Q(SX),total:Z(),nextSeqNo:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var TX=$({seqNo:Z(),title:X(),completed:aY()}),EX=CY([`blocked`,`pending`,`in_progress`,`completed`,`skipped`,`failed`]),DX=EX.enum,OX=$({id:Z(),orderRunId:Z(),operationId:Z(),seqNo:Z(),title:X(),description:X(),workCenterKey:X().nullable(),stepCount:Z().optional(),predecessors:Q(bX).optional(),status:EX,assignedTo:X().nullable(),cost:Z().nullable(),note:X().nullable(),completedAt:dJ().nullable(),stepSummary:Q(TX).optional(),fieldRefSummary:Q(gX).optional(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()});$({assignedToId:Z().int().nullable().optional()}).strict(),yY([$({note:X().max(2e3).optional()}).strict(),lY(),sY()]).transform(e=>e??{}),$({id:Z(),status:EX,assignedTo:X().nullable(),cost:Z().nullable(),note:X().nullable(),completedAt:dJ().nullable(),updatedAt:dJ(),updatedBy:X(),_actions:Q(Uj).optional()}),$({items:Q(OX),total:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var kX=$({seqNo:Z(),title:X()}),AX=CY([`draft`,`approved`,`obsolete`]),jX=AX.enum,MX=$({id:Z(),orderId:Z(),revNo:Z(),status:AX,description:X(),changeSummary:X().nullable(),itemKey:X().nullable(),operationSummary:Q(kX).optional(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()});$({description:X().max(2e3).optional(),changeSummary:X().max(2e3).optional()}).strict();var NX=$({description:X().max(2e3).optional(),changeSummary:X().max(2e3).optional()}).strict();$({page:XY().int().min(1).optional().default(1),pageSize:XY().int().min(1).max(100).optional().default(20),status:AX.optional(),includeObsolete:CY([`true`,`false`]).transform(e=>e===`true`).optional().default(!1)}),$({items:Q(MX),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var PX=$({seqNo:Z(),title:X(),status:EX}),FX=CY([`released`,`started`,`closed`,`cancelled`]),IX=FX.enum,LX=CY([`low`,`medium`,`high`,`critical`]),RX=LX.enum,zX=$({id:Z(),runNo:Z(),orderId:Z(),orderKey:X(),revNo:Z(),itemKey:X().nullable(),instanceId:Z().nullable(),instanceKey:X().nullable(),status:FX,priority:LX,cost:Z().nullable(),dueAt:X().nullable(),releaseNote:X().nullable(),operationSummary:Q(PX).optional(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()}),BX=$({revNo:Z().int().min(1).optional(),priority:LX.optional().default(`medium`),dueAt:X().regex(/^\d{4}-\d{2}-\d{2}$/,`Must be YYYY-MM-DD`),releaseNote:X().max(2e3).optional()}).strict(),VX=$({priority:LX.optional(),dueAt:X().regex(/^\d{4}-\d{2}-\d{2}$/,`Must be YYYY-MM-DD`).nullable().optional(),releaseNote:X().max(2e3).nullable().optional()}).strict();$({instanceKey:X().max(200).optional(),quantity:Z().nullable().optional(),fieldValues:Q($({fieldId:Z().int(),value:X().max(2e3),setIndex:Z().int().min(0).optional()})).optional()}).strict(),$({page:XY().int().min(1).optional().default(1),pageSize:XY().int().min(1).max(100).optional().default(20),status:FX.optional(),priority:LX.optional(),search:X().optional()}),$({items:Q(zX),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()}),$({page:XY().int().min(1).optional().default(1),pageSize:XY().int().min(1).max(100).optional().default(20),status:EX.optional(),priority:LX.optional(),search:X().optional(),viewAs:X().optional(),canWork:yY([TY(`true`),TY(`false`)]).transform(e=>e===`true`).optional(),clockedIn:yY([TY(`true`),TY(`false`)]).transform(e=>e===`true`).optional()}),$({items:Q($({id:Z(),orderKey:X(),revNo:Z(),runNo:Z(),seqNo:Z(),title:X(),workCenterKey:X().nullable(),canWork:aY(),status:EX,priority:LX,assignedTo:X().nullable(),dueAt:X().nullable(),createdAt:dJ()})),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actionTemplates:Q(Wj).optional()});var HX=$({_actions:Q(Uj).optional()}).extend({id:Z(),_links:Q(Vj).optional()});HX.extend({key:X()}),HX.extend({seqNo:Z()}),$({items:Q($({id:Z(),seqNo:Z()})),total:Z(),_actions:Q(Uj).optional()}),HX.extend({revNo:Z()}),HX.extend({runNo:Z()}),$({id:Z(),username:X(),apiKey:X().nullable().optional(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()}),$({status:FX,_actions:Q(Uj).optional()}),$({status:EX,_actions:Q(Uj).optional()}),$({completed:aY(),_actions:Q(Uj).optional()}),$({status:AX,_actions:Q(Uj).optional()}),$({value:lX,validation:oX,_actions:Q(Uj).optional()}),$({items:Q($({fieldSeqNo:Z(),value:lX,validation:oX})),total:Z(),_actions:Q(Uj).optional()}),$({setCount:Z(),_actions:Q(Uj).optional()});var UX=$({id:Z(),predecessorSeqNo:Z(),predecessorTitle:X(),createdAt:dJ(),createdBy:X()}),WX=$({predecessorSeqNo:Z().int().min(1)}).strict();$({items:Q(UX),total:Z(),_links:Q(Vj),_actions:Q(Uj).optional(),_actionTemplates:Q(Wj).optional()});var GX=CY([`note`,`issue`,`feedback`]);GX.enum;var KX=$({id:Z(),operationRunId:Z(),type:GX,body:X(),createdAt:dJ(),createdBy:X(),_links:Q(Vj).optional()});$({type:GX.optional(),body:X().min(1).max(5e3)}).strict(),$({items:Q(KX),total:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var qX=CY([`active`,`archived`]),JX=qX.enum,YX=$({id:Z(),key:X(),description:X(),status:qX,itemKey:X().nullable(),createdBy:X(),createdAt:dJ(),updatedBy:X(),updatedAt:dJ(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()}),XX=$({key:X().min(1).max(100).regex(/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/,`Key must be alphanumeric with hyphens`),description:X().max(2e3).optional().default(``),itemKey:X().max(100).optional()}).strict(),ZX=$({key:X().min(1).max(100).regex(/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/,`Key must be alphanumeric with hyphens`).optional(),description:X().max(2e3).optional(),status:qX.optional(),itemKey:X().max(100).nullable().optional()}).strict();$({page:XY().int().min(1).optional().default(1),pageSize:XY().int().min(1).max(100).optional().default(20),status:CY([`active`,`archived`]).optional(),search:X().optional()}),$({items:Q(YX),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var QX=$({field:X(),from:yY([X(),Z(),aY(),lY()]),to:yY([X(),Z(),aY(),lY()])}),$X=CY([`added`,`removed`,`modified`,`unchanged`]),eZ=$({seqNo:Z(),label:X(),status:$X,changes:Q(QX).optional()}),tZ=$({seqNo:Z(),title:X(),status:$X,changes:Q(QX).optional(),fields:Q(eZ).optional()}),nZ=$({predecessorSeqNo:Z(),predecessorTitle:X(),status:CY([`added`,`removed`,`unchanged`])}),rZ=$({seqNo:Z(),title:X(),status:$X,changes:Q(QX).optional(),steps:Q(tZ).optional(),dependencies:Q(nZ).optional()});$({fromRevNo:Z(),toRevNo:Z(),revisionChanges:Q(QX),operations:Q(rZ)}),$({from:XY().int().min(1),to:XY().int().min(1)});var iZ=$({id:Z(),operationId:Z(),seqNo:Z(),title:X(),instructions:X(),multiSet:aY(),fieldCount:Z().optional(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),fields:aX,_links:Q(Vj).optional(),_actions:Q(Uj).optional()}),aZ=$({seqNo:Z().int().min(1).optional(),title:X().max(200).optional(),instructions:X().max(1e4).optional(),multiSet:aY().optional()}).strict();$({items:Q(aZ).min(1).max(100)});var oZ=$({seqNo:Z().int().min(1).optional(),title:X().max(200).optional(),instructions:X().max(1e4).optional(),multiSet:aY().optional()}).strict();$({items:Q(iZ),total:Z(),nextSeqNo:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var sZ=CY([`erp_admin`,`order_planner`,`order_executor`,`order_manager`,`item_manager`]);sZ.enum;var cZ=X().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/,`Must contain only letters, numbers, hyphens, and underscores`);$({username:cZ,password:X().min(6)}).strict(),$({username:cZ.optional(),password:X().min(6).optional()}).strict(),$({permission:sZ}).strict(),$({agentId:Z().int()}).strict(),$({password:X().min(6)}).strict();var lZ=$({permission:sZ,grantedAt:X(),grantedBy:Z().nullable(),_actions:Q(dY()).optional()});$({id:Z(),username:X(),isAgent:aY(),createdAt:X(),updatedAt:X(),apiKey:X().nullable().optional(),permissions:Q(lZ),_links:Q(dY()).optional(),_actions:Q(dY()).optional()}),$({items:Q($({id:Z(),username:X(),isAgent:aY(),createdAt:X(),permissionCount:Z()})),total:Z(),page:Z(),pageSize:Z(),_links:Q(dY()).optional(),_linkTemplates:Q(dY()).optional(),_actions:Q(dY()).optional()}),$({page:XY().int().min(1).default(1),pageSize:XY().int().min(1).max(100).default(20),search:X().optional()});var uZ=$({userId:Z(),username:X(),createdAt:X(),createdBy:X().nullable(),_actions:Q(Uj).optional()});$({id:Z(),key:X(),description:X(),userAssignments:Q(uZ),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),_links:Q(Vj),_actions:Q(Uj).optional()}),$({key:X().min(1).max(100).regex(/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/,`Key must be alphanumeric with hyphens`),description:X().max(2e3).optional().default(``)}).strict(),$({key:X().min(1).max(100).regex(/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/,`Key must be alphanumeric with hyphens`).optional(),description:X().max(2e3).optional()}).strict(),$({username:X().min(1)}).strict(),$({page:XY().int().min(1).optional().default(1),pageSize:XY().int().min(1).max(100).optional().default(20),search:X().optional()}),$({items:Q($({id:Z(),key:X(),description:X(),userCount:Z(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X()})),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var dZ=({opened:e,onClose:t})=>{let{login:n}=xM(),[r,i]=(0,v.useState)(!1),a=rN({initialValues:{username:``,password:``},validate:oU($Y)}),o=()=>{a.reset(),t()};return(0,I.jsx)(Nh,{opened:e,onClose:o,title:`Login`,children:(0,I.jsx)(`form`,{onSubmit:a.onSubmit(async e=>{i(!0);try{await n(e.username,e.password),window.location.reload()}catch(e){gM(e)}finally{i(!1)}}),children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsx)(Mv,{label:`Username`,...a.getInputProps(`username`),"data-autofocus":!0}),(0,I.jsx)(Mv,{label:`Password`,type:`password`,...a.getInputProps(`password`)}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:o,children:`Cancel`}),(0,I.jsx)(H,{type:`submit`,loading:r,children:`Login`})]})]})})})},fZ=[{label:`Items`,path:`/items`},{label:`Orders`,path:`/orders`},{label:`Work Centers`,path:`/work-centers`},{label:`Dispatch`,path:`/dispatch`},{label:`Inventory`,path:`/inventory`},{label:`Users`,path:`/users`},{label:`Admin`,path:`/admin`}],pZ=({supervisorAuth:e})=>{let[t,{toggle:n,close:r}]=_n(),[i,{open:a,close:o}]=_n(),s=hC(),c=fC(),{user:l,logout:u}=xM(),d=e=>c.pathname.startsWith(e),f=fZ.find(e=>d(e.path))?.label??`Orders`;return(0,I.jsxs)(hf,{header:{height:48},navbar:{width:250,breakpoint:`sm`,collapsed:{desktop:!0,mobile:!t}},padding:0,children:[(0,I.jsx)(hf.Header,{children:(0,I.jsxs)(B,{h:`100%`,px:`md`,wrap:`nowrap`,gap:`xs`,children:[(0,I.jsx)(gl,{onClick:n,hiddenFrom:`sm`,style:{flexShrink:0,display:`flex`,alignItems:`center`},children:(0,I.jsx)(`img`,{src:Kj,alt:`NAISYS`,style:{width:`36px`,height:`36px`}})}),(0,I.jsx)(R,{visibleFrom:`sm`,style:{flexShrink:0},children:(0,I.jsxs)(zw,{to:`/orders`,style:{textDecoration:`none`,color:`inherit`,display:`flex`,alignItems:`center`,gap:`0.5rem`,cursor:`pointer`},children:[(0,I.jsx)(`img`,{src:Kj,alt:`NAISYS`,style:{width:`36px`,height:`36px`}}),(0,I.jsx)(V,{size:`lg`,fw:500,children:`NAISYS`})]})}),(0,I.jsx)(gl,{hiddenFrom:`sm`,onClick:n,style:{flexShrink:0},children:(0,I.jsxs)(V,{size:`sm`,fw:600,children:[`NAISYS / `,f]})}),(0,I.jsxs)(B,{gap:6,visibleFrom:`sm`,wrap:`nowrap`,style:{flexShrink:0},children:[e&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{size:`sm`,c:`dimmed`,component:`a`,href:`/supervisor/`,style:{cursor:`pointer`,textDecoration:`none`},children:`Supervisor`}),(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`|`})]}),(0,I.jsx)(V,{size:`sm`,fw:700,children:`ERP`})]}),(0,I.jsx)(B,{gap:`xs`,visibleFrom:`sm`,wrap:`nowrap`,style:{flex:1,minWidth:0,overflow:`hidden`},children:fZ.map(e=>(0,I.jsx)(gl,{component:zw,to:e.path,px:`sm`,py:4,style:t=>({borderRadius:t.radius.sm,flexShrink:0,backgroundColor:d(e.path)?`var(--mantine-color-dark-5)`:void 0}),children:(0,I.jsx)(V,{size:`sm`,fw:d(e.path)?600:400,c:d(e.path)?void 0:`dimmed`,children:e.label})},e.path))}),(0,I.jsx)(R,{hiddenFrom:`sm`,style:{flex:1}}),(0,I.jsx)(M_,{label:`API Reference`,children:(0,I.jsx)(vu,{variant:`subtle`,color:`gray`,component:`a`,href:`/erp/api-reference/`,visibleFrom:`sm`,style:{flexShrink:0},children:(0,I.jsx)(Zj,{size:`1.2rem`})})}),l?(0,I.jsxs)(gh,{position:`bottom-end`,withArrow:!0,children:[(0,I.jsx)(gh.Target,{children:(0,I.jsx)(H,{variant:`subtle`,size:`xs`,color:`gray`,style:{flexShrink:0},children:l.username})}),(0,I.jsxs)(gh.Dropdown,{children:[(0,I.jsx)(gh.Item,{leftSection:(0,I.jsx)(fM,{size:`0.9rem`}),onClick:()=>s(`/users/${l.username}`),children:`My User`}),(0,I.jsx)(gh.Item,{leftSection:(0,I.jsx)(sM,{size:`0.9rem`}),onClick:async()=>{await u(),window.location.reload()},children:`Logout`})]})]}):(0,I.jsx)(H,{size:`xs`,variant:`subtle`,onClick:a,style:{flexShrink:0},children:`Login`})]})}),(0,I.jsxs)(hf.Navbar,{p:`md`,children:[(0,I.jsxs)(B,{gap:6,px:`sm`,py:4,children:[e&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{size:`sm`,c:`dimmed`,component:`a`,href:`/supervisor/`,style:{textDecoration:`none`},children:`Supervisor`}),(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`|`})]}),(0,I.jsx)(V,{size:`sm`,fw:700,children:`ERP`})]}),(0,I.jsx)(nm,{mb:4}),fZ.map(e=>(0,I.jsx)(gl,{component:zw,to:e.path,onClick:r,p:`sm`,mb:4,style:t=>({borderRadius:t.radius.sm,backgroundColor:d(e.path)?`var(--mantine-color-dark-5)`:void 0}),children:(0,I.jsx)(V,{size:`sm`,fw:d(e.path)?600:400,c:d(e.path)?void 0:`dimmed`,children:e.label})},e.path))]}),(0,I.jsxs)(hf.Main,{children:[!l&&(0,I.jsx)(Ld,{variant:`light`,color:`violet`,icon:(0,I.jsx)(tM,{size:`1rem`}),py:4,radius:0,styles:{wrapper:{justifyContent:`center`,alignItems:`center`},body:{flex:`initial`}},children:(0,I.jsx)(V,{size:`xs`,children:`Public read-only mode — login for full access`})}),(0,I.jsx)(GC,{context:{supervisorAuth:e}})]}),(0,I.jsx)(dZ,{opened:i,onClose:o})]})},mZ=()=>{let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(!0),i=(0,v.useCallback)(async()=>{r(!0);try{t(await q.get(J.admin))}catch{}finally{r(!1)}},[]);(0,v.useEffect)(()=>{i()},[i]);let a=e?!!Rj(e._actions,`view-logs`):!1,o=e?!!Rj(e._actions,`view-attachments`):!1,s=(0,v.useCallback)(async(e,t)=>q.get(J.adminLogs(void 0,t)),[]),c=(0,v.useCallback)(async(e,t)=>{let n=new URLSearchParams;return n.set(`page`,String(e)),n.set(`pageSize`,String(t)),q.get(`${J.adminAttachments}?${n}`)},[]),l=(0,v.useCallback)(e=>J.adminAttachmentDownload(e),[]);return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,w:`100%`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Admin`}),n?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):e?(0,I.jsxs)(jv,{defaultValue:`info`,children:[(0,I.jsxs)(jv.List,{children:[(0,I.jsx)(jv.Tab,{value:`info`,children:`Info`}),a&&(0,I.jsx)(jv.Tab,{value:`logs`,children:`Server Logs`}),o&&(0,I.jsx)(jv.Tab,{value:`attachments`,children:`Attachments`})]}),(0,I.jsx)(jv.Panel,{value:`info`,pt:`md`,children:(0,I.jsx)(W,{striped:!0,highlightOnHover:!0,children:(0,I.jsx)(W.Tbody,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Td,{fw:600,children:`ERP DB Path`}),(0,I.jsxs)(W.Td,{children:[e.erpDbPath,e.erpDbSize!=null&&` (${Lj(e.erpDbSize)})`]})]})})})}),a&&(0,I.jsx)(jv.Panel,{value:`logs`,pt:`md`,children:(0,I.jsx)(aU,{fetchLogs:s})}),o&&(0,I.jsx)(jv.Panel,{value:`attachments`,pt:`md`,children:(0,I.jsx)(pN,{fetchAttachments:c,getDownloadUrl:l})})]}):null]})},hZ=({value:e,onChange:t,onUserSelect:n,...r})=>{let[i]=zt(e,300),[a,o]=(0,v.useState)([]),s=(0,v.useCallback)(async e=>{try{let t=new URLSearchParams;t.set(`pageSize`,`10`),e&&t.set(`search`,e),o((await q.get(`${J.users}?${t}`)).items.map(e=>({id:e.id,username:e.username})))}catch{o([])}},[]);return(0,v.useEffect)(()=>{s(i)},[i,s]),(0,I.jsx)(Dp,{data:a.map(e=>e.username),value:e,onChange:t,onOptionSubmit:e=>{t(e);let r=a.find(t=>t.username===e);r&&n&&n(r)},...r})},gZ={display:`block`,color:`inherit`,textDecoration:`none`,padding:`var(--table-vertical-spacing) var(--table-horizontal-spacing, var(--mantine-spacing-xs))`},_Z={[DX.blocked]:`gray`,[DX.pending]:`blue`,[DX.in_progress]:`yellow`,[DX.completed]:`green`,[DX.skipped]:`gray`,[DX.failed]:`red`},vZ={low:`gray`,medium:`blue`,high:`orange`,critical:`red`},yZ=[{value:DX.pending,label:`Pending`},{value:DX.in_progress,label:`In Progress`},{value:DX.failed,label:`Failed`}],bZ=()=>{let[e,t]=qw(),n=Number(e.get(`page`))||1,r=e.get(`status`)||void 0,i=e.get(`priority`)||void 0,a=e.get(`search`)||``,o=e.get(`viewAs`)||``,s=e.get(`canWork`)===`true`,c=e.get(`clockedIn`)===`true`,[l,u]=(0,v.useState)(a),[d,f]=(0,v.useState)(o),[p]=zt(l,300),m=(0,v.useRef)(!0);(0,v.useEffect)(()=>{if(m.current){m.current=!1;return}t(e=>(p?e.set(`search`,p):e.delete(`search`),e.set(`page`,`1`),e))},[p,t]);let[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(!0),b=(0,v.useCallback)(async()=>{y(!0);try{let e=new URLSearchParams;e.set(`page`,String(n)),e.set(`pageSize`,`20`),r&&e.set(`status`,r),i&&e.set(`priority`,i),a&&e.set(`search`,a),o&&e.set(`viewAs`,o),s&&e.set(`canWork`,`true`),c&&e.set(`clockedIn`,`true`),g(await q.get(`${J.dispatch}?${e}`))}catch(e){gM(e)}finally{y(!1)}},[n,r,i,a,o,s,c]);(0,v.useEffect)(()=>{b()},[b]);let x=h?Math.ceil(h.total/h.pageSize):0;return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,children:[(0,I.jsx)(B,{justify:`space-between`,mb:`lg`,children:(0,I.jsx)(zv,{order:2,children:`Dispatch`})}),(0,I.jsxs)(B,{mb:`md`,children:[(0,I.jsx)(Mv,{placeholder:`Search...`,value:l,onChange:e=>u(e.currentTarget.value),style:{flex:1}}),(0,I.jsx)(R_,{placeholder:`All open`,data:yZ,value:r??null,onChange:e=>{t(t=>(e?t.set(`status`,e):t.delete(`status`),t.set(`page`,`1`),t))},clearable:!0}),(0,I.jsx)(R_,{placeholder:`All priorities`,data:LX.options.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),value:i??null,onChange:e=>{t(t=>(e?t.set(`priority`,e):t.delete(`priority`),t.set(`page`,`1`),t))},clearable:!0}),(0,I.jsx)(hZ,{placeholder:`View as user...`,value:d,onChange:e=>{f(e),e||t(e=>(e.delete(`viewAs`),e.set(`page`,`1`),e))},onUserSelect:e=>{f(e.username),t(t=>(t.set(`viewAs`,e.username),t.set(`page`,`1`),t))},w:180,size:`sm`}),(0,I.jsx)(yp,{label:`Can Work`,checked:s,onChange:e=>{t(t=>(e.currentTarget.checked?t.set(`canWork`,`true`):t.delete(`canWork`),t.set(`page`,`1`),t))}}),(0,I.jsx)(yp,{label:`Clocked In`,checked:c,onChange:e=>{t(t=>(e.currentTarget.checked?t.set(`clockedIn`,`true`):t.delete(`clockedIn`),t.set(`page`,`1`),t))}})]}),_?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):h&&h.items.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Order / Run`}),(0,I.jsx)(W.Th,{children:`Operation`}),(0,I.jsx)(W.Th,{children:`Can Work`}),(0,I.jsx)(W.Th,{children:`Status`}),(0,I.jsx)(W.Th,{children:`Priority`}),(0,I.jsx)(W.Th,{children:`Assigned To`}),(0,I.jsx)(W.Th,{children:`Due`})]})}),(0,I.jsx)(W.Tbody,{children:h.items.map(e=>{let t=`/orders/${e.orderKey}/runs/${e.runNo}/ops/${e.seqNo}`;return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsxs)(B,{gap:`xs`,wrap:`nowrap`,children:[(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:e.orderKey}),(0,I.jsxs)(Ap,{color:`violet`,variant:`light`,size:`sm`,children:[`R`,e.revNo]}),(0,I.jsxs)(V,{size:`sm`,ff:`monospace`,children:[`#`,e.runNo]})]})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsxs)(V,{size:`sm`,children:[(0,I.jsx)(V,{span:!0,ff:`monospace`,children:e.seqNo}),` — `,e.title]})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(V,{size:`sm`,c:e.canWork?`green`:`red`,children:e.canWork?`Yes`:`No`})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(Ap,{color:_Z[e.status]??`gray`,variant:`light`,children:e.status})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(Ap,{color:vZ[e.priority]??`gray`,variant:`light`,children:e.priority})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.assignedTo??`—`})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.dueAt?new Date(e.dueAt).toLocaleDateString():`—`})})]},e.id)})})]}),x>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:x,value:n,onChange:e=>t(t=>(t.set(`page`,String(e)),t))})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`xl`,children:`No open operations found.`})]})},xZ=()=>{let[e,t]=qw(),n=Number(e.get(`page`))||1,r=e.get(`search`)||``,[i,a]=(0,v.useState)(r),[o]=zt(i,300),s=(0,v.useRef)(!0);(0,v.useEffect)(()=>{if(s.current){s.current=!1;return}t(e=>(o?e.set(`search`,o):e.delete(`search`),e.set(`page`,`1`),e))},[o,t]);let[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!0),f=(0,v.useCallback)(async()=>{d(!0);try{let e=new URLSearchParams;e.set(`page`,String(n)),e.set(`pageSize`,`20`),r&&e.set(`search`,r),l(await q.get(`${J.inventory}?${e}`))}catch(e){gM(e)}finally{d(!1)}},[n,r]);(0,v.useEffect)(()=>{f()},[f]);let p=c?Math.ceil(c.total/c.pageSize):0;return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,children:[(0,I.jsx)(B,{justify:`space-between`,mb:`lg`,children:(0,I.jsx)(zv,{order:2,children:`Inventory`})}),(0,I.jsx)(B,{mb:`md`,children:(0,I.jsx)(Mv,{placeholder:`Search...`,value:i,onChange:e=>a(e.currentTarget.value),style:{flex:1}})}),u?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):c&&c.items.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Item`}),(0,I.jsx)(W.Th,{children:`Instance`}),(0,I.jsx)(W.Th,{children:`Quantity`}),(0,I.jsx)(W.Th,{children:`Produced By`}),(0,I.jsx)(W.Th,{children:`Created`})]})}),(0,I.jsx)(W.Tbody,{children:c.items.map(e=>{let t=`/items/${e.itemKey}/instances/${e.id}`;return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:`/items/${e.itemKey}`,style:gZ,children:(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:e.itemKey})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:e.key})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.quantity==null?`—`:e.quantity})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.orderKey?(0,I.jsxs)(V,{size:`sm`,children:[e.orderKey,` Run `,e.orderRunNo]}):`—`})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:new Date(e.createdAt).toLocaleDateString()})})]},e.id)})})]}),p>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:p,value:n,onChange:e=>t(t=>(t.set(`page`,String(e)),t))})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`xl`,children:`No inventory found.`})]})},SZ=()=>{let e=hC(),[t,n]=(0,v.useState)(``),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),s=async()=>{o(!0);try{await q.post(J.items,{key:t,description:r}),e(`/items`)}catch(e){gM(e)}finally{o(!1)}};return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Create Item`}),(0,I.jsxs)(U,{children:[(0,I.jsx)(Mv,{label:`Key`,description:`Alphanumeric with hyphens`,value:t,onChange:e=>n(e.currentTarget.value),required:!0,"data-autofocus":!0}),(0,I.jsx)(Qm,{label:`Description`,value:r,onChange:e=>i(e.currentTarget.value),autosize:!0,minRows:2}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>e(`/items`),children:`Cancel`}),(0,I.jsx)(H,{onClick:s,loading:a,disabled:!t,children:`Create`})]})]})]})},CZ=({createdBy:e,createdAt:t,updatedBy:n,updatedAt:r})=>(0,I.jsx)(M_,{label:(0,I.jsxs)(U,{gap:4,children:[(0,I.jsxs)(V,{size:`xs`,children:[`Created`,e?` by ${e}`:``,`,`,` `,new Date(t).toLocaleString()]}),(0,I.jsxs)(V,{size:`xs`,children:[`Modified`,n?` by ${n}`:``,`,`,` `,new Date(r).toLocaleString()]})]}),multiline:!0,withArrow:!0,children:(0,I.jsx)(vu,{variant:`subtle`,size:`sm`,color:`gray`,children:(0,I.jsx)(rM,{size:16})})}),wZ={string:`String`,number:`Number`,date:`Date`,datetime:`Date/Time`,yesNo:`Yes/No`,checkbox:`Checkbox`,attachment:`Attachment`};function TZ(e){return wZ[e]??e}var EZ=({fieldsEndpoint:e,fieldEndpoint:t,initialData:n})=>{let[r,i]=(0,v.useState)(n),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),d=rN({initialValues:{seqNo:10,label:``,type:tX.string,isArray:!1,required:!1},validate:oU(iX)}),f=rN({initialValues:{seqNo:10,label:``,type:tX.string,isArray:!1,required:!1},validate:oU(rX)}),p=e=>{d.setValues({seqNo:e.seqNo,label:e.label,type:e.type,isArray:e.isArray,required:e.required}),o(e.id),c(!1)},m=async e=>{let n=r.items.find(e=>e.id===a);if(n){u(!0);try{let a=await q.put(t(n.seqNo),e);o(null),i({...r,items:r.items.map(e=>e.id===a.id?a:e).sort((e,t)=>e.seqNo-t.seqNo)})}catch(e){gM(e)}finally{u(!1)}}},h=async e=>{if(confirm(`Delete field "${e.label}"?`))try{await q.delete(t(e.seqNo)),i({...r,items:r.items.filter(t=>t.id!==e.id),total:r.total-1})}catch(e){gM(e)}},g=()=>{f.setValues({seqNo:r.nextSeqNo,label:``,type:tX.string,isArray:!1,required:!1}),c(!0),o(null)},_=async t=>{u(!0);try{let n=await q.post(e,t);c(!1),i({...r,items:[...r.items,n].sort((e,t)=>e.seqNo-t.seqNo),total:r.total+1,nextSeqNo:n.seqNo+10})}catch(e){gM(e)}finally{u(!1)}},y=e=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Vg,{label:`Sequence #`,min:1,step:10,...e.getInputProps(`seqNo`)}),(0,I.jsx)(Mv,{label:`Label`,placeholder:`Field label...`,...e.getInputProps(`label`)}),(0,I.jsx)(R_,{label:`Type`,data:eX.options.map(e=>({value:e,label:TZ(e)})),...e.getInputProps(`type`)}),(0,I.jsx)(yp,{label:`Array (accepts multiple values)`,...e.getInputProps(`isArray`,{type:`checkbox`})}),(0,I.jsx)(yp,{label:`Required`,...e.getInputProps(`required`,{type:`checkbox`})})]});return(0,I.jsxs)(U,{gap:`xs`,mt:`xs`,children:[(0,I.jsxs)(B,{justify:`space-between`,children:[r.items.length>0&&(0,I.jsx)(V,{size:`xs`,fw:600,c:`dimmed`,children:`Data Fields`}),Rj(r._actions,`create`)&&!s&&(0,I.jsx)(H,{size:`compact-xs`,variant:`subtle`,onClick:g,children:`Add Field`})]}),r.items.map(e=>(0,I.jsx)(`div`,{children:a===e.id?(0,I.jsx)(`form`,{onSubmit:d.onSubmit(m),children:(0,I.jsxs)(U,{gap:`xs`,children:[y(d),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,size:`compact-xs`,onClick:()=>o(null),children:`Cancel`}),(0,I.jsx)(H,{type:`submit`,size:`compact-xs`,loading:l,children:`Save`})]})]})}):(0,I.jsxs)(B,{justify:`space-between`,wrap:`nowrap`,children:[(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsxs)(V,{size:`xs`,children:[e.seqNo,`.`]}),(0,I.jsx)(V,{size:`xs`,fw:500,children:e.label}),(0,I.jsx)(Ap,{size:`xs`,variant:`light`,children:TZ(e.type)}),e.isArray&&(0,I.jsx)(Ap,{size:`xs`,variant:`light`,color:`blue`,children:`[]`}),e.required&&(0,I.jsx)(Ap,{size:`xs`,variant:`light`,color:`red`,children:`required`})]}),(0,I.jsxs)(B,{gap:4,wrap:`nowrap`,children:[(0,I.jsx)(CZ,{createdBy:e.createdBy,createdAt:e.createdAt,updatedBy:e.updatedBy,updatedAt:e.updatedAt}),Rj(e._actions,`update`)&&(0,I.jsx)(H,{size:`compact-xs`,variant:`subtle`,onClick:()=>p(e),children:`Edit`}),Rj(e._actions,`delete`)&&(0,I.jsx)(H,{size:`compact-xs`,color:`red`,variant:`subtle`,onClick:()=>h(e),children:`Delete`})]})]})},e.id)),s&&(0,I.jsx)(`form`,{onSubmit:f.onSubmit(_),children:(0,I.jsxs)(U,{gap:`xs`,children:[y(f),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,size:`compact-xs`,onClick:()=>c(!1),children:`Cancel`}),(0,I.jsx)(H,{type:`submit`,size:`compact-xs`,loading:l,children:`Add`})]})]})})]})},DZ=()=>{let{key:e}=bC(),t=hC(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),m=(0,v.useCallback)(async()=>{if(e){a(!0);try{r(await q.get(J.item(e)))}catch(e){gM(e)}finally{a(!1)}}},[e]);return(0,v.useEffect)(()=>{m()},[m]),i?(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(U,{align:`center`,children:(0,I.jsx)(uu,{})})}):n?o?(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Edit Item`}),(0,I.jsxs)(U,{children:[(0,I.jsx)(Mv,{label:`Key`,description:`Alphanumeric with hyphens`,value:c,onChange:e=>l(e.currentTarget.value),required:!0}),(0,I.jsx)(Qm,{label:`Description`,value:u,onChange:e=>d(e.currentTarget.value),autosize:!0,minRows:2}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>s(!1),children:`Cancel`}),(0,I.jsx)(H,{onClick:async()=>{if(e){p(!0);try{let n={key:c,description:u};await q.put(J.item(e),n),s(!1),c===e?await m():t(`/items/${c}`,{replace:!0})}catch(e){gM(e)}finally{p(!1)}}},loading:f,children:`Save`})]})]})]}):(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(zv,{order:2,children:n.key}),(0,I.jsx)(CZ,{createdBy:n.createdBy,createdAt:n.createdAt,updatedBy:n.updatedBy,updatedAt:n.updatedAt})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>t(`/items`),children:`Back`}),Rj(n._actions,`update`)&&(0,I.jsx)(H,{onClick:()=>{n&&(l(n.key),d(n.description),s(!0))},children:`Edit`}),Rj(n._actions,`delete`)&&(0,I.jsx)(H,{color:`red`,variant:`outline`,onClick:async()=>{if(!(!e||!confirm(`Delete this item?`)))try{await q.delete(J.item(e)),t(`/items`)}catch(e){gM(e)}},children:`Delete`})]})]}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,children:(0,I.jsx)(U,{gap:`sm`,children:(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Description:`}),(0,I.jsx)(V,{children:n.description||`—`})]})})}),(0,I.jsx)(B,{mt:`lg`,children:(0,I.jsx)(H,{variant:`light`,onClick:()=>t(`/items/${n.key}/instances`),children:`View Instances`})}),(0,I.jsx)(EZ,{fieldsEndpoint:J.itemFields(n.key),fieldEndpoint:e=>J.itemField(n.key,e),initialData:n.fields})]}):(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(V,{children:`Item not found.`})})};function OZ(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function kZ(e){return`${OZ(e)}T${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`}var AZ=new Set([`.jpg`,`.jpeg`,`.png`,`.gif`,`.webp`,`.svg`,`.bmp`]);function jZ(e){let t=e.slice(e.lastIndexOf(`.`)).toLowerCase();return AZ.has(t)}function MZ(e){return e.endsWith(`[]`)}function NZ(e){return e.endsWith(`[]`)?e.slice(0,-2):e}function PZ(e,t){return`${e}_${t}`}function FZ(e){return Object.fromEntries(e.map(e=>[PZ(e.fieldId,e.setIndex),e.value]))}function IZ(e){return typeof e==`string`?e:e.join(`, `)}function LZ(e){return Array.isArray(e)?e.length>0?e:[``]:e?[e]:[``]}function RZ({status:e}){return e===`saving`?(0,I.jsx)(uu,{size:14}):e===`saved`?(0,I.jsx)($j,{size:14,color:`green`}):e===`error`?(0,I.jsx)(Yj,{size:14,color:`red`}):null}var zZ=({fieldValues:e,multiSet:t,completed:n,_actionTemplates:r,fieldValueEndpoint:i,deleteSetEndpoint:a,attachmentEndpoint:o,attachmentDownloadUrl:s,onSetDeleted:c,onActionsUpdated:l})=>{let[u,d]=(0,v.useState)(e),[f,p]=(0,v.useState)(()=>FZ(e)),[m,h]=(0,v.useState)({}),g=(0,v.useRef)({}),[_,y]=(0,v.useState)(0),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),w=(0,v.useRef)(e);(0,v.useEffect)(()=>{e!==w.current&&(w.current=e,d(e),p(FZ(e)))},[e]);let T=(e,t,n)=>{let r=PZ(e,t);p(e=>({...e,[r]:n}))},E=(e,t,n)=>{let r=PZ(e,t);d(r=>r.some(n=>n.fieldId===e&&n.setIndex===t)?r.map(r=>r.fieldId===e&&r.setIndex===t?n:r):[...r,n]),p(e=>({...e,[r]:n.value}))},D=()=>{let e=u.reduce((e,t)=>Math.max(e,t.setIndex),-1)+1,t=u.filter(e=>e.setIndex===0);if(t.length===0)return;let n=t.map(t=>({...t,setIndex:e,value:MZ(t.type)?[]:``,validation:t.required?{valid:!1,error:`Required`}:{valid:!0}}));d(e=>[...e,...n])},O=(e,t,n)=>{d(r=>r.map(r=>r.fieldId===e&&r.setIndex===t?{...r,attachments:[...r.attachments??[],n]}:r))},k=[...new Set(u.map(e=>e.setIndex))].sort((e,t)=>e-t);k.length===0&&k.push(0);let A=Math.min(_,k[k.length-1]);A!==_&&y(A);let j=u.filter(e=>e.setIndex===A),ee=(e,t,n)=>{let r=PZ(e,t);g.current[r]&&(clearTimeout(g.current[r]),delete g.current[r]),n===`saved`&&(g.current[r]=setTimeout(()=>{h(e=>{let t={...e};return delete t[r],t}),delete g.current[r]},1500)),h(e=>({...e,[r]:n}))},te=async(e,t)=>{let n=e.value;if(JSON.stringify(t)!==JSON.stringify(n)){ee(e.fieldId,e.setIndex,`saving`);try{let n=await q.put(i(e.fieldSeqNo,e.setIndex),{value:t});E(e.fieldId,e.setIndex,n),ee(e.fieldId,e.setIndex,`saved`),n._actions&&n._actionTemplates&&l?.(n._actions,n._actionTemplates)}catch(t){gM(t),ee(e.fieldId,e.setIndex,`error`)}}},ne=(e,t)=>{T(e.fieldId,e.setIndex,t),te(e,t)},re=(e,t,n)=>{let r=[...LZ(f[PZ(e.fieldId,e.setIndex)]??e.value)];r[t]=n,T(e.fieldId,e.setIndex,r)},M=e=>{let t=[...LZ(f[PZ(e.fieldId,e.setIndex)]??e.value),``];T(e.fieldId,e.setIndex,t)},N=(e,t)=>{let n=[...LZ(f[PZ(e.fieldId,e.setIndex)]??e.value)];n.splice(t,1),T(e.fieldId,e.setIndex,n),te(e,n)},ie=()=>{y(k.length>0?k[k.length-1]+1:0),D()},ae=async e=>{x(!0);try{await q.delete(a(e)),A>=e&&A>0&&y(A-1),c()}catch(e){gM(e)}finally{x(!1)}},oe=!!zj(r,`uploadAttachment`),se=!!zj(r,`deleteAttachment`),ce=async(e,t)=>{if(t){C(PZ(e.fieldId,e.setIndex));try{let n=await q.upload(o(e.fieldSeqNo,e.setIndex),t);O(e.fieldId,e.setIndex,{id:n.attachmentId,filename:n.filename,fileSize:n.fileSize})}catch(e){gM(e)}finally{C(null)}}},[le,ue]=(0,v.useState)(null),de=async(e,t)=>{ue(`${PZ(e.fieldId,e.setIndex)}_${t}`);try{await q.delete(`${o(e.fieldSeqNo,e.setIndex)}/${t}`),d(n=>n.map(n=>n.fieldId===e.fieldId&&n.setIndex===e.setIndex?{...n,attachments:(n.attachments??[]).filter(e=>e.id!==t)}:n))}catch(e){gM(e)}finally{ue(null)}};function fe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function pe(e,t,n){let r=e.attachments??[],i=PZ(e.fieldId,e.setIndex),a=S===i,o=n&&oe&&(MZ(e.type)||r.length===0);return(0,I.jsxs)(U,{gap:4,children:[(0,I.jsx)(V,{size:`xs`,fw:500,children:t}),r.map(t=>{let r=le===`${i}_${t.id}`,a=s(e.fieldSeqNo,t.id),o=jZ(t.filename);return(0,I.jsxs)(U,{gap:4,children:[o&&(0,I.jsx)(Wd,{href:a,target:`_blank`,children:(0,I.jsx)(Om,{src:a,alt:t.filename,maw:200,mah:200,fit:`contain`,radius:`sm`})}),(0,I.jsxs)(B,{gap:`xs`,children:[!o&&(0,I.jsx)(nM,{size:14}),(0,I.jsx)(Wd,{size:`xs`,href:a,target:`_blank`,children:t.filename}),(0,I.jsxs)(V,{size:`xs`,c:`dimmed`,children:[`(`,fe(t.fileSize),`)`]}),n&&se&&(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,color:`red`,loading:r,onClick:()=>de(e,t.id),title:`Remove attachment`,children:(0,I.jsx)(pM,{size:14})})]})]},t.id)}),r.length===0&&!n&&(0,I.jsx)(V,{size:`xs`,c:`dimmed`,children:`No attachments`}),o&&(0,I.jsx)(Tm,{onChange:t=>ce(e,t),children:e=>(0,I.jsx)(H,{...e,size:`compact-xs`,variant:`light`,leftSection:a?(0,I.jsx)(uu,{size:14}):(0,I.jsx)(dM,{size:14}),loading:a,children:`Upload File`})})]},i)}function me(e,t,n,r){let{label:i,onTextChange:a,onImmediateChange:o,onBlurSave:s}=r,c=e.validation&&!e.validation.valid?e.validation.error:void 0;switch(NZ(e.type)){case tX.date:return(0,I.jsx)(ex,{label:i,size:`xs`,style:{flex:1},valueFormat:`YYYY-MM-DD`,clearable:!0,error:c,value:t?new Date(t+`T00:00:00`):null,onChange:e=>o(e?typeof e==`string`?e:OZ(e):``),rightSection:(0,I.jsx)(RZ,{status:n})});case tX.datetime:return(0,I.jsx)(ax,{label:i,size:`xs`,style:{flex:1},valueFormat:`YYYY-MM-DD HH:mm`,clearable:!0,error:c,value:t?new Date(t):null,onChange:e=>o(e?typeof e==`string`?e:kZ(e):``),rightSection:(0,I.jsx)(RZ,{status:n})});case tX.yesNo:return(0,I.jsxs)(B,{gap:`xs`,align:`center`,children:[i&&(0,I.jsx)(V,{size:`xs`,fw:500,children:i}),(0,I.jsx)(rv,{size:`xs`,onLabel:`Yes`,offLabel:`No`,checked:t===`Yes`,onChange:e=>o(e.currentTarget.checked?`Yes`:`No`)}),(0,I.jsx)(RZ,{status:n})]});case tX.checkbox:return(0,I.jsxs)(B,{gap:`xs`,align:`center`,children:[(0,I.jsx)(yp,{label:i,size:`xs`,checked:t===`checked`,onChange:e=>o(e.currentTarget.checked?`checked`:``)}),(0,I.jsx)(RZ,{status:n})]});case tX.attachment:return null;default:return(0,I.jsx)(Mv,{label:i,size:`xs`,style:{flex:1},error:c,value:t,onChange:e=>a(e.currentTarget.value),onBlur:s,rightSection:(0,I.jsx)(RZ,{status:n})})}}function he(e){let t=IZ(e.value);if(!t)return`—`;if(MZ(e.type)&&Array.isArray(e.value))return e.value.filter(Boolean).join(`, `)||`—`;switch(NZ(e.type)){case tX.date:return new Date(t+`T00:00:00`).toLocaleDateString();case tX.datetime:return new Date(t).toLocaleString();case tX.checkbox:return t===`checked`?`Checked`:`—`;default:return t}}let ge=!n&&!!zj(r,`updateField`);return(0,I.jsxs)(U,{gap:`xs`,mt:`xs`,children:[(0,I.jsx)(V,{size:`xs`,fw:600,c:`dimmed`,children:`Data Fields`}),t&&(0,I.jsxs)(B,{gap:4,children:[k.map(e=>(0,I.jsxs)(H,{size:`compact-xs`,variant:e===A?`filled`:`light`,onClick:()=>y(e),children:[`Set `,e+1]},e)),ge&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,onClick:ie,title:`Add set`,children:(0,I.jsx)(lM,{size:14})}),k.length>1&&(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,color:`red`,loading:b,onClick:()=>ae(A),title:`Delete current set`,children:(0,I.jsx)(uM,{size:14})})]})]}),j.map(e=>{let t=PZ(e.fieldId,e.setIndex),n=m[t],r=e.required?`${e.label} *`:e.label,i=ge,a=f[t]??e.value;if(NZ(e.type)===tX.attachment)return pe(e,r,i);if(!i)return MZ(e.type)&&Array.isArray(e.value)&&e.value.filter(Boolean).length>0?(0,I.jsxs)(U,{gap:2,children:[(0,I.jsxs)(V,{size:`xs`,fw:500,children:[r,`:`]}),e.value.filter(Boolean).map((e,t)=>(0,I.jsxs)(V,{size:`xs`,pl:`sm`,children:[`• `,e]},t))]},t):(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsxs)(V,{size:`xs`,fw:500,children:[r,`:`]}),typeof e.value==`string`&&e.value?.startsWith(`http`)?(0,I.jsx)(Wd,{size:`xs`,href:e.value,target:`_blank`,children:e.value}):(0,I.jsx)(V,{size:`xs`,children:he(e)}),e.validation&&!e.validation.valid&&(0,I.jsx)(V,{size:`xs`,c:`red`,children:e.validation.error})]},t);if(MZ(e.type)){let i=LZ(a);return(0,I.jsxs)(U,{gap:4,children:[(0,I.jsxs)(B,{gap:`xs`,align:`center`,children:[(0,I.jsx)(V,{size:`xs`,fw:500,children:r}),(0,I.jsx)(RZ,{status:n})]}),i.map((t,n)=>(0,I.jsxs)(B,{gap:4,align:`flex-end`,children:[me(e,t,void 0,{onTextChange:t=>re(e,n,t),onImmediateChange:t=>{let r=[...i];r[n]=t,T(e.fieldId,e.setIndex,r),te(e,r)},onBlurSave:()=>void te(e,a)}),i.length>1&&(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,color:`red`,onClick:()=>N(e,n),title:`Remove item`,children:(0,I.jsx)(pM,{size:14})})]},n)),(0,I.jsx)(B,{children:(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,onClick:()=>M(e),title:`Add item`,children:(0,I.jsx)(lM,{size:14})})}),e.validation&&!e.validation.valid&&(0,I.jsx)(V,{size:`xs`,c:`red`,children:e.validation.error})]},t)}return(0,I.jsx)(B,{gap:`xs`,align:`flex-end`,children:me(e,IZ(a),n,{label:r,onTextChange:t=>T(e.fieldId,e.setIndex,t),onImmediateChange:t=>ne(e,t),onBlurSave:()=>void te(e,a)})},t)})]})},BZ=()=>{let{key:e,instanceId:t}=bC(),n=hC(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!0),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),_=(0,v.useCallback)(async()=>{if(!(!e||!t)){o(!0);try{i(await q.get(J.itemInstance(e,t)))}catch(e){gM(e)}finally{o(!1)}}},[e,t]);(0,v.useEffect)(()=>{_()},[_]);let y=()=>{r&&(f(r.key),m(r.quantity==null?``:String(r.quantity)),c(!0))},b=async()=>{if(!(!e||!t)){g(!0);try{let n={key:d,quantity:p?Number(p):null};await q.put(J.itemInstance(e,t),n),c(!1),await _()}catch(e){gM(e)}finally{g(!1)}}},x=async()=>{if(!(!e||!t||!confirm(`Delete this instance?`)))try{await q.delete(J.itemInstance(e,t)),n(`/items/${e}/instances`)}catch(e){gM(e)}};if(a)return(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(U,{align:`center`,children:(0,I.jsx)(uu,{})})});if(!r)return(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(V,{children:`Instance not found.`})});if(s)return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Edit Instance`}),(0,I.jsxs)(U,{children:[(0,I.jsx)(Mv,{label:`Key (lot/serial number)`,value:d,onChange:e=>f(e.currentTarget.value),required:!0}),(0,I.jsx)(Mv,{label:`Quantity`,type:`number`,value:p,onChange:e=>m(e.currentTarget.value)}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>c(!1),children:`Cancel`}),(0,I.jsx)(H,{onClick:b,loading:h,children:`Save`})]})]})]});let S=r.fieldValues.length>0,C=Rj(r._actions,`update`);return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(zv,{order:2,children:r.key}),(0,I.jsx)(CZ,{createdBy:r.createdBy,createdAt:r.createdAt,updatedBy:r.updatedBy,updatedAt:r.updatedAt})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>n(`/items/${e}/instances`),children:`Back`}),Rj(r._actions,`update`)&&(0,I.jsx)(H,{onClick:y,children:`Edit`}),Rj(r._actions,`delete`)&&(0,I.jsx)(H,{color:`red`,variant:`outline`,onClick:x,children:`Delete`})]})]}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,children:(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Key:`}),(0,I.jsx)(V,{ff:`monospace`,children:r.key})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Quantity:`}),(0,I.jsx)(V,{children:r.quantity==null?`—`:r.quantity})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Produced By:`}),r.orderKey?(0,I.jsxs)(Wd,{href:`/erp/orders/${r.orderKey}/runs/${r.orderRunNo}`,onClick:e=>{e.button===1||e.ctrlKey||e.metaKey||(e.preventDefault(),n(`/orders/${r.orderKey}/runs/${r.orderRunNo}`))},children:[r.orderKey,` Order Run `,r.orderRunNo]}):(0,I.jsx)(V,{children:`—`})]})]})}),S&&(0,I.jsxs)(Wp,{withBorder:!0,p:`lg`,mt:`md`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`xs`,children:[(0,I.jsx)(V,{fw:600,children:`Field Values`}),C&&(0,I.jsx)(H,{size:`xs`,variant:l?`filled`:`light`,onClick:()=>u(e=>!e),children:l?`Done Editing`:`Edit Fields`})]}),(0,I.jsx)(zZ,{fieldValues:r.fieldValues,multiSet:!1,completed:!l,_actionTemplates:l?r._actionTemplates:void 0,fieldValueEndpoint:(n,r)=>J.itemInstanceFieldValue(e,t,n),deleteSetEndpoint:n=>J.itemInstanceDeleteSet(e,t,n),attachmentEndpoint:(e,t)=>``,attachmentDownloadUrl:()=>``,onSetDeleted:()=>void _()})]})]})},VZ=()=>{let{key:e}=bC(),t=hC(),[n,r]=qw(),i=Number(n.get(`page`))||1,a=n.get(`search`)||``,[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!0),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(!1),y=(0,v.useCallback)(async()=>{if(e){l(!0);try{let t=new URLSearchParams;t.set(`page`,String(i)),t.set(`pageSize`,`20`),a&&t.set(`search`,a),s(await q.get(`${J.itemInstances(e)}?${t}`))}catch(e){gM(e)}finally{l(!1)}}},[e,i,a]);(0,v.useEffect)(()=>{y()},[y]);let b=async()=>{if(e){_(!0);try{let n={key:f,quantity:m?Number(m):null};t(`/items/${e}/instances/${(await q.post(J.itemInstances(e),n)).id}`)}catch(e){gM(e)}finally{_(!1)}}},x=o?Math.ceil(o.total/o.pageSize):0;return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsx)(B,{children:(0,I.jsxs)(zv,{order:2,children:[`Instances for `,e]})}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>t(`/items/${e}`),children:`Back to Item`}),o&&Rj(o._actions,`create`)&&!u&&(0,I.jsx)(H,{onClick:()=>d(!0),children:`Create New`})]})]}),u&&(0,I.jsxs)(Wp,{withBorder:!0,p:`lg`,mb:`md`,children:[(0,I.jsx)(zv,{order:4,mb:`sm`,children:`New Instance`}),(0,I.jsxs)(U,{children:[(0,I.jsx)(Mv,{label:`Key (lot/serial number)`,value:f,onChange:e=>p(e.currentTarget.value),required:!0,"data-autofocus":!0}),(0,I.jsx)(Mv,{label:`Quantity`,type:`number`,value:m,onChange:e=>h(e.currentTarget.value)}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>{d(!1),p(``),h(``)},children:`Cancel`}),(0,I.jsx)(H,{onClick:b,loading:g,disabled:!f,children:`Create`})]})]})]}),(0,I.jsx)(B,{mb:`md`,children:(0,I.jsx)(Mv,{placeholder:`Search by key...`,value:a,onChange:e=>{let t=e.currentTarget.value;r(e=>(t?e.set(`search`,t):e.delete(`search`),e.set(`page`,`1`),e))},style:{flex:1}})}),c?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):o&&o.items.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Key`}),(0,I.jsx)(W.Th,{children:`Quantity`}),(0,I.jsx)(W.Th,{children:`Order Run`}),(0,I.jsx)(W.Th,{children:`Created`})]})}),(0,I.jsx)(W.Tbody,{children:o.items.map(t=>{let n=`/items/${e}/instances/${t.id}`;return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:t.key})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:(0,I.jsx)(V,{size:`sm`,children:t.quantity==null?`—`:t.quantity})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:(0,I.jsx)(V,{size:`sm`,children:t.orderKey?`${t.orderKey} Run ${t.orderRunNo}`:`—`})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:new Date(t.createdAt).toLocaleDateString()})})]},t.id)})})]}),x>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:x,value:i,onChange:e=>r(t=>(t.set(`page`,String(e)),t))})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`xl`,children:`No instances found.`})]})},HZ=()=>{let e=hC(),[t,n]=qw(),r=Number(t.get(`page`))||1,i=t.get(`search`)||``,[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!0),l=(0,v.useCallback)(async()=>{c(!0);try{let e=new URLSearchParams;e.set(`page`,String(r)),e.set(`pageSize`,`20`),i&&e.set(`search`,i),o(await q.get(`${J.items}?${e}`))}catch(e){gM(e)}finally{c(!1)}},[r,i]);(0,v.useEffect)(()=>{l()},[l]);let u=a?Math.ceil(a.total/a.pageSize):0;return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsx)(zv,{order:2,children:`Items`}),a&&Rj(a._actions,`create`)&&(0,I.jsx)(H,{onClick:()=>e(`/items/new`),children:`Create New`})]}),(0,I.jsx)(B,{mb:`md`,children:(0,I.jsx)(Mv,{placeholder:`Search...`,value:i,onChange:e=>{let t=e.currentTarget.value;n(e=>(t?e.set(`search`,t):e.delete(`search`),e.set(`page`,`1`),e))},style:{flex:1}})}),s?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):a&&a.items.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Key`}),(0,I.jsx)(W.Th,{children:`Description`}),(0,I.jsx)(W.Th,{children:`Created`})]})}),(0,I.jsx)(W.Tbody,{children:a.items.map(e=>{let t=`/items/${e.key}`;return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:e.key})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(V,{size:`sm`,lineClamp:1,children:e.description||`—`})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:new Date(e.createdAt).toLocaleDateString()})})]},e.id)})})]}),u>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:u,value:r,onChange:e=>n(t=>(t.set(`page`,String(e)),t))})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`xl`,children:`No items found.`})]})},UZ=()=>{let{login:e}=xM(),[t,n]=v.useState(``),[r,i]=v.useState(``),[a,o]=v.useState(!1),[s,c]=v.useState(``),l=async()=>{if(!t.trim()||!r.trim()){c(`Please enter both username and password`);return}o(!0),c(``);try{await e(t,r)}catch(e){c(e instanceof Error?e.message:`An error occurred`)}finally{o(!1)}},u=e=>{e.key===`Enter`&&l()};return(0,I.jsx)(Kp,{style:{minHeight:`100vh`},children:(0,I.jsxs)(U,{align:`center`,gap:`lg`,w:320,children:[(0,I.jsx)(`img`,{src:Kj,alt:`NAISYS`,style:{width:`64px`,height:`64px`}}),(0,I.jsx)(V,{size:`xl`,fw:600,children:`NAISYS ERP`}),(0,I.jsxs)(U,{gap:`md`,w:`100%`,children:[s&&(0,I.jsx)(Ld,{color:`red`,variant:`light`,children:s}),(0,I.jsx)(Mv,{label:`Username`,placeholder:`Enter your username`,value:t,onChange:e=>n(e.currentTarget.value),onKeyDown:u,"data-autofocus":!0,disabled:a}),(0,I.jsx)(Mv,{label:`Password`,type:`password`,placeholder:`Enter your password`,value:r,onChange:e=>i(e.currentTarget.value),onKeyDown:u,disabled:a}),(0,I.jsx)(H,{fullWidth:!0,onClick:l,loading:a,disabled:!t.trim()||!r.trim(),children:`Login`})]})]})})},WZ=({initialData:e,isEdit:t,onSubmit:n,onCancel:r})=>{let i=t?ZX:XX,a=rN({initialValues:{key:e?.key??``,description:e?.description??``,status:e?.status??JX.active,itemKey:e?.itemKey??``},validate:oU(i)}),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)([]),[f]=zt(a.values.itemKey,300),p=(0,v.useCallback)(async e=>{try{let t=new URLSearchParams;t.set(`pageSize`,`10`),e&&t.set(`search`,e),d((await q.get(`${J.items}?${t}`)).items.map(e=>e.key))}catch{d([])}},[]);return(0,v.useEffect)(()=>{p(f)},[f,p]),(0,I.jsx)(`form`,{onSubmit:a.onSubmit(async e=>{s(!0),l(null);try{let r=t?{key:e.key,description:e.description,status:e.status,itemKey:e.itemKey||null}:{key:e.key,description:e.description,itemKey:e.itemKey||void 0};await n(i.parse(r))}catch(e){l(e instanceof Error?e.message:`An error occurred`)}finally{s(!1)}}),children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsx)(Mv,{label:`Key`,description:`Unique identifier (alphanumeric, hyphens allowed)`,placeholder:`standard-order`,...a.getInputProps(`key`)}),(0,I.jsx)(Dp,{label:`Produces Item`,placeholder:`Search by item key...`,data:u,...a.getInputProps(`itemKey`)}),(0,I.jsx)(Qm,{label:`Description`,placeholder:`Describe this order...`,...a.getInputProps(`description`),autosize:!0,minRows:3}),t&&(0,I.jsx)(R_,{label:`Status`,data:qX.options.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),...a.getInputProps(`status`)}),c&&(0,I.jsx)(`div`,{style:{color:`var(--mantine-color-red-6)`},children:c}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{type:`submit`,loading:o,children:t?`Save Changes`:`Create`}),(0,I.jsx)(H,{variant:`subtle`,onClick:r,children:`Cancel`})]})]})})},GZ=()=>{let e=hC();return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Create Order`}),(0,I.jsx)(WZ,{onSubmit:async t=>{await q.post(J.orders,t),e(`/orders`)},onCancel:()=>e(`/orders`)})]})},KZ={[jX.draft]:`blue`,[jX.approved]:`green`,[jX.obsolete]:`gray`},qZ=10,JZ=({orderKey:e})=>{let t=hC(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)([]),[m,h]=(0,v.useState)(!1),g=(0,v.useCallback)(async()=>{a(!0);try{let t=new URLSearchParams({page:String(o),pageSize:String(qZ)});m&&t.set(`includeObsolete`,`true`),r(await q.get(`${J.orderRevs(e)}?${t}`))}catch(e){gM(e)}finally{a(!1)}},[e,o,m]);(0,v.useEffect)(()=>{g()},[g]);let _=async()=>{l(!0);try{t(`/orders/${e}/revs/${(await q.post(J.orderRevs(e),{})).revNo}/header`)}catch(e){gM(e)}finally{l(!1)}},y=async t=>{if(confirm(`Approve revision #${t.revNo}?`))try{await q.post(J.orderRevApprove(e,t.revNo),{}),await g()}catch(e){gM(e)}},b=async t=>{if(confirm(`Mark revision #${t.revNo} as obsolete?`))try{await q.post(J.orderRevObsolete(e,t.revNo),{}),await g()}catch(e){gM(e)}},x=async t=>{if(confirm(`Delete revision #${t.revNo}?`))try{await q.delete(J.orderRev(e,t.revNo)),await g()}catch(e){gM(e)}},S=e=>{p(t=>t.includes(e)?t.filter(t=>t!==e):t.length>=2?[t[1],e]:[...t,e])},C=()=>{if(f.length!==2)return;let[n,r]=f.sort((e,t)=>e-t);t(`/orders/${e}/revs/diff?from=${n}&to=${r}`)},w=n?Math.ceil(n.total/qZ):0;return(0,I.jsxs)(Wp,{withBorder:!0,p:`lg`,mt:`lg`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`md`,children:[(0,I.jsx)(zv,{order:4,children:`Revisions`}),(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(yp,{label:`Show obsolete`,checked:m,onChange:e=>{h(e.currentTarget.checked),s(1)}}),u&&f.length===2&&(0,I.jsx)(H,{size:`sm`,variant:`light`,onClick:C,children:`Compare`}),(0,I.jsx)(H,{size:`sm`,variant:u?`filled`:`light`,color:u?`gray`:`violet`,onClick:()=>{d(e=>!e),p([])},children:u?`Cancel`:`Compare`}),n&&Rj(n._actions,`create`)&&(0,I.jsx)(H,{size:`sm`,onClick:_,loading:c,children:`New Revision`})]})]}),i?(0,I.jsx)(U,{align:`center`,py:`md`,children:(0,I.jsx)(uu,{})}):!n||n.items.length===0?(0,I.jsx)(V,{c:`dimmed`,children:`No revisions yet.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[u&&(0,I.jsx)(W.Th,{w:40}),(0,I.jsx)(W.Th,{children:`Rev`}),(0,I.jsx)(W.Th,{children:`Status`}),(0,I.jsx)(W.Th,{children:`Change Summary`}),(0,I.jsx)(W.Th,{children:`Created`}),!u&&(0,I.jsx)(W.Th,{children:`Actions`})]})}),(0,I.jsx)(W.Tbody,{children:n.items.map(t=>{let n=`/orders/${e}/revs/${t.revNo}`;return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},"data-testid":`revision-row-${t.revNo}`,children:[u&&(0,I.jsx)(W.Td,{children:(0,I.jsx)(yp,{checked:f.includes(t.revNo),onChange:()=>S(t.revNo)})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:(0,I.jsxs)(Ap,{color:`violet`,variant:`light`,children:[`REV `,t.revNo]})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:(0,I.jsx)(Ap,{color:KZ[t.status]??`gray`,variant:`light`,"data-testid":`revision-status-${t.revNo}`,children:t.status})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:t.changeSummary??`—`})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:new Date(t.createdAt).toLocaleString()})}),!u&&(0,I.jsx)(W.Td,{children:(0,I.jsxs)(B,{gap:`xs`,children:[Rj(t._actions,`approve`)&&(0,I.jsx)(H,{size:`xs`,variant:`light`,color:`green`,onClick:()=>y(t),"data-testid":`revision-approve-${t.revNo}`,children:`Approve`}),Rj(t._actions,`delete`)&&(0,I.jsx)(H,{size:`xs`,variant:`light`,color:`red`,onClick:()=>x(t),children:`Delete`}),Rj(t._actions,`cut-order`)&&(0,I.jsx)(H,{size:`xs`,variant:`light`,color:`teal`,component:zw,to:`/orders/${e}/runs/new?revNo=${t.revNo}`,"data-testid":`revision-cut-order-${t.revNo}`,children:`Cut Order`}),Rj(t._actions,`obsolete`)&&(0,I.jsx)(H,{size:`xs`,variant:`light`,color:`gray`,onClick:()=>b(t),children:`Mark Obsolete`})]})})]},t.id)})})]}),w>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:w,value:o,onChange:s})})]})]})},YZ=()=>{let{key:e}=bC(),t=hC(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(!1),c=(0,v.useCallback)(async()=>{if(e){a(!0);try{r(await q.get(J.order(e)))}catch(e){gM(e)}finally{a(!1)}}},[e]);return(0,v.useEffect)(()=>{c()},[c]),i?(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(U,{align:`center`,children:(0,I.jsx)(uu,{})})}):n?o?(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Edit Order`}),(0,I.jsx)(WZ,{initialData:{key:n.key,description:n.description,status:n.status,itemKey:n.itemKey},isEdit:!0,onSubmit:async n=>{e&&(await q.put(J.order(e),n),s(!1),n.key&&n.key!==e?t(`/orders/${n.key}`,{replace:!0}):await c())},onCancel:()=>s(!1)})]}):(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(zv,{order:2,children:n.key}),(0,I.jsx)(CZ,{createdBy:n.createdBy,createdAt:n.createdAt,updatedBy:n.updatedBy,updatedAt:n.updatedAt}),(0,I.jsx)(Ap,{color:n.status===JX.active?`green`:`gray`,variant:`light`,size:`lg`,children:n.status})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>t(`/orders`),children:`Back`}),(0,I.jsx)(H,{variant:`light`,component:zw,to:`/orders/${e}/runs`,children:`View Runs`}),Rj(n._actions,`update`)&&(0,I.jsx)(H,{onClick:()=>s(!0),children:`Edit`}),Rj(n._actions,`delete`)&&(0,I.jsx)(H,{color:`red`,variant:`outline`,onClick:async()=>{if(!(!e||!confirm(`Delete this order?`)))try{await q.delete(J.order(e)),t(`/orders`)}catch(e){gM(e)}},children:`Delete`})]})]}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,children:(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Produces Item:`}),n.itemKey?(0,I.jsx)(V,{component:zw,to:`/items/${n.itemKey}`,c:`blue`,style:{textDecoration:`none`},children:n.itemKey}):(0,I.jsx)(V,{children:`—`})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Description:`}),(0,I.jsx)(V,{children:n.description||`—`})]})]})}),(0,I.jsx)(JZ,{orderKey:e})]}):(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(V,{children:`Order not found.`})})},XZ=()=>{let e=hC(),[t,n]=qw(),r=Number(t.get(`page`))||1,i=t.get(`status`)||void 0,a=t.get(`search`)||``,[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!0),u=(0,v.useCallback)(async()=>{l(!0);try{let e=new URLSearchParams;e.set(`page`,String(r)),e.set(`pageSize`,`20`),i&&e.set(`status`,i),a&&e.set(`search`,a),s(await q.get(`${J.orders}?${e}`))}catch(e){gM(e)}finally{l(!1)}},[r,i,a]);(0,v.useEffect)(()=>{u()},[u]);let d=o?Math.ceil(o.total/o.pageSize):0;return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsx)(zv,{order:2,children:`Orders`}),o&&Rj(o._actions,`create`)&&(0,I.jsx)(H,{onClick:()=>e(`/orders/new`),children:`Create New`})]}),(0,I.jsxs)(B,{mb:`md`,children:[(0,I.jsx)(Mv,{placeholder:`Search...`,value:a,onChange:e=>{let t=e.currentTarget.value;n(e=>(t?e.set(`search`,t):e.delete(`search`),e.set(`page`,`1`),e))},style:{flex:1}}),(0,I.jsx)(R_,{placeholder:`All statuses`,data:qX.options.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),value:i??null,onChange:e=>{n(t=>(e?t.set(`status`,e):t.delete(`status`),t.set(`page`,`1`),t))},clearable:!0})]}),c?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):o&&o.items.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Key`}),(0,I.jsx)(W.Th,{children:`Status`}),(0,I.jsx)(W.Th,{children:`Created`})]})}),(0,I.jsx)(W.Tbody,{children:o.items.map(e=>{let t=`/orders/${e.key}`;return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:e.key})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(Ap,{color:e.status===JX.active?`green`:`gray`,variant:`light`,children:e.status})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:new Date(e.createdAt).toLocaleDateString()})})]},e.id)})})]}),d>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:d,value:r,onChange:e=>n(t=>(t.set(`page`,String(e)),t))})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`xl`,children:`No orders found.`})]})},ZZ=({items:e,loading:t,linkBuilder:n})=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{fw:600,children:`OPERATIONS`}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,children:t?(0,I.jsx)(U,{align:`center`,py:`sm`,children:(0,I.jsx)(uu,{size:`sm`})}):!e||e.length===0?(0,I.jsx)(V,{c:`dimmed`,size:`sm`,children:`No operations defined.`}):(0,I.jsxs)(W,{children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Seq`}),(0,I.jsx)(W.Th,{children:`Title`}),(0,I.jsx)(W.Th,{children:`Prerequisites`}),(0,I.jsx)(W.Th,{children:`Steps`}),(0,I.jsx)(W.Th,{children:`Cost`})]})}),(0,I.jsx)(W.Tbody,{children:e.map(e=>{let t=n(e.seqNo);return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.seqNo})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.title})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.predecessors&&e.predecessors.length>0?(0,I.jsx)(B,{gap:4,children:e.predecessors.map(e=>(0,I.jsxs)(Ap,{variant:`light`,size:`sm`,children:[e.seqNo,`. `,e.title]},e.seqNo))}):(0,I.jsx)(V,{c:`dimmed`,size:`sm`,children:`None`})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.stepCount??0})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.cost?`$${e.cost.toFixed(2)}`:`—`})})]},e.id)})})]})})]}),QZ=()=>{let{orderKey:e,revNo:t}=bC(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),u=rN({initialValues:{description:``,changeSummary:``},validate:oU(NX)}),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(!0),h=(0,v.useCallback)(async()=>{if(!(!e||!t)){a(!0);try{r(await q.get(J.orderRev(e,t)))}catch(e){gM(e)}finally{a(!1)}}},[e,t]),g=(0,v.useCallback)(async()=>{if(!(!e||!t)){m(!0);try{f(await q.get(J.orderRevOps(e,t)))}catch(e){gM(e)}finally{m(!1)}}},[e,t]);(0,v.useEffect)(()=>{h(),g()},[h,g]);let _=()=>{n&&(u.setValues({description:n.description||``,changeSummary:n.changeSummary||``}),s(!0))},y=async i=>{if(n){l(!0);try{r(await q.put(J.orderRev(e,t),i)),s(!1)}catch(e){gM(e)}finally{l(!1)}}};if(i)return(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})});if(!n)return(0,I.jsx)(U,{p:`md`,children:(0,I.jsx)(V,{children:`Revision not found.`})});let b=Rj(n._actions,`update`);return(0,I.jsx)(Qp,{size:`md`,py:`xl`,w:`100%`,children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsxs)(B,{justify:`space-between`,children:[(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(V,{fw:600,children:`HEADER`}),(0,I.jsx)(CZ,{createdBy:n.createdBy,createdAt:n.createdAt,updatedBy:n.updatedBy,updatedAt:n.updatedAt})]}),b&&!o&&(0,I.jsx)(H,{size:`xs`,variant:`light`,onClick:_,children:`Edit`})]}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,children:o?(0,I.jsx)(`form`,{onSubmit:u.onSubmit(y),children:(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsx)(Qm,{label:`Description`,placeholder:`Revision description...`,autosize:!0,minRows:3,...u.getInputProps(`description`)}),(0,I.jsx)(Qm,{label:`Change Summary`,placeholder:`What changed in this revision...`,autosize:!0,minRows:3,...u.getInputProps(`changeSummary`)}),(0,I.jsxs)(B,{justify:`flex-end`,mt:`xs`,children:[(0,I.jsx)(H,{variant:`subtle`,size:`xs`,onClick:()=>s(!1),children:`Cancel`}),(0,I.jsx)(H,{type:`submit`,size:`xs`,loading:c,children:`Save`})]})]})}):(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(V,{size:`sm`,fw:500,mb:4,children:`Produces Item`}),n.itemKey?(0,I.jsx)(V,{component:zw,to:`/items/${n.itemKey}`,size:`sm`,c:`blue`,style:{textDecoration:`none`},children:n.itemKey}):(0,I.jsx)(V,{c:`dimmed`,children:`None`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(V,{size:`sm`,fw:500,mb:4,children:`Description`}),n.description?(0,I.jsx)(nU,{children:n.description}):(0,I.jsx)(V,{c:`dimmed`,children:`No description`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(V,{size:`sm`,fw:500,mb:4,children:`Change Summary`}),n.changeSummary?(0,I.jsx)(nU,{children:n.changeSummary}):(0,I.jsx)(V,{c:`dimmed`,children:`No change summary`}),Number(t)>1&&(0,I.jsx)(V,{component:zw,to:`/orders/${e}/revs/diff?from=${Number(t)-1}&to=${t}`,size:`xs`,c:`blue`,mt:`xs`,style:{textDecoration:`none`,display:`inline-block`},children:`Diff with previous revision`})]})]})}),(0,I.jsx)(ZZ,{items:d?.items??null,loading:p,linkBuilder:n=>`/orders/${e}/revs/${t}/ops/${n}`})]})})},$Z=({value:e,onChange:t,...n})=>{let[r]=zt(e,300),[i,a]=(0,v.useState)([]),o=(0,v.useCallback)(async e=>{try{let t=new URLSearchParams;t.set(`pageSize`,`10`),e&&t.set(`search`,e),a((await q.get(`${J.workCenters}?${t}`)).items.map(e=>e.key))}catch{a([])}},[]);return(0,v.useEffect)(()=>{o(r)},[r,o]),(0,I.jsx)(Dp,{data:i,value:e,onChange:t,...n})},eQ=({orderKey:e,revNo:t,opSeqNo:n,showTitle:r=!0})=>{let[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(!0),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(n);n!==f&&(p(n),a(null),s(!0),l(!1));let m=rN({initialValues:{predecessorSeqNo:10},validate:oU(WX)}),h=(0,v.useCallback)(async()=>{s(!0);try{a(await q.get(J.orderRevOpDeps(e,t,n)))}catch(e){gM(e)}finally{s(!1)}},[e,t,n]);(0,v.useEffect)(()=>{h()},[h]);let g=async r=>{if(i){d(!0);try{let o=await q.post(J.orderRevOpDeps(e,t,n),r);l(!1),a({...i,items:[...i.items,o].sort((e,t)=>e.predecessorSeqNo-t.predecessorSeqNo),total:i.total+1})}catch(e){gM(e)}finally{d(!1)}}},_=async r=>{if(i)try{await q.delete(J.orderRevOpDep(e,t,n,r.predecessorSeqNo)),a({...i,items:i.items.filter(e=>e.id!==r.id),total:i.total-1})}catch(e){gM(e)}},y=!o&&i!==null&&i.items.length===0&&!c;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(B,{justify:`space-between`,children:[r&&!y&&(0,I.jsx)(zv,{order:5,children:`Dependencies`}),Rj(i?._actions,`create`)&&!c&&(0,I.jsx)(H,{size:`xs`,variant:`light`,onClick:()=>{m.reset(),l(!0)},children:`Add Dependency`})]}),o?(0,I.jsx)(U,{align:`center`,py:`sm`,children:(0,I.jsx)(uu,{size:`sm`})}):(0,I.jsxs)(U,{gap:`xs`,children:[i?.items.map(e=>(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsxs)(Ap,{variant:`light`,size:`lg`,children:[e.predecessorSeqNo,`. `,e.predecessorTitle]}),zj(i?._actionTemplates,`deleteDependency`)&&(0,I.jsx)(H,{size:`compact-xs`,color:`red`,variant:`subtle`,onClick:()=>_(e),children:`Remove`})]},e.id)),c&&(0,I.jsx)(`form`,{onSubmit:m.onSubmit(g),children:(0,I.jsxs)(B,{gap:`sm`,children:[(0,I.jsx)(Vg,{placeholder:`Predecessor op #`,min:1,step:10,size:`xs`,style:{width:160},...m.getInputProps(`predecessorSeqNo`)}),(0,I.jsx)(H,{type:`submit`,size:`xs`,loading:u,children:`Add`}),(0,I.jsx)(H,{variant:`subtle`,size:`xs`,onClick:()=>l(!1),children:`Cancel`})]})})]})]})},tQ=({orderKey:e,revNo:t,opSeqNo:n})=>{let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!0),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)([]),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(n);n!==b&&(x(n),i(null),o(!0));let S=(0,v.useCallback)(async()=>{o(!0);try{i(await q.get(J.orderRevOpFieldRefs(e,t,n)))}catch(e){gM(e)}finally{o(!1)}},[e,t,n]);(0,v.useEffect)(()=>{S()},[S]);let C=async()=>{c(!0),g(null),m(``),f(!0);try{u((await q.get(J.orderRevOpFieldRefAvailable(e,t,n))).items)}catch(e){gM(e)}finally{f(!1)}},w=async()=>{if(!(!h||!p.trim())){y(!0);try{let r=await q.post(J.orderRevOpFieldRefs(e,t,n),{title:p.trim(),sourceOpSeqNo:h.opSeqNo,sourceStepSeqNo:h.stepSeqNo});c(!1),i(e=>e&&{...e,items:[...e.items,r].sort((e,t)=>e.seqNo-t.seqNo),total:e.total+1})}catch(e){gM(e)}finally{y(!1)}}},T=async a=>{if(r)try{await q.delete(J.orderRevOpFieldRef(e,t,n,a.seqNo)),i({...r,items:r.items.filter(e=>e.id!==a.id),total:r.total-1})}catch(e){gM(e)}};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(B,{justify:`space-between`,children:[!(!a&&r!==null&&r.items.length===0)&&(0,I.jsx)(zv,{order:5,children:`Referenced Fields`}),Rj(r?._actions,`create`)&&(0,I.jsx)(H,{size:`xs`,variant:`light`,onClick:C,children:`Add Reference`})]}),a?(0,I.jsx)(U,{align:`center`,py:`sm`,children:(0,I.jsx)(uu,{size:`sm`})}):(0,I.jsx)(U,{gap:`xs`,children:r?.items.map(n=>(0,I.jsxs)(Wp,{withBorder:!0,p:`sm`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:n.fields.length>0?`xs`:void 0,children:[(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(V,{size:`sm`,fw:500,children:n.title}),(0,I.jsxs)(Wd,{component:zw,to:`/orders/${e}/revs/${t}/ops/${n.sourceOpSeqNo}`,size:`xs`,c:`dimmed`,children:[`Op `,n.sourceOpSeqNo,` / Step `,n.sourceStepSeqNo]})]}),Rj(n._actions,`delete`)&&(0,I.jsx)(H,{size:`compact-xs`,color:`red`,variant:`subtle`,onClick:()=>T(n),children:`Remove`})]}),n.fields.length>0&&(0,I.jsx)(W,{withRowBorders:!1,children:(0,I.jsx)(W.Tbody,{children:n.fields.map(e=>(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Td,{w:40,children:(0,I.jsx)(V,{size:`xs`,c:`dimmed`,children:e.seqNo})}),(0,I.jsx)(W.Td,{children:(0,I.jsx)(V,{size:`xs`,children:e.label})}),(0,I.jsx)(W.Td,{w:100,children:(0,I.jsx)(Ap,{variant:`light`,size:`xs`,children:e.type})})]},e.seqNo))})})]},n.id))}),(0,I.jsx)(Nh,{opened:s,onClose:()=>c(!1),title:`Add Field Reference`,size:`md`,children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsx)(Mv,{label:`Reference Title`,placeholder:`e.g. Dimensions from Inspection`,value:p,onChange:e=>m(e.currentTarget.value),"data-autofocus":!0}),(0,I.jsx)(V,{size:`sm`,fw:500,children:`Select a step with fields:`}),d?(0,I.jsx)(U,{align:`center`,py:`sm`,children:(0,I.jsx)(uu,{size:`sm`})}):l.length===0?(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`No steps with fields available to reference.`}):(0,I.jsx)(U,{gap:`xs`,children:l.map(e=>(0,I.jsx)(gl,{onClick:()=>{g(e),p.trim()||m(`${e.opTitle} - ${e.stepTitle}`)},style:t=>({padding:t.spacing.xs,borderRadius:t.radius.sm,border:`1px solid ${h?.stepId===e.stepId?t.colors.blue[5]:t.colors.gray[3]}`,backgroundColor:h?.stepId===e.stepId?t.colors.blue[0]:void 0}),children:(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsxs)(Ap,{variant:`light`,size:`sm`,children:[`Op `,e.opSeqNo,` / Step `,e.stepSeqNo]}),(0,I.jsxs)(V,{size:`sm`,children:[e.opTitle,` - `,e.stepTitle]}),(0,I.jsxs)(V,{size:`xs`,c:`dimmed`,children:[`(`,e.fieldCount,` field`,e.fieldCount===1?``:`s`,`)`]})]})},e.stepId))}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>c(!1),children:`Cancel`}),(0,I.jsx)(H,{onClick:()=>void w(),loading:_,disabled:!h||!p.trim(),children:`Add Reference`})]})]})})]})},nQ=({orderKey:e,revNo:t,opSeqNo:n})=>{let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!0),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(n);n!==p&&(m(n),i(null),o(!0),c(null),u(!1));let h=rN({initialValues:{seqNo:10,title:``,instructions:``,multiSet:!1},validate:oU(oZ)}),g=rN({initialValues:{seqNo:10,title:``,instructions:``,multiSet:!1},validate:oU(aZ)}),_=(0,v.useCallback)(async()=>{o(!0);try{i(await q.get(J.orderRevOpSteps(e,t,n)))}catch(e){gM(e)}finally{o(!1)}},[e,t,n]);(0,v.useEffect)(()=>{_()},[_]);let y=e=>{h.setValues({seqNo:e.seqNo,title:e.title,instructions:e.instructions,multiSet:e.multiSet}),c(e.id),u(!1)},b=async a=>{let o=r?.items.find(e=>e.id===s);if(!(!o||!r)){f(!0);try{let s=await q.put(J.orderRevOpStep(e,t,n,o.seqNo),a);c(null),i({...r,items:r.items.map(e=>e.id===s.id?s:e).sort((e,t)=>e.seqNo-t.seqNo)})}catch(e){gM(e)}finally{f(!1)}}},x=async a=>{if(!(!r||!confirm(`Delete step ${a.seqNo}?`)))try{await q.delete(J.orderRevOpStep(e,t,n,a.seqNo)),i({...r,items:r.items.filter(e=>e.id!==a.id),total:r.total-1})}catch(e){gM(e)}};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(B,{justify:`space-between`,children:[(0,I.jsx)(zv,{order:5,children:`Steps`}),Rj(r?._actions,`create`)&&!l&&(0,I.jsx)(H,{size:`xs`,variant:`light`,onClick:()=>{g.setValues({seqNo:r?.nextSeqNo??10,title:``,instructions:``}),u(!0),c(null)},children:`Add Step`})]}),a?(0,I.jsx)(U,{align:`center`,py:`sm`,children:(0,I.jsx)(uu,{size:`sm`})}):(0,I.jsxs)(U,{gap:`xs`,children:[r?.items.map(r=>(0,I.jsxs)(Wp,{withBorder:!0,p:`sm`,children:[s===r.id?(0,I.jsx)(`form`,{onSubmit:h.onSubmit(b),children:(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsx)(Vg,{label:`Sequence #`,min:1,step:10,...h.getInputProps(`seqNo`)}),(0,I.jsx)(Mv,{label:`Title`,placeholder:`Short step name`,...h.getInputProps(`title`)}),(0,I.jsx)(Qm,{label:`Instructions (markdown)`,placeholder:`Step instructions...`,autosize:!0,minRows:3,...h.getInputProps(`instructions`)}),(0,I.jsx)(yp,{label:`Allow multiple field value sets`,...h.getInputProps(`multiSet`,{type:`checkbox`})}),(0,I.jsxs)(B,{justify:`flex-end`,mt:`xs`,children:[(0,I.jsx)(H,{variant:`subtle`,size:`xs`,onClick:()=>c(null),children:`Cancel`}),(0,I.jsx)(H,{type:`submit`,size:`xs`,loading:d,children:`Save`})]})]})}):(0,I.jsxs)(B,{justify:`space-between`,align:`flex-start`,wrap:`nowrap`,children:[(0,I.jsxs)(U,{gap:4,style:{flex:1,minWidth:0},children:[(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsxs)(V,{fw:600,size:`sm`,children:[`STEP `,r.seqNo,r.title?`: ${r.title}`:``]}),r.multiSet&&(0,I.jsx)(Ap,{size:`xs`,variant:`light`,color:`violet`,children:`multi-set`})]}),r.instructions?(0,I.jsx)(nU,{children:r.instructions}):(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`No instructions`})]}),(0,I.jsxs)(B,{gap:`xs`,wrap:`nowrap`,children:[(0,I.jsx)(CZ,{createdBy:r.createdBy,createdAt:r.createdAt,updatedBy:r.updatedBy,updatedAt:r.updatedAt}),Rj(r._actions,`update`)&&(0,I.jsx)(H,{size:`xs`,variant:`light`,onClick:()=>y(r),children:`Edit`}),Rj(r._actions,`delete`)&&(0,I.jsx)(H,{size:`xs`,color:`red`,variant:`outline`,onClick:()=>x(r),children:`Delete`})]})]}),(0,I.jsx)(EZ,{fieldsEndpoint:J.orderRevOpStepFields(e,t,n,r.seqNo),fieldEndpoint:i=>J.orderRevOpStepField(e,t,n,r.seqNo,i),initialData:r.fields})]},r.id)),r&&r.items.length===0&&!l&&(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`No steps yet.`}),l&&(0,I.jsx)(Wp,{withBorder:!0,p:`sm`,children:(0,I.jsx)(`form`,{onSubmit:g.onSubmit(async a=>{if(r){f(!0);try{let o=await q.post(J.orderRevOpSteps(e,t,n),a);u(!1),i({...r,items:[...r.items,o].sort((e,t)=>e.seqNo-t.seqNo),total:r.total+1,nextSeqNo:o.seqNo+10})}catch(e){gM(e)}finally{f(!1)}}}),children:(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsx)(Vg,{label:`Sequence #`,min:1,step:10,...g.getInputProps(`seqNo`)}),(0,I.jsx)(Mv,{label:`Title`,placeholder:`Short step name`,...g.getInputProps(`title`)}),(0,I.jsx)(Qm,{label:`Instructions (markdown)`,placeholder:`Step instructions...`,autosize:!0,minRows:3,...g.getInputProps(`instructions`)}),(0,I.jsx)(yp,{label:`Allow multiple field value sets`,...g.getInputProps(`multiSet`,{type:`checkbox`})}),(0,I.jsxs)(B,{justify:`flex-end`,mt:`xs`,children:[(0,I.jsx)(H,{variant:`subtle`,size:`xs`,onClick:()=>u(!1),children:`Cancel`}),(0,I.jsx)(H,{type:`submit`,size:`xs`,loading:d,children:`Add`})]})]})})})]})]})},rQ=()=>{let{orderKey:e,revNo:t,seqNo:n}=bC(),r=hC(),{onOperationUpdate:i}=vC(),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!0),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(!1),p=rN({initialValues:{title:``,description:``,workCenterKey:``,seqNo:10},validate:oU(wX)}),m=(0,v.useCallback)(async()=>{if(!(!e||!t||!n)){c(!0);try{o(await q.get(J.orderRevOp(e,t,n)))}catch(e){gM(e)}finally{c(!1)}}},[e,t,n]);(0,v.useEffect)(()=>{m()},[m]);let h=()=>{a&&(p.setValues({title:a.title,description:a.description,workCenterKey:a.workCenterKey??``,seqNo:a.seqNo}),u(!0))},g=async n=>{if(a){f(!0);try{let s={...n,workCenterKey:n.workCenterKey||null},c=await q.put(J.orderRevOp(e,t,a.seqNo),s);o(c),u(!1),i(),n.seqNo&&n.seqNo!==a.seqNo&&r(`/orders/${e}/revs/${t}/ops/${c.seqNo}`,{replace:!0})}catch(e){gM(e)}finally{f(!1)}}},_=async()=>{if(!(!a||!confirm(`Delete operation "${a.title}"?`)))try{await q.delete(J.orderRevOp(e,t,a.seqNo)),r(`/orders/${e}/revs/${t}`)}catch(e){gM(e)}};if(s)return(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})});if(!a)return(0,I.jsx)(U,{p:`md`,children:(0,I.jsx)(V,{children:`Operation not found.`})});let y=Rj(a._actions,`update`);return(0,I.jsx)(Qp,{size:`md`,py:`xl`,w:`100%`,children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsxs)(B,{justify:`space-between`,children:[(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsxs)(V,{fw:600,children:[`OPERATION `,a.seqNo,`: `,a.title]}),a.workCenterKey&&(0,I.jsxs)(V,{size:`sm`,c:`dimmed`,children:[`[`,a.workCenterKey,`]`]}),(0,I.jsx)(CZ,{createdBy:a.createdBy,createdAt:a.createdAt,updatedBy:a.updatedBy,updatedAt:a.updatedAt})]}),(0,I.jsxs)(B,{gap:`xs`,children:[y&&!l&&(0,I.jsx)(H,{size:`xs`,variant:`light`,onClick:h,children:`Edit`}),Rj(a._actions,`delete`)&&(0,I.jsx)(H,{size:`xs`,color:`red`,variant:`outline`,onClick:_,children:`Delete`})]})]}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,children:l?(0,I.jsx)(`form`,{onSubmit:p.onSubmit(g),children:(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsx)(Mv,{label:`Title`,placeholder:`Operation title...`,...p.getInputProps(`title`)}),(0,I.jsx)(Vg,{label:`Sequence #`,min:1,step:10,...p.getInputProps(`seqNo`)}),(0,I.jsx)($Z,{label:`Work Center`,placeholder:`Search work centers...`,value:p.values.workCenterKey??``,onChange:e=>p.setFieldValue(`workCenterKey`,e)}),(0,I.jsx)(Qm,{label:`Description`,placeholder:`Operation description...`,autosize:!0,minRows:3,...p.getInputProps(`description`)}),(0,I.jsxs)(B,{justify:`flex-end`,mt:`xs`,children:[(0,I.jsx)(H,{variant:`subtle`,size:`xs`,onClick:()=>u(!1),children:`Cancel`}),(0,I.jsx)(H,{type:`submit`,size:`xs`,loading:d,children:`Save`})]})]})}):a.description?(0,I.jsx)(nU,{children:a.description}):(0,I.jsx)(V,{c:`dimmed`,children:`No description`})}),(0,I.jsx)(eQ,{orderKey:e,revNo:t,opSeqNo:n}),(0,I.jsx)(tQ,{orderKey:e,revNo:t,opSeqNo:n}),(0,I.jsx)(nQ,{orderKey:e,revNo:t,opSeqNo:n})]})})},iQ={added:`green`,removed:`red`,modified:`yellow`,unchanged:`gray`},aQ=({changes:e})=>(0,I.jsxs)(W,{withTableBorder:!0,withColumnBorders:!0,fz:`sm`,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Property`}),(0,I.jsx)(W.Th,{children:`From`}),(0,I.jsx)(W.Th,{children:`To`})]})}),(0,I.jsx)(W.Tbody,{children:e.map(e=>(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Td,{fw:600,children:e.field}),(0,I.jsx)(W.Td,{c:`red`,children:String(e.from??`—`)}),(0,I.jsx)(W.Td,{c:`green`,children:String(e.to??`—`)})]},e.field))})]}),oQ=({fields:e})=>{let t=e.filter(e=>e.status!==`unchanged`);return t.length===0?null:(0,I.jsxs)(U,{gap:`xs`,ml:`md`,children:[(0,I.jsx)(V,{fz:`sm`,fw:600,children:`Fields`}),t.map(e=>(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(Ap,{size:`xs`,color:iQ[e.status],children:e.status}),(0,I.jsxs)(V,{fz:`sm`,children:[`#`,e.seqNo,` `,e.label]}),e.changes&&e.changes.length>0&&(0,I.jsxs)(V,{fz:`xs`,c:`dimmed`,children:[`(`,e.changes.map(e=>e.field).join(`, `),`)`]})]},e.seqNo))]})},sQ=({steps:e})=>{let t=e.filter(e=>e.status!==`unchanged`);return t.length===0?null:(0,I.jsxs)(U,{gap:`xs`,ml:`md`,children:[(0,I.jsx)(V,{fz:`sm`,fw:600,children:`Steps`}),t.map(e=>(0,I.jsxs)(Wp,{withBorder:!0,p:`xs`,children:[(0,I.jsxs)(B,{gap:`xs`,mb:e.changes||e.fields?`xs`:0,children:[(0,I.jsx)(Ap,{size:`xs`,color:iQ[e.status],children:e.status}),(0,I.jsxs)(V,{fz:`sm`,children:[`Step #`,e.seqNo,` `,e.title||`(untitled)`]})]}),e.changes&&e.changes.length>0&&(0,I.jsx)(aQ,{changes:e.changes}),e.fields&&(0,I.jsx)(oQ,{fields:e.fields})]},e.seqNo))]})},cQ=({deps:e})=>{let t=e.filter(e=>e.status!==`unchanged`);return t.length===0?null:(0,I.jsxs)(U,{gap:`xs`,ml:`md`,children:[(0,I.jsx)(V,{fz:`sm`,fw:600,children:`Dependencies`}),t.map(e=>(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(Ap,{size:`xs`,color:iQ[e.status],children:e.status}),(0,I.jsxs)(V,{fz:`sm`,children:[`Predecessor: #`,e.predecessorSeqNo,` `,e.predecessorTitle]})]},e.predecessorSeqNo))]})},lQ=({op:e})=>(0,I.jsxs)(Pd.Item,{value:`op-${e.seqNo}`,children:[(0,I.jsx)(Pd.Control,{children:(0,I.jsxs)(B,{gap:`sm`,children:[(0,I.jsx)(Ap,{color:iQ[e.status],children:e.status}),(0,I.jsxs)(V,{fw:600,children:[`OP `,e.seqNo,`: `,e.title]})]})}),(0,I.jsx)(Pd.Panel,{children:(0,I.jsxs)(U,{gap:`sm`,children:[e.changes&&e.changes.length>0&&(0,I.jsx)(aQ,{changes:e.changes}),e.steps&&(0,I.jsx)(sQ,{steps:e.steps}),e.dependencies&&(0,I.jsx)(cQ,{deps:e.dependencies}),!e.changes&&!e.steps&&!e.dependencies&&(0,I.jsx)(V,{fz:`sm`,c:`dimmed`,children:e.status===`added`?`New operation`:e.status===`removed`?`Operation removed`:`No changes`})]})})]}),uQ=()=>{let{orderKey:e}=bC(),[t]=qw(),n=hC(),r=t.get(`from`),i=t.get(`to`),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!0),l=(0,v.useCallback)(async()=>{if(!(!e||!r||!i)){c(!0);try{o(await q.get(J.orderRevDiff(e,r,i)))}catch(e){gM(e)}finally{c(!1)}}},[e,r,i]);(0,v.useEffect)(()=>{l()},[l]);let u=a?a.operations.filter(e=>e.status!==`unchanged`):[],d=a?a.operations.length-u.length:0;return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsxs)(zv,{order:2,children:[`Compare Revisions: Rev `,r,` → Rev `,i]}),(0,I.jsx)(H,{variant:`subtle`,onClick:()=>n(`/orders/${e}`),children:`Back to Order`})]}),s?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):a?(0,I.jsxs)(U,{gap:`md`,children:[a.revisionChanges.length>0&&(0,I.jsxs)(Wp,{withBorder:!0,p:`lg`,children:[(0,I.jsx)(zv,{order:4,mb:`sm`,children:`Revision Properties`}),(0,I.jsx)(aQ,{changes:a.revisionChanges})]}),(0,I.jsxs)(Wp,{withBorder:!0,p:`lg`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`sm`,children:[(0,I.jsx)(zv,{order:4,children:`Operations`}),d>0&&(0,I.jsxs)(V,{fz:`sm`,c:`dimmed`,children:[d,` unchanged operation`,d===1?``:`s`,` hidden`]})]}),u.length===0&&a.revisionChanges.length===0?(0,I.jsx)(V,{c:`dimmed`,children:`No differences found between revisions.`}):u.length===0?(0,I.jsx)(V,{c:`dimmed`,children:`No operation changes.`}):(0,I.jsx)(Pd,{variant:`separated`,multiple:!0,children:u.map(e=>(0,I.jsx)(lQ,{op:e},e.seqNo))})]})]}):(0,I.jsx)(V,{children:`Could not load diff.`})]})},dQ=({orderKey:e,revNo:t,refreshKey:n})=>{let r=hC(),i=fC(),{seqNo:a}=bC(),o=i.pathname.endsWith(`/header`),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(!1),h=rN({initialValues:{seqNo:10,title:``,description:``},validate:oU(CX)}),g=(0,v.useCallback)(async()=>{u(!0);try{c(await q.get(J.orderRevOps(e,t)))}catch(e){gM(e)}finally{u(!1)}},[e,t]);return(0,v.useEffect)(()=>{g()},[g,n]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(U,{gap:`xs`,children:[(0,I.jsx)(Wp,{padding:`sm`,radius:`md`,withBorder:!0,component:`a`,href:`/erp/orders/${e}/revs/${t}/header`,onClick:n=>{n.button===1||n.ctrlKey||n.metaKey||(n.preventDefault(),r(`/orders/${e}/revs/${t}/header`))},style:{cursor:`pointer`,textDecoration:`none`,color:`inherit`,backgroundColor:o?`var(--mantine-color-blue-9)`:void 0},children:(0,I.jsx)(V,{size:`sm`,fw:500,children:`Header`})}),l?(0,I.jsx)(U,{align:`center`,py:`md`,children:(0,I.jsx)(uu,{size:`sm`})}):!s||s.items.length===0?(0,I.jsx)(V,{c:`dimmed`,size:`sm`,ta:`center`,py:`md`,children:`No operations yet.`}):s.items.map(n=>{let i=`/orders/${e}/revs/${t}/ops/${n.seqNo}`;return(0,I.jsx)(Wp,{padding:`sm`,radius:`md`,withBorder:!0,component:`a`,href:`/erp${i}`,onClick:e=>{e.button===1||e.ctrlKey||e.metaKey||(e.preventDefault(),r(i))},style:{cursor:`pointer`,textDecoration:`none`,color:`inherit`,backgroundColor:a===String(n.seqNo)?`var(--mantine-color-blue-9)`:void 0},children:(0,I.jsxs)(V,{size:`sm`,fw:500,children:[n.seqNo,`. `,n.title]})},n.id)}),Rj(s?._actions,`create`)&&(0,I.jsx)(H,{variant:`subtle`,color:`gray`,size:`compact-sm`,leftSection:(0,I.jsx)(lM,{size:`0.9rem`}),onClick:()=>{h.setFieldValue(`seqNo`,s?.nextSeqNo??10),f(!0)},fullWidth:!0,mt:`xs`,children:`Add Operation`})]}),(0,I.jsx)(Nh,{opened:d,onClose:()=>{f(!1),h.reset()},title:`Add Operation`,children:(0,I.jsx)(`form`,{onSubmit:h.onSubmit(async n=>{m(!0);try{let i=await q.post(J.orderRevOps(e,t),{seqNo:n.seqNo,title:n.title,description:n.description||void 0});f(!1),h.reset(),await g(),r(`/orders/${e}/revs/${t}/ops/${i.seqNo}`)}catch(e){gM(e)}finally{m(!1)}}),children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsx)(Vg,{label:`Sequence #`,min:1,step:10,...h.getInputProps(`seqNo`)}),(0,I.jsx)(Mv,{label:`Title`,placeholder:`Operation title...`,...h.getInputProps(`title`)}),(0,I.jsx)(Qm,{label:`Description`,placeholder:`Optional description...`,...h.getInputProps(`description`),autosize:!0,minRows:2}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>{f(!1),h.reset()},children:`Cancel`}),(0,I.jsx)(H,{type:`submit`,loading:p,children:`Create`})]})]})})})]})},fQ={[jX.draft]:`blue`,[jX.approved]:`green`,[jX.obsolete]:`gray`},pQ=({revision:e,orderKey:t,revNo:n,onRefresh:r,onOpenOperations:i})=>{let a=hC();return(0,I.jsxs)(B,{justify:`space-between`,px:`md`,py:`xs`,style:{borderBottom:`calc(0.125rem * var(--mantine-scale)) solid var(--mantine-color-dark-4)`},children:[(0,I.jsxs)(B,{gap:`sm`,children:[i&&(0,I.jsx)(vu,{variant:`subtle`,color:`gray`,hiddenFrom:`md`,onClick:i,children:(0,I.jsx)(oM,{size:`1.2rem`})}),(0,I.jsxs)(V,{size:`lg`,children:[`ORDER:`,` `,(0,I.jsx)(Wd,{href:`/erp/orders/${t}`,onClick:e=>{e.button===1||e.ctrlKey||e.metaKey||(e.preventDefault(),a(`/orders/${t}`))},children:t})]}),(0,I.jsxs)(Ap,{color:`violet`,variant:`light`,size:`sm`,children:[`REV `,e.revNo]}),(0,I.jsx)(Ap,{color:fQ[e.status]??`gray`,variant:`light`,size:`sm`,children:e.status}),e.description&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`|`}),(0,I.jsx)(V,{size:`sm`,c:`dimmed`,lineClamp:1,maw:300,children:e.description})]})]}),(0,I.jsxs)(B,{gap:`xs`,children:[Rj(e._actions,`approve`)&&(0,I.jsx)(H,{size:`xs`,color:`green`,onClick:async()=>{if(confirm(`Approve revision #${n}?`))try{await q.post(J.orderRevApprove(t,n),{}),r()}catch(e){gM(e)}},children:`Approve`}),(0,I.jsx)(iN,{actions:e._actions,rel:`cut-order`,size:`xs`,color:`teal`,onClick:()=>a(`/orders/${t}/runs/new?revNo=${e.revNo}`),children:`Cut Order`}),(0,I.jsx)(iN,{actions:e._actions,rel:`obsolete`,size:`xs`,color:`gray`,variant:`outline`,onClick:async()=>{if(confirm(`Mark revision #${n} as obsolete?`))try{await q.post(J.orderRevObsolete(t,n),{}),r()}catch(e){gM(e)}},children:`Obsolete`}),Rj(e._actions,`delete`)&&(0,I.jsx)(H,{size:`xs`,color:`red`,variant:`outline`,onClick:async()=>{if(confirm(`Delete revision #${n}?`))try{await q.delete(J.orderRev(t,n)),a(`/orders/${t}`)}catch(e){gM(e)}},children:`Delete`})]})]})},mQ=260,hQ=()=>{let{orderKey:e,revNo:t}=bC(),n=fC(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!0),[s,{toggle:c}]=_n(),[l,{open:u,close:d}]=_n(),[f,p]=(0,v.useState)(0),m={onOperationUpdate:()=>p(e=>e+1)},h=(0,v.useCallback)(async()=>{if(!(!e||!t)){o(!0);try{i(await q.get(J.orderRev(e,t)))}catch(e){gM(e)}finally{o(!1)}}},[e,t]);return(0,v.useEffect)(()=>{h()},[h]),(0,v.useEffect)(()=>{d()},[n.pathname]),a?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):!r||!e||!t?(0,I.jsx)(R,{p:`md`,children:(0,I.jsx)(V,{children:`Revision not found.`})}):(0,I.jsxs)(R,{display:`flex`,style:{flexDirection:`column`,height:`calc(100dvh - var(--app-shell-header-height, 0px))`},children:[(0,I.jsx)(pQ,{revision:r,orderKey:e,revNo:t,onRefresh:h,onOpenOperations:u}),(0,I.jsxs)(R,{display:`flex`,style:{flex:1,minHeight:0},children:[(0,I.jsx)(R,{visibleFrom:`md`,style:{flexShrink:0,display:`flex`,flexDirection:`column`},children:s?(0,I.jsx)(R,{style:{borderRight:`1px solid var(--mantine-color-dark-4)`,paddingRight:4},children:(0,I.jsx)(M_,{label:`Expand sidebar`,position:`right`,children:(0,I.jsx)(vu,{variant:`subtle`,color:`gray`,onClick:c,children:(0,I.jsx)(aM,{size:`1.2rem`})})})}):(0,I.jsxs)(R,{style:{width:mQ,minWidth:mQ,borderRight:`1px solid var(--mantine-color-dark-4)`,display:`flex`,flexDirection:`column`,overflowY:`auto`,padding:`0 var(--mantine-spacing-md)`},children:[(0,I.jsx)(B,{justify:`flex-end`,p:4,children:(0,I.jsx)(M_,{label:`Collapse sidebar`,position:`right`,children:(0,I.jsx)(vu,{variant:`subtle`,color:`gray`,size:`sm`,onClick:c,children:(0,I.jsx)(iM,{size:`1rem`})})})}),(0,I.jsx)(dQ,{orderKey:e,revNo:t,refreshKey:f})]})}),(0,I.jsx)(`div`,{style:{flex:1,minHeight:0,overflowY:`auto`,display:`flex`,flexDirection:`column`},children:(0,I.jsx)(GC,{context:m})})]}),(0,I.jsx)(Cm,{opened:l,onClose:d,title:`Operations`,size:mQ,children:(0,I.jsx)(dQ,{orderKey:e,revNo:t,refreshKey:f})})]})};function gQ(){return new Date().toISOString().slice(0,10)}function _Q(e,t){let n={priority:e.priority||void 0,dueAt:e.dueAt||void 0,releaseNote:e.releaseNote||void 0};return t?(e.dueAt||(n.dueAt=null),e.releaseNote||(n.releaseNote=null)):n.revNo=typeof e.revNo==`number`?e.revNo:void 0,n}var vQ=({initialData:e,isEdit:t,onSubmit:n,onCancel:r})=>{let i=t?VX:BX,a=rN({initialValues:{revNo:e?.revNo??``,priority:e?.priority??RX.medium,dueAt:e?.dueAt??(t?``:gQ()),releaseNote:e?.releaseNote??``},validate:e=>oU(i)(_Q(e,t))}),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null);return(0,I.jsx)(`form`,{onSubmit:a.onSubmit(async e=>{s(!0),l(null);try{let r=_Q(e,t);await n(i.parse(r))}catch(e){l(e instanceof Error?e.message:`An error occurred`)}finally{s(!1)}}),children:(0,I.jsxs)(U,{gap:`md`,children:[!t&&(0,I.jsx)(Vg,{label:`Rev No`,placeholder:`Latest approved`,min:1,...a.getInputProps(`revNo`)}),(0,I.jsx)(R_,{label:`Priority`,data:LX.options.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),...a.getInputProps(`priority`)}),(0,I.jsx)(Mv,{label:`Due Date`,type:`date`,...a.getInputProps(`dueAt`)}),(0,I.jsx)(Qm,{label:`Release Note`,placeholder:`Additional notes...`,...a.getInputProps(`releaseNote`),autosize:!0,minRows:3}),c&&(0,I.jsx)(`div`,{style:{color:`var(--mantine-color-red-6)`},children:c}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{type:`submit`,loading:o,children:t?`Save Changes`:`Create`}),(0,I.jsx)(H,{variant:`subtle`,onClick:r,children:`Cancel`})]})]})})},yQ={[RX.low]:`gray`,[RX.medium]:`blue`,[RX.high]:`orange`,[RX.critical]:`red`},bQ=()=>{let{orderKey:e,runNo:t}=bC(),{orderRun:n,onOrderRunUpdate:r}=vC(),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!0),f=(0,v.useCallback)(async()=>{if(e)try{s((await q.get(J.orderRev(e,n.revNo))).description||null)}catch{}},[e,n.revNo]),p=(0,v.useCallback)(async()=>{if(!(!e||!t)){d(!0);try{l(await q.get(J.operationRuns(e,t)))}catch(e){gM(e)}finally{d(!1)}}},[e,t]);(0,v.useEffect)(()=>{f(),p()},[f,p]);let m=async n=>{try{r(await q.put(J.orderRun(e,t),n)),a(!1)}catch(e){gM(e)}},h=Rj(n._actions,`update`);return(0,I.jsx)(Qp,{size:`md`,py:`xl`,w:`100%`,children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsxs)(B,{justify:`space-between`,children:[(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(V,{fw:600,children:`HEADER`}),(0,I.jsx)(CZ,{createdBy:n.createdBy,createdAt:n.createdAt,updatedBy:n.updatedBy,updatedAt:n.updatedAt})]}),h&&!i&&(0,I.jsx)(H,{size:`xs`,variant:`light`,onClick:()=>a(!0),children:`Edit`})]}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,children:i?(0,I.jsx)(vQ,{initialData:{priority:n.priority,dueAt:n.dueAt??``,releaseNote:n.releaseNote??``},isEdit:!0,onSubmit:m,onCancel:()=>a(!1)}):(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:140,children:`Produces Item:`}),n.itemKey?(0,I.jsx)(V,{component:zw,to:`/items/${n.itemKey}`,size:`sm`,c:`blue`,style:{textDecoration:`none`},children:n.itemKey}):(0,I.jsx)(V,{c:`dimmed`,children:`—`})]}),(0,I.jsxs)(B,{align:`flex-start`,children:[(0,I.jsx)(V,{fw:600,w:140,children:`Description:`}),o?(0,I.jsx)(nU,{children:o}):(0,I.jsx)(V,{c:`dimmed`,children:`—`})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:140,children:`Priority:`}),(0,I.jsx)(Ap,{color:yQ[n.priority]??`gray`,variant:`light`,children:n.priority})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:140,children:`Due Date:`}),(0,I.jsx)(V,{children:n.dueAt??`—`})]}),(0,I.jsxs)(B,{align:`flex-start`,children:[(0,I.jsx)(V,{fw:600,w:140,children:`Release Note:`}),(0,I.jsx)(V,{style:{whiteSpace:`pre-wrap`},children:n.releaseNote??`—`})]})]})}),(0,I.jsx)(ZZ,{items:c?.items??null,loading:u,linkBuilder:n=>`/orders/${e}/runs/${t}/ops/${n}`})]})})},xQ={note:`blue`,issue:`red`,feedback:`green`},SQ=({orderKey:e,runNo:t,seqNo:n,refreshKey:r,onCountChange:i})=>{let[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!0),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(`note`),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(n);n!==h&&(g(n),o(null),c(!0));let _=(0,v.useCallback)(async()=>{c(!0);try{let r=await q.get(J.operationRunComments(e,t,n));o(r),i?.(r.total)}catch(e){gM(e)}finally{c(!1)}},[e,t,n,r]);(0,v.useEffect)(()=>{_()},[_]);let y=async()=>{if(l.trim()){m(!0);try{let r=await q.post(J.operationRunComments(e,t,n),{type:d,body:l.trim()});o(e=>e&&{...e,items:[...e.items,r],total:e.total+1}),i?.((a?.total??0)+1),u(``)}catch(e){gM(e)}finally{m(!1)}}},b=a?._actions&&Rj(a._actions,`create`);return s?(0,I.jsx)(U,{align:`center`,py:`sm`,children:(0,I.jsx)(uu,{size:`sm`})}):(0,I.jsxs)(U,{gap:`xs`,children:[a?.items.map(e=>(0,I.jsxs)(Wp,{withBorder:!0,p:`sm`,children:[(0,I.jsxs)(B,{justify:`space-between`,align:`flex-start`,mb:4,children:[(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(V,{size:`sm`,fw:600,children:e.createdBy}),(0,I.jsx)(Ap,{color:xQ[e.type]??`gray`,variant:`light`,size:`xs`,children:e.type})]}),(0,I.jsx)(V,{size:`xs`,c:`dimmed`,children:new Date(e.createdAt).toLocaleString()})]}),(0,I.jsx)(V,{size:`sm`,style:{whiteSpace:`pre-wrap`},children:e.body})]},e.id)),a&&a.items.length===0&&(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`No comments.`}),b&&(0,I.jsx)(Wp,{withBorder:!0,p:`sm`,children:(0,I.jsxs)(U,{gap:`xs`,children:[(0,I.jsx)(Qm,{autosize:!0,minRows:2,placeholder:`Add a comment...`,value:l,onChange:e=>u(e.currentTarget.value)}),(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(R_,{size:`xs`,w:120,value:d,onChange:e=>f(e??`note`),data:[{value:`note`,label:`Note`},{value:`issue`,label:`Issue`},{value:`feedback`,label:`Feedback`}]}),(0,I.jsx)(H,{size:`xs`,loading:p,disabled:!l.trim(),onClick:()=>void y(),children:`Post`})]})]})})]})};function CQ(e,t){let n=(t?new Date(t):new Date).getTime()-new Date(e).getTime(),r=Math.floor(n/6e4),i=Math.floor(r/60),a=r%60;return i>0?`${i}h ${a}m`:`${a}m`}var wQ=({orderKey:e,runNo:t,seqNo:n,refreshKey:r,showTitle:i=!0,onActionsChange:a})=>{let[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!0),[u,d]=(0,v.useState)(n);n!==u&&(d(n),s(null),l(!0));let f=(0,v.useCallback)(async()=>{l(!0);try{s(await q.get(J.laborTickets(e,t,n)))}catch(e){gM(e)}finally{l(!1)}},[e,t,n,r]);(0,v.useEffect)(()=>{f()},[f]),(0,v.useEffect)(()=>{a?.({canClockIn:!!o&&!!Rj(o._actions,`clock-in`),canClockOut:!!o&&!!Rj(o._actions,`clock-out`)})},[o,a]);let p=async r=>{try{await q.delete(J.laborTicket(e,t,n,r)),await f()}catch(e){gM(e)}};return(0,I.jsxs)(I.Fragment,{children:[i&&(0,I.jsx)(zv,{order:5,children:`Labor Tickets`}),c?(0,I.jsx)(U,{align:`center`,py:`sm`,children:(0,I.jsx)(uu,{size:`sm`})}):(0,I.jsx)(I.Fragment,{children:o&&o.items.length>0?(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,withTableBorder:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`User`}),(0,I.jsx)(W.Th,{children:`Run`}),(0,I.jsx)(W.Th,{children:`Clock In`}),(0,I.jsx)(W.Th,{children:`Clock Out`}),(0,I.jsx)(W.Th,{children:`Duration`}),(0,I.jsx)(W.Th,{children:`Cost`}),(0,I.jsx)(W.Th,{})]})}),(0,I.jsx)(W.Tbody,{children:o.items.map(e=>(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Td,{children:e.username}),(0,I.jsx)(W.Td,{children:e.runId==null?`—`:(0,I.jsx)(Wd,{size:`sm`,href:`/supervisor/agents/${e.username}/runs/${e.runId}-1`,children:e.runId})}),(0,I.jsx)(W.Td,{children:new Date(e.clockIn).toLocaleString()}),(0,I.jsx)(W.Td,{children:e.clockOut?new Date(e.clockOut).toLocaleString():(0,I.jsx)(Ap,{color:`green`,size:`sm`,variant:`light`,children:`Open`})}),(0,I.jsx)(W.Td,{children:CQ(e.clockIn,e.clockOut)}),(0,I.jsx)(W.Td,{children:e.cost==null?`—`:`$${e.cost.toFixed(2)}`}),(0,I.jsx)(W.Td,{children:zj(o._actionTemplates,`deleteTicket`)&&(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,color:`red`,onClick:()=>void p(e.id),title:`Delete ticket`,children:(0,I.jsx)(uM,{size:14})})})]},e.id))})]}):(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`No labor tickets.`})})]})},TQ={panelGrid:`_panelGrid_fki9i_1`},EQ=({orderKey:e,runNo:t,seqNo:n,refreshKey:r,onStepUpdate:i,onCountChange:a})=>{let[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!0),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(n),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(!1);n!==f&&(p(n),s(null),l(!0));let x=(0,v.useCallback)(async()=>{l(!0);try{let r=await q.get(J.stepRuns(e,t,n,!0));s(r),a?.(r.total)}catch(e){gM(e)}finally{l(!1)}},[e,t,n,r]);(0,v.useEffect)(()=>{x()},[x]);let S=e=>{s(t=>t&&{...t,items:t.items.map(t=>t.id===e.id?{...t,...e}:t)}),i?.()},C=(e,t,n)=>{s(r=>r&&{...r,items:r.items.map(r=>r.id===e?{...r,_actions:t,_actionTemplates:n}:r)})},w=async(r,i)=>{d(r.id);try{S(await q.post(J.stepRunComplete(e,t,n,r.seqNo),{note:i}))}catch(e){gM(e)}finally{d(null)}},T=async r=>{d(r.id);try{S(await q.post(J.stepRunReopen(e,t,n,r.seqNo),{}))}catch(e){gM(e)}finally{d(null)}},E=async()=>{if(m){b(!0);try{await w(m,g.trim()||void 0),h(null),_(``)}finally{b(!1)}}};return(0,I.jsxs)(I.Fragment,{children:[c?(0,I.jsx)(U,{align:`center`,py:`sm`,children:(0,I.jsx)(uu,{size:`sm`})}):(0,I.jsxs)(U,{gap:`xs`,children:[o?.items.map(r=>{let i=Rj(r._actions,`complete`,{includeDisabled:!0}),a=Rj(r._actions,`reopen`,{includeDisabled:!0});return(0,I.jsx)(Wp,{withBorder:!0,p:`sm`,children:(0,I.jsxs)(U,{gap:`xs`,children:[(0,I.jsxs)(B,{justify:`space-between`,align:`center`,children:[(0,I.jsxs)(V,{fw:600,size:`sm`,children:[`STEP `,r.seqNo,r.title?`: ${r.title}`:``]}),(0,I.jsxs)(B,{gap:`xs`,children:[i&&(0,I.jsx)(M_,{label:Bj(i.disabledReason),disabled:!i.disabledReason,multiline:!0,maw:400,style:{whiteSpace:`pre-line`},children:(0,I.jsxs)(B,{gap:0,children:[(0,I.jsx)(H,{size:`xs`,color:`green`,disabled:i.disabled,loading:u===r.id,onClick:()=>w(r),style:{borderTopRightRadius:0,borderBottomRightRadius:0},children:`Complete`}),(0,I.jsxs)(gh,{position:`bottom-end`,withinPortal:!0,children:[(0,I.jsx)(gh.Target,{children:(0,I.jsx)(H,{size:`xs`,color:`green`,px:6,disabled:i.disabled||u===r.id,style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeft:`1px solid rgba(255,255,255,0.3)`},children:(0,I.jsx)(eM,{size:14})})}),(0,I.jsx)(gh.Dropdown,{children:(0,I.jsx)(gh.Item,{leftSection:(0,I.jsx)(cM,{size:14}),onClick:()=>{h(r),_(``)},children:`Complete with note`})})]})]})}),a&&(0,I.jsxs)(B,{gap:`xs`,align:`center`,children:[(0,I.jsxs)(V,{size:`xs`,c:`green`,children:[`Completed by `,r.updatedBy,` on`,` `,new Date(r.updatedAt).toLocaleString()]}),(()=>{let e=(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,color:`gray`,disabled:a.disabled,loading:u===r.id,onClick:a.disabled?void 0:()=>T(r),title:Bj(a.disabledReason)??`Undo completion`,children:(0,I.jsx)(Qj,{size:14})}),t=Bj(a.disabledReason);return t?(0,I.jsx)(M_,{label:t,multiline:!0,maw:350,style:{whiteSpace:`pre-line`},children:e}):e})()]}),!i&&!a&&r.completed&&(0,I.jsxs)(V,{size:`xs`,c:`green`,children:[`Completed by `,r.updatedBy,` on`,` `,new Date(r.updatedAt).toLocaleString()]})]})]}),r.instructions?(0,I.jsx)(nU,{children:r.instructions}):(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`No instructions`}),r.note&&(0,I.jsxs)(V,{size:`xs`,c:`green`,fs:`italic`,children:[`Note: `,r.note]}),(r.fieldValues?.length??0)>0&&(0,I.jsx)(zZ,{fieldValues:r.fieldValues,multiSet:r.multiSet,completed:r.completed,_actionTemplates:r._actionTemplates,fieldValueEndpoint:(i,a)=>r.multiSet?J.stepRunSetFieldValue(e,t,n,r.seqNo,a,i):J.stepRunFieldValue(e,t,n,r.seqNo,i),deleteSetEndpoint:i=>J.stepRunDeleteSet(e,t,n,r.seqNo,i),attachmentEndpoint:(i,a)=>r.multiSet?J.stepFieldSetAttachments(e,t,n,r.seqNo,a,i):J.stepFieldAttachments(e,t,n,r.seqNo,i),attachmentDownloadUrl:(i,a)=>`/api/erp/${J.stepFieldAttachmentDownload(e,t,n,r.seqNo,i,a)}`,onSetDeleted:()=>void x(),onActionsUpdated:(e,t)=>C(r.id,e,t)})]})},r.id)}),o&&o.items.length===0&&(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`No steps.`})]}),(0,I.jsx)(Nh,{opened:m!==null,onClose:()=>h(null),title:`Complete with note`,size:`sm`,children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsx)(Qm,{label:`Note`,placeholder:`Enter a note...`,value:g,onChange:e=>_(e.currentTarget.value),autosize:!0,minRows:3,maxRows:6,"data-autofocus":!0}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>h(null),children:`Cancel`}),(0,I.jsx)(H,{color:`green`,onClick:()=>void E(),loading:y,children:`Complete`})]})]})})]})},DQ={blocked:`orange`,pending:`gray`,in_progress:`yellow`,completed:`green`,skipped:`gray`,failed:`red`},OQ=({ref_:e,orderKey:t,runNo:n})=>{let r=()=>``;return(0,I.jsxs)(Wp,{withBorder:!0,p:`sm`,children:[(0,I.jsxs)(B,{gap:`xs`,mb:`xs`,children:[(0,I.jsx)(V,{size:`sm`,fw:500,children:e.title}),(0,I.jsxs)(Wd,{component:zw,to:`/orders/${t}/runs/${n}/ops/${e.sourceOpSeqNo}`,size:`xs`,c:`dimmed`,children:[`Op `,e.sourceOpSeqNo,` / Step `,e.sourceStepSeqNo]})]}),(0,I.jsx)(zZ,{fieldValues:e.fieldValues,multiSet:e.multiSet,completed:!0,fieldValueEndpoint:r,deleteSetEndpoint:r,attachmentEndpoint:r,attachmentDownloadUrl:(r,i)=>`/api/erp/${J.stepFieldAttachmentDownload(t,n,String(e.sourceOpSeqNo),String(e.sourceStepSeqNo),r,i)}`,onSetDeleted:r})]})},kQ=()=>{let{orderKey:e,runNo:t,seqNo:n}=bC(),{onOperationUpdate:r,orderRun:i,refreshOrderRun:a}=vC(),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!0),[u,d]=(0,v.useState)(0),[f,p]=(0,v.useState)(`description`),[m,h]=(0,v.useState)(`steps`),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(``),[T,E]=(0,v.useState)({canClockIn:!1,canClockOut:!1}),[D,O]=(0,v.useState)(!1),[k,A]=(0,v.useState)(!1),[j,ee]=(0,v.useState)(``),[te,ne]=(0,v.useState)(!1),re=(0,v.useCallback)(async()=>{if(!(!e||!t||!n)){l(!0);try{s(await q.get(J.operationRun(e,t,n)))}catch(e){gM(e)}finally{l(!1)}}},[e,t,n]);(0,v.useEffect)(()=>{re()},[re]);let M=async r=>{if(!(!e||!t||!n))try{s(await q.put(J.operationRun(e,t,n),{assignedToId:r})),S(!1)}catch(e){gM(e)}},N=async(i,o={})=>{if(!e||!t||!n)return;let c={start:J.operationRunStart,complete:J.operationRunComplete,skip:J.operationRunSkip,fail:J.operationRunFail,reopen:J.operationRunReopen};try{let l=await q.post(c[i](e,t,n),o);s(e=>e&&{...e,...l}),d(e=>e+1),r(),a()}catch(e){gM(e)}},ie=async()=>{if(!(!e||!t||!n)){O(!0);try{await q.post(J.laborTicketClockIn(e,t,n),{}),d(e=>e+1)}catch(e){gM(e)}finally{O(!1)}}},ae=async()=>{if(!(!e||!t||!n)){O(!0);try{await q.post(J.laborTicketClockOut(e,t,n),{}),d(e=>e+1)}catch(e){gM(e)}finally{O(!1)}}},oe=async()=>{ne(!0);try{await N(`complete`,{note:j.trim()||void 0}),A(!1),ee(``)}finally{ne(!1)}};return c?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):o?(0,I.jsxs)(Qp,{size:`md`,py:`xl`,w:`100%`,children:[(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsxs)(B,{justify:`space-between`,children:[(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsxs)(V,{fw:600,children:[`OPERATION `,o.seqNo,`: `,o.title]}),o.workCenterKey&&(0,I.jsxs)(V,{size:`sm`,c:`dimmed`,children:[`[`,o.workCenterKey,`]`]}),(0,I.jsx)(CZ,{createdBy:o.createdBy,createdAt:o.createdAt,updatedBy:o.updatedBy,updatedAt:o.updatedAt}),(0,I.jsx)(Ap,{color:DQ[o.status]??`gray`,variant:`light`,size:`sm`,children:o.status}),o.assignedTo?(0,I.jsxs)(B,{gap:4,children:[(0,I.jsxs)(V,{size:`sm`,c:`dimmed`,children:[`assigned to `,o.assignedTo]}),Rj(o._actions,`assign`)&&(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,color:`gray`,onClick:()=>void M(null),title:`Unassign`,children:(0,I.jsx)(pM,{size:12})})]}):Rj(o._actions,`assign`)&&(0,I.jsxs)(nu,{opened:x,onChange:S,position:`bottom`,withArrow:!0,children:[(0,I.jsx)(nu.Target,{children:(0,I.jsx)(V,{size:`sm`,c:`blue`,style:{cursor:`pointer`},onClick:()=>S(!0),children:`assign`})}),(0,I.jsx)(nu.Dropdown,{children:(0,I.jsx)(hZ,{placeholder:`Search users...`,value:C,onChange:w,onUserSelect:e=>{w(``),M(e.id)},size:`xs`,w:200})})]})]}),(0,I.jsxs)(B,{gap:`xs`,children:[(T.canClockIn||T.canClockOut)&&(0,I.jsxs)(I.Fragment,{children:[T.canClockIn&&(0,I.jsx)(H,{size:`xs`,color:`green`,variant:`outline`,loading:D,onClick:()=>void ie(),children:`Clock In`}),T.canClockOut&&(0,I.jsx)(H,{size:`xs`,color:`orange`,variant:`outline`,loading:D,onClick:()=>void ae(),children:`Clock Out`}),(0,I.jsx)(nm,{orientation:`vertical`})]}),(0,I.jsx)(iN,{actions:o._actions,rel:`start`,size:`xs`,color:`green`,onClick:()=>N(`start`),children:`Start`}),Rj(o._actions,`complete`,{includeDisabled:!0})&&(()=>{let e=Rj(o._actions,`complete`,{includeDisabled:!0});return(0,I.jsxs)(B,{gap:0,children:[(0,I.jsx)(H,{size:`xs`,color:`green`,disabled:e.disabled,onClick:()=>N(`complete`),style:{borderTopRightRadius:0,borderBottomRightRadius:0},children:`Complete`}),(0,I.jsxs)(gh,{position:`bottom-end`,withinPortal:!0,children:[(0,I.jsx)(gh.Target,{children:(0,I.jsx)(H,{size:`xs`,color:`green`,px:6,disabled:e.disabled,style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeft:`1px solid rgba(255,255,255,0.3)`},children:(0,I.jsx)(eM,{size:14})})}),(0,I.jsx)(gh.Dropdown,{children:(0,I.jsx)(gh.Item,{leftSection:(0,I.jsx)(cM,{size:14}),onClick:()=>{A(!0),ee(``)},children:`Complete with note`})})]})]})})(),(()=>{let e=Rj(o._actions,`reopen`,{includeDisabled:!0});if(!e)return null;let{label:t,color:n}={[DX.completed]:{label:`Completed`,color:`green`},[DX.skipped]:{label:`Skipped`,color:`gray`},[DX.failed]:{label:`Failed`,color:`red`}}[o.status]??{label:o.status,color:`gray`},r=(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,color:`gray`,disabled:e.disabled,onClick:e.disabled?void 0:()=>N(`reopen`),title:Bj(e.disabledReason)??`Undo ${t.toLowerCase()}`,children:(0,I.jsx)(Qj,{size:14})});return(0,I.jsxs)(B,{gap:`xs`,align:`center`,children:[(0,I.jsxs)(V,{size:`xs`,c:n,children:[t,` by `,o.updatedBy,` on`,` `,new Date(o.updatedAt).toLocaleString(),o.cost?` for $${o.cost.toFixed(2)}`:``]}),(()=>{let t=Bj(e.disabledReason);return t?(0,I.jsx)(M_,{label:t,multiline:!0,maw:350,style:{whiteSpace:`pre-line`},children:r}):r})()]})})(),Rj(o._actions,`skip`)&&(0,I.jsx)(H,{size:`xs`,color:`gray`,variant:`outline`,onClick:()=>N(`skip`),children:`Skip`}),Rj(o._actions,`fail`)&&(0,I.jsx)(H,{size:`xs`,color:`red`,variant:`outline`,onClick:()=>N(`fail`),children:`Fail`})]})]}),(0,I.jsxs)(jv,{value:f,onChange:p,children:[(0,I.jsxs)(jv.List,{children:[(0,I.jsx)(jv.Tab,{value:`description`,children:`Description`}),(0,I.jsx)(jv.Tab,{value:`dependencies`,children:`Dependencies`}),(0,I.jsx)(jv.Tab,{value:`labor`,children:`Labor Tickets`})]}),(0,I.jsxs)(`div`,{className:TQ.panelGrid,children:[(0,I.jsx)(jv.Panel,{value:`description`,pt:`sm`,keepMounted:!0,"data-active":f===`description`||void 0,children:(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,children:(0,I.jsxs)(U,{gap:`sm`,children:[o.description&&(0,I.jsx)(nU,{children:o.description}),o.note&&(0,I.jsxs)(V,{size:`xs`,c:DQ[o.status]??`dimmed`,fs:`italic`,children:[`Note: `,o.note]})]})})}),(0,I.jsx)(jv.Panel,{value:`dependencies`,pt:`sm`,keepMounted:!0,"data-active":f===`dependencies`||void 0,children:(0,I.jsx)(eQ,{orderKey:e,revNo:String(i.revNo),opSeqNo:n,showTitle:!1})}),(0,I.jsx)(jv.Panel,{value:`labor`,pt:`sm`,keepMounted:!0,"data-active":f===`labor`||void 0,children:(0,I.jsx)(wQ,{orderKey:e,runNo:t,seqNo:n,refreshKey:u,showTitle:!1,onActionsChange:E})})]})]}),o.fieldRefSummary&&o.fieldRefSummary.length>0&&(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsx)(zv,{order:5,children:`Referenced Fields`}),o.fieldRefSummary.map(n=>(0,I.jsx)(OQ,{ref_:n,orderKey:e,runNo:t},n.seqNo))]}),(0,I.jsx)(I_,{value:m,onChange:h,data:[{value:`steps`,label:`Steps${g?` (${g})`:``}`},{value:`comments`,label:`Comments${y?` (${y})`:``}`}]}),(0,I.jsx)(`div`,{style:{display:m===`steps`?void 0:`none`},children:(0,I.jsx)(EQ,{orderKey:e,runNo:t,seqNo:n,refreshKey:u,onStepUpdate:re,onCountChange:_})}),(0,I.jsx)(`div`,{style:{display:m===`comments`?void 0:`none`},children:(0,I.jsx)(SQ,{orderKey:e,runNo:t,seqNo:n,refreshKey:u,onCountChange:b})})]}),(0,I.jsx)(Nh,{opened:k,onClose:()=>A(!1),title:`Complete with note`,size:`sm`,children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsx)(Qm,{label:`Note`,placeholder:`Enter a note...`,value:j,onChange:e=>ee(e.currentTarget.value),autosize:!0,minRows:3,maxRows:6,"data-autofocus":!0}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>A(!1),children:`Cancel`}),(0,I.jsx)(H,{color:`green`,onClick:()=>void oe(),loading:te,children:`Complete`})]})]})})]}):(0,I.jsx)(U,{p:`md`,children:(0,I.jsx)(V,{children:`Operation run not found.`})})},AQ=()=>{let{orderKey:e}=bC(),t=hC(),[n]=qw(),r=Number(n.get(`revNo`))||0;return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Create Order Run`}),(0,I.jsx)(vQ,{initialData:{revNo:r||void 0},onSubmit:async n=>{t(`/orders/${e}/runs/${(await q.post(J.orderRuns(e),n)).runNo}`)},onCancel:()=>t(`/orders/${e}/runs`)})]})},jQ={blocked:`orange`,pending:`gray`,in_progress:`yellow`,completed:`green`,skipped:`gray`,failed:`red`},MQ=({orderKey:e,runNo:t,refreshKey:n})=>{let r=hC(),i=fC(),{seqNo:a}=bC(),o=i.pathname.endsWith(`/header`),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!0),d=(0,v.useCallback)(async()=>{u(!0);try{c(await q.get(J.operationRuns(e,t)))}catch(e){gM(e)}finally{u(!1)}},[e,t]);return(0,v.useEffect)(()=>{d()},[d,n]),(0,I.jsxs)(U,{gap:`xs`,children:[(0,I.jsx)(Wp,{padding:`sm`,radius:`md`,withBorder:!0,component:`a`,href:`/erp/orders/${e}/runs/${t}/header`,onClick:n=>{n.button===1||n.ctrlKey||n.metaKey||(n.preventDefault(),r(`/orders/${e}/runs/${t}/header`))},style:{cursor:`pointer`,textDecoration:`none`,color:`inherit`,backgroundColor:o?`var(--mantine-color-blue-9)`:void 0},children:(0,I.jsx)(V,{size:`sm`,fw:500,children:`Header`})}),l?(0,I.jsx)(U,{align:`center`,py:`md`,children:(0,I.jsx)(uu,{size:`sm`})}):!s||s.items.length===0?(0,I.jsx)(V,{c:`dimmed`,size:`sm`,ta:`center`,py:`md`,children:`No operation runs yet.`}):s.items.map(n=>{let i=`/orders/${e}/runs/${t}/ops/${n.seqNo}`;return(0,I.jsxs)(Wp,{padding:`sm`,radius:`md`,withBorder:!0,component:`a`,href:`/erp${i}`,onClick:e=>{e.button===1||e.ctrlKey||e.metaKey||(e.preventDefault(),r(i))},style:{cursor:`pointer`,textDecoration:`none`,color:`inherit`,backgroundColor:a===String(n.seqNo)?`var(--mantine-color-blue-9)`:void 0},children:[(0,I.jsxs)(V,{size:`sm`,fw:500,children:[n.seqNo,`. `,n.title]}),(0,I.jsx)(Ap,{color:jQ[n.status]??`gray`,variant:`light`,size:`xs`,mt:4,children:n.status})]},n.id)})]})};function NQ(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function PQ(e){return`${NQ(e)}T${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`}var FQ=({opened:e,onClose:t,orderRun:n,orderKey:r,runNo:i,onCompleted:a})=>{let[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)([]),[f,p]=(0,v.useState)({}),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(!1);(0,v.useEffect)(()=>{!e||!n.itemKey||(h(!0),q.get(J.itemFields(n.itemKey)).then(e=>{d(e.items);let t={};for(let n of e.items)t[n.id]=``;p(t)}).catch(gM).finally(()=>h(!1)))},[e,n.itemKey]);let y=()=>{s(``),l(``),p({}),t()},b=async()=>{_(!0);try{let e={};o.trim()&&(e.instanceKey=o.trim()),typeof c==`number`&&(e.quantity=c);let t=Object.entries(f).filter(([,e])=>e!==``).map(([e,t])=>({fieldId:Number(e),value:t}));t.length>0&&(e.fieldValues=t),a(await q.post(J.orderRunComplete(r,i),e)),y()}catch(e){gM(e)}finally{_(!1)}},x=(e,t)=>{p(n=>({...n,[e]:t}))};return(0,I.jsx)(Nh,{opened:e,onClose:y,title:`Complete Order Run`,size:`md`,children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsx)(Mv,{label:`Instance Key (SN / Lot Code)`,placeholder:`Leave blank to auto-generate`,value:o,onChange:e=>s(e.currentTarget.value),"data-autofocus":!0}),(0,I.jsx)(Vg,{label:`Quantity`,placeholder:`Optional`,value:c,onChange:l,min:0,decimalScale:4}),m&&(0,I.jsx)(B,{justify:`center`,children:(0,I.jsx)(uu,{size:`sm`})}),u.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{size:`sm`,fw:600,c:`dimmed`,children:`Item Fields`}),u.map(e=>{let t=f[e.id]??``,n=e.required?`${e.label} *`:e.label;switch(e.type){case tX.date:return(0,I.jsx)(ex,{label:n,size:`sm`,valueFormat:`YYYY-MM-DD`,clearable:!0,value:t?new Date(t+`T00:00:00`):null,onChange:t=>x(e.id,t?typeof t==`string`?t:NQ(t):``)},e.id);case tX.datetime:return(0,I.jsx)(ax,{label:n,size:`sm`,valueFormat:`YYYY-MM-DD HH:mm`,clearable:!0,value:t?new Date(t):null,onChange:t=>x(e.id,t?typeof t==`string`?t:PQ(t):``)},e.id);case tX.yesNo:return(0,I.jsxs)(B,{gap:`xs`,align:`center`,children:[(0,I.jsx)(V,{size:`sm`,fw:500,children:n}),(0,I.jsx)(rv,{size:`sm`,onLabel:`Yes`,offLabel:`No`,checked:t===`Yes`,onChange:t=>x(e.id,t.currentTarget.checked?`Yes`:`No`)})]},e.id);case tX.checkbox:return(0,I.jsx)(yp,{label:n,size:`sm`,checked:t===`checked`,onChange:t=>x(e.id,t.currentTarget.checked?`checked`:``)},e.id);case tX.number:return(0,I.jsx)(Mv,{label:n,size:`sm`,type:`number`,value:t,onChange:t=>x(e.id,t.currentTarget.value)},e.id);default:return(0,I.jsx)(Mv,{label:n,size:`sm`,value:t,onChange:t=>x(e.id,t.currentTarget.value)},e.id)}})]}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:y,children:`Cancel`}),(0,I.jsx)(H,{color:`green`,onClick:b,loading:g,children:`Complete`})]})]})})},IQ={[IX.released]:`blue`,[IX.started]:`yellow`,[IX.closed]:`green`,[IX.cancelled]:`gray`},LQ={[RX.low]:`gray`,[RX.medium]:`blue`,[RX.high]:`orange`,[RX.critical]:`red`},RQ=({orderRun:e,orderKey:t,runNo:n,onUpdate:r,onOpenOperations:i})=>{let a=hC(),[o,{open:s,close:c}]=_n(),l=async e=>{let i={start:J.orderRunStart,close:J.orderRunClose,cancel:J.orderRunCancel,reopen:J.orderRunReopen};try{r(await q.post(i[e](t,n),{}))}catch(e){gM(e)}},u=async()=>{if(confirm(`Delete this order run?`))try{await q.delete(J.orderRun(t,n)),a(`/orders/${t}/runs`)}catch(e){gM(e)}};return(0,I.jsxs)(B,{justify:`space-between`,px:`md`,py:`xs`,style:{borderBottom:`calc(0.125rem * var(--mantine-scale)) solid var(--mantine-color-dark-4)`},children:[(0,I.jsxs)(B,{gap:`sm`,children:[i&&(0,I.jsx)(vu,{variant:`subtle`,color:`gray`,hiddenFrom:`md`,onClick:i,children:(0,I.jsx)(oM,{size:`1.2rem`})}),(0,I.jsxs)(V,{size:`lg`,children:[`ORDER:`,` `,(0,I.jsx)(Wd,{href:`/erp/orders/${t}`,onClick:e=>{e.button===1||e.ctrlKey||e.metaKey||(e.preventDefault(),a(`/orders/${t}`))},children:t})]}),(0,I.jsxs)(Ap,{component:`a`,href:`/erp/orders/${t}/revs/${e.revNo}`,onClick:n=>{n.button===1||n.ctrlKey||n.metaKey||(n.preventDefault(),a(`/orders/${t}/revs/${e.revNo}`))},color:`violet`,variant:`light`,size:`sm`,style:{cursor:`pointer`},children:[`REV `,e.revNo]}),(0,I.jsxs)(V,{size:`lg`,fw:`bold`,children:[`RUN `,e.runNo]}),(0,I.jsx)(Ap,{color:IQ[e.status]??`gray`,variant:`light`,size:`sm`,"data-testid":`order-run-status`,children:e.status}),(0,I.jsx)(Ap,{color:LQ[e.priority]??`gray`,variant:`light`,size:`sm`,children:e.priority}),e.releaseNote&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`|`}),(0,I.jsx)(V,{size:`sm`,c:`dimmed`,lineClamp:1,maw:300,children:e.releaseNote})]}),e.instanceKey&&e.itemKey&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`|`}),(0,I.jsxs)(V,{size:`sm`,c:`dimmed`,children:[`Completed into`,` `,(0,I.jsxs)(Wd,{size:`sm`,href:`/erp/items/${e.itemKey}/instances/${e.instanceId}`,onClick:t=>{t.button===1||t.ctrlKey||t.metaKey||(t.preventDefault(),a(`/items/${e.itemKey}/instances/${e.instanceId}`))},children:[e.itemKey,` `,e.instanceKey]})]})]})]}),(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(iN,{actions:e._actions,rel:`start`,size:`xs`,color:`green`,"data-testid":`order-run-start`,onClick:()=>l(`start`),children:`Start`}),(0,I.jsx)(iN,{actions:e._actions,rel:`complete`,size:`xs`,color:`green`,"data-testid":`order-run-complete`,onClick:s,children:`Complete`}),(0,I.jsx)(iN,{actions:e._actions,rel:`close`,size:`xs`,color:`green`,"data-testid":`order-run-close`,onClick:()=>l(`close`),children:`Close`}),Rj(e._actions,`reopen`)&&(0,I.jsxs)(B,{gap:`xs`,align:`center`,children:[(0,I.jsxs)(V,{size:`xs`,c:e.status===IX.closed?`green`:`orange`,children:[e.status===IX.closed?`Closed`:`Cancelled`,` `,`by `,e.updatedBy,` on`,` `,new Date(e.updatedAt).toLocaleString(),e.cost?` for $${e.cost.toFixed(2)}`:``]}),(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,color:`gray`,onClick:()=>l(`reopen`),title:`Undo ${e.status===IX.closed?`close`:`cancel`}`,children:(0,I.jsx)(Qj,{size:14})})]}),Rj(e._actions,`cancel`)&&(0,I.jsx)(H,{size:`xs`,color:`orange`,variant:`outline`,onClick:()=>{confirm(`Cancel this order run?`)&&l(`cancel`)},children:`Cancel`}),Rj(e._actions,`delete`)&&(0,I.jsx)(H,{size:`xs`,color:`red`,variant:`outline`,onClick:u,children:`Delete`})]}),(0,I.jsx)(FQ,{opened:o,onClose:c,orderRun:e,orderKey:t,runNo:n,onCompleted:r})]})},zQ=260,BQ=()=>{let{orderKey:e,runNo:t}=bC(),n=fC(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!0),[s,{toggle:c}]=_n(),[l,{open:u,close:d}]=_n(),[f,p]=(0,v.useState)(0),m={onOperationUpdate:()=>p(e=>e+1),orderRun:r,onOrderRunUpdate:i,refreshOrderRun:()=>void h()},h=(0,v.useCallback)(async()=>{if(!(!e||!t)){o(!0);try{i(await q.get(J.orderRun(e,t)))}catch(e){gM(e)}finally{o(!1)}}},[e,t]);return(0,v.useEffect)(()=>{h()},[h]),(0,v.useEffect)(()=>{d()},[n.pathname]),a?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):!r||!e||!t?(0,I.jsx)(R,{p:`md`,children:(0,I.jsx)(V,{children:`Order run not found.`})}):(0,I.jsxs)(R,{display:`flex`,style:{flexDirection:`column`,height:`calc(100dvh - var(--app-shell-header-height, 0px))`},children:[(0,I.jsx)(RQ,{orderRun:r,orderKey:e,runNo:t,onUpdate:i,onOpenOperations:u}),(0,I.jsxs)(R,{display:`flex`,style:{flex:1,minHeight:0},children:[(0,I.jsx)(R,{visibleFrom:`md`,style:{flexShrink:0,display:`flex`,flexDirection:`column`},children:s?(0,I.jsx)(R,{style:{borderRight:`1px solid var(--mantine-color-dark-4)`,paddingRight:4},children:(0,I.jsx)(M_,{label:`Expand sidebar`,position:`right`,children:(0,I.jsx)(vu,{variant:`subtle`,color:`gray`,onClick:c,children:(0,I.jsx)(aM,{size:`1.2rem`})})})}):(0,I.jsxs)(R,{style:{width:zQ,minWidth:zQ,borderRight:`1px solid var(--mantine-color-dark-4)`,display:`flex`,flexDirection:`column`,overflowY:`auto`,padding:`0 var(--mantine-spacing-md)`},children:[(0,I.jsx)(B,{justify:`flex-end`,p:4,children:(0,I.jsx)(M_,{label:`Collapse sidebar`,position:`right`,children:(0,I.jsx)(vu,{variant:`subtle`,color:`gray`,size:`sm`,onClick:c,children:(0,I.jsx)(iM,{size:`1rem`})})})}),(0,I.jsx)(MQ,{orderKey:e,runNo:t,refreshKey:f})]})}),(0,I.jsx)(`div`,{style:{flex:1,minHeight:0,overflowY:`auto`,display:`flex`,flexDirection:`column`},children:(0,I.jsx)(GC,{context:m})})]}),(0,I.jsx)(Cm,{opened:l,onClose:d,title:`Operations`,size:zQ,children:(0,I.jsx)(MQ,{orderKey:e,runNo:t,refreshKey:f})})]})},VQ={[IX.released]:`blue`,[IX.started]:`yellow`,[IX.closed]:`green`,[IX.cancelled]:`gray`},HQ={[RX.low]:`gray`,[RX.medium]:`blue`,[RX.high]:`orange`,[RX.critical]:`red`},UQ=()=>{let{orderKey:e}=bC(),[t,n]=qw(),r=Number(t.get(`page`))||1,i=t.get(`status`)||void 0,a=t.get(`priority`)||void 0,o=t.get(`search`)||``,[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!0),d=(0,v.useCallback)(async()=>{u(!0);try{let t=new URLSearchParams;t.set(`page`,String(r)),t.set(`pageSize`,`20`),i&&t.set(`status`,i),a&&t.set(`priority`,a),o&&t.set(`search`,o),c(await q.get(`${J.orderRuns(e)}?${t}`))}catch(e){gM(e)}finally{u(!1)}},[e,r,i,a,o]);(0,v.useEffect)(()=>{d()},[d]);let f=s?Math.ceil(s.total/s.pageSize):0;return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsxs)(zv,{order:2,children:[`Runs for `,e]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{variant:`subtle`,component:zw,to:`/orders/${e}`,children:`Back to Order`}),(0,I.jsx)(H,{component:zw,to:`/orders/${e}/runs/new`,children:`Create New`})]})]}),(0,I.jsxs)(B,{mb:`md`,children:[(0,I.jsx)(Mv,{placeholder:`Search...`,value:o,onChange:e=>{let t=e.currentTarget.value;n(e=>(t?e.set(`search`,t):e.delete(`search`),e.set(`page`,`1`),e))},style:{flex:1}}),(0,I.jsx)(R_,{placeholder:`All statuses`,data:FX.options.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),value:i??null,onChange:e=>{n(t=>(e?t.set(`status`,e):t.delete(`status`),t.set(`page`,`1`),t))},clearable:!0}),(0,I.jsx)(R_,{placeholder:`All priorities`,data:LX.options.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),value:a??null,onChange:e=>{n(t=>(e?t.set(`priority`,e):t.delete(`priority`),t.set(`page`,`1`),t))},clearable:!0})]}),l?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):s&&s.items.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Run #`}),(0,I.jsx)(W.Th,{children:`Rev`}),(0,I.jsx)(W.Th,{children:`Status`}),(0,I.jsx)(W.Th,{children:`Priority`}),(0,I.jsx)(W.Th,{children:`Cost`}),(0,I.jsx)(W.Th,{children:`Due`}),(0,I.jsx)(W.Th,{children:`Created`})]})}),(0,I.jsx)(W.Tbody,{children:s.items.map(t=>{let n=`/orders/${e}/runs/${t.runNo}`;return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},"data-testid":`order-run-row-${t.runNo}`,children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:t.runNo})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:t.revNo})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:(0,I.jsx)(Ap,{color:VQ[t.status]??`gray`,variant:`light`,children:t.status})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:(0,I.jsx)(Ap,{color:HQ[t.priority]??`gray`,variant:`light`,children:t.priority})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:t.cost?`$${t.cost.toFixed(2)}`:`—`})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:t.dueAt?new Date(t.dueAt).toLocaleDateString():`—`})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:new Date(t.createdAt).toLocaleDateString()})})]},t.id)})})]}),f>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:f,value:r,onChange:e=>n(t=>(t.set(`page`,String(e)),t))})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`xl`,children:`No order runs found.`})]})},WQ=()=>{let{username:e}=bC(),t=hC(),{supervisorAuth:n}=vC(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!0),[s,{open:c,close:l}]=_n(),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(!1),[x,{open:S,close:C}]=_n(),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(!1),[O,k]=(0,v.useState)(``),A=(0,v.useCallback)(async()=>{if(e){o(!0);try{i(await q.get(J.user(e)))}catch{}finally{o(!1)}}},[e]);(0,v.useEffect)(()=>{A()},[A]);let j=async()=>{if(!(!e||!confirm(`Delete this user?`)))try{await q.delete(J.user(e)),t(`/users`)}catch(e){gM(e)}},ee=async()=>{if(!(!e||!u)){p(!0),h(``);try{await q.put(J.user(e),{username:u}),l(),u===e?A():t(`/users/${u}`,{replace:!0})}catch(e){h(e instanceof Error?e.message:`Failed to update user`)}finally{p(!1)}}},te=async()=>{if(w){D(!0),k(``);try{await q.post(J.changePassword,{password:w}),C(),T(``)}catch(e){k(e instanceof Error?e.message:`Failed to change password`)}finally{D(!1)}}},ne=async()=>{if(!(!e||!g))try{await q.post(J.userPermissions(e),{permission:g}),_(null),A()}catch(e){gM(e)}},re=async t=>{if(e)try{await q.delete(J.userPermission(e,t)),A()}catch(e){gM(e)}},M=async()=>{if(e&&confirm(`Rotate this user's API key? The old key will stop working immediately.`)){b(!0);try{await q.post(J.userRotateKey(e),{}),A()}catch(e){gM(e)}finally{b(!1)}}};if(a)return(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(U,{align:`center`,children:(0,I.jsx)(uu,{})})});if(!r)return(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(V,{children:`User not found.`})});let N=sZ.options.filter(e=>!r.permissions?.some(t=>t.permission===e));return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(zv,{order:2,children:r.username}),(0,I.jsx)(CZ,{createdAt:r.createdAt,updatedAt:r.updatedAt})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>t(`/users`),children:`Back`}),Rj(r._actions,`change-password`)&&(0,I.jsx)(H,{variant:`outline`,onClick:()=>{T(``),k(``),S()},children:`Change Password`}),Rj(r._actions,`update`)&&(0,I.jsx)(H,{onClick:()=>{d(r.username),h(``),c()},children:`Edit`}),Rj(r._actions,`delete`)&&(0,I.jsx)(H,{color:`red`,variant:`outline`,onClick:j,children:`Delete`})]})]}),r.isAgent&&!n&&(0,I.jsx)(Wp,{withBorder:!0,p:`sm`,mb:`lg`,bg:`var(--mantine-color-red-light)`,children:(0,I.jsxs)(B,{gap:`xs`,wrap:`nowrap`,children:[(0,I.jsx)(Xj,{size:18,color:`var(--mantine-color-red-6)`}),(0,I.jsx)(V,{size:`sm`,children:`This is an agent user but ERP is running without supervisor auth. API key lookups and agent authentication will not work.`})]})}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,mb:`lg`,children:(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Username:`}),(0,I.jsx)(V,{ff:`monospace`,children:r.username})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Type:`}),(0,I.jsx)(V,{children:r.isAgent?`Agent`:`User`})]}),(r.apiKey||Rj(r._actions,`rotate-key`))&&(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`API Key:`}),(0,I.jsx)(rU,{value:r.apiKey??null,onRotate:Rj(r._actions,`rotate-key`)?M:void 0,rotating:y})]})]})}),(0,I.jsx)(zv,{order:3,mb:`sm`,children:`Permissions`}),r.permissions&&r.permissions.length>0?(0,I.jsxs)(W,{striped:!0,withTableBorder:!0,mb:`md`,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Permission`}),(0,I.jsx)(W.Th,{children:`Granted At`}),(0,I.jsx)(W.Th,{children:`Actions`})]})}),(0,I.jsx)(W.Tbody,{children:r.permissions.map(e=>(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Td,{children:(0,I.jsx)(V,{ff:`monospace`,children:e.permission})}),(0,I.jsx)(W.Td,{children:new Date(e.grantedAt).toLocaleString()}),(0,I.jsx)(W.Td,{children:Rj(e._actions,`revoke`)&&(0,I.jsx)(H,{size:`xs`,color:`red`,variant:`subtle`,onClick:()=>re(e.permission),children:`Revoke`})})]},e.permission))})]}):(0,I.jsx)(V,{c:`dimmed`,mb:`md`,children:`No permissions granted.`}),Rj(r._actions,`grant-permission`)&&N.length>0&&(0,I.jsxs)(B,{children:[(0,I.jsx)(R_,{placeholder:`Select permission`,data:N.map(e=>({value:e,label:e})),value:g,onChange:e=>_(e)}),(0,I.jsx)(H,{onClick:ne,disabled:!g,children:`Grant`})]}),(0,I.jsx)(Nh,{opened:s,onClose:l,title:`Edit User`,children:(0,I.jsxs)(U,{children:[(0,I.jsx)(Mv,{label:`Username`,value:u,onChange:e=>d(e.currentTarget.value)}),m&&(0,I.jsx)(V,{c:`red`,size:`sm`,children:m}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:l,children:`Cancel`}),(0,I.jsx)(H,{onClick:ee,loading:f,children:`Save`})]})]})}),(0,I.jsx)(Nh,{opened:x,onClose:C,title:`Change Password`,children:(0,I.jsxs)(U,{children:[(0,I.jsx)(m_,{label:`New Password`,value:w,onChange:e=>T(e.currentTarget.value)}),O&&(0,I.jsx)(V,{c:`red`,size:`sm`,children:O}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:C,children:`Cancel`}),(0,I.jsx)(H,{onClick:te,loading:E,children:`Save`})]})]})})]})},GQ=()=>{let[e,t]=qw(),n=hC(),{supervisorAuth:r}=vC(),i=Number(e.get(`page`))||1,a=e.get(`search`)||``,[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!0),[u,{open:d,close:f}]=_n(),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(!1),[b,{open:x,close:S}]=_n(),[C,w]=(0,v.useState)([]),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(!1),[k,A]=(0,v.useState)(!1),j=(0,v.useCallback)(async()=>{l(!0);try{let e=new URLSearchParams;e.set(`page`,String(i)),e.set(`pageSize`,`20`),a&&e.set(`search`,a),s(await q.get(`${J.users}?${e}`))}catch(e){gM(e)}finally{l(!1)}},[i,a]);(0,v.useEffect)(()=>{j()},[j]);let ee=async()=>{y(!0);try{await q.post(J.users,{username:p,password:h}),f(),n(`/users/${p}`),m(``),g(``)}catch(e){gM(e)}finally{y(!1)}},te=async()=>{x(),E(null),A(!0);try{let e=await q.get(`/api/supervisor/agents`),t=[],n=1,r;do r=await q.get(`${J.users}?page=${n}&pageSize=100`),t=t.concat(r.items),n++;while(t.length<r.total);let i=new Set(t.filter(e=>e.isAgent).map(e=>e.username));w(e.items.filter(e=>!e.archived&&!i.has(e.name)).map(e=>({value:String(e.id),label:e.name})))}catch(e){gM(e),S()}finally{A(!1)}},ne=async()=>{if(T){O(!0);try{let e=await q.post(J.usersFromAgent,{agentId:Number(T)});S(),n(`/users/${e.username}`)}catch(e){gM(e)}finally{O(!1)}}},re=o?Math.ceil(o.total/o.pageSize):0;return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsx)(zv,{order:2,children:`Users`}),(0,I.jsxs)(B,{children:[r&&(0,I.jsx)(H,{variant:`outline`,onClick:te,children:`Create Agent User`}),(0,I.jsx)(H,{onClick:d,children:`Create User`})]})]}),(0,I.jsx)(B,{mb:`md`,children:(0,I.jsx)(Mv,{placeholder:`Search...`,value:a,onChange:e=>{let n=e.currentTarget.value;t(e=>(n?e.set(`search`,n):e.delete(`search`),e.set(`page`,`1`),e))},style:{flex:1}})}),c?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):o&&o.items.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Username`}),(0,I.jsx)(W.Th,{children:`Type`}),(0,I.jsx)(W.Th,{children:`Permissions`}),(0,I.jsx)(W.Th,{children:`Created`})]})}),(0,I.jsx)(W.Tbody,{children:o.items.map(e=>(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:`/users/${e.username}`,style:gZ,children:(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:e.username})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:`/users/${e.username}`,style:gZ,children:(0,I.jsxs)(B,{gap:4,wrap:`nowrap`,children:[e.isAgent?`Agent`:`User`,e.isAgent&&!r&&(0,I.jsx)(M_,{label:`Agent user without supervisor auth — API key and auth will not work`,children:(0,I.jsx)(Xj,{size:14,color:`var(--mantine-color-red-6)`})})]})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:`/users/${e.username}`,style:gZ,children:e.permissionCount})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:`/users/${e.username}`,style:gZ,children:new Date(e.createdAt).toLocaleDateString()})})]},e.id))})]}),re>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:re,value:i,onChange:e=>t(t=>(t.set(`page`,String(e)),t))})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`xl`,children:`No users found.`}),(0,I.jsx)(Nh,{opened:u,onClose:f,title:`Create User`,children:(0,I.jsxs)(U,{children:[(0,I.jsx)(Mv,{label:`Username`,value:p,onChange:e=>m(e.currentTarget.value),"data-autofocus":!0}),(0,I.jsx)(m_,{label:`Password`,value:h,onChange:e=>g(e.currentTarget.value)}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:f,children:`Cancel`}),(0,I.jsx)(H,{onClick:ee,loading:_,disabled:!p||h.length<6,children:`Create`})]})]})}),(0,I.jsx)(Nh,{opened:b,onClose:S,title:`Create Agent User`,children:(0,I.jsxs)(U,{children:[k?(0,I.jsx)(uu,{size:`sm`}):(0,I.jsx)(R_,{label:`Agent`,placeholder:`Select an agent`,data:C,value:T,onChange:E,searchable:!0}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:S,children:`Cancel`}),(0,I.jsx)(H,{onClick:ne,loading:D,disabled:!T,children:`Create`})]})]})})]})},KQ=()=>{let e=hC(),[t,n]=(0,v.useState)(``),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1);return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Create Work Center`}),(0,I.jsxs)(U,{children:[(0,I.jsx)(Mv,{label:`Key`,description:`Alphanumeric with hyphens`,value:t,onChange:e=>n(e.currentTarget.value),required:!0}),(0,I.jsx)(Qm,{label:`Description`,value:r,onChange:e=>i(e.currentTarget.value),autosize:!0,minRows:2}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>e(`/work-centers`),children:`Cancel`}),(0,I.jsx)(H,{onClick:async()=>{o(!0);try{await q.post(J.workCenters,{key:t,description:r}),e(`/work-centers/${t}`)}catch(e){gM(e)}finally{o(!1)}},loading:a,disabled:!t,children:`Create`})]})]})]})},qQ=()=>{let{key:e}=bC(),t=hC(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(``),g=(0,v.useCallback)(async()=>{if(e){a(!0);try{r(await q.get(J.workCenter(e)))}catch(e){gM(e)}finally{a(!1)}}},[e]);(0,v.useEffect)(()=>{g()},[g]);let _=()=>{n&&(l(n.key),d(n.description),s(!0))},y=async()=>{if(e){p(!0);try{let n={key:c,description:u};await q.put(J.workCenter(e),n),s(!1),c===e?await g():t(`/work-centers/${c}`,{replace:!0})}catch(e){gM(e)}finally{p(!1)}}},b=async()=>{if(!(!e||!confirm(`Delete this work center?`)))try{await q.delete(J.workCenter(e)),t(`/work-centers`)}catch(e){gM(e)}},x=async()=>{if(!(!e||!m.trim()))try{await q.post(J.workCenterUsers(e),{username:m.trim()}),h(``),await g()}catch(e){gM(e)}},S=async t=>{if(e)try{await q.delete(J.workCenterUser(e,t)),await g()}catch(e){gM(e)}};if(i)return(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(U,{align:`center`,children:(0,I.jsx)(uu,{})})});if(!n)return(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(V,{children:`Work center not found.`})});if(o)return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Edit Work Center`}),(0,I.jsxs)(U,{children:[(0,I.jsx)(Mv,{label:`Key`,description:`Alphanumeric with hyphens`,value:c,onChange:e=>l(e.currentTarget.value),required:!0}),(0,I.jsx)(Qm,{label:`Description`,value:u,onChange:e=>d(e.currentTarget.value),autosize:!0,minRows:2}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>s(!1),children:`Cancel`}),(0,I.jsx)(H,{onClick:y,loading:f,children:`Save`})]})]})]});let C=Rj(n._actions,`assignUser`);return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(zv,{order:2,children:n.key}),(0,I.jsx)(CZ,{createdBy:n.createdBy,createdAt:n.createdAt,updatedBy:n.updatedBy,updatedAt:n.updatedAt})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>t(`/work-centers`),children:`Back`}),Rj(n._actions,`update`)&&(0,I.jsx)(H,{onClick:_,children:`Edit`}),Rj(n._actions,`delete`)&&(0,I.jsx)(H,{color:`red`,variant:`outline`,onClick:b,children:`Delete`})]})]}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,mb:`lg`,children:(0,I.jsx)(U,{gap:`sm`,children:(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Description:`}),(0,I.jsx)(V,{children:n.description||`—`})]})})}),(0,I.jsx)(zv,{order:4,mb:`sm`,children:`Assigned Users`}),C&&(0,I.jsxs)(B,{mb:`md`,children:[(0,I.jsx)(hZ,{placeholder:`Search users...`,value:m,onChange:h,style:{flex:1}}),(0,I.jsx)(H,{onClick:x,disabled:!m.trim(),children:`Assign`})]}),n.userAssignments.length>0?(0,I.jsxs)(W,{striped:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Username`}),(0,I.jsx)(W.Th,{children:`Assigned`}),(0,I.jsx)(W.Th,{children:`By`}),C&&(0,I.jsx)(W.Th,{w:50})]})}),(0,I.jsx)(W.Tbody,{children:n.userAssignments.map(e=>(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Td,{children:(0,I.jsx)(V,{size:`sm`,children:e.username})}),(0,I.jsx)(W.Td,{children:(0,I.jsx)(V,{size:`sm`,children:new Date(e.createdAt).toLocaleDateString()})}),(0,I.jsx)(W.Td,{children:(0,I.jsx)(V,{size:`sm`,children:e.createdBy??`—`})}),C&&(0,I.jsx)(W.Td,{children:Rj(e._actions,`remove`)&&(0,I.jsx)(vu,{color:`red`,variant:`subtle`,size:`sm`,onClick:()=>S(e.username),children:(0,I.jsx)(uM,{size:`0.9rem`})})})]},e.userId))})]}):(0,I.jsx)(V,{c:`dimmed`,py:`md`,children:`No users assigned.`})]})},JQ=()=>{let e=hC(),[t,n]=qw(),r=Number(t.get(`page`))||1,i=t.get(`search`)||``,[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!0),l=(0,v.useCallback)(async()=>{c(!0);try{let e=new URLSearchParams;e.set(`page`,String(r)),e.set(`pageSize`,`20`),i&&e.set(`search`,i),o(await q.get(`${J.workCenters}?${e}`))}catch(e){gM(e)}finally{c(!1)}},[r,i]);(0,v.useEffect)(()=>{l()},[l]);let u=a?Math.ceil(a.total/a.pageSize):0;return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsx)(zv,{order:2,children:`Work Centers`}),a&&Rj(a._actions,`create`)&&(0,I.jsx)(H,{onClick:()=>e(`/work-centers/new`),children:`Create New`})]}),(0,I.jsx)(B,{mb:`md`,children:(0,I.jsx)(Mv,{placeholder:`Search...`,value:i,onChange:e=>{let t=e.currentTarget.value;n(e=>(t?e.set(`search`,t):e.delete(`search`),e.set(`page`,`1`),e))},style:{flex:1}})}),s?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):a&&a.items.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Key`}),(0,I.jsx)(W.Th,{children:`Description`}),(0,I.jsx)(W.Th,{children:`Users`}),(0,I.jsx)(W.Th,{children:`Created`})]})}),(0,I.jsx)(W.Tbody,{children:a.items.map(e=>{let t=`/work-centers/${e.key}`;return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:e.key})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(V,{size:`sm`,lineClamp:1,children:e.description||`—`})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(V,{size:`sm`,children:e.userCount})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:new Date(e.createdAt).toLocaleDateString()})})]},e.id)})})]}),u>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:u,value:r,onChange:e=>n(t=>(t.set(`page`,String(e)),t))})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`xl`,children:`No work centers found.`})]})},YQ=()=>{let[e,t]=v.useState(!1),[n,r]=v.useState(!1),[i,a]=v.useState(!1),{user:o,loading:s}=xM();return v.useEffect(()=>{fetch(`/api/erp/client-config`).then(e=>e.json()).then(e=>{t(e.publicRead),r(e.supervisorAuth)}).catch(()=>{}).finally(()=>a(!0))},[]),s||!i?null:!o&&!e?(0,I.jsx)(UZ,{}):(0,I.jsx)(JC,{children:(0,I.jsxs)(KC,{element:(0,I.jsx)(pZ,{supervisorAuth:n}),children:[(0,I.jsx)(KC,{path:`/`,element:(0,I.jsx)(WC,{to:`/orders`,replace:!0})}),(0,I.jsx)(KC,{path:`/orders`,element:(0,I.jsx)(XZ,{})}),(0,I.jsx)(KC,{path:`/orders/new`,element:(0,I.jsx)(GZ,{})}),(0,I.jsx)(KC,{path:`/orders/:key`,element:(0,I.jsx)(YZ,{})}),(0,I.jsx)(KC,{path:`/orders/:orderKey/revs/diff`,element:(0,I.jsx)(uQ,{})}),(0,I.jsxs)(KC,{path:`/orders/:orderKey/revs/:revNo`,element:(0,I.jsx)(hQ,{}),children:[(0,I.jsx)(KC,{index:!0,element:(0,I.jsx)(WC,{to:`header`,replace:!0})}),(0,I.jsx)(KC,{path:`header`,element:(0,I.jsx)(QZ,{})}),(0,I.jsx)(KC,{path:`ops/:seqNo`,element:(0,I.jsx)(rQ,{})})]}),(0,I.jsx)(KC,{path:`/orders/:orderKey/runs`,element:(0,I.jsx)(UQ,{})}),(0,I.jsx)(KC,{path:`/orders/:orderKey/runs/new`,element:(0,I.jsx)(AQ,{})}),(0,I.jsxs)(KC,{path:`/orders/:orderKey/runs/:runNo`,element:(0,I.jsx)(BQ,{}),children:[(0,I.jsx)(KC,{index:!0,element:(0,I.jsx)(WC,{to:`header`,replace:!0})}),(0,I.jsx)(KC,{path:`header`,element:(0,I.jsx)(bQ,{})}),(0,I.jsx)(KC,{path:`ops/:seqNo`,element:(0,I.jsx)(kQ,{})})]}),(0,I.jsx)(KC,{path:`/items`,element:(0,I.jsx)(HZ,{})}),(0,I.jsx)(KC,{path:`/items/new`,element:(0,I.jsx)(SZ,{})}),(0,I.jsx)(KC,{path:`/items/:key`,element:(0,I.jsx)(DZ,{})}),(0,I.jsx)(KC,{path:`/items/:key/instances`,element:(0,I.jsx)(VZ,{})}),(0,I.jsx)(KC,{path:`/items/:key/instances/:instanceId`,element:(0,I.jsx)(BZ,{})}),(0,I.jsx)(KC,{path:`/work-centers`,element:(0,I.jsx)(JQ,{})}),(0,I.jsx)(KC,{path:`/work-centers/new`,element:(0,I.jsx)(KQ,{})}),(0,I.jsx)(KC,{path:`/work-centers/:key`,element:(0,I.jsx)(qQ,{})}),(0,I.jsx)(KC,{path:`/dispatch`,element:(0,I.jsx)(bZ,{})}),(0,I.jsx)(KC,{path:`/inventory`,element:(0,I.jsx)(xZ,{})}),(0,I.jsx)(KC,{path:`/users`,element:(0,I.jsx)(GQ,{})}),(0,I.jsx)(KC,{path:`/users/:username`,element:(0,I.jsx)(WQ,{})}),(0,I.jsx)(KC,{path:`/admin`,element:(0,I.jsx)(mZ,{})})]})})};_.createRoot(document.getElementById(`root`)).render((0,I.jsx)(v.StrictMode,{children:(0,I.jsx)(()=>(0,I.jsx)(zr,{defaultColorScheme:`dark`,children:(0,I.jsxs)($v,{settings:{consistentWeeks:!0},children:[(0,I.jsx)(Xx,{position:`top-right`}),(0,I.jsx)(Iw,{basename:`/erp`,children:(0,I.jsx)(bM,{children:(0,I.jsx)(YQ,{})})})]})}),{})}));
168
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Lq(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:Bq(t,`input`,e.processors),output:Bq(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Rq(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Rq(r.element,n);if(r.type===`set`)return Rq(r.valueType,n);if(r.type===`lazy`)return Rq(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return Rq(r.innerType,n);if(r.type===`intersection`)return Rq(r.left,n)||Rq(r.right,n);if(r.type===`record`||r.type===`map`)return Rq(r.keyType,n)||Rq(r.valueType,n);if(r.type===`pipe`)return Rq(r.in,n)||Rq(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Rq(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Rq(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Rq(e,n))return!0;return!!(r.rest&&Rq(r.rest,n))}return!1}var zq=(e,t={})=>n=>{let r=Pq({...n,processors:t});return Fq(e,r),Iq(r,e),Lq(r,e)},Bq=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Pq({...i??{},target:a,io:t,processors:n});return Fq(e,o),Iq(o,e),Lq(o,e)},Vq={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Hq=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Vq[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Uq=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},Wq=(e,t,n,r)=>{n.type=`boolean`},Gq=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Kq=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},qq=(e,t,n,r)=>{n.not={}},Jq=(e,t,n,r)=>{let i=e._zod.def,a=dU(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Yq=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Xq=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Zq=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Qq=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Fq(a.element,t,{...r,path:[...r.path,`items`]})},$q=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Fq(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Fq(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},eJ=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Fq(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},tJ=(e,t,n,r)=>{let i=e._zod.def,a=Fq(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Fq(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},nJ=(e,t,n,r)=>{let i=e._zod.def,a=Fq(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},rJ=(e,t,n,r)=>{let i=e._zod.def;Fq(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},iJ=(e,t,n,r)=>{let i=e._zod.def;Fq(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},aJ=(e,t,n,r)=>{let i=e._zod.def;Fq(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},oJ=(e,t,n,r)=>{let i=e._zod.def;Fq(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},sJ=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;Fq(a,t,r);let o=t.seen.get(e);o.ref=a},cJ=(e,t,n,r)=>{let i=e._zod.def;Fq(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},lJ=(e,t,n,r)=>{let i=e._zod.def;Fq(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},uJ=Y(`ZodISODateTime`,(e,t)=>{CG.init(e,t),FJ.init(e,t)});function dJ(e){return ZK(uJ,e)}var fJ=Y(`ZodISODate`,(e,t)=>{wG.init(e,t),FJ.init(e,t)});function pJ(e){return QK(fJ,e)}var mJ=Y(`ZodISOTime`,(e,t)=>{TG.init(e,t),FJ.init(e,t)});function hJ(e){return $K(mJ,e)}var gJ=Y(`ZodISODuration`,(e,t)=>{EG.init(e,t),FJ.init(e,t)});function _J(e){return eq(gJ,e)}var vJ=(e,t)=>{JU.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>ZU(e,t)},flatten:{value:t=>XU(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,fU,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,fU,2)}},isEmpty:{get(){return e.issues.length===0}}})};Y(`ZodError`,vJ);var yJ=Y(`ZodError`,vJ,{Parent:Error}),bJ=QU(yJ),xJ=$U(yJ),SJ=eW(yJ),CJ=nW(yJ),wJ=iW(yJ),TJ=aW(yJ),EJ=oW(yJ),DJ=sW(yJ),OJ=cW(yJ),kJ=lW(yJ),AJ=uW(yJ),jJ=dW(yJ),MJ=Y(`ZodType`,(e,t)=>(lG.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Bq(e,`input`),output:Bq(e,`output`)}}),e.toJSONSchema=zq(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(bU(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>AU(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>bJ(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>SJ(e,t,n),e.parseAsync=async(t,n)=>xJ(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>CJ(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>wJ(e,t,n),e.decode=(t,n)=>TJ(e,t,n),e.encodeAsync=async(t,n)=>EJ(e,t,n),e.decodeAsync=async(t,n)=>DJ(e,t,n),e.safeEncode=(t,n)=>OJ(e,t,n),e.safeDecode=(t,n)=>kJ(e,t,n),e.safeEncodeAsync=async(t,n)=>AJ(e,t,n),e.safeDecodeAsync=async(t,n)=>jJ(e,t,n),e.refine=(t,n)=>e.check(qY(t,n)),e.superRefine=t=>e.check(JY(t)),e.overwrite=t=>e.check(wq(t)),e.optional=()=>kY(e),e.exactOptional=()=>jY(e),e.nullable=()=>NY(e),e.nullish=()=>kY(NY(e)),e.nonoptional=t=>zY(e,t),e.array=()=>Q(e),e.or=t=>yY([e,t]),e.and=t=>xY(e,t),e.transform=t=>UY(e,DY(t)),e.default=t=>FY(e,t),e.prefault=t=>LY(e,t),e.catch=t=>VY(e,t),e.pipe=t=>UY(e,t),e.readonly=()=>GY(e),e.describe=t=>{let n=e.clone();return EK.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return EK.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return EK.get(e);let n=e.clone();return EK.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),NJ=Y(`_ZodString`,(e,t)=>{uG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hq(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(vq(...t)),e.includes=(...t)=>e.check(xq(...t)),e.startsWith=(...t)=>e.check(Sq(...t)),e.endsWith=(...t)=>e.check(Cq(...t)),e.min=(...t)=>e.check(gq(...t)),e.max=(...t)=>e.check(hq(...t)),e.length=(...t)=>e.check(_q(...t)),e.nonempty=(...t)=>e.check(gq(1,...t)),e.lowercase=t=>e.check(yq(t)),e.uppercase=t=>e.check(bq(t)),e.trim=()=>e.check(Eq()),e.normalize=(...t)=>e.check(Tq(...t)),e.toLowerCase=()=>e.check(Dq()),e.toUpperCase=()=>e.check(Oq()),e.slugify=()=>e.check(kq())}),PJ=Y(`ZodString`,(e,t)=>{uG.init(e,t),NJ.init(e,t),e.email=t=>e.check(kK(IJ,t)),e.url=t=>e.check(FK(zJ,t)),e.jwt=t=>e.check(XK(eY,t)),e.emoji=t=>e.check(IK(BJ,t)),e.guid=t=>e.check(AK(LJ,t)),e.uuid=t=>e.check(jK(RJ,t)),e.uuidv4=t=>e.check(MK(RJ,t)),e.uuidv6=t=>e.check(NK(RJ,t)),e.uuidv7=t=>e.check(PK(RJ,t)),e.nanoid=t=>e.check(LK(VJ,t)),e.guid=t=>e.check(AK(LJ,t)),e.cuid=t=>e.check(RK(HJ,t)),e.cuid2=t=>e.check(zK(UJ,t)),e.ulid=t=>e.check(BK(WJ,t)),e.base64=t=>e.check(qK(ZJ,t)),e.base64url=t=>e.check(JK(QJ,t)),e.xid=t=>e.check(VK(GJ,t)),e.ksuid=t=>e.check(HK(KJ,t)),e.ipv4=t=>e.check(UK(qJ,t)),e.ipv6=t=>e.check(WK(JJ,t)),e.cidrv4=t=>e.check(GK(YJ,t)),e.cidrv6=t=>e.check(KK(XJ,t)),e.e164=t=>e.check(YK($J,t)),e.datetime=t=>e.check(dJ(t)),e.date=t=>e.check(pJ(t)),e.time=t=>e.check(hJ(t)),e.duration=t=>e.check(_J(t))});function X(e){return DK(PJ,e)}var FJ=Y(`ZodStringFormat`,(e,t)=>{dG.init(e,t),NJ.init(e,t)}),IJ=Y(`ZodEmail`,(e,t)=>{mG.init(e,t),FJ.init(e,t)}),LJ=Y(`ZodGUID`,(e,t)=>{fG.init(e,t),FJ.init(e,t)}),RJ=Y(`ZodUUID`,(e,t)=>{pG.init(e,t),FJ.init(e,t)}),zJ=Y(`ZodURL`,(e,t)=>{hG.init(e,t),FJ.init(e,t)}),BJ=Y(`ZodEmoji`,(e,t)=>{gG.init(e,t),FJ.init(e,t)}),VJ=Y(`ZodNanoID`,(e,t)=>{_G.init(e,t),FJ.init(e,t)}),HJ=Y(`ZodCUID`,(e,t)=>{vG.init(e,t),FJ.init(e,t)}),UJ=Y(`ZodCUID2`,(e,t)=>{yG.init(e,t),FJ.init(e,t)}),WJ=Y(`ZodULID`,(e,t)=>{bG.init(e,t),FJ.init(e,t)}),GJ=Y(`ZodXID`,(e,t)=>{xG.init(e,t),FJ.init(e,t)}),KJ=Y(`ZodKSUID`,(e,t)=>{SG.init(e,t),FJ.init(e,t)}),qJ=Y(`ZodIPv4`,(e,t)=>{DG.init(e,t),FJ.init(e,t)}),JJ=Y(`ZodIPv6`,(e,t)=>{OG.init(e,t),FJ.init(e,t)}),YJ=Y(`ZodCIDRv4`,(e,t)=>{kG.init(e,t),FJ.init(e,t)}),XJ=Y(`ZodCIDRv6`,(e,t)=>{AG.init(e,t),FJ.init(e,t)}),ZJ=Y(`ZodBase64`,(e,t)=>{MG.init(e,t),FJ.init(e,t)}),QJ=Y(`ZodBase64URL`,(e,t)=>{PG.init(e,t),FJ.init(e,t)}),$J=Y(`ZodE164`,(e,t)=>{FG.init(e,t),FJ.init(e,t)}),eY=Y(`ZodJWT`,(e,t)=>{LG.init(e,t),FJ.init(e,t)}),tY=Y(`ZodNumber`,(e,t)=>{RG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uq(e,t,n,r),e.gt=(t,n)=>e.check(fq(t,n)),e.gte=(t,n)=>e.check(pq(t,n)),e.min=(t,n)=>e.check(pq(t,n)),e.lt=(t,n)=>e.check(uq(t,n)),e.lte=(t,n)=>e.check(dq(t,n)),e.max=(t,n)=>e.check(dq(t,n)),e.int=t=>e.check(rY(t)),e.safe=t=>e.check(rY(t)),e.positive=t=>e.check(fq(0,t)),e.nonnegative=t=>e.check(pq(0,t)),e.negative=t=>e.check(uq(0,t)),e.nonpositive=t=>e.check(dq(0,t)),e.multipleOf=(t,n)=>e.check(mq(t,n)),e.step=(t,n)=>e.check(mq(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Z(e){return tq(tY,e)}var nY=Y(`ZodNumberFormat`,(e,t)=>{zG.init(e,t),tY.init(e,t)});function rY(e){return rq(nY,e)}var iY=Y(`ZodBoolean`,(e,t)=>{BG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wq(e,t,n,r)});function aY(e){return iq(iY,e)}var oY=Y(`ZodUndefined`,(e,t)=>{VG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kq(e,t,n,r)});function sY(e){return aq(oY,e)}var cY=Y(`ZodNull`,(e,t)=>{HG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gq(e,t,n,r)});function lY(e){return oq(cY,e)}var uY=Y(`ZodAny`,(e,t)=>{UG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function dY(){return sq(uY)}var fY=Y(`ZodUnknown`,(e,t)=>{WG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function pY(){return cq(fY)}var mY=Y(`ZodNever`,(e,t)=>{GG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qq(e,t,n,r)});function hY(e){return lq(mY,e)}var gY=Y(`ZodArray`,(e,t)=>{qG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qq(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(gq(t,n)),e.nonempty=t=>e.check(gq(1,t)),e.max=(t,n)=>e.check(hq(t,n)),e.length=(t,n)=>e.check(_q(t,n)),e.unwrap=()=>e.element});function Q(e,t){return Aq(gY,e,t)}var _Y=Y(`ZodObject`,(e,t)=>{QG.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$q(e,t,n,r),vU(e,`shape`,()=>t.shape),e.keyof=()=>CY(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:pY()}),e.loose=()=>e.clone({...e._zod.def,catchall:pY()}),e.strict=()=>e.clone({...e._zod.def,catchall:hY()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>IU(e,t),e.safeExtend=t=>LU(e,t),e.merge=t=>RU(e,t),e.pick=t=>PU(e,t),e.omit=t=>FU(e,t),e.partial=(...t)=>zU(OY,e,t[0]),e.required=(...t)=>BU(RY,e,t[0])});function $(e,t){return new _Y({type:`object`,shape:e??{},...jU(t)})}var vY=Y(`ZodUnion`,(e,t)=>{eK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eJ(e,t,n,r),e.options=t.options});function yY(e,t){return new vY({type:`union`,options:e,...jU(t)})}var bY=Y(`ZodIntersection`,(e,t)=>{tK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tJ(e,t,n,r)});function xY(e,t){return new bY({type:`intersection`,left:e,right:t})}var SY=Y(`ZodEnum`,(e,t)=>{iK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jq(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new SY({...t,checks:[],...jU(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new SY({...t,checks:[],...jU(r),entries:i})}});function CY(e,t){return new SY({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...jU(t)})}var wY=Y(`ZodLiteral`,(e,t)=>{aK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yq(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function TY(e,t){return new wY({type:`literal`,values:Array.isArray(e)?e:[e],...jU(t)})}var EY=Y(`ZodTransform`,(e,t)=>{oK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zq(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new cU(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(KU(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(KU(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function DY(e){return new EY({type:`transform`,transform:e})}var OY=Y(`ZodOptional`,(e,t)=>{cK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lJ(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function kY(e){return new OY({type:`optional`,innerType:e})}var AY=Y(`ZodExactOptional`,(e,t)=>{lK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lJ(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function jY(e){return new AY({type:`optional`,innerType:e})}var MY=Y(`ZodNullable`,(e,t)=>{uK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nJ(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function NY(e){return new MY({type:`nullable`,innerType:e})}var PY=Y(`ZodDefault`,(e,t)=>{dK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>iJ(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function FY(e,t){return new PY({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():DU(t)}})}var IY=Y(`ZodPrefault`,(e,t)=>{pK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>aJ(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function LY(e,t){return new IY({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():DU(t)}})}var RY=Y(`ZodNonOptional`,(e,t)=>{mK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rJ(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zY(e,t){return new RY({type:`nonoptional`,innerType:e,...jU(t)})}var BY=Y(`ZodCatch`,(e,t)=>{gK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oJ(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function VY(e,t){return new BY({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var HY=Y(`ZodPipe`,(e,t)=>{_K.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sJ(e,t,n,r),e.in=t.in,e.out=t.out});function UY(e,t){return new HY({type:`pipe`,in:e,out:t})}var WY=Y(`ZodReadonly`,(e,t)=>{yK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cJ(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function GY(e){return new WY({type:`readonly`,innerType:e})}var KY=Y(`ZodCustom`,(e,t)=>{xK.init(e,t),MJ.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xq(e,t,n,r)});function qY(e,t={}){return jq(KY,e,t)}function JY(e){return Mq(e)}function YY(e){return OK(PJ,e)}function XY(e){return nq(tY,e)}$({erpDbPath:X(),erpDbSize:Z().optional(),_actions:Q(Uj).optional()});var ZY=$({id:X(),filename:X(),fileSize:Z(),fileHash:X(),uploadedBy:X(),createdAt:X()});$({page:XY().optional().default(1),pageSize:XY().optional().default(50)}),$({attachments:Q(ZY),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj)});var QY=$({level:Z(),time:Z(),msg:X(),detail:X().optional()});$({lines:XY().optional().default(200),minLevel:XY().optional()}),$({entries:Q(QY),fileName:X(),fileSize:Z().optional()}),$({message:X()}),$({items:Q($({id:Z(),entityType:X(),entityId:Z(),action:X(),field:X(),oldValue:X().nullable(),newValue:X().nullable(),userId:Z(),createdAt:dJ()}))}),$({entityType:X(),entityId:XY().int()});var $Y=$({username:X().min(1),password:X().min(1)}).strict();$({user:$({id:Z(),username:X(),permissions:Q(X()).optional()})}),$({statusCode:Z().int(),error:X(),message:X()});var eX=CY([`string`,`number`,`date`,`datetime`,`yesNo`,`checkbox`,`attachment`]),tX=eX.enum,nX=$({id:Z(),fieldSetId:Z(),seqNo:Z(),label:X(),type:eX,isArray:aY(),required:aY(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()}),rX=$({seqNo:Z().int().min(1).optional(),label:X().min(1).max(200),type:eX.optional(),isArray:aY().optional(),required:aY().optional()}).strict();$({items:Q(rX).min(1).max(100)});var iX=$({seqNo:Z().int().min(1).optional(),label:X().min(1).max(200).optional(),type:eX.optional(),isArray:aY().optional(),required:aY().optional()}).strict(),aX=$({items:Q(nX),total:Z(),nextSeqNo:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()}),oX=$({valid:aY(),error:X().optional()}),sX=$({id:X(),filename:X(),fileSize:Z(),downloadHref:X().optional()}),cX=YY(),lX=yY([Q(cX),cX]),uX=$({fieldId:Z(),fieldSeqNo:Z(),label:X(),type:X(),valueFormat:X(),required:aY(),setIndex:Z(),value:lX,attachments:Q(sX).optional(),validation:oX});$({attachmentId:X(),filename:X(),fileSize:Z()});var dX=$({id:Z(),operationRunId:Z(),stepId:Z(),seqNo:Z(),title:X(),instructions:X(),multiSet:aY(),completed:aY(),note:X().nullable(),fieldCount:Z().optional(),fieldValues:Q(uX).optional(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),_links:Q(Vj).optional(),_actions:Q(Uj).optional(),_actionTemplates:Q(Wj).optional()}),fX=YY().max(2e3);$({value:yY([Q(fX),fX])}).strict(),$({fieldValues:Q($({fieldSeqNo:Z().int(),value:yY([Q(fX),fX])}))}).strict();var pX=$({items:Q(uX),total:Z()});uX.extend({_actions:Q(Uj).optional(),_actionTemplates:Q(Wj).optional()}),pX.extend({_actions:Q(Uj).optional(),_actionTemplates:Q(Wj).optional()}),$({setCount:Z(),_actions:Q(Uj).optional(),_actionTemplates:Q(Wj).optional()}),$({id:Z(),completed:aY(),note:X().nullable(),updatedAt:dJ(),updatedBy:X(),_actions:Q(Uj).optional(),_actionTemplates:Q(Wj).optional()}),$({includeFields:yY([TY(`true`),TY(`false`)]).transform(e=>e===`true`).optional()}),$({items:Q(dX),total:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var mX=$({seqNo:Z(),label:X(),type:eX}),hX=$({id:Z(),seqNo:Z(),title:X(),sourceOpSeqNo:Z(),sourceOpTitle:X(),sourceStepSeqNo:Z(),sourceStepTitle:X(),fields:Q(mX),createdAt:dJ(),createdBy:X(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()});$({seqNo:Z().int().min(1).optional(),title:X().min(1).max(200),sourceOpSeqNo:Z().int().min(1),sourceStepSeqNo:Z().int().min(1)}).strict(),$({items:Q(hX),total:Z(),nextSeqNo:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var gX=$({seqNo:Z(),title:X(),sourceOpSeqNo:Z(),sourceOpTitle:X(),sourceStepSeqNo:Z(),sourceStepTitle:X(),multiSet:aY(),fieldValues:Q(uX)});$({page:XY().int().min(1).optional().default(1),pageSize:XY().int().min(1).max(100).optional().default(20),search:X().optional()}),$({items:Q($({id:Z(),itemKey:X(),key:X(),quantity:Z().nullable(),orderKey:X().nullable(),orderRunNo:Z().nullable(),createdAt:dJ()})),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj),_actionTemplates:Q(Wj).optional()});var _X=$({id:Z(),itemKey:X(),orderKey:X().nullable(),orderRunNo:Z().nullable(),key:X(),quantity:Z().nullable(),fieldValues:Q(uX),createdBy:X(),createdAt:dJ(),updatedBy:X(),updatedAt:dJ(),_links:Q(Vj).optional(),_actions:Q(Uj).optional(),_actionTemplates:Q(Wj).optional()});$({key:X().min(1).max(200),quantity:Z().nullable().optional(),orderRunId:Z().nullable().optional()}).strict(),$({key:X().min(1).max(200).optional(),quantity:Z().nullable().optional(),orderRunId:Z().nullable().optional()}).strict(),$({page:XY().int().min(1).optional().default(1),pageSize:XY().int().min(1).max(100).optional().default(20),search:X().optional()}),$({items:Q(_X),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var vX=$({id:Z(),key:X(),description:X(),fields:aX,createdBy:X(),createdAt:dJ(),updatedBy:X(),updatedAt:dJ(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()});$({key:X().min(1).max(100).regex(/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/,`Key must be alphanumeric with hyphens`),description:X().max(2e3).optional().default(``)}).strict(),$({key:X().min(1).max(100).regex(/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/,`Key must be alphanumeric with hyphens`).optional(),description:X().max(2e3).optional()}).strict(),$({page:XY().int().min(1).optional().default(1),pageSize:XY().int().min(1).max(100).optional().default(20),search:X().optional()}),$({items:Q(vX),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var yX=$({id:Z(),operationRunId:Z(),userId:Z(),username:X(),runId:Z().nullable(),clockIn:dJ(),clockOut:dJ().nullable(),cost:Z().nullable(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),_links:Q(Vj).optional()});$({userId:Z().int().optional(),ticketId:Z().int().optional()}).strict(),$({items:Q(yX),total:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional(),_actionTemplates:Q(Wj).optional()});var bX=$({seqNo:Z(),title:X()}),xX=$({seqNo:Z(),title:X()}),SX=$({id:Z(),orderRevId:Z(),seqNo:Z(),title:X(),description:X(),workCenterKey:X().nullable(),stepCount:Z().optional(),stepSummary:Q(xX).optional(),predecessors:Q(bX).optional(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()}),CX=$({seqNo:Z().int().min(1).optional(),title:X().min(1).max(200),description:X().max(2e3).optional(),workCenterKey:X().max(100).nullable().optional(),predecessorSeqNos:Q(Z().int().min(1)).optional()}).strict(),wX=$({title:X().min(1).max(200).optional(),description:X().max(2e3).optional(),workCenterKey:X().max(100).nullable().optional(),seqNo:Z().int().min(1).optional()}).strict();$({items:Q(SX),total:Z(),nextSeqNo:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var TX=$({seqNo:Z(),title:X(),completed:aY()}),EX=CY([`blocked`,`pending`,`in_progress`,`completed`,`skipped`,`failed`]),DX=EX.enum,OX=$({id:Z(),orderRunId:Z(),operationId:Z(),seqNo:Z(),title:X(),description:X(),workCenterKey:X().nullable(),stepCount:Z().optional(),predecessors:Q(bX).optional(),status:EX,assignedTo:X().nullable(),cost:Z().nullable(),note:X().nullable(),completedAt:dJ().nullable(),stepSummary:Q(TX).optional(),fieldRefSummary:Q(gX).optional(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()});$({assignedToId:Z().int().nullable().optional()}).strict(),yY([$({note:X().max(2e3).optional()}).strict(),lY(),sY()]).transform(e=>e??{}),$({id:Z(),status:EX,assignedTo:X().nullable(),cost:Z().nullable(),note:X().nullable(),completedAt:dJ().nullable(),updatedAt:dJ(),updatedBy:X(),_actions:Q(Uj).optional()}),$({items:Q(OX),total:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var kX=$({seqNo:Z(),title:X()}),AX=CY([`draft`,`approved`,`obsolete`]),jX=AX.enum,MX=$({id:Z(),orderId:Z(),revNo:Z(),status:AX,description:X(),changeSummary:X().nullable(),itemKey:X().nullable(),operationSummary:Q(kX).optional(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()});$({description:X().max(2e3).optional(),changeSummary:X().max(2e3).optional()}).strict();var NX=$({description:X().max(2e3).optional(),changeSummary:X().max(2e3).optional()}).strict();$({page:XY().int().min(1).optional().default(1),pageSize:XY().int().min(1).max(100).optional().default(20),status:AX.optional(),includeObsolete:CY([`true`,`false`]).transform(e=>e===`true`).optional().default(!1)}),$({items:Q(MX),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var PX=$({seqNo:Z(),title:X(),status:EX}),FX=CY([`released`,`started`,`closed`,`cancelled`]),IX=FX.enum,LX=CY([`low`,`medium`,`high`,`critical`]),RX=LX.enum,zX=$({id:Z(),runNo:Z(),orderId:Z(),orderKey:X(),revNo:Z(),itemKey:X().nullable(),instanceId:Z().nullable(),instanceKey:X().nullable(),status:FX,priority:LX,cost:Z().nullable(),dueAt:X().nullable(),releaseNote:X().nullable(),operationSummary:Q(PX).optional(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()}),BX=$({revNo:Z().int().min(1).optional(),priority:LX.optional().default(`medium`),dueAt:X().regex(/^\d{4}-\d{2}-\d{2}$/,`Must be YYYY-MM-DD`),releaseNote:X().max(2e3).optional()}).strict(),VX=$({priority:LX.optional(),dueAt:X().regex(/^\d{4}-\d{2}-\d{2}$/,`Must be YYYY-MM-DD`).nullable().optional(),releaseNote:X().max(2e3).nullable().optional()}).strict();$({instanceKey:X().max(200).optional(),quantity:Z().nullable().optional(),fieldValues:Q($({fieldId:Z().int(),value:X().max(2e3),setIndex:Z().int().min(0).optional()})).optional()}).strict(),$({page:XY().int().min(1).optional().default(1),pageSize:XY().int().min(1).max(100).optional().default(20),status:FX.optional(),priority:LX.optional(),search:X().optional()}),$({items:Q(zX),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()}),$({page:XY().int().min(1).optional().default(1),pageSize:XY().int().min(1).max(100).optional().default(20),status:EX.optional(),priority:LX.optional(),search:X().optional(),viewAs:X().optional(),canWork:yY([TY(`true`),TY(`false`)]).transform(e=>e===`true`).optional(),clockedIn:yY([TY(`true`),TY(`false`)]).transform(e=>e===`true`).optional()}),$({items:Q($({id:Z(),orderKey:X(),revNo:Z(),runNo:Z(),seqNo:Z(),title:X(),workCenterKey:X().nullable(),canWork:aY(),status:EX,priority:LX,assignedTo:X().nullable(),dueAt:X().nullable(),createdAt:dJ()})),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actionTemplates:Q(Wj).optional()});var HX=$({_actions:Q(Uj).optional()}).extend({id:Z(),_links:Q(Vj).optional()});HX.extend({key:X()}),HX.extend({seqNo:Z()}),$({items:Q($({id:Z(),seqNo:Z()})),total:Z(),_actions:Q(Uj).optional()}),HX.extend({revNo:Z()}),HX.extend({runNo:Z()}),$({id:Z(),username:X(),apiKey:X().nullable().optional(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()}),$({status:FX,_actions:Q(Uj).optional()}),$({status:EX,_actions:Q(Uj).optional()}),$({completed:aY(),_actions:Q(Uj).optional()}),$({status:AX,_actions:Q(Uj).optional()}),$({value:lX,validation:oX,_actions:Q(Uj).optional()}),$({items:Q($({fieldSeqNo:Z(),value:lX,validation:oX})),total:Z(),_actions:Q(Uj).optional()}),$({setCount:Z(),_actions:Q(Uj).optional()});var UX=$({id:Z(),predecessorSeqNo:Z(),predecessorTitle:X(),createdAt:dJ(),createdBy:X()}),WX=$({predecessorSeqNo:Z().int().min(1)}).strict();$({items:Q(UX),total:Z(),_links:Q(Vj),_actions:Q(Uj).optional(),_actionTemplates:Q(Wj).optional()});var GX=CY([`note`,`issue`,`feedback`]);GX.enum;var KX=$({id:Z(),operationRunId:Z(),type:GX,body:X(),createdAt:dJ(),createdBy:X(),_links:Q(Vj).optional()});$({type:GX.optional(),body:X().min(1).max(5e3)}).strict(),$({items:Q(KX),total:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var qX=CY([`active`,`archived`]),JX=qX.enum,YX=$({id:Z(),key:X(),description:X(),status:qX,itemKey:X().nullable(),createdBy:X(),createdAt:dJ(),updatedBy:X(),updatedAt:dJ(),_links:Q(Vj).optional(),_actions:Q(Uj).optional()}),XX=$({key:X().min(1).max(100).regex(/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/,`Key must be alphanumeric with hyphens`),description:X().max(2e3).optional().default(``),itemKey:X().max(100).optional()}).strict(),ZX=$({key:X().min(1).max(100).regex(/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/,`Key must be alphanumeric with hyphens`).optional(),description:X().max(2e3).optional(),status:qX.optional(),itemKey:X().max(100).nullable().optional()}).strict();$({page:XY().int().min(1).optional().default(1),pageSize:XY().int().min(1).max(100).optional().default(20),status:CY([`active`,`archived`]).optional(),search:X().optional()}),$({items:Q(YX),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var QX=$({field:X(),from:yY([X(),Z(),aY(),lY()]),to:yY([X(),Z(),aY(),lY()])}),$X=CY([`added`,`removed`,`modified`,`unchanged`]),eZ=$({seqNo:Z(),label:X(),status:$X,changes:Q(QX).optional()}),tZ=$({seqNo:Z(),title:X(),status:$X,changes:Q(QX).optional(),fields:Q(eZ).optional()}),nZ=$({predecessorSeqNo:Z(),predecessorTitle:X(),status:CY([`added`,`removed`,`unchanged`])}),rZ=$({seqNo:Z(),title:X(),status:$X,changes:Q(QX).optional(),steps:Q(tZ).optional(),dependencies:Q(nZ).optional()});$({fromRevNo:Z(),toRevNo:Z(),revisionChanges:Q(QX),operations:Q(rZ)}),$({from:XY().int().min(1),to:XY().int().min(1)});var iZ=$({id:Z(),operationId:Z(),seqNo:Z(),title:X(),instructions:X(),multiSet:aY(),fieldCount:Z().optional(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),fields:aX,_links:Q(Vj).optional(),_actions:Q(Uj).optional()}),aZ=$({seqNo:Z().int().min(1).optional(),title:X().max(200).optional(),instructions:X().max(1e4).optional(),multiSet:aY().optional()}).strict();$({items:Q(aZ).min(1).max(100)});var oZ=$({seqNo:Z().int().min(1).optional(),title:X().max(200).optional(),instructions:X().max(1e4).optional(),multiSet:aY().optional()}).strict();$({items:Q(iZ),total:Z(),nextSeqNo:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var sZ=CY([`erp_admin`,`order_planner`,`order_executor`,`order_manager`,`item_manager`]);sZ.enum;var cZ=X().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/,`Must contain only letters, numbers, hyphens, and underscores`);$({username:cZ,password:X().min(6)}).strict(),$({username:cZ.optional(),password:X().min(6).optional()}).strict(),$({permission:sZ}).strict(),$({agentId:Z().int()}).strict(),$({password:X().min(6)}).strict();var lZ=$({permission:sZ,grantedAt:X(),grantedBy:Z().nullable(),_actions:Q(dY()).optional()});$({id:Z(),username:X(),isAgent:aY(),createdAt:X(),updatedAt:X(),apiKey:X().nullable().optional(),permissions:Q(lZ),_links:Q(dY()).optional(),_actions:Q(dY()).optional()}),$({items:Q($({id:Z(),username:X(),isAgent:aY(),createdAt:X(),permissionCount:Z()})),total:Z(),page:Z(),pageSize:Z(),_links:Q(dY()).optional(),_linkTemplates:Q(dY()).optional(),_actions:Q(dY()).optional()}),$({page:XY().int().min(1).default(1),pageSize:XY().int().min(1).max(100).default(20),search:X().optional()});var uZ=$({userId:Z(),username:X(),createdAt:X(),createdBy:X().nullable(),_actions:Q(Uj).optional()});$({id:Z(),key:X(),description:X(),userAssignments:Q(uZ),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X(),_links:Q(Vj),_actions:Q(Uj).optional()}),$({key:X().min(1).max(100).regex(/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/,`Key must be alphanumeric with hyphens`),description:X().max(2e3).optional().default(``)}).strict(),$({key:X().min(1).max(100).regex(/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/,`Key must be alphanumeric with hyphens`).optional(),description:X().max(2e3).optional()}).strict(),$({username:X().min(1)}).strict(),$({page:XY().int().min(1).optional().default(1),pageSize:XY().int().min(1).max(100).optional().default(20),search:X().optional()}),$({items:Q($({id:Z(),key:X(),description:X(),userCount:Z(),createdAt:dJ(),createdBy:X(),updatedAt:dJ(),updatedBy:X()})),total:Z(),page:Z(),pageSize:Z(),_links:Q(Vj),_linkTemplates:Q(Gj).optional(),_actions:Q(Uj).optional()});var dZ=({opened:e,onClose:t})=>{let{login:n}=xM(),[r,i]=(0,v.useState)(!1),a=rN({initialValues:{username:``,password:``},validate:oU($Y)}),o=()=>{a.reset(),t()};return(0,I.jsx)(Nh,{opened:e,onClose:o,title:`Login`,children:(0,I.jsx)(`form`,{onSubmit:a.onSubmit(async e=>{i(!0);try{await n(e.username,e.password),window.location.reload()}catch(e){gM(e)}finally{i(!1)}}),children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsx)(Mv,{label:`Username`,...a.getInputProps(`username`),"data-autofocus":!0}),(0,I.jsx)(Mv,{label:`Password`,type:`password`,...a.getInputProps(`password`)}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:o,children:`Cancel`}),(0,I.jsx)(H,{type:`submit`,loading:r,children:`Login`})]})]})})})},fZ=[{label:`Items`,path:`/items`},{label:`Orders`,path:`/orders`},{label:`Work Centers`,path:`/work-centers`},{label:`Dispatch`,path:`/dispatch`},{label:`Inventory`,path:`/inventory`},{label:`Users`,path:`/users`},{label:`Admin`,path:`/admin`}],pZ=({supervisorAuth:e})=>{let[t,{toggle:n,close:r}]=_n(),[i,{open:a,close:o}]=_n(),s=hC(),c=fC(),{user:l,logout:u}=xM(),d=e=>c.pathname.startsWith(e),f=fZ.find(e=>d(e.path))?.label??`Orders`;return(0,I.jsxs)(hf,{header:{height:48},navbar:{width:250,breakpoint:`sm`,collapsed:{desktop:!0,mobile:!t}},padding:0,children:[(0,I.jsx)(hf.Header,{children:(0,I.jsxs)(B,{h:`100%`,px:`md`,wrap:`nowrap`,gap:`xs`,children:[(0,I.jsx)(gl,{onClick:n,hiddenFrom:`sm`,style:{flexShrink:0,display:`flex`,alignItems:`center`},children:(0,I.jsx)(`img`,{src:Kj,alt:`NAISYS`,style:{width:`36px`,height:`36px`}})}),(0,I.jsx)(R,{visibleFrom:`sm`,style:{flexShrink:0},children:(0,I.jsxs)(zw,{to:`/orders`,style:{textDecoration:`none`,color:`inherit`,display:`flex`,alignItems:`center`,gap:`0.5rem`,cursor:`pointer`},children:[(0,I.jsx)(`img`,{src:Kj,alt:`NAISYS`,style:{width:`36px`,height:`36px`}}),(0,I.jsx)(V,{size:`lg`,fw:500,children:`NAISYS`})]})}),(0,I.jsx)(gl,{hiddenFrom:`sm`,onClick:n,style:{flexShrink:0},children:(0,I.jsxs)(V,{size:`sm`,fw:600,children:[`NAISYS / `,f]})}),(0,I.jsxs)(B,{gap:6,visibleFrom:`sm`,wrap:`nowrap`,style:{flexShrink:0},children:[e&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{size:`sm`,c:`dimmed`,component:`a`,href:`/supervisor/`,style:{cursor:`pointer`,textDecoration:`none`},children:`Supervisor`}),(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`|`})]}),(0,I.jsx)(V,{size:`sm`,fw:700,children:`ERP`})]}),(0,I.jsx)(B,{gap:`xs`,visibleFrom:`sm`,wrap:`nowrap`,style:{flex:1,minWidth:0,overflow:`hidden`},children:fZ.map(e=>(0,I.jsx)(gl,{component:zw,to:e.path,px:`sm`,py:4,style:t=>({borderRadius:t.radius.sm,flexShrink:0,backgroundColor:d(e.path)?`var(--mantine-color-dark-5)`:void 0}),children:(0,I.jsx)(V,{size:`sm`,fw:d(e.path)?600:400,c:d(e.path)?void 0:`dimmed`,children:e.label})},e.path))}),(0,I.jsx)(R,{hiddenFrom:`sm`,style:{flex:1}}),(0,I.jsx)(M_,{label:`API Reference`,children:(0,I.jsx)(vu,{variant:`subtle`,color:`gray`,component:`a`,href:`/erp/api-reference/`,visibleFrom:`sm`,style:{flexShrink:0},children:(0,I.jsx)(Zj,{size:`1.2rem`})})}),l?(0,I.jsxs)(gh,{position:`bottom-end`,withArrow:!0,children:[(0,I.jsx)(gh.Target,{children:(0,I.jsx)(H,{variant:`subtle`,size:`xs`,color:`gray`,style:{flexShrink:0},children:l.username})}),(0,I.jsxs)(gh.Dropdown,{children:[(0,I.jsx)(gh.Item,{leftSection:(0,I.jsx)(fM,{size:`0.9rem`}),onClick:()=>s(`/users/${l.username}`),children:`My User`}),(0,I.jsx)(gh.Item,{leftSection:(0,I.jsx)(sM,{size:`0.9rem`}),onClick:async()=>{await u(),window.location.reload()},children:`Logout`})]})]}):(0,I.jsx)(H,{size:`xs`,variant:`subtle`,onClick:a,style:{flexShrink:0},children:`Login`})]})}),(0,I.jsxs)(hf.Navbar,{p:`md`,children:[(0,I.jsxs)(B,{gap:6,px:`sm`,py:4,children:[e&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{size:`sm`,c:`dimmed`,component:`a`,href:`/supervisor/`,style:{textDecoration:`none`},children:`Supervisor`}),(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`|`})]}),(0,I.jsx)(V,{size:`sm`,fw:700,children:`ERP`})]}),(0,I.jsx)(nm,{mb:4}),fZ.map(e=>(0,I.jsx)(gl,{component:zw,to:e.path,onClick:r,p:`sm`,mb:4,style:t=>({borderRadius:t.radius.sm,backgroundColor:d(e.path)?`var(--mantine-color-dark-5)`:void 0}),children:(0,I.jsx)(V,{size:`sm`,fw:d(e.path)?600:400,c:d(e.path)?void 0:`dimmed`,children:e.label})},e.path))]}),(0,I.jsxs)(hf.Main,{children:[!l&&(0,I.jsx)(Ld,{variant:`light`,color:`violet`,icon:(0,I.jsx)(tM,{size:`1rem`}),py:4,radius:0,styles:{wrapper:{justifyContent:`center`,alignItems:`center`},body:{flex:`initial`}},children:(0,I.jsx)(V,{size:`xs`,children:`Public read-only mode — login for full access`})}),(0,I.jsx)(GC,{context:{supervisorAuth:e}})]}),(0,I.jsx)(dZ,{opened:i,onClose:o})]})},mZ=()=>{let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(!0),i=(0,v.useCallback)(async()=>{r(!0);try{t(await q.get(J.admin))}catch{}finally{r(!1)}},[]);(0,v.useEffect)(()=>{i()},[i]);let a=e?!!Rj(e._actions,`view-logs`):!1,o=e?!!Rj(e._actions,`view-attachments`):!1,s=(0,v.useCallback)(async(e,t)=>q.get(J.adminLogs(void 0,t)),[]),c=(0,v.useCallback)(async(e,t)=>{let n=new URLSearchParams;return n.set(`page`,String(e)),n.set(`pageSize`,String(t)),q.get(`${J.adminAttachments}?${n}`)},[]),l=(0,v.useCallback)(e=>J.adminAttachmentDownload(e),[]);return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,w:`100%`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Admin`}),n?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):e?(0,I.jsxs)(jv,{defaultValue:`info`,children:[(0,I.jsxs)(jv.List,{children:[(0,I.jsx)(jv.Tab,{value:`info`,children:`Info`}),a&&(0,I.jsx)(jv.Tab,{value:`logs`,children:`Server Logs`}),o&&(0,I.jsx)(jv.Tab,{value:`attachments`,children:`Attachments`})]}),(0,I.jsx)(jv.Panel,{value:`info`,pt:`md`,children:(0,I.jsx)(W,{striped:!0,highlightOnHover:!0,children:(0,I.jsx)(W.Tbody,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Td,{fw:600,children:`ERP DB Path`}),(0,I.jsxs)(W.Td,{children:[e.erpDbPath,e.erpDbSize!=null&&` (${Lj(e.erpDbSize)})`]})]})})})}),a&&(0,I.jsx)(jv.Panel,{value:`logs`,pt:`md`,children:(0,I.jsx)(aU,{fetchLogs:s})}),o&&(0,I.jsx)(jv.Panel,{value:`attachments`,pt:`md`,children:(0,I.jsx)(pN,{fetchAttachments:c,getDownloadUrl:l})})]}):null]})},hZ=({value:e,onChange:t,onUserSelect:n,...r})=>{let[i]=zt(e,300),[a,o]=(0,v.useState)([]),s=(0,v.useCallback)(async e=>{try{let t=new URLSearchParams;t.set(`pageSize`,`10`),e&&t.set(`search`,e),o((await q.get(`${J.users}?${t}`)).items.map(e=>({id:e.id,username:e.username})))}catch{o([])}},[]);return(0,v.useEffect)(()=>{s(i)},[i,s]),(0,I.jsx)(Dp,{data:a.map(e=>e.username),value:e,onChange:t,onOptionSubmit:e=>{t(e);let r=a.find(t=>t.username===e);r&&n&&n(r)},...r})},gZ={display:`block`,color:`inherit`,textDecoration:`none`,padding:`var(--table-vertical-spacing) var(--table-horizontal-spacing, var(--mantine-spacing-xs))`},_Z={[DX.blocked]:`gray`,[DX.pending]:`blue`,[DX.in_progress]:`yellow`,[DX.completed]:`green`,[DX.skipped]:`gray`,[DX.failed]:`red`},vZ={low:`gray`,medium:`blue`,high:`orange`,critical:`red`},yZ=[{value:DX.pending,label:`Pending`},{value:DX.in_progress,label:`In Progress`},{value:DX.failed,label:`Failed`}],bZ=()=>{let[e,t]=qw(),n=Number(e.get(`page`))||1,r=e.get(`status`)||void 0,i=e.get(`priority`)||void 0,a=e.get(`search`)||``,o=e.get(`viewAs`)||``,s=e.get(`canWork`)===`true`,c=e.get(`clockedIn`)===`true`,[l,u]=(0,v.useState)(a),[d,f]=(0,v.useState)(o),[p]=zt(l,300),m=(0,v.useRef)(!0);(0,v.useEffect)(()=>{if(m.current){m.current=!1;return}t(e=>(p?e.set(`search`,p):e.delete(`search`),e.set(`page`,`1`),e))},[p,t]);let[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(!0),b=(0,v.useCallback)(async()=>{y(!0);try{let e=new URLSearchParams;e.set(`page`,String(n)),e.set(`pageSize`,`20`),r&&e.set(`status`,r),i&&e.set(`priority`,i),a&&e.set(`search`,a),o&&e.set(`viewAs`,o),s&&e.set(`canWork`,`true`),c&&e.set(`clockedIn`,`true`),g(await q.get(`${J.dispatch}?${e}`))}catch(e){gM(e)}finally{y(!1)}},[n,r,i,a,o,s,c]);(0,v.useEffect)(()=>{b()},[b]);let x=h?Math.ceil(h.total/h.pageSize):0;return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,children:[(0,I.jsx)(B,{justify:`space-between`,mb:`lg`,children:(0,I.jsx)(zv,{order:2,children:`Dispatch`})}),(0,I.jsxs)(B,{mb:`md`,children:[(0,I.jsx)(Mv,{placeholder:`Search...`,value:l,onChange:e=>u(e.currentTarget.value),style:{flex:1}}),(0,I.jsx)(R_,{placeholder:`All open`,data:yZ,value:r??null,onChange:e=>{t(t=>(e?t.set(`status`,e):t.delete(`status`),t.set(`page`,`1`),t))},clearable:!0}),(0,I.jsx)(R_,{placeholder:`All priorities`,data:LX.options.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),value:i??null,onChange:e=>{t(t=>(e?t.set(`priority`,e):t.delete(`priority`),t.set(`page`,`1`),t))},clearable:!0}),(0,I.jsx)(hZ,{placeholder:`View as user...`,value:d,onChange:e=>{f(e),e||t(e=>(e.delete(`viewAs`),e.set(`page`,`1`),e))},onUserSelect:e=>{f(e.username),t(t=>(t.set(`viewAs`,e.username),t.set(`page`,`1`),t))},w:180,size:`sm`}),(0,I.jsx)(yp,{label:`Can Work`,checked:s,onChange:e=>{t(t=>(e.currentTarget.checked?t.set(`canWork`,`true`):t.delete(`canWork`),t.set(`page`,`1`),t))}}),(0,I.jsx)(yp,{label:`Clocked In`,checked:c,onChange:e=>{t(t=>(e.currentTarget.checked?t.set(`clockedIn`,`true`):t.delete(`clockedIn`),t.set(`page`,`1`),t))}})]}),_?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):h&&h.items.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Order / Run`}),(0,I.jsx)(W.Th,{children:`Operation`}),(0,I.jsx)(W.Th,{children:`Can Work`}),(0,I.jsx)(W.Th,{children:`Status`}),(0,I.jsx)(W.Th,{children:`Priority`}),(0,I.jsx)(W.Th,{children:`Assigned To`}),(0,I.jsx)(W.Th,{children:`Due`})]})}),(0,I.jsx)(W.Tbody,{children:h.items.map(e=>{let t=`/orders/${e.orderKey}/runs/${e.runNo}/ops/${e.seqNo}`;return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsxs)(B,{gap:`xs`,wrap:`nowrap`,children:[(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:e.orderKey}),(0,I.jsxs)(Ap,{color:`violet`,variant:`light`,size:`sm`,children:[`R`,e.revNo]}),(0,I.jsxs)(V,{size:`sm`,ff:`monospace`,children:[`#`,e.runNo]})]})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsxs)(V,{size:`sm`,children:[(0,I.jsx)(V,{span:!0,ff:`monospace`,children:e.seqNo}),` — `,e.title]})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(V,{size:`sm`,c:e.canWork?`green`:`red`,children:e.canWork?`Yes`:`No`})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(Ap,{color:_Z[e.status]??`gray`,variant:`light`,children:e.status})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(Ap,{color:vZ[e.priority]??`gray`,variant:`light`,children:e.priority})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.assignedTo??`—`})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.dueAt?new Date(e.dueAt).toLocaleDateString():`—`})})]},e.id)})})]}),x>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:x,value:n,onChange:e=>t(t=>(t.set(`page`,String(e)),t))})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`xl`,children:`No open operations found.`})]})},xZ=()=>{let[e,t]=qw(),n=Number(e.get(`page`))||1,r=e.get(`search`)||``,[i,a]=(0,v.useState)(r),[o]=zt(i,300),s=(0,v.useRef)(!0);(0,v.useEffect)(()=>{if(s.current){s.current=!1;return}t(e=>(o?e.set(`search`,o):e.delete(`search`),e.set(`page`,`1`),e))},[o,t]);let[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!0),f=(0,v.useCallback)(async()=>{d(!0);try{let e=new URLSearchParams;e.set(`page`,String(n)),e.set(`pageSize`,`20`),r&&e.set(`search`,r),l(await q.get(`${J.inventory}?${e}`))}catch(e){gM(e)}finally{d(!1)}},[n,r]);(0,v.useEffect)(()=>{f()},[f]);let p=c?Math.ceil(c.total/c.pageSize):0;return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,children:[(0,I.jsx)(B,{justify:`space-between`,mb:`lg`,children:(0,I.jsx)(zv,{order:2,children:`Inventory`})}),(0,I.jsx)(B,{mb:`md`,children:(0,I.jsx)(Mv,{placeholder:`Search...`,value:i,onChange:e=>a(e.currentTarget.value),style:{flex:1}})}),u?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):c&&c.items.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Item`}),(0,I.jsx)(W.Th,{children:`Instance`}),(0,I.jsx)(W.Th,{children:`Quantity`}),(0,I.jsx)(W.Th,{children:`Produced By`}),(0,I.jsx)(W.Th,{children:`Created`})]})}),(0,I.jsx)(W.Tbody,{children:c.items.map(e=>{let t=`/items/${e.itemKey}/instances/${e.id}`;return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:`/items/${e.itemKey}`,style:gZ,children:(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:e.itemKey})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:e.key})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.quantity==null?`—`:e.quantity})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.orderKey?(0,I.jsxs)(V,{size:`sm`,children:[e.orderKey,` Run `,e.orderRunNo]}):`—`})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:new Date(e.createdAt).toLocaleDateString()})})]},e.id)})})]}),p>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:p,value:n,onChange:e=>t(t=>(t.set(`page`,String(e)),t))})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`xl`,children:`No inventory found.`})]})},SZ=()=>{let e=hC(),[t,n]=(0,v.useState)(``),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),s=async()=>{o(!0);try{await q.post(J.items,{key:t,description:r}),e(`/items`)}catch(e){gM(e)}finally{o(!1)}};return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Create Item`}),(0,I.jsxs)(U,{children:[(0,I.jsx)(Mv,{label:`Key`,description:`Alphanumeric with hyphens`,value:t,onChange:e=>n(e.currentTarget.value),required:!0,"data-autofocus":!0}),(0,I.jsx)(Qm,{label:`Description`,value:r,onChange:e=>i(e.currentTarget.value),autosize:!0,minRows:2}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>e(`/items`),children:`Cancel`}),(0,I.jsx)(H,{onClick:s,loading:a,disabled:!t,children:`Create`})]})]})]})},CZ=({createdBy:e,createdAt:t,updatedBy:n,updatedAt:r})=>(0,I.jsx)(M_,{label:(0,I.jsxs)(U,{gap:4,children:[(0,I.jsxs)(V,{size:`xs`,children:[`Created`,e?` by ${e}`:``,`,`,` `,new Date(t).toLocaleString()]}),(0,I.jsxs)(V,{size:`xs`,children:[`Modified`,n?` by ${n}`:``,`,`,` `,new Date(r).toLocaleString()]})]}),multiline:!0,withArrow:!0,children:(0,I.jsx)(vu,{variant:`subtle`,size:`sm`,color:`gray`,children:(0,I.jsx)(rM,{size:16})})}),wZ={string:`String`,number:`Number`,date:`Date`,datetime:`Date/Time`,yesNo:`Yes/No`,checkbox:`Checkbox`,attachment:`Attachment`};function TZ(e){return wZ[e]??e}var EZ=({fieldsEndpoint:e,fieldEndpoint:t,initialData:n})=>{let[r,i]=(0,v.useState)(n),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),d=rN({initialValues:{seqNo:10,label:``,type:tX.string,isArray:!1,required:!1},validate:oU(iX)}),f=rN({initialValues:{seqNo:10,label:``,type:tX.string,isArray:!1,required:!1},validate:oU(rX)}),p=e=>{d.setValues({seqNo:e.seqNo,label:e.label,type:e.type,isArray:e.isArray,required:e.required}),o(e.id),c(!1)},m=async e=>{let n=r.items.find(e=>e.id===a);if(n){u(!0);try{let a=await q.put(t(n.seqNo),e);o(null),i({...r,items:r.items.map(e=>e.id===a.id?a:e).sort((e,t)=>e.seqNo-t.seqNo)})}catch(e){gM(e)}finally{u(!1)}}},h=async e=>{if(confirm(`Delete field "${e.label}"?`))try{await q.delete(t(e.seqNo)),i({...r,items:r.items.filter(t=>t.id!==e.id),total:r.total-1})}catch(e){gM(e)}},g=()=>{f.setValues({seqNo:r.nextSeqNo,label:``,type:tX.string,isArray:!1,required:!1}),c(!0),o(null)},_=async t=>{u(!0);try{let n=await q.post(e,t);c(!1),i({...r,items:[...r.items,n].sort((e,t)=>e.seqNo-t.seqNo),total:r.total+1,nextSeqNo:n.seqNo+10})}catch(e){gM(e)}finally{u(!1)}},y=e=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Vg,{label:`Sequence #`,min:1,step:10,...e.getInputProps(`seqNo`)}),(0,I.jsx)(Mv,{label:`Label`,placeholder:`Field label...`,...e.getInputProps(`label`)}),(0,I.jsx)(R_,{label:`Type`,data:eX.options.map(e=>({value:e,label:TZ(e)})),...e.getInputProps(`type`)}),(0,I.jsx)(yp,{label:`Array (accepts multiple values)`,...e.getInputProps(`isArray`,{type:`checkbox`})}),(0,I.jsx)(yp,{label:`Required`,...e.getInputProps(`required`,{type:`checkbox`})})]});return(0,I.jsxs)(U,{gap:`xs`,mt:`xs`,children:[(0,I.jsxs)(B,{justify:`space-between`,children:[r.items.length>0&&(0,I.jsx)(V,{size:`xs`,fw:600,c:`dimmed`,children:`Data Fields`}),Rj(r._actions,`create`)&&!s&&(0,I.jsx)(H,{size:`compact-xs`,variant:`subtle`,onClick:g,children:`Add Field`})]}),r.items.map(e=>(0,I.jsx)(`div`,{children:a===e.id?(0,I.jsx)(`form`,{onSubmit:d.onSubmit(m),children:(0,I.jsxs)(U,{gap:`xs`,children:[y(d),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,size:`compact-xs`,onClick:()=>o(null),children:`Cancel`}),(0,I.jsx)(H,{type:`submit`,size:`compact-xs`,loading:l,children:`Save`})]})]})}):(0,I.jsxs)(B,{justify:`space-between`,wrap:`nowrap`,children:[(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsxs)(V,{size:`xs`,children:[e.seqNo,`.`]}),(0,I.jsx)(V,{size:`xs`,fw:500,children:e.label}),(0,I.jsx)(Ap,{size:`xs`,variant:`light`,children:TZ(e.type)}),e.isArray&&(0,I.jsx)(Ap,{size:`xs`,variant:`light`,color:`blue`,children:`[]`}),e.required&&(0,I.jsx)(Ap,{size:`xs`,variant:`light`,color:`red`,children:`required`})]}),(0,I.jsxs)(B,{gap:4,wrap:`nowrap`,children:[(0,I.jsx)(CZ,{createdBy:e.createdBy,createdAt:e.createdAt,updatedBy:e.updatedBy,updatedAt:e.updatedAt}),Rj(e._actions,`update`)&&(0,I.jsx)(H,{size:`compact-xs`,variant:`subtle`,onClick:()=>p(e),children:`Edit`}),Rj(e._actions,`delete`)&&(0,I.jsx)(H,{size:`compact-xs`,color:`red`,variant:`subtle`,onClick:()=>h(e),children:`Delete`})]})]})},e.id)),s&&(0,I.jsx)(`form`,{onSubmit:f.onSubmit(_),children:(0,I.jsxs)(U,{gap:`xs`,children:[y(f),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,size:`compact-xs`,onClick:()=>c(!1),children:`Cancel`}),(0,I.jsx)(H,{type:`submit`,size:`compact-xs`,loading:l,children:`Add`})]})]})})]})},DZ=()=>{let{key:e}=bC(),t=hC(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),m=(0,v.useCallback)(async()=>{if(e){a(!0);try{r(await q.get(J.item(e)))}catch(e){gM(e)}finally{a(!1)}}},[e]);return(0,v.useEffect)(()=>{m()},[m]),i?(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(U,{align:`center`,children:(0,I.jsx)(uu,{})})}):n?o?(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Edit Item`}),(0,I.jsxs)(U,{children:[(0,I.jsx)(Mv,{label:`Key`,description:`Alphanumeric with hyphens`,value:c,onChange:e=>l(e.currentTarget.value),required:!0}),(0,I.jsx)(Qm,{label:`Description`,value:u,onChange:e=>d(e.currentTarget.value),autosize:!0,minRows:2}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>s(!1),children:`Cancel`}),(0,I.jsx)(H,{onClick:async()=>{if(e){p(!0);try{let n={key:c,description:u};await q.put(J.item(e),n),s(!1),c===e?await m():t(`/items/${c}`,{replace:!0})}catch(e){gM(e)}finally{p(!1)}}},loading:f,children:`Save`})]})]})]}):(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(zv,{order:2,children:n.key}),(0,I.jsx)(CZ,{createdBy:n.createdBy,createdAt:n.createdAt,updatedBy:n.updatedBy,updatedAt:n.updatedAt})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>t(`/items`),children:`Back`}),Rj(n._actions,`update`)&&(0,I.jsx)(H,{onClick:()=>{n&&(l(n.key),d(n.description),s(!0))},children:`Edit`}),Rj(n._actions,`delete`)&&(0,I.jsx)(H,{color:`red`,variant:`outline`,onClick:async()=>{if(!(!e||!confirm(`Delete this item?`)))try{await q.delete(J.item(e)),t(`/items`)}catch(e){gM(e)}},children:`Delete`})]})]}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,children:(0,I.jsx)(U,{gap:`sm`,children:(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Description:`}),(0,I.jsx)(V,{children:n.description||`—`})]})})}),(0,I.jsx)(B,{mt:`lg`,children:(0,I.jsx)(H,{variant:`light`,onClick:()=>t(`/items/${n.key}/instances`),children:`View Instances`})}),(0,I.jsx)(EZ,{fieldsEndpoint:J.itemFields(n.key),fieldEndpoint:e=>J.itemField(n.key,e),initialData:n.fields})]}):(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(V,{children:`Item not found.`})})};function OZ(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function kZ(e){return`${OZ(e)}T${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`}var AZ=new Set([`.jpg`,`.jpeg`,`.png`,`.gif`,`.webp`,`.svg`,`.bmp`]);function jZ(e){let t=e.slice(e.lastIndexOf(`.`)).toLowerCase();return AZ.has(t)}function MZ(e){return e.endsWith(`[]`)}function NZ(e){return e.endsWith(`[]`)?e.slice(0,-2):e}function PZ(e,t){return`${e}_${t}`}function FZ(e){return Object.fromEntries(e.map(e=>[PZ(e.fieldId,e.setIndex),e.value]))}function IZ(e){return typeof e==`string`?e:e.join(`, `)}function LZ(e){return Array.isArray(e)?e.length>0?e:[``]:e?[e]:[``]}function RZ({status:e}){return e===`saving`?(0,I.jsx)(uu,{size:14}):e===`saved`?(0,I.jsx)($j,{size:14,color:`green`}):e===`error`?(0,I.jsx)(Yj,{size:14,color:`red`}):null}var zZ=({fieldValues:e,multiSet:t,completed:n,_actionTemplates:r,fieldValueEndpoint:i,deleteSetEndpoint:a,attachmentEndpoint:o,attachmentDownloadUrl:s,onSetDeleted:c,onActionsUpdated:l})=>{let[u,d]=(0,v.useState)(e),[f,p]=(0,v.useState)(()=>FZ(e)),[m,h]=(0,v.useState)({}),g=(0,v.useRef)({}),[_,y]=(0,v.useState)(0),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),w=(0,v.useRef)(e);(0,v.useEffect)(()=>{e!==w.current&&(w.current=e,d(e),p(FZ(e)))},[e]);let T=(e,t,n)=>{let r=PZ(e,t);p(e=>({...e,[r]:n}))},E=(e,t,n)=>{let r=PZ(e,t);d(r=>r.some(n=>n.fieldId===e&&n.setIndex===t)?r.map(r=>r.fieldId===e&&r.setIndex===t?n:r):[...r,n]),p(e=>({...e,[r]:n.value}))},D=()=>{let e=u.reduce((e,t)=>Math.max(e,t.setIndex),-1)+1,t=u.filter(e=>e.setIndex===0);if(t.length===0)return;let n=t.map(t=>({...t,setIndex:e,value:MZ(t.type)?[]:``,validation:t.required?{valid:!1,error:`Required`}:{valid:!0}}));d(e=>[...e,...n])},O=(e,t,n)=>{d(r=>r.map(r=>r.fieldId===e&&r.setIndex===t?{...r,attachments:[...r.attachments??[],n]}:r))},k=[...new Set(u.map(e=>e.setIndex))].sort((e,t)=>e-t);k.length===0&&k.push(0);let A=Math.min(_,k[k.length-1]);A!==_&&y(A);let j=u.filter(e=>e.setIndex===A),ee=(e,t,n)=>{let r=PZ(e,t);g.current[r]&&(clearTimeout(g.current[r]),delete g.current[r]),n===`saved`&&(g.current[r]=setTimeout(()=>{h(e=>{let t={...e};return delete t[r],t}),delete g.current[r]},1500)),h(e=>({...e,[r]:n}))},te=async(e,t)=>{let n=e.value;if(JSON.stringify(t)!==JSON.stringify(n)){ee(e.fieldId,e.setIndex,`saving`);try{let n=await q.put(i(e.fieldSeqNo,e.setIndex),{value:t});E(e.fieldId,e.setIndex,n),ee(e.fieldId,e.setIndex,`saved`),n._actions&&n._actionTemplates&&l?.(n._actions,n._actionTemplates)}catch(t){gM(t),ee(e.fieldId,e.setIndex,`error`)}}},ne=(e,t)=>{T(e.fieldId,e.setIndex,t),te(e,t)},re=(e,t,n)=>{let r=[...LZ(f[PZ(e.fieldId,e.setIndex)]??e.value)];r[t]=n,T(e.fieldId,e.setIndex,r)},M=e=>{let t=[...LZ(f[PZ(e.fieldId,e.setIndex)]??e.value),``];T(e.fieldId,e.setIndex,t)},N=(e,t)=>{let n=[...LZ(f[PZ(e.fieldId,e.setIndex)]??e.value)];n.splice(t,1),T(e.fieldId,e.setIndex,n),te(e,n)},ie=()=>{y(k.length>0?k[k.length-1]+1:0),D()},ae=async e=>{x(!0);try{await q.delete(a(e)),A>=e&&A>0&&y(A-1),c()}catch(e){gM(e)}finally{x(!1)}},oe=!!zj(r,`uploadAttachment`),se=!!zj(r,`deleteAttachment`),ce=async(e,t)=>{if(t){C(PZ(e.fieldId,e.setIndex));try{let n=await q.upload(o(e.fieldSeqNo,e.setIndex),t);O(e.fieldId,e.setIndex,{id:n.attachmentId,filename:n.filename,fileSize:n.fileSize})}catch(e){gM(e)}finally{C(null)}}},[le,ue]=(0,v.useState)(null),de=async(e,t)=>{ue(`${PZ(e.fieldId,e.setIndex)}_${t}`);try{await q.delete(`${o(e.fieldSeqNo,e.setIndex)}/${t}`),d(n=>n.map(n=>n.fieldId===e.fieldId&&n.setIndex===e.setIndex?{...n,attachments:(n.attachments??[]).filter(e=>e.id!==t)}:n))}catch(e){gM(e)}finally{ue(null)}};function fe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function pe(e,t,n){let r=e.attachments??[],i=PZ(e.fieldId,e.setIndex),a=S===i,o=n&&oe&&(MZ(e.type)||r.length===0);return(0,I.jsxs)(U,{gap:4,children:[(0,I.jsx)(V,{size:`xs`,fw:500,children:t}),r.map(t=>{let r=le===`${i}_${t.id}`,a=s(e.fieldSeqNo,t.id),o=jZ(t.filename);return(0,I.jsxs)(U,{gap:4,children:[o&&(0,I.jsx)(Wd,{href:a,target:`_blank`,children:(0,I.jsx)(Om,{src:a,alt:t.filename,maw:200,mah:200,fit:`contain`,radius:`sm`})}),(0,I.jsxs)(B,{gap:`xs`,children:[!o&&(0,I.jsx)(nM,{size:14}),(0,I.jsx)(Wd,{size:`xs`,href:a,target:`_blank`,children:t.filename}),(0,I.jsxs)(V,{size:`xs`,c:`dimmed`,children:[`(`,fe(t.fileSize),`)`]}),n&&se&&(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,color:`red`,loading:r,onClick:()=>de(e,t.id),title:`Remove attachment`,children:(0,I.jsx)(pM,{size:14})})]})]},t.id)}),r.length===0&&!n&&(0,I.jsx)(V,{size:`xs`,c:`dimmed`,children:`No attachments`}),o&&(0,I.jsx)(Tm,{onChange:t=>ce(e,t),children:e=>(0,I.jsx)(H,{...e,size:`compact-xs`,variant:`light`,leftSection:a?(0,I.jsx)(uu,{size:14}):(0,I.jsx)(dM,{size:14}),loading:a,children:`Upload File`})})]},i)}function me(e,t,n,r){let{label:i,onTextChange:a,onImmediateChange:o,onBlurSave:s}=r,c=e.validation&&!e.validation.valid?e.validation.error:void 0;switch(NZ(e.type)){case tX.date:return(0,I.jsx)(ex,{label:i,size:`xs`,style:{flex:1},valueFormat:`YYYY-MM-DD`,clearable:!0,error:c,value:t?new Date(t+`T00:00:00`):null,onChange:e=>o(e?typeof e==`string`?e:OZ(e):``),rightSection:(0,I.jsx)(RZ,{status:n})});case tX.datetime:return(0,I.jsx)(ax,{label:i,size:`xs`,style:{flex:1},valueFormat:`YYYY-MM-DD HH:mm`,clearable:!0,error:c,value:t?new Date(t):null,onChange:e=>o(e?typeof e==`string`?e:kZ(e):``),rightSection:(0,I.jsx)(RZ,{status:n})});case tX.yesNo:return(0,I.jsxs)(B,{gap:`xs`,align:`center`,children:[i&&(0,I.jsx)(V,{size:`xs`,fw:500,children:i}),(0,I.jsx)(rv,{size:`xs`,onLabel:`Yes`,offLabel:`No`,checked:t===`Yes`,onChange:e=>o(e.currentTarget.checked?`Yes`:`No`)}),(0,I.jsx)(RZ,{status:n})]});case tX.checkbox:return(0,I.jsxs)(B,{gap:`xs`,align:`center`,children:[(0,I.jsx)(yp,{label:i,size:`xs`,checked:t===`checked`,onChange:e=>o(e.currentTarget.checked?`checked`:``)}),(0,I.jsx)(RZ,{status:n})]});case tX.attachment:return null;default:return(0,I.jsx)(Mv,{label:i,size:`xs`,style:{flex:1},error:c,value:t,onChange:e=>a(e.currentTarget.value),onBlur:s,rightSection:(0,I.jsx)(RZ,{status:n})})}}function he(e){let t=IZ(e.value);if(!t)return`—`;if(MZ(e.type)&&Array.isArray(e.value))return e.value.filter(Boolean).join(`, `)||`—`;switch(NZ(e.type)){case tX.date:return new Date(t+`T00:00:00`).toLocaleDateString();case tX.datetime:return new Date(t).toLocaleString();case tX.checkbox:return t===`checked`?`Checked`:`—`;default:return t}}let ge=!n&&!!zj(r,`updateField`);return(0,I.jsxs)(U,{gap:`xs`,mt:`xs`,children:[(0,I.jsx)(V,{size:`xs`,fw:600,c:`dimmed`,children:`Data Fields`}),t&&(0,I.jsxs)(B,{gap:4,children:[k.map(e=>(0,I.jsxs)(H,{size:`compact-xs`,variant:e===A?`filled`:`light`,onClick:()=>y(e),children:[`Set `,e+1]},e)),ge&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,onClick:ie,title:`Add set`,children:(0,I.jsx)(lM,{size:14})}),k.length>1&&(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,color:`red`,loading:b,onClick:()=>ae(A),title:`Delete current set`,children:(0,I.jsx)(uM,{size:14})})]})]}),j.map(e=>{let t=PZ(e.fieldId,e.setIndex),n=m[t],r=e.required?`${e.label} *`:e.label,i=ge,a=f[t]??e.value;if(NZ(e.type)===tX.attachment)return pe(e,r,i);if(!i)return MZ(e.type)&&Array.isArray(e.value)&&e.value.filter(Boolean).length>0?(0,I.jsxs)(U,{gap:2,children:[(0,I.jsxs)(V,{size:`xs`,fw:500,children:[r,`:`]}),e.value.filter(Boolean).map((e,t)=>(0,I.jsxs)(V,{size:`xs`,pl:`sm`,children:[`• `,e]},t))]},t):(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsxs)(V,{size:`xs`,fw:500,children:[r,`:`]}),typeof e.value==`string`&&e.value?.startsWith(`http`)?(0,I.jsx)(Wd,{size:`xs`,href:e.value,target:`_blank`,children:e.value}):(0,I.jsx)(V,{size:`xs`,children:he(e)}),e.validation&&!e.validation.valid&&(0,I.jsx)(V,{size:`xs`,c:`red`,children:e.validation.error})]},t);if(MZ(e.type)){let i=LZ(a);return(0,I.jsxs)(U,{gap:4,children:[(0,I.jsxs)(B,{gap:`xs`,align:`center`,children:[(0,I.jsx)(V,{size:`xs`,fw:500,children:r}),(0,I.jsx)(RZ,{status:n})]}),i.map((t,n)=>(0,I.jsxs)(B,{gap:4,align:`flex-end`,children:[me(e,t,void 0,{onTextChange:t=>re(e,n,t),onImmediateChange:t=>{let r=[...i];r[n]=t,T(e.fieldId,e.setIndex,r),te(e,r)},onBlurSave:()=>void te(e,a)}),i.length>1&&(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,color:`red`,onClick:()=>N(e,n),title:`Remove item`,children:(0,I.jsx)(pM,{size:14})})]},n)),(0,I.jsx)(B,{children:(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,onClick:()=>M(e),title:`Add item`,children:(0,I.jsx)(lM,{size:14})})}),e.validation&&!e.validation.valid&&(0,I.jsx)(V,{size:`xs`,c:`red`,children:e.validation.error})]},t)}return(0,I.jsx)(B,{gap:`xs`,align:`flex-end`,children:me(e,IZ(a),n,{label:r,onTextChange:t=>T(e.fieldId,e.setIndex,t),onImmediateChange:t=>ne(e,t),onBlurSave:()=>void te(e,a)})},t)})]})},BZ=()=>{let{key:e,instanceId:t}=bC(),n=hC(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!0),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),_=(0,v.useCallback)(async()=>{if(!(!e||!t)){o(!0);try{i(await q.get(J.itemInstance(e,t)))}catch(e){gM(e)}finally{o(!1)}}},[e,t]);(0,v.useEffect)(()=>{_()},[_]);let y=()=>{r&&(f(r.key),m(r.quantity==null?``:String(r.quantity)),c(!0))},b=async()=>{if(!(!e||!t)){g(!0);try{let n={key:d,quantity:p?Number(p):null};await q.put(J.itemInstance(e,t),n),c(!1),await _()}catch(e){gM(e)}finally{g(!1)}}},x=async()=>{if(!(!e||!t||!confirm(`Delete this instance?`)))try{await q.delete(J.itemInstance(e,t)),n(`/items/${e}/instances`)}catch(e){gM(e)}};if(a)return(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(U,{align:`center`,children:(0,I.jsx)(uu,{})})});if(!r)return(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(V,{children:`Instance not found.`})});if(s)return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Edit Instance`}),(0,I.jsxs)(U,{children:[(0,I.jsx)(Mv,{label:`Key (lot/serial number)`,value:d,onChange:e=>f(e.currentTarget.value),required:!0}),(0,I.jsx)(Mv,{label:`Quantity`,type:`number`,value:p,onChange:e=>m(e.currentTarget.value)}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>c(!1),children:`Cancel`}),(0,I.jsx)(H,{onClick:b,loading:h,children:`Save`})]})]})]});let S=r.fieldValues.length>0,C=Rj(r._actions,`update`);return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(zv,{order:2,children:r.key}),(0,I.jsx)(CZ,{createdBy:r.createdBy,createdAt:r.createdAt,updatedBy:r.updatedBy,updatedAt:r.updatedAt})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>n(`/items/${e}/instances`),children:`Back`}),Rj(r._actions,`update`)&&(0,I.jsx)(H,{onClick:y,children:`Edit`}),Rj(r._actions,`delete`)&&(0,I.jsx)(H,{color:`red`,variant:`outline`,onClick:x,children:`Delete`})]})]}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,children:(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Key:`}),(0,I.jsx)(V,{ff:`monospace`,children:r.key})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Quantity:`}),(0,I.jsx)(V,{children:r.quantity==null?`—`:r.quantity})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Produced By:`}),r.orderKey?(0,I.jsxs)(Wd,{href:`/erp/orders/${r.orderKey}/runs/${r.orderRunNo}`,onClick:e=>{e.button===1||e.ctrlKey||e.metaKey||(e.preventDefault(),n(`/orders/${r.orderKey}/runs/${r.orderRunNo}`))},children:[r.orderKey,` Order Run `,r.orderRunNo]}):(0,I.jsx)(V,{children:`—`})]})]})}),S&&(0,I.jsxs)(Wp,{withBorder:!0,p:`lg`,mt:`md`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`xs`,children:[(0,I.jsx)(V,{fw:600,children:`Field Values`}),C&&(0,I.jsx)(H,{size:`xs`,variant:l?`filled`:`light`,onClick:()=>u(e=>!e),children:l?`Done Editing`:`Edit Fields`})]}),(0,I.jsx)(zZ,{fieldValues:r.fieldValues,multiSet:!1,completed:!l,_actionTemplates:l?r._actionTemplates:void 0,fieldValueEndpoint:(n,r)=>J.itemInstanceFieldValue(e,t,n),deleteSetEndpoint:n=>J.itemInstanceDeleteSet(e,t,n),attachmentEndpoint:(e,t)=>``,attachmentDownloadUrl:()=>``,onSetDeleted:()=>void _()})]})]})},VZ=()=>{let{key:e}=bC(),t=hC(),[n,r]=qw(),i=Number(n.get(`page`))||1,a=n.get(`search`)||``,[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!0),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(!1),y=(0,v.useCallback)(async()=>{if(e){l(!0);try{let t=new URLSearchParams;t.set(`page`,String(i)),t.set(`pageSize`,`20`),a&&t.set(`search`,a),s(await q.get(`${J.itemInstances(e)}?${t}`))}catch(e){gM(e)}finally{l(!1)}}},[e,i,a]);(0,v.useEffect)(()=>{y()},[y]);let b=async()=>{if(e){_(!0);try{let n={key:f,quantity:m?Number(m):null};t(`/items/${e}/instances/${(await q.post(J.itemInstances(e),n)).id}`)}catch(e){gM(e)}finally{_(!1)}}},x=o?Math.ceil(o.total/o.pageSize):0;return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsx)(B,{children:(0,I.jsxs)(zv,{order:2,children:[`Instances for `,e]})}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>t(`/items/${e}`),children:`Back to Item`}),o&&Rj(o._actions,`create`)&&!u&&(0,I.jsx)(H,{onClick:()=>d(!0),children:`Create New`})]})]}),u&&(0,I.jsxs)(Wp,{withBorder:!0,p:`lg`,mb:`md`,children:[(0,I.jsx)(zv,{order:4,mb:`sm`,children:`New Instance`}),(0,I.jsxs)(U,{children:[(0,I.jsx)(Mv,{label:`Key (lot/serial number)`,value:f,onChange:e=>p(e.currentTarget.value),required:!0,"data-autofocus":!0}),(0,I.jsx)(Mv,{label:`Quantity`,type:`number`,value:m,onChange:e=>h(e.currentTarget.value)}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>{d(!1),p(``),h(``)},children:`Cancel`}),(0,I.jsx)(H,{onClick:b,loading:g,disabled:!f,children:`Create`})]})]})]}),(0,I.jsx)(B,{mb:`md`,children:(0,I.jsx)(Mv,{placeholder:`Search by key...`,value:a,onChange:e=>{let t=e.currentTarget.value;r(e=>(t?e.set(`search`,t):e.delete(`search`),e.set(`page`,`1`),e))},style:{flex:1}})}),c?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):o&&o.items.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Key`}),(0,I.jsx)(W.Th,{children:`Quantity`}),(0,I.jsx)(W.Th,{children:`Order Run`}),(0,I.jsx)(W.Th,{children:`Created`})]})}),(0,I.jsx)(W.Tbody,{children:o.items.map(t=>{let n=`/items/${e}/instances/${t.id}`;return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:t.key})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:(0,I.jsx)(V,{size:`sm`,children:t.quantity==null?`—`:t.quantity})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:(0,I.jsx)(V,{size:`sm`,children:t.orderKey?`${t.orderKey} Run ${t.orderRunNo}`:`—`})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:new Date(t.createdAt).toLocaleDateString()})})]},t.id)})})]}),x>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:x,value:i,onChange:e=>r(t=>(t.set(`page`,String(e)),t))})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`xl`,children:`No instances found.`})]})},HZ=()=>{let e=hC(),[t,n]=qw(),r=Number(t.get(`page`))||1,i=t.get(`search`)||``,[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!0),l=(0,v.useCallback)(async()=>{c(!0);try{let e=new URLSearchParams;e.set(`page`,String(r)),e.set(`pageSize`,`20`),i&&e.set(`search`,i),o(await q.get(`${J.items}?${e}`))}catch(e){gM(e)}finally{c(!1)}},[r,i]);(0,v.useEffect)(()=>{l()},[l]);let u=a?Math.ceil(a.total/a.pageSize):0;return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsx)(zv,{order:2,children:`Items`}),a&&Rj(a._actions,`create`)&&(0,I.jsx)(H,{onClick:()=>e(`/items/new`),children:`Create New`})]}),(0,I.jsx)(B,{mb:`md`,children:(0,I.jsx)(Mv,{placeholder:`Search...`,value:i,onChange:e=>{let t=e.currentTarget.value;n(e=>(t?e.set(`search`,t):e.delete(`search`),e.set(`page`,`1`),e))},style:{flex:1}})}),s?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):a&&a.items.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Key`}),(0,I.jsx)(W.Th,{children:`Description`}),(0,I.jsx)(W.Th,{children:`Created`})]})}),(0,I.jsx)(W.Tbody,{children:a.items.map(e=>{let t=`/items/${e.key}`;return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:e.key})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(V,{size:`sm`,lineClamp:1,children:e.description||`—`})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:new Date(e.createdAt).toLocaleDateString()})})]},e.id)})})]}),u>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:u,value:r,onChange:e=>n(t=>(t.set(`page`,String(e)),t))})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`xl`,children:`No items found.`})]})},UZ=()=>{let{login:e}=xM(),[t,n]=v.useState(``),[r,i]=v.useState(``),[a,o]=v.useState(!1),[s,c]=v.useState(``),l=async()=>{if(!t.trim()||!r.trim()){c(`Please enter both username and password`);return}o(!0),c(``);try{await e(t,r)}catch(e){c(e instanceof Error?e.message:`An error occurred`)}finally{o(!1)}},u=e=>{e.key===`Enter`&&l()};return(0,I.jsx)(Kp,{style:{minHeight:`100vh`},children:(0,I.jsxs)(U,{align:`center`,gap:`lg`,w:320,children:[(0,I.jsx)(`img`,{src:Kj,alt:`NAISYS`,style:{width:`64px`,height:`64px`}}),(0,I.jsx)(V,{size:`xl`,fw:600,children:`NAISYS ERP`}),(0,I.jsxs)(U,{gap:`md`,w:`100%`,children:[s&&(0,I.jsx)(Ld,{color:`red`,variant:`light`,children:s}),(0,I.jsx)(Mv,{label:`Username`,placeholder:`Enter your username`,value:t,onChange:e=>n(e.currentTarget.value),onKeyDown:u,"data-autofocus":!0,disabled:a}),(0,I.jsx)(Mv,{label:`Password`,type:`password`,placeholder:`Enter your password`,value:r,onChange:e=>i(e.currentTarget.value),onKeyDown:u,disabled:a}),(0,I.jsx)(H,{fullWidth:!0,onClick:l,loading:a,disabled:!t.trim()||!r.trim(),children:`Login`})]})]})})},WZ=({initialData:e,isEdit:t,onSubmit:n,onCancel:r})=>{let i=t?ZX:XX,a=rN({initialValues:{key:e?.key??``,description:e?.description??``,status:e?.status??JX.active,itemKey:e?.itemKey??``},validate:oU(i)}),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)([]),[f]=zt(a.values.itemKey,300),p=(0,v.useCallback)(async e=>{try{let t=new URLSearchParams;t.set(`pageSize`,`10`),e&&t.set(`search`,e),d((await q.get(`${J.items}?${t}`)).items.map(e=>e.key))}catch{d([])}},[]);return(0,v.useEffect)(()=>{p(f)},[f,p]),(0,I.jsx)(`form`,{onSubmit:a.onSubmit(async e=>{s(!0),l(null);try{let r=t?{key:e.key,description:e.description,status:e.status,itemKey:e.itemKey||null}:{key:e.key,description:e.description,itemKey:e.itemKey||void 0};await n(i.parse(r))}catch(e){l(e instanceof Error?e.message:`An error occurred`)}finally{s(!1)}}),children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsx)(Mv,{label:`Key`,description:`Unique identifier (alphanumeric, hyphens allowed)`,placeholder:`standard-order`,...a.getInputProps(`key`)}),(0,I.jsx)(Dp,{label:`Produces Item`,placeholder:`Search by item key...`,data:u,...a.getInputProps(`itemKey`)}),(0,I.jsx)(Qm,{label:`Description`,placeholder:`Describe this order...`,...a.getInputProps(`description`),autosize:!0,minRows:3}),t&&(0,I.jsx)(R_,{label:`Status`,data:qX.options.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),...a.getInputProps(`status`)}),c&&(0,I.jsx)(`div`,{style:{color:`var(--mantine-color-red-6)`},children:c}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{type:`submit`,loading:o,children:t?`Save Changes`:`Create`}),(0,I.jsx)(H,{variant:`subtle`,onClick:r,children:`Cancel`})]})]})})},GZ=()=>{let e=hC();return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Create Order`}),(0,I.jsx)(WZ,{onSubmit:async t=>{await q.post(J.orders,t),e(`/orders`)},onCancel:()=>e(`/orders`)})]})},KZ={[jX.draft]:`blue`,[jX.approved]:`green`,[jX.obsolete]:`gray`},qZ=10,JZ=({orderKey:e})=>{let t=hC(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)([]),[m,h]=(0,v.useState)(!1),g=(0,v.useCallback)(async()=>{a(!0);try{let t=new URLSearchParams({page:String(o),pageSize:String(qZ)});m&&t.set(`includeObsolete`,`true`),r(await q.get(`${J.orderRevs(e)}?${t}`))}catch(e){gM(e)}finally{a(!1)}},[e,o,m]);(0,v.useEffect)(()=>{g()},[g]);let _=async()=>{l(!0);try{t(`/orders/${e}/revs/${(await q.post(J.orderRevs(e),{})).revNo}/header`)}catch(e){gM(e)}finally{l(!1)}},y=async t=>{if(confirm(`Approve revision #${t.revNo}?`))try{await q.post(J.orderRevApprove(e,t.revNo),{}),await g()}catch(e){gM(e)}},b=async t=>{if(confirm(`Mark revision #${t.revNo} as obsolete?`))try{await q.post(J.orderRevObsolete(e,t.revNo),{}),await g()}catch(e){gM(e)}},x=async t=>{if(confirm(`Delete revision #${t.revNo}?`))try{await q.delete(J.orderRev(e,t.revNo)),await g()}catch(e){gM(e)}},S=e=>{p(t=>t.includes(e)?t.filter(t=>t!==e):t.length>=2?[t[1],e]:[...t,e])},C=()=>{if(f.length!==2)return;let[n,r]=f.sort((e,t)=>e-t);t(`/orders/${e}/revs/diff?from=${n}&to=${r}`)},w=n?Math.ceil(n.total/qZ):0;return(0,I.jsxs)(Wp,{withBorder:!0,p:`lg`,mt:`lg`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`md`,children:[(0,I.jsx)(zv,{order:4,children:`Revisions`}),(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(yp,{label:`Show obsolete`,checked:m,onChange:e=>{h(e.currentTarget.checked),s(1)}}),u&&f.length===2&&(0,I.jsx)(H,{size:`sm`,variant:`light`,onClick:C,children:`Compare`}),(0,I.jsx)(H,{size:`sm`,variant:u?`filled`:`light`,color:u?`gray`:`violet`,onClick:()=>{d(e=>!e),p([])},children:u?`Cancel`:`Compare`}),n&&Rj(n._actions,`create`)&&(0,I.jsx)(H,{size:`sm`,onClick:_,loading:c,children:`New Revision`})]})]}),i?(0,I.jsx)(U,{align:`center`,py:`md`,children:(0,I.jsx)(uu,{})}):!n||n.items.length===0?(0,I.jsx)(V,{c:`dimmed`,children:`No revisions yet.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[u&&(0,I.jsx)(W.Th,{w:40}),(0,I.jsx)(W.Th,{children:`Rev`}),(0,I.jsx)(W.Th,{children:`Status`}),(0,I.jsx)(W.Th,{children:`Change Summary`}),(0,I.jsx)(W.Th,{children:`Created`}),!u&&(0,I.jsx)(W.Th,{children:`Actions`})]})}),(0,I.jsx)(W.Tbody,{children:n.items.map(t=>{let n=`/orders/${e}/revs/${t.revNo}`;return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},"data-testid":`revision-row-${t.revNo}`,children:[u&&(0,I.jsx)(W.Td,{children:(0,I.jsx)(yp,{checked:f.includes(t.revNo),onChange:()=>S(t.revNo)})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:(0,I.jsxs)(Ap,{color:`violet`,variant:`light`,children:[`REV `,t.revNo]})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:(0,I.jsx)(Ap,{color:KZ[t.status]??`gray`,variant:`light`,"data-testid":`revision-status-${t.revNo}`,children:t.status})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:t.changeSummary??`—`})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:new Date(t.createdAt).toLocaleString()})}),!u&&(0,I.jsx)(W.Td,{children:(0,I.jsxs)(B,{gap:`xs`,children:[Rj(t._actions,`approve`)&&(0,I.jsx)(H,{size:`xs`,variant:`light`,color:`green`,onClick:()=>y(t),"data-testid":`revision-approve-${t.revNo}`,children:`Approve`}),Rj(t._actions,`delete`)&&(0,I.jsx)(H,{size:`xs`,variant:`light`,color:`red`,onClick:()=>x(t),children:`Delete`}),Rj(t._actions,`cut-order`)&&(0,I.jsx)(H,{size:`xs`,variant:`light`,color:`teal`,component:zw,to:`/orders/${e}/runs/new?revNo=${t.revNo}`,"data-testid":`revision-cut-order-${t.revNo}`,children:`Cut Order`}),Rj(t._actions,`obsolete`)&&(0,I.jsx)(H,{size:`xs`,variant:`light`,color:`gray`,onClick:()=>b(t),children:`Mark Obsolete`})]})})]},t.id)})})]}),w>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:w,value:o,onChange:s})})]})]})},YZ=()=>{let{key:e}=bC(),t=hC(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(!1),c=(0,v.useCallback)(async()=>{if(e){a(!0);try{r(await q.get(J.order(e)))}catch(e){gM(e)}finally{a(!1)}}},[e]);return(0,v.useEffect)(()=>{c()},[c]),i?(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(U,{align:`center`,children:(0,I.jsx)(uu,{})})}):n?o?(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Edit Order`}),(0,I.jsx)(WZ,{initialData:{key:n.key,description:n.description,status:n.status,itemKey:n.itemKey},isEdit:!0,onSubmit:async n=>{e&&(await q.put(J.order(e),n),s(!1),n.key&&n.key!==e?t(`/orders/${n.key}`,{replace:!0}):await c())},onCancel:()=>s(!1)})]}):(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(zv,{order:2,children:n.key}),(0,I.jsx)(CZ,{createdBy:n.createdBy,createdAt:n.createdAt,updatedBy:n.updatedBy,updatedAt:n.updatedAt}),(0,I.jsx)(Ap,{color:n.status===JX.active?`green`:`gray`,variant:`light`,size:`lg`,children:n.status})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>t(`/orders`),children:`Back`}),(0,I.jsx)(H,{variant:`light`,component:zw,to:`/orders/${e}/runs`,children:`View Runs`}),Rj(n._actions,`update`)&&(0,I.jsx)(H,{onClick:()=>s(!0),children:`Edit`}),Rj(n._actions,`delete`)&&(0,I.jsx)(H,{color:`red`,variant:`outline`,onClick:async()=>{if(!(!e||!confirm(`Delete this order?`)))try{await q.delete(J.order(e)),t(`/orders`)}catch(e){gM(e)}},children:`Delete`})]})]}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,children:(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Produces Item:`}),n.itemKey?(0,I.jsx)(V,{component:zw,to:`/items/${n.itemKey}`,c:`blue`,style:{textDecoration:`none`},children:n.itemKey}):(0,I.jsx)(V,{children:`—`})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Description:`}),(0,I.jsx)(V,{children:n.description||`—`})]})]})}),(0,I.jsx)(JZ,{orderKey:e})]}):(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(V,{children:`Order not found.`})})},XZ=()=>{let e=hC(),[t,n]=qw(),r=Number(t.get(`page`))||1,i=t.get(`status`)||void 0,a=t.get(`search`)||``,[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!0),u=(0,v.useCallback)(async()=>{l(!0);try{let e=new URLSearchParams;e.set(`page`,String(r)),e.set(`pageSize`,`20`),i&&e.set(`status`,i),a&&e.set(`search`,a),s(await q.get(`${J.orders}?${e}`))}catch(e){gM(e)}finally{l(!1)}},[r,i,a]);(0,v.useEffect)(()=>{u()},[u]);let d=o?Math.ceil(o.total/o.pageSize):0;return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsx)(zv,{order:2,children:`Orders`}),o&&Rj(o._actions,`create`)&&(0,I.jsx)(H,{onClick:()=>e(`/orders/new`),children:`Create New`})]}),(0,I.jsxs)(B,{mb:`md`,children:[(0,I.jsx)(Mv,{placeholder:`Search...`,value:a,onChange:e=>{let t=e.currentTarget.value;n(e=>(t?e.set(`search`,t):e.delete(`search`),e.set(`page`,`1`),e))},style:{flex:1}}),(0,I.jsx)(R_,{placeholder:`All statuses`,data:qX.options.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),value:i??null,onChange:e=>{n(t=>(e?t.set(`status`,e):t.delete(`status`),t.set(`page`,`1`),t))},clearable:!0})]}),c?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):o&&o.items.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Key`}),(0,I.jsx)(W.Th,{children:`Status`}),(0,I.jsx)(W.Th,{children:`Created`})]})}),(0,I.jsx)(W.Tbody,{children:o.items.map(e=>{let t=`/orders/${e.key}`;return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:e.key})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(Ap,{color:e.status===JX.active?`green`:`gray`,variant:`light`,children:e.status})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:new Date(e.createdAt).toLocaleDateString()})})]},e.id)})})]}),d>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:d,value:r,onChange:e=>n(t=>(t.set(`page`,String(e)),t))})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`xl`,children:`No orders found.`})]})},ZZ=({items:e,loading:t,linkBuilder:n})=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{fw:600,children:`OPERATIONS`}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,children:t?(0,I.jsx)(U,{align:`center`,py:`sm`,children:(0,I.jsx)(uu,{size:`sm`})}):!e||e.length===0?(0,I.jsx)(V,{c:`dimmed`,size:`sm`,children:`No operations defined.`}):(0,I.jsxs)(W,{children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Seq`}),(0,I.jsx)(W.Th,{children:`Title`}),(0,I.jsx)(W.Th,{children:`Prerequisites`}),(0,I.jsx)(W.Th,{children:`Steps`}),(0,I.jsx)(W.Th,{children:`Cost`})]})}),(0,I.jsx)(W.Tbody,{children:e.map(e=>{let t=n(e.seqNo);return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.seqNo})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.title})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.predecessors&&e.predecessors.length>0?(0,I.jsx)(B,{gap:4,children:e.predecessors.map(e=>(0,I.jsxs)(Ap,{variant:`light`,size:`sm`,children:[e.seqNo,`. `,e.title]},e.seqNo))}):(0,I.jsx)(V,{c:`dimmed`,size:`sm`,children:`None`})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.stepCount??0})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:e.cost?`$${e.cost.toFixed(2)}`:`—`})})]},e.id)})})]})})]}),QZ=()=>{let{orderKey:e,revNo:t}=bC(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),u=rN({initialValues:{description:``,changeSummary:``},validate:oU(NX)}),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(!0),h=(0,v.useCallback)(async()=>{if(!(!e||!t)){a(!0);try{r(await q.get(J.orderRev(e,t)))}catch(e){gM(e)}finally{a(!1)}}},[e,t]),g=(0,v.useCallback)(async()=>{if(!(!e||!t)){m(!0);try{f(await q.get(J.orderRevOps(e,t)))}catch(e){gM(e)}finally{m(!1)}}},[e,t]);(0,v.useEffect)(()=>{h(),g()},[h,g]);let _=()=>{n&&(u.setValues({description:n.description||``,changeSummary:n.changeSummary||``}),s(!0))},y=async i=>{if(n){l(!0);try{r(await q.put(J.orderRev(e,t),i)),s(!1)}catch(e){gM(e)}finally{l(!1)}}};if(i)return(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})});if(!n)return(0,I.jsx)(U,{p:`md`,children:(0,I.jsx)(V,{children:`Revision not found.`})});let b=Rj(n._actions,`update`);return(0,I.jsx)(Qp,{size:`md`,py:`xl`,w:`100%`,children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsxs)(B,{justify:`space-between`,children:[(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(V,{fw:600,children:`HEADER`}),(0,I.jsx)(CZ,{createdBy:n.createdBy,createdAt:n.createdAt,updatedBy:n.updatedBy,updatedAt:n.updatedAt})]}),b&&!o&&(0,I.jsx)(H,{size:`xs`,variant:`light`,onClick:_,children:`Edit`})]}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,children:o?(0,I.jsx)(`form`,{onSubmit:u.onSubmit(y),children:(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsx)(Qm,{label:`Description`,placeholder:`Revision description...`,autosize:!0,minRows:3,...u.getInputProps(`description`)}),(0,I.jsx)(Qm,{label:`Change Summary`,placeholder:`What changed in this revision...`,autosize:!0,minRows:3,...u.getInputProps(`changeSummary`)}),(0,I.jsxs)(B,{justify:`flex-end`,mt:`xs`,children:[(0,I.jsx)(H,{variant:`subtle`,size:`xs`,onClick:()=>s(!1),children:`Cancel`}),(0,I.jsx)(H,{type:`submit`,size:`xs`,loading:c,children:`Save`})]})]})}):(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(V,{size:`sm`,fw:500,mb:4,children:`Produces Item`}),n.itemKey?(0,I.jsx)(V,{component:zw,to:`/items/${n.itemKey}`,size:`sm`,c:`blue`,style:{textDecoration:`none`},children:n.itemKey}):(0,I.jsx)(V,{c:`dimmed`,children:`None`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(V,{size:`sm`,fw:500,mb:4,children:`Description`}),n.description?(0,I.jsx)(nU,{children:n.description}):(0,I.jsx)(V,{c:`dimmed`,children:`No description`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(V,{size:`sm`,fw:500,mb:4,children:`Change Summary`}),n.changeSummary?(0,I.jsx)(nU,{children:n.changeSummary}):(0,I.jsx)(V,{c:`dimmed`,children:`No change summary`}),Number(t)>1&&(0,I.jsx)(V,{component:zw,to:`/orders/${e}/revs/diff?from=${Number(t)-1}&to=${t}`,size:`xs`,c:`blue`,mt:`xs`,style:{textDecoration:`none`,display:`inline-block`},children:`Diff with previous revision`})]})]})}),(0,I.jsx)(ZZ,{items:d?.items??null,loading:p,linkBuilder:n=>`/orders/${e}/revs/${t}/ops/${n}`})]})})},$Z=({value:e,onChange:t,...n})=>{let[r]=zt(e,300),[i,a]=(0,v.useState)([]),o=(0,v.useCallback)(async e=>{try{let t=new URLSearchParams;t.set(`pageSize`,`10`),e&&t.set(`search`,e),a((await q.get(`${J.workCenters}?${t}`)).items.map(e=>e.key))}catch{a([])}},[]);return(0,v.useEffect)(()=>{o(r)},[r,o]),(0,I.jsx)(Dp,{data:i,value:e,onChange:t,...n})},eQ=({orderKey:e,revNo:t,opSeqNo:n,showTitle:r=!0})=>{let[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(!0),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(n);n!==f&&(p(n),a(null),s(!0),l(!1));let m=rN({initialValues:{predecessorSeqNo:10},validate:oU(WX)}),h=(0,v.useCallback)(async()=>{s(!0);try{a(await q.get(J.orderRevOpDeps(e,t,n)))}catch(e){gM(e)}finally{s(!1)}},[e,t,n]);(0,v.useEffect)(()=>{h()},[h]);let g=async r=>{if(i){d(!0);try{let o=await q.post(J.orderRevOpDeps(e,t,n),r);l(!1),a({...i,items:[...i.items,o].sort((e,t)=>e.predecessorSeqNo-t.predecessorSeqNo),total:i.total+1})}catch(e){gM(e)}finally{d(!1)}}},_=async r=>{if(i)try{await q.delete(J.orderRevOpDep(e,t,n,r.predecessorSeqNo)),a({...i,items:i.items.filter(e=>e.id!==r.id),total:i.total-1})}catch(e){gM(e)}},y=!o&&i!==null&&i.items.length===0&&!c;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(B,{justify:`space-between`,children:[r&&!y&&(0,I.jsx)(zv,{order:5,children:`Dependencies`}),Rj(i?._actions,`create`)&&!c&&(0,I.jsx)(H,{size:`xs`,variant:`light`,onClick:()=>{m.reset(),l(!0)},children:`Add Dependency`})]}),o?(0,I.jsx)(U,{align:`center`,py:`sm`,children:(0,I.jsx)(uu,{size:`sm`})}):(0,I.jsxs)(U,{gap:`xs`,children:[i?.items.map(e=>(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsxs)(Ap,{variant:`light`,size:`lg`,children:[e.predecessorSeqNo,`. `,e.predecessorTitle]}),zj(i?._actionTemplates,`deleteDependency`)&&(0,I.jsx)(H,{size:`compact-xs`,color:`red`,variant:`subtle`,onClick:()=>_(e),children:`Remove`})]},e.id)),c&&(0,I.jsx)(`form`,{onSubmit:m.onSubmit(g),children:(0,I.jsxs)(B,{gap:`sm`,children:[(0,I.jsx)(Vg,{placeholder:`Predecessor op #`,min:1,step:10,size:`xs`,style:{width:160},...m.getInputProps(`predecessorSeqNo`)}),(0,I.jsx)(H,{type:`submit`,size:`xs`,loading:u,children:`Add`}),(0,I.jsx)(H,{variant:`subtle`,size:`xs`,onClick:()=>l(!1),children:`Cancel`})]})})]})]})},tQ=({orderKey:e,revNo:t,opSeqNo:n})=>{let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!0),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)([]),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(n);n!==b&&(x(n),i(null),o(!0));let S=(0,v.useCallback)(async()=>{o(!0);try{i(await q.get(J.orderRevOpFieldRefs(e,t,n)))}catch(e){gM(e)}finally{o(!1)}},[e,t,n]);(0,v.useEffect)(()=>{S()},[S]);let C=async()=>{c(!0),g(null),m(``),f(!0);try{u((await q.get(J.orderRevOpFieldRefAvailable(e,t,n))).items)}catch(e){gM(e)}finally{f(!1)}},w=async()=>{if(!(!h||!p.trim())){y(!0);try{let r=await q.post(J.orderRevOpFieldRefs(e,t,n),{title:p.trim(),sourceOpSeqNo:h.opSeqNo,sourceStepSeqNo:h.stepSeqNo});c(!1),i(e=>e&&{...e,items:[...e.items,r].sort((e,t)=>e.seqNo-t.seqNo),total:e.total+1})}catch(e){gM(e)}finally{y(!1)}}},T=async a=>{if(r)try{await q.delete(J.orderRevOpFieldRef(e,t,n,a.seqNo)),i({...r,items:r.items.filter(e=>e.id!==a.id),total:r.total-1})}catch(e){gM(e)}};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(B,{justify:`space-between`,children:[!(!a&&r!==null&&r.items.length===0)&&(0,I.jsx)(zv,{order:5,children:`Referenced Fields`}),Rj(r?._actions,`create`)&&(0,I.jsx)(H,{size:`xs`,variant:`light`,onClick:C,children:`Add Reference`})]}),a?(0,I.jsx)(U,{align:`center`,py:`sm`,children:(0,I.jsx)(uu,{size:`sm`})}):(0,I.jsx)(U,{gap:`xs`,children:r?.items.map(n=>(0,I.jsxs)(Wp,{withBorder:!0,p:`sm`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:n.fields.length>0?`xs`:void 0,children:[(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(V,{size:`sm`,fw:500,children:n.title}),(0,I.jsxs)(Wd,{component:zw,to:`/orders/${e}/revs/${t}/ops/${n.sourceOpSeqNo}`,size:`xs`,c:`dimmed`,children:[`Op `,n.sourceOpSeqNo,` / Step `,n.sourceStepSeqNo]})]}),Rj(n._actions,`delete`)&&(0,I.jsx)(H,{size:`compact-xs`,color:`red`,variant:`subtle`,onClick:()=>T(n),children:`Remove`})]}),n.fields.length>0&&(0,I.jsx)(W,{withRowBorders:!1,children:(0,I.jsx)(W.Tbody,{children:n.fields.map(e=>(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Td,{w:40,children:(0,I.jsx)(V,{size:`xs`,c:`dimmed`,children:e.seqNo})}),(0,I.jsx)(W.Td,{children:(0,I.jsx)(V,{size:`xs`,children:e.label})}),(0,I.jsx)(W.Td,{w:100,children:(0,I.jsx)(Ap,{variant:`light`,size:`xs`,children:e.type})})]},e.seqNo))})})]},n.id))}),(0,I.jsx)(Nh,{opened:s,onClose:()=>c(!1),title:`Add Field Reference`,size:`md`,children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsx)(Mv,{label:`Reference Title`,placeholder:`e.g. Dimensions from Inspection`,value:p,onChange:e=>m(e.currentTarget.value),"data-autofocus":!0}),(0,I.jsx)(V,{size:`sm`,fw:500,children:`Select a step with fields:`}),d?(0,I.jsx)(U,{align:`center`,py:`sm`,children:(0,I.jsx)(uu,{size:`sm`})}):l.length===0?(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`No steps with fields available to reference.`}):(0,I.jsx)(U,{gap:`xs`,children:l.map(e=>(0,I.jsx)(gl,{onClick:()=>{g(e),p.trim()||m(`${e.opTitle} - ${e.stepTitle}`)},style:t=>({padding:t.spacing.xs,borderRadius:t.radius.sm,border:`1px solid ${h?.stepId===e.stepId?t.colors.blue[5]:t.colors.gray[3]}`,backgroundColor:h?.stepId===e.stepId?t.colors.blue[0]:void 0}),children:(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsxs)(Ap,{variant:`light`,size:`sm`,children:[`Op `,e.opSeqNo,` / Step `,e.stepSeqNo]}),(0,I.jsxs)(V,{size:`sm`,children:[e.opTitle,` - `,e.stepTitle]}),(0,I.jsxs)(V,{size:`xs`,c:`dimmed`,children:[`(`,e.fieldCount,` field`,e.fieldCount===1?``:`s`,`)`]})]})},e.stepId))}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>c(!1),children:`Cancel`}),(0,I.jsx)(H,{onClick:()=>void w(),loading:_,disabled:!h||!p.trim(),children:`Add Reference`})]})]})})]})},nQ=({orderKey:e,revNo:t,opSeqNo:n})=>{let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!0),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(n);n!==p&&(m(n),i(null),o(!0),c(null),u(!1));let h=rN({initialValues:{seqNo:10,title:``,instructions:``,multiSet:!1},validate:oU(oZ)}),g=rN({initialValues:{seqNo:10,title:``,instructions:``,multiSet:!1},validate:oU(aZ)}),_=(0,v.useCallback)(async()=>{o(!0);try{i(await q.get(J.orderRevOpSteps(e,t,n)))}catch(e){gM(e)}finally{o(!1)}},[e,t,n]);(0,v.useEffect)(()=>{_()},[_]);let y=e=>{h.setValues({seqNo:e.seqNo,title:e.title,instructions:e.instructions,multiSet:e.multiSet}),c(e.id),u(!1)},b=async a=>{let o=r?.items.find(e=>e.id===s);if(!(!o||!r)){f(!0);try{let s=await q.put(J.orderRevOpStep(e,t,n,o.seqNo),a);c(null),i({...r,items:r.items.map(e=>e.id===s.id?s:e).sort((e,t)=>e.seqNo-t.seqNo)})}catch(e){gM(e)}finally{f(!1)}}},x=async a=>{if(!(!r||!confirm(`Delete step ${a.seqNo}?`)))try{await q.delete(J.orderRevOpStep(e,t,n,a.seqNo)),i({...r,items:r.items.filter(e=>e.id!==a.id),total:r.total-1})}catch(e){gM(e)}};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(B,{justify:`space-between`,children:[(0,I.jsx)(zv,{order:5,children:`Steps`}),Rj(r?._actions,`create`)&&!l&&(0,I.jsx)(H,{size:`xs`,variant:`light`,onClick:()=>{g.setValues({seqNo:r?.nextSeqNo??10,title:``,instructions:``}),u(!0),c(null)},children:`Add Step`})]}),a?(0,I.jsx)(U,{align:`center`,py:`sm`,children:(0,I.jsx)(uu,{size:`sm`})}):(0,I.jsxs)(U,{gap:`xs`,children:[r?.items.map(r=>(0,I.jsxs)(Wp,{withBorder:!0,p:`sm`,children:[s===r.id?(0,I.jsx)(`form`,{onSubmit:h.onSubmit(b),children:(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsx)(Vg,{label:`Sequence #`,min:1,step:10,...h.getInputProps(`seqNo`)}),(0,I.jsx)(Mv,{label:`Title`,placeholder:`Short step name`,...h.getInputProps(`title`)}),(0,I.jsx)(Qm,{label:`Instructions (markdown)`,placeholder:`Step instructions...`,autosize:!0,minRows:3,...h.getInputProps(`instructions`)}),(0,I.jsx)(yp,{label:`Allow multiple field value sets`,...h.getInputProps(`multiSet`,{type:`checkbox`})}),(0,I.jsxs)(B,{justify:`flex-end`,mt:`xs`,children:[(0,I.jsx)(H,{variant:`subtle`,size:`xs`,onClick:()=>c(null),children:`Cancel`}),(0,I.jsx)(H,{type:`submit`,size:`xs`,loading:d,children:`Save`})]})]})}):(0,I.jsxs)(B,{justify:`space-between`,align:`flex-start`,wrap:`nowrap`,children:[(0,I.jsxs)(U,{gap:4,style:{flex:1,minWidth:0},children:[(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsxs)(V,{fw:600,size:`sm`,children:[`STEP `,r.seqNo,r.title?`: ${r.title}`:``]}),r.multiSet&&(0,I.jsx)(Ap,{size:`xs`,variant:`light`,color:`violet`,children:`multi-set`})]}),r.instructions?(0,I.jsx)(nU,{children:r.instructions}):(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`No instructions`})]}),(0,I.jsxs)(B,{gap:`xs`,wrap:`nowrap`,children:[(0,I.jsx)(CZ,{createdBy:r.createdBy,createdAt:r.createdAt,updatedBy:r.updatedBy,updatedAt:r.updatedAt}),Rj(r._actions,`update`)&&(0,I.jsx)(H,{size:`xs`,variant:`light`,onClick:()=>y(r),children:`Edit`}),Rj(r._actions,`delete`)&&(0,I.jsx)(H,{size:`xs`,color:`red`,variant:`outline`,onClick:()=>x(r),children:`Delete`})]})]}),(0,I.jsx)(EZ,{fieldsEndpoint:J.orderRevOpStepFields(e,t,n,r.seqNo),fieldEndpoint:i=>J.orderRevOpStepField(e,t,n,r.seqNo,i),initialData:r.fields})]},r.id)),r&&r.items.length===0&&!l&&(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`No steps yet.`}),l&&(0,I.jsx)(Wp,{withBorder:!0,p:`sm`,children:(0,I.jsx)(`form`,{onSubmit:g.onSubmit(async a=>{if(r){f(!0);try{let o=await q.post(J.orderRevOpSteps(e,t,n),a);u(!1),i({...r,items:[...r.items,o].sort((e,t)=>e.seqNo-t.seqNo),total:r.total+1,nextSeqNo:o.seqNo+10})}catch(e){gM(e)}finally{f(!1)}}}),children:(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsx)(Vg,{label:`Sequence #`,min:1,step:10,...g.getInputProps(`seqNo`)}),(0,I.jsx)(Mv,{label:`Title`,placeholder:`Short step name`,...g.getInputProps(`title`)}),(0,I.jsx)(Qm,{label:`Instructions (markdown)`,placeholder:`Step instructions...`,autosize:!0,minRows:3,...g.getInputProps(`instructions`)}),(0,I.jsx)(yp,{label:`Allow multiple field value sets`,...g.getInputProps(`multiSet`,{type:`checkbox`})}),(0,I.jsxs)(B,{justify:`flex-end`,mt:`xs`,children:[(0,I.jsx)(H,{variant:`subtle`,size:`xs`,onClick:()=>u(!1),children:`Cancel`}),(0,I.jsx)(H,{type:`submit`,size:`xs`,loading:d,children:`Add`})]})]})})})]})]})},rQ=()=>{let{orderKey:e,revNo:t,seqNo:n}=bC(),r=hC(),{onOperationUpdate:i}=vC(),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!0),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(!1),p=rN({initialValues:{title:``,description:``,workCenterKey:``,seqNo:10},validate:oU(wX)}),m=(0,v.useCallback)(async()=>{if(!(!e||!t||!n)){c(!0);try{o(await q.get(J.orderRevOp(e,t,n)))}catch(e){gM(e)}finally{c(!1)}}},[e,t,n]);(0,v.useEffect)(()=>{m()},[m]);let h=()=>{a&&(p.setValues({title:a.title,description:a.description,workCenterKey:a.workCenterKey??``,seqNo:a.seqNo}),u(!0))},g=async n=>{if(a){f(!0);try{let s={...n,workCenterKey:n.workCenterKey||null},c=await q.put(J.orderRevOp(e,t,a.seqNo),s);o(c),u(!1),i(),n.seqNo&&n.seqNo!==a.seqNo&&r(`/orders/${e}/revs/${t}/ops/${c.seqNo}`,{replace:!0})}catch(e){gM(e)}finally{f(!1)}}},_=async()=>{if(!(!a||!confirm(`Delete operation "${a.title}"?`)))try{await q.delete(J.orderRevOp(e,t,a.seqNo)),r(`/orders/${e}/revs/${t}`)}catch(e){gM(e)}};if(s)return(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})});if(!a)return(0,I.jsx)(U,{p:`md`,children:(0,I.jsx)(V,{children:`Operation not found.`})});let y=Rj(a._actions,`update`);return(0,I.jsx)(Qp,{size:`md`,py:`xl`,w:`100%`,children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsxs)(B,{justify:`space-between`,children:[(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsxs)(V,{fw:600,children:[`OPERATION `,a.seqNo,`: `,a.title]}),a.workCenterKey&&(0,I.jsxs)(V,{size:`sm`,c:`dimmed`,children:[`[`,a.workCenterKey,`]`]}),(0,I.jsx)(CZ,{createdBy:a.createdBy,createdAt:a.createdAt,updatedBy:a.updatedBy,updatedAt:a.updatedAt})]}),(0,I.jsxs)(B,{gap:`xs`,children:[y&&!l&&(0,I.jsx)(H,{size:`xs`,variant:`light`,onClick:h,children:`Edit`}),Rj(a._actions,`delete`)&&(0,I.jsx)(H,{size:`xs`,color:`red`,variant:`outline`,onClick:_,children:`Delete`})]})]}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,children:l?(0,I.jsx)(`form`,{onSubmit:p.onSubmit(g),children:(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsx)(Mv,{label:`Title`,placeholder:`Operation title...`,...p.getInputProps(`title`)}),(0,I.jsx)(Vg,{label:`Sequence #`,min:1,step:10,...p.getInputProps(`seqNo`)}),(0,I.jsx)($Z,{label:`Work Center`,placeholder:`Search work centers...`,value:p.values.workCenterKey??``,onChange:e=>p.setFieldValue(`workCenterKey`,e)}),(0,I.jsx)(Qm,{label:`Description`,placeholder:`Operation description...`,autosize:!0,minRows:3,...p.getInputProps(`description`)}),(0,I.jsxs)(B,{justify:`flex-end`,mt:`xs`,children:[(0,I.jsx)(H,{variant:`subtle`,size:`xs`,onClick:()=>u(!1),children:`Cancel`}),(0,I.jsx)(H,{type:`submit`,size:`xs`,loading:d,children:`Save`})]})]})}):a.description?(0,I.jsx)(nU,{children:a.description}):(0,I.jsx)(V,{c:`dimmed`,children:`No description`})}),(0,I.jsx)(eQ,{orderKey:e,revNo:t,opSeqNo:n}),(0,I.jsx)(tQ,{orderKey:e,revNo:t,opSeqNo:n}),(0,I.jsx)(nQ,{orderKey:e,revNo:t,opSeqNo:n})]})})},iQ={added:`green`,removed:`red`,modified:`yellow`,unchanged:`gray`},aQ=({changes:e})=>(0,I.jsxs)(W,{withTableBorder:!0,withColumnBorders:!0,fz:`sm`,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Property`}),(0,I.jsx)(W.Th,{children:`From`}),(0,I.jsx)(W.Th,{children:`To`})]})}),(0,I.jsx)(W.Tbody,{children:e.map(e=>(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Td,{fw:600,children:e.field}),(0,I.jsx)(W.Td,{c:`red`,children:String(e.from??`—`)}),(0,I.jsx)(W.Td,{c:`green`,children:String(e.to??`—`)})]},e.field))})]}),oQ=({fields:e})=>{let t=e.filter(e=>e.status!==`unchanged`);return t.length===0?null:(0,I.jsxs)(U,{gap:`xs`,ml:`md`,children:[(0,I.jsx)(V,{fz:`sm`,fw:600,children:`Fields`}),t.map(e=>(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(Ap,{size:`xs`,color:iQ[e.status],children:e.status}),(0,I.jsxs)(V,{fz:`sm`,children:[`#`,e.seqNo,` `,e.label]}),e.changes&&e.changes.length>0&&(0,I.jsxs)(V,{fz:`xs`,c:`dimmed`,children:[`(`,e.changes.map(e=>e.field).join(`, `),`)`]})]},e.seqNo))]})},sQ=({steps:e})=>{let t=e.filter(e=>e.status!==`unchanged`);return t.length===0?null:(0,I.jsxs)(U,{gap:`xs`,ml:`md`,children:[(0,I.jsx)(V,{fz:`sm`,fw:600,children:`Steps`}),t.map(e=>(0,I.jsxs)(Wp,{withBorder:!0,p:`xs`,children:[(0,I.jsxs)(B,{gap:`xs`,mb:e.changes||e.fields?`xs`:0,children:[(0,I.jsx)(Ap,{size:`xs`,color:iQ[e.status],children:e.status}),(0,I.jsxs)(V,{fz:`sm`,children:[`Step #`,e.seqNo,` `,e.title||`(untitled)`]})]}),e.changes&&e.changes.length>0&&(0,I.jsx)(aQ,{changes:e.changes}),e.fields&&(0,I.jsx)(oQ,{fields:e.fields})]},e.seqNo))]})},cQ=({deps:e})=>{let t=e.filter(e=>e.status!==`unchanged`);return t.length===0?null:(0,I.jsxs)(U,{gap:`xs`,ml:`md`,children:[(0,I.jsx)(V,{fz:`sm`,fw:600,children:`Dependencies`}),t.map(e=>(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(Ap,{size:`xs`,color:iQ[e.status],children:e.status}),(0,I.jsxs)(V,{fz:`sm`,children:[`Predecessor: #`,e.predecessorSeqNo,` `,e.predecessorTitle]})]},e.predecessorSeqNo))]})},lQ=({op:e})=>(0,I.jsxs)(Pd.Item,{value:`op-${e.seqNo}`,children:[(0,I.jsx)(Pd.Control,{children:(0,I.jsxs)(B,{gap:`sm`,children:[(0,I.jsx)(Ap,{color:iQ[e.status],children:e.status}),(0,I.jsxs)(V,{fw:600,children:[`OP `,e.seqNo,`: `,e.title]})]})}),(0,I.jsx)(Pd.Panel,{children:(0,I.jsxs)(U,{gap:`sm`,children:[e.changes&&e.changes.length>0&&(0,I.jsx)(aQ,{changes:e.changes}),e.steps&&(0,I.jsx)(sQ,{steps:e.steps}),e.dependencies&&(0,I.jsx)(cQ,{deps:e.dependencies}),!e.changes&&!e.steps&&!e.dependencies&&(0,I.jsx)(V,{fz:`sm`,c:`dimmed`,children:e.status===`added`?`New operation`:e.status===`removed`?`Operation removed`:`No changes`})]})})]}),uQ=()=>{let{orderKey:e}=bC(),[t]=qw(),n=hC(),r=t.get(`from`),i=t.get(`to`),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!0),l=(0,v.useCallback)(async()=>{if(!(!e||!r||!i)){c(!0);try{o(await q.get(J.orderRevDiff(e,r,i)))}catch(e){gM(e)}finally{c(!1)}}},[e,r,i]);(0,v.useEffect)(()=>{l()},[l]);let u=a?a.operations.filter(e=>e.status!==`unchanged`):[],d=a?a.operations.length-u.length:0;return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsxs)(zv,{order:2,children:[`Compare Revisions: Rev `,r,` → Rev `,i]}),(0,I.jsx)(H,{variant:`subtle`,onClick:()=>n(`/orders/${e}`),children:`Back to Order`})]}),s?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):a?(0,I.jsxs)(U,{gap:`md`,children:[a.revisionChanges.length>0&&(0,I.jsxs)(Wp,{withBorder:!0,p:`lg`,children:[(0,I.jsx)(zv,{order:4,mb:`sm`,children:`Revision Properties`}),(0,I.jsx)(aQ,{changes:a.revisionChanges})]}),(0,I.jsxs)(Wp,{withBorder:!0,p:`lg`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`sm`,children:[(0,I.jsx)(zv,{order:4,children:`Operations`}),d>0&&(0,I.jsxs)(V,{fz:`sm`,c:`dimmed`,children:[d,` unchanged operation`,d===1?``:`s`,` hidden`]})]}),u.length===0&&a.revisionChanges.length===0?(0,I.jsx)(V,{c:`dimmed`,children:`No differences found between revisions.`}):u.length===0?(0,I.jsx)(V,{c:`dimmed`,children:`No operation changes.`}):(0,I.jsx)(Pd,{variant:`separated`,multiple:!0,children:u.map(e=>(0,I.jsx)(lQ,{op:e},e.seqNo))})]})]}):(0,I.jsx)(V,{children:`Could not load diff.`})]})},dQ=({orderKey:e,revNo:t,refreshKey:n})=>{let r=hC(),i=fC(),{seqNo:a}=bC(),o=i.pathname.endsWith(`/header`),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(!1),h=rN({initialValues:{seqNo:10,title:``,description:``},validate:oU(CX)}),g=(0,v.useCallback)(async()=>{u(!0);try{c(await q.get(J.orderRevOps(e,t)))}catch(e){gM(e)}finally{u(!1)}},[e,t]);return(0,v.useEffect)(()=>{g()},[g,n]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(U,{gap:`xs`,children:[(0,I.jsx)(Wp,{padding:`sm`,radius:`md`,withBorder:!0,component:`a`,href:`/erp/orders/${e}/revs/${t}/header`,onClick:n=>{n.button===1||n.ctrlKey||n.metaKey||(n.preventDefault(),r(`/orders/${e}/revs/${t}/header`))},style:{cursor:`pointer`,textDecoration:`none`,color:`inherit`,backgroundColor:o?`var(--mantine-color-blue-9)`:void 0},children:(0,I.jsx)(V,{size:`sm`,fw:500,children:`Header`})}),l?(0,I.jsx)(U,{align:`center`,py:`md`,children:(0,I.jsx)(uu,{size:`sm`})}):!s||s.items.length===0?(0,I.jsx)(V,{c:`dimmed`,size:`sm`,ta:`center`,py:`md`,children:`No operations yet.`}):s.items.map(n=>{let i=`/orders/${e}/revs/${t}/ops/${n.seqNo}`;return(0,I.jsx)(Wp,{padding:`sm`,radius:`md`,withBorder:!0,component:`a`,href:`/erp${i}`,onClick:e=>{e.button===1||e.ctrlKey||e.metaKey||(e.preventDefault(),r(i))},style:{cursor:`pointer`,textDecoration:`none`,color:`inherit`,backgroundColor:a===String(n.seqNo)?`var(--mantine-color-blue-9)`:void 0},children:(0,I.jsxs)(V,{size:`sm`,fw:500,children:[n.seqNo,`. `,n.title]})},n.id)}),Rj(s?._actions,`create`)&&(0,I.jsx)(H,{variant:`subtle`,color:`gray`,size:`compact-sm`,leftSection:(0,I.jsx)(lM,{size:`0.9rem`}),onClick:()=>{h.setFieldValue(`seqNo`,s?.nextSeqNo??10),f(!0)},fullWidth:!0,mt:`xs`,children:`Add Operation`})]}),(0,I.jsx)(Nh,{opened:d,onClose:()=>{f(!1),h.reset()},title:`Add Operation`,children:(0,I.jsx)(`form`,{onSubmit:h.onSubmit(async n=>{m(!0);try{let i=await q.post(J.orderRevOps(e,t),{seqNo:n.seqNo,title:n.title,description:n.description||void 0});f(!1),h.reset(),await g(),r(`/orders/${e}/revs/${t}/ops/${i.seqNo}`)}catch(e){gM(e)}finally{m(!1)}}),children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsx)(Vg,{label:`Sequence #`,min:1,step:10,...h.getInputProps(`seqNo`)}),(0,I.jsx)(Mv,{label:`Title`,placeholder:`Operation title...`,...h.getInputProps(`title`)}),(0,I.jsx)(Qm,{label:`Description`,placeholder:`Optional description...`,...h.getInputProps(`description`),autosize:!0,minRows:2}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>{f(!1),h.reset()},children:`Cancel`}),(0,I.jsx)(H,{type:`submit`,loading:p,children:`Create`})]})]})})})]})},fQ={[jX.draft]:`blue`,[jX.approved]:`green`,[jX.obsolete]:`gray`},pQ=({revision:e,orderKey:t,revNo:n,onRefresh:r,onOpenOperations:i})=>{let a=hC();return(0,I.jsxs)(B,{justify:`space-between`,px:`md`,py:`xs`,style:{borderBottom:`calc(0.125rem * var(--mantine-scale)) solid var(--mantine-color-dark-4)`},children:[(0,I.jsxs)(B,{gap:`sm`,children:[i&&(0,I.jsx)(vu,{variant:`subtle`,color:`gray`,hiddenFrom:`md`,onClick:i,children:(0,I.jsx)(oM,{size:`1.2rem`})}),(0,I.jsxs)(V,{size:`lg`,children:[`ORDER:`,` `,(0,I.jsx)(Wd,{href:`/erp/orders/${t}`,onClick:e=>{e.button===1||e.ctrlKey||e.metaKey||(e.preventDefault(),a(`/orders/${t}`))},children:t})]}),(0,I.jsxs)(Ap,{color:`violet`,variant:`light`,size:`sm`,children:[`REV `,e.revNo]}),(0,I.jsx)(Ap,{color:fQ[e.status]??`gray`,variant:`light`,size:`sm`,children:e.status}),e.description&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`|`}),(0,I.jsx)(V,{size:`sm`,c:`dimmed`,lineClamp:1,maw:300,children:e.description})]})]}),(0,I.jsxs)(B,{gap:`xs`,children:[Rj(e._actions,`approve`)&&(0,I.jsx)(H,{size:`xs`,color:`green`,onClick:async()=>{if(confirm(`Approve revision #${n}?`))try{await q.post(J.orderRevApprove(t,n),{}),r()}catch(e){gM(e)}},children:`Approve`}),(0,I.jsx)(iN,{actions:e._actions,rel:`cut-order`,size:`xs`,color:`teal`,onClick:()=>a(`/orders/${t}/runs/new?revNo=${e.revNo}`),children:`Cut Order`}),(0,I.jsx)(iN,{actions:e._actions,rel:`obsolete`,size:`xs`,color:`gray`,variant:`outline`,onClick:async()=>{if(confirm(`Mark revision #${n} as obsolete?`))try{await q.post(J.orderRevObsolete(t,n),{}),r()}catch(e){gM(e)}},children:`Obsolete`}),Rj(e._actions,`delete`)&&(0,I.jsx)(H,{size:`xs`,color:`red`,variant:`outline`,onClick:async()=>{if(confirm(`Delete revision #${n}?`))try{await q.delete(J.orderRev(t,n)),a(`/orders/${t}`)}catch(e){gM(e)}},children:`Delete`})]})]})},mQ=260,hQ=()=>{let{orderKey:e,revNo:t}=bC(),n=fC(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!0),[s,{toggle:c}]=_n(),[l,{open:u,close:d}]=_n(),[f,p]=(0,v.useState)(0),m={onOperationUpdate:()=>p(e=>e+1)},h=(0,v.useCallback)(async()=>{if(!(!e||!t)){o(!0);try{i(await q.get(J.orderRev(e,t)))}catch(e){gM(e)}finally{o(!1)}}},[e,t]);return(0,v.useEffect)(()=>{h()},[h]),(0,v.useEffect)(()=>{d()},[n.pathname]),a?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):!r||!e||!t?(0,I.jsx)(R,{p:`md`,children:(0,I.jsx)(V,{children:`Revision not found.`})}):(0,I.jsxs)(R,{display:`flex`,style:{flexDirection:`column`,height:`calc(100dvh - var(--app-shell-header-height, 0px))`},children:[(0,I.jsx)(pQ,{revision:r,orderKey:e,revNo:t,onRefresh:h,onOpenOperations:u}),(0,I.jsxs)(R,{display:`flex`,style:{flex:1,minHeight:0},children:[(0,I.jsx)(R,{visibleFrom:`md`,style:{flexShrink:0,display:`flex`,flexDirection:`column`},children:s?(0,I.jsx)(R,{style:{borderRight:`1px solid var(--mantine-color-dark-4)`,paddingRight:4},children:(0,I.jsx)(M_,{label:`Expand sidebar`,position:`right`,children:(0,I.jsx)(vu,{variant:`subtle`,color:`gray`,onClick:c,children:(0,I.jsx)(aM,{size:`1.2rem`})})})}):(0,I.jsxs)(R,{style:{width:mQ,minWidth:mQ,borderRight:`1px solid var(--mantine-color-dark-4)`,display:`flex`,flexDirection:`column`,overflowY:`auto`,padding:`0 var(--mantine-spacing-md)`},children:[(0,I.jsx)(B,{justify:`flex-end`,p:4,children:(0,I.jsx)(M_,{label:`Collapse sidebar`,position:`right`,children:(0,I.jsx)(vu,{variant:`subtle`,color:`gray`,size:`sm`,onClick:c,children:(0,I.jsx)(iM,{size:`1rem`})})})}),(0,I.jsx)(dQ,{orderKey:e,revNo:t,refreshKey:f})]})}),(0,I.jsx)(`div`,{style:{flex:1,minHeight:0,overflowY:`auto`,display:`flex`,flexDirection:`column`},children:(0,I.jsx)(GC,{context:m})})]}),(0,I.jsx)(Cm,{opened:l,onClose:d,title:`Operations`,size:mQ,children:(0,I.jsx)(dQ,{orderKey:e,revNo:t,refreshKey:f})})]})};function gQ(){return new Date().toISOString().slice(0,10)}function _Q(e,t){let n={priority:e.priority||void 0,dueAt:e.dueAt||void 0,releaseNote:e.releaseNote||void 0};return t?(e.dueAt||(n.dueAt=null),e.releaseNote||(n.releaseNote=null)):n.revNo=typeof e.revNo==`number`?e.revNo:void 0,n}var vQ=({initialData:e,isEdit:t,onSubmit:n,onCancel:r})=>{let i=t?VX:BX,a=rN({initialValues:{revNo:e?.revNo??``,priority:e?.priority??RX.medium,dueAt:e?.dueAt??(t?``:gQ()),releaseNote:e?.releaseNote??``},validate:e=>oU(i)(_Q(e,t))}),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null);return(0,I.jsx)(`form`,{onSubmit:a.onSubmit(async e=>{s(!0),l(null);try{let r=_Q(e,t);await n(i.parse(r))}catch(e){l(e instanceof Error?e.message:`An error occurred`)}finally{s(!1)}}),children:(0,I.jsxs)(U,{gap:`md`,children:[!t&&(0,I.jsx)(Vg,{label:`Rev No`,placeholder:`Latest approved`,min:1,...a.getInputProps(`revNo`)}),(0,I.jsx)(R_,{label:`Priority`,data:LX.options.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),...a.getInputProps(`priority`)}),(0,I.jsx)(Mv,{label:`Due Date`,type:`date`,...a.getInputProps(`dueAt`)}),(0,I.jsx)(Qm,{label:`Release Note`,placeholder:`Additional notes...`,...a.getInputProps(`releaseNote`),autosize:!0,minRows:3}),c&&(0,I.jsx)(`div`,{style:{color:`var(--mantine-color-red-6)`},children:c}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{type:`submit`,loading:o,children:t?`Save Changes`:`Create`}),(0,I.jsx)(H,{variant:`subtle`,onClick:r,children:`Cancel`})]})]})})},yQ={[RX.low]:`gray`,[RX.medium]:`blue`,[RX.high]:`orange`,[RX.critical]:`red`},bQ=()=>{let{orderKey:e,runNo:t}=bC(),{orderRun:n,onOrderRunUpdate:r}=vC(),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!0),f=(0,v.useCallback)(async()=>{if(e)try{s((await q.get(J.orderRev(e,n.revNo))).description||null)}catch{}},[e,n.revNo]),p=(0,v.useCallback)(async()=>{if(!(!e||!t)){d(!0);try{l(await q.get(J.operationRuns(e,t)))}catch(e){gM(e)}finally{d(!1)}}},[e,t]);(0,v.useEffect)(()=>{f(),p()},[f,p]);let m=async n=>{try{r(await q.put(J.orderRun(e,t),n)),a(!1)}catch(e){gM(e)}},h=Rj(n._actions,`update`);return(0,I.jsx)(Qp,{size:`md`,py:`xl`,w:`100%`,children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsxs)(B,{justify:`space-between`,children:[(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(V,{fw:600,children:`HEADER`}),(0,I.jsx)(CZ,{createdBy:n.createdBy,createdAt:n.createdAt,updatedBy:n.updatedBy,updatedAt:n.updatedAt})]}),h&&!i&&(0,I.jsx)(H,{size:`xs`,variant:`light`,onClick:()=>a(!0),children:`Edit`})]}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,children:i?(0,I.jsx)(vQ,{initialData:{priority:n.priority,dueAt:n.dueAt??``,releaseNote:n.releaseNote??``},isEdit:!0,onSubmit:m,onCancel:()=>a(!1)}):(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:140,children:`Produces Item:`}),n.itemKey?(0,I.jsx)(V,{component:zw,to:`/items/${n.itemKey}`,size:`sm`,c:`blue`,style:{textDecoration:`none`},children:n.itemKey}):(0,I.jsx)(V,{c:`dimmed`,children:`—`})]}),(0,I.jsxs)(B,{align:`flex-start`,children:[(0,I.jsx)(V,{fw:600,w:140,children:`Description:`}),o?(0,I.jsx)(nU,{children:o}):(0,I.jsx)(V,{c:`dimmed`,children:`—`})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:140,children:`Priority:`}),(0,I.jsx)(Ap,{color:yQ[n.priority]??`gray`,variant:`light`,children:n.priority})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:140,children:`Due Date:`}),(0,I.jsx)(V,{children:n.dueAt??`—`})]}),(0,I.jsxs)(B,{align:`flex-start`,children:[(0,I.jsx)(V,{fw:600,w:140,children:`Release Note:`}),(0,I.jsx)(V,{style:{whiteSpace:`pre-wrap`},children:n.releaseNote??`—`})]})]})}),(0,I.jsx)(ZZ,{items:c?.items??null,loading:u,linkBuilder:n=>`/orders/${e}/runs/${t}/ops/${n}`})]})})},xQ={note:`blue`,issue:`red`,feedback:`green`},SQ=({orderKey:e,runNo:t,seqNo:n,refreshKey:r,onCountChange:i})=>{let[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!0),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(`note`),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(n);n!==h&&(g(n),o(null),c(!0));let _=(0,v.useCallback)(async()=>{c(!0);try{let r=await q.get(J.operationRunComments(e,t,n));o(r),i?.(r.total)}catch(e){gM(e)}finally{c(!1)}},[e,t,n,r]);(0,v.useEffect)(()=>{_()},[_]);let y=async()=>{if(l.trim()){m(!0);try{let r=await q.post(J.operationRunComments(e,t,n),{type:d,body:l.trim()});o(e=>e&&{...e,items:[...e.items,r],total:e.total+1}),i?.((a?.total??0)+1),u(``)}catch(e){gM(e)}finally{m(!1)}}},b=a?._actions&&Rj(a._actions,`create`);return s?(0,I.jsx)(U,{align:`center`,py:`sm`,children:(0,I.jsx)(uu,{size:`sm`})}):(0,I.jsxs)(U,{gap:`xs`,children:[a?.items.map(e=>(0,I.jsxs)(Wp,{withBorder:!0,p:`sm`,children:[(0,I.jsxs)(B,{justify:`space-between`,align:`flex-start`,mb:4,children:[(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(V,{size:`sm`,fw:600,children:e.createdBy}),(0,I.jsx)(Ap,{color:xQ[e.type]??`gray`,variant:`light`,size:`xs`,children:e.type})]}),(0,I.jsx)(V,{size:`xs`,c:`dimmed`,children:new Date(e.createdAt).toLocaleString()})]}),(0,I.jsx)(V,{size:`sm`,style:{whiteSpace:`pre-wrap`},children:e.body})]},e.id)),a&&a.items.length===0&&(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`No comments.`}),b&&(0,I.jsx)(Wp,{withBorder:!0,p:`sm`,children:(0,I.jsxs)(U,{gap:`xs`,children:[(0,I.jsx)(Qm,{autosize:!0,minRows:2,placeholder:`Add a comment...`,value:l,onChange:e=>u(e.currentTarget.value)}),(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(R_,{size:`xs`,w:120,value:d,onChange:e=>f(e??`note`),data:[{value:`note`,label:`Note`},{value:`issue`,label:`Issue`},{value:`feedback`,label:`Feedback`}]}),(0,I.jsx)(H,{size:`xs`,loading:p,disabled:!l.trim(),onClick:()=>void y(),children:`Post`})]})]})})]})};function CQ(e,t){let n=(t?new Date(t):new Date).getTime()-new Date(e).getTime(),r=Math.floor(n/6e4),i=Math.floor(r/60),a=r%60;return i>0?`${i}h ${a}m`:`${a}m`}var wQ=({orderKey:e,runNo:t,seqNo:n,refreshKey:r,showTitle:i=!0,onActionsChange:a})=>{let[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!0),[u,d]=(0,v.useState)(n);n!==u&&(d(n),s(null),l(!0));let f=(0,v.useCallback)(async()=>{l(!0);try{s(await q.get(J.laborTickets(e,t,n)))}catch(e){gM(e)}finally{l(!1)}},[e,t,n,r]);(0,v.useEffect)(()=>{f()},[f]),(0,v.useEffect)(()=>{a?.({canClockIn:!!o&&!!Rj(o._actions,`clock-in`),canClockOut:!!o&&!!Rj(o._actions,`clock-out`)})},[o,a]);let p=async r=>{try{await q.delete(J.laborTicket(e,t,n,r)),await f()}catch(e){gM(e)}};return(0,I.jsxs)(I.Fragment,{children:[i&&(0,I.jsx)(zv,{order:5,children:`Labor Tickets`}),c?(0,I.jsx)(U,{align:`center`,py:`sm`,children:(0,I.jsx)(uu,{size:`sm`})}):(0,I.jsx)(I.Fragment,{children:o&&o.items.length>0?(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,withTableBorder:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`User`}),(0,I.jsx)(W.Th,{children:`Run`}),(0,I.jsx)(W.Th,{children:`Clock In`}),(0,I.jsx)(W.Th,{children:`Clock Out`}),(0,I.jsx)(W.Th,{children:`Duration`}),(0,I.jsx)(W.Th,{children:`Cost`}),(0,I.jsx)(W.Th,{})]})}),(0,I.jsx)(W.Tbody,{children:o.items.map(e=>(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Td,{children:e.username}),(0,I.jsx)(W.Td,{children:e.runId==null?`—`:(0,I.jsx)(Wd,{size:`sm`,href:`/supervisor/agents/${e.username}/runs/${e.runId}-1`,children:e.runId})}),(0,I.jsx)(W.Td,{children:new Date(e.clockIn).toLocaleString()}),(0,I.jsx)(W.Td,{children:e.clockOut?new Date(e.clockOut).toLocaleString():(0,I.jsx)(Ap,{color:`green`,size:`sm`,variant:`light`,children:`Open`})}),(0,I.jsx)(W.Td,{children:CQ(e.clockIn,e.clockOut)}),(0,I.jsx)(W.Td,{children:e.cost==null?`—`:`$${e.cost.toFixed(2)}`}),(0,I.jsx)(W.Td,{children:zj(o._actionTemplates,`deleteTicket`)&&(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,color:`red`,onClick:()=>void p(e.id),title:`Delete ticket`,children:(0,I.jsx)(uM,{size:14})})})]},e.id))})]}):(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`No labor tickets.`})})]})},TQ={panelGrid:`_panelGrid_fki9i_1`},EQ=({orderKey:e,runNo:t,seqNo:n,refreshKey:r,onStepUpdate:i,onCountChange:a})=>{let[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!0),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(n),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(!1);n!==f&&(p(n),s(null),l(!0));let x=(0,v.useCallback)(async()=>{l(!0);try{let r=await q.get(J.stepRuns(e,t,n,!0));s(r),a?.(r.total)}catch(e){gM(e)}finally{l(!1)}},[e,t,n,r]);(0,v.useEffect)(()=>{x()},[x]);let S=e=>{s(t=>t&&{...t,items:t.items.map(t=>t.id===e.id?{...t,...e}:t)}),i?.()},C=(e,t,n)=>{s(r=>r&&{...r,items:r.items.map(r=>r.id===e?{...r,_actions:t,_actionTemplates:n}:r)})},w=async(r,i)=>{d(r.id);try{S(await q.post(J.stepRunComplete(e,t,n,r.seqNo),{note:i}))}catch(e){gM(e)}finally{d(null)}},T=async r=>{d(r.id);try{S(await q.post(J.stepRunReopen(e,t,n,r.seqNo),{}))}catch(e){gM(e)}finally{d(null)}},E=async()=>{if(m){b(!0);try{await w(m,g.trim()||void 0),h(null),_(``)}finally{b(!1)}}};return(0,I.jsxs)(I.Fragment,{children:[c?(0,I.jsx)(U,{align:`center`,py:`sm`,children:(0,I.jsx)(uu,{size:`sm`})}):(0,I.jsxs)(U,{gap:`xs`,children:[o?.items.map(r=>{let i=Rj(r._actions,`complete`,{includeDisabled:!0}),a=Rj(r._actions,`reopen`,{includeDisabled:!0});return(0,I.jsx)(Wp,{withBorder:!0,p:`sm`,children:(0,I.jsxs)(U,{gap:`xs`,children:[(0,I.jsxs)(B,{justify:`space-between`,align:`center`,children:[(0,I.jsxs)(V,{fw:600,size:`sm`,children:[`STEP `,r.seqNo,r.title?`: ${r.title}`:``]}),(0,I.jsxs)(B,{gap:`xs`,children:[i&&(0,I.jsx)(M_,{label:Bj(i.disabledReason),disabled:!i.disabledReason,multiline:!0,maw:400,style:{whiteSpace:`pre-line`},children:(0,I.jsxs)(B,{gap:0,children:[(0,I.jsx)(H,{size:`xs`,color:`green`,disabled:i.disabled,loading:u===r.id,onClick:()=>w(r),style:{borderTopRightRadius:0,borderBottomRightRadius:0},children:`Complete`}),(0,I.jsxs)(gh,{position:`bottom-end`,withinPortal:!0,children:[(0,I.jsx)(gh.Target,{children:(0,I.jsx)(H,{size:`xs`,color:`green`,px:6,disabled:i.disabled||u===r.id,style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeft:`1px solid rgba(255,255,255,0.3)`},children:(0,I.jsx)(eM,{size:14})})}),(0,I.jsx)(gh.Dropdown,{children:(0,I.jsx)(gh.Item,{leftSection:(0,I.jsx)(cM,{size:14}),onClick:()=>{h(r),_(``)},children:`Complete with note`})})]})]})}),a&&(0,I.jsxs)(B,{gap:`xs`,align:`center`,children:[(0,I.jsxs)(V,{size:`xs`,c:`green`,children:[`Completed by `,r.updatedBy,` on`,` `,new Date(r.updatedAt).toLocaleString()]}),(()=>{let e=(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,color:`gray`,disabled:a.disabled,loading:u===r.id,onClick:a.disabled?void 0:()=>T(r),title:Bj(a.disabledReason)??`Undo completion`,children:(0,I.jsx)(Qj,{size:14})}),t=Bj(a.disabledReason);return t?(0,I.jsx)(M_,{label:t,multiline:!0,maw:350,style:{whiteSpace:`pre-line`},children:e}):e})()]}),!i&&!a&&r.completed&&(0,I.jsxs)(V,{size:`xs`,c:`green`,children:[`Completed by `,r.updatedBy,` on`,` `,new Date(r.updatedAt).toLocaleString()]})]})]}),r.instructions?(0,I.jsx)(nU,{children:r.instructions}):(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`No instructions`}),r.note&&(0,I.jsxs)(V,{size:`xs`,c:`green`,fs:`italic`,children:[`Note: `,r.note]}),(r.fieldValues?.length??0)>0&&(0,I.jsx)(zZ,{fieldValues:r.fieldValues,multiSet:r.multiSet,completed:r.completed,_actionTemplates:r._actionTemplates,fieldValueEndpoint:(i,a)=>r.multiSet?J.stepRunSetFieldValue(e,t,n,r.seqNo,a,i):J.stepRunFieldValue(e,t,n,r.seqNo,i),deleteSetEndpoint:i=>J.stepRunDeleteSet(e,t,n,r.seqNo,i),attachmentEndpoint:(i,a)=>r.multiSet?J.stepFieldSetAttachments(e,t,n,r.seqNo,a,i):J.stepFieldAttachments(e,t,n,r.seqNo,i),attachmentDownloadUrl:(i,a)=>`/erp/api/${J.stepFieldAttachmentDownload(e,t,n,r.seqNo,i,a)}`,onSetDeleted:()=>void x(),onActionsUpdated:(e,t)=>C(r.id,e,t)})]})},r.id)}),o&&o.items.length===0&&(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`No steps.`})]}),(0,I.jsx)(Nh,{opened:m!==null,onClose:()=>h(null),title:`Complete with note`,size:`sm`,children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsx)(Qm,{label:`Note`,placeholder:`Enter a note...`,value:g,onChange:e=>_(e.currentTarget.value),autosize:!0,minRows:3,maxRows:6,"data-autofocus":!0}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>h(null),children:`Cancel`}),(0,I.jsx)(H,{color:`green`,onClick:()=>void E(),loading:y,children:`Complete`})]})]})})]})},DQ={blocked:`orange`,pending:`gray`,in_progress:`yellow`,completed:`green`,skipped:`gray`,failed:`red`},OQ=({ref_:e,orderKey:t,runNo:n})=>{let r=()=>``;return(0,I.jsxs)(Wp,{withBorder:!0,p:`sm`,children:[(0,I.jsxs)(B,{gap:`xs`,mb:`xs`,children:[(0,I.jsx)(V,{size:`sm`,fw:500,children:e.title}),(0,I.jsxs)(Wd,{component:zw,to:`/orders/${t}/runs/${n}/ops/${e.sourceOpSeqNo}`,size:`xs`,c:`dimmed`,children:[`Op `,e.sourceOpSeqNo,` / Step `,e.sourceStepSeqNo]})]}),(0,I.jsx)(zZ,{fieldValues:e.fieldValues,multiSet:e.multiSet,completed:!0,fieldValueEndpoint:r,deleteSetEndpoint:r,attachmentEndpoint:r,attachmentDownloadUrl:(r,i)=>`/erp/api/${J.stepFieldAttachmentDownload(t,n,String(e.sourceOpSeqNo),String(e.sourceStepSeqNo),r,i)}`,onSetDeleted:r})]})},kQ=()=>{let{orderKey:e,runNo:t,seqNo:n}=bC(),{onOperationUpdate:r,orderRun:i,refreshOrderRun:a}=vC(),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!0),[u,d]=(0,v.useState)(0),[f,p]=(0,v.useState)(`description`),[m,h]=(0,v.useState)(`steps`),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(``),[T,E]=(0,v.useState)({canClockIn:!1,canClockOut:!1}),[D,O]=(0,v.useState)(!1),[k,A]=(0,v.useState)(!1),[j,ee]=(0,v.useState)(``),[te,ne]=(0,v.useState)(!1),re=(0,v.useCallback)(async()=>{if(!(!e||!t||!n)){l(!0);try{s(await q.get(J.operationRun(e,t,n)))}catch(e){gM(e)}finally{l(!1)}}},[e,t,n]);(0,v.useEffect)(()=>{re()},[re]);let M=async r=>{if(!(!e||!t||!n))try{s(await q.put(J.operationRun(e,t,n),{assignedToId:r})),S(!1)}catch(e){gM(e)}},N=async(i,o={})=>{if(!e||!t||!n)return;let c={start:J.operationRunStart,complete:J.operationRunComplete,skip:J.operationRunSkip,fail:J.operationRunFail,reopen:J.operationRunReopen};try{let l=await q.post(c[i](e,t,n),o);s(e=>e&&{...e,...l}),d(e=>e+1),r(),a()}catch(e){gM(e)}},ie=async()=>{if(!(!e||!t||!n)){O(!0);try{await q.post(J.laborTicketClockIn(e,t,n),{}),d(e=>e+1)}catch(e){gM(e)}finally{O(!1)}}},ae=async()=>{if(!(!e||!t||!n)){O(!0);try{await q.post(J.laborTicketClockOut(e,t,n),{}),d(e=>e+1)}catch(e){gM(e)}finally{O(!1)}}},oe=async()=>{ne(!0);try{await N(`complete`,{note:j.trim()||void 0}),A(!1),ee(``)}finally{ne(!1)}};return c?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):o?(0,I.jsxs)(Qp,{size:`md`,py:`xl`,w:`100%`,children:[(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsxs)(B,{justify:`space-between`,children:[(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsxs)(V,{fw:600,children:[`OPERATION `,o.seqNo,`: `,o.title]}),o.workCenterKey&&(0,I.jsxs)(V,{size:`sm`,c:`dimmed`,children:[`[`,o.workCenterKey,`]`]}),(0,I.jsx)(CZ,{createdBy:o.createdBy,createdAt:o.createdAt,updatedBy:o.updatedBy,updatedAt:o.updatedAt}),(0,I.jsx)(Ap,{color:DQ[o.status]??`gray`,variant:`light`,size:`sm`,children:o.status}),o.assignedTo?(0,I.jsxs)(B,{gap:4,children:[(0,I.jsxs)(V,{size:`sm`,c:`dimmed`,children:[`assigned to `,o.assignedTo]}),Rj(o._actions,`assign`)&&(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,color:`gray`,onClick:()=>void M(null),title:`Unassign`,children:(0,I.jsx)(pM,{size:12})})]}):Rj(o._actions,`assign`)&&(0,I.jsxs)(nu,{opened:x,onChange:S,position:`bottom`,withArrow:!0,children:[(0,I.jsx)(nu.Target,{children:(0,I.jsx)(V,{size:`sm`,c:`blue`,style:{cursor:`pointer`},onClick:()=>S(!0),children:`assign`})}),(0,I.jsx)(nu.Dropdown,{children:(0,I.jsx)(hZ,{placeholder:`Search users...`,value:C,onChange:w,onUserSelect:e=>{w(``),M(e.id)},size:`xs`,w:200})})]})]}),(0,I.jsxs)(B,{gap:`xs`,children:[(T.canClockIn||T.canClockOut)&&(0,I.jsxs)(I.Fragment,{children:[T.canClockIn&&(0,I.jsx)(H,{size:`xs`,color:`green`,variant:`outline`,loading:D,onClick:()=>void ie(),children:`Clock In`}),T.canClockOut&&(0,I.jsx)(H,{size:`xs`,color:`orange`,variant:`outline`,loading:D,onClick:()=>void ae(),children:`Clock Out`}),(0,I.jsx)(nm,{orientation:`vertical`})]}),(0,I.jsx)(iN,{actions:o._actions,rel:`start`,size:`xs`,color:`green`,onClick:()=>N(`start`),children:`Start`}),Rj(o._actions,`complete`,{includeDisabled:!0})&&(()=>{let e=Rj(o._actions,`complete`,{includeDisabled:!0});return(0,I.jsxs)(B,{gap:0,children:[(0,I.jsx)(H,{size:`xs`,color:`green`,disabled:e.disabled,onClick:()=>N(`complete`),style:{borderTopRightRadius:0,borderBottomRightRadius:0},children:`Complete`}),(0,I.jsxs)(gh,{position:`bottom-end`,withinPortal:!0,children:[(0,I.jsx)(gh.Target,{children:(0,I.jsx)(H,{size:`xs`,color:`green`,px:6,disabled:e.disabled,style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeft:`1px solid rgba(255,255,255,0.3)`},children:(0,I.jsx)(eM,{size:14})})}),(0,I.jsx)(gh.Dropdown,{children:(0,I.jsx)(gh.Item,{leftSection:(0,I.jsx)(cM,{size:14}),onClick:()=>{A(!0),ee(``)},children:`Complete with note`})})]})]})})(),(()=>{let e=Rj(o._actions,`reopen`,{includeDisabled:!0});if(!e)return null;let{label:t,color:n}={[DX.completed]:{label:`Completed`,color:`green`},[DX.skipped]:{label:`Skipped`,color:`gray`},[DX.failed]:{label:`Failed`,color:`red`}}[o.status]??{label:o.status,color:`gray`},r=(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,color:`gray`,disabled:e.disabled,onClick:e.disabled?void 0:()=>N(`reopen`),title:Bj(e.disabledReason)??`Undo ${t.toLowerCase()}`,children:(0,I.jsx)(Qj,{size:14})});return(0,I.jsxs)(B,{gap:`xs`,align:`center`,children:[(0,I.jsxs)(V,{size:`xs`,c:n,children:[t,` by `,o.updatedBy,` on`,` `,new Date(o.updatedAt).toLocaleString(),o.cost?` for $${o.cost.toFixed(2)}`:``]}),(()=>{let t=Bj(e.disabledReason);return t?(0,I.jsx)(M_,{label:t,multiline:!0,maw:350,style:{whiteSpace:`pre-line`},children:r}):r})()]})})(),Rj(o._actions,`skip`)&&(0,I.jsx)(H,{size:`xs`,color:`gray`,variant:`outline`,onClick:()=>N(`skip`),children:`Skip`}),Rj(o._actions,`fail`)&&(0,I.jsx)(H,{size:`xs`,color:`red`,variant:`outline`,onClick:()=>N(`fail`),children:`Fail`})]})]}),(0,I.jsxs)(jv,{value:f,onChange:p,children:[(0,I.jsxs)(jv.List,{children:[(0,I.jsx)(jv.Tab,{value:`description`,children:`Description`}),(0,I.jsx)(jv.Tab,{value:`dependencies`,children:`Dependencies`}),(0,I.jsx)(jv.Tab,{value:`labor`,children:`Labor Tickets`})]}),(0,I.jsxs)(`div`,{className:TQ.panelGrid,children:[(0,I.jsx)(jv.Panel,{value:`description`,pt:`sm`,keepMounted:!0,"data-active":f===`description`||void 0,children:(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,children:(0,I.jsxs)(U,{gap:`sm`,children:[o.description&&(0,I.jsx)(nU,{children:o.description}),o.note&&(0,I.jsxs)(V,{size:`xs`,c:DQ[o.status]??`dimmed`,fs:`italic`,children:[`Note: `,o.note]})]})})}),(0,I.jsx)(jv.Panel,{value:`dependencies`,pt:`sm`,keepMounted:!0,"data-active":f===`dependencies`||void 0,children:(0,I.jsx)(eQ,{orderKey:e,revNo:String(i.revNo),opSeqNo:n,showTitle:!1})}),(0,I.jsx)(jv.Panel,{value:`labor`,pt:`sm`,keepMounted:!0,"data-active":f===`labor`||void 0,children:(0,I.jsx)(wQ,{orderKey:e,runNo:t,seqNo:n,refreshKey:u,showTitle:!1,onActionsChange:E})})]})]}),o.fieldRefSummary&&o.fieldRefSummary.length>0&&(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsx)(zv,{order:5,children:`Referenced Fields`}),o.fieldRefSummary.map(n=>(0,I.jsx)(OQ,{ref_:n,orderKey:e,runNo:t},n.seqNo))]}),(0,I.jsx)(I_,{value:m,onChange:h,data:[{value:`steps`,label:`Steps${g?` (${g})`:``}`},{value:`comments`,label:`Comments${y?` (${y})`:``}`}]}),(0,I.jsx)(`div`,{style:{display:m===`steps`?void 0:`none`},children:(0,I.jsx)(EQ,{orderKey:e,runNo:t,seqNo:n,refreshKey:u,onStepUpdate:re,onCountChange:_})}),(0,I.jsx)(`div`,{style:{display:m===`comments`?void 0:`none`},children:(0,I.jsx)(SQ,{orderKey:e,runNo:t,seqNo:n,refreshKey:u,onCountChange:b})})]}),(0,I.jsx)(Nh,{opened:k,onClose:()=>A(!1),title:`Complete with note`,size:`sm`,children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsx)(Qm,{label:`Note`,placeholder:`Enter a note...`,value:j,onChange:e=>ee(e.currentTarget.value),autosize:!0,minRows:3,maxRows:6,"data-autofocus":!0}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>A(!1),children:`Cancel`}),(0,I.jsx)(H,{color:`green`,onClick:()=>void oe(),loading:te,children:`Complete`})]})]})})]}):(0,I.jsx)(U,{p:`md`,children:(0,I.jsx)(V,{children:`Operation run not found.`})})},AQ=()=>{let{orderKey:e}=bC(),t=hC(),[n]=qw(),r=Number(n.get(`revNo`))||0;return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Create Order Run`}),(0,I.jsx)(vQ,{initialData:{revNo:r||void 0},onSubmit:async n=>{t(`/orders/${e}/runs/${(await q.post(J.orderRuns(e),n)).runNo}`)},onCancel:()=>t(`/orders/${e}/runs`)})]})},jQ={blocked:`orange`,pending:`gray`,in_progress:`yellow`,completed:`green`,skipped:`gray`,failed:`red`},MQ=({orderKey:e,runNo:t,refreshKey:n})=>{let r=hC(),i=fC(),{seqNo:a}=bC(),o=i.pathname.endsWith(`/header`),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!0),d=(0,v.useCallback)(async()=>{u(!0);try{c(await q.get(J.operationRuns(e,t)))}catch(e){gM(e)}finally{u(!1)}},[e,t]);return(0,v.useEffect)(()=>{d()},[d,n]),(0,I.jsxs)(U,{gap:`xs`,children:[(0,I.jsx)(Wp,{padding:`sm`,radius:`md`,withBorder:!0,component:`a`,href:`/erp/orders/${e}/runs/${t}/header`,onClick:n=>{n.button===1||n.ctrlKey||n.metaKey||(n.preventDefault(),r(`/orders/${e}/runs/${t}/header`))},style:{cursor:`pointer`,textDecoration:`none`,color:`inherit`,backgroundColor:o?`var(--mantine-color-blue-9)`:void 0},children:(0,I.jsx)(V,{size:`sm`,fw:500,children:`Header`})}),l?(0,I.jsx)(U,{align:`center`,py:`md`,children:(0,I.jsx)(uu,{size:`sm`})}):!s||s.items.length===0?(0,I.jsx)(V,{c:`dimmed`,size:`sm`,ta:`center`,py:`md`,children:`No operation runs yet.`}):s.items.map(n=>{let i=`/orders/${e}/runs/${t}/ops/${n.seqNo}`;return(0,I.jsxs)(Wp,{padding:`sm`,radius:`md`,withBorder:!0,component:`a`,href:`/erp${i}`,onClick:e=>{e.button===1||e.ctrlKey||e.metaKey||(e.preventDefault(),r(i))},style:{cursor:`pointer`,textDecoration:`none`,color:`inherit`,backgroundColor:a===String(n.seqNo)?`var(--mantine-color-blue-9)`:void 0},children:[(0,I.jsxs)(V,{size:`sm`,fw:500,children:[n.seqNo,`. `,n.title]}),(0,I.jsx)(Ap,{color:jQ[n.status]??`gray`,variant:`light`,size:`xs`,mt:4,children:n.status})]},n.id)})]})};function NQ(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function PQ(e){return`${NQ(e)}T${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`}var FQ=({opened:e,onClose:t,orderRun:n,orderKey:r,runNo:i,onCompleted:a})=>{let[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)([]),[f,p]=(0,v.useState)({}),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(!1);(0,v.useEffect)(()=>{!e||!n.itemKey||(h(!0),q.get(J.itemFields(n.itemKey)).then(e=>{d(e.items);let t={};for(let n of e.items)t[n.id]=``;p(t)}).catch(gM).finally(()=>h(!1)))},[e,n.itemKey]);let y=()=>{s(``),l(``),p({}),t()},b=async()=>{_(!0);try{let e={};o.trim()&&(e.instanceKey=o.trim()),typeof c==`number`&&(e.quantity=c);let t=Object.entries(f).filter(([,e])=>e!==``).map(([e,t])=>({fieldId:Number(e),value:t}));t.length>0&&(e.fieldValues=t),a(await q.post(J.orderRunComplete(r,i),e)),y()}catch(e){gM(e)}finally{_(!1)}},x=(e,t)=>{p(n=>({...n,[e]:t}))};return(0,I.jsx)(Nh,{opened:e,onClose:y,title:`Complete Order Run`,size:`md`,children:(0,I.jsxs)(U,{gap:`md`,children:[(0,I.jsx)(Mv,{label:`Instance Key (SN / Lot Code)`,placeholder:`Leave blank to auto-generate`,value:o,onChange:e=>s(e.currentTarget.value),"data-autofocus":!0}),(0,I.jsx)(Vg,{label:`Quantity`,placeholder:`Optional`,value:c,onChange:l,min:0,decimalScale:4}),m&&(0,I.jsx)(B,{justify:`center`,children:(0,I.jsx)(uu,{size:`sm`})}),u.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{size:`sm`,fw:600,c:`dimmed`,children:`Item Fields`}),u.map(e=>{let t=f[e.id]??``,n=e.required?`${e.label} *`:e.label;switch(e.type){case tX.date:return(0,I.jsx)(ex,{label:n,size:`sm`,valueFormat:`YYYY-MM-DD`,clearable:!0,value:t?new Date(t+`T00:00:00`):null,onChange:t=>x(e.id,t?typeof t==`string`?t:NQ(t):``)},e.id);case tX.datetime:return(0,I.jsx)(ax,{label:n,size:`sm`,valueFormat:`YYYY-MM-DD HH:mm`,clearable:!0,value:t?new Date(t):null,onChange:t=>x(e.id,t?typeof t==`string`?t:PQ(t):``)},e.id);case tX.yesNo:return(0,I.jsxs)(B,{gap:`xs`,align:`center`,children:[(0,I.jsx)(V,{size:`sm`,fw:500,children:n}),(0,I.jsx)(rv,{size:`sm`,onLabel:`Yes`,offLabel:`No`,checked:t===`Yes`,onChange:t=>x(e.id,t.currentTarget.checked?`Yes`:`No`)})]},e.id);case tX.checkbox:return(0,I.jsx)(yp,{label:n,size:`sm`,checked:t===`checked`,onChange:t=>x(e.id,t.currentTarget.checked?`checked`:``)},e.id);case tX.number:return(0,I.jsx)(Mv,{label:n,size:`sm`,type:`number`,value:t,onChange:t=>x(e.id,t.currentTarget.value)},e.id);default:return(0,I.jsx)(Mv,{label:n,size:`sm`,value:t,onChange:t=>x(e.id,t.currentTarget.value)},e.id)}})]}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:y,children:`Cancel`}),(0,I.jsx)(H,{color:`green`,onClick:b,loading:g,children:`Complete`})]})]})})},IQ={[IX.released]:`blue`,[IX.started]:`yellow`,[IX.closed]:`green`,[IX.cancelled]:`gray`},LQ={[RX.low]:`gray`,[RX.medium]:`blue`,[RX.high]:`orange`,[RX.critical]:`red`},RQ=({orderRun:e,orderKey:t,runNo:n,onUpdate:r,onOpenOperations:i})=>{let a=hC(),[o,{open:s,close:c}]=_n(),l=async e=>{let i={start:J.orderRunStart,close:J.orderRunClose,cancel:J.orderRunCancel,reopen:J.orderRunReopen};try{r(await q.post(i[e](t,n),{}))}catch(e){gM(e)}},u=async()=>{if(confirm(`Delete this order run?`))try{await q.delete(J.orderRun(t,n)),a(`/orders/${t}/runs`)}catch(e){gM(e)}};return(0,I.jsxs)(B,{justify:`space-between`,px:`md`,py:`xs`,style:{borderBottom:`calc(0.125rem * var(--mantine-scale)) solid var(--mantine-color-dark-4)`},children:[(0,I.jsxs)(B,{gap:`sm`,children:[i&&(0,I.jsx)(vu,{variant:`subtle`,color:`gray`,hiddenFrom:`md`,onClick:i,children:(0,I.jsx)(oM,{size:`1.2rem`})}),(0,I.jsxs)(V,{size:`lg`,children:[`ORDER:`,` `,(0,I.jsx)(Wd,{href:`/erp/orders/${t}`,onClick:e=>{e.button===1||e.ctrlKey||e.metaKey||(e.preventDefault(),a(`/orders/${t}`))},children:t})]}),(0,I.jsxs)(Ap,{component:`a`,href:`/erp/orders/${t}/revs/${e.revNo}`,onClick:n=>{n.button===1||n.ctrlKey||n.metaKey||(n.preventDefault(),a(`/orders/${t}/revs/${e.revNo}`))},color:`violet`,variant:`light`,size:`sm`,style:{cursor:`pointer`},children:[`REV `,e.revNo]}),(0,I.jsxs)(V,{size:`lg`,fw:`bold`,children:[`RUN `,e.runNo]}),(0,I.jsx)(Ap,{color:IQ[e.status]??`gray`,variant:`light`,size:`sm`,"data-testid":`order-run-status`,children:e.status}),(0,I.jsx)(Ap,{color:LQ[e.priority]??`gray`,variant:`light`,size:`sm`,children:e.priority}),e.releaseNote&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`|`}),(0,I.jsx)(V,{size:`sm`,c:`dimmed`,lineClamp:1,maw:300,children:e.releaseNote})]}),e.instanceKey&&e.itemKey&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{size:`sm`,c:`dimmed`,children:`|`}),(0,I.jsxs)(V,{size:`sm`,c:`dimmed`,children:[`Completed into`,` `,(0,I.jsxs)(Wd,{size:`sm`,href:`/erp/items/${e.itemKey}/instances/${e.instanceId}`,onClick:t=>{t.button===1||t.ctrlKey||t.metaKey||(t.preventDefault(),a(`/items/${e.itemKey}/instances/${e.instanceId}`))},children:[e.itemKey,` `,e.instanceKey]})]})]})]}),(0,I.jsxs)(B,{gap:`xs`,children:[(0,I.jsx)(iN,{actions:e._actions,rel:`start`,size:`xs`,color:`green`,"data-testid":`order-run-start`,onClick:()=>l(`start`),children:`Start`}),(0,I.jsx)(iN,{actions:e._actions,rel:`complete`,size:`xs`,color:`green`,"data-testid":`order-run-complete`,onClick:s,children:`Complete`}),(0,I.jsx)(iN,{actions:e._actions,rel:`close`,size:`xs`,color:`green`,"data-testid":`order-run-close`,onClick:()=>l(`close`),children:`Close`}),Rj(e._actions,`reopen`)&&(0,I.jsxs)(B,{gap:`xs`,align:`center`,children:[(0,I.jsxs)(V,{size:`xs`,c:e.status===IX.closed?`green`:`orange`,children:[e.status===IX.closed?`Closed`:`Cancelled`,` `,`by `,e.updatedBy,` on`,` `,new Date(e.updatedAt).toLocaleString(),e.cost?` for $${e.cost.toFixed(2)}`:``]}),(0,I.jsx)(vu,{size:`xs`,variant:`subtle`,color:`gray`,onClick:()=>l(`reopen`),title:`Undo ${e.status===IX.closed?`close`:`cancel`}`,children:(0,I.jsx)(Qj,{size:14})})]}),Rj(e._actions,`cancel`)&&(0,I.jsx)(H,{size:`xs`,color:`orange`,variant:`outline`,onClick:()=>{confirm(`Cancel this order run?`)&&l(`cancel`)},children:`Cancel`}),Rj(e._actions,`delete`)&&(0,I.jsx)(H,{size:`xs`,color:`red`,variant:`outline`,onClick:u,children:`Delete`})]}),(0,I.jsx)(FQ,{opened:o,onClose:c,orderRun:e,orderKey:t,runNo:n,onCompleted:r})]})},zQ=260,BQ=()=>{let{orderKey:e,runNo:t}=bC(),n=fC(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!0),[s,{toggle:c}]=_n(),[l,{open:u,close:d}]=_n(),[f,p]=(0,v.useState)(0),m={onOperationUpdate:()=>p(e=>e+1),orderRun:r,onOrderRunUpdate:i,refreshOrderRun:()=>void h()},h=(0,v.useCallback)(async()=>{if(!(!e||!t)){o(!0);try{i(await q.get(J.orderRun(e,t)))}catch(e){gM(e)}finally{o(!1)}}},[e,t]);return(0,v.useEffect)(()=>{h()},[h]),(0,v.useEffect)(()=>{d()},[n.pathname]),a?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):!r||!e||!t?(0,I.jsx)(R,{p:`md`,children:(0,I.jsx)(V,{children:`Order run not found.`})}):(0,I.jsxs)(R,{display:`flex`,style:{flexDirection:`column`,height:`calc(100dvh - var(--app-shell-header-height, 0px))`},children:[(0,I.jsx)(RQ,{orderRun:r,orderKey:e,runNo:t,onUpdate:i,onOpenOperations:u}),(0,I.jsxs)(R,{display:`flex`,style:{flex:1,minHeight:0},children:[(0,I.jsx)(R,{visibleFrom:`md`,style:{flexShrink:0,display:`flex`,flexDirection:`column`},children:s?(0,I.jsx)(R,{style:{borderRight:`1px solid var(--mantine-color-dark-4)`,paddingRight:4},children:(0,I.jsx)(M_,{label:`Expand sidebar`,position:`right`,children:(0,I.jsx)(vu,{variant:`subtle`,color:`gray`,onClick:c,children:(0,I.jsx)(aM,{size:`1.2rem`})})})}):(0,I.jsxs)(R,{style:{width:zQ,minWidth:zQ,borderRight:`1px solid var(--mantine-color-dark-4)`,display:`flex`,flexDirection:`column`,overflowY:`auto`,padding:`0 var(--mantine-spacing-md)`},children:[(0,I.jsx)(B,{justify:`flex-end`,p:4,children:(0,I.jsx)(M_,{label:`Collapse sidebar`,position:`right`,children:(0,I.jsx)(vu,{variant:`subtle`,color:`gray`,size:`sm`,onClick:c,children:(0,I.jsx)(iM,{size:`1rem`})})})}),(0,I.jsx)(MQ,{orderKey:e,runNo:t,refreshKey:f})]})}),(0,I.jsx)(`div`,{style:{flex:1,minHeight:0,overflowY:`auto`,display:`flex`,flexDirection:`column`},children:(0,I.jsx)(GC,{context:m})})]}),(0,I.jsx)(Cm,{opened:l,onClose:d,title:`Operations`,size:zQ,children:(0,I.jsx)(MQ,{orderKey:e,runNo:t,refreshKey:f})})]})},VQ={[IX.released]:`blue`,[IX.started]:`yellow`,[IX.closed]:`green`,[IX.cancelled]:`gray`},HQ={[RX.low]:`gray`,[RX.medium]:`blue`,[RX.high]:`orange`,[RX.critical]:`red`},UQ=()=>{let{orderKey:e}=bC(),[t,n]=qw(),r=Number(t.get(`page`))||1,i=t.get(`status`)||void 0,a=t.get(`priority`)||void 0,o=t.get(`search`)||``,[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!0),d=(0,v.useCallback)(async()=>{u(!0);try{let t=new URLSearchParams;t.set(`page`,String(r)),t.set(`pageSize`,`20`),i&&t.set(`status`,i),a&&t.set(`priority`,a),o&&t.set(`search`,o),c(await q.get(`${J.orderRuns(e)}?${t}`))}catch(e){gM(e)}finally{u(!1)}},[e,r,i,a,o]);(0,v.useEffect)(()=>{d()},[d]);let f=s?Math.ceil(s.total/s.pageSize):0;return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsxs)(zv,{order:2,children:[`Runs for `,e]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{variant:`subtle`,component:zw,to:`/orders/${e}`,children:`Back to Order`}),(0,I.jsx)(H,{component:zw,to:`/orders/${e}/runs/new`,children:`Create New`})]})]}),(0,I.jsxs)(B,{mb:`md`,children:[(0,I.jsx)(Mv,{placeholder:`Search...`,value:o,onChange:e=>{let t=e.currentTarget.value;n(e=>(t?e.set(`search`,t):e.delete(`search`),e.set(`page`,`1`),e))},style:{flex:1}}),(0,I.jsx)(R_,{placeholder:`All statuses`,data:FX.options.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),value:i??null,onChange:e=>{n(t=>(e?t.set(`status`,e):t.delete(`status`),t.set(`page`,`1`),t))},clearable:!0}),(0,I.jsx)(R_,{placeholder:`All priorities`,data:LX.options.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),value:a??null,onChange:e=>{n(t=>(e?t.set(`priority`,e):t.delete(`priority`),t.set(`page`,`1`),t))},clearable:!0})]}),l?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):s&&s.items.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Run #`}),(0,I.jsx)(W.Th,{children:`Rev`}),(0,I.jsx)(W.Th,{children:`Status`}),(0,I.jsx)(W.Th,{children:`Priority`}),(0,I.jsx)(W.Th,{children:`Cost`}),(0,I.jsx)(W.Th,{children:`Due`}),(0,I.jsx)(W.Th,{children:`Created`})]})}),(0,I.jsx)(W.Tbody,{children:s.items.map(t=>{let n=`/orders/${e}/runs/${t.runNo}`;return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},"data-testid":`order-run-row-${t.runNo}`,children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:t.runNo})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:t.revNo})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:(0,I.jsx)(Ap,{color:VQ[t.status]??`gray`,variant:`light`,children:t.status})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:(0,I.jsx)(Ap,{color:HQ[t.priority]??`gray`,variant:`light`,children:t.priority})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:t.cost?`$${t.cost.toFixed(2)}`:`—`})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:t.dueAt?new Date(t.dueAt).toLocaleDateString():`—`})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:n,style:gZ,children:new Date(t.createdAt).toLocaleDateString()})})]},t.id)})})]}),f>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:f,value:r,onChange:e=>n(t=>(t.set(`page`,String(e)),t))})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`xl`,children:`No order runs found.`})]})},WQ=()=>{let{username:e}=bC(),t=hC(),{supervisorAuth:n}=vC(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!0),[s,{open:c,close:l}]=_n(),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(!1),[x,{open:S,close:C}]=_n(),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(!1),[O,k]=(0,v.useState)(``),A=(0,v.useCallback)(async()=>{if(e){o(!0);try{i(await q.get(J.user(e)))}catch{}finally{o(!1)}}},[e]);(0,v.useEffect)(()=>{A()},[A]);let j=async()=>{if(!(!e||!confirm(`Delete this user?`)))try{await q.delete(J.user(e)),t(`/users`)}catch(e){gM(e)}},ee=async()=>{if(!(!e||!u)){p(!0),h(``);try{await q.put(J.user(e),{username:u}),l(),u===e?A():t(`/users/${u}`,{replace:!0})}catch(e){h(e instanceof Error?e.message:`Failed to update user`)}finally{p(!1)}}},te=async()=>{if(w){D(!0),k(``);try{await q.post(J.changePassword,{password:w}),C(),T(``)}catch(e){k(e instanceof Error?e.message:`Failed to change password`)}finally{D(!1)}}},ne=async()=>{if(!(!e||!g))try{await q.post(J.userPermissions(e),{permission:g}),_(null),A()}catch(e){gM(e)}},re=async t=>{if(e)try{await q.delete(J.userPermission(e,t)),A()}catch(e){gM(e)}},M=async()=>{if(e&&confirm(`Rotate this user's API key? The old key will stop working immediately.`)){b(!0);try{await q.post(J.userRotateKey(e),{}),A()}catch(e){gM(e)}finally{b(!1)}}};if(a)return(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(U,{align:`center`,children:(0,I.jsx)(uu,{})})});if(!r)return(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(V,{children:`User not found.`})});let N=sZ.options.filter(e=>!r.permissions?.some(t=>t.permission===e));return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(zv,{order:2,children:r.username}),(0,I.jsx)(CZ,{createdAt:r.createdAt,updatedAt:r.updatedAt})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>t(`/users`),children:`Back`}),Rj(r._actions,`change-password`)&&(0,I.jsx)(H,{variant:`outline`,onClick:()=>{T(``),k(``),S()},children:`Change Password`}),Rj(r._actions,`update`)&&(0,I.jsx)(H,{onClick:()=>{d(r.username),h(``),c()},children:`Edit`}),Rj(r._actions,`delete`)&&(0,I.jsx)(H,{color:`red`,variant:`outline`,onClick:j,children:`Delete`})]})]}),r.isAgent&&!n&&(0,I.jsx)(Wp,{withBorder:!0,p:`sm`,mb:`lg`,bg:`var(--mantine-color-red-light)`,children:(0,I.jsxs)(B,{gap:`xs`,wrap:`nowrap`,children:[(0,I.jsx)(Xj,{size:18,color:`var(--mantine-color-red-6)`}),(0,I.jsx)(V,{size:`sm`,children:`This is an agent user but ERP is running without supervisor auth. API key lookups and agent authentication will not work.`})]})}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,mb:`lg`,children:(0,I.jsxs)(U,{gap:`sm`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Username:`}),(0,I.jsx)(V,{ff:`monospace`,children:r.username})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Type:`}),(0,I.jsx)(V,{children:r.isAgent?`Agent`:`User`})]}),(r.apiKey||Rj(r._actions,`rotate-key`))&&(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`API Key:`}),(0,I.jsx)(rU,{value:r.apiKey??null,onRotate:Rj(r._actions,`rotate-key`)?M:void 0,rotating:y})]})]})}),(0,I.jsx)(zv,{order:3,mb:`sm`,children:`Permissions`}),r.permissions&&r.permissions.length>0?(0,I.jsxs)(W,{striped:!0,withTableBorder:!0,mb:`md`,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Permission`}),(0,I.jsx)(W.Th,{children:`Granted At`}),(0,I.jsx)(W.Th,{children:`Actions`})]})}),(0,I.jsx)(W.Tbody,{children:r.permissions.map(e=>(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Td,{children:(0,I.jsx)(V,{ff:`monospace`,children:e.permission})}),(0,I.jsx)(W.Td,{children:new Date(e.grantedAt).toLocaleString()}),(0,I.jsx)(W.Td,{children:Rj(e._actions,`revoke`)&&(0,I.jsx)(H,{size:`xs`,color:`red`,variant:`subtle`,onClick:()=>re(e.permission),children:`Revoke`})})]},e.permission))})]}):(0,I.jsx)(V,{c:`dimmed`,mb:`md`,children:`No permissions granted.`}),Rj(r._actions,`grant-permission`)&&N.length>0&&(0,I.jsxs)(B,{children:[(0,I.jsx)(R_,{placeholder:`Select permission`,data:N.map(e=>({value:e,label:e})),value:g,onChange:e=>_(e)}),(0,I.jsx)(H,{onClick:ne,disabled:!g,children:`Grant`})]}),(0,I.jsx)(Nh,{opened:s,onClose:l,title:`Edit User`,children:(0,I.jsxs)(U,{children:[(0,I.jsx)(Mv,{label:`Username`,value:u,onChange:e=>d(e.currentTarget.value)}),m&&(0,I.jsx)(V,{c:`red`,size:`sm`,children:m}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:l,children:`Cancel`}),(0,I.jsx)(H,{onClick:ee,loading:f,children:`Save`})]})]})}),(0,I.jsx)(Nh,{opened:x,onClose:C,title:`Change Password`,children:(0,I.jsxs)(U,{children:[(0,I.jsx)(m_,{label:`New Password`,value:w,onChange:e=>T(e.currentTarget.value)}),O&&(0,I.jsx)(V,{c:`red`,size:`sm`,children:O}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:C,children:`Cancel`}),(0,I.jsx)(H,{onClick:te,loading:E,children:`Save`})]})]})})]})},GQ=()=>{let[e,t]=qw(),n=hC(),{supervisorAuth:r}=vC(),i=Number(e.get(`page`))||1,a=e.get(`search`)||``,[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!0),[u,{open:d,close:f}]=_n(),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(!1),[b,{open:x,close:S}]=_n(),[C,w]=(0,v.useState)([]),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(!1),[k,A]=(0,v.useState)(!1),j=(0,v.useCallback)(async()=>{l(!0);try{let e=new URLSearchParams;e.set(`page`,String(i)),e.set(`pageSize`,`20`),a&&e.set(`search`,a),s(await q.get(`${J.users}?${e}`))}catch(e){gM(e)}finally{l(!1)}},[i,a]);(0,v.useEffect)(()=>{j()},[j]);let ee=async()=>{y(!0);try{await q.post(J.users,{username:p,password:h}),f(),n(`/users/${p}`),m(``),g(``)}catch(e){gM(e)}finally{y(!1)}},te=async()=>{x(),E(null),A(!0);try{let e=await q.get(`/supervisor/api/agents`),t=[],n=1,r;do r=await q.get(`${J.users}?page=${n}&pageSize=100`),t=t.concat(r.items),n++;while(t.length<r.total);let i=new Set(t.filter(e=>e.isAgent).map(e=>e.username));w(e.items.filter(e=>!e.archived&&!i.has(e.name)).map(e=>({value:String(e.id),label:e.name})))}catch(e){gM(e),S()}finally{A(!1)}},ne=async()=>{if(T){O(!0);try{let e=await q.post(J.usersFromAgent,{agentId:Number(T)});S(),n(`/users/${e.username}`)}catch(e){gM(e)}finally{O(!1)}}},re=o?Math.ceil(o.total/o.pageSize):0;return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsx)(zv,{order:2,children:`Users`}),(0,I.jsxs)(B,{children:[r&&(0,I.jsx)(H,{variant:`outline`,onClick:te,children:`Create Agent User`}),(0,I.jsx)(H,{onClick:d,children:`Create User`})]})]}),(0,I.jsx)(B,{mb:`md`,children:(0,I.jsx)(Mv,{placeholder:`Search...`,value:a,onChange:e=>{let n=e.currentTarget.value;t(e=>(n?e.set(`search`,n):e.delete(`search`),e.set(`page`,`1`),e))},style:{flex:1}})}),c?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):o&&o.items.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Username`}),(0,I.jsx)(W.Th,{children:`Type`}),(0,I.jsx)(W.Th,{children:`Permissions`}),(0,I.jsx)(W.Th,{children:`Created`})]})}),(0,I.jsx)(W.Tbody,{children:o.items.map(e=>(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:`/users/${e.username}`,style:gZ,children:(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:e.username})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:`/users/${e.username}`,style:gZ,children:(0,I.jsxs)(B,{gap:4,wrap:`nowrap`,children:[e.isAgent?`Agent`:`User`,e.isAgent&&!r&&(0,I.jsx)(M_,{label:`Agent user without supervisor auth — API key and auth will not work`,children:(0,I.jsx)(Xj,{size:14,color:`var(--mantine-color-red-6)`})})]})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:`/users/${e.username}`,style:gZ,children:e.permissionCount})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:`/users/${e.username}`,style:gZ,children:new Date(e.createdAt).toLocaleDateString()})})]},e.id))})]}),re>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:re,value:i,onChange:e=>t(t=>(t.set(`page`,String(e)),t))})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`xl`,children:`No users found.`}),(0,I.jsx)(Nh,{opened:u,onClose:f,title:`Create User`,children:(0,I.jsxs)(U,{children:[(0,I.jsx)(Mv,{label:`Username`,value:p,onChange:e=>m(e.currentTarget.value),"data-autofocus":!0}),(0,I.jsx)(m_,{label:`Password`,value:h,onChange:e=>g(e.currentTarget.value)}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:f,children:`Cancel`}),(0,I.jsx)(H,{onClick:ee,loading:_,disabled:!p||h.length<6,children:`Create`})]})]})}),(0,I.jsx)(Nh,{opened:b,onClose:S,title:`Create Agent User`,children:(0,I.jsxs)(U,{children:[k?(0,I.jsx)(uu,{size:`sm`}):(0,I.jsx)(R_,{label:`Agent`,placeholder:`Select an agent`,data:C,value:T,onChange:E,searchable:!0}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:S,children:`Cancel`}),(0,I.jsx)(H,{onClick:ne,loading:D,disabled:!T,children:`Create`})]})]})})]})},KQ=()=>{let e=hC(),[t,n]=(0,v.useState)(``),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1);return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Create Work Center`}),(0,I.jsxs)(U,{children:[(0,I.jsx)(Mv,{label:`Key`,description:`Alphanumeric with hyphens`,value:t,onChange:e=>n(e.currentTarget.value),required:!0}),(0,I.jsx)(Qm,{label:`Description`,value:r,onChange:e=>i(e.currentTarget.value),autosize:!0,minRows:2}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>e(`/work-centers`),children:`Cancel`}),(0,I.jsx)(H,{onClick:async()=>{o(!0);try{await q.post(J.workCenters,{key:t,description:r}),e(`/work-centers/${t}`)}catch(e){gM(e)}finally{o(!1)}},loading:a,disabled:!t,children:`Create`})]})]})]})},qQ=()=>{let{key:e}=bC(),t=hC(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(``),g=(0,v.useCallback)(async()=>{if(e){a(!0);try{r(await q.get(J.workCenter(e)))}catch(e){gM(e)}finally{a(!1)}}},[e]);(0,v.useEffect)(()=>{g()},[g]);let _=()=>{n&&(l(n.key),d(n.description),s(!0))},y=async()=>{if(e){p(!0);try{let n={key:c,description:u};await q.put(J.workCenter(e),n),s(!1),c===e?await g():t(`/work-centers/${c}`,{replace:!0})}catch(e){gM(e)}finally{p(!1)}}},b=async()=>{if(!(!e||!confirm(`Delete this work center?`)))try{await q.delete(J.workCenter(e)),t(`/work-centers`)}catch(e){gM(e)}},x=async()=>{if(!(!e||!m.trim()))try{await q.post(J.workCenterUsers(e),{username:m.trim()}),h(``),await g()}catch(e){gM(e)}},S=async t=>{if(e)try{await q.delete(J.workCenterUser(e,t)),await g()}catch(e){gM(e)}};if(i)return(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(U,{align:`center`,children:(0,I.jsx)(uu,{})})});if(!n)return(0,I.jsx)(Qp,{size:`md`,py:`xl`,children:(0,I.jsx)(V,{children:`Work center not found.`})});if(o)return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsx)(zv,{order:2,mb:`lg`,children:`Edit Work Center`}),(0,I.jsxs)(U,{children:[(0,I.jsx)(Mv,{label:`Key`,description:`Alphanumeric with hyphens`,value:c,onChange:e=>l(e.currentTarget.value),required:!0}),(0,I.jsx)(Qm,{label:`Description`,value:u,onChange:e=>d(e.currentTarget.value),autosize:!0,minRows:2}),(0,I.jsxs)(B,{justify:`flex-end`,children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>s(!1),children:`Cancel`}),(0,I.jsx)(H,{onClick:y,loading:f,children:`Save`})]})]})]});let C=Rj(n._actions,`assignUser`);return(0,I.jsxs)(Qp,{size:`md`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsxs)(B,{children:[(0,I.jsx)(zv,{order:2,children:n.key}),(0,I.jsx)(CZ,{createdBy:n.createdBy,createdAt:n.createdAt,updatedBy:n.updatedBy,updatedAt:n.updatedAt})]}),(0,I.jsxs)(B,{children:[(0,I.jsx)(H,{variant:`subtle`,onClick:()=>t(`/work-centers`),children:`Back`}),Rj(n._actions,`update`)&&(0,I.jsx)(H,{onClick:_,children:`Edit`}),Rj(n._actions,`delete`)&&(0,I.jsx)(H,{color:`red`,variant:`outline`,onClick:b,children:`Delete`})]})]}),(0,I.jsx)(Wp,{withBorder:!0,p:`lg`,mb:`lg`,children:(0,I.jsx)(U,{gap:`sm`,children:(0,I.jsxs)(B,{children:[(0,I.jsx)(V,{fw:600,w:120,children:`Description:`}),(0,I.jsx)(V,{children:n.description||`—`})]})})}),(0,I.jsx)(zv,{order:4,mb:`sm`,children:`Assigned Users`}),C&&(0,I.jsxs)(B,{mb:`md`,children:[(0,I.jsx)(hZ,{placeholder:`Search users...`,value:m,onChange:h,style:{flex:1}}),(0,I.jsx)(H,{onClick:x,disabled:!m.trim(),children:`Assign`})]}),n.userAssignments.length>0?(0,I.jsxs)(W,{striped:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Username`}),(0,I.jsx)(W.Th,{children:`Assigned`}),(0,I.jsx)(W.Th,{children:`By`}),C&&(0,I.jsx)(W.Th,{w:50})]})}),(0,I.jsx)(W.Tbody,{children:n.userAssignments.map(e=>(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Td,{children:(0,I.jsx)(V,{size:`sm`,children:e.username})}),(0,I.jsx)(W.Td,{children:(0,I.jsx)(V,{size:`sm`,children:new Date(e.createdAt).toLocaleDateString()})}),(0,I.jsx)(W.Td,{children:(0,I.jsx)(V,{size:`sm`,children:e.createdBy??`—`})}),C&&(0,I.jsx)(W.Td,{children:Rj(e._actions,`remove`)&&(0,I.jsx)(vu,{color:`red`,variant:`subtle`,size:`sm`,onClick:()=>S(e.username),children:(0,I.jsx)(uM,{size:`0.9rem`})})})]},e.userId))})]}):(0,I.jsx)(V,{c:`dimmed`,py:`md`,children:`No users assigned.`})]})},JQ=()=>{let e=hC(),[t,n]=qw(),r=Number(t.get(`page`))||1,i=t.get(`search`)||``,[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!0),l=(0,v.useCallback)(async()=>{c(!0);try{let e=new URLSearchParams;e.set(`page`,String(r)),e.set(`pageSize`,`20`),i&&e.set(`search`,i),o(await q.get(`${J.workCenters}?${e}`))}catch(e){gM(e)}finally{c(!1)}},[r,i]);(0,v.useEffect)(()=>{l()},[l]);let u=a?Math.ceil(a.total/a.pageSize):0;return(0,I.jsxs)(Qp,{size:`lg`,py:`xl`,children:[(0,I.jsxs)(B,{justify:`space-between`,mb:`lg`,children:[(0,I.jsx)(zv,{order:2,children:`Work Centers`}),a&&Rj(a._actions,`create`)&&(0,I.jsx)(H,{onClick:()=>e(`/work-centers/new`),children:`Create New`})]}),(0,I.jsx)(B,{mb:`md`,children:(0,I.jsx)(Mv,{placeholder:`Search...`,value:i,onChange:e=>{let t=e.currentTarget.value;n(e=>(t?e.set(`search`,t):e.delete(`search`),e.set(`page`,`1`),e))},style:{flex:1}})}),s?(0,I.jsx)(U,{align:`center`,py:`xl`,children:(0,I.jsx)(uu,{})}):a&&a.items.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(W,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(W.Thead,{children:(0,I.jsxs)(W.Tr,{children:[(0,I.jsx)(W.Th,{children:`Key`}),(0,I.jsx)(W.Th,{children:`Description`}),(0,I.jsx)(W.Th,{children:`Users`}),(0,I.jsx)(W.Th,{children:`Created`})]})}),(0,I.jsx)(W.Tbody,{children:a.items.map(e=>{let t=`/work-centers/${e.key}`;return(0,I.jsxs)(W.Tr,{style:{cursor:`pointer`},children:[(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(V,{size:`sm`,ff:`monospace`,children:e.key})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(V,{size:`sm`,lineClamp:1,children:e.description||`—`})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:(0,I.jsx)(V,{size:`sm`,children:e.userCount})})}),(0,I.jsx)(W.Td,{style:{padding:0},children:(0,I.jsx)(zw,{to:t,style:gZ,children:new Date(e.createdAt).toLocaleDateString()})})]},e.id)})})]}),u>1&&(0,I.jsx)(B,{justify:`center`,mt:`md`,children:(0,I.jsx)(u_,{total:u,value:r,onChange:e=>n(t=>(t.set(`page`,String(e)),t))})})]}):(0,I.jsx)(V,{c:`dimmed`,ta:`center`,py:`xl`,children:`No work centers found.`})]})},YQ=()=>{let[e,t]=v.useState(!1),[n,r]=v.useState(!1),[i,a]=v.useState(!1),{user:o,loading:s}=xM();return v.useEffect(()=>{fetch(`/erp/api/client-config`).then(e=>e.json()).then(e=>{t(e.publicRead),r(e.supervisorAuth)}).catch(()=>{}).finally(()=>a(!0))},[]),s||!i?null:!o&&!e?(0,I.jsx)(UZ,{}):(0,I.jsx)(JC,{children:(0,I.jsxs)(KC,{element:(0,I.jsx)(pZ,{supervisorAuth:n}),children:[(0,I.jsx)(KC,{path:`/`,element:(0,I.jsx)(WC,{to:`/orders`,replace:!0})}),(0,I.jsx)(KC,{path:`/orders`,element:(0,I.jsx)(XZ,{})}),(0,I.jsx)(KC,{path:`/orders/new`,element:(0,I.jsx)(GZ,{})}),(0,I.jsx)(KC,{path:`/orders/:key`,element:(0,I.jsx)(YZ,{})}),(0,I.jsx)(KC,{path:`/orders/:orderKey/revs/diff`,element:(0,I.jsx)(uQ,{})}),(0,I.jsxs)(KC,{path:`/orders/:orderKey/revs/:revNo`,element:(0,I.jsx)(hQ,{}),children:[(0,I.jsx)(KC,{index:!0,element:(0,I.jsx)(WC,{to:`header`,replace:!0})}),(0,I.jsx)(KC,{path:`header`,element:(0,I.jsx)(QZ,{})}),(0,I.jsx)(KC,{path:`ops/:seqNo`,element:(0,I.jsx)(rQ,{})})]}),(0,I.jsx)(KC,{path:`/orders/:orderKey/runs`,element:(0,I.jsx)(UQ,{})}),(0,I.jsx)(KC,{path:`/orders/:orderKey/runs/new`,element:(0,I.jsx)(AQ,{})}),(0,I.jsxs)(KC,{path:`/orders/:orderKey/runs/:runNo`,element:(0,I.jsx)(BQ,{}),children:[(0,I.jsx)(KC,{index:!0,element:(0,I.jsx)(WC,{to:`header`,replace:!0})}),(0,I.jsx)(KC,{path:`header`,element:(0,I.jsx)(bQ,{})}),(0,I.jsx)(KC,{path:`ops/:seqNo`,element:(0,I.jsx)(kQ,{})})]}),(0,I.jsx)(KC,{path:`/items`,element:(0,I.jsx)(HZ,{})}),(0,I.jsx)(KC,{path:`/items/new`,element:(0,I.jsx)(SZ,{})}),(0,I.jsx)(KC,{path:`/items/:key`,element:(0,I.jsx)(DZ,{})}),(0,I.jsx)(KC,{path:`/items/:key/instances`,element:(0,I.jsx)(VZ,{})}),(0,I.jsx)(KC,{path:`/items/:key/instances/:instanceId`,element:(0,I.jsx)(BZ,{})}),(0,I.jsx)(KC,{path:`/work-centers`,element:(0,I.jsx)(JQ,{})}),(0,I.jsx)(KC,{path:`/work-centers/new`,element:(0,I.jsx)(KQ,{})}),(0,I.jsx)(KC,{path:`/work-centers/:key`,element:(0,I.jsx)(qQ,{})}),(0,I.jsx)(KC,{path:`/dispatch`,element:(0,I.jsx)(bZ,{})}),(0,I.jsx)(KC,{path:`/inventory`,element:(0,I.jsx)(xZ,{})}),(0,I.jsx)(KC,{path:`/users`,element:(0,I.jsx)(GQ,{})}),(0,I.jsx)(KC,{path:`/users/:username`,element:(0,I.jsx)(WQ,{})}),(0,I.jsx)(KC,{path:`/admin`,element:(0,I.jsx)(mZ,{})})]})})};_.createRoot(document.getElementById(`root`)).render((0,I.jsx)(v.StrictMode,{children:(0,I.jsx)(()=>(0,I.jsx)(zr,{defaultColorScheme:`dark`,children:(0,I.jsxs)($v,{settings:{consistentWeeks:!0},children:[(0,I.jsx)(Xx,{position:`top-right`}),(0,I.jsx)(Iw,{basename:`/erp`,children:(0,I.jsx)(bM,{children:(0,I.jsx)(YQ,{})})})]})}),{})}));