ldrouter 1.11.3 → 1.11.4

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.
@@ -282,7 +282,7 @@ Please change the parent <Route path="${N}"> to <Route path="${N==="/"?"*":`${N}
282
282
  *
283
283
  * This source code is licensed under the ISC license.
284
284
  * See the LICENSE file in the root directory of this source tree.
285
- */const jC=ze("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function e0(a){var l,o,i="";if(typeof a=="string"||typeof a=="number")i+=a;else if(typeof a=="object")if(Array.isArray(a)){var u=a.length;for(l=0;l<u;l++)a[l]&&(o=e0(a[l]))&&(i&&(i+=" "),i+=o)}else for(o in a)a[o]&&(i&&(i+=" "),i+=o);return i}function t0(){for(var a,l,o=0,i="",u=arguments.length;o<u;o++)(a=arguments[o])&&(l=e0(a))&&(i&&(i+=" "),i+=l);return i}const Th="-",CC=a=>{const l=RC(a),{conflictingClassGroups:o,conflictingClassGroupModifiers:i}=a;return{getClassGroupId:h=>{const p=h.split(Th);return p[0]===""&&p.length!==1&&p.shift(),n0(p,l)||EC(h)},getConflictingClassGroupIds:(h,p)=>{const g=o[h]||[];return p&&i[h]?[...g,...i[h]]:g}}},n0=(a,l)=>{var h;if(a.length===0)return l.classGroupId;const o=a[0],i=l.nextPart.get(o),u=i?n0(a.slice(1),i):void 0;if(u)return u;if(l.validators.length===0)return;const d=a.join(Th);return(h=l.validators.find(({validator:p})=>p(d)))==null?void 0:h.classGroupId},Bx=/^\[(.+)\]$/,EC=a=>{if(Bx.test(a)){const l=Bx.exec(a)[1],o=l==null?void 0:l.substring(0,l.indexOf(":"));if(o)return"arbitrary.."+o}},RC=a=>{const{theme:l,prefix:o}=a,i={nextPart:new Map,validators:[]};return TC(Object.entries(a.classGroups),o).forEach(([d,h])=>{Gf(h,i,d,l)}),i},Gf=(a,l,o,i)=>{a.forEach(u=>{if(typeof u=="string"){const d=u===""?l:Hx(l,u);d.classGroupId=o;return}if(typeof u=="function"){if(NC(u)){Gf(u(i),l,o,i);return}l.validators.push({validator:u,classGroupId:o});return}Object.entries(u).forEach(([d,h])=>{Gf(h,Hx(l,d),o,i)})})},Hx=(a,l)=>{let o=a;return l.split(Th).forEach(i=>{o.nextPart.has(i)||o.nextPart.set(i,{nextPart:new Map,validators:[]}),o=o.nextPart.get(i)}),o},NC=a=>a.isThemeGetter,TC=(a,l)=>l?a.map(([o,i])=>{const u=i.map(d=>typeof d=="string"?l+d:typeof d=="object"?Object.fromEntries(Object.entries(d).map(([h,p])=>[l+h,p])):d);return[o,u]}):a,AC=a=>{if(a<1)return{get:()=>{},set:()=>{}};let l=0,o=new Map,i=new Map;const u=(d,h)=>{o.set(d,h),l++,l>a&&(l=0,i=o,o=new Map)};return{get(d){let h=o.get(d);if(h!==void 0)return h;if((h=i.get(d))!==void 0)return u(d,h),h},set(d,h){o.has(d)?o.set(d,h):u(d,h)}}},a0="!",MC=a=>{const{separator:l,experimentalParseClassName:o}=a,i=l.length===1,u=l[0],d=l.length,h=p=>{const g=[];let v=0,x=0,y;for(let j=0;j<p.length;j++){let N=p[j];if(v===0){if(N===u&&(i||p.slice(j,j+d)===l)){g.push(p.slice(x,j)),x=j+d;continue}if(N==="/"){y=j;continue}}N==="["?v++:N==="]"&&v--}const S=g.length===0?p:p.substring(x),w=S.startsWith(a0),C=w?S.substring(1):S,E=y&&y>x?y-x:void 0;return{modifiers:g,hasImportantModifier:w,baseClassName:C,maybePostfixModifierPosition:E}};return o?p=>o({className:p,parseClassName:h}):h},DC=a=>{if(a.length<=1)return a;const l=[];let o=[];return a.forEach(i=>{i[0]==="["?(l.push(...o.sort(),i),o=[]):o.push(i)}),l.push(...o.sort()),l},_C=a=>({cache:AC(a.cacheSize),parseClassName:MC(a),...CC(a)}),OC=/\s+/,kC=(a,l)=>{const{parseClassName:o,getClassGroupId:i,getConflictingClassGroupIds:u}=l,d=[],h=a.trim().split(OC);let p="";for(let g=h.length-1;g>=0;g-=1){const v=h[g],{modifiers:x,hasImportantModifier:y,baseClassName:S,maybePostfixModifierPosition:w}=o(v);let C=!!w,E=i(C?S.substring(0,w):S);if(!E){if(!C){p=v+(p.length>0?" "+p:p);continue}if(E=i(S),!E){p=v+(p.length>0?" "+p:p);continue}C=!1}const j=DC(x).join(":"),N=y?j+a0:j,M=N+E;if(d.includes(M))continue;d.push(M);const T=u(E,C);for(let _=0;_<T.length;++_){const O=T[_];d.push(N+O)}p=v+(p.length>0?" "+p:p)}return p};function zC(){let a=0,l,o,i="";for(;a<arguments.length;)(l=arguments[a++])&&(o=l0(l))&&(i&&(i+=" "),i+=o);return i}const l0=a=>{if(typeof a=="string")return a;let l,o="";for(let i=0;i<a.length;i++)a[i]&&(l=l0(a[i]))&&(o&&(o+=" "),o+=l);return o};function LC(a,...l){let o,i,u,d=h;function h(g){const v=l.reduce((x,y)=>y(x),a());return o=_C(v),i=o.cache.get,u=o.cache.set,d=p,p(g)}function p(g){const v=i(g);if(v)return v;const x=kC(g,o);return u(g,x),x}return function(){return d(zC.apply(null,arguments))}}const dt=a=>{const l=o=>o[a]||[];return l.isThemeGetter=!0,l},r0=/^\[(?:([a-z-]+):)?(.+)\]$/i,UC=/^\d+\/\d+$/,BC=new Set(["px","full","screen"]),HC=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,PC=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,qC=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,IC=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,VC=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ya=a=>fs(a)||BC.has(a)||UC.test(a),Dl=a=>Ss(a,"length",ZC),fs=a=>!!a&&!Number.isNaN(Number(a)),Rf=a=>Ss(a,"number",fs),So=a=>!!a&&Number.isInteger(Number(a)),GC=a=>a.endsWith("%")&&fs(a.slice(0,-1)),ke=a=>r0.test(a),_l=a=>HC.test(a),YC=new Set(["length","size","percentage"]),$C=a=>Ss(a,YC,s0),KC=a=>Ss(a,"position",s0),XC=new Set(["image","url"]),FC=a=>Ss(a,XC,WC),QC=a=>Ss(a,"",JC),wo=()=>!0,Ss=(a,l,o)=>{const i=r0.exec(a);return i?i[1]?typeof l=="string"?i[1]===l:l.has(i[1]):o(i[2]):!1},ZC=a=>PC.test(a)&&!qC.test(a),s0=()=>!1,JC=a=>IC.test(a),WC=a=>VC.test(a),eE=()=>{const a=dt("colors"),l=dt("spacing"),o=dt("blur"),i=dt("brightness"),u=dt("borderColor"),d=dt("borderRadius"),h=dt("borderSpacing"),p=dt("borderWidth"),g=dt("contrast"),v=dt("grayscale"),x=dt("hueRotate"),y=dt("invert"),S=dt("gap"),w=dt("gradientColorStops"),C=dt("gradientColorStopPositions"),E=dt("inset"),j=dt("margin"),N=dt("opacity"),M=dt("padding"),T=dt("saturate"),_=dt("scale"),O=dt("sepia"),A=dt("skew"),H=dt("space"),z=dt("translate"),K=()=>["auto","contain","none"],se=()=>["auto","hidden","clip","visible","scroll"],X=()=>["auto",ke,l],I=()=>[ke,l],re=()=>["",Ya,Dl],ee=()=>["auto",fs,ke],oe=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],U=()=>["solid","dashed","dotted","double","none"],$=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],le=()=>["start","end","center","between","around","evenly","stretch"],B=()=>["","0",ke],Z=()=>["auto","avoid","all","avoid-page","page","left","right","column"],D=()=>[fs,ke];return{cacheSize:500,separator:":",theme:{colors:[wo],spacing:[Ya,Dl],blur:["none","",_l,ke],brightness:D(),borderColor:[a],borderRadius:["none","","full",_l,ke],borderSpacing:I(),borderWidth:re(),contrast:D(),grayscale:B(),hueRotate:D(),invert:B(),gap:I(),gradientColorStops:[a],gradientColorStopPositions:[GC,Dl],inset:X(),margin:X(),opacity:D(),padding:I(),saturate:D(),scale:D(),sepia:B(),skew:D(),space:I(),translate:I()},classGroups:{aspect:[{aspect:["auto","square","video",ke]}],container:["container"],columns:[{columns:[_l]}],"break-after":[{"break-after":Z()}],"break-before":[{"break-before":Z()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...oe(),ke]}],overflow:[{overflow:se()}],"overflow-x":[{"overflow-x":se()}],"overflow-y":[{"overflow-y":se()}],overscroll:[{overscroll:K()}],"overscroll-x":[{"overscroll-x":K()}],"overscroll-y":[{"overscroll-y":K()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[E]}],"inset-x":[{"inset-x":[E]}],"inset-y":[{"inset-y":[E]}],start:[{start:[E]}],end:[{end:[E]}],top:[{top:[E]}],right:[{right:[E]}],bottom:[{bottom:[E]}],left:[{left:[E]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",So,ke]}],basis:[{basis:X()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ke]}],grow:[{grow:B()}],shrink:[{shrink:B()}],order:[{order:["first","last","none",So,ke]}],"grid-cols":[{"grid-cols":[wo]}],"col-start-end":[{col:["auto",{span:["full",So,ke]},ke]}],"col-start":[{"col-start":ee()}],"col-end":[{"col-end":ee()}],"grid-rows":[{"grid-rows":[wo]}],"row-start-end":[{row:["auto",{span:[So,ke]},ke]}],"row-start":[{"row-start":ee()}],"row-end":[{"row-end":ee()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ke]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ke]}],gap:[{gap:[S]}],"gap-x":[{"gap-x":[S]}],"gap-y":[{"gap-y":[S]}],"justify-content":[{justify:["normal",...le()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...le(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...le(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[M]}],px:[{px:[M]}],py:[{py:[M]}],ps:[{ps:[M]}],pe:[{pe:[M]}],pt:[{pt:[M]}],pr:[{pr:[M]}],pb:[{pb:[M]}],pl:[{pl:[M]}],m:[{m:[j]}],mx:[{mx:[j]}],my:[{my:[j]}],ms:[{ms:[j]}],me:[{me:[j]}],mt:[{mt:[j]}],mr:[{mr:[j]}],mb:[{mb:[j]}],ml:[{ml:[j]}],"space-x":[{"space-x":[H]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[H]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ke,l]}],"min-w":[{"min-w":[ke,l,"min","max","fit"]}],"max-w":[{"max-w":[ke,l,"none","full","min","max","fit","prose",{screen:[_l]},_l]}],h:[{h:[ke,l,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ke,l,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ke,l,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ke,l,"auto","min","max","fit"]}],"font-size":[{text:["base",_l,Dl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Rf]}],"font-family":[{font:[wo]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",ke]}],"line-clamp":[{"line-clamp":["none",fs,Rf]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Ya,ke]}],"list-image":[{"list-image":["none",ke]}],"list-style-type":[{list:["none","disc","decimal",ke]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[a]}],"placeholder-opacity":[{"placeholder-opacity":[N]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[a]}],"text-opacity":[{"text-opacity":[N]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...U(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Ya,Dl]}],"underline-offset":[{"underline-offset":["auto",Ya,ke]}],"text-decoration-color":[{decoration:[a]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ke]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ke]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[N]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...oe(),KC]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",$C]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},FC]}],"bg-color":[{bg:[a]}],"gradient-from-pos":[{from:[C]}],"gradient-via-pos":[{via:[C]}],"gradient-to-pos":[{to:[C]}],"gradient-from":[{from:[w]}],"gradient-via":[{via:[w]}],"gradient-to":[{to:[w]}],rounded:[{rounded:[d]}],"rounded-s":[{"rounded-s":[d]}],"rounded-e":[{"rounded-e":[d]}],"rounded-t":[{"rounded-t":[d]}],"rounded-r":[{"rounded-r":[d]}],"rounded-b":[{"rounded-b":[d]}],"rounded-l":[{"rounded-l":[d]}],"rounded-ss":[{"rounded-ss":[d]}],"rounded-se":[{"rounded-se":[d]}],"rounded-ee":[{"rounded-ee":[d]}],"rounded-es":[{"rounded-es":[d]}],"rounded-tl":[{"rounded-tl":[d]}],"rounded-tr":[{"rounded-tr":[d]}],"rounded-br":[{"rounded-br":[d]}],"rounded-bl":[{"rounded-bl":[d]}],"border-w":[{border:[p]}],"border-w-x":[{"border-x":[p]}],"border-w-y":[{"border-y":[p]}],"border-w-s":[{"border-s":[p]}],"border-w-e":[{"border-e":[p]}],"border-w-t":[{"border-t":[p]}],"border-w-r":[{"border-r":[p]}],"border-w-b":[{"border-b":[p]}],"border-w-l":[{"border-l":[p]}],"border-opacity":[{"border-opacity":[N]}],"border-style":[{border:[...U(),"hidden"]}],"divide-x":[{"divide-x":[p]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[p]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[N]}],"divide-style":[{divide:U()}],"border-color":[{border:[u]}],"border-color-x":[{"border-x":[u]}],"border-color-y":[{"border-y":[u]}],"border-color-s":[{"border-s":[u]}],"border-color-e":[{"border-e":[u]}],"border-color-t":[{"border-t":[u]}],"border-color-r":[{"border-r":[u]}],"border-color-b":[{"border-b":[u]}],"border-color-l":[{"border-l":[u]}],"divide-color":[{divide:[u]}],"outline-style":[{outline:["",...U()]}],"outline-offset":[{"outline-offset":[Ya,ke]}],"outline-w":[{outline:[Ya,Dl]}],"outline-color":[{outline:[a]}],"ring-w":[{ring:re()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[a]}],"ring-opacity":[{"ring-opacity":[N]}],"ring-offset-w":[{"ring-offset":[Ya,Dl]}],"ring-offset-color":[{"ring-offset":[a]}],shadow:[{shadow:["","inner","none",_l,QC]}],"shadow-color":[{shadow:[wo]}],opacity:[{opacity:[N]}],"mix-blend":[{"mix-blend":[...$(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":$()}],filter:[{filter:["","none"]}],blur:[{blur:[o]}],brightness:[{brightness:[i]}],contrast:[{contrast:[g]}],"drop-shadow":[{"drop-shadow":["","none",_l,ke]}],grayscale:[{grayscale:[v]}],"hue-rotate":[{"hue-rotate":[x]}],invert:[{invert:[y]}],saturate:[{saturate:[T]}],sepia:[{sepia:[O]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[o]}],"backdrop-brightness":[{"backdrop-brightness":[i]}],"backdrop-contrast":[{"backdrop-contrast":[g]}],"backdrop-grayscale":[{"backdrop-grayscale":[v]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[x]}],"backdrop-invert":[{"backdrop-invert":[y]}],"backdrop-opacity":[{"backdrop-opacity":[N]}],"backdrop-saturate":[{"backdrop-saturate":[T]}],"backdrop-sepia":[{"backdrop-sepia":[O]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[h]}],"border-spacing-x":[{"border-spacing-x":[h]}],"border-spacing-y":[{"border-spacing-y":[h]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ke]}],duration:[{duration:D()}],ease:[{ease:["linear","in","out","in-out",ke]}],delay:[{delay:D()}],animate:[{animate:["none","spin","ping","pulse","bounce",ke]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[_]}],"scale-x":[{"scale-x":[_]}],"scale-y":[{"scale-y":[_]}],rotate:[{rotate:[So,ke]}],"translate-x":[{"translate-x":[z]}],"translate-y":[{"translate-y":[z]}],"skew-x":[{"skew-x":[A]}],"skew-y":[{"skew-y":[A]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ke]}],accent:[{accent:["auto",a]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ke]}],"caret-color":[{caret:[a]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ke]}],fill:[{fill:[a,"none"]}],"stroke-w":[{stroke:[Ya,Dl,Rf]}],stroke:[{stroke:[a,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},tE=LC(eE);function Re(...a){return tE(t0(a))}function Mt(a,l="—"){return a==null||Number.isNaN(a)?l:a.toLocaleString()}function kc(a,l=1,o="—"){return a==null||Number.isNaN(a)?o:`${(a*100).toFixed(l)}%`}function dr(a){return a?a<1e3?`${Math.round(a)} ms`:`${(a/1e3).toFixed(2)} s`:"—"}function Ah(a){if(!a)return"—";try{return new Date(a).toLocaleString()}catch{return a}}function nE(a,l=8){return a?a.length>l?`${a.slice(0,l)}…`:a:"—"}function aE(a){if(!a)return"—";const l=Date.now()-new Date(a).getTime();if(!Number.isFinite(l)||l<0)return"—";const o=Math.floor(l/1e3);if(o<60)return`${o}s ago`;const i=Math.floor(o/60);if(i<60)return`${i}m ago`;const u=Math.floor(i/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}const lE=[{to:"/",label:"Dashboard",icon:Fy,end:!0},{to:"/providers",label:"Providers",icon:Jy},{to:"/models",label:"Models",icon:W2},{to:"/combos",label:"Combos",icon:Zy},{to:"/aliases",label:"Aliases",icon:lC},{to:"/api-keys",label:"API Keys",icon:Qy},{to:"/requests",label:"Requests",icon:$y},{to:"/statistics",label:"Statistics",icon:cC},{to:"/audit",label:"Audit Logs",icon:vC},{to:"/settings",label:"Settings",icon:rC}];function rE(){const[a,l]=m.useState(null);return m.useEffect(()=>{let o=!1;return fetch("/api/admin/settings/system",{credentials:"include"}).then(i=>i.ok?i.json():null).then(i=>{!o&&(i!=null&&i.appVersion)&&l(i.appVersion)}).catch(()=>{}),()=>{o=!0}},[]),s.jsxs("aside",{className:"hidden w-60 shrink-0 border-r bg-sidebar text-sidebar-foreground md:flex md:flex-col",children:[s.jsxs("div",{className:"flex h-14 items-center gap-2 border-b px-4",children:[s.jsx("img",{src:"/logo.png",alt:"LateDev Router",className:"h-7 w-7 object-contain"}),s.jsx("div",{className:"font-semibold tracking-tight",children:"LateDev Router"})]}),s.jsx("nav",{className:"flex-1 space-y-0.5 p-2",children:lE.map(o=>s.jsxs(Iy,{to:o.to,end:o.end,className:({isActive:i})=>Re("flex items-center gap-2 rounded-md px-3 py-2 text-sm transition-colors",i?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[s.jsx(o.icon,{className:"h-4 w-4"}),o.label]},o.to))}),s.jsxs("div",{className:"border-t p-3 text-xs text-muted-foreground flex items-center gap-2",children:[s.jsx(xC,{className:"h-3.5 w-3.5 text-primary"})," ",a?`v${a}`:"v…"]})]})}var sE=Object.defineProperty,Mh=(a,l)=>sE(a,"name",{value:l,configurable:!0});function Yf(a,l){if(typeof a=="function")return a(l);a!=null&&(a.current=l)}Mh(Yf,"setRef");function o0(...a){return l=>{let o=!1;const i=a.map(u=>{const d=Yf(u,l);return!o&&typeof d=="function"&&(o=!0),d});if(o)return()=>{for(let u=0;u<i.length;u++){const d=i[u];typeof d=="function"?d():Yf(a[u],null)}}}}Mh(o0,"composeRefs");function Ie(...a){return m.useCallback(o0(...a),a)}Mh(Ie,"useComposedRefs");var oE=Object.defineProperty,ra=(a,l)=>oE(a,"name",{value:l,configurable:!0});function va(a){const l=m.forwardRef((o,i)=>{let{children:u,...d}=o,h=null,p=!1;const g=[];$f(u)&&typeof tc=="function"&&(u=tc(u._payload)),m.Children.forEach(u,S=>{var w;if(f0(S)){p=!0;const C=S;let E="child"in C.props?C.props.child:C.props.children;$f(E)&&typeof tc=="function"&&(E=tc(E._payload)),h=cE(C,E),g.push((w=h==null?void 0:h.props)==null?void 0:w.children)}else g.push(S)}),h?h=m.cloneElement(h,void 0,g):!p&&m.Children.count(u)===1&&m.isValidElement(u)&&(h=u);const v=h?d0(h):void 0,x=Ie(i,v);if(!h){if(u||u===0)throw new Error(p?fE(a):dE(a));return u}const y=u0(d,h.props??{});return h.type!==m.Fragment&&(y.ref=i?x:v),m.cloneElement(h,y)});return l.displayName=`${a}.Slot`,l}ra(va,"createSlot");var iE=va("Slot"),i0=Symbol.for("radix.slottable");function c0(a){const l=ra(o=>"child"in o?o.children(o.child):o.children,"Slottable");return l.displayName=`${a}.Slottable`,l.__radixId=i0,l}ra(c0,"createSlottable");var cE=ra((a,l)=>{if("child"in a.props){const o=a.props.child;return m.isValidElement(o)?m.cloneElement(o,void 0,a.props.children(o.props.children)):null}return m.isValidElement(l)?l:null},"getSlottableElementFromSlottable");function u0(a,l){const o={...l};for(const i in l){const u=a[i],d=l[i];/^on[A-Z]/.test(i)?u&&d?o[i]=(...p)=>{const g=d(...p);return u(...p),g}:u&&(o[i]=u):i==="style"?o[i]={...u,...d}:i==="className"&&(o[i]=[u,d].filter(Boolean).join(" "))}return{...a,...o}}ra(u0,"mergeProps");function d0(a){var i,u;let l=(i=Object.getOwnPropertyDescriptor(a.props,"ref"))==null?void 0:i.get,o=l&&"isReactWarning"in l&&l.isReactWarning;return o?a.ref:(l=(u=Object.getOwnPropertyDescriptor(a,"ref"))==null?void 0:u.get,o=l&&"isReactWarning"in l&&l.isReactWarning,o?a.props.ref:a.props.ref||a.ref)}ra(d0,"getElementRef");function f0(a){return m.isValidElement(a)&&typeof a.type=="function"&&"__radixId"in a.type&&a.type.__radixId===i0}ra(f0,"isSlottable");var uE=Symbol.for("react.lazy");function $f(a){return a!=null&&typeof a=="object"&&"$$typeof"in a&&a.$$typeof===uE&&"_payload"in a&&h0(a._payload)}ra($f,"isLazyComponent");function h0(a){return typeof a=="object"&&a!==null&&"then"in a}ra(h0,"isPromiseLike");var dE=ra(a=>`${a} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),fE=ra(a=>`${a} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),tc=gs[" use ".trim().toString()];const Px=a=>typeof a=="boolean"?`${a}`:a===0?"0":a,qx=t0,m0=(a,l)=>o=>{var i;if((l==null?void 0:l.variants)==null)return qx(a,o==null?void 0:o.class,o==null?void 0:o.className);const{variants:u,defaultVariants:d}=l,h=Object.keys(u).map(v=>{const x=o==null?void 0:o[v],y=d==null?void 0:d[v];if(x===null)return null;const S=Px(x)||Px(y);return u[v][S]}),p=o&&Object.entries(o).reduce((v,x)=>{let[y,S]=x;return S===void 0||(v[y]=S),v},{}),g=l==null||(i=l.compoundVariants)===null||i===void 0?void 0:i.reduce((v,x)=>{let{class:y,className:S,...w}=x;return Object.entries(w).every(C=>{let[E,j]=C;return Array.isArray(j)?j.includes({...d,...p}[E]):{...d,...p}[E]===j})?[...v,y,S]:v},[]);return qx(a,h,g,o==null?void 0:o.class,o==null?void 0:o.className)},hE=m0("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-6",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),he=m.forwardRef(({className:a,variant:l,size:o,asChild:i=!1,...u},d)=>{const h=i?iE:"button";return s.jsx(h,{className:Re(hE({variant:l,size:o,className:a})),ref:d,...u})});he.displayName="Button";const p0=m.createContext(void 0);function mE({children:a,defaultTheme:l="system",storageKey:o="latedev-theme"}){const[i,u]=m.useState(()=>localStorage.getItem(o)||l);m.useEffect(()=>{const h=window.document.documentElement;if(h.classList.remove("light","dark"),i==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";h.classList.add(p);return}h.classList.add(i)},[i]);const d={theme:i,setTheme:h=>{localStorage.setItem(o,h),u(h)}};return s.jsx(p0.Provider,{value:d,children:a})}function pE(){const a=m.useContext(p0);if(!a)throw new Error("useTheme must be used within ThemeProvider");return a}var gE=Object.defineProperty,ws=(a,l)=>gE(a,"name",{value:l,configurable:!0}),g0=!!(typeof window<"u"&&window.document&&window.document.createElement);function Ee(a,l,{checkForDefaultPrevented:o=!0}={}){return ws(function(u){if(a==null||a(u),o===!1||!u||!u.defaultPrevented)return l==null?void 0:l(u)},"handleEvent")}ws(Ee,"composeEventHandlers");function vE(a){var l;if(!g0)throw new Error("Cannot access window outside of the DOM");return((l=a==null?void 0:a.ownerDocument)==null?void 0:l.defaultView)??window}ws(vE,"getOwnerWindow");function Kf(a){if(!g0)throw new Error("Cannot access document outside of the DOM");return(a==null?void 0:a.ownerDocument)??document}ws(Kf,"getOwnerDocument");function v0(a,l=!1){const{activeElement:o}=Kf(a);if(!(o!=null&&o.nodeName))return null;if(x0(o)&&o.contentDocument)return v0(o.contentDocument.body,l);if(l){const i=o.getAttribute("aria-activedescendant");if(i){const u=Kf(o).getElementById(i);if(u)return u}}return o}ws(v0,"getActiveElement");function x0(a){return a.tagName==="IFRAME"}ws(x0,"isFrame");var xE=Object.defineProperty,Pn=(a,l)=>xE(a,"name",{value:l,configurable:!0});function yE(a,l){const o=m.createContext(l);o.displayName=a+"Context";const i=Pn(d=>{const{children:h,...p}=d,g=m.useMemo(()=>p,Object.values(p));return s.jsx(o.Provider,{value:g,children:h})},"Provider");i.displayName=a+"Provider";function u(d,h={}){const{optional:p=!1}=h,g=m.useContext(o);if(g)return g;if(l!==void 0)return l;if(!p)throw new Error(`\`${d}\` must be used within \`${a}\``)}return Pn(u,"useContext"),[i,u]}Pn(yE,"createContext");function fn(a,l=[]){let o=[];function i(d,h){const p=m.createContext(h);p.displayName=d+"Context";const g=o.length;o=[...o,h];const v=Pn(y=>{var N;const{scope:S,children:w,...C}=y,E=((N=S==null?void 0:S[a])==null?void 0:N[g])||p,j=m.useMemo(()=>C,Object.values(C));return s.jsx(E.Provider,{value:j,children:w})},"Provider");v.displayName=d+"Provider";function x(y,S,w={}){var N;const{optional:C=!1}=w,E=((N=S==null?void 0:S[a])==null?void 0:N[g])||p,j=m.useContext(E);if(j)return j;if(h!==void 0)return h;if(!C)throw new Error(`\`${y}\` must be used within \`${d}\``)}return Pn(x,"useContext"),[v,x]}Pn(i,"createContext");const u=Pn(()=>{const d=o.map(h=>m.createContext(h));return Pn(function(p){const g=(p==null?void 0:p[a])||d;return m.useMemo(()=>({[`__scope${a}`]:{...p,[a]:g}}),[p,g])},"useScope")},"createScope");return u.scopeName=a,[i,y0(u,...l)]}Pn(fn,"createContextScope");function y0(...a){const l=a[0];if(a.length===1)return l;const o=Pn(()=>{const i=a.map(u=>({useScope:u(),scopeName:u.scopeName}));return Pn(function(d){const h=i.reduce((p,{useScope:g,scopeName:v})=>{const y=g(d)[`__scope${v}`];return{...p,...y}},{});return m.useMemo(()=>({[`__scope${l.scopeName}`]:h}),[h])},"useComposedScopes")},"createScope");return o.scopeName=l.scopeName,o}Pn(y0,"composeContextScopes");var Dt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},bE=Object.defineProperty,SE=(a,l)=>bE(a,"name",{value:l,configurable:!0}),Ix=gs[" useEffectEvent ".trim().toString()],Vx=gs[" useInsertionEffect ".trim().toString()];function b0(a){if(typeof Ix=="function")return Ix(a);const l=m.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Vx=="function"?Vx(()=>{l.current=a}):Dt(()=>{l.current=a}),m.useMemo(()=>((...o)=>{var i;return(i=l.current)==null?void 0:i.call(l,...o)}),[])}SE(b0,"useEffectEvent");var wE=Object.defineProperty,ko=(a,l)=>wE(a,"name",{value:l,configurable:!0}),jE=gs[" useInsertionEffect ".trim().toString()]||Dt;function Ja({prop:a,defaultProp:l,onChange:o=ko(()=>{},"onChange"),caller:i}){const[u,d,h]=S0({defaultProp:l,onChange:o}),p=a!==void 0,g=p?a:u,v=m.useCallback(x=>{var y;if(p){const S=w0(x)?x(a):x;S!==a&&((y=h.current)==null||y.call(h,S))}else d(x)},[p,a,d,h]);return[g,v]}ko(Ja,"useControllableState");function S0({defaultProp:a,onChange:l}){const[o,i]=m.useState(a),u=m.useRef(o),d=m.useRef(l);return jE(()=>{d.current=l},[l]),m.useEffect(()=>{var h;u.current!==o&&((h=d.current)==null||h.call(d,o),u.current=o)},[o,u]),[o,i,d]}ko(S0,"useUncontrolledState");function w0(a){return typeof a=="function"}ko(w0,"isFunction");var Gx=Symbol("RADIX:SYNC_STATE");function CE(a,l,o,i){const{prop:u,defaultProp:d,onChange:h,caller:p}=l,g=u!==void 0,v=b0(h),x=[{...o,state:d}];i&&x.push(i);const[y,S]=m.useReducer((j,N)=>{if(N.type===Gx)return{...j,state:N.state};const M=a(j,N);return g&&!Object.is(M.state,j.state)&&v(M.state),M},...x),w=y.state,C=m.useRef(w);m.useEffect(()=>{C.current!==w&&(C.current=w,g||v(w))},[w,C,g]);const E=m.useMemo(()=>u!==void 0?{...y,state:u}:y,[y,u]);return m.useEffect(()=>{g&&!Object.is(u,y.state)&&S({type:Gx,state:u})},[u,y.state,g]),[E,S]}ko(CE,"useControllableStateReducer");var EE=Object.defineProperty,RE=(a,l)=>EE(a,"name",{value:l,configurable:!0}),NE=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Be=NE.reduce((a,l)=>{const o=va(`Primitive.${l}`),i=m.forwardRef((u,d)=>{const{asChild:h,...p}=u,g=h?o:l;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(g,{...p,ref:d})});return i.displayName=`Primitive.${l}`,{...a,[l]:i}},{});function Dh(a,l){a&&bs.flushSync(()=>a.dispatchEvent(l))}RE(Dh,"dispatchDiscreteCustomEvent");var TE=Object.defineProperty,zt=(a,l)=>TE(a,"name",{value:l,configurable:!0});function zc(a){const l=a+"CollectionProvider",[o,i]=fn(l),[u,d]=o(l,{collectionRef:{current:null},itemMap:new Map}),h=zt(E=>{const{scope:j,children:N}=E,M=m.useRef(null),T=m.useRef(new Map).current;return s.jsx(u,{scope:j,itemMap:T,collectionRef:M,children:N})},"CollectionProvider");h.displayName=l;const p=a+"CollectionSlot",g=va(p),v=m.forwardRef((E,j)=>{const{scope:N,children:M}=E,T=d(p,N),_=Ie(j,T.collectionRef);return s.jsx(g,{ref:_,children:M})});v.displayName=p;const x=a+"CollectionItemSlot",y="data-radix-collection-item",S=va(x),w=m.forwardRef((E,j)=>{const{scope:N,children:M,...T}=E,_=m.useRef(null),O=Ie(j,_),A=d(x,N);return m.useEffect(()=>(A.itemMap.set(_,{ref:_,...T}),()=>void A.itemMap.delete(_))),s.jsx(S,{[y]:"",ref:O,children:M})});w.displayName=x;function C(E){const j=d(a+"CollectionConsumer",E);return m.useCallback(()=>{const M=j.collectionRef.current;if(!M)return[];const T=Array.from(M.querySelectorAll(`[${y}]`));return Array.from(j.itemMap.values()).sort((A,H)=>T.indexOf(A.ref.current)-T.indexOf(H.ref.current))},[j.collectionRef,j.itemMap])}return zt(C,"useCollection"),[{Provider:h,Slot:v,ItemSlot:w},C,i]}zt(zc,"createCollection");var Yx=new WeakMap,Tt,wn,Nf=(wn=class extends Map{constructor(o){super(o);bx(this,Tt);pf(this,Tt,[...super.keys()]),Yx.set(this,!0)}set(o,i){return Yx.get(this)&&(this.has(o)?Gt(this,Tt)[Gt(this,Tt).indexOf(o)]=o:Gt(this,Tt).push(o)),super.set(o,i),this}insert(o,i,u){const d=this.has(i),h=Gt(this,Tt).length,p=_h(o);let g=p>=0?p:h+p;const v=g<0||g>=h?-1:g;if(v===this.size||d&&v===this.size-1||v===-1)return this.set(i,u),this;const x=this.size+(d?0:1);p<0&&g++;const y=[...Gt(this,Tt)];let S,w=!1;for(let C=g;C<x;C++)if(g===C){let E=y[C];y[C]===i&&(E=y[C+1]),d&&this.delete(i),S=this.get(E),this.set(i,u)}else{!w&&y[C-1]===i&&(w=!0);const E=y[w?C:C-1],j=S;S=this.get(E),this.delete(E),this.set(E,j)}return this}with(o,i,u){const d=new wn(this);return d.insert(o,i,u),d}before(o){const i=Gt(this,Tt).indexOf(o)-1;if(!(i<0))return this.entryAt(i)}setBefore(o,i,u){const d=Gt(this,Tt).indexOf(o);return d===-1?this:this.insert(d,i,u)}after(o){let i=Gt(this,Tt).indexOf(o);if(i=i===-1||i===this.size-1?-1:i+1,i!==-1)return this.entryAt(i)}setAfter(o,i,u){const d=Gt(this,Tt).indexOf(o);return d===-1?this:this.insert(d+1,i,u)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return pf(this,Tt,[]),super.clear()}delete(o){const i=super.delete(o);return i&&Gt(this,Tt).splice(Gt(this,Tt).indexOf(o),1),i}deleteAt(o){const i=this.keyAt(o);return i!==void 0?this.delete(i):!1}at(o){const i=gc(Gt(this,Tt),o);if(i!==void 0)return this.get(i)}entryAt(o){const i=gc(Gt(this,Tt),o);if(i!==void 0)return[i,this.get(i)]}indexOf(o){return Gt(this,Tt).indexOf(o)}keyAt(o){return gc(Gt(this,Tt),o)}from(o,i){const u=this.indexOf(o);if(u===-1)return;let d=u+i;return d<0&&(d=0),d>=this.size&&(d=this.size-1),this.at(d)}keyFrom(o,i){const u=this.indexOf(o);if(u===-1)return;let d=u+i;return d<0&&(d=0),d>=this.size&&(d=this.size-1),this.keyAt(d)}find(o,i){let u=0;for(const d of this){if(Reflect.apply(o,i,[d,u,this]))return d;u++}}findIndex(o,i){let u=0;for(const d of this){if(Reflect.apply(o,i,[d,u,this]))return u;u++}return-1}filter(o,i){const u=[];let d=0;for(const h of this)Reflect.apply(o,i,[h,d,this])&&u.push(h),d++;return new wn(u)}map(o,i){const u=[];let d=0;for(const h of this)u.push([h[0],Reflect.apply(o,i,[h,d,this])]),d++;return new wn(u)}reduce(...o){const[i,u]=o;let d=0,h=u??this.at(0);for(const p of this)d===0&&o.length===1?h=p:h=Reflect.apply(i,this,[h,p,d,this]),d++;return h}reduceRight(...o){const[i,u]=o;let d=u??this.at(-1);for(let h=this.size-1;h>=0;h--){const p=this.at(h);h===this.size-1&&o.length===1?d=p:d=Reflect.apply(i,this,[d,p,h,this])}return d}toSorted(o){const i=[...this.entries()].sort(o);return new wn(i)}toReversed(){const o=new wn;for(let i=this.size-1;i>=0;i--){const u=this.keyAt(i),d=this.get(u);o.set(u,d)}return o}toSpliced(...o){const i=[...this.entries()];return i.splice(...o),new wn(i)}slice(o,i){const u=new wn;let d=this.size-1;if(o===void 0)return u;o<0&&(o=o+this.size),i!==void 0&&i>0&&(d=i-1);for(let h=o;h<=d;h++){const p=this.keyAt(h),g=this.get(p);u.set(p,g)}return u}every(o,i){let u=0;for(const d of this){if(!Reflect.apply(o,i,[d,u,this]))return!1;u++}return!0}some(o,i){let u=0;for(const d of this){if(Reflect.apply(o,i,[d,u,this]))return!0;u++}return!1}},Tt=new WeakMap,zt(wn,"OrderedDict"),wn);function gc(a,l){if("at"in Array.prototype)return Array.prototype.at.call(a,l);const o=j0(a,l);return o===-1?void 0:a[o]}zt(gc,"at");function j0(a,l){const o=a.length,i=_h(l),u=i>=0?i:o+i;return u<0||u>=o?-1:u}zt(j0,"toSafeIndex");function _h(a){return a!==a||a===0?0:Math.trunc(a)}zt(_h,"toSafeInteger");function AE(a){const l=a+"CollectionProvider",[o,i]=fn(l),[u,d]=o(l,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Nf,setItemMap:zt(()=>{},"setItemMap")}),h=zt(({state:T,..._})=>T?s.jsx(g,{..._,state:T}):s.jsx(p,{..._}),"CollectionProvider");h.displayName=l;const p=zt(T=>{const _=j();return s.jsx(g,{...T,state:_})},"CollectionInit");p.displayName=l+"Init";const g=zt(T=>{const{scope:_,children:O,state:A}=T,H=m.useRef(null),[z,K]=m.useState(null),se=Ie(H,K),[X,I]=A;return m.useEffect(()=>{if(!z)return;const re=R0(()=>{});return re.observe(z,{childList:!0,subtree:!0}),()=>{re.disconnect()}},[z]),s.jsx(u,{scope:_,itemMap:X,setItemMap:I,collectionRef:se,collectionRefObject:H,collectionElement:z,children:O})},"CollectionProviderImpl");g.displayName=l+"Impl";const v=a+"CollectionSlot",x=va(v),y=m.forwardRef((T,_)=>{const{scope:O,children:A}=T,H=d(v,O),z=Ie(_,H.collectionRef);return s.jsx(x,{ref:z,children:A})});y.displayName=v;const S=a+"CollectionItemSlot",w="data-radix-collection-item",C=va(S),E=m.forwardRef((T,_)=>{const{scope:O,children:A,...H}=T,z=m.useRef(null),[K,se]=m.useState(null),X=Ie(_,z,se),I=d(S,O),{setItemMap:re}=I,ee=m.useRef(H);C0(ee.current,H)||(ee.current=H);const oe=ee.current;return m.useEffect(()=>{const U=oe;return re($=>K?$.has(K)?$.set(K,{...U,element:K}).toSorted(Xf):($.set(K,{...U,element:K}),$.toSorted(Xf)):$),()=>{re($=>!K||!$.has(K)?$:($.delete(K),new Nf($)))}},[K,oe,re]),s.jsx(C,{[w]:"",ref:X,children:A})});E.displayName=S;function j(){return m.useState(new Nf)}zt(j,"useInitCollection");function N(T){const{itemMap:_}=d(a+"CollectionConsumer",T);return _}return zt(N,"useCollection"),[{Provider:h,Slot:y,ItemSlot:E},{createCollectionScope:i,useCollection:N,useInitCollection:j}]}zt(AE,"createCollection");function C0(a,l){if(a===l)return!0;if(typeof a!="object"||typeof l!="object"||a==null||l==null)return!1;const o=Object.keys(a),i=Object.keys(l);if(o.length!==i.length)return!1;for(const u of o)if(!Object.prototype.hasOwnProperty.call(l,u)||a[u]!==l[u])return!1;return!0}zt(C0,"shallowEqual");function E0(a,l){return!!(l.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_PRECEDING)}zt(E0,"isElementPreceding");function Xf(a,l){return!a[1].element||!l[1].element?0:E0(a[1].element,l[1].element)?-1:1}zt(Xf,"sortByDocumentPosition");function R0(a){return new MutationObserver(o=>{for(const i of o)if(i.type==="childList"){a();return}})}zt(R0,"getChildListObserver");var ME=Object.defineProperty,DE=(a,l)=>ME(a,"name",{value:l,configurable:!0}),_E=m.createContext(void 0);function zo(a){const l=m.useContext(_E);return a||l||"ltr"}DE(zo,"useDirection");var OE=Object.defineProperty,kE=(a,l)=>OE(a,"name",{value:l,configurable:!0});function $n(a){const l=m.useRef(a);return m.useEffect(()=>{l.current=a}),m.useMemo(()=>((...o)=>{var i;return(i=l.current)==null?void 0:i.call(l,...o)}),[])}kE($n,"useCallbackRef");var zE=Object.defineProperty,kt=(a,l)=>zE(a,"name",{value:l,configurable:!0}),Ff="dismissableLayer.update",LE="dismissableLayer.pointerDownOutside",UE="dismissableLayer.focusOutside",$x,N0=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Lc=m.forwardRef(kt(function(l,o){const{disableOutsidePointerEvents:i=!1,deferPointerDownOutside:u=!1,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:g,onDismiss:v,...x}=l,y=m.useContext(N0),[S,w]=m.useState(null),C=(S==null?void 0:S.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,E]=m.useState({}),j=Ie(o,w),N=Array.from(y.layers),[M]=[...y.layersWithOutsidePointerEventsDisabled].slice(-1),T=M?N.indexOf(M):-1,_=S?N.indexOf(S):-1,O=y.layersWithOutsidePointerEventsDisabled.size>0,A=_>=T,H=m.useRef(!1),z=A0(I=>{h==null||h(I),g==null||g(I),I.defaultPrevented||v==null||v()},{ownerDocument:C,deferPointerDownOutside:u,isDeferredPointerDownOutsideRef:H,dismissableSurfaces:y.dismissableSurfaces,shouldHandlePointerDownOutside:m.useCallback(I=>{if(!(I instanceof Node))return!1;const re=[...y.branches].some(ee=>ee.contains(I));return A&&!re},[y.branches,A])}),K=M0(I=>{if(u&&H.current)return;const re=I.target;[...y.branches].some(oe=>oe.contains(re))||(p==null||p(I),g==null||g(I),I.defaultPrevented||v==null||v())},C),se=S?_===N.length-1:!1,X=$n(I=>{I.key==="Escape"&&(d==null||d(I),!I.defaultPrevented&&v&&(I.preventDefault(),v()))});return m.useEffect(()=>{if(se)return C.addEventListener("keydown",X,{capture:!0}),()=>C.removeEventListener("keydown",X,{capture:!0})},[C,se,X]),m.useEffect(()=>{if(S)return i&&(y.layersWithOutsidePointerEventsDisabled.size===0&&($x=C.body.style.pointerEvents,C.body.style.pointerEvents="none"),y.layersWithOutsidePointerEventsDisabled.add(S)),y.layers.add(S),Qf(),()=>{i&&(y.layersWithOutsidePointerEventsDisabled.delete(S),y.layersWithOutsidePointerEventsDisabled.size===0&&(C.body.style.pointerEvents=$x))}},[S,C,i,y]),m.useEffect(()=>()=>{S&&(y.layers.delete(S),y.layersWithOutsidePointerEventsDisabled.delete(S),Qf())},[S,y]),m.useEffect(()=>{const I=kt(()=>E({}),"handleUpdate");return document.addEventListener(Ff,I),()=>document.removeEventListener(Ff,I)},[]),s.jsx(Be.div,{...x,ref:j,style:{pointerEvents:O?A?"auto":"none":void 0,...l.style},onFocusCapture:Ee(l.onFocusCapture,K.onFocusCapture),onBlurCapture:Ee(l.onBlurCapture,K.onBlurCapture),onPointerDownCapture:Ee(l.onPointerDownCapture,z.onPointerDownCapture)})},"DismissableLayer"));function T0(){const a=m.useContext(N0),[l,o]=m.useState(null);return m.useEffect(()=>{if(l)return a.dismissableSurfaces.add(l),()=>{a.dismissableSurfaces.delete(l)}},[l,a.dismissableSurfaces]),o}kt(T0,"useDismissableLayerSurface");var BE=kt(()=>!0,"IS_TRUE");function A0(a,l){const{ownerDocument:o=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:i=!1,isDeferredPointerDownOutsideRef:u,dismissableSurfaces:d,shouldHandlePointerDownOutside:h=BE}=l,p=$n(a),g=m.useRef(!1),v=m.useRef(!1),x=m.useRef(new Map),y=m.useRef(()=>{});return m.useEffect(()=>{function S(){v.current=!1,u.current=!1,x.current.clear()}kt(S,"resetOutsideInteraction");function w(){return Array.from(x.current.values()).some(Boolean)}kt(w,"isOutsideInteractionIntercepted");function C(T){if(!v.current)return;const _=T.target;_ instanceof Node&&[...d].some(A=>A.contains(_))||x.current.set(T.type,!0),T.type==="click"&&window.setTimeout(()=>{v.current&&y.current()},0)}kt(C,"handleInteractionCapture");function E(T){v.current&&x.current.set(T.type,!1)}kt(E,"handleInteractionBubble");const j=kt(T=>{if(T.target&&!g.current){let _=function(){o.removeEventListener("click",y.current);const A=w();S(),A||Oh(LE,p,O,{discrete:!0})};if(kt(_,"handleAndDispatchPointerDownOutsideEvent"),!h(T.target)){o.removeEventListener("click",y.current),S(),g.current=!1;return}const O={originalEvent:T};v.current=!0,u.current=i&&T.button===0,x.current.clear(),!i||T.button!==0?_():(o.removeEventListener("click",y.current),y.current=_,o.addEventListener("click",y.current,{once:!0}))}else o.removeEventListener("click",y.current),S();g.current=!1},"handlePointerDown"),N=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const T of N)o.addEventListener(T,C,!0),o.addEventListener(T,E);const M=window.setTimeout(()=>{o.addEventListener("pointerdown",j)},0);return()=>{window.clearTimeout(M),o.removeEventListener("pointerdown",j),o.removeEventListener("click",y.current);for(const T of N)o.removeEventListener(T,C,!0),o.removeEventListener(T,E)}},[o,p,i,u,d,h]),{onPointerDownCapture:kt(()=>g.current=!0,"onPointerDownCapture")}}kt(A0,"usePointerDownOutside");function M0(a,l=globalThis==null?void 0:globalThis.document){const o=$n(a),i=m.useRef(!1);return m.useEffect(()=>{const u=kt(d=>{d.target&&!i.current&&Oh(UE,o,{originalEvent:d},{discrete:!1})},"handleFocus");return l.addEventListener("focusin",u),()=>l.removeEventListener("focusin",u)},[l,o]),{onFocusCapture:kt(()=>i.current=!0,"onFocusCapture"),onBlurCapture:kt(()=>i.current=!1,"onBlurCapture")}}kt(M0,"useFocusOutside");function Qf(){const a=new CustomEvent(Ff);document.dispatchEvent(a)}kt(Qf,"dispatchUpdate");function Oh(a,l,o,{discrete:i}){const u=o.originalEvent.target,d=new CustomEvent(a,{bubbles:!1,cancelable:!0,detail:o});l&&u.addEventListener(a,l,{once:!0}),i?Dh(u,d):u.dispatchEvent(d)}kt(Oh,"handleAndDispatchCustomEvent");var HE=Object.defineProperty,kh=(a,l)=>HE(a,"name",{value:l,configurable:!0}),nc=0,ha=null;function PE(a){return Lo(),a.children}kh(PE,"FocusGuards");function Lo(){m.useEffect(()=>{ha||(ha={start:Zf(),end:Zf()});const{start:a,end:l}=ha;return document.body.firstElementChild!==a&&document.body.insertAdjacentElement("afterbegin",a),document.body.lastElementChild!==l&&document.body.insertAdjacentElement("beforeend",l),nc++,()=>{nc===1&&(ha==null||ha.start.remove(),ha==null||ha.end.remove(),ha=null),nc=Math.max(0,nc-1)}},[])}kh(Lo,"useFocusGuards");function Zf(){const a=document.createElement("span");return a.setAttribute("data-radix-focus-guard",""),a.tabIndex=0,a.style.outline="none",a.style.opacity="0",a.style.position="fixed",a.style.pointerEvents="none",a}kh(Zf,"createFocusGuard");var qE=Object.defineProperty,Qt=(a,l)=>qE(a,"name",{value:l,configurable:!0}),Tf="focusScope.autoFocusOnMount",Af="focusScope.autoFocusOnUnmount",Kx={bubbles:!1,cancelable:!0},zh=m.forwardRef(Qt(function(l,o){const{loop:i=!1,trapped:u=!1,onMountAutoFocus:d,onUnmountAutoFocus:h,...p}=l,[g,v]=m.useState(null),x=$n(d),y=$n(h),S=m.useRef(null),w=Ie(o,v),C=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(u){let j=function(_){if(C.paused||!g)return;const O=_.target;g.contains(O)?S.current=O:$a(S.current,{select:!0})},N=function(_){if(C.paused||!g)return;const O=_.relatedTarget;O!==null&&(g.contains(O)||$a(S.current,{select:!0}))},M=function(_){if(document.activeElement===document.body)for(const A of _)A.removedNodes.length>0&&$a(g)};Qt(j,"handleFocusIn"),Qt(N,"handleFocusOut"),Qt(M,"handleMutations"),document.addEventListener("focusin",j),document.addEventListener("focusout",N);const T=new MutationObserver(M);return g&&T.observe(g,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",N),T.disconnect()}}},[u,g,C.paused]),m.useEffect(()=>{if(g){Xx.add(C);const j=document.activeElement;if(!g.contains(j)){const M=new CustomEvent(Tf,Kx);g.addEventListener(Tf,x),g.dispatchEvent(M),M.defaultPrevented||(D0(L0(Lh(g)),{select:!0}),document.activeElement===j&&$a(g))}return()=>{g.removeEventListener(Tf,x),setTimeout(()=>{const M=new CustomEvent(Af,Kx);g.addEventListener(Af,y),g.dispatchEvent(M),M.defaultPrevented||$a(j??document.body,{select:!0}),g.removeEventListener(Af,y),Xx.remove(C)},0)}}},[g,x,y,C]);const E=m.useCallback(j=>{if(!i&&!u||C.paused)return;const N=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,M=document.activeElement;if(N&&M){const T=j.currentTarget,[_,O]=_0(T);_&&O?!j.shiftKey&&M===O?(j.preventDefault(),i&&$a(_,{select:!0})):j.shiftKey&&M===_&&(j.preventDefault(),i&&$a(O,{select:!0})):M===T&&j.preventDefault()}},[i,u,C.paused]);return s.jsx(Be.div,{tabIndex:-1,...p,ref:w,onKeyDown:E})},"FocusScope"));function D0(a,{select:l=!1}={}){const o=document.activeElement;for(const i of a)if($a(i,{select:l}),document.activeElement!==o)return}Qt(D0,"focusFirst");function _0(a){const l=Lh(a),o=Jf(l,a),i=Jf(l.reverse(),a);return[o,i]}Qt(_0,"getTabbableEdges");function Lh(a){const l=[],o=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,{acceptNode:Qt(i=>{const u=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||u?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;o.nextNode();)l.push(o.currentNode);return l}Qt(Lh,"getTabbableCandidates");function Jf(a,l){const o=typeof l.checkVisibility=="function"&&l.checkVisibility({checkVisibilityCSS:!0});for(const i of a)if(!(o?!i.checkVisibility({checkVisibilityCSS:!0}):O0(i,{upTo:l})))return i}Qt(Jf,"findVisible");function O0(a,{upTo:l}){if(getComputedStyle(a).visibility==="hidden")return!0;for(;a;){if(l!==void 0&&a===l)return!1;if(getComputedStyle(a).display==="none")return!0;a=a.parentElement}return!1}Qt(O0,"isHidden");function k0(a){return a instanceof HTMLInputElement&&"select"in a}Qt(k0,"isSelectableInput");function $a(a,{select:l=!1}={}){if(a&&a.focus){const o=document.activeElement;a.focus({preventScroll:!0}),a!==o&&k0(a)&&l&&a.select()}}Qt($a,"focus");var Xx=z0();function z0(){let a=[];return{add(l){const o=a[0];l!==o&&(o==null||o.pause()),a=Wf(a,l),a.unshift(l)},remove(l){var o;a=Wf(a,l),(o=a[0])==null||o.resume()}}}Qt(z0,"createFocusScopesStack");function Wf(a,l){const o=[...a],i=o.indexOf(l);return i!==-1&&o.splice(i,1),o}Qt(Wf,"arrayRemove");function L0(a){return a.filter(l=>l.tagName!=="A")}Qt(L0,"removeLinks");var IE=Object.defineProperty,VE=(a,l)=>IE(a,"name",{value:l,configurable:!0}),GE=gs[" useId ".trim().toString()]||(()=>{}),YE=0;function ga(a){const[l,o]=m.useState(GE());return Dt(()=>{a||o(i=>i??String(YE++))},[a]),a||(l?`radix-${l}`:"")}VE(ga,"useId");const $E=["top","right","bottom","left"],Bl=Math.min,Xa=Math.max,wc=Math.round,ac=Math.floor,Fa=a=>({x:a,y:a}),KE={left:"right",right:"left",bottom:"top",top:"bottom"};function U0(a,l,o){return Xa(a,Bl(l,o))}function Wa(a,l){return typeof a=="function"?a(l):a}function Hl(a){return a.split("-")[0]}function js(a){return a.split("-")[1]}function Uh(a){return a==="x"?"y":"x"}function Bh(a){return a==="y"?"height":"width"}function pa(a){const l=a[0];return l==="t"||l==="b"?"y":"x"}function Hh(a){return Uh(pa(a))}function XE(a,l,o){o===void 0&&(o=!1);const i=js(a),u=Hh(a),d=Bh(u);let h=u==="x"?i===(o?"end":"start")?"right":"left":i==="start"?"bottom":"top";return l.reference[d]>l.floating[d]&&(h=jc(h)),[h,jc(h)]}function FE(a){const l=jc(a);return[eh(a),l,eh(l)]}function eh(a){return a.includes("start")?a.replace("start","end"):a.replace("end","start")}const Fx=["left","right"],Qx=["right","left"],QE=["top","bottom"],ZE=["bottom","top"];function JE(a,l,o){switch(a){case"top":case"bottom":return o?l?Qx:Fx:l?Fx:Qx;case"left":case"right":return l?QE:ZE;default:return[]}}function WE(a,l,o,i){const u=js(a);let d=JE(Hl(a),o==="start",i);return u&&(d=d.map(h=>h+"-"+u),l&&(d=d.concat(d.map(eh)))),d}function jc(a){const l=Hl(a);return KE[l]+a.slice(l.length)}function eR(a){var l,o,i,u;return{top:(l=a.top)!=null?l:0,right:(o=a.right)!=null?o:0,bottom:(i=a.bottom)!=null?i:0,left:(u=a.left)!=null?u:0}}function B0(a){return typeof a!="number"?eR(a):{top:a,right:a,bottom:a,left:a}}function Cc(a){const{x:l,y:o,width:i,height:u}=a;return{width:i,height:u,top:o,left:l,right:l+i,bottom:o+u,x:l,y:o}}function Zx(a,l,o){let{reference:i,floating:u}=a;const d=pa(l),h=Hh(l),p=Bh(h),g=Hl(l),v=d==="y",x=i.x+i.width/2-u.width/2,y=i.y+i.height/2-u.height/2,S=i[p]/2-u[p]/2;let w;switch(g){case"top":w={x,y:i.y-u.height};break;case"bottom":w={x,y:i.y+i.height};break;case"right":w={x:i.x+i.width,y};break;case"left":w={x:i.x-u.width,y};break;default:w={x:i.x,y:i.y}}const C=js(l);return C&&(w[h]+=S*(C==="end"?1:-1)*(o&&v?-1:1)),w}async function tR(a,l){var o;l===void 0&&(l={});const{x:i,y:u,platform:d,rects:h,elements:p,strategy:g}=a,{boundary:v="clippingAncestors",rootBoundary:x="viewport",elementContext:y="floating",altBoundary:S=!1,padding:w=0}=Wa(l,a),C=B0(w),j=p[S?y==="floating"?"reference":"floating":y],N=Cc(await d.getClippingRect({element:(o=await(d.isElement==null?void 0:d.isElement(j)))==null||o?j:j.contextElement||await(d.getDocumentElement==null?void 0:d.getDocumentElement(p.floating)),boundary:v,rootBoundary:x,strategy:g})),M=y==="floating"?{x:i,y:u,width:h.floating.width,height:h.floating.height}:h.reference,T=await(d.getOffsetParent==null?void 0:d.getOffsetParent(p.floating)),_=await(d.isElement==null?void 0:d.isElement(T))&&await(d.getScale==null?void 0:d.getScale(T))||{x:1,y:1},O=Cc(d.convertOffsetParentRelativeRectToViewportRelativeRect?await d.convertOffsetParentRelativeRectToViewportRelativeRect({elements:p,rect:M,offsetParent:T,strategy:g}):M);return{top:(N.top-O.top+C.top)/_.y,bottom:(O.bottom-N.bottom+C.bottom)/_.y,left:(N.left-O.left+C.left)/_.x,right:(O.right-N.right+C.right)/_.x}}const nR=50,aR=async(a,l,o)=>{const{placement:i="bottom",strategy:u="absolute",middleware:d=[],platform:h}=o,p=h.detectOverflow?h:{...h,detectOverflow:tR},g=await(h.isRTL==null?void 0:h.isRTL(l));let v=await h.getElementRects({reference:a,floating:l,strategy:u}),{x,y}=Zx(v,i,g),S=i,w=0;const C={};for(let E=0;E<d.length;E++){const j=d[E];if(!j)continue;const{name:N,fn:M}=j,{x:T,y:_,data:O,reset:A}=await M({x,y,initialPlacement:i,placement:S,strategy:u,middlewareData:C,rects:v,platform:p,elements:{reference:a,floating:l}});x=T??x,y=_??y,C[N]={...C[N],...O},A&&w<nR&&(w++,typeof A=="object"&&(A.placement&&(S=A.placement),A.rects&&(v=A.rects===!0?await h.getElementRects({reference:a,floating:l,strategy:u}):A.rects),{x,y}=Zx(v,S,g)),E=-1)}return{x,y,placement:S,strategy:u,middlewareData:C}},lR=a=>({name:"arrow",options:a,async fn(l){const{x:o,y:i,placement:u,rects:d,platform:h,elements:p,middlewareData:g}=l,{element:v,padding:x=0}=Wa(a,l)||{};if(v==null)return{};const y=B0(x),S={x:o,y:i},w=Hh(u),C=Bh(w),E=await h.getDimensions(v),j=w==="y",N=j?"top":"left",M=j?"bottom":"right",T=j?"clientHeight":"clientWidth",_=d.reference[C]+d.reference[w]-S[w]-d.floating[C],O=S[w]-d.reference[w],A=await(h.getOffsetParent==null?void 0:h.getOffsetParent(v));let H=A?A[T]:0;(!H||!await(h.isElement==null?void 0:h.isElement(A)))&&(H=p.floating[T]||d.floating[C]);const z=_/2-O/2,K=H/2-E[C]/2-1,se=Bl(y[N],K),X=Bl(y[M],K),I=H-E[C]-X,re=H/2-E[C]/2+z,ee=U0(se,re,I),oe=!g.arrow&&js(u)!=null&&re!==ee&&d.reference[C]/2-(re<se?se:X)-E[C]/2<0,U=oe?re<se?re-se:re-I:0;return{[w]:S[w]+U,data:{[w]:ee,centerOffset:re-ee-U,...oe&&{alignmentOffset:U}},reset:oe}}}),rR=function(a){return a===void 0&&(a={}),{name:"flip",options:a,async fn(l){var o,i;const{placement:u,middlewareData:d,rects:h,initialPlacement:p,platform:g,elements:v}=l,{mainAxis:x=!0,crossAxis:y=!0,fallbackPlacements:S,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:C="none",flipAlignment:E=!0,...j}=Wa(a,l);if((o=d.arrow)!=null&&o.alignmentOffset)return{};const N=Hl(u),M=pa(p),T=Hl(p)===p,_=await(g.isRTL==null?void 0:g.isRTL(v.floating)),O=S||(T||!E?[jc(p)]:FE(p)),A=C!=="none";!S&&A&&O.push(...WE(p,E,C,_));const H=[p,...O],z=await g.detectOverflow(l,j),K=[];let se=((i=d.flip)==null?void 0:i.overflows)||[];if(x&&K.push(z[N]),y){const ee=XE(u,h,_);K.push(z[ee[0]],z[ee[1]])}if(se=[...se,{placement:u,overflows:K}],!K.every(ee=>ee<=0)){var X,I;const ee=(((X=d.flip)==null?void 0:X.index)||0)+1,oe=H[ee];if(oe&&(!(y==="alignment"?M!==pa(oe):!1)||se.every(le=>pa(le.placement)===M?le.overflows[0]>0:!0)))return{data:{index:ee,overflows:se},reset:{placement:oe}};let U=(I=se.filter($=>$.overflows[0]<=0).sort(($,le)=>$.overflows[1]-le.overflows[1])[0])==null?void 0:I.placement;if(!U)switch(w){case"bestFit":{var re;const $=(re=se.filter(le=>{if(A){const B=pa(le.placement);return B===M||B==="y"}return!0}).map(le=>[le.placement,le.overflows.filter(B=>B>0).reduce((B,Z)=>B+Z,0)]).sort((le,B)=>le[1]-B[1])[0])==null?void 0:re[0];$&&(U=$);break}case"initialPlacement":U=p;break}if(u!==U)return{reset:{placement:U}}}return{}}}};function Jx(a,l){return{top:a.top-l.height,right:a.right-l.width,bottom:a.bottom-l.height,left:a.left-l.width}}function Wx(a){return $E.some(l=>a[l]>=0)}const sR=function(a){return a===void 0&&(a={}),{name:"hide",options:a,async fn(l){const{rects:o,platform:i}=l,{strategy:u="referenceHidden",...d}=Wa(a,l);switch(u){case"referenceHidden":{const h=await i.detectOverflow(l,{...d,elementContext:"reference"}),p=Jx(h,o.reference);return{data:{referenceHiddenOffsets:p,referenceHidden:Wx(p)}}}case"escaped":{const h=await i.detectOverflow(l,{...d,altBoundary:!0}),p=Jx(h,o.floating);return{data:{escapedOffsets:p,escaped:Wx(p)}}}default:return{}}}}},H0=new Set(["left","top"]);async function oR(a,l){const{placement:o,platform:i,elements:u}=a,d=await(i.isRTL==null?void 0:i.isRTL(u.floating)),h=Hl(o),p=js(o),g=pa(o)==="y",v=H0.has(h)?-1:1,x=d&&g?-1:1,y=Wa(l,a);let{mainAxis:S,crossAxis:w,alignmentAxis:C}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:y.mainAxis||0,crossAxis:y.crossAxis||0,alignmentAxis:y.alignmentAxis};return p&&typeof C=="number"&&(w=p==="end"?C*-1:C),g?{x:w*x,y:S*v}:{x:S*v,y:w*x}}const iR=function(a){return a===void 0&&(a=0),{name:"offset",options:a,async fn(l){var o,i;const{x:u,y:d,placement:h,middlewareData:p}=l,g=await oR(l,a);return h===((o=p.offset)==null?void 0:o.placement)&&(i=p.arrow)!=null&&i.alignmentOffset?{}:{x:u+g.x,y:d+g.y,data:{...g,placement:h}}}}},cR=function(a){return a===void 0&&(a={}),{name:"shift",options:a,async fn(l){const{x:o,y:i,placement:u,platform:d}=l,{mainAxis:h=!0,crossAxis:p=!1,limiter:g={fn:M=>{let{x:T,y:_}=M;return{x:T,y:_}}},...v}=Wa(a,l),x={x:o,y:i},y=await d.detectOverflow(l,v),S=pa(u),w=Uh(S);let C=x[w],E=x[S];const j=(M,T)=>U0(T+y[M==="y"?"top":"left"],T,T-y[M==="y"?"bottom":"right"]);h&&(C=j(w,C)),p&&(E=j(S,E));const N=g.fn({...l,[w]:C,[S]:E});return{...N,data:{x:N.x-o,y:N.y-i,enabled:{[w]:h,[S]:p}}}}}},uR=function(a){return a===void 0&&(a={}),{options:a,fn(l){var o,i;const{x:u,y:d,placement:h,rects:p,middlewareData:g}=l,{offset:v=0,mainAxis:x=!0,crossAxis:y=!0}=Wa(a,l),S={x:u,y:d},w=pa(h),C=Uh(w);let E=S[C],j=S[w];const N=Wa(v,l),M=typeof N=="number"?{mainAxis:N,crossAxis:0}:{mainAxis:(o=N.mainAxis)!=null?o:0,crossAxis:(i=N.crossAxis)!=null?i:0};if(x){const O=C==="y"?"height":"width",A=p.reference[C]-p.floating[O]+M.mainAxis,H=p.reference[C]+p.reference[O]-M.mainAxis;E<A?E=A:E>H&&(E=H)}if(y){var T,_;const O=C==="y"?"width":"height",A=H0.has(Hl(h)),H=p.reference[w]-p.floating[O]+(A&&((T=g.offset)==null?void 0:T[w])||0)+(A?0:M.crossAxis),z=p.reference[w]+p.reference[O]+(A?0:((_=g.offset)==null?void 0:_[w])||0)-(A?M.crossAxis:0);j<H?j=H:j>z&&(j=z)}return{[C]:E,[w]:j}}}},dR=function(a){return a===void 0&&(a={}),{name:"size",options:a,async fn(l){const{placement:o,rects:i,platform:u,elements:d}=l,{apply:h=()=>{},...p}=Wa(a,l),g=await u.detectOverflow(l,p),v=Hl(o),x=js(o),y=pa(o)==="y",{width:S,height:w}=i.floating;let C,E;v==="top"||v==="bottom"?(C=v,E=x===(await(u.isRTL==null?void 0:u.isRTL(d.floating))?"start":"end")?"left":"right"):(E=v,C=x==="end"?"top":"bottom");const j=w-g.top-g.bottom,N=S-g.left-g.right,M=Bl(w-g[C],j),T=Bl(S-g[E],N),_=l.middlewareData.shift,O=!_;let A=M,H=T;_!=null&&_.enabled.x&&(H=N),_!=null&&_.enabled.y&&(A=j),O&&!x&&(y?H=S-2*Xa(g.left,g.right):A=w-2*Xa(g.top,g.bottom)),await h({...l,availableWidth:H,availableHeight:A});const z=await u.getDimensions(d.floating);return S!==z.width||w!==z.height?{reset:{rects:!0}}:{}}}};function Uc(){return typeof window<"u"}function Cs(a){return P0(a)?(a.nodeName||"").toLowerCase():"#document"}function un(a){var l;return(a==null||(l=a.ownerDocument)==null?void 0:l.defaultView)||window}function nl(a){var l;return(l=(P0(a)?a.ownerDocument:a.document)||window.document)==null?void 0:l.documentElement}function P0(a){return Uc()?a instanceof Node||a instanceof un(a).Node:!1}function xa(a){return Uc()?a instanceof Element||a instanceof un(a).Element:!1}function ql(a){return Uc()?a instanceof HTMLElement||a instanceof un(a).HTMLElement:!1}function ey(a){return!Uc()||typeof ShadowRoot>"u"?!1:a instanceof ShadowRoot||a instanceof un(a).ShadowRoot}function Bc(a){const{overflow:l,overflowX:o,overflowY:i,display:u}=ya(a);return/auto|scroll|overlay|hidden|clip/.test(l+i+o)&&u!=="inline"&&u!=="contents"}function fR(a){return/^(table|td|th)$/.test(Cs(a))}function Hc(a){try{if(a.matches(":popover-open"))return!0}catch{}try{return a.matches(":modal")}catch{return!1}}const hR=/transform|translate|scale|rotate|perspective|filter/,mR=/paint|layout|strict|content/,ir=a=>!!a&&a!=="none";let Mf;function Ph(a){const l=xa(a)?ya(a):a;return ir(l.transform)||ir(l.translate)||ir(l.scale)||ir(l.rotate)||ir(l.perspective)||!qh()&&(ir(l.backdropFilter)||ir(l.filter))||hR.test(l.willChange||"")||mR.test(l.contain||"")}function pR(a){let l=fr(a);for(;ql(l)&&!Eo(l);){if(Ph(l))return l;if(Hc(l))return null;l=fr(l)}return null}function qh(){return Mf==null&&(Mf=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Mf}function Eo(a){return/^(html|body|#document)$/.test(Cs(a))}function ya(a){return un(a).getComputedStyle(a)}function Pc(a){return xa(a)?{scrollLeft:a.scrollLeft,scrollTop:a.scrollTop}:{scrollLeft:a.scrollX,scrollTop:a.scrollY}}function fr(a){if(Cs(a)==="html")return a;const l=a.assignedSlot||a.parentNode||ey(a)&&a.host||nl(a);return ey(l)?l.host:l}function q0(a){const l=fr(a);return Eo(l)?(a.ownerDocument||a).body:ql(l)&&Bc(l)?l:q0(l)}function Ro(a,l,o){var i;l===void 0&&(l=[]),o===void 0&&(o=!0);const u=q0(a),d=u===((i=a.ownerDocument)==null?void 0:i.body),h=un(u);if(d){const p=th(h);return l.concat(h,h.visualViewport||[],Bc(u)?u:[],p&&o?Ro(p):[])}else return l.concat(u,Ro(u,[],o))}function th(a){return a.parent&&Object.getPrototypeOf(a.parent)?a.frameElement:null}function I0(a){const l=ya(a);let o=parseFloat(l.width)||0,i=parseFloat(l.height)||0;const u=ql(a),d=u?a.offsetWidth:o,h=u?a.offsetHeight:i,p=wc(o)!==d||wc(i)!==h;return p&&(o=d,i=h),{width:o,height:i,$:p}}function Ih(a){return xa(a)?a:a.contextElement}function hs(a){const l=Ih(a);if(!ql(l))return Fa(1);const o=l.getBoundingClientRect(),{width:i,height:u,$:d}=I0(l);let h=(d?wc(o.width):o.width)/i,p=(d?wc(o.height):o.height)/u;return(!h||!Number.isFinite(h))&&(h=1),(!p||!Number.isFinite(p))&&(p=1),{x:h,y:p}}const gR=Fa(0);function V0(a){const l=un(a);return!qh()||!l.visualViewport?gR:{x:l.visualViewport.offsetLeft,y:l.visualViewport.offsetTop}}function vR(a,l,o){return l===void 0&&(l=!1),!!o&&l&&o===un(a)}function hr(a,l,o,i){l===void 0&&(l=!1),o===void 0&&(o=!1);const u=a.getBoundingClientRect(),d=Ih(a);let h=Fa(1);l&&(i?xa(i)&&(h=hs(i)):h=hs(a));const p=vR(d,o,i)?V0(d):Fa(0);let g=(u.left+p.x)/h.x,v=(u.top+p.y)/h.y,x=u.width/h.x,y=u.height/h.y;if(d&&i){const S=un(d),w=xa(i)?un(i):i;let C=S,E=th(C);for(;E&&w!==C;){const j=hs(E),N=E.getBoundingClientRect(),M=ya(E),T=N.left+(E.clientLeft+parseFloat(M.paddingLeft))*j.x,_=N.top+(E.clientTop+parseFloat(M.paddingTop))*j.y;g*=j.x,v*=j.y,x*=j.x,y*=j.y,g+=T,v+=_,C=un(E),E=th(C)}}return Cc({width:x,height:y,x:g,y:v})}function qc(a,l){const o=Pc(a).scrollLeft;return l?l.left+o:hr(nl(a)).left+o}function G0(a,l){const o=a.getBoundingClientRect(),i=o.left+l.scrollLeft-qc(a,o),u=o.top+l.scrollTop;return{x:i,y:u}}function xR(a){let{elements:l,rect:o,offsetParent:i,strategy:u}=a;const d=u==="fixed",h=nl(i),p=l?Hc(l.floating):!1;if(i===h||p&&d)return o;let g={scrollLeft:0,scrollTop:0},v=Fa(1);const x=Fa(0),y=ql(i);if((y||!d)&&((Cs(i)!=="body"||Bc(h))&&(g=Pc(i)),y)){const w=hr(i);v=hs(i),x.x=w.x+i.clientLeft,x.y=w.y+i.clientTop}const S=h&&!y&&!d?G0(h,g):Fa(0);return{width:o.width*v.x,height:o.height*v.y,x:o.x*v.x-g.scrollLeft*v.x+x.x+S.x,y:o.y*v.y-g.scrollTop*v.y+x.y+S.y}}function yR(a){return a.getClientRects?Array.from(a.getClientRects()):[]}function bR(a){const l=Pc(a),o=a.ownerDocument.body,i=Xa(a.scrollWidth,a.clientWidth,o.scrollWidth,o.clientWidth),u=Xa(a.scrollHeight,a.clientHeight,o.scrollHeight,o.clientHeight);let d=-l.scrollLeft+qc(a);const h=-l.scrollTop;return ya(o).direction==="rtl"&&(d+=Xa(a.clientWidth,o.clientWidth)-i),{width:i,height:u,x:d,y:h}}const SR=25;function wR(a,l,o){o===void 0&&(o="viewport");const i=o==="layoutViewport",u=un(a),d=nl(a),h=u.visualViewport;let p=d.clientWidth,g=d.clientHeight,v=0,x=0;if(h){const S=!qh()||l==="fixed";i?S||(v=-h.offsetLeft,x=-h.offsetTop):(p=h.width,g=h.height,S&&(v=h.offsetLeft,x=h.offsetTop))}if(qc(d)<=0){const S=d.ownerDocument,w=S.body,C=getComputedStyle(w),E=S.compatMode==="CSS1Compat"&&parseFloat(C.marginLeft)+parseFloat(C.marginRight)||0,j=Math.abs(d.clientWidth-w.clientWidth-E),N=getComputedStyle(d).scrollbarGutter==="stable both-edges"?j/2:j;N<=SR&&(p-=N)}return{width:p,height:g,x:v,y:x}}function jR(a,l){const o=hr(a,!0,l==="fixed"),i=o.top+a.clientTop,u=o.left+a.clientLeft,d=hs(a),h=a.clientWidth*d.x,p=a.clientHeight*d.y,g=u*d.x,v=i*d.y;return{width:h,height:p,x:g,y:v}}function ty(a,l,o){let i;if(l==="viewport"||l==="layoutViewport")i=wR(a,o,l);else if(l==="document")i=bR(nl(a));else if(xa(l))i=jR(l,o);else{const u=V0(a);i={x:l.x-u.x,y:l.y-u.y,width:l.width,height:l.height}}return Cc(i)}function CR(a,l){const o=l.get(a);if(o)return o;let i=Ro(a,[],!1).filter(p=>xa(p)&&Cs(p)!=="body"),u=null;const d=ya(a).position==="fixed";let h=d?fr(a):a;for(;xa(h)&&!Eo(h);){const p=ya(h),g=Ph(h),v=u?u.position:d?"fixed":"";!g&&(v==="fixed"||v==="absolute"&&p.position==="static")?i=i.filter(y=>y!==h):u=p,h=fr(h)}return l.set(a,i),i}function ER(a){let{element:l,boundary:o,rootBoundary:i,strategy:u}=a;const h=[...o==="clippingAncestors"?Hc(l)?[]:CR(l,this._c):[].concat(o),i],p=ty(l,h[0],u);let g=p.top,v=p.right,x=p.bottom,y=p.left;for(let S=1;S<h.length;S++){const w=ty(l,h[S],u);g=Xa(w.top,g),v=Bl(w.right,v),x=Bl(w.bottom,x),y=Xa(w.left,y)}return{width:v-y,height:x-g,x:y,y:g}}function RR(a){const{width:l,height:o}=I0(a);return{width:l,height:o}}function NR(a,l,o){const i=ql(l),u=nl(l),d=o==="fixed",h=hr(a,!0,d,l);let p={scrollLeft:0,scrollTop:0};const g=Fa(0);if((i||!d)&&((Cs(l)!=="body"||Bc(u))&&(p=Pc(l)),i)){const S=hr(l,!0,d,l);g.x=S.x+l.clientLeft,g.y=S.y+l.clientTop}!i&&u&&(g.x=qc(u));const v=u&&!i&&!d?G0(u,p):Fa(0),x=h.left+p.scrollLeft-g.x-v.x,y=h.top+p.scrollTop-g.y-v.y;return{x,y,width:h.width,height:h.height}}function Df(a){return ya(a).position==="static"}function ny(a,l){if(!ql(a)||ya(a).position==="fixed")return null;if(l)return l(a);let o=a.offsetParent;return nl(a)===o&&(o=o.ownerDocument.body),o}function Y0(a,l){const o=un(a);if(Hc(a))return o;if(!ql(a)){let u=fr(a);for(;u&&!Eo(u);){if(xa(u)&&!Df(u))return u;u=fr(u)}return o}let i=ny(a,l);for(;i&&fR(i)&&Df(i);)i=ny(i,l);return i&&Eo(i)&&Df(i)&&!Ph(i)?o:i||pR(a)||o}const TR=async function(a){const l=this.getOffsetParent||Y0,o=this.getDimensions,i=await o(a.floating);return{reference:NR(a.reference,await l(a.floating),a.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function AR(a){return ya(a).direction==="rtl"}const MR={convertOffsetParentRelativeRectToViewportRelativeRect:xR,getDocumentElement:nl,getClippingRect:ER,getOffsetParent:Y0,getElementRects:TR,getClientRects:yR,getDimensions:RR,getScale:hs,isElement:xa,isRTL:AR};function $0(a,l){return a.x===l.x&&a.y===l.y&&a.width===l.width&&a.height===l.height}function DR(a,l,o){let i=null,u;const d=nl(a);function h(){var x;clearTimeout(u),(x=i)==null||x.disconnect(),i=null}function p(x,y){x===void 0&&(x=!1),y===void 0&&(y=1),h();const S=a.getBoundingClientRect(),{left:w,top:C,width:E,height:j}=S;if(x||l(),!E||!j)return;const N=ac(C),M=ac(d.clientWidth-(w+E)),T=ac(d.clientHeight-(C+j)),_=ac(w),A={rootMargin:-N+"px "+-M+"px "+-T+"px "+-_+"px",threshold:Xa(0,Bl(1,y))||1};let H=!0;function z(K){const se=K[0].intersectionRatio;if(!$0(S,a.getBoundingClientRect()))return p();if(se!==y){if(!H)return p();se?p(!1,se):u=setTimeout(()=>{p(!1,1e-7)},1e3)}H=!1}try{i=new IntersectionObserver(z,{...A,root:d.ownerDocument})}catch{i=new IntersectionObserver(z,A)}i.observe(a)}const g=un(a),v=()=>p(o);return g.addEventListener("resize",v),p(!0),()=>{g.removeEventListener("resize",v),h()}}function _R(a,l,o,i){i===void 0&&(i={});const{ancestorScroll:u=!0,ancestorResize:d=!0,elementResize:h=typeof ResizeObserver=="function",layoutShift:p=typeof IntersectionObserver=="function",animationFrame:g=!1}=i,v=Ih(a),x=u||d?[...v?Ro(v):[],...l?Ro(l):[]]:[];x.forEach(N=>{u&&N.addEventListener("scroll",o),d&&N.addEventListener("resize",o)});const y=v&&p?DR(v,o,d):null;let S=-1,w=null;h&&(w=new ResizeObserver(N=>{let[M]=N;M&&M.target===v&&w&&l&&(w.unobserve(l),cancelAnimationFrame(S),S=requestAnimationFrame(()=>{var T;(T=w)==null||T.observe(l)})),o()}),v&&!g&&w.observe(v),l&&w.observe(l));let C,E=g?hr(a):null;g&&j();function j(){const N=hr(a);E&&!$0(E,N)&&o(),E=N,C=requestAnimationFrame(j)}return o(),()=>{var N;x.forEach(M=>{u&&M.removeEventListener("scroll",o),d&&M.removeEventListener("resize",o)}),y==null||y(),(N=w)==null||N.disconnect(),w=null,g&&cancelAnimationFrame(C)}}const OR=iR,kR=cR,zR=rR,LR=dR,UR=sR,ay=lR,BR=uR,HR=(a,l,o)=>{const i=new Map,u=o??{},d={...MR,...u.platform,_c:i};return aR(a,l,{...u,platform:d})};var PR=typeof document<"u",qR=function(){},vc=PR?m.useLayoutEffect:qR;function Ec(a,l){if(a===l)return!0;if(typeof a!=typeof l)return!1;if(typeof a=="function"&&a.toString()===l.toString())return!0;let o,i,u;if(a&&l&&typeof a=="object"){if(Array.isArray(a)){if(o=a.length,o!==l.length)return!1;for(i=o;i--!==0;)if(!Ec(a[i],l[i]))return!1;return!0}if(u=Object.keys(a),o=u.length,o!==Object.keys(l).length)return!1;for(i=o;i--!==0;)if(!{}.hasOwnProperty.call(l,u[i]))return!1;for(i=o;i--!==0;){const d=u[i];if(!(d==="_owner"&&a.$$typeof)&&!Ec(a[d],l[d]))return!1}return!0}return a!==a&&l!==l}function K0(a){return typeof window>"u"?1:(a.ownerDocument.defaultView||window).devicePixelRatio||1}function ly(a,l){const o=K0(a);return Math.round(l*o)/o}function _f(a){const l=m.useRef(a);return vc(()=>{l.current=a}),l}function IR(a){a===void 0&&(a={});const{placement:l="bottom",strategy:o="absolute",middleware:i=[],platform:u,elements:{reference:d,floating:h}={},transform:p=!0,whileElementsMounted:g,open:v}=a,[x,y]=m.useState({x:0,y:0,strategy:o,placement:l,middlewareData:{},isPositioned:!1}),[S,w]=m.useState(i);Ec(S,i)||w(i);const[C,E]=m.useState(null),[j,N]=m.useState(null),M=m.useCallback(le=>{le!==A.current&&(A.current=le,E(le))},[]),T=m.useCallback(le=>{le!==H.current&&(H.current=le,N(le))},[]),_=d||C,O=h||j,A=m.useRef(null),H=m.useRef(null),z=m.useRef(x),K=g!=null,se=_f(g),X=_f(u),I=_f(v),re=m.useCallback(()=>{if(!A.current||!H.current)return;const le={placement:l,strategy:o,middleware:S};X.current&&(le.platform=X.current),HR(A.current,H.current,le).then(B=>{const Z={...B,isPositioned:I.current!==!1};ee.current&&!Ec(z.current,Z)&&(z.current=Z,bs.flushSync(()=>{y(Z)}))})},[S,l,o,X,I]);vc(()=>{v===!1&&z.current.isPositioned&&(z.current.isPositioned=!1,y(le=>({...le,isPositioned:!1})))},[v]);const ee=m.useRef(!1);vc(()=>(ee.current=!0,()=>{ee.current=!1}),[]),vc(()=>{if(_&&(A.current=_),O&&(H.current=O),_&&O){if(se.current)return se.current(_,O,re);re()}},[_,O,re,se,K]);const oe=m.useMemo(()=>({reference:A,floating:H,setReference:M,setFloating:T}),[M,T]),U=m.useMemo(()=>({reference:_,floating:O}),[_,O]),$=m.useMemo(()=>{const le={position:o,left:0,top:0};if(!U.floating)return le;const B=ly(U.floating,x.x),Z=ly(U.floating,x.y);return p?{...le,transform:"translate("+B+"px, "+Z+"px)",...K0(U.floating)>=1.5&&{willChange:"transform"}}:{position:o,left:B,top:Z}},[o,p,U.floating,x.x,x.y]);return m.useMemo(()=>({...x,update:re,refs:oe,elements:U,floatingStyles:$}),[x,re,oe,U,$])}const VR=a=>{function l(o){return{}.hasOwnProperty.call(o,"current")}return{name:"arrow",options:a,fn(o){const{element:i,padding:u}=typeof a=="function"?a(o):a;return i&&l(i)?i.current!=null?ay({element:i.current,padding:u}).fn(o):{}:i?ay({element:i,padding:u}).fn(o):{}}}},GR=(a,l)=>{const o=OR(a);return{name:o.name,fn:o.fn,options:[a,l]}},YR=(a,l)=>{const o=kR(a);return{name:o.name,fn:o.fn,options:[a,l]}},$R=(a,l)=>({fn:BR(a).fn,options:[a,l]}),KR=(a,l)=>{const o=zR(a);return{name:o.name,fn:o.fn,options:[a,l]}},XR=(a,l)=>{const o=LR(a);return{name:o.name,fn:o.fn,options:[a,l]}},FR=(a,l)=>{const o=UR(a);return{name:o.name,fn:o.fn,options:[a,l]}},QR=(a,l)=>{const o=VR(a);return{name:o.name,fn:o.fn,options:[a,l]}};var ZR=Object.defineProperty,JR=(a,l)=>ZR(a,"name",{value:l,configurable:!0});function Ic(a){const[l,o]=m.useState(void 0);return Dt(()=>{if(a){o({width:a.offsetWidth,height:a.offsetHeight});const i=new ResizeObserver(u=>{if(!Array.isArray(u)||!u.length)return;const d=u[0];let h,p;if("borderBoxSize"in d){const g=d.borderBoxSize,v=Array.isArray(g)?g[0]:g;h=v.inlineSize,p=v.blockSize}else h=a.offsetWidth,p=a.offsetHeight;o({width:h,height:p})});return i.observe(a,{box:"border-box"}),()=>i.unobserve(a)}else o(void 0)},[a]),l}JR(Ic,"useSize");var WR=Object.defineProperty,Ll=(a,l)=>WR(a,"name",{value:l,configurable:!0}),X0="Popper",[F0,Es]=fn(X0),[eN,Q0]=F0(X0),tN=Ll(a=>{const{__scopePopper:l,children:o}=a,[i,u]=m.useState(null),[d,h]=m.useState(void 0);return s.jsx(eN,{scope:l,anchor:i,onAnchorChange:u,placementState:d,setPlacementState:h,children:o})},"Popper"),nN="PopperAnchor",aN=m.forwardRef(Ll(function(l,o){const{__scopePopper:i,virtualRef:u,...d}=l,h=Q0(nN,i),p=m.useRef(null),g=h.onAnchorChange,v=m.useCallback(E=>{p.current=E,E&&g(E)},[g]),x=Ie(o,v),y=m.useRef(null);m.useEffect(()=>{if(!u)return;const E=y.current;y.current=u.current,E!==y.current&&g(y.current)});const S=h.placementState&&Vc(h.placementState),w=S==null?void 0:S[0],C=S==null?void 0:S[1];return u?null:s.jsx(Be.div,{"data-radix-popper-side":w,"data-radix-popper-align":C,...d,ref:x})},"PopperAnchor")),Z0="PopperContent",[lN,U_]=F0(Z0),rN=m.forwardRef(Ll(function(l,o){var xe,J,me,je,Me,mt,pt;const{__scopePopper:i,side:u="bottom",sideOffset:d=0,align:h="center",alignOffset:p=0,arrowPadding:g=0,avoidCollisions:v=!0,collisionBoundary:x=[],collisionPadding:y=0,sticky:S="partial",hideWhenDetached:w=!1,updatePositionStrategy:C="optimized",onPlaced:E,...j}=l,N=Q0(Z0,i),[M,T]=m.useState(null),_=Ie(o,T),[O,A]=m.useState(null),H=Ic(O),z=(H==null?void 0:H.width)??0,K=(H==null?void 0:H.height)??0,se=u+(h!=="center"?"-"+h:""),X=typeof y=="number"?y:{top:0,right:0,bottom:0,left:0,...y},I=Array.isArray(x)?x:[x],re=I.length>0,ee={padding:X,boundary:I.filter(J0),altBoundary:re},{refs:oe,floatingStyles:U,placement:$,isPositioned:le,middlewareData:B}=IR({strategy:"fixed",placement:se,whileElementsMounted:Ll((...bt)=>_R(...bt,{animationFrame:C==="always"}),"whileElementsMounted"),elements:{reference:N.anchor},middleware:[GR({mainAxis:d+K,alignmentAxis:p}),v&&YR({mainAxis:!0,crossAxis:!1,limiter:S==="partial"?$R():void 0,...ee}),v&&KR({...ee}),XR({...ee,apply:Ll(({elements:bt,rects:St,availableWidth:Lt,availableHeight:hn})=>{const{width:Qn,height:mn}=St.reference,ja=bt.floating.style;ja.setProperty("--radix-popper-available-width",`${Lt}px`),ja.setProperty("--radix-popper-available-height",`${hn}px`),ja.setProperty("--radix-popper-anchor-width",`${Qn}px`),ja.setProperty("--radix-popper-anchor-height",`${mn}px`)},"apply")}),O&&QR({element:O,padding:g}),sN({arrowWidth:z,arrowHeight:K}),w&&FR({strategy:"referenceHidden",...ee,boundary:re?ee.boundary:void 0})]}),Z=N.setPlacementState;Dt(()=>(Z($),()=>{Z(void 0)}),[$,Z]);const[D,q]=Vc($),Q=$n(E);Dt(()=>{le&&(Q==null||Q())},[le,Q]);const ae=(xe=B.arrow)==null?void 0:xe.x,ce=(J=B.arrow)==null?void 0:J.y,Se=((me=B.arrow)==null?void 0:me.centerOffset)!==0,[ue,fe]=m.useState();return Dt(()=>{M&&fe(window.getComputedStyle(M).zIndex)},[M]),s.jsx("div",{ref:oe.setFloating,"data-radix-popper-content-wrapper":"",style:{...U,transform:le?U.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ue,"--radix-popper-transform-origin":[(je=B.transformOrigin)==null?void 0:je.x,(Me=B.transformOrigin)==null?void 0:Me.y].join(" "),...((mt=B.hide)==null?void 0:mt.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:l.dir,children:s.jsx(lN,{scope:i,placedSide:D,placedAlign:q,onArrowChange:A,arrowX:ae,arrowY:ce,shouldHideArrow:Se,children:s.jsx(Be.div,{"data-side":D,"data-align":q,...j,ref:_,style:{...j.style,animation:le?(pt=j.style)==null?void 0:pt.animation:"none"}})})})},"PopperContent"));function J0(a){return a!==null}Ll(J0,"isNotNull");var sN=Ll(a=>({name:"transformOrigin",options:a,fn(l){var j,N,M;const{placement:o,rects:i,middlewareData:u}=l,h=((j=u.arrow)==null?void 0:j.centerOffset)!==0,p=h?0:a.arrowWidth,g=h?0:a.arrowHeight,[v,x]=Vc(o),y={start:"0%",center:"50%",end:"100%"}[x],S=(((N=u.arrow)==null?void 0:N.x)??0)+p/2,w=(((M=u.arrow)==null?void 0:M.y)??0)+g/2;let C="",E="";return v==="bottom"?(C=h?y:`${S}px`,E=`${-g}px`):v==="top"?(C=h?y:`${S}px`,E=`${i.floating.height+g}px`):v==="right"?(C=`${-g}px`,E=h?y:`${w}px`):v==="left"&&(C=`${i.floating.width+g}px`,E=h?y:`${w}px`),{data:{x:C,y:E}}}}),"transformOrigin");function Vc(a){const[l,o="center"]=a.split("-");return[l,o]}Ll(Vc,"getSideAndAlignFromPlacement");var W0=tN,eb=aN,Vh=rN,oN=Object.defineProperty,iN=(a,l)=>oN(a,"name",{value:l,configurable:!0}),Gh=m.forwardRef(iN(function(l,o){var g;const{container:i,...u}=l,[d,h]=m.useState(!1);Dt(()=>h(!0),[]);const p=i||d&&((g=globalThis==null?void 0:globalThis.document)==null?void 0:g.body);return p?bs.createPortal(s.jsx(Be.div,{...u,ref:o}),p):null},"Portal")),cN=Object.defineProperty,el=(a,l)=>cN(a,"name",{value:l,configurable:!0});function tb(a,l){return m.useReducer((o,i)=>l[o][i]??o,a)}el(tb,"useStateMachine");var al=el(a=>{const{present:l,children:o}=a,i=nb(l),u=typeof o=="function"?o({present:i.isPresent}):m.Children.only(o),d=ab(i.ref,lb(u));return typeof o=="function"||i.isPresent?m.cloneElement(u,{ref:d}):null},"Presence");function nb(a){const[l,o]=m.useState(),i=m.useRef(null),u=m.useRef(a),d=m.useRef("none"),h=m.useRef(void 0),p=a?"mounted":"unmounted",[g,v]=tb(p,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{g==="mounted"?(d.current=h.current??us(i.current),h.current=void 0):d.current="none"},[g]),Dt(()=>{const x=i.current,y=u.current;if(y!==a){const w=d.current,C=us(x);a?(h.current=C,v("MOUNT")):C==="none"||(x==null?void 0:x.display)==="none"?v("UNMOUNT"):v(y&&w!==C?"ANIMATION_OUT":"UNMOUNT"),u.current=a}},[a,v]),Dt(()=>{if(l){let x;const y=l.ownerDocument.defaultView??window,S=el(C=>{const j=us(i.current).includes(CSS.escape(C.animationName));if(C.target===l&&j&&(v("ANIMATION_END"),!u.current)){const N=l.style.animationFillMode;l.style.animationFillMode="forwards",x=y.setTimeout(()=>{l.style.animationFillMode==="forwards"&&(l.style.animationFillMode=N)})}},"handleAnimationEnd"),w=el(C=>{C.target===l&&(d.current=us(i.current))},"handleAnimationStart");return l.addEventListener("animationstart",w),l.addEventListener("animationcancel",S),l.addEventListener("animationend",S),()=>{y.clearTimeout(x),l.removeEventListener("animationstart",w),l.removeEventListener("animationcancel",S),l.removeEventListener("animationend",S)}}else v("ANIMATION_END")},[l,v]),{isPresent:["mounted","unmountSuspended"].includes(g),ref:m.useCallback(x=>{if(x){const y=getComputedStyle(x);i.current=y,h.current=us(y)}else i.current=null;o(x)},[])}}el(nb,"usePresence");function nh(a,l){if(typeof a=="function")return a(l);a!=null&&(a.current=l)}el(nh,"setRef");function ab(...a){const l=m.useRef(a);return l.current=a,m.useCallback(o=>{const i=l.current;let u=!1;const d=i.map(h=>{const p=nh(h,o);return!u&&typeof p=="function"&&(u=!0),p});if(u)return()=>{for(let h=0;h<d.length;h++){const p=d[h];typeof p=="function"?p():nh(i[h],null)}}},[])}el(ab,"useStableComposedRefs");function us(a){return(a==null?void 0:a.animationName)||"none"}el(us,"getAnimationName");function lb(a){var i,u;let l=(i=Object.getOwnPropertyDescriptor(a.props,"ref"))==null?void 0:i.get,o=l&&"isReactWarning"in l&&l.isReactWarning;return o?a.ref:(l=(u=Object.getOwnPropertyDescriptor(a,"ref"))==null?void 0:u.get,o=l&&"isReactWarning"in l&&l.isReactWarning,o?a.props.ref:a.props.ref||a.ref)}el(lb,"getElementRef");var uN=Object.defineProperty,Yh=(a,l)=>uN(a,"name",{value:l,configurable:!0}),Of=!1;function rb(){const[a,l]=m.useState(Of);return m.useEffect(()=>{Of||(Of=!0,l(!0))},[]),a}Yh(rb,"useIsHydrated");var sb=gs[" useSyncExternalStore ".trim().toString()];function ob(){return()=>{}}Yh(ob,"subscribe");function ib(){return sb(ob,()=>!0,()=>!1)}Yh(ib,"useIsHydratedModern");var dN=typeof sb=="function"?ib:rb,fN=Object.defineProperty,pr=(a,l)=>fN(a,"name",{value:l,configurable:!0}),kf="rovingFocusGroup.onEntryFocus",hN={bubbles:!1,cancelable:!0},Gc="RovingFocusGroup",[ah,cb,mN]=zc(Gc),[pN,Yc]=fn(Gc,[mN]),[gN,vN]=pN(Gc),xN=m.forwardRef(pr(function(l,o){return s.jsx(ah.Provider,{scope:l.__scopeRovingFocusGroup,children:s.jsx(ah.Slot,{scope:l.__scopeRovingFocusGroup,children:s.jsx(yN,{...l,ref:o})})})},"RovingFocusGroup")),yN=m.forwardRef(pr(function(l,o){const{__scopeRovingFocusGroup:i,orientation:u,loop:d=!1,dir:h,currentTabStopId:p,defaultCurrentTabStopId:g,onCurrentTabStopIdChange:v,onEntryFocus:x,preventScrollOnEntryFocus:y=!1,...S}=l,w=m.useRef(null),C=Ie(o,w),E=zo(h),[j,N]=Ja({prop:p,defaultProp:g??null,onChange:v,caller:Gc}),[M,T]=m.useState(!1),_=$n(x),O=cb(i),A=m.useRef(!1),[H,z]=m.useState(0);return m.useEffect(()=>{const K=w.current;if(K)return K.addEventListener(kf,_),()=>K.removeEventListener(kf,_)},[_]),s.jsx(gN,{scope:i,orientation:u,dir:E,loop:d,currentTabStopId:j,onItemFocus:m.useCallback(K=>N(K),[N]),onItemShiftTab:m.useCallback(()=>T(!0),[]),onFocusableItemAdd:m.useCallback(()=>z(K=>K+1),[]),onFocusableItemRemove:m.useCallback(()=>z(K=>K-1),[]),children:s.jsx(Be.div,{tabIndex:M||H===0?-1:0,"data-orientation":u,...S,ref:C,style:{outline:"none",...l.style},onMouseDown:Ee(l.onMouseDown,()=>{A.current=!0}),onFocus:Ee(l.onFocus,K=>{const se=!A.current;if(K.target===K.currentTarget&&se&&!M){const X=new CustomEvent(kf,hN);if(K.currentTarget.dispatchEvent(X),!X.defaultPrevented){const I=O().filter($=>$.focusable),re=I.find($=>$.active),ee=I.find($=>$.id===j),U=[re,ee,...I].filter(Boolean).map($=>$.ref.current);$h(U,y)}}A.current=!1}),onBlur:Ee(l.onBlur,()=>T(!1))})})},"RovingFocusGroupImpl")),bN="RovingFocusGroupItem",SN=m.forwardRef(pr(function(l,o){const{__scopeRovingFocusGroup:i,focusable:u=!0,active:d=!1,tabStopId:h,children:p,...g}=l,v=ga(),x=h||v,y=vN(bN,i),S=y.currentTabStopId===x,w=cb(i),{onFocusableItemAdd:C,onFocusableItemRemove:E,currentTabStopId:j}=y,N=dN();return Dt(()=>{if(!(!N||!u))return C(),()=>E()},[N,u,C,E]),m.useEffect(()=>{if(!(N||!u))return C(),()=>E()},[N,u,C,E]),s.jsx(ah.ItemSlot,{scope:i,id:x,focusable:u,active:d,children:s.jsx(Be.span,{tabIndex:S?0:-1,"data-orientation":y.orientation,...g,ref:o,onMouseDown:Ee(l.onMouseDown,M=>{u?y.onItemFocus(x):M.preventDefault()}),onFocus:Ee(l.onFocus,()=>y.onItemFocus(x)),onKeyDown:Ee(l.onKeyDown,M=>{if(M.key==="Tab"&&M.shiftKey){y.onItemShiftTab();return}if(M.target!==M.currentTarget)return;const T=db(M,y.orientation,y.dir);if(T!==void 0){if(M.metaKey||M.ctrlKey||M.altKey||M.shiftKey)return;M.preventDefault();let O=w().filter(A=>A.focusable).map(A=>A.ref.current);if(T==="last")O.reverse();else if(T==="prev"||T==="next"){T==="prev"&&O.reverse();const A=O.indexOf(M.currentTarget);O=y.loop?fb(O,A+1):O.slice(A+1)}setTimeout(()=>$h(O))}}),children:typeof p=="function"?p({isCurrentTabStop:S,hasTabStop:j!=null}):p})})},"RovingFocusGroupItem")),wN={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ub(a,l){return l!=="rtl"?a:a==="ArrowLeft"?"ArrowRight":a==="ArrowRight"?"ArrowLeft":a}pr(ub,"getDirectionAwareKey");function db(a,l,o){const i=ub(a.key,o);if(!(l==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(l==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return wN[i]}pr(db,"getFocusIntent");function $h(a,l=!1){const o=document.activeElement;for(const i of a)if(i===o||(i.focus({preventScroll:l}),document.activeElement!==o))return}pr($h,"focusFirst");function fb(a,l){return a.map((o,i)=>a[(l+i)%a.length])}pr(fb,"wrapArray");var hb=xN,mb=SN,jN=function(a){if(typeof document>"u")return null;var l=Array.isArray(a)?a[0]:a;return l.ownerDocument.body},os=new WeakMap,lc=new WeakMap,rc={},zf=0,pb=function(a){return a&&(a.host||pb(a.parentNode))},CN=function(a,l){return l.map(function(o){if(a.contains(o))return o;var i=pb(o);return i&&a.contains(i)?i:(console.error("aria-hidden",o,"in not contained inside",a,". Doing nothing"),null)}).filter(function(o){return!!o})},EN=function(a,l,o,i){var u=CN(l,Array.isArray(a)?a:[a]);rc[o]||(rc[o]=new WeakMap);var d=rc[o],h=[],p=new Set,g=new Set(u),v=function(y){!y||p.has(y)||(p.add(y),v(y.parentNode))};u.forEach(v);var x=function(y){!y||g.has(y)||Array.prototype.forEach.call(y.children,function(S){if(p.has(S))x(S);else try{var w=S.getAttribute(i),C=w!==null&&w!=="false",E=(os.get(S)||0)+1,j=(d.get(S)||0)+1;os.set(S,E),d.set(S,j),h.push(S),E===1&&C&&lc.set(S,!0),j===1&&S.setAttribute(o,"true"),C||S.setAttribute(i,"true")}catch(N){console.error("aria-hidden: cannot operate on ",S,N)}})};return x(l),p.clear(),zf++,function(){h.forEach(function(y){var S=os.get(y)-1,w=d.get(y)-1;os.set(y,S),d.set(y,w),S||(lc.has(y)||y.removeAttribute(i),lc.delete(y)),w||y.removeAttribute(o)}),zf--,zf||(os=new WeakMap,os=new WeakMap,lc=new WeakMap,rc={})}},Kh=function(a,l,o){o===void 0&&(o="data-aria-hidden");var i=Array.from(Array.isArray(a)?a:[a]),u=jN(a);return u?(i.push.apply(i,Array.from(u.querySelectorAll("[aria-live], script"))),EN(i,u,o,"aria-hidden")):function(){return null}},ma=function(){return ma=Object.assign||function(l){for(var o,i=1,u=arguments.length;i<u;i++){o=arguments[i];for(var d in o)Object.prototype.hasOwnProperty.call(o,d)&&(l[d]=o[d])}return l},ma.apply(this,arguments)};function gb(a,l){var o={};for(var i in a)Object.prototype.hasOwnProperty.call(a,i)&&l.indexOf(i)<0&&(o[i]=a[i]);if(a!=null&&typeof Object.getOwnPropertySymbols=="function")for(var u=0,i=Object.getOwnPropertySymbols(a);u<i.length;u++)l.indexOf(i[u])<0&&Object.prototype.propertyIsEnumerable.call(a,i[u])&&(o[i[u]]=a[i[u]]);return o}function RN(a,l,o){if(o||arguments.length===2)for(var i=0,u=l.length,d;i<u;i++)(d||!(i in l))&&(d||(d=Array.prototype.slice.call(l,0,i)),d[i]=l[i]);return a.concat(d||Array.prototype.slice.call(l))}var xc="right-scroll-bar-position",yc="width-before-scroll-bar",NN="with-scroll-bars-hidden",TN="--removed-body-scroll-bar-size";function Lf(a,l){return typeof a=="function"?a(l):a&&(a.current=l),a}function AN(a,l){var o=m.useState(function(){return{value:a,callback:l,facade:{get current(){return o.value},set current(i){var u=o.value;u!==i&&(o.value=i,o.callback(i,u))}}}})[0];return o.callback=l,o.facade}var MN=typeof window<"u"?m.useLayoutEffect:m.useEffect,ry=new WeakMap;function DN(a,l){var o=AN(null,function(i){return a.forEach(function(u){return Lf(u,i)})});return MN(function(){var i=ry.get(o);if(i){var u=new Set(i),d=new Set(a),h=o.current;u.forEach(function(p){d.has(p)||Lf(p,null)}),d.forEach(function(p){u.has(p)||Lf(p,h)})}ry.set(o,a)},[a]),o}function _N(a){return a}function ON(a,l){l===void 0&&(l=_N);var o=[],i=!1,u={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return o.length?o[o.length-1]:a},useMedium:function(d){var h=l(d,i);return o.push(h),function(){o=o.filter(function(p){return p!==h})}},assignSyncMedium:function(d){for(i=!0;o.length;){var h=o;o=[],h.forEach(d)}o={push:function(p){return d(p)},filter:function(){return o}}},assignMedium:function(d){i=!0;var h=[];if(o.length){var p=o;o=[],p.forEach(d),h=o}var g=function(){var x=h;h=[],x.forEach(d)},v=function(){return Promise.resolve().then(g)};v(),o={push:function(x){h.push(x),v()},filter:function(x){return h=h.filter(x),o}}}};return u}function kN(a){a===void 0&&(a={});var l=ON(null);return l.options=ma({async:!0,ssr:!1},a),l}var vb=function(a){var l=a.sideCar,o=gb(a,["sideCar"]);if(!l)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=l.read();if(!i)throw new Error("Sidecar medium not found");return m.createElement(i,ma({},o))};vb.isSideCarExport=!0;function zN(a,l){return a.useMedium(l),vb}var xb=kN(),Uf=function(){},$c=m.forwardRef(function(a,l){var o=m.useRef(null),i=m.useState({onScrollCapture:Uf,onWheelCapture:Uf,onTouchMoveCapture:Uf}),u=i[0],d=i[1],h=a.forwardProps,p=a.children,g=a.className,v=a.removeScrollBar,x=a.enabled,y=a.shards,S=a.sideCar,w=a.noRelative,C=a.noIsolation,E=a.inert,j=a.allowPinchZoom,N=a.as,M=N===void 0?"div":N,T=a.gapMode,_=gb(a,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),O=S,A=DN([o,l]),H=ma(ma({},_),u);return m.createElement(m.Fragment,null,x&&m.createElement(O,{sideCar:xb,removeScrollBar:v,shards:y,noRelative:w,noIsolation:C,inert:E,setCallbacks:d,allowPinchZoom:!!j,lockRef:o,gapMode:T}),h?m.cloneElement(m.Children.only(p),ma(ma({},H),{ref:A})):m.createElement(M,ma({},H,{className:g,ref:A}),p))});$c.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};$c.classNames={fullWidth:yc,zeroRight:xc};var LN=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function UN(){if(!document)return null;var a=document.createElement("style");a.type="text/css";var l=LN();return l&&a.setAttribute("nonce",l),a}function BN(a,l){a.styleSheet?a.styleSheet.cssText=l:a.appendChild(document.createTextNode(l))}function HN(a){var l=document.head||document.getElementsByTagName("head")[0];l.appendChild(a)}var PN=function(){var a=0,l=null;return{add:function(o){a==0&&(l=UN())&&(BN(l,o),HN(l)),a++},remove:function(){a--,!a&&l&&(l.parentNode&&l.parentNode.removeChild(l),l=null)}}},qN=function(){var a=PN();return function(l,o){m.useEffect(function(){return a.add(l),function(){a.remove()}},[l&&o])}},yb=function(){var a=qN(),l=function(o){var i=o.styles,u=o.dynamic;return a(i,u),null};return l},IN={left:0,top:0,right:0,gap:0},Bf=function(a){return parseInt(a||"",10)||0},VN=function(a){var l=window.getComputedStyle(document.body),o=l[a==="padding"?"paddingLeft":"marginLeft"],i=l[a==="padding"?"paddingTop":"marginTop"],u=l[a==="padding"?"paddingRight":"marginRight"];return[Bf(o),Bf(i),Bf(u)]},GN=function(a){if(a===void 0&&(a="margin"),typeof window>"u")return IN;var l=VN(a),o=document.documentElement.clientWidth,i=window.innerWidth;return{left:l[0],top:l[1],right:l[2],gap:Math.max(0,i-o+l[2]-l[0])}},YN=yb(),ms="data-scroll-locked",$N=function(a,l,o,i){var u=a.left,d=a.top,h=a.right,p=a.gap;return o===void 0&&(o="margin"),`
285
+ */const jC=ze("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function eb(a){var l,o,i="";if(typeof a=="string"||typeof a=="number")i+=a;else if(typeof a=="object")if(Array.isArray(a)){var u=a.length;for(l=0;l<u;l++)a[l]&&(o=eb(a[l]))&&(i&&(i+=" "),i+=o)}else for(o in a)a[o]&&(i&&(i+=" "),i+=o);return i}function tb(){for(var a,l,o=0,i="",u=arguments.length;o<u;o++)(a=arguments[o])&&(l=eb(a))&&(i&&(i+=" "),i+=l);return i}const Th="-",CC=a=>{const l=RC(a),{conflictingClassGroups:o,conflictingClassGroupModifiers:i}=a;return{getClassGroupId:h=>{const p=h.split(Th);return p[0]===""&&p.length!==1&&p.shift(),nb(p,l)||EC(h)},getConflictingClassGroupIds:(h,p)=>{const g=o[h]||[];return p&&i[h]?[...g,...i[h]]:g}}},nb=(a,l)=>{var h;if(a.length===0)return l.classGroupId;const o=a[0],i=l.nextPart.get(o),u=i?nb(a.slice(1),i):void 0;if(u)return u;if(l.validators.length===0)return;const d=a.join(Th);return(h=l.validators.find(({validator:p})=>p(d)))==null?void 0:h.classGroupId},Bx=/^\[(.+)\]$/,EC=a=>{if(Bx.test(a)){const l=Bx.exec(a)[1],o=l==null?void 0:l.substring(0,l.indexOf(":"));if(o)return"arbitrary.."+o}},RC=a=>{const{theme:l,prefix:o}=a,i={nextPart:new Map,validators:[]};return TC(Object.entries(a.classGroups),o).forEach(([d,h])=>{Gf(h,i,d,l)}),i},Gf=(a,l,o,i)=>{a.forEach(u=>{if(typeof u=="string"){const d=u===""?l:Hx(l,u);d.classGroupId=o;return}if(typeof u=="function"){if(NC(u)){Gf(u(i),l,o,i);return}l.validators.push({validator:u,classGroupId:o});return}Object.entries(u).forEach(([d,h])=>{Gf(h,Hx(l,d),o,i)})})},Hx=(a,l)=>{let o=a;return l.split(Th).forEach(i=>{o.nextPart.has(i)||o.nextPart.set(i,{nextPart:new Map,validators:[]}),o=o.nextPart.get(i)}),o},NC=a=>a.isThemeGetter,TC=(a,l)=>l?a.map(([o,i])=>{const u=i.map(d=>typeof d=="string"?l+d:typeof d=="object"?Object.fromEntries(Object.entries(d).map(([h,p])=>[l+h,p])):d);return[o,u]}):a,AC=a=>{if(a<1)return{get:()=>{},set:()=>{}};let l=0,o=new Map,i=new Map;const u=(d,h)=>{o.set(d,h),l++,l>a&&(l=0,i=o,o=new Map)};return{get(d){let h=o.get(d);if(h!==void 0)return h;if((h=i.get(d))!==void 0)return u(d,h),h},set(d,h){o.has(d)?o.set(d,h):u(d,h)}}},ab="!",MC=a=>{const{separator:l,experimentalParseClassName:o}=a,i=l.length===1,u=l[0],d=l.length,h=p=>{const g=[];let v=0,x=0,y;for(let j=0;j<p.length;j++){let N=p[j];if(v===0){if(N===u&&(i||p.slice(j,j+d)===l)){g.push(p.slice(x,j)),x=j+d;continue}if(N==="/"){y=j;continue}}N==="["?v++:N==="]"&&v--}const S=g.length===0?p:p.substring(x),w=S.startsWith(ab),C=w?S.substring(1):S,E=y&&y>x?y-x:void 0;return{modifiers:g,hasImportantModifier:w,baseClassName:C,maybePostfixModifierPosition:E}};return o?p=>o({className:p,parseClassName:h}):h},DC=a=>{if(a.length<=1)return a;const l=[];let o=[];return a.forEach(i=>{i[0]==="["?(l.push(...o.sort(),i),o=[]):o.push(i)}),l.push(...o.sort()),l},_C=a=>({cache:AC(a.cacheSize),parseClassName:MC(a),...CC(a)}),OC=/\s+/,kC=(a,l)=>{const{parseClassName:o,getClassGroupId:i,getConflictingClassGroupIds:u}=l,d=[],h=a.trim().split(OC);let p="";for(let g=h.length-1;g>=0;g-=1){const v=h[g],{modifiers:x,hasImportantModifier:y,baseClassName:S,maybePostfixModifierPosition:w}=o(v);let C=!!w,E=i(C?S.substring(0,w):S);if(!E){if(!C){p=v+(p.length>0?" "+p:p);continue}if(E=i(S),!E){p=v+(p.length>0?" "+p:p);continue}C=!1}const j=DC(x).join(":"),N=y?j+ab:j,M=N+E;if(d.includes(M))continue;d.push(M);const T=u(E,C);for(let _=0;_<T.length;++_){const O=T[_];d.push(N+O)}p=v+(p.length>0?" "+p:p)}return p};function zC(){let a=0,l,o,i="";for(;a<arguments.length;)(l=arguments[a++])&&(o=lb(l))&&(i&&(i+=" "),i+=o);return i}const lb=a=>{if(typeof a=="string")return a;let l,o="";for(let i=0;i<a.length;i++)a[i]&&(l=lb(a[i]))&&(o&&(o+=" "),o+=l);return o};function LC(a,...l){let o,i,u,d=h;function h(g){const v=l.reduce((x,y)=>y(x),a());return o=_C(v),i=o.cache.get,u=o.cache.set,d=p,p(g)}function p(g){const v=i(g);if(v)return v;const x=kC(g,o);return u(g,x),x}return function(){return d(zC.apply(null,arguments))}}const dt=a=>{const l=o=>o[a]||[];return l.isThemeGetter=!0,l},rb=/^\[(?:([a-z-]+):)?(.+)\]$/i,UC=/^\d+\/\d+$/,BC=new Set(["px","full","screen"]),HC=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,PC=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,qC=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,IC=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,VC=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ya=a=>fs(a)||BC.has(a)||UC.test(a),Dl=a=>Ss(a,"length",ZC),fs=a=>!!a&&!Number.isNaN(Number(a)),Rf=a=>Ss(a,"number",fs),So=a=>!!a&&Number.isInteger(Number(a)),GC=a=>a.endsWith("%")&&fs(a.slice(0,-1)),ke=a=>rb.test(a),_l=a=>HC.test(a),YC=new Set(["length","size","percentage"]),$C=a=>Ss(a,YC,sb),KC=a=>Ss(a,"position",sb),XC=new Set(["image","url"]),FC=a=>Ss(a,XC,WC),QC=a=>Ss(a,"",JC),wo=()=>!0,Ss=(a,l,o)=>{const i=rb.exec(a);return i?i[1]?typeof l=="string"?i[1]===l:l.has(i[1]):o(i[2]):!1},ZC=a=>PC.test(a)&&!qC.test(a),sb=()=>!1,JC=a=>IC.test(a),WC=a=>VC.test(a),eE=()=>{const a=dt("colors"),l=dt("spacing"),o=dt("blur"),i=dt("brightness"),u=dt("borderColor"),d=dt("borderRadius"),h=dt("borderSpacing"),p=dt("borderWidth"),g=dt("contrast"),v=dt("grayscale"),x=dt("hueRotate"),y=dt("invert"),S=dt("gap"),w=dt("gradientColorStops"),C=dt("gradientColorStopPositions"),E=dt("inset"),j=dt("margin"),N=dt("opacity"),M=dt("padding"),T=dt("saturate"),_=dt("scale"),O=dt("sepia"),A=dt("skew"),H=dt("space"),z=dt("translate"),K=()=>["auto","contain","none"],se=()=>["auto","hidden","clip","visible","scroll"],X=()=>["auto",ke,l],I=()=>[ke,l],re=()=>["",Ya,Dl],ee=()=>["auto",fs,ke],oe=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],U=()=>["solid","dashed","dotted","double","none"],$=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],le=()=>["start","end","center","between","around","evenly","stretch"],B=()=>["","0",ke],Z=()=>["auto","avoid","all","avoid-page","page","left","right","column"],D=()=>[fs,ke];return{cacheSize:500,separator:":",theme:{colors:[wo],spacing:[Ya,Dl],blur:["none","",_l,ke],brightness:D(),borderColor:[a],borderRadius:["none","","full",_l,ke],borderSpacing:I(),borderWidth:re(),contrast:D(),grayscale:B(),hueRotate:D(),invert:B(),gap:I(),gradientColorStops:[a],gradientColorStopPositions:[GC,Dl],inset:X(),margin:X(),opacity:D(),padding:I(),saturate:D(),scale:D(),sepia:B(),skew:D(),space:I(),translate:I()},classGroups:{aspect:[{aspect:["auto","square","video",ke]}],container:["container"],columns:[{columns:[_l]}],"break-after":[{"break-after":Z()}],"break-before":[{"break-before":Z()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...oe(),ke]}],overflow:[{overflow:se()}],"overflow-x":[{"overflow-x":se()}],"overflow-y":[{"overflow-y":se()}],overscroll:[{overscroll:K()}],"overscroll-x":[{"overscroll-x":K()}],"overscroll-y":[{"overscroll-y":K()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[E]}],"inset-x":[{"inset-x":[E]}],"inset-y":[{"inset-y":[E]}],start:[{start:[E]}],end:[{end:[E]}],top:[{top:[E]}],right:[{right:[E]}],bottom:[{bottom:[E]}],left:[{left:[E]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",So,ke]}],basis:[{basis:X()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ke]}],grow:[{grow:B()}],shrink:[{shrink:B()}],order:[{order:["first","last","none",So,ke]}],"grid-cols":[{"grid-cols":[wo]}],"col-start-end":[{col:["auto",{span:["full",So,ke]},ke]}],"col-start":[{"col-start":ee()}],"col-end":[{"col-end":ee()}],"grid-rows":[{"grid-rows":[wo]}],"row-start-end":[{row:["auto",{span:[So,ke]},ke]}],"row-start":[{"row-start":ee()}],"row-end":[{"row-end":ee()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ke]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ke]}],gap:[{gap:[S]}],"gap-x":[{"gap-x":[S]}],"gap-y":[{"gap-y":[S]}],"justify-content":[{justify:["normal",...le()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...le(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...le(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[M]}],px:[{px:[M]}],py:[{py:[M]}],ps:[{ps:[M]}],pe:[{pe:[M]}],pt:[{pt:[M]}],pr:[{pr:[M]}],pb:[{pb:[M]}],pl:[{pl:[M]}],m:[{m:[j]}],mx:[{mx:[j]}],my:[{my:[j]}],ms:[{ms:[j]}],me:[{me:[j]}],mt:[{mt:[j]}],mr:[{mr:[j]}],mb:[{mb:[j]}],ml:[{ml:[j]}],"space-x":[{"space-x":[H]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[H]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ke,l]}],"min-w":[{"min-w":[ke,l,"min","max","fit"]}],"max-w":[{"max-w":[ke,l,"none","full","min","max","fit","prose",{screen:[_l]},_l]}],h:[{h:[ke,l,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ke,l,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ke,l,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ke,l,"auto","min","max","fit"]}],"font-size":[{text:["base",_l,Dl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Rf]}],"font-family":[{font:[wo]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",ke]}],"line-clamp":[{"line-clamp":["none",fs,Rf]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Ya,ke]}],"list-image":[{"list-image":["none",ke]}],"list-style-type":[{list:["none","disc","decimal",ke]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[a]}],"placeholder-opacity":[{"placeholder-opacity":[N]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[a]}],"text-opacity":[{"text-opacity":[N]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...U(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Ya,Dl]}],"underline-offset":[{"underline-offset":["auto",Ya,ke]}],"text-decoration-color":[{decoration:[a]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ke]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ke]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[N]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...oe(),KC]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",$C]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},FC]}],"bg-color":[{bg:[a]}],"gradient-from-pos":[{from:[C]}],"gradient-via-pos":[{via:[C]}],"gradient-to-pos":[{to:[C]}],"gradient-from":[{from:[w]}],"gradient-via":[{via:[w]}],"gradient-to":[{to:[w]}],rounded:[{rounded:[d]}],"rounded-s":[{"rounded-s":[d]}],"rounded-e":[{"rounded-e":[d]}],"rounded-t":[{"rounded-t":[d]}],"rounded-r":[{"rounded-r":[d]}],"rounded-b":[{"rounded-b":[d]}],"rounded-l":[{"rounded-l":[d]}],"rounded-ss":[{"rounded-ss":[d]}],"rounded-se":[{"rounded-se":[d]}],"rounded-ee":[{"rounded-ee":[d]}],"rounded-es":[{"rounded-es":[d]}],"rounded-tl":[{"rounded-tl":[d]}],"rounded-tr":[{"rounded-tr":[d]}],"rounded-br":[{"rounded-br":[d]}],"rounded-bl":[{"rounded-bl":[d]}],"border-w":[{border:[p]}],"border-w-x":[{"border-x":[p]}],"border-w-y":[{"border-y":[p]}],"border-w-s":[{"border-s":[p]}],"border-w-e":[{"border-e":[p]}],"border-w-t":[{"border-t":[p]}],"border-w-r":[{"border-r":[p]}],"border-w-b":[{"border-b":[p]}],"border-w-l":[{"border-l":[p]}],"border-opacity":[{"border-opacity":[N]}],"border-style":[{border:[...U(),"hidden"]}],"divide-x":[{"divide-x":[p]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[p]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[N]}],"divide-style":[{divide:U()}],"border-color":[{border:[u]}],"border-color-x":[{"border-x":[u]}],"border-color-y":[{"border-y":[u]}],"border-color-s":[{"border-s":[u]}],"border-color-e":[{"border-e":[u]}],"border-color-t":[{"border-t":[u]}],"border-color-r":[{"border-r":[u]}],"border-color-b":[{"border-b":[u]}],"border-color-l":[{"border-l":[u]}],"divide-color":[{divide:[u]}],"outline-style":[{outline:["",...U()]}],"outline-offset":[{"outline-offset":[Ya,ke]}],"outline-w":[{outline:[Ya,Dl]}],"outline-color":[{outline:[a]}],"ring-w":[{ring:re()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[a]}],"ring-opacity":[{"ring-opacity":[N]}],"ring-offset-w":[{"ring-offset":[Ya,Dl]}],"ring-offset-color":[{"ring-offset":[a]}],shadow:[{shadow:["","inner","none",_l,QC]}],"shadow-color":[{shadow:[wo]}],opacity:[{opacity:[N]}],"mix-blend":[{"mix-blend":[...$(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":$()}],filter:[{filter:["","none"]}],blur:[{blur:[o]}],brightness:[{brightness:[i]}],contrast:[{contrast:[g]}],"drop-shadow":[{"drop-shadow":["","none",_l,ke]}],grayscale:[{grayscale:[v]}],"hue-rotate":[{"hue-rotate":[x]}],invert:[{invert:[y]}],saturate:[{saturate:[T]}],sepia:[{sepia:[O]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[o]}],"backdrop-brightness":[{"backdrop-brightness":[i]}],"backdrop-contrast":[{"backdrop-contrast":[g]}],"backdrop-grayscale":[{"backdrop-grayscale":[v]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[x]}],"backdrop-invert":[{"backdrop-invert":[y]}],"backdrop-opacity":[{"backdrop-opacity":[N]}],"backdrop-saturate":[{"backdrop-saturate":[T]}],"backdrop-sepia":[{"backdrop-sepia":[O]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[h]}],"border-spacing-x":[{"border-spacing-x":[h]}],"border-spacing-y":[{"border-spacing-y":[h]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ke]}],duration:[{duration:D()}],ease:[{ease:["linear","in","out","in-out",ke]}],delay:[{delay:D()}],animate:[{animate:["none","spin","ping","pulse","bounce",ke]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[_]}],"scale-x":[{"scale-x":[_]}],"scale-y":[{"scale-y":[_]}],rotate:[{rotate:[So,ke]}],"translate-x":[{"translate-x":[z]}],"translate-y":[{"translate-y":[z]}],"skew-x":[{"skew-x":[A]}],"skew-y":[{"skew-y":[A]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ke]}],accent:[{accent:["auto",a]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ke]}],"caret-color":[{caret:[a]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ke]}],fill:[{fill:[a,"none"]}],"stroke-w":[{stroke:[Ya,Dl,Rf]}],stroke:[{stroke:[a,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},tE=LC(eE);function Re(...a){return tE(tb(a))}function Mt(a,l="—"){return a==null||Number.isNaN(a)?l:a.toLocaleString()}function kc(a,l=1,o="—"){return a==null||Number.isNaN(a)?o:`${(a*100).toFixed(l)}%`}function dr(a){return a?a<1e3?`${Math.round(a)} ms`:`${(a/1e3).toFixed(2)} s`:"—"}function Ah(a){if(!a)return"—";try{return new Date(a).toLocaleString()}catch{return a}}function nE(a,l=8){return a?a.length>l?`${a.slice(0,l)}…`:a:"—"}function aE(a){if(!a)return"—";const l=Date.now()-new Date(a).getTime();if(!Number.isFinite(l)||l<0)return"—";const o=Math.floor(l/1e3);if(o<60)return`${o}s ago`;const i=Math.floor(o/60);if(i<60)return`${i}m ago`;const u=Math.floor(i/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}const lE=[{to:"/",label:"Dashboard",icon:Fy,end:!0},{to:"/providers",label:"Providers",icon:Jy},{to:"/models",label:"Models",icon:W2},{to:"/combos",label:"Combos",icon:Zy},{to:"/aliases",label:"Aliases",icon:lC},{to:"/api-keys",label:"API Keys",icon:Qy},{to:"/requests",label:"Requests",icon:$y},{to:"/statistics",label:"Statistics",icon:cC},{to:"/audit",label:"Audit Logs",icon:vC},{to:"/settings",label:"Settings",icon:rC}];function rE(){const[a,l]=m.useState(null);return m.useEffect(()=>{let o=!1;return fetch("/api/admin/settings/system",{credentials:"include"}).then(i=>i.ok?i.json():null).then(i=>{!o&&(i!=null&&i.appVersion)&&l(i.appVersion)}).catch(()=>{}),()=>{o=!0}},[]),s.jsxs("aside",{className:"hidden w-60 shrink-0 border-r bg-sidebar text-sidebar-foreground md:flex md:flex-col",children:[s.jsxs("div",{className:"flex h-14 items-center gap-2 border-b px-4",children:[s.jsx("img",{src:"/logo.png",alt:"LateDev Router",className:"h-7 w-7 object-contain"}),s.jsx("div",{className:"font-semibold tracking-tight",children:"LateDev Router"})]}),s.jsx("nav",{className:"flex-1 space-y-0.5 p-2",children:lE.map(o=>s.jsxs(Iy,{to:o.to,end:o.end,className:({isActive:i})=>Re("flex items-center gap-2 rounded-md px-3 py-2 text-sm transition-colors",i?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[s.jsx(o.icon,{className:"h-4 w-4"}),o.label]},o.to))}),s.jsxs("div",{className:"border-t p-3 text-xs text-muted-foreground flex items-center gap-2",children:[s.jsx(xC,{className:"h-3.5 w-3.5 text-primary"})," ",a?`v${a}`:"v…"]})]})}var sE=Object.defineProperty,Mh=(a,l)=>sE(a,"name",{value:l,configurable:!0});function Yf(a,l){if(typeof a=="function")return a(l);a!=null&&(a.current=l)}Mh(Yf,"setRef");function ob(...a){return l=>{let o=!1;const i=a.map(u=>{const d=Yf(u,l);return!o&&typeof d=="function"&&(o=!0),d});if(o)return()=>{for(let u=0;u<i.length;u++){const d=i[u];typeof d=="function"?d():Yf(a[u],null)}}}}Mh(ob,"composeRefs");function Ie(...a){return m.useCallback(ob(...a),a)}Mh(Ie,"useComposedRefs");var oE=Object.defineProperty,ra=(a,l)=>oE(a,"name",{value:l,configurable:!0});function va(a){const l=m.forwardRef((o,i)=>{let{children:u,...d}=o,h=null,p=!1;const g=[];$f(u)&&typeof tc=="function"&&(u=tc(u._payload)),m.Children.forEach(u,S=>{var w;if(fb(S)){p=!0;const C=S;let E="child"in C.props?C.props.child:C.props.children;$f(E)&&typeof tc=="function"&&(E=tc(E._payload)),h=cE(C,E),g.push((w=h==null?void 0:h.props)==null?void 0:w.children)}else g.push(S)}),h?h=m.cloneElement(h,void 0,g):!p&&m.Children.count(u)===1&&m.isValidElement(u)&&(h=u);const v=h?db(h):void 0,x=Ie(i,v);if(!h){if(u||u===0)throw new Error(p?fE(a):dE(a));return u}const y=ub(d,h.props??{});return h.type!==m.Fragment&&(y.ref=i?x:v),m.cloneElement(h,y)});return l.displayName=`${a}.Slot`,l}ra(va,"createSlot");var iE=va("Slot"),ib=Symbol.for("radix.slottable");function cb(a){const l=ra(o=>"child"in o?o.children(o.child):o.children,"Slottable");return l.displayName=`${a}.Slottable`,l.__radixId=ib,l}ra(cb,"createSlottable");var cE=ra((a,l)=>{if("child"in a.props){const o=a.props.child;return m.isValidElement(o)?m.cloneElement(o,void 0,a.props.children(o.props.children)):null}return m.isValidElement(l)?l:null},"getSlottableElementFromSlottable");function ub(a,l){const o={...l};for(const i in l){const u=a[i],d=l[i];/^on[A-Z]/.test(i)?u&&d?o[i]=(...p)=>{const g=d(...p);return u(...p),g}:u&&(o[i]=u):i==="style"?o[i]={...u,...d}:i==="className"&&(o[i]=[u,d].filter(Boolean).join(" "))}return{...a,...o}}ra(ub,"mergeProps");function db(a){var i,u;let l=(i=Object.getOwnPropertyDescriptor(a.props,"ref"))==null?void 0:i.get,o=l&&"isReactWarning"in l&&l.isReactWarning;return o?a.ref:(l=(u=Object.getOwnPropertyDescriptor(a,"ref"))==null?void 0:u.get,o=l&&"isReactWarning"in l&&l.isReactWarning,o?a.props.ref:a.props.ref||a.ref)}ra(db,"getElementRef");function fb(a){return m.isValidElement(a)&&typeof a.type=="function"&&"__radixId"in a.type&&a.type.__radixId===ib}ra(fb,"isSlottable");var uE=Symbol.for("react.lazy");function $f(a){return a!=null&&typeof a=="object"&&"$$typeof"in a&&a.$$typeof===uE&&"_payload"in a&&hb(a._payload)}ra($f,"isLazyComponent");function hb(a){return typeof a=="object"&&a!==null&&"then"in a}ra(hb,"isPromiseLike");var dE=ra(a=>`${a} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),fE=ra(a=>`${a} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),tc=gs[" use ".trim().toString()];const Px=a=>typeof a=="boolean"?`${a}`:a===0?"0":a,qx=tb,mb=(a,l)=>o=>{var i;if((l==null?void 0:l.variants)==null)return qx(a,o==null?void 0:o.class,o==null?void 0:o.className);const{variants:u,defaultVariants:d}=l,h=Object.keys(u).map(v=>{const x=o==null?void 0:o[v],y=d==null?void 0:d[v];if(x===null)return null;const S=Px(x)||Px(y);return u[v][S]}),p=o&&Object.entries(o).reduce((v,x)=>{let[y,S]=x;return S===void 0||(v[y]=S),v},{}),g=l==null||(i=l.compoundVariants)===null||i===void 0?void 0:i.reduce((v,x)=>{let{class:y,className:S,...w}=x;return Object.entries(w).every(C=>{let[E,j]=C;return Array.isArray(j)?j.includes({...d,...p}[E]):{...d,...p}[E]===j})?[...v,y,S]:v},[]);return qx(a,h,g,o==null?void 0:o.class,o==null?void 0:o.className)},hE=mb("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-6",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),he=m.forwardRef(({className:a,variant:l,size:o,asChild:i=!1,...u},d)=>{const h=i?iE:"button";return s.jsx(h,{className:Re(hE({variant:l,size:o,className:a})),ref:d,...u})});he.displayName="Button";const pb=m.createContext(void 0);function mE({children:a,defaultTheme:l="system",storageKey:o="latedev-theme"}){const[i,u]=m.useState(()=>localStorage.getItem(o)||l);m.useEffect(()=>{const h=window.document.documentElement;if(h.classList.remove("light","dark"),i==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";h.classList.add(p);return}h.classList.add(i)},[i]);const d={theme:i,setTheme:h=>{localStorage.setItem(o,h),u(h)}};return s.jsx(pb.Provider,{value:d,children:a})}function pE(){const a=m.useContext(pb);if(!a)throw new Error("useTheme must be used within ThemeProvider");return a}var gE=Object.defineProperty,ws=(a,l)=>gE(a,"name",{value:l,configurable:!0}),gb=!!(typeof window<"u"&&window.document&&window.document.createElement);function Ee(a,l,{checkForDefaultPrevented:o=!0}={}){return ws(function(u){if(a==null||a(u),o===!1||!u||!u.defaultPrevented)return l==null?void 0:l(u)},"handleEvent")}ws(Ee,"composeEventHandlers");function vE(a){var l;if(!gb)throw new Error("Cannot access window outside of the DOM");return((l=a==null?void 0:a.ownerDocument)==null?void 0:l.defaultView)??window}ws(vE,"getOwnerWindow");function Kf(a){if(!gb)throw new Error("Cannot access document outside of the DOM");return(a==null?void 0:a.ownerDocument)??document}ws(Kf,"getOwnerDocument");function vb(a,l=!1){const{activeElement:o}=Kf(a);if(!(o!=null&&o.nodeName))return null;if(xb(o)&&o.contentDocument)return vb(o.contentDocument.body,l);if(l){const i=o.getAttribute("aria-activedescendant");if(i){const u=Kf(o).getElementById(i);if(u)return u}}return o}ws(vb,"getActiveElement");function xb(a){return a.tagName==="IFRAME"}ws(xb,"isFrame");var xE=Object.defineProperty,Pn=(a,l)=>xE(a,"name",{value:l,configurable:!0});function yE(a,l){const o=m.createContext(l);o.displayName=a+"Context";const i=Pn(d=>{const{children:h,...p}=d,g=m.useMemo(()=>p,Object.values(p));return s.jsx(o.Provider,{value:g,children:h})},"Provider");i.displayName=a+"Provider";function u(d,h={}){const{optional:p=!1}=h,g=m.useContext(o);if(g)return g;if(l!==void 0)return l;if(!p)throw new Error(`\`${d}\` must be used within \`${a}\``)}return Pn(u,"useContext"),[i,u]}Pn(yE,"createContext");function fn(a,l=[]){let o=[];function i(d,h){const p=m.createContext(h);p.displayName=d+"Context";const g=o.length;o=[...o,h];const v=Pn(y=>{var N;const{scope:S,children:w,...C}=y,E=((N=S==null?void 0:S[a])==null?void 0:N[g])||p,j=m.useMemo(()=>C,Object.values(C));return s.jsx(E.Provider,{value:j,children:w})},"Provider");v.displayName=d+"Provider";function x(y,S,w={}){var N;const{optional:C=!1}=w,E=((N=S==null?void 0:S[a])==null?void 0:N[g])||p,j=m.useContext(E);if(j)return j;if(h!==void 0)return h;if(!C)throw new Error(`\`${y}\` must be used within \`${d}\``)}return Pn(x,"useContext"),[v,x]}Pn(i,"createContext");const u=Pn(()=>{const d=o.map(h=>m.createContext(h));return Pn(function(p){const g=(p==null?void 0:p[a])||d;return m.useMemo(()=>({[`__scope${a}`]:{...p,[a]:g}}),[p,g])},"useScope")},"createScope");return u.scopeName=a,[i,yb(u,...l)]}Pn(fn,"createContextScope");function yb(...a){const l=a[0];if(a.length===1)return l;const o=Pn(()=>{const i=a.map(u=>({useScope:u(),scopeName:u.scopeName}));return Pn(function(d){const h=i.reduce((p,{useScope:g,scopeName:v})=>{const y=g(d)[`__scope${v}`];return{...p,...y}},{});return m.useMemo(()=>({[`__scope${l.scopeName}`]:h}),[h])},"useComposedScopes")},"createScope");return o.scopeName=l.scopeName,o}Pn(yb,"composeContextScopes");var Dt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},bE=Object.defineProperty,SE=(a,l)=>bE(a,"name",{value:l,configurable:!0}),Ix=gs[" useEffectEvent ".trim().toString()],Vx=gs[" useInsertionEffect ".trim().toString()];function bb(a){if(typeof Ix=="function")return Ix(a);const l=m.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Vx=="function"?Vx(()=>{l.current=a}):Dt(()=>{l.current=a}),m.useMemo(()=>((...o)=>{var i;return(i=l.current)==null?void 0:i.call(l,...o)}),[])}SE(bb,"useEffectEvent");var wE=Object.defineProperty,ko=(a,l)=>wE(a,"name",{value:l,configurable:!0}),jE=gs[" useInsertionEffect ".trim().toString()]||Dt;function Ja({prop:a,defaultProp:l,onChange:o=ko(()=>{},"onChange"),caller:i}){const[u,d,h]=Sb({defaultProp:l,onChange:o}),p=a!==void 0,g=p?a:u,v=m.useCallback(x=>{var y;if(p){const S=wb(x)?x(a):x;S!==a&&((y=h.current)==null||y.call(h,S))}else d(x)},[p,a,d,h]);return[g,v]}ko(Ja,"useControllableState");function Sb({defaultProp:a,onChange:l}){const[o,i]=m.useState(a),u=m.useRef(o),d=m.useRef(l);return jE(()=>{d.current=l},[l]),m.useEffect(()=>{var h;u.current!==o&&((h=d.current)==null||h.call(d,o),u.current=o)},[o,u]),[o,i,d]}ko(Sb,"useUncontrolledState");function wb(a){return typeof a=="function"}ko(wb,"isFunction");var Gx=Symbol("RADIX:SYNC_STATE");function CE(a,l,o,i){const{prop:u,defaultProp:d,onChange:h,caller:p}=l,g=u!==void 0,v=bb(h),x=[{...o,state:d}];i&&x.push(i);const[y,S]=m.useReducer((j,N)=>{if(N.type===Gx)return{...j,state:N.state};const M=a(j,N);return g&&!Object.is(M.state,j.state)&&v(M.state),M},...x),w=y.state,C=m.useRef(w);m.useEffect(()=>{C.current!==w&&(C.current=w,g||v(w))},[w,C,g]);const E=m.useMemo(()=>u!==void 0?{...y,state:u}:y,[y,u]);return m.useEffect(()=>{g&&!Object.is(u,y.state)&&S({type:Gx,state:u})},[u,y.state,g]),[E,S]}ko(CE,"useControllableStateReducer");var EE=Object.defineProperty,RE=(a,l)=>EE(a,"name",{value:l,configurable:!0}),NE=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Be=NE.reduce((a,l)=>{const o=va(`Primitive.${l}`),i=m.forwardRef((u,d)=>{const{asChild:h,...p}=u,g=h?o:l;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(g,{...p,ref:d})});return i.displayName=`Primitive.${l}`,{...a,[l]:i}},{});function Dh(a,l){a&&bs.flushSync(()=>a.dispatchEvent(l))}RE(Dh,"dispatchDiscreteCustomEvent");var TE=Object.defineProperty,zt=(a,l)=>TE(a,"name",{value:l,configurable:!0});function zc(a){const l=a+"CollectionProvider",[o,i]=fn(l),[u,d]=o(l,{collectionRef:{current:null},itemMap:new Map}),h=zt(E=>{const{scope:j,children:N}=E,M=m.useRef(null),T=m.useRef(new Map).current;return s.jsx(u,{scope:j,itemMap:T,collectionRef:M,children:N})},"CollectionProvider");h.displayName=l;const p=a+"CollectionSlot",g=va(p),v=m.forwardRef((E,j)=>{const{scope:N,children:M}=E,T=d(p,N),_=Ie(j,T.collectionRef);return s.jsx(g,{ref:_,children:M})});v.displayName=p;const x=a+"CollectionItemSlot",y="data-radix-collection-item",S=va(x),w=m.forwardRef((E,j)=>{const{scope:N,children:M,...T}=E,_=m.useRef(null),O=Ie(j,_),A=d(x,N);return m.useEffect(()=>(A.itemMap.set(_,{ref:_,...T}),()=>void A.itemMap.delete(_))),s.jsx(S,{[y]:"",ref:O,children:M})});w.displayName=x;function C(E){const j=d(a+"CollectionConsumer",E);return m.useCallback(()=>{const M=j.collectionRef.current;if(!M)return[];const T=Array.from(M.querySelectorAll(`[${y}]`));return Array.from(j.itemMap.values()).sort((A,H)=>T.indexOf(A.ref.current)-T.indexOf(H.ref.current))},[j.collectionRef,j.itemMap])}return zt(C,"useCollection"),[{Provider:h,Slot:v,ItemSlot:w},C,i]}zt(zc,"createCollection");var Yx=new WeakMap,Tt,wn,Nf=(wn=class extends Map{constructor(o){super(o);bx(this,Tt);pf(this,Tt,[...super.keys()]),Yx.set(this,!0)}set(o,i){return Yx.get(this)&&(this.has(o)?Gt(this,Tt)[Gt(this,Tt).indexOf(o)]=o:Gt(this,Tt).push(o)),super.set(o,i),this}insert(o,i,u){const d=this.has(i),h=Gt(this,Tt).length,p=_h(o);let g=p>=0?p:h+p;const v=g<0||g>=h?-1:g;if(v===this.size||d&&v===this.size-1||v===-1)return this.set(i,u),this;const x=this.size+(d?0:1);p<0&&g++;const y=[...Gt(this,Tt)];let S,w=!1;for(let C=g;C<x;C++)if(g===C){let E=y[C];y[C]===i&&(E=y[C+1]),d&&this.delete(i),S=this.get(E),this.set(i,u)}else{!w&&y[C-1]===i&&(w=!0);const E=y[w?C:C-1],j=S;S=this.get(E),this.delete(E),this.set(E,j)}return this}with(o,i,u){const d=new wn(this);return d.insert(o,i,u),d}before(o){const i=Gt(this,Tt).indexOf(o)-1;if(!(i<0))return this.entryAt(i)}setBefore(o,i,u){const d=Gt(this,Tt).indexOf(o);return d===-1?this:this.insert(d,i,u)}after(o){let i=Gt(this,Tt).indexOf(o);if(i=i===-1||i===this.size-1?-1:i+1,i!==-1)return this.entryAt(i)}setAfter(o,i,u){const d=Gt(this,Tt).indexOf(o);return d===-1?this:this.insert(d+1,i,u)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return pf(this,Tt,[]),super.clear()}delete(o){const i=super.delete(o);return i&&Gt(this,Tt).splice(Gt(this,Tt).indexOf(o),1),i}deleteAt(o){const i=this.keyAt(o);return i!==void 0?this.delete(i):!1}at(o){const i=gc(Gt(this,Tt),o);if(i!==void 0)return this.get(i)}entryAt(o){const i=gc(Gt(this,Tt),o);if(i!==void 0)return[i,this.get(i)]}indexOf(o){return Gt(this,Tt).indexOf(o)}keyAt(o){return gc(Gt(this,Tt),o)}from(o,i){const u=this.indexOf(o);if(u===-1)return;let d=u+i;return d<0&&(d=0),d>=this.size&&(d=this.size-1),this.at(d)}keyFrom(o,i){const u=this.indexOf(o);if(u===-1)return;let d=u+i;return d<0&&(d=0),d>=this.size&&(d=this.size-1),this.keyAt(d)}find(o,i){let u=0;for(const d of this){if(Reflect.apply(o,i,[d,u,this]))return d;u++}}findIndex(o,i){let u=0;for(const d of this){if(Reflect.apply(o,i,[d,u,this]))return u;u++}return-1}filter(o,i){const u=[];let d=0;for(const h of this)Reflect.apply(o,i,[h,d,this])&&u.push(h),d++;return new wn(u)}map(o,i){const u=[];let d=0;for(const h of this)u.push([h[0],Reflect.apply(o,i,[h,d,this])]),d++;return new wn(u)}reduce(...o){const[i,u]=o;let d=0,h=u??this.at(0);for(const p of this)d===0&&o.length===1?h=p:h=Reflect.apply(i,this,[h,p,d,this]),d++;return h}reduceRight(...o){const[i,u]=o;let d=u??this.at(-1);for(let h=this.size-1;h>=0;h--){const p=this.at(h);h===this.size-1&&o.length===1?d=p:d=Reflect.apply(i,this,[d,p,h,this])}return d}toSorted(o){const i=[...this.entries()].sort(o);return new wn(i)}toReversed(){const o=new wn;for(let i=this.size-1;i>=0;i--){const u=this.keyAt(i),d=this.get(u);o.set(u,d)}return o}toSpliced(...o){const i=[...this.entries()];return i.splice(...o),new wn(i)}slice(o,i){const u=new wn;let d=this.size-1;if(o===void 0)return u;o<0&&(o=o+this.size),i!==void 0&&i>0&&(d=i-1);for(let h=o;h<=d;h++){const p=this.keyAt(h),g=this.get(p);u.set(p,g)}return u}every(o,i){let u=0;for(const d of this){if(!Reflect.apply(o,i,[d,u,this]))return!1;u++}return!0}some(o,i){let u=0;for(const d of this){if(Reflect.apply(o,i,[d,u,this]))return!0;u++}return!1}},Tt=new WeakMap,zt(wn,"OrderedDict"),wn);function gc(a,l){if("at"in Array.prototype)return Array.prototype.at.call(a,l);const o=jb(a,l);return o===-1?void 0:a[o]}zt(gc,"at");function jb(a,l){const o=a.length,i=_h(l),u=i>=0?i:o+i;return u<0||u>=o?-1:u}zt(jb,"toSafeIndex");function _h(a){return a!==a||a===0?0:Math.trunc(a)}zt(_h,"toSafeInteger");function AE(a){const l=a+"CollectionProvider",[o,i]=fn(l),[u,d]=o(l,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Nf,setItemMap:zt(()=>{},"setItemMap")}),h=zt(({state:T,..._})=>T?s.jsx(g,{..._,state:T}):s.jsx(p,{..._}),"CollectionProvider");h.displayName=l;const p=zt(T=>{const _=j();return s.jsx(g,{...T,state:_})},"CollectionInit");p.displayName=l+"Init";const g=zt(T=>{const{scope:_,children:O,state:A}=T,H=m.useRef(null),[z,K]=m.useState(null),se=Ie(H,K),[X,I]=A;return m.useEffect(()=>{if(!z)return;const re=Rb(()=>{});return re.observe(z,{childList:!0,subtree:!0}),()=>{re.disconnect()}},[z]),s.jsx(u,{scope:_,itemMap:X,setItemMap:I,collectionRef:se,collectionRefObject:H,collectionElement:z,children:O})},"CollectionProviderImpl");g.displayName=l+"Impl";const v=a+"CollectionSlot",x=va(v),y=m.forwardRef((T,_)=>{const{scope:O,children:A}=T,H=d(v,O),z=Ie(_,H.collectionRef);return s.jsx(x,{ref:z,children:A})});y.displayName=v;const S=a+"CollectionItemSlot",w="data-radix-collection-item",C=va(S),E=m.forwardRef((T,_)=>{const{scope:O,children:A,...H}=T,z=m.useRef(null),[K,se]=m.useState(null),X=Ie(_,z,se),I=d(S,O),{setItemMap:re}=I,ee=m.useRef(H);Cb(ee.current,H)||(ee.current=H);const oe=ee.current;return m.useEffect(()=>{const U=oe;return re($=>K?$.has(K)?$.set(K,{...U,element:K}).toSorted(Xf):($.set(K,{...U,element:K}),$.toSorted(Xf)):$),()=>{re($=>!K||!$.has(K)?$:($.delete(K),new Nf($)))}},[K,oe,re]),s.jsx(C,{[w]:"",ref:X,children:A})});E.displayName=S;function j(){return m.useState(new Nf)}zt(j,"useInitCollection");function N(T){const{itemMap:_}=d(a+"CollectionConsumer",T);return _}return zt(N,"useCollection"),[{Provider:h,Slot:y,ItemSlot:E},{createCollectionScope:i,useCollection:N,useInitCollection:j}]}zt(AE,"createCollection");function Cb(a,l){if(a===l)return!0;if(typeof a!="object"||typeof l!="object"||a==null||l==null)return!1;const o=Object.keys(a),i=Object.keys(l);if(o.length!==i.length)return!1;for(const u of o)if(!Object.prototype.hasOwnProperty.call(l,u)||a[u]!==l[u])return!1;return!0}zt(Cb,"shallowEqual");function Eb(a,l){return!!(l.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_PRECEDING)}zt(Eb,"isElementPreceding");function Xf(a,l){return!a[1].element||!l[1].element?0:Eb(a[1].element,l[1].element)?-1:1}zt(Xf,"sortByDocumentPosition");function Rb(a){return new MutationObserver(o=>{for(const i of o)if(i.type==="childList"){a();return}})}zt(Rb,"getChildListObserver");var ME=Object.defineProperty,DE=(a,l)=>ME(a,"name",{value:l,configurable:!0}),_E=m.createContext(void 0);function zo(a){const l=m.useContext(_E);return a||l||"ltr"}DE(zo,"useDirection");var OE=Object.defineProperty,kE=(a,l)=>OE(a,"name",{value:l,configurable:!0});function $n(a){const l=m.useRef(a);return m.useEffect(()=>{l.current=a}),m.useMemo(()=>((...o)=>{var i;return(i=l.current)==null?void 0:i.call(l,...o)}),[])}kE($n,"useCallbackRef");var zE=Object.defineProperty,kt=(a,l)=>zE(a,"name",{value:l,configurable:!0}),Ff="dismissableLayer.update",LE="dismissableLayer.pointerDownOutside",UE="dismissableLayer.focusOutside",$x,Nb=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Lc=m.forwardRef(kt(function(l,o){const{disableOutsidePointerEvents:i=!1,deferPointerDownOutside:u=!1,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:g,onDismiss:v,...x}=l,y=m.useContext(Nb),[S,w]=m.useState(null),C=(S==null?void 0:S.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,E]=m.useState({}),j=Ie(o,w),N=Array.from(y.layers),[M]=[...y.layersWithOutsidePointerEventsDisabled].slice(-1),T=M?N.indexOf(M):-1,_=S?N.indexOf(S):-1,O=y.layersWithOutsidePointerEventsDisabled.size>0,A=_>=T,H=m.useRef(!1),z=Ab(I=>{h==null||h(I),g==null||g(I),I.defaultPrevented||v==null||v()},{ownerDocument:C,deferPointerDownOutside:u,isDeferredPointerDownOutsideRef:H,dismissableSurfaces:y.dismissableSurfaces,shouldHandlePointerDownOutside:m.useCallback(I=>{if(!(I instanceof Node))return!1;const re=[...y.branches].some(ee=>ee.contains(I));return A&&!re},[y.branches,A])}),K=Mb(I=>{if(u&&H.current)return;const re=I.target;[...y.branches].some(oe=>oe.contains(re))||(p==null||p(I),g==null||g(I),I.defaultPrevented||v==null||v())},C),se=S?_===N.length-1:!1,X=$n(I=>{I.key==="Escape"&&(d==null||d(I),!I.defaultPrevented&&v&&(I.preventDefault(),v()))});return m.useEffect(()=>{if(se)return C.addEventListener("keydown",X,{capture:!0}),()=>C.removeEventListener("keydown",X,{capture:!0})},[C,se,X]),m.useEffect(()=>{if(S)return i&&(y.layersWithOutsidePointerEventsDisabled.size===0&&($x=C.body.style.pointerEvents,C.body.style.pointerEvents="none"),y.layersWithOutsidePointerEventsDisabled.add(S)),y.layers.add(S),Qf(),()=>{i&&(y.layersWithOutsidePointerEventsDisabled.delete(S),y.layersWithOutsidePointerEventsDisabled.size===0&&(C.body.style.pointerEvents=$x))}},[S,C,i,y]),m.useEffect(()=>()=>{S&&(y.layers.delete(S),y.layersWithOutsidePointerEventsDisabled.delete(S),Qf())},[S,y]),m.useEffect(()=>{const I=kt(()=>E({}),"handleUpdate");return document.addEventListener(Ff,I),()=>document.removeEventListener(Ff,I)},[]),s.jsx(Be.div,{...x,ref:j,style:{pointerEvents:O?A?"auto":"none":void 0,...l.style},onFocusCapture:Ee(l.onFocusCapture,K.onFocusCapture),onBlurCapture:Ee(l.onBlurCapture,K.onBlurCapture),onPointerDownCapture:Ee(l.onPointerDownCapture,z.onPointerDownCapture)})},"DismissableLayer"));function Tb(){const a=m.useContext(Nb),[l,o]=m.useState(null);return m.useEffect(()=>{if(l)return a.dismissableSurfaces.add(l),()=>{a.dismissableSurfaces.delete(l)}},[l,a.dismissableSurfaces]),o}kt(Tb,"useDismissableLayerSurface");var BE=kt(()=>!0,"IS_TRUE");function Ab(a,l){const{ownerDocument:o=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:i=!1,isDeferredPointerDownOutsideRef:u,dismissableSurfaces:d,shouldHandlePointerDownOutside:h=BE}=l,p=$n(a),g=m.useRef(!1),v=m.useRef(!1),x=m.useRef(new Map),y=m.useRef(()=>{});return m.useEffect(()=>{function S(){v.current=!1,u.current=!1,x.current.clear()}kt(S,"resetOutsideInteraction");function w(){return Array.from(x.current.values()).some(Boolean)}kt(w,"isOutsideInteractionIntercepted");function C(T){if(!v.current)return;const _=T.target;_ instanceof Node&&[...d].some(A=>A.contains(_))||x.current.set(T.type,!0),T.type==="click"&&window.setTimeout(()=>{v.current&&y.current()},0)}kt(C,"handleInteractionCapture");function E(T){v.current&&x.current.set(T.type,!1)}kt(E,"handleInteractionBubble");const j=kt(T=>{if(T.target&&!g.current){let _=function(){o.removeEventListener("click",y.current);const A=w();S(),A||Oh(LE,p,O,{discrete:!0})};if(kt(_,"handleAndDispatchPointerDownOutsideEvent"),!h(T.target)){o.removeEventListener("click",y.current),S(),g.current=!1;return}const O={originalEvent:T};v.current=!0,u.current=i&&T.button===0,x.current.clear(),!i||T.button!==0?_():(o.removeEventListener("click",y.current),y.current=_,o.addEventListener("click",y.current,{once:!0}))}else o.removeEventListener("click",y.current),S();g.current=!1},"handlePointerDown"),N=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const T of N)o.addEventListener(T,C,!0),o.addEventListener(T,E);const M=window.setTimeout(()=>{o.addEventListener("pointerdown",j)},0);return()=>{window.clearTimeout(M),o.removeEventListener("pointerdown",j),o.removeEventListener("click",y.current);for(const T of N)o.removeEventListener(T,C,!0),o.removeEventListener(T,E)}},[o,p,i,u,d,h]),{onPointerDownCapture:kt(()=>g.current=!0,"onPointerDownCapture")}}kt(Ab,"usePointerDownOutside");function Mb(a,l=globalThis==null?void 0:globalThis.document){const o=$n(a),i=m.useRef(!1);return m.useEffect(()=>{const u=kt(d=>{d.target&&!i.current&&Oh(UE,o,{originalEvent:d},{discrete:!1})},"handleFocus");return l.addEventListener("focusin",u),()=>l.removeEventListener("focusin",u)},[l,o]),{onFocusCapture:kt(()=>i.current=!0,"onFocusCapture"),onBlurCapture:kt(()=>i.current=!1,"onBlurCapture")}}kt(Mb,"useFocusOutside");function Qf(){const a=new CustomEvent(Ff);document.dispatchEvent(a)}kt(Qf,"dispatchUpdate");function Oh(a,l,o,{discrete:i}){const u=o.originalEvent.target,d=new CustomEvent(a,{bubbles:!1,cancelable:!0,detail:o});l&&u.addEventListener(a,l,{once:!0}),i?Dh(u,d):u.dispatchEvent(d)}kt(Oh,"handleAndDispatchCustomEvent");var HE=Object.defineProperty,kh=(a,l)=>HE(a,"name",{value:l,configurable:!0}),nc=0,ha=null;function PE(a){return Lo(),a.children}kh(PE,"FocusGuards");function Lo(){m.useEffect(()=>{ha||(ha={start:Zf(),end:Zf()});const{start:a,end:l}=ha;return document.body.firstElementChild!==a&&document.body.insertAdjacentElement("afterbegin",a),document.body.lastElementChild!==l&&document.body.insertAdjacentElement("beforeend",l),nc++,()=>{nc===1&&(ha==null||ha.start.remove(),ha==null||ha.end.remove(),ha=null),nc=Math.max(0,nc-1)}},[])}kh(Lo,"useFocusGuards");function Zf(){const a=document.createElement("span");return a.setAttribute("data-radix-focus-guard",""),a.tabIndex=0,a.style.outline="none",a.style.opacity="0",a.style.position="fixed",a.style.pointerEvents="none",a}kh(Zf,"createFocusGuard");var qE=Object.defineProperty,Qt=(a,l)=>qE(a,"name",{value:l,configurable:!0}),Tf="focusScope.autoFocusOnMount",Af="focusScope.autoFocusOnUnmount",Kx={bubbles:!1,cancelable:!0},zh=m.forwardRef(Qt(function(l,o){const{loop:i=!1,trapped:u=!1,onMountAutoFocus:d,onUnmountAutoFocus:h,...p}=l,[g,v]=m.useState(null),x=$n(d),y=$n(h),S=m.useRef(null),w=Ie(o,v),C=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(u){let j=function(_){if(C.paused||!g)return;const O=_.target;g.contains(O)?S.current=O:$a(S.current,{select:!0})},N=function(_){if(C.paused||!g)return;const O=_.relatedTarget;O!==null&&(g.contains(O)||$a(S.current,{select:!0}))},M=function(_){if(document.activeElement===document.body)for(const A of _)A.removedNodes.length>0&&$a(g)};Qt(j,"handleFocusIn"),Qt(N,"handleFocusOut"),Qt(M,"handleMutations"),document.addEventListener("focusin",j),document.addEventListener("focusout",N);const T=new MutationObserver(M);return g&&T.observe(g,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",N),T.disconnect()}}},[u,g,C.paused]),m.useEffect(()=>{if(g){Xx.add(C);const j=document.activeElement;if(!g.contains(j)){const M=new CustomEvent(Tf,Kx);g.addEventListener(Tf,x),g.dispatchEvent(M),M.defaultPrevented||(Db(Lb(Lh(g)),{select:!0}),document.activeElement===j&&$a(g))}return()=>{g.removeEventListener(Tf,x),setTimeout(()=>{const M=new CustomEvent(Af,Kx);g.addEventListener(Af,y),g.dispatchEvent(M),M.defaultPrevented||$a(j??document.body,{select:!0}),g.removeEventListener(Af,y),Xx.remove(C)},0)}}},[g,x,y,C]);const E=m.useCallback(j=>{if(!i&&!u||C.paused)return;const N=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,M=document.activeElement;if(N&&M){const T=j.currentTarget,[_,O]=_b(T);_&&O?!j.shiftKey&&M===O?(j.preventDefault(),i&&$a(_,{select:!0})):j.shiftKey&&M===_&&(j.preventDefault(),i&&$a(O,{select:!0})):M===T&&j.preventDefault()}},[i,u,C.paused]);return s.jsx(Be.div,{tabIndex:-1,...p,ref:w,onKeyDown:E})},"FocusScope"));function Db(a,{select:l=!1}={}){const o=document.activeElement;for(const i of a)if($a(i,{select:l}),document.activeElement!==o)return}Qt(Db,"focusFirst");function _b(a){const l=Lh(a),o=Jf(l,a),i=Jf(l.reverse(),a);return[o,i]}Qt(_b,"getTabbableEdges");function Lh(a){const l=[],o=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,{acceptNode:Qt(i=>{const u=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||u?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;o.nextNode();)l.push(o.currentNode);return l}Qt(Lh,"getTabbableCandidates");function Jf(a,l){const o=typeof l.checkVisibility=="function"&&l.checkVisibility({checkVisibilityCSS:!0});for(const i of a)if(!(o?!i.checkVisibility({checkVisibilityCSS:!0}):Ob(i,{upTo:l})))return i}Qt(Jf,"findVisible");function Ob(a,{upTo:l}){if(getComputedStyle(a).visibility==="hidden")return!0;for(;a;){if(l!==void 0&&a===l)return!1;if(getComputedStyle(a).display==="none")return!0;a=a.parentElement}return!1}Qt(Ob,"isHidden");function kb(a){return a instanceof HTMLInputElement&&"select"in a}Qt(kb,"isSelectableInput");function $a(a,{select:l=!1}={}){if(a&&a.focus){const o=document.activeElement;a.focus({preventScroll:!0}),a!==o&&kb(a)&&l&&a.select()}}Qt($a,"focus");var Xx=zb();function zb(){let a=[];return{add(l){const o=a[0];l!==o&&(o==null||o.pause()),a=Wf(a,l),a.unshift(l)},remove(l){var o;a=Wf(a,l),(o=a[0])==null||o.resume()}}}Qt(zb,"createFocusScopesStack");function Wf(a,l){const o=[...a],i=o.indexOf(l);return i!==-1&&o.splice(i,1),o}Qt(Wf,"arrayRemove");function Lb(a){return a.filter(l=>l.tagName!=="A")}Qt(Lb,"removeLinks");var IE=Object.defineProperty,VE=(a,l)=>IE(a,"name",{value:l,configurable:!0}),GE=gs[" useId ".trim().toString()]||(()=>{}),YE=0;function ga(a){const[l,o]=m.useState(GE());return Dt(()=>{a||o(i=>i??String(YE++))},[a]),a||(l?`radix-${l}`:"")}VE(ga,"useId");const $E=["top","right","bottom","left"],Bl=Math.min,Xa=Math.max,wc=Math.round,ac=Math.floor,Fa=a=>({x:a,y:a}),KE={left:"right",right:"left",bottom:"top",top:"bottom"};function Ub(a,l,o){return Xa(a,Bl(l,o))}function Wa(a,l){return typeof a=="function"?a(l):a}function Hl(a){return a.split("-")[0]}function js(a){return a.split("-")[1]}function Uh(a){return a==="x"?"y":"x"}function Bh(a){return a==="y"?"height":"width"}function pa(a){const l=a[0];return l==="t"||l==="b"?"y":"x"}function Hh(a){return Uh(pa(a))}function XE(a,l,o){o===void 0&&(o=!1);const i=js(a),u=Hh(a),d=Bh(u);let h=u==="x"?i===(o?"end":"start")?"right":"left":i==="start"?"bottom":"top";return l.reference[d]>l.floating[d]&&(h=jc(h)),[h,jc(h)]}function FE(a){const l=jc(a);return[eh(a),l,eh(l)]}function eh(a){return a.includes("start")?a.replace("start","end"):a.replace("end","start")}const Fx=["left","right"],Qx=["right","left"],QE=["top","bottom"],ZE=["bottom","top"];function JE(a,l,o){switch(a){case"top":case"bottom":return o?l?Qx:Fx:l?Fx:Qx;case"left":case"right":return l?QE:ZE;default:return[]}}function WE(a,l,o,i){const u=js(a);let d=JE(Hl(a),o==="start",i);return u&&(d=d.map(h=>h+"-"+u),l&&(d=d.concat(d.map(eh)))),d}function jc(a){const l=Hl(a);return KE[l]+a.slice(l.length)}function eR(a){var l,o,i,u;return{top:(l=a.top)!=null?l:0,right:(o=a.right)!=null?o:0,bottom:(i=a.bottom)!=null?i:0,left:(u=a.left)!=null?u:0}}function Bb(a){return typeof a!="number"?eR(a):{top:a,right:a,bottom:a,left:a}}function Cc(a){const{x:l,y:o,width:i,height:u}=a;return{width:i,height:u,top:o,left:l,right:l+i,bottom:o+u,x:l,y:o}}function Zx(a,l,o){let{reference:i,floating:u}=a;const d=pa(l),h=Hh(l),p=Bh(h),g=Hl(l),v=d==="y",x=i.x+i.width/2-u.width/2,y=i.y+i.height/2-u.height/2,S=i[p]/2-u[p]/2;let w;switch(g){case"top":w={x,y:i.y-u.height};break;case"bottom":w={x,y:i.y+i.height};break;case"right":w={x:i.x+i.width,y};break;case"left":w={x:i.x-u.width,y};break;default:w={x:i.x,y:i.y}}const C=js(l);return C&&(w[h]+=S*(C==="end"?1:-1)*(o&&v?-1:1)),w}async function tR(a,l){var o;l===void 0&&(l={});const{x:i,y:u,platform:d,rects:h,elements:p,strategy:g}=a,{boundary:v="clippingAncestors",rootBoundary:x="viewport",elementContext:y="floating",altBoundary:S=!1,padding:w=0}=Wa(l,a),C=Bb(w),j=p[S?y==="floating"?"reference":"floating":y],N=Cc(await d.getClippingRect({element:(o=await(d.isElement==null?void 0:d.isElement(j)))==null||o?j:j.contextElement||await(d.getDocumentElement==null?void 0:d.getDocumentElement(p.floating)),boundary:v,rootBoundary:x,strategy:g})),M=y==="floating"?{x:i,y:u,width:h.floating.width,height:h.floating.height}:h.reference,T=await(d.getOffsetParent==null?void 0:d.getOffsetParent(p.floating)),_=await(d.isElement==null?void 0:d.isElement(T))&&await(d.getScale==null?void 0:d.getScale(T))||{x:1,y:1},O=Cc(d.convertOffsetParentRelativeRectToViewportRelativeRect?await d.convertOffsetParentRelativeRectToViewportRelativeRect({elements:p,rect:M,offsetParent:T,strategy:g}):M);return{top:(N.top-O.top+C.top)/_.y,bottom:(O.bottom-N.bottom+C.bottom)/_.y,left:(N.left-O.left+C.left)/_.x,right:(O.right-N.right+C.right)/_.x}}const nR=50,aR=async(a,l,o)=>{const{placement:i="bottom",strategy:u="absolute",middleware:d=[],platform:h}=o,p=h.detectOverflow?h:{...h,detectOverflow:tR},g=await(h.isRTL==null?void 0:h.isRTL(l));let v=await h.getElementRects({reference:a,floating:l,strategy:u}),{x,y}=Zx(v,i,g),S=i,w=0;const C={};for(let E=0;E<d.length;E++){const j=d[E];if(!j)continue;const{name:N,fn:M}=j,{x:T,y:_,data:O,reset:A}=await M({x,y,initialPlacement:i,placement:S,strategy:u,middlewareData:C,rects:v,platform:p,elements:{reference:a,floating:l}});x=T??x,y=_??y,C[N]={...C[N],...O},A&&w<nR&&(w++,typeof A=="object"&&(A.placement&&(S=A.placement),A.rects&&(v=A.rects===!0?await h.getElementRects({reference:a,floating:l,strategy:u}):A.rects),{x,y}=Zx(v,S,g)),E=-1)}return{x,y,placement:S,strategy:u,middlewareData:C}},lR=a=>({name:"arrow",options:a,async fn(l){const{x:o,y:i,placement:u,rects:d,platform:h,elements:p,middlewareData:g}=l,{element:v,padding:x=0}=Wa(a,l)||{};if(v==null)return{};const y=Bb(x),S={x:o,y:i},w=Hh(u),C=Bh(w),E=await h.getDimensions(v),j=w==="y",N=j?"top":"left",M=j?"bottom":"right",T=j?"clientHeight":"clientWidth",_=d.reference[C]+d.reference[w]-S[w]-d.floating[C],O=S[w]-d.reference[w],A=await(h.getOffsetParent==null?void 0:h.getOffsetParent(v));let H=A?A[T]:0;(!H||!await(h.isElement==null?void 0:h.isElement(A)))&&(H=p.floating[T]||d.floating[C]);const z=_/2-O/2,K=H/2-E[C]/2-1,se=Bl(y[N],K),X=Bl(y[M],K),I=H-E[C]-X,re=H/2-E[C]/2+z,ee=Ub(se,re,I),oe=!g.arrow&&js(u)!=null&&re!==ee&&d.reference[C]/2-(re<se?se:X)-E[C]/2<0,U=oe?re<se?re-se:re-I:0;return{[w]:S[w]+U,data:{[w]:ee,centerOffset:re-ee-U,...oe&&{alignmentOffset:U}},reset:oe}}}),rR=function(a){return a===void 0&&(a={}),{name:"flip",options:a,async fn(l){var o,i;const{placement:u,middlewareData:d,rects:h,initialPlacement:p,platform:g,elements:v}=l,{mainAxis:x=!0,crossAxis:y=!0,fallbackPlacements:S,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:C="none",flipAlignment:E=!0,...j}=Wa(a,l);if((o=d.arrow)!=null&&o.alignmentOffset)return{};const N=Hl(u),M=pa(p),T=Hl(p)===p,_=await(g.isRTL==null?void 0:g.isRTL(v.floating)),O=S||(T||!E?[jc(p)]:FE(p)),A=C!=="none";!S&&A&&O.push(...WE(p,E,C,_));const H=[p,...O],z=await g.detectOverflow(l,j),K=[];let se=((i=d.flip)==null?void 0:i.overflows)||[];if(x&&K.push(z[N]),y){const ee=XE(u,h,_);K.push(z[ee[0]],z[ee[1]])}if(se=[...se,{placement:u,overflows:K}],!K.every(ee=>ee<=0)){var X,I;const ee=(((X=d.flip)==null?void 0:X.index)||0)+1,oe=H[ee];if(oe&&(!(y==="alignment"?M!==pa(oe):!1)||se.every(le=>pa(le.placement)===M?le.overflows[0]>0:!0)))return{data:{index:ee,overflows:se},reset:{placement:oe}};let U=(I=se.filter($=>$.overflows[0]<=0).sort(($,le)=>$.overflows[1]-le.overflows[1])[0])==null?void 0:I.placement;if(!U)switch(w){case"bestFit":{var re;const $=(re=se.filter(le=>{if(A){const B=pa(le.placement);return B===M||B==="y"}return!0}).map(le=>[le.placement,le.overflows.filter(B=>B>0).reduce((B,Z)=>B+Z,0)]).sort((le,B)=>le[1]-B[1])[0])==null?void 0:re[0];$&&(U=$);break}case"initialPlacement":U=p;break}if(u!==U)return{reset:{placement:U}}}return{}}}};function Jx(a,l){return{top:a.top-l.height,right:a.right-l.width,bottom:a.bottom-l.height,left:a.left-l.width}}function Wx(a){return $E.some(l=>a[l]>=0)}const sR=function(a){return a===void 0&&(a={}),{name:"hide",options:a,async fn(l){const{rects:o,platform:i}=l,{strategy:u="referenceHidden",...d}=Wa(a,l);switch(u){case"referenceHidden":{const h=await i.detectOverflow(l,{...d,elementContext:"reference"}),p=Jx(h,o.reference);return{data:{referenceHiddenOffsets:p,referenceHidden:Wx(p)}}}case"escaped":{const h=await i.detectOverflow(l,{...d,altBoundary:!0}),p=Jx(h,o.floating);return{data:{escapedOffsets:p,escaped:Wx(p)}}}default:return{}}}}},Hb=new Set(["left","top"]);async function oR(a,l){const{placement:o,platform:i,elements:u}=a,d=await(i.isRTL==null?void 0:i.isRTL(u.floating)),h=Hl(o),p=js(o),g=pa(o)==="y",v=Hb.has(h)?-1:1,x=d&&g?-1:1,y=Wa(l,a);let{mainAxis:S,crossAxis:w,alignmentAxis:C}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:y.mainAxis||0,crossAxis:y.crossAxis||0,alignmentAxis:y.alignmentAxis};return p&&typeof C=="number"&&(w=p==="end"?C*-1:C),g?{x:w*x,y:S*v}:{x:S*v,y:w*x}}const iR=function(a){return a===void 0&&(a=0),{name:"offset",options:a,async fn(l){var o,i;const{x:u,y:d,placement:h,middlewareData:p}=l,g=await oR(l,a);return h===((o=p.offset)==null?void 0:o.placement)&&(i=p.arrow)!=null&&i.alignmentOffset?{}:{x:u+g.x,y:d+g.y,data:{...g,placement:h}}}}},cR=function(a){return a===void 0&&(a={}),{name:"shift",options:a,async fn(l){const{x:o,y:i,placement:u,platform:d}=l,{mainAxis:h=!0,crossAxis:p=!1,limiter:g={fn:M=>{let{x:T,y:_}=M;return{x:T,y:_}}},...v}=Wa(a,l),x={x:o,y:i},y=await d.detectOverflow(l,v),S=pa(u),w=Uh(S);let C=x[w],E=x[S];const j=(M,T)=>Ub(T+y[M==="y"?"top":"left"],T,T-y[M==="y"?"bottom":"right"]);h&&(C=j(w,C)),p&&(E=j(S,E));const N=g.fn({...l,[w]:C,[S]:E});return{...N,data:{x:N.x-o,y:N.y-i,enabled:{[w]:h,[S]:p}}}}}},uR=function(a){return a===void 0&&(a={}),{options:a,fn(l){var o,i;const{x:u,y:d,placement:h,rects:p,middlewareData:g}=l,{offset:v=0,mainAxis:x=!0,crossAxis:y=!0}=Wa(a,l),S={x:u,y:d},w=pa(h),C=Uh(w);let E=S[C],j=S[w];const N=Wa(v,l),M=typeof N=="number"?{mainAxis:N,crossAxis:0}:{mainAxis:(o=N.mainAxis)!=null?o:0,crossAxis:(i=N.crossAxis)!=null?i:0};if(x){const O=C==="y"?"height":"width",A=p.reference[C]-p.floating[O]+M.mainAxis,H=p.reference[C]+p.reference[O]-M.mainAxis;E<A?E=A:E>H&&(E=H)}if(y){var T,_;const O=C==="y"?"width":"height",A=Hb.has(Hl(h)),H=p.reference[w]-p.floating[O]+(A&&((T=g.offset)==null?void 0:T[w])||0)+(A?0:M.crossAxis),z=p.reference[w]+p.reference[O]+(A?0:((_=g.offset)==null?void 0:_[w])||0)-(A?M.crossAxis:0);j<H?j=H:j>z&&(j=z)}return{[C]:E,[w]:j}}}},dR=function(a){return a===void 0&&(a={}),{name:"size",options:a,async fn(l){const{placement:o,rects:i,platform:u,elements:d}=l,{apply:h=()=>{},...p}=Wa(a,l),g=await u.detectOverflow(l,p),v=Hl(o),x=js(o),y=pa(o)==="y",{width:S,height:w}=i.floating;let C,E;v==="top"||v==="bottom"?(C=v,E=x===(await(u.isRTL==null?void 0:u.isRTL(d.floating))?"start":"end")?"left":"right"):(E=v,C=x==="end"?"top":"bottom");const j=w-g.top-g.bottom,N=S-g.left-g.right,M=Bl(w-g[C],j),T=Bl(S-g[E],N),_=l.middlewareData.shift,O=!_;let A=M,H=T;_!=null&&_.enabled.x&&(H=N),_!=null&&_.enabled.y&&(A=j),O&&!x&&(y?H=S-2*Xa(g.left,g.right):A=w-2*Xa(g.top,g.bottom)),await h({...l,availableWidth:H,availableHeight:A});const z=await u.getDimensions(d.floating);return S!==z.width||w!==z.height?{reset:{rects:!0}}:{}}}};function Uc(){return typeof window<"u"}function Cs(a){return Pb(a)?(a.nodeName||"").toLowerCase():"#document"}function un(a){var l;return(a==null||(l=a.ownerDocument)==null?void 0:l.defaultView)||window}function nl(a){var l;return(l=(Pb(a)?a.ownerDocument:a.document)||window.document)==null?void 0:l.documentElement}function Pb(a){return Uc()?a instanceof Node||a instanceof un(a).Node:!1}function xa(a){return Uc()?a instanceof Element||a instanceof un(a).Element:!1}function ql(a){return Uc()?a instanceof HTMLElement||a instanceof un(a).HTMLElement:!1}function ey(a){return!Uc()||typeof ShadowRoot>"u"?!1:a instanceof ShadowRoot||a instanceof un(a).ShadowRoot}function Bc(a){const{overflow:l,overflowX:o,overflowY:i,display:u}=ya(a);return/auto|scroll|overlay|hidden|clip/.test(l+i+o)&&u!=="inline"&&u!=="contents"}function fR(a){return/^(table|td|th)$/.test(Cs(a))}function Hc(a){try{if(a.matches(":popover-open"))return!0}catch{}try{return a.matches(":modal")}catch{return!1}}const hR=/transform|translate|scale|rotate|perspective|filter/,mR=/paint|layout|strict|content/,ir=a=>!!a&&a!=="none";let Mf;function Ph(a){const l=xa(a)?ya(a):a;return ir(l.transform)||ir(l.translate)||ir(l.scale)||ir(l.rotate)||ir(l.perspective)||!qh()&&(ir(l.backdropFilter)||ir(l.filter))||hR.test(l.willChange||"")||mR.test(l.contain||"")}function pR(a){let l=fr(a);for(;ql(l)&&!Eo(l);){if(Ph(l))return l;if(Hc(l))return null;l=fr(l)}return null}function qh(){return Mf==null&&(Mf=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Mf}function Eo(a){return/^(html|body|#document)$/.test(Cs(a))}function ya(a){return un(a).getComputedStyle(a)}function Pc(a){return xa(a)?{scrollLeft:a.scrollLeft,scrollTop:a.scrollTop}:{scrollLeft:a.scrollX,scrollTop:a.scrollY}}function fr(a){if(Cs(a)==="html")return a;const l=a.assignedSlot||a.parentNode||ey(a)&&a.host||nl(a);return ey(l)?l.host:l}function qb(a){const l=fr(a);return Eo(l)?(a.ownerDocument||a).body:ql(l)&&Bc(l)?l:qb(l)}function Ro(a,l,o){var i;l===void 0&&(l=[]),o===void 0&&(o=!0);const u=qb(a),d=u===((i=a.ownerDocument)==null?void 0:i.body),h=un(u);if(d){const p=th(h);return l.concat(h,h.visualViewport||[],Bc(u)?u:[],p&&o?Ro(p):[])}else return l.concat(u,Ro(u,[],o))}function th(a){return a.parent&&Object.getPrototypeOf(a.parent)?a.frameElement:null}function Ib(a){const l=ya(a);let o=parseFloat(l.width)||0,i=parseFloat(l.height)||0;const u=ql(a),d=u?a.offsetWidth:o,h=u?a.offsetHeight:i,p=wc(o)!==d||wc(i)!==h;return p&&(o=d,i=h),{width:o,height:i,$:p}}function Ih(a){return xa(a)?a:a.contextElement}function hs(a){const l=Ih(a);if(!ql(l))return Fa(1);const o=l.getBoundingClientRect(),{width:i,height:u,$:d}=Ib(l);let h=(d?wc(o.width):o.width)/i,p=(d?wc(o.height):o.height)/u;return(!h||!Number.isFinite(h))&&(h=1),(!p||!Number.isFinite(p))&&(p=1),{x:h,y:p}}const gR=Fa(0);function Vb(a){const l=un(a);return!qh()||!l.visualViewport?gR:{x:l.visualViewport.offsetLeft,y:l.visualViewport.offsetTop}}function vR(a,l,o){return l===void 0&&(l=!1),!!o&&l&&o===un(a)}function hr(a,l,o,i){l===void 0&&(l=!1),o===void 0&&(o=!1);const u=a.getBoundingClientRect(),d=Ih(a);let h=Fa(1);l&&(i?xa(i)&&(h=hs(i)):h=hs(a));const p=vR(d,o,i)?Vb(d):Fa(0);let g=(u.left+p.x)/h.x,v=(u.top+p.y)/h.y,x=u.width/h.x,y=u.height/h.y;if(d&&i){const S=un(d),w=xa(i)?un(i):i;let C=S,E=th(C);for(;E&&w!==C;){const j=hs(E),N=E.getBoundingClientRect(),M=ya(E),T=N.left+(E.clientLeft+parseFloat(M.paddingLeft))*j.x,_=N.top+(E.clientTop+parseFloat(M.paddingTop))*j.y;g*=j.x,v*=j.y,x*=j.x,y*=j.y,g+=T,v+=_,C=un(E),E=th(C)}}return Cc({width:x,height:y,x:g,y:v})}function qc(a,l){const o=Pc(a).scrollLeft;return l?l.left+o:hr(nl(a)).left+o}function Gb(a,l){const o=a.getBoundingClientRect(),i=o.left+l.scrollLeft-qc(a,o),u=o.top+l.scrollTop;return{x:i,y:u}}function xR(a){let{elements:l,rect:o,offsetParent:i,strategy:u}=a;const d=u==="fixed",h=nl(i),p=l?Hc(l.floating):!1;if(i===h||p&&d)return o;let g={scrollLeft:0,scrollTop:0},v=Fa(1);const x=Fa(0),y=ql(i);if((y||!d)&&((Cs(i)!=="body"||Bc(h))&&(g=Pc(i)),y)){const w=hr(i);v=hs(i),x.x=w.x+i.clientLeft,x.y=w.y+i.clientTop}const S=h&&!y&&!d?Gb(h,g):Fa(0);return{width:o.width*v.x,height:o.height*v.y,x:o.x*v.x-g.scrollLeft*v.x+x.x+S.x,y:o.y*v.y-g.scrollTop*v.y+x.y+S.y}}function yR(a){return a.getClientRects?Array.from(a.getClientRects()):[]}function bR(a){const l=Pc(a),o=a.ownerDocument.body,i=Xa(a.scrollWidth,a.clientWidth,o.scrollWidth,o.clientWidth),u=Xa(a.scrollHeight,a.clientHeight,o.scrollHeight,o.clientHeight);let d=-l.scrollLeft+qc(a);const h=-l.scrollTop;return ya(o).direction==="rtl"&&(d+=Xa(a.clientWidth,o.clientWidth)-i),{width:i,height:u,x:d,y:h}}const SR=25;function wR(a,l,o){o===void 0&&(o="viewport");const i=o==="layoutViewport",u=un(a),d=nl(a),h=u.visualViewport;let p=d.clientWidth,g=d.clientHeight,v=0,x=0;if(h){const S=!qh()||l==="fixed";i?S||(v=-h.offsetLeft,x=-h.offsetTop):(p=h.width,g=h.height,S&&(v=h.offsetLeft,x=h.offsetTop))}if(qc(d)<=0){const S=d.ownerDocument,w=S.body,C=getComputedStyle(w),E=S.compatMode==="CSS1Compat"&&parseFloat(C.marginLeft)+parseFloat(C.marginRight)||0,j=Math.abs(d.clientWidth-w.clientWidth-E),N=getComputedStyle(d).scrollbarGutter==="stable both-edges"?j/2:j;N<=SR&&(p-=N)}return{width:p,height:g,x:v,y:x}}function jR(a,l){const o=hr(a,!0,l==="fixed"),i=o.top+a.clientTop,u=o.left+a.clientLeft,d=hs(a),h=a.clientWidth*d.x,p=a.clientHeight*d.y,g=u*d.x,v=i*d.y;return{width:h,height:p,x:g,y:v}}function ty(a,l,o){let i;if(l==="viewport"||l==="layoutViewport")i=wR(a,o,l);else if(l==="document")i=bR(nl(a));else if(xa(l))i=jR(l,o);else{const u=Vb(a);i={x:l.x-u.x,y:l.y-u.y,width:l.width,height:l.height}}return Cc(i)}function CR(a,l){const o=l.get(a);if(o)return o;let i=Ro(a,[],!1).filter(p=>xa(p)&&Cs(p)!=="body"),u=null;const d=ya(a).position==="fixed";let h=d?fr(a):a;for(;xa(h)&&!Eo(h);){const p=ya(h),g=Ph(h),v=u?u.position:d?"fixed":"";!g&&(v==="fixed"||v==="absolute"&&p.position==="static")?i=i.filter(y=>y!==h):u=p,h=fr(h)}return l.set(a,i),i}function ER(a){let{element:l,boundary:o,rootBoundary:i,strategy:u}=a;const h=[...o==="clippingAncestors"?Hc(l)?[]:CR(l,this._c):[].concat(o),i],p=ty(l,h[0],u);let g=p.top,v=p.right,x=p.bottom,y=p.left;for(let S=1;S<h.length;S++){const w=ty(l,h[S],u);g=Xa(w.top,g),v=Bl(w.right,v),x=Bl(w.bottom,x),y=Xa(w.left,y)}return{width:v-y,height:x-g,x:y,y:g}}function RR(a){const{width:l,height:o}=Ib(a);return{width:l,height:o}}function NR(a,l,o){const i=ql(l),u=nl(l),d=o==="fixed",h=hr(a,!0,d,l);let p={scrollLeft:0,scrollTop:0};const g=Fa(0);if((i||!d)&&((Cs(l)!=="body"||Bc(u))&&(p=Pc(l)),i)){const S=hr(l,!0,d,l);g.x=S.x+l.clientLeft,g.y=S.y+l.clientTop}!i&&u&&(g.x=qc(u));const v=u&&!i&&!d?Gb(u,p):Fa(0),x=h.left+p.scrollLeft-g.x-v.x,y=h.top+p.scrollTop-g.y-v.y;return{x,y,width:h.width,height:h.height}}function Df(a){return ya(a).position==="static"}function ny(a,l){if(!ql(a)||ya(a).position==="fixed")return null;if(l)return l(a);let o=a.offsetParent;return nl(a)===o&&(o=o.ownerDocument.body),o}function Yb(a,l){const o=un(a);if(Hc(a))return o;if(!ql(a)){let u=fr(a);for(;u&&!Eo(u);){if(xa(u)&&!Df(u))return u;u=fr(u)}return o}let i=ny(a,l);for(;i&&fR(i)&&Df(i);)i=ny(i,l);return i&&Eo(i)&&Df(i)&&!Ph(i)?o:i||pR(a)||o}const TR=async function(a){const l=this.getOffsetParent||Yb,o=this.getDimensions,i=await o(a.floating);return{reference:NR(a.reference,await l(a.floating),a.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function AR(a){return ya(a).direction==="rtl"}const MR={convertOffsetParentRelativeRectToViewportRelativeRect:xR,getDocumentElement:nl,getClippingRect:ER,getOffsetParent:Yb,getElementRects:TR,getClientRects:yR,getDimensions:RR,getScale:hs,isElement:xa,isRTL:AR};function $b(a,l){return a.x===l.x&&a.y===l.y&&a.width===l.width&&a.height===l.height}function DR(a,l,o){let i=null,u;const d=nl(a);function h(){var x;clearTimeout(u),(x=i)==null||x.disconnect(),i=null}function p(x,y){x===void 0&&(x=!1),y===void 0&&(y=1),h();const S=a.getBoundingClientRect(),{left:w,top:C,width:E,height:j}=S;if(x||l(),!E||!j)return;const N=ac(C),M=ac(d.clientWidth-(w+E)),T=ac(d.clientHeight-(C+j)),_=ac(w),A={rootMargin:-N+"px "+-M+"px "+-T+"px "+-_+"px",threshold:Xa(0,Bl(1,y))||1};let H=!0;function z(K){const se=K[0].intersectionRatio;if(!$b(S,a.getBoundingClientRect()))return p();if(se!==y){if(!H)return p();se?p(!1,se):u=setTimeout(()=>{p(!1,1e-7)},1e3)}H=!1}try{i=new IntersectionObserver(z,{...A,root:d.ownerDocument})}catch{i=new IntersectionObserver(z,A)}i.observe(a)}const g=un(a),v=()=>p(o);return g.addEventListener("resize",v),p(!0),()=>{g.removeEventListener("resize",v),h()}}function _R(a,l,o,i){i===void 0&&(i={});const{ancestorScroll:u=!0,ancestorResize:d=!0,elementResize:h=typeof ResizeObserver=="function",layoutShift:p=typeof IntersectionObserver=="function",animationFrame:g=!1}=i,v=Ih(a),x=u||d?[...v?Ro(v):[],...l?Ro(l):[]]:[];x.forEach(N=>{u&&N.addEventListener("scroll",o),d&&N.addEventListener("resize",o)});const y=v&&p?DR(v,o,d):null;let S=-1,w=null;h&&(w=new ResizeObserver(N=>{let[M]=N;M&&M.target===v&&w&&l&&(w.unobserve(l),cancelAnimationFrame(S),S=requestAnimationFrame(()=>{var T;(T=w)==null||T.observe(l)})),o()}),v&&!g&&w.observe(v),l&&w.observe(l));let C,E=g?hr(a):null;g&&j();function j(){const N=hr(a);E&&!$b(E,N)&&o(),E=N,C=requestAnimationFrame(j)}return o(),()=>{var N;x.forEach(M=>{u&&M.removeEventListener("scroll",o),d&&M.removeEventListener("resize",o)}),y==null||y(),(N=w)==null||N.disconnect(),w=null,g&&cancelAnimationFrame(C)}}const OR=iR,kR=cR,zR=rR,LR=dR,UR=sR,ay=lR,BR=uR,HR=(a,l,o)=>{const i=new Map,u=o??{},d={...MR,...u.platform,_c:i};return aR(a,l,{...u,platform:d})};var PR=typeof document<"u",qR=function(){},vc=PR?m.useLayoutEffect:qR;function Ec(a,l){if(a===l)return!0;if(typeof a!=typeof l)return!1;if(typeof a=="function"&&a.toString()===l.toString())return!0;let o,i,u;if(a&&l&&typeof a=="object"){if(Array.isArray(a)){if(o=a.length,o!==l.length)return!1;for(i=o;i--!==0;)if(!Ec(a[i],l[i]))return!1;return!0}if(u=Object.keys(a),o=u.length,o!==Object.keys(l).length)return!1;for(i=o;i--!==0;)if(!{}.hasOwnProperty.call(l,u[i]))return!1;for(i=o;i--!==0;){const d=u[i];if(!(d==="_owner"&&a.$$typeof)&&!Ec(a[d],l[d]))return!1}return!0}return a!==a&&l!==l}function Kb(a){return typeof window>"u"?1:(a.ownerDocument.defaultView||window).devicePixelRatio||1}function ly(a,l){const o=Kb(a);return Math.round(l*o)/o}function _f(a){const l=m.useRef(a);return vc(()=>{l.current=a}),l}function IR(a){a===void 0&&(a={});const{placement:l="bottom",strategy:o="absolute",middleware:i=[],platform:u,elements:{reference:d,floating:h}={},transform:p=!0,whileElementsMounted:g,open:v}=a,[x,y]=m.useState({x:0,y:0,strategy:o,placement:l,middlewareData:{},isPositioned:!1}),[S,w]=m.useState(i);Ec(S,i)||w(i);const[C,E]=m.useState(null),[j,N]=m.useState(null),M=m.useCallback(le=>{le!==A.current&&(A.current=le,E(le))},[]),T=m.useCallback(le=>{le!==H.current&&(H.current=le,N(le))},[]),_=d||C,O=h||j,A=m.useRef(null),H=m.useRef(null),z=m.useRef(x),K=g!=null,se=_f(g),X=_f(u),I=_f(v),re=m.useCallback(()=>{if(!A.current||!H.current)return;const le={placement:l,strategy:o,middleware:S};X.current&&(le.platform=X.current),HR(A.current,H.current,le).then(B=>{const Z={...B,isPositioned:I.current!==!1};ee.current&&!Ec(z.current,Z)&&(z.current=Z,bs.flushSync(()=>{y(Z)}))})},[S,l,o,X,I]);vc(()=>{v===!1&&z.current.isPositioned&&(z.current.isPositioned=!1,y(le=>({...le,isPositioned:!1})))},[v]);const ee=m.useRef(!1);vc(()=>(ee.current=!0,()=>{ee.current=!1}),[]),vc(()=>{if(_&&(A.current=_),O&&(H.current=O),_&&O){if(se.current)return se.current(_,O,re);re()}},[_,O,re,se,K]);const oe=m.useMemo(()=>({reference:A,floating:H,setReference:M,setFloating:T}),[M,T]),U=m.useMemo(()=>({reference:_,floating:O}),[_,O]),$=m.useMemo(()=>{const le={position:o,left:0,top:0};if(!U.floating)return le;const B=ly(U.floating,x.x),Z=ly(U.floating,x.y);return p?{...le,transform:"translate("+B+"px, "+Z+"px)",...Kb(U.floating)>=1.5&&{willChange:"transform"}}:{position:o,left:B,top:Z}},[o,p,U.floating,x.x,x.y]);return m.useMemo(()=>({...x,update:re,refs:oe,elements:U,floatingStyles:$}),[x,re,oe,U,$])}const VR=a=>{function l(o){return{}.hasOwnProperty.call(o,"current")}return{name:"arrow",options:a,fn(o){const{element:i,padding:u}=typeof a=="function"?a(o):a;return i&&l(i)?i.current!=null?ay({element:i.current,padding:u}).fn(o):{}:i?ay({element:i,padding:u}).fn(o):{}}}},GR=(a,l)=>{const o=OR(a);return{name:o.name,fn:o.fn,options:[a,l]}},YR=(a,l)=>{const o=kR(a);return{name:o.name,fn:o.fn,options:[a,l]}},$R=(a,l)=>({fn:BR(a).fn,options:[a,l]}),KR=(a,l)=>{const o=zR(a);return{name:o.name,fn:o.fn,options:[a,l]}},XR=(a,l)=>{const o=LR(a);return{name:o.name,fn:o.fn,options:[a,l]}},FR=(a,l)=>{const o=UR(a);return{name:o.name,fn:o.fn,options:[a,l]}},QR=(a,l)=>{const o=VR(a);return{name:o.name,fn:o.fn,options:[a,l]}};var ZR=Object.defineProperty,JR=(a,l)=>ZR(a,"name",{value:l,configurable:!0});function Ic(a){const[l,o]=m.useState(void 0);return Dt(()=>{if(a){o({width:a.offsetWidth,height:a.offsetHeight});const i=new ResizeObserver(u=>{if(!Array.isArray(u)||!u.length)return;const d=u[0];let h,p;if("borderBoxSize"in d){const g=d.borderBoxSize,v=Array.isArray(g)?g[0]:g;h=v.inlineSize,p=v.blockSize}else h=a.offsetWidth,p=a.offsetHeight;o({width:h,height:p})});return i.observe(a,{box:"border-box"}),()=>i.unobserve(a)}else o(void 0)},[a]),l}JR(Ic,"useSize");var WR=Object.defineProperty,Ll=(a,l)=>WR(a,"name",{value:l,configurable:!0}),Xb="Popper",[Fb,Es]=fn(Xb),[eN,Qb]=Fb(Xb),tN=Ll(a=>{const{__scopePopper:l,children:o}=a,[i,u]=m.useState(null),[d,h]=m.useState(void 0);return s.jsx(eN,{scope:l,anchor:i,onAnchorChange:u,placementState:d,setPlacementState:h,children:o})},"Popper"),nN="PopperAnchor",aN=m.forwardRef(Ll(function(l,o){const{__scopePopper:i,virtualRef:u,...d}=l,h=Qb(nN,i),p=m.useRef(null),g=h.onAnchorChange,v=m.useCallback(E=>{p.current=E,E&&g(E)},[g]),x=Ie(o,v),y=m.useRef(null);m.useEffect(()=>{if(!u)return;const E=y.current;y.current=u.current,E!==y.current&&g(y.current)});const S=h.placementState&&Vc(h.placementState),w=S==null?void 0:S[0],C=S==null?void 0:S[1];return u?null:s.jsx(Be.div,{"data-radix-popper-side":w,"data-radix-popper-align":C,...d,ref:x})},"PopperAnchor")),Zb="PopperContent",[lN,U_]=Fb(Zb),rN=m.forwardRef(Ll(function(l,o){var xe,J,me,je,Me,mt,pt;const{__scopePopper:i,side:u="bottom",sideOffset:d=0,align:h="center",alignOffset:p=0,arrowPadding:g=0,avoidCollisions:v=!0,collisionBoundary:x=[],collisionPadding:y=0,sticky:S="partial",hideWhenDetached:w=!1,updatePositionStrategy:C="optimized",onPlaced:E,...j}=l,N=Qb(Zb,i),[M,T]=m.useState(null),_=Ie(o,T),[O,A]=m.useState(null),H=Ic(O),z=(H==null?void 0:H.width)??0,K=(H==null?void 0:H.height)??0,se=u+(h!=="center"?"-"+h:""),X=typeof y=="number"?y:{top:0,right:0,bottom:0,left:0,...y},I=Array.isArray(x)?x:[x],re=I.length>0,ee={padding:X,boundary:I.filter(Jb),altBoundary:re},{refs:oe,floatingStyles:U,placement:$,isPositioned:le,middlewareData:B}=IR({strategy:"fixed",placement:se,whileElementsMounted:Ll((...bt)=>_R(...bt,{animationFrame:C==="always"}),"whileElementsMounted"),elements:{reference:N.anchor},middleware:[GR({mainAxis:d+K,alignmentAxis:p}),v&&YR({mainAxis:!0,crossAxis:!1,limiter:S==="partial"?$R():void 0,...ee}),v&&KR({...ee}),XR({...ee,apply:Ll(({elements:bt,rects:St,availableWidth:Lt,availableHeight:hn})=>{const{width:Qn,height:mn}=St.reference,ja=bt.floating.style;ja.setProperty("--radix-popper-available-width",`${Lt}px`),ja.setProperty("--radix-popper-available-height",`${hn}px`),ja.setProperty("--radix-popper-anchor-width",`${Qn}px`),ja.setProperty("--radix-popper-anchor-height",`${mn}px`)},"apply")}),O&&QR({element:O,padding:g}),sN({arrowWidth:z,arrowHeight:K}),w&&FR({strategy:"referenceHidden",...ee,boundary:re?ee.boundary:void 0})]}),Z=N.setPlacementState;Dt(()=>(Z($),()=>{Z(void 0)}),[$,Z]);const[D,q]=Vc($),Q=$n(E);Dt(()=>{le&&(Q==null||Q())},[le,Q]);const ae=(xe=B.arrow)==null?void 0:xe.x,ce=(J=B.arrow)==null?void 0:J.y,Se=((me=B.arrow)==null?void 0:me.centerOffset)!==0,[ue,fe]=m.useState();return Dt(()=>{M&&fe(window.getComputedStyle(M).zIndex)},[M]),s.jsx("div",{ref:oe.setFloating,"data-radix-popper-content-wrapper":"",style:{...U,transform:le?U.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ue,"--radix-popper-transform-origin":[(je=B.transformOrigin)==null?void 0:je.x,(Me=B.transformOrigin)==null?void 0:Me.y].join(" "),...((mt=B.hide)==null?void 0:mt.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:l.dir,children:s.jsx(lN,{scope:i,placedSide:D,placedAlign:q,onArrowChange:A,arrowX:ae,arrowY:ce,shouldHideArrow:Se,children:s.jsx(Be.div,{"data-side":D,"data-align":q,...j,ref:_,style:{...j.style,animation:le?(pt=j.style)==null?void 0:pt.animation:"none"}})})})},"PopperContent"));function Jb(a){return a!==null}Ll(Jb,"isNotNull");var sN=Ll(a=>({name:"transformOrigin",options:a,fn(l){var j,N,M;const{placement:o,rects:i,middlewareData:u}=l,h=((j=u.arrow)==null?void 0:j.centerOffset)!==0,p=h?0:a.arrowWidth,g=h?0:a.arrowHeight,[v,x]=Vc(o),y={start:"0%",center:"50%",end:"100%"}[x],S=(((N=u.arrow)==null?void 0:N.x)??0)+p/2,w=(((M=u.arrow)==null?void 0:M.y)??0)+g/2;let C="",E="";return v==="bottom"?(C=h?y:`${S}px`,E=`${-g}px`):v==="top"?(C=h?y:`${S}px`,E=`${i.floating.height+g}px`):v==="right"?(C=`${-g}px`,E=h?y:`${w}px`):v==="left"&&(C=`${i.floating.width+g}px`,E=h?y:`${w}px`),{data:{x:C,y:E}}}}),"transformOrigin");function Vc(a){const[l,o="center"]=a.split("-");return[l,o]}Ll(Vc,"getSideAndAlignFromPlacement");var Wb=tN,e0=aN,Vh=rN,oN=Object.defineProperty,iN=(a,l)=>oN(a,"name",{value:l,configurable:!0}),Gh=m.forwardRef(iN(function(l,o){var g;const{container:i,...u}=l,[d,h]=m.useState(!1);Dt(()=>h(!0),[]);const p=i||d&&((g=globalThis==null?void 0:globalThis.document)==null?void 0:g.body);return p?bs.createPortal(s.jsx(Be.div,{...u,ref:o}),p):null},"Portal")),cN=Object.defineProperty,el=(a,l)=>cN(a,"name",{value:l,configurable:!0});function t0(a,l){return m.useReducer((o,i)=>l[o][i]??o,a)}el(t0,"useStateMachine");var al=el(a=>{const{present:l,children:o}=a,i=n0(l),u=typeof o=="function"?o({present:i.isPresent}):m.Children.only(o),d=a0(i.ref,l0(u));return typeof o=="function"||i.isPresent?m.cloneElement(u,{ref:d}):null},"Presence");function n0(a){const[l,o]=m.useState(),i=m.useRef(null),u=m.useRef(a),d=m.useRef("none"),h=m.useRef(void 0),p=a?"mounted":"unmounted",[g,v]=t0(p,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{g==="mounted"?(d.current=h.current??us(i.current),h.current=void 0):d.current="none"},[g]),Dt(()=>{const x=i.current,y=u.current;if(y!==a){const w=d.current,C=us(x);a?(h.current=C,v("MOUNT")):C==="none"||(x==null?void 0:x.display)==="none"?v("UNMOUNT"):v(y&&w!==C?"ANIMATION_OUT":"UNMOUNT"),u.current=a}},[a,v]),Dt(()=>{if(l){let x;const y=l.ownerDocument.defaultView??window,S=el(C=>{const j=us(i.current).includes(CSS.escape(C.animationName));if(C.target===l&&j&&(v("ANIMATION_END"),!u.current)){const N=l.style.animationFillMode;l.style.animationFillMode="forwards",x=y.setTimeout(()=>{l.style.animationFillMode==="forwards"&&(l.style.animationFillMode=N)})}},"handleAnimationEnd"),w=el(C=>{C.target===l&&(d.current=us(i.current))},"handleAnimationStart");return l.addEventListener("animationstart",w),l.addEventListener("animationcancel",S),l.addEventListener("animationend",S),()=>{y.clearTimeout(x),l.removeEventListener("animationstart",w),l.removeEventListener("animationcancel",S),l.removeEventListener("animationend",S)}}else v("ANIMATION_END")},[l,v]),{isPresent:["mounted","unmountSuspended"].includes(g),ref:m.useCallback(x=>{if(x){const y=getComputedStyle(x);i.current=y,h.current=us(y)}else i.current=null;o(x)},[])}}el(n0,"usePresence");function nh(a,l){if(typeof a=="function")return a(l);a!=null&&(a.current=l)}el(nh,"setRef");function a0(...a){const l=m.useRef(a);return l.current=a,m.useCallback(o=>{const i=l.current;let u=!1;const d=i.map(h=>{const p=nh(h,o);return!u&&typeof p=="function"&&(u=!0),p});if(u)return()=>{for(let h=0;h<d.length;h++){const p=d[h];typeof p=="function"?p():nh(i[h],null)}}},[])}el(a0,"useStableComposedRefs");function us(a){return(a==null?void 0:a.animationName)||"none"}el(us,"getAnimationName");function l0(a){var i,u;let l=(i=Object.getOwnPropertyDescriptor(a.props,"ref"))==null?void 0:i.get,o=l&&"isReactWarning"in l&&l.isReactWarning;return o?a.ref:(l=(u=Object.getOwnPropertyDescriptor(a,"ref"))==null?void 0:u.get,o=l&&"isReactWarning"in l&&l.isReactWarning,o?a.props.ref:a.props.ref||a.ref)}el(l0,"getElementRef");var uN=Object.defineProperty,Yh=(a,l)=>uN(a,"name",{value:l,configurable:!0}),Of=!1;function r0(){const[a,l]=m.useState(Of);return m.useEffect(()=>{Of||(Of=!0,l(!0))},[]),a}Yh(r0,"useIsHydrated");var s0=gs[" useSyncExternalStore ".trim().toString()];function o0(){return()=>{}}Yh(o0,"subscribe");function i0(){return s0(o0,()=>!0,()=>!1)}Yh(i0,"useIsHydratedModern");var dN=typeof s0=="function"?i0:r0,fN=Object.defineProperty,pr=(a,l)=>fN(a,"name",{value:l,configurable:!0}),kf="rovingFocusGroup.onEntryFocus",hN={bubbles:!1,cancelable:!0},Gc="RovingFocusGroup",[ah,c0,mN]=zc(Gc),[pN,Yc]=fn(Gc,[mN]),[gN,vN]=pN(Gc),xN=m.forwardRef(pr(function(l,o){return s.jsx(ah.Provider,{scope:l.__scopeRovingFocusGroup,children:s.jsx(ah.Slot,{scope:l.__scopeRovingFocusGroup,children:s.jsx(yN,{...l,ref:o})})})},"RovingFocusGroup")),yN=m.forwardRef(pr(function(l,o){const{__scopeRovingFocusGroup:i,orientation:u,loop:d=!1,dir:h,currentTabStopId:p,defaultCurrentTabStopId:g,onCurrentTabStopIdChange:v,onEntryFocus:x,preventScrollOnEntryFocus:y=!1,...S}=l,w=m.useRef(null),C=Ie(o,w),E=zo(h),[j,N]=Ja({prop:p,defaultProp:g??null,onChange:v,caller:Gc}),[M,T]=m.useState(!1),_=$n(x),O=c0(i),A=m.useRef(!1),[H,z]=m.useState(0);return m.useEffect(()=>{const K=w.current;if(K)return K.addEventListener(kf,_),()=>K.removeEventListener(kf,_)},[_]),s.jsx(gN,{scope:i,orientation:u,dir:E,loop:d,currentTabStopId:j,onItemFocus:m.useCallback(K=>N(K),[N]),onItemShiftTab:m.useCallback(()=>T(!0),[]),onFocusableItemAdd:m.useCallback(()=>z(K=>K+1),[]),onFocusableItemRemove:m.useCallback(()=>z(K=>K-1),[]),children:s.jsx(Be.div,{tabIndex:M||H===0?-1:0,"data-orientation":u,...S,ref:C,style:{outline:"none",...l.style},onMouseDown:Ee(l.onMouseDown,()=>{A.current=!0}),onFocus:Ee(l.onFocus,K=>{const se=!A.current;if(K.target===K.currentTarget&&se&&!M){const X=new CustomEvent(kf,hN);if(K.currentTarget.dispatchEvent(X),!X.defaultPrevented){const I=O().filter($=>$.focusable),re=I.find($=>$.active),ee=I.find($=>$.id===j),U=[re,ee,...I].filter(Boolean).map($=>$.ref.current);$h(U,y)}}A.current=!1}),onBlur:Ee(l.onBlur,()=>T(!1))})})},"RovingFocusGroupImpl")),bN="RovingFocusGroupItem",SN=m.forwardRef(pr(function(l,o){const{__scopeRovingFocusGroup:i,focusable:u=!0,active:d=!1,tabStopId:h,children:p,...g}=l,v=ga(),x=h||v,y=vN(bN,i),S=y.currentTabStopId===x,w=c0(i),{onFocusableItemAdd:C,onFocusableItemRemove:E,currentTabStopId:j}=y,N=dN();return Dt(()=>{if(!(!N||!u))return C(),()=>E()},[N,u,C,E]),m.useEffect(()=>{if(!(N||!u))return C(),()=>E()},[N,u,C,E]),s.jsx(ah.ItemSlot,{scope:i,id:x,focusable:u,active:d,children:s.jsx(Be.span,{tabIndex:S?0:-1,"data-orientation":y.orientation,...g,ref:o,onMouseDown:Ee(l.onMouseDown,M=>{u?y.onItemFocus(x):M.preventDefault()}),onFocus:Ee(l.onFocus,()=>y.onItemFocus(x)),onKeyDown:Ee(l.onKeyDown,M=>{if(M.key==="Tab"&&M.shiftKey){y.onItemShiftTab();return}if(M.target!==M.currentTarget)return;const T=d0(M,y.orientation,y.dir);if(T!==void 0){if(M.metaKey||M.ctrlKey||M.altKey||M.shiftKey)return;M.preventDefault();let O=w().filter(A=>A.focusable).map(A=>A.ref.current);if(T==="last")O.reverse();else if(T==="prev"||T==="next"){T==="prev"&&O.reverse();const A=O.indexOf(M.currentTarget);O=y.loop?f0(O,A+1):O.slice(A+1)}setTimeout(()=>$h(O))}}),children:typeof p=="function"?p({isCurrentTabStop:S,hasTabStop:j!=null}):p})})},"RovingFocusGroupItem")),wN={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function u0(a,l){return l!=="rtl"?a:a==="ArrowLeft"?"ArrowRight":a==="ArrowRight"?"ArrowLeft":a}pr(u0,"getDirectionAwareKey");function d0(a,l,o){const i=u0(a.key,o);if(!(l==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(l==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return wN[i]}pr(d0,"getFocusIntent");function $h(a,l=!1){const o=document.activeElement;for(const i of a)if(i===o||(i.focus({preventScroll:l}),document.activeElement!==o))return}pr($h,"focusFirst");function f0(a,l){return a.map((o,i)=>a[(l+i)%a.length])}pr(f0,"wrapArray");var h0=xN,m0=SN,jN=function(a){if(typeof document>"u")return null;var l=Array.isArray(a)?a[0]:a;return l.ownerDocument.body},os=new WeakMap,lc=new WeakMap,rc={},zf=0,p0=function(a){return a&&(a.host||p0(a.parentNode))},CN=function(a,l){return l.map(function(o){if(a.contains(o))return o;var i=p0(o);return i&&a.contains(i)?i:(console.error("aria-hidden",o,"in not contained inside",a,". Doing nothing"),null)}).filter(function(o){return!!o})},EN=function(a,l,o,i){var u=CN(l,Array.isArray(a)?a:[a]);rc[o]||(rc[o]=new WeakMap);var d=rc[o],h=[],p=new Set,g=new Set(u),v=function(y){!y||p.has(y)||(p.add(y),v(y.parentNode))};u.forEach(v);var x=function(y){!y||g.has(y)||Array.prototype.forEach.call(y.children,function(S){if(p.has(S))x(S);else try{var w=S.getAttribute(i),C=w!==null&&w!=="false",E=(os.get(S)||0)+1,j=(d.get(S)||0)+1;os.set(S,E),d.set(S,j),h.push(S),E===1&&C&&lc.set(S,!0),j===1&&S.setAttribute(o,"true"),C||S.setAttribute(i,"true")}catch(N){console.error("aria-hidden: cannot operate on ",S,N)}})};return x(l),p.clear(),zf++,function(){h.forEach(function(y){var S=os.get(y)-1,w=d.get(y)-1;os.set(y,S),d.set(y,w),S||(lc.has(y)||y.removeAttribute(i),lc.delete(y)),w||y.removeAttribute(o)}),zf--,zf||(os=new WeakMap,os=new WeakMap,lc=new WeakMap,rc={})}},Kh=function(a,l,o){o===void 0&&(o="data-aria-hidden");var i=Array.from(Array.isArray(a)?a:[a]),u=jN(a);return u?(i.push.apply(i,Array.from(u.querySelectorAll("[aria-live], script"))),EN(i,u,o,"aria-hidden")):function(){return null}},ma=function(){return ma=Object.assign||function(l){for(var o,i=1,u=arguments.length;i<u;i++){o=arguments[i];for(var d in o)Object.prototype.hasOwnProperty.call(o,d)&&(l[d]=o[d])}return l},ma.apply(this,arguments)};function g0(a,l){var o={};for(var i in a)Object.prototype.hasOwnProperty.call(a,i)&&l.indexOf(i)<0&&(o[i]=a[i]);if(a!=null&&typeof Object.getOwnPropertySymbols=="function")for(var u=0,i=Object.getOwnPropertySymbols(a);u<i.length;u++)l.indexOf(i[u])<0&&Object.prototype.propertyIsEnumerable.call(a,i[u])&&(o[i[u]]=a[i[u]]);return o}function RN(a,l,o){if(o||arguments.length===2)for(var i=0,u=l.length,d;i<u;i++)(d||!(i in l))&&(d||(d=Array.prototype.slice.call(l,0,i)),d[i]=l[i]);return a.concat(d||Array.prototype.slice.call(l))}var xc="right-scroll-bar-position",yc="width-before-scroll-bar",NN="with-scroll-bars-hidden",TN="--removed-body-scroll-bar-size";function Lf(a,l){return typeof a=="function"?a(l):a&&(a.current=l),a}function AN(a,l){var o=m.useState(function(){return{value:a,callback:l,facade:{get current(){return o.value},set current(i){var u=o.value;u!==i&&(o.value=i,o.callback(i,u))}}}})[0];return o.callback=l,o.facade}var MN=typeof window<"u"?m.useLayoutEffect:m.useEffect,ry=new WeakMap;function DN(a,l){var o=AN(null,function(i){return a.forEach(function(u){return Lf(u,i)})});return MN(function(){var i=ry.get(o);if(i){var u=new Set(i),d=new Set(a),h=o.current;u.forEach(function(p){d.has(p)||Lf(p,null)}),d.forEach(function(p){u.has(p)||Lf(p,h)})}ry.set(o,a)},[a]),o}function _N(a){return a}function ON(a,l){l===void 0&&(l=_N);var o=[],i=!1,u={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return o.length?o[o.length-1]:a},useMedium:function(d){var h=l(d,i);return o.push(h),function(){o=o.filter(function(p){return p!==h})}},assignSyncMedium:function(d){for(i=!0;o.length;){var h=o;o=[],h.forEach(d)}o={push:function(p){return d(p)},filter:function(){return o}}},assignMedium:function(d){i=!0;var h=[];if(o.length){var p=o;o=[],p.forEach(d),h=o}var g=function(){var x=h;h=[],x.forEach(d)},v=function(){return Promise.resolve().then(g)};v(),o={push:function(x){h.push(x),v()},filter:function(x){return h=h.filter(x),o}}}};return u}function kN(a){a===void 0&&(a={});var l=ON(null);return l.options=ma({async:!0,ssr:!1},a),l}var v0=function(a){var l=a.sideCar,o=g0(a,["sideCar"]);if(!l)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=l.read();if(!i)throw new Error("Sidecar medium not found");return m.createElement(i,ma({},o))};v0.isSideCarExport=!0;function zN(a,l){return a.useMedium(l),v0}var x0=kN(),Uf=function(){},$c=m.forwardRef(function(a,l){var o=m.useRef(null),i=m.useState({onScrollCapture:Uf,onWheelCapture:Uf,onTouchMoveCapture:Uf}),u=i[0],d=i[1],h=a.forwardProps,p=a.children,g=a.className,v=a.removeScrollBar,x=a.enabled,y=a.shards,S=a.sideCar,w=a.noRelative,C=a.noIsolation,E=a.inert,j=a.allowPinchZoom,N=a.as,M=N===void 0?"div":N,T=a.gapMode,_=g0(a,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),O=S,A=DN([o,l]),H=ma(ma({},_),u);return m.createElement(m.Fragment,null,x&&m.createElement(O,{sideCar:x0,removeScrollBar:v,shards:y,noRelative:w,noIsolation:C,inert:E,setCallbacks:d,allowPinchZoom:!!j,lockRef:o,gapMode:T}),h?m.cloneElement(m.Children.only(p),ma(ma({},H),{ref:A})):m.createElement(M,ma({},H,{className:g,ref:A}),p))});$c.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};$c.classNames={fullWidth:yc,zeroRight:xc};var LN=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function UN(){if(!document)return null;var a=document.createElement("style");a.type="text/css";var l=LN();return l&&a.setAttribute("nonce",l),a}function BN(a,l){a.styleSheet?a.styleSheet.cssText=l:a.appendChild(document.createTextNode(l))}function HN(a){var l=document.head||document.getElementsByTagName("head")[0];l.appendChild(a)}var PN=function(){var a=0,l=null;return{add:function(o){a==0&&(l=UN())&&(BN(l,o),HN(l)),a++},remove:function(){a--,!a&&l&&(l.parentNode&&l.parentNode.removeChild(l),l=null)}}},qN=function(){var a=PN();return function(l,o){m.useEffect(function(){return a.add(l),function(){a.remove()}},[l&&o])}},y0=function(){var a=qN(),l=function(o){var i=o.styles,u=o.dynamic;return a(i,u),null};return l},IN={left:0,top:0,right:0,gap:0},Bf=function(a){return parseInt(a||"",10)||0},VN=function(a){var l=window.getComputedStyle(document.body),o=l[a==="padding"?"paddingLeft":"marginLeft"],i=l[a==="padding"?"paddingTop":"marginTop"],u=l[a==="padding"?"paddingRight":"marginRight"];return[Bf(o),Bf(i),Bf(u)]},GN=function(a){if(a===void 0&&(a="margin"),typeof window>"u")return IN;var l=VN(a),o=document.documentElement.clientWidth,i=window.innerWidth;return{left:l[0],top:l[1],right:l[2],gap:Math.max(0,i-o+l[2]-l[0])}},YN=y0(),ms="data-scroll-locked",$N=function(a,l,o,i){var u=a.left,d=a.top,h=a.right,p=a.gap;return o===void 0&&(o="margin"),`
286
286
  .`.concat(NN,` {
287
287
  overflow: hidden `).concat(i,`;
288
288
  padding-right: `).concat(p,"px ").concat(i,`;
@@ -319,12 +319,12 @@ Please change the parent <Route path="${N}"> to <Route path="${N==="/"?"*":`${N}
319
319
  body[`).concat(ms,`] {
320
320
  `).concat(TN,": ").concat(p,`px;
321
321
  }
322
- `)},sy=function(){var a=parseInt(document.body.getAttribute(ms)||"0",10);return isFinite(a)?a:0},KN=function(){m.useEffect(function(){return document.body.setAttribute(ms,(sy()+1).toString()),function(){var a=sy()-1;a<=0?document.body.removeAttribute(ms):document.body.setAttribute(ms,a.toString())}},[])},XN=function(a){var l=a.noRelative,o=a.noImportant,i=a.gapMode,u=i===void 0?"margin":i;KN();var d=m.useMemo(function(){return GN(u)},[u]);return m.createElement(YN,{styles:$N(d,!l,u,o?"":"!important")})},lh=!1;if(typeof window<"u")try{var sc=Object.defineProperty({},"passive",{get:function(){return lh=!0,!0}});window.addEventListener("test",sc,sc),window.removeEventListener("test",sc,sc)}catch{lh=!1}var is=lh?{passive:!1}:!1,FN=function(a){return a.tagName==="TEXTAREA"},bb=function(a,l){if(!(a instanceof Element))return!1;var o=window.getComputedStyle(a);return o[l]!=="hidden"&&!(o.overflowY===o.overflowX&&!FN(a)&&o[l]==="visible")},QN=function(a){return bb(a,"overflowY")},ZN=function(a){return bb(a,"overflowX")},oy=function(a,l){var o=l.ownerDocument,i=l;do{typeof ShadowRoot<"u"&&i instanceof ShadowRoot&&(i=i.host);var u=Sb(a,i);if(u){var d=wb(a,i),h=d[1],p=d[2];if(h>p)return!0}i=i.parentNode}while(i&&i!==o.body);return!1},JN=function(a){var l=a.scrollTop,o=a.scrollHeight,i=a.clientHeight;return[l,o,i]},WN=function(a){var l=a.scrollLeft,o=a.scrollWidth,i=a.clientWidth;return[l,o,i]},Sb=function(a,l){return a==="v"?QN(l):ZN(l)},wb=function(a,l){return a==="v"?JN(l):WN(l)},eT=function(a,l){return a==="h"&&l==="rtl"?-1:1},tT=function(a,l,o,i,u){var d=eT(a,window.getComputedStyle(l).direction),h=d*i,p=o.target,g=l.contains(p),v=!1,x=h>0,y=0,S=0;do{if(!p)break;var w=wb(a,p),C=w[0],E=w[1],j=w[2],N=E-j-d*C;(C||N)&&Sb(a,p)&&(y+=N,S+=C);var M=p.parentNode;p=M&&M.nodeType===Node.DOCUMENT_FRAGMENT_NODE?M.host:M}while(!g&&p!==document.body||g&&(l.contains(p)||l===p));return(x&&Math.abs(y)<1||!x&&Math.abs(S)<1)&&(v=!0),v},oc=function(a){return"changedTouches"in a?[a.changedTouches[0].clientX,a.changedTouches[0].clientY]:[0,0]},iy=function(a){return[a.deltaX,a.deltaY]},cy=function(a){return a&&"current"in a?a.current:a},nT=function(a,l){return a[0]===l[0]&&a[1]===l[1]},aT=function(a){return`
322
+ `)},sy=function(){var a=parseInt(document.body.getAttribute(ms)||"0",10);return isFinite(a)?a:0},KN=function(){m.useEffect(function(){return document.body.setAttribute(ms,(sy()+1).toString()),function(){var a=sy()-1;a<=0?document.body.removeAttribute(ms):document.body.setAttribute(ms,a.toString())}},[])},XN=function(a){var l=a.noRelative,o=a.noImportant,i=a.gapMode,u=i===void 0?"margin":i;KN();var d=m.useMemo(function(){return GN(u)},[u]);return m.createElement(YN,{styles:$N(d,!l,u,o?"":"!important")})},lh=!1;if(typeof window<"u")try{var sc=Object.defineProperty({},"passive",{get:function(){return lh=!0,!0}});window.addEventListener("test",sc,sc),window.removeEventListener("test",sc,sc)}catch{lh=!1}var is=lh?{passive:!1}:!1,FN=function(a){return a.tagName==="TEXTAREA"},b0=function(a,l){if(!(a instanceof Element))return!1;var o=window.getComputedStyle(a);return o[l]!=="hidden"&&!(o.overflowY===o.overflowX&&!FN(a)&&o[l]==="visible")},QN=function(a){return b0(a,"overflowY")},ZN=function(a){return b0(a,"overflowX")},oy=function(a,l){var o=l.ownerDocument,i=l;do{typeof ShadowRoot<"u"&&i instanceof ShadowRoot&&(i=i.host);var u=S0(a,i);if(u){var d=w0(a,i),h=d[1],p=d[2];if(h>p)return!0}i=i.parentNode}while(i&&i!==o.body);return!1},JN=function(a){var l=a.scrollTop,o=a.scrollHeight,i=a.clientHeight;return[l,o,i]},WN=function(a){var l=a.scrollLeft,o=a.scrollWidth,i=a.clientWidth;return[l,o,i]},S0=function(a,l){return a==="v"?QN(l):ZN(l)},w0=function(a,l){return a==="v"?JN(l):WN(l)},eT=function(a,l){return a==="h"&&l==="rtl"?-1:1},tT=function(a,l,o,i,u){var d=eT(a,window.getComputedStyle(l).direction),h=d*i,p=o.target,g=l.contains(p),v=!1,x=h>0,y=0,S=0;do{if(!p)break;var w=w0(a,p),C=w[0],E=w[1],j=w[2],N=E-j-d*C;(C||N)&&S0(a,p)&&(y+=N,S+=C);var M=p.parentNode;p=M&&M.nodeType===Node.DOCUMENT_FRAGMENT_NODE?M.host:M}while(!g&&p!==document.body||g&&(l.contains(p)||l===p));return(x&&Math.abs(y)<1||!x&&Math.abs(S)<1)&&(v=!0),v},oc=function(a){return"changedTouches"in a?[a.changedTouches[0].clientX,a.changedTouches[0].clientY]:[0,0]},iy=function(a){return[a.deltaX,a.deltaY]},cy=function(a){return a&&"current"in a?a.current:a},nT=function(a,l){return a[0]===l[0]&&a[1]===l[1]},aT=function(a){return`
323
323
  .block-interactivity-`.concat(a,` {pointer-events: none;}
324
324
  .allow-interactivity-`).concat(a,` {pointer-events: all;}
325
- `)},lT=0,cs=[];function rT(a){var l=m.useRef([]),o=m.useRef([0,0]),i=m.useRef(),u=m.useState(lT++)[0],d=m.useState(yb)[0],h=m.useRef(a);m.useEffect(function(){h.current=a},[a]),m.useEffect(function(){if(a.inert){document.body.classList.add("block-interactivity-".concat(u));var E=RN([a.lockRef.current],(a.shards||[]).map(cy),!0).filter(Boolean);return E.forEach(function(j){return j.classList.add("allow-interactivity-".concat(u))}),function(){document.body.classList.remove("block-interactivity-".concat(u)),E.forEach(function(j){return j.classList.remove("allow-interactivity-".concat(u))})}}},[a.inert,a.lockRef.current,a.shards]);var p=m.useCallback(function(E,j){if("touches"in E&&E.touches.length===2||E.type==="wheel"&&E.ctrlKey)return!h.current.allowPinchZoom;var N=oc(E),M=o.current,T="deltaX"in E?E.deltaX:M[0]-N[0],_="deltaY"in E?E.deltaY:M[1]-N[1],O,A=E.target,H=Math.abs(T)>Math.abs(_)?"h":"v";if("touches"in E&&H==="h"&&A.type==="range")return!1;var z=window.getSelection(),K=z&&z.anchorNode,se=K?K===A||K.contains(A):!1;if(se)return!1;var X=oy(H,A);if(!X)return!0;if(X?O=H:(O=H==="v"?"h":"v",X=oy(H,A)),!X)return!1;if(!i.current&&"changedTouches"in E&&(T||_)&&(i.current=O),!O)return!0;var I=i.current||O;return tT(I,j,E,I==="h"?T:_)},[]),g=m.useCallback(function(E){var j=E;if(!(!cs.length||cs[cs.length-1]!==d)){var N="deltaY"in j?iy(j):oc(j),M=l.current.filter(function(O){return O.name===j.type&&(O.target===j.target||j.target===O.shadowParent)&&nT(O.delta,N)})[0];if(M&&M.should){j.cancelable&&j.preventDefault();return}if(!M){var T=(h.current.shards||[]).map(cy).filter(Boolean).filter(function(O){return O.contains(j.target)}),_=T.length>0?p(j,T[0]):!h.current.noIsolation;_&&j.cancelable&&j.preventDefault()}}},[]),v=m.useCallback(function(E,j,N,M){var T={name:E,delta:j,target:N,should:M,shadowParent:sT(N)};l.current.push(T),setTimeout(function(){l.current=l.current.filter(function(_){return _!==T})},1)},[]),x=m.useCallback(function(E){o.current=oc(E),i.current=void 0},[]),y=m.useCallback(function(E){v(E.type,iy(E),E.target,p(E,a.lockRef.current))},[]),S=m.useCallback(function(E){v(E.type,oc(E),E.target,p(E,a.lockRef.current))},[]);m.useEffect(function(){return cs.push(d),a.setCallbacks({onScrollCapture:y,onWheelCapture:y,onTouchMoveCapture:S}),document.addEventListener("wheel",g,is),document.addEventListener("touchmove",g,is),document.addEventListener("touchstart",x,is),function(){cs=cs.filter(function(E){return E!==d}),document.removeEventListener("wheel",g,is),document.removeEventListener("touchmove",g,is),document.removeEventListener("touchstart",x,is)}},[]);var w=a.removeScrollBar,C=a.inert;return m.createElement(m.Fragment,null,C?m.createElement(d,{styles:aT(u)}):null,w?m.createElement(XN,{noRelative:a.noRelative,gapMode:a.gapMode}):null)}function sT(a){for(var l=null;a!==null;)a instanceof ShadowRoot&&(l=a.host,a=a.host),a=a.parentNode;return l}const oT=zN(xb,rT);var Kc=m.forwardRef(function(a,l){return m.createElement($c,ma({},a,{ref:l,sideCar:oT}))});Kc.classNames=$c.classNames;var iT=Object.defineProperty,it=(a,l)=>iT(a,"name",{value:l,configurable:!0}),cT=["Enter"," "],uT=["ArrowDown","PageUp","Home"],jb=["ArrowUp","PageDown","End"],dT=[...uT,...jb],Xc="Menu",[rh,fT,hT]=zc(Xc),[gr,Cb]=fn(Xc,[hT,Es,Yc]),Xh=Es(),Eb=Yc(),[mT,Uo]=gr(Xc),[pT,Fh]=gr(Xc),gT=it(a=>{const{__scopeMenu:l,open:o=!1,children:i,dir:u,onOpenChange:d,modal:h=!0}=a,p=Xh(l),[g,v]=m.useState(null),x=m.useRef(!1),y=$n(d),S=zo(u);return m.useEffect(()=>{const w=it(()=>{x.current=!0,document.addEventListener("pointerdown",C,{capture:!0,once:!0}),document.addEventListener("pointermove",C,{capture:!0,once:!0})},"handleKeyDown"),C=it(()=>x.current=!1,"handlePointer");return document.addEventListener("keydown",w,{capture:!0}),()=>{document.removeEventListener("keydown",w,{capture:!0}),document.removeEventListener("pointerdown",C,{capture:!0}),document.removeEventListener("pointermove",C,{capture:!0})}},[]),m.useEffect(()=>{if(!o)return;const w=it(()=>y(!1),"handleBlur");return window.addEventListener("blur",w),()=>window.removeEventListener("blur",w)},[o,y]),s.jsx(W0,{...p,children:s.jsx(mT,{scope:l,open:o,onOpenChange:y,content:g,onContentChange:v,children:s.jsx(pT,{scope:l,onClose:m.useCallback(()=>y(!1),[y]),isUsingKeyboardRef:x,dir:S,modal:h,children:i})})})},"Menu"),vT=m.forwardRef(it(function(l,o){const{__scopeMenu:i,...u}=l,d=Xh(i);return s.jsx(eb,{...d,...u,ref:o})},"MenuAnchor")),Rb="MenuPortal",[xT,yT]=gr(Rb,{forceMount:void 0}),bT=it(a=>{const{__scopeMenu:l,forceMount:o,children:i,container:u}=a,d=Uo(Rb,l);return s.jsx(xT,{scope:l,forceMount:o,children:s.jsx(al,{present:o||d.open,children:s.jsx(Gh,{asChild:!0,container:u,children:i})})})},"MenuPortal"),Ul="MenuContent",[ST,Nb]=gr(Ul),wT=m.forwardRef(it(function(l,o){const i=yT(Ul,l.__scopeMenu),{forceMount:u=i.forceMount,...d}=l,h=Uo(Ul,l.__scopeMenu),p=Fh(Ul,l.__scopeMenu);return s.jsx(rh.Provider,{scope:l.__scopeMenu,children:s.jsx(al,{present:u||h.open,children:s.jsx(rh.Slot,{scope:l.__scopeMenu,children:p.modal?s.jsx(jT,{...d,ref:o}):s.jsx(CT,{...d,ref:o})})})})},"MenuContent")),jT=m.forwardRef(it(function(l,o){const i=Uo(Ul,l.__scopeMenu),u=m.useRef(null),d=Ie(o,u);return m.useEffect(()=>{const h=u.current;if(h)return Kh(h)},[]),s.jsx(Tb,{...l,ref:d,trapFocus:i.open,disableOutsidePointerEvents:i.open,disableOutsideScroll:!0,onFocusOutside:Ee(l.onFocusOutside,h=>h.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>i.onOpenChange(!1)})},"MenuRootContentModal")),CT=m.forwardRef(it(function(l,o){const i=Uo(Ul,l.__scopeMenu);return s.jsx(Tb,{...l,ref:o,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>i.onOpenChange(!1)})},"MenuRootContentNonModal")),ET=va("MenuContent.ScrollLock"),Tb=m.forwardRef(it(function(l,o){const{__scopeMenu:i,loop:u=!1,trapFocus:d,onOpenAutoFocus:h,onCloseAutoFocus:p,disableOutsidePointerEvents:g,onEntryFocus:v,onEscapeKeyDown:x,onPointerDownOutside:y,onFocusOutside:S,onInteractOutside:w,onDismiss:C,disableOutsideScroll:E,...j}=l,N=Uo(Ul,i),M=Fh(Ul,i),T=Xh(i),_=Eb(i),O=fT(i),[A,H]=m.useState(null),z=m.useRef(null),K=Ie(o,z,N.onContentChange),se=m.useRef(0),X=m.useRef(""),I=m.useRef(0),re=m.useRef(null),ee=m.useRef("right"),oe=m.useRef(0),U=E?Kc:m.Fragment,$=E?{as:ET,allowPinchZoom:!0}:void 0,le=it(Z=>{var fe,xe;const D=X.current+Z,q=O().filter(J=>!J.disabled),Q=document.activeElement,ae=(fe=q.find(J=>J.ref.current===Q))==null?void 0:fe.textValue,ce=q.map(J=>J.textValue),Se=Ob(ce,D,ae),ue=(xe=q.find(J=>J.textValue===Se))==null?void 0:xe.ref.current;it((function J(me){X.current=me,window.clearTimeout(se.current),me!==""&&(se.current=window.setTimeout(()=>J(""),1e3))}),"updateSearch")(D),ue&&setTimeout(()=>ue.focus())},"handleTypeaheadSearch");m.useEffect(()=>()=>window.clearTimeout(se.current),[]),Lo();const B=m.useCallback(Z=>{var q,Q;return ee.current===((q=re.current)==null?void 0:q.side)&&zb(Z,(Q=re.current)==null?void 0:Q.area)},[]);return s.jsx(ST,{scope:i,searchRef:X,onItemEnter:m.useCallback(Z=>{B(Z)&&Z.preventDefault()},[B]),onItemLeave:m.useCallback(Z=>{var D;B(Z)||((D=z.current)==null||D.focus(),H(null))},[B]),onTriggerLeave:m.useCallback(Z=>{B(Z)&&Z.preventDefault()},[B]),pointerGraceTimerRef:I,onPointerGraceIntentChange:m.useCallback(Z=>{re.current=Z},[]),children:s.jsx(U,{...$,children:s.jsx(zh,{asChild:!0,trapped:d,onMountAutoFocus:Ee(h,Z=>{var D;Z.preventDefault(),(D=z.current)==null||D.focus({preventScroll:!0})}),onUnmountAutoFocus:p,children:s.jsx(Lc,{asChild:!0,disableOutsidePointerEvents:g,onEscapeKeyDown:x,onPointerDownOutside:y,onFocusOutside:S,onInteractOutside:w,onDismiss:C,children:s.jsx(hb,{asChild:!0,..._,dir:M.dir,orientation:"vertical",loop:u,currentTabStopId:A,onCurrentTabStopIdChange:H,onEntryFocus:Ee(v,Z=>{M.isUsingKeyboardRef.current||Z.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(Vh,{role:"menu","aria-orientation":"vertical","data-state":Ab(N.open),"data-radix-menu-content":"",dir:M.dir,...T,...j,ref:K,style:{outline:"none",...j.style},onKeyDown:Ee(j.onKeyDown,Z=>{const q=Z.target.closest("[data-radix-menu-content]")===Z.currentTarget,Q=Z.ctrlKey||Z.altKey||Z.metaKey,ae=Z.key.length===1;q&&(Z.key==="Tab"&&Z.preventDefault(),!Q&&ae&&le(Z.key));const ce=z.current;if(Z.target!==ce||!dT.includes(Z.key))return;Z.preventDefault();const ue=O().filter(fe=>!fe.disabled).map(fe=>fe.ref.current);jb.includes(Z.key)&&ue.reverse(),Db(ue)}),onBlur:Ee(l.onBlur,Z=>{Z.currentTarget.contains(Z.target)||(window.clearTimeout(se.current),X.current="")}),onPointerMove:Ee(l.onPointerMove,Rc(Z=>{const D=Z.target,q=oe.current!==Z.clientX;if(Z.currentTarget.contains(D)&&q){const Q=Z.clientX>oe.current?"right":"left";ee.current=Q,oe.current=Z.clientX}}))})})})})})})},"MenuContentImpl")),RT=m.forwardRef(it(function(l,o){const{__scopeMenu:i,...u}=l;return s.jsx(Be.div,{...u,ref:o})},"MenuLabel")),sh="MenuItem",uy="menu.itemSelect",NT=m.forwardRef(it(function(l,o){const{disabled:i=!1,onSelect:u,...d}=l,h=m.useRef(null),p=Fh(sh,l.__scopeMenu),g=Nb(sh,l.__scopeMenu),v=Ie(o,h),x=m.useRef(!1),y=it(()=>{const S=h.current;if(!i&&S){const w=new CustomEvent(uy,{bubbles:!0,cancelable:!0});S.addEventListener(uy,C=>u==null?void 0:u(C),{once:!0}),Dh(S,w),w.defaultPrevented?x.current=!1:p.onClose()}},"handleSelect");return s.jsx(TT,{...d,ref:v,disabled:i,onClick:Ee(l.onClick,y),onPointerDown:S=>{var w;(w=l.onPointerDown)==null||w.call(l,S),x.current=!0},onPointerUp:Ee(l.onPointerUp,S=>{var w;x.current||(w=S.currentTarget)==null||w.click()}),onKeyDown:Ee(l.onKeyDown,S=>{i||S.target!==S.currentTarget||g.searchRef.current!==""&&S.key===" "||cT.includes(S.key)&&(S.currentTarget.click(),S.preventDefault())})})},"MenuItem")),TT=m.forwardRef(it(function(l,o){const{__scopeMenu:i,disabled:u=!1,textValue:d,...h}=l,p=Nb(sh,i),g=Eb(i),v=m.useRef(null),x=Ie(o,v),[y,S]=m.useState(!1),[w,C]=m.useState("");return m.useEffect(()=>{const E=v.current;E&&C((E.textContent??"").trim())},[h.children]),s.jsx(rh.ItemSlot,{scope:i,disabled:u,textValue:d??w,children:s.jsx(mb,{asChild:!0,...g,focusable:!u,children:s.jsx(Be.div,{role:"menuitem","data-highlighted":y?"":void 0,"aria-disabled":u||void 0,"data-disabled":u?"":void 0,...h,ref:x,onPointerMove:Ee(l.onPointerMove,Rc(E=>{u?p.onItemLeave(E):(p.onItemEnter(E),E.defaultPrevented||E.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ee(l.onPointerLeave,Rc(E=>p.onItemLeave(E))),onFocus:Ee(l.onFocus,()=>S(!0)),onBlur:Ee(l.onBlur,()=>S(!1))})})})},"MenuItemImpl")),AT="MenuRadioGroup",[B_,H_]=gr(AT,{value:void 0,onValueChange:it(()=>{},"onValueChange")}),MT="MenuItemIndicator",[P_,q_]=gr(MT,{checked:!1}),DT=m.forwardRef(it(function(l,o){const{__scopeMenu:i,...u}=l;return s.jsx(Be.div,{role:"separator","aria-orientation":"horizontal",...u,ref:o})},"MenuSeparator")),_T="MenuSub",[I_,V_]=gr(_T);function Ab(a){return a?"open":"closed"}it(Ab,"getOpenState");function Mb(a){return a==="indeterminate"}it(Mb,"isIndeterminate");function OT(a){return Mb(a)?"indeterminate":a?"checked":"unchecked"}it(OT,"getCheckedState");function Db(a){const l=document.activeElement;for(const o of a)if(o===l||(o.focus(),document.activeElement!==l))return}it(Db,"focusFirst");function _b(a,l){return a.map((o,i)=>a[(l+i)%a.length])}it(_b,"wrapArray");function Ob(a,l,o){const u=l.length>1&&Array.from(l).every(v=>v===l[0])?l[0]:l,d=o?a.indexOf(o):-1;let h=_b(a,Math.max(d,0));u.length===1&&(h=h.filter(v=>v!==o));const g=h.find(v=>v.toLowerCase().startsWith(u.toLowerCase()));return g!==o?g:void 0}it(Ob,"getNextMatch");function kb(a,l){const{x:o,y:i}=a;let u=!1;for(let d=0,h=l.length-1;d<l.length;h=d++){const p=l[d],g=l[h],v=p.x,x=p.y,y=g.x,S=g.y;x>i!=S>i&&o<(y-v)*(i-x)/(S-x)+v&&(u=!u)}return u}it(kb,"isPointInPolygon");function zb(a,l){if(!l)return!1;const o={x:a.clientX,y:a.clientY};return kb(o,l)}it(zb,"isPointerInGraceArea");function Rc(a){return l=>l.pointerType==="mouse"?a(l):void 0}it(Rc,"whenMouse");var kT=gT,zT=vT,LT=bT,UT=wT,BT=RT,HT=NT,PT=DT,qT=Object.defineProperty,vr=(a,l)=>qT(a,"name",{value:l,configurable:!0}),Qh="DropdownMenu",[IT,G_]=fn(Qh,[Cb]),xr=Cb(),[VT,Lb]=IT(Qh),GT=vr(a=>{const{__scopeDropdownMenu:l,children:o,dir:i,open:u,defaultOpen:d,onOpenChange:h,modal:p=!0}=a,g=xr(l),v=m.useRef(null),[x,y]=Ja({prop:u,defaultProp:d??!1,onChange:h,caller:Qh});return s.jsx(VT,{scope:l,triggerId:ga(),triggerRef:v,contentId:ga(),open:x,onOpenChange:y,onOpenToggle:m.useCallback(()=>y(S=>!S),[y]),modal:p,children:s.jsx(kT,{...g,open:x,onOpenChange:y,dir:i,modal:p,children:o})})},"DropdownMenu"),YT="DropdownMenuTrigger",$T=m.forwardRef(vr(function(l,o){const{__scopeDropdownMenu:i,disabled:u=!1,...d}=l,h=Lb(YT,i),p=xr(i),g=Ie(o,h.triggerRef);return s.jsx(zT,{asChild:!0,...p,children:s.jsx(Be.button,{type:"button",id:h.triggerId,"aria-haspopup":"menu","aria-expanded":h.open,"aria-controls":h.open?h.contentId:void 0,"data-state":h.open?"open":"closed","data-disabled":u?"":void 0,disabled:u,...d,ref:g,onPointerDown:Ee(l.onPointerDown,v=>{!u&&v.button===0&&v.ctrlKey===!1&&(h.onOpenToggle(),h.open||v.preventDefault())}),onKeyDown:Ee(l.onKeyDown,v=>{u||(["Enter"," "].includes(v.key)&&h.onOpenToggle(),v.key==="ArrowDown"&&h.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(v.key)&&v.preventDefault())})})})},"DropdownMenuTrigger")),KT=vr(a=>{const{__scopeDropdownMenu:l,...o}=a,i=xr(l);return s.jsx(LT,{...i,...o})},"DropdownMenuPortal"),XT="DropdownMenuContent",FT=m.forwardRef(vr(function(l,o){const{__scopeDropdownMenu:i,...u}=l,d=Lb(XT,i),h=xr(i),p=m.useRef(!1);return s.jsx(UT,{id:d.contentId,"aria-labelledby":d.triggerId,...h,...u,ref:o,onCloseAutoFocus:Ee(l.onCloseAutoFocus,g=>{var v;p.current||(v=d.triggerRef.current)==null||v.focus(),p.current=!1,g.preventDefault()}),onInteractOutside:Ee(l.onInteractOutside,g=>{const v=g.detail.originalEvent,x=v.button===0&&v.ctrlKey===!0,y=v.button===2||x;(!d.modal||y)&&(p.current=!0)}),style:{...l.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),QT=m.forwardRef(vr(function(l,o){const{__scopeDropdownMenu:i,...u}=l,d=xr(i);return s.jsx(BT,{...d,...u,ref:o})},"DropdownMenuLabel")),ZT=m.forwardRef(vr(function(l,o){const{__scopeDropdownMenu:i,...u}=l,d=xr(i);return s.jsx(HT,{...d,...u,ref:o})},"DropdownMenuItem")),JT=m.forwardRef(vr(function(l,o){const{__scopeDropdownMenu:i,...u}=l,d=xr(i);return s.jsx(PT,{...d,...u,ref:o})},"DropdownMenuSeparator")),WT=GT,eA=$T,tA=KT,Ub=FT,Bb=QT,Hb=ZT,Pb=JT;const nA=WT,aA=eA,qb=m.forwardRef(({className:a,sideOffset:l=4,...o},i)=>s.jsx(tA,{children:s.jsx(Ub,{ref:i,sideOffset:l,className:Re("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",a),...o})}));qb.displayName=Ub.displayName;const Ib=m.forwardRef(({className:a,inset:l,...o},i)=>s.jsx(Hb,{ref:i,className:Re("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",l&&"pl-8",a),...o}));Ib.displayName=Hb.displayName;const lA=m.forwardRef(({className:a,...l},o)=>s.jsx(Bb,{ref:o,className:Re("px-2 py-1.5 text-sm font-semibold",a),...l}));lA.displayName=Bb.displayName;const rA=m.forwardRef(({className:a,...l},o)=>s.jsx(Pb,{ref:o,className:Re("-mx-1 my-1 h-px bg-muted",a),...l}));rA.displayName=Pb.displayName;function sA(){const{theme:a,setTheme:l}=pE(),{user:o,logout:i}=Nh(),[u,d]=m.useState(!1),[h,p]=m.useState(null),g=Do(),v=a==="light"?bC:a==="dark"?hC:fC;return m.useEffect(()=>{we.get("/api/admin/update/check").then(x=>p(x)).catch(()=>{})},[]),s.jsxs("header",{className:"flex h-14 items-center justify-between border-b bg-background px-4",children:[s.jsx("div",{className:"text-sm text-muted-foreground",children:"Admin"}),s.jsxs("div",{className:"flex items-center gap-2",children:[(h==null?void 0:h.hasUpdate)&&s.jsxs(he,{variant:"ghost",size:"sm",title:`New version available: v${h.latestVersion} — go to Settings → System to update`,onClick:()=>g("/settings?tab=system"),children:[s.jsx(tC,{className:"mr-1 h-4 w-4 text-blue-500"}),"Update v",h.latestVersion]}),s.jsx(he,{variant:"ghost",size:"icon",onClick:()=>l(a==="dark"?"light":"dark"),children:s.jsx(v,{className:"h-4 w-4"})}),s.jsxs(nA,{open:u,onOpenChange:d,children:[s.jsx(aA,{asChild:!0,children:s.jsx(he,{variant:"ghost",children:(o==null?void 0:o.username)??"admin"})}),s.jsx(qb,{align:"end",children:s.jsxs(Ib,{onClick:()=>void i(),children:[s.jsx(dC,{className:"mr-2 h-4 w-4"})," Sign out"]})})]})]})]})}const Ae=m.forwardRef(({className:a,type:l,...o},i)=>s.jsx("input",{type:l,className:Re("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",a),ref:i,...o}));Ae.displayName="Input";var oA=Object.defineProperty,iA=(a,l)=>oA(a,"name",{value:l,configurable:!0}),cA=m.forwardRef(iA(function(l,o){return s.jsx(Be.label,{...l,ref:o,onMouseDown:i=>{var d;i.target.closest("button, input, select, textarea")||((d=l.onMouseDown)==null||d.call(l,i),!i.defaultPrevented&&i.detail>1&&i.preventDefault())}})},"Label")),Vb=cA;const be=m.forwardRef(({className:a,...l},o)=>s.jsx(Vb,{ref:o,className:Re("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",a),...l}));be.displayName=Vb.displayName;const Xe=m.forwardRef(({className:a,...l},o)=>s.jsx("div",{ref:o,className:Re("rounded-lg border bg-card text-card-foreground shadow-sm",a),...l}));Xe.displayName="Card";const Fe=m.forwardRef(({className:a,...l},o)=>s.jsx("div",{ref:o,className:Re("flex flex-col space-y-1.5 p-6",a),...l}));Fe.displayName="CardHeader";const Qe=m.forwardRef(({className:a,...l},o)=>s.jsx("h3",{ref:o,className:Re("text-lg font-semibold leading-none tracking-tight",a),...l}));Qe.displayName="CardTitle";const on=m.forwardRef(({className:a,...l},o)=>s.jsx("p",{ref:o,className:Re("text-sm text-muted-foreground",a),...l}));on.displayName="CardDescription";const Ze=m.forwardRef(({className:a,...l},o)=>s.jsx("div",{ref:o,className:Re("p-6 pt-0",a),...l}));Ze.displayName="CardContent";const Gb=m.forwardRef(({className:a,...l},o)=>s.jsx("div",{ref:o,className:Re("flex items-center p-6 pt-0",a),...l}));Gb.displayName="CardFooter";var uA=a=>{switch(a){case"success":return hA;case"info":return pA;case"warning":return mA;case"error":return gA;default:return null}},dA=Array(12).fill(0),fA=({visible:a,className:l})=>ie.createElement("div",{className:["sonner-loading-wrapper",l].filter(Boolean).join(" "),"data-visible":a},ie.createElement("div",{className:"sonner-spinner"},dA.map((o,i)=>ie.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${i}`})))),hA=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ie.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),mA=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ie.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),pA=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ie.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),gA=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ie.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),vA=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ie.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ie.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),xA=()=>{let[a,l]=ie.useState(document.hidden);return ie.useEffect(()=>{let o=()=>{l(document.hidden)};return document.addEventListener("visibilitychange",o),()=>window.removeEventListener("visibilitychange",o)},[]),a},oh=1,yA=class{constructor(){this.subscribe=a=>(this.subscribers.push(a),()=>{let l=this.subscribers.indexOf(a);this.subscribers.splice(l,1)}),this.publish=a=>{this.subscribers.forEach(l=>l(a))},this.addToast=a=>{this.publish(a),this.toasts=[...this.toasts,a]},this.create=a=>{var l;let{message:o,...i}=a,u=typeof(a==null?void 0:a.id)=="number"||((l=a.id)==null?void 0:l.length)>0?a.id:oh++,d=this.toasts.find(p=>p.id===u),h=a.dismissible===void 0?!0:a.dismissible;return this.dismissedToasts.has(u)&&this.dismissedToasts.delete(u),d?this.toasts=this.toasts.map(p=>p.id===u?(this.publish({...p,...a,id:u,title:o}),{...p,...a,id:u,dismissible:h,title:o}):p):this.addToast({title:o,...i,dismissible:h,id:u}),u},this.dismiss=a=>(this.dismissedToasts.add(a),a||this.toasts.forEach(l=>{this.subscribers.forEach(o=>o({id:l.id,dismiss:!0}))}),this.subscribers.forEach(l=>l({id:a,dismiss:!0})),a),this.message=(a,l)=>this.create({...l,message:a}),this.error=(a,l)=>this.create({...l,message:a,type:"error"}),this.success=(a,l)=>this.create({...l,type:"success",message:a}),this.info=(a,l)=>this.create({...l,type:"info",message:a}),this.warning=(a,l)=>this.create({...l,type:"warning",message:a}),this.loading=(a,l)=>this.create({...l,type:"loading",message:a}),this.promise=(a,l)=>{if(!l)return;let o;l.loading!==void 0&&(o=this.create({...l,promise:a,type:"loading",message:l.loading,description:typeof l.description!="function"?l.description:void 0}));let i=a instanceof Promise?a:a(),u=o!==void 0,d,h=i.then(async g=>{if(d=["resolve",g],ie.isValidElement(g))u=!1,this.create({id:o,type:"default",message:g});else if(SA(g)&&!g.ok){u=!1;let v=typeof l.error=="function"?await l.error(`HTTP error! status: ${g.status}`):l.error,x=typeof l.description=="function"?await l.description(`HTTP error! status: ${g.status}`):l.description;this.create({id:o,type:"error",message:v,description:x})}else if(l.success!==void 0){u=!1;let v=typeof l.success=="function"?await l.success(g):l.success,x=typeof l.description=="function"?await l.description(g):l.description;this.create({id:o,type:"success",message:v,description:x})}}).catch(async g=>{if(d=["reject",g],l.error!==void 0){u=!1;let v=typeof l.error=="function"?await l.error(g):l.error,x=typeof l.description=="function"?await l.description(g):l.description;this.create({id:o,type:"error",message:v,description:x})}}).finally(()=>{var g;u&&(this.dismiss(o),o=void 0),(g=l.finally)==null||g.call(l)}),p=()=>new Promise((g,v)=>h.then(()=>d[0]==="reject"?v(d[1]):g(d[1])).catch(v));return typeof o!="string"&&typeof o!="number"?{unwrap:p}:Object.assign(o,{unwrap:p})},this.custom=(a,l)=>{let o=(l==null?void 0:l.id)||oh++;return this.create({jsx:a(o),id:o,...l}),o},this.getActiveToasts=()=>this.toasts.filter(a=>!this.dismissedToasts.has(a.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},sn=new yA,bA=(a,l)=>{let o=(l==null?void 0:l.id)||oh++;return sn.addToast({title:a,...l,id:o}),o},SA=a=>a&&typeof a=="object"&&"ok"in a&&typeof a.ok=="boolean"&&"status"in a&&typeof a.status=="number",wA=bA,jA=()=>sn.toasts,CA=()=>sn.getActiveToasts(),ve=Object.assign(wA,{success:sn.success,info:sn.info,warning:sn.warning,error:sn.error,custom:sn.custom,message:sn.message,promise:sn.promise,dismiss:sn.dismiss,loading:sn.loading},{getHistory:jA,getToasts:CA});function EA(a,{insertAt:l}={}){if(typeof document>"u")return;let o=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",l==="top"&&o.firstChild?o.insertBefore(i,o.firstChild):o.appendChild(i),i.styleSheet?i.styleSheet.cssText=a:i.appendChild(document.createTextNode(a))}EA(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
326
- `);function ic(a){return a.label!==void 0}var RA=3,NA="32px",TA="16px",dy=4e3,AA=356,MA=14,DA=20,_A=200;function na(...a){return a.filter(Boolean).join(" ")}function OA(a){let[l,o]=a.split("-"),i=[];return l&&i.push(l),o&&i.push(o),i}var kA=a=>{var l,o,i,u,d,h,p,g,v,x,y;let{invert:S,toast:w,unstyled:C,interacting:E,setHeights:j,visibleToasts:N,heights:M,index:T,toasts:_,expanded:O,removeToast:A,defaultRichColors:H,closeButton:z,style:K,cancelButtonStyle:se,actionButtonStyle:X,className:I="",descriptionClassName:re="",duration:ee,position:oe,gap:U,loadingIcon:$,expandByDefault:le,classNames:B,icons:Z,closeButtonAriaLabel:D="Close toast",pauseWhenPageIsHidden:q}=a,[Q,ae]=ie.useState(null),[ce,Se]=ie.useState(null),[ue,fe]=ie.useState(!1),[xe,J]=ie.useState(!1),[me,je]=ie.useState(!1),[Me,mt]=ie.useState(!1),[pt,bt]=ie.useState(!1),[St,Lt]=ie.useState(0),[hn,Qn]=ie.useState(0),mn=ie.useRef(w.duration||ee||dy),ja=ie.useRef(null),Ca=ie.useRef(null),$t=T===0,Jc=T+1<=N,Kt=w.type,Ea=w.dismissible!==!1,br=w.className||"",Wc=w.descriptionClassName||"",Vl=ie.useMemo(()=>M.findIndex(Te=>Te.toastId===w.id)||0,[M,w.id]),eu=ie.useMemo(()=>{var Te;return(Te=w.closeButton)!=null?Te:z},[w.closeButton,z]),Po=ie.useMemo(()=>w.duration||ee||dy,[w.duration,ee]),Ra=ie.useRef(0),wt=ie.useRef(0),Zn=ie.useRef(0),jt=ie.useRef(null),[tu,nu]=oe.split("-"),qo=ie.useMemo(()=>M.reduce((Te,Ke,st)=>st>=Vl?Te:Te+Ke.height,0),[M,Vl]),Gl=xA(),Sr=w.invert||S,sl=Kt==="loading";wt.current=ie.useMemo(()=>Vl*U+qo,[Vl,qo]),ie.useEffect(()=>{mn.current=Po},[Po]),ie.useEffect(()=>{fe(!0)},[]),ie.useEffect(()=>{let Te=Ca.current;if(Te){let Ke=Te.getBoundingClientRect().height;return Qn(Ke),j(st=>[{toastId:w.id,height:Ke,position:w.position},...st]),()=>j(st=>st.filter(Xt=>Xt.toastId!==w.id))}},[j,w.id]),ie.useLayoutEffect(()=>{if(!ue)return;let Te=Ca.current,Ke=Te.style.height;Te.style.height="auto";let st=Te.getBoundingClientRect().height;Te.style.height=Ke,Qn(st),j(Xt=>Xt.find(Ut=>Ut.toastId===w.id)?Xt.map(Ut=>Ut.toastId===w.id?{...Ut,height:st}:Ut):[{toastId:w.id,height:st,position:w.position},...Xt])},[ue,w.title,w.description,j,w.id]);let Vt=ie.useCallback(()=>{J(!0),Lt(wt.current),j(Te=>Te.filter(Ke=>Ke.toastId!==w.id)),setTimeout(()=>{A(w)},_A)},[w,A,j,wt]);ie.useEffect(()=>{if(w.promise&&Kt==="loading"||w.duration===1/0||w.type==="loading")return;let Te;return O||E||q&&Gl?(()=>{if(Zn.current<Ra.current){let Ke=new Date().getTime()-Ra.current;mn.current=mn.current-Ke}Zn.current=new Date().getTime()})():mn.current!==1/0&&(Ra.current=new Date().getTime(),Te=setTimeout(()=>{var Ke;(Ke=w.onAutoClose)==null||Ke.call(w,w),Vt()},mn.current)),()=>clearTimeout(Te)},[O,E,w,Kt,q,Gl,Vt]),ie.useEffect(()=>{w.delete&&Vt()},[Vt,w.delete]);function wr(){var Te,Ke,st;return Z!=null&&Z.loading?ie.createElement("div",{className:na(B==null?void 0:B.loader,(Te=w==null?void 0:w.classNames)==null?void 0:Te.loader,"sonner-loader"),"data-visible":Kt==="loading"},Z.loading):$?ie.createElement("div",{className:na(B==null?void 0:B.loader,(Ke=w==null?void 0:w.classNames)==null?void 0:Ke.loader,"sonner-loader"),"data-visible":Kt==="loading"},$):ie.createElement(fA,{className:na(B==null?void 0:B.loader,(st=w==null?void 0:w.classNames)==null?void 0:st.loader),visible:Kt==="loading"})}return ie.createElement("li",{tabIndex:0,ref:Ca,className:na(I,br,B==null?void 0:B.toast,(l=w==null?void 0:w.classNames)==null?void 0:l.toast,B==null?void 0:B.default,B==null?void 0:B[Kt],(o=w==null?void 0:w.classNames)==null?void 0:o[Kt]),"data-sonner-toast":"","data-rich-colors":(i=w.richColors)!=null?i:H,"data-styled":!(w.jsx||w.unstyled||C),"data-mounted":ue,"data-promise":!!w.promise,"data-swiped":pt,"data-removed":xe,"data-visible":Jc,"data-y-position":tu,"data-x-position":nu,"data-index":T,"data-front":$t,"data-swiping":me,"data-dismissible":Ea,"data-type":Kt,"data-invert":Sr,"data-swipe-out":Me,"data-swipe-direction":ce,"data-expanded":!!(O||le&&ue),style:{"--index":T,"--toasts-before":T,"--z-index":_.length-T,"--offset":`${xe?St:wt.current}px`,"--initial-height":le?"auto":`${hn}px`,...K,...w.style},onDragEnd:()=>{je(!1),ae(null),jt.current=null},onPointerDown:Te=>{sl||!Ea||(ja.current=new Date,Lt(wt.current),Te.target.setPointerCapture(Te.pointerId),Te.target.tagName!=="BUTTON"&&(je(!0),jt.current={x:Te.clientX,y:Te.clientY}))},onPointerUp:()=>{var Te,Ke,st,Xt;if(Me||!Ea)return;jt.current=null;let Ut=Number(((Te=Ca.current)==null?void 0:Te.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),oa=Number(((Ke=Ca.current)==null?void 0:Ke.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ia=new Date().getTime()-((st=ja.current)==null?void 0:st.getTime()),Zt=Q==="x"?Ut:oa,Jn=Math.abs(Zt)/ia;if(Math.abs(Zt)>=DA||Jn>.11){Lt(wt.current),(Xt=w.onDismiss)==null||Xt.call(w,w),Se(Q==="x"?Ut>0?"right":"left":oa>0?"down":"up"),Vt(),mt(!0),bt(!1);return}je(!1),ae(null)},onPointerMove:Te=>{var Ke,st,Xt,Ut;if(!jt.current||!Ea||((Ke=window.getSelection())==null?void 0:Ke.toString().length)>0)return;let oa=Te.clientY-jt.current.y,ia=Te.clientX-jt.current.x,Zt=(st=a.swipeDirections)!=null?st:OA(oe);!Q&&(Math.abs(ia)>1||Math.abs(oa)>1)&&ae(Math.abs(ia)>Math.abs(oa)?"x":"y");let Jn={x:0,y:0};Q==="y"?(Zt.includes("top")||Zt.includes("bottom"))&&(Zt.includes("top")&&oa<0||Zt.includes("bottom")&&oa>0)&&(Jn.y=oa):Q==="x"&&(Zt.includes("left")||Zt.includes("right"))&&(Zt.includes("left")&&ia<0||Zt.includes("right")&&ia>0)&&(Jn.x=ia),(Math.abs(Jn.x)>0||Math.abs(Jn.y)>0)&&bt(!0),(Xt=Ca.current)==null||Xt.style.setProperty("--swipe-amount-x",`${Jn.x}px`),(Ut=Ca.current)==null||Ut.style.setProperty("--swipe-amount-y",`${Jn.y}px`)}},eu&&!w.jsx?ie.createElement("button",{"aria-label":D,"data-disabled":sl,"data-close-button":!0,onClick:sl||!Ea?()=>{}:()=>{var Te;Vt(),(Te=w.onDismiss)==null||Te.call(w,w)},className:na(B==null?void 0:B.closeButton,(u=w==null?void 0:w.classNames)==null?void 0:u.closeButton)},(d=Z==null?void 0:Z.close)!=null?d:vA):null,w.jsx||m.isValidElement(w.title)?w.jsx?w.jsx:typeof w.title=="function"?w.title():w.title:ie.createElement(ie.Fragment,null,Kt||w.icon||w.promise?ie.createElement("div",{"data-icon":"",className:na(B==null?void 0:B.icon,(h=w==null?void 0:w.classNames)==null?void 0:h.icon)},w.promise||w.type==="loading"&&!w.icon?w.icon||wr():null,w.type!=="loading"?w.icon||(Z==null?void 0:Z[Kt])||uA(Kt):null):null,ie.createElement("div",{"data-content":"",className:na(B==null?void 0:B.content,(p=w==null?void 0:w.classNames)==null?void 0:p.content)},ie.createElement("div",{"data-title":"",className:na(B==null?void 0:B.title,(g=w==null?void 0:w.classNames)==null?void 0:g.title)},typeof w.title=="function"?w.title():w.title),w.description?ie.createElement("div",{"data-description":"",className:na(re,Wc,B==null?void 0:B.description,(v=w==null?void 0:w.classNames)==null?void 0:v.description)},typeof w.description=="function"?w.description():w.description):null),m.isValidElement(w.cancel)?w.cancel:w.cancel&&ic(w.cancel)?ie.createElement("button",{"data-button":!0,"data-cancel":!0,style:w.cancelButtonStyle||se,onClick:Te=>{var Ke,st;ic(w.cancel)&&Ea&&((st=(Ke=w.cancel).onClick)==null||st.call(Ke,Te),Vt())},className:na(B==null?void 0:B.cancelButton,(x=w==null?void 0:w.classNames)==null?void 0:x.cancelButton)},w.cancel.label):null,m.isValidElement(w.action)?w.action:w.action&&ic(w.action)?ie.createElement("button",{"data-button":!0,"data-action":!0,style:w.actionButtonStyle||X,onClick:Te=>{var Ke,st;ic(w.action)&&((st=(Ke=w.action).onClick)==null||st.call(Ke,Te),!Te.defaultPrevented&&Vt())},className:na(B==null?void 0:B.actionButton,(y=w==null?void 0:w.classNames)==null?void 0:y.actionButton)},w.action.label):null))};function fy(){if(typeof window>"u"||typeof document>"u")return"ltr";let a=document.documentElement.getAttribute("dir");return a==="auto"||!a?window.getComputedStyle(document.documentElement).direction:a}function zA(a,l){let o={};return[a,l].forEach((i,u)=>{let d=u===1,h=d?"--mobile-offset":"--offset",p=d?TA:NA;function g(v){["top","right","bottom","left"].forEach(x=>{o[`${h}-${x}`]=typeof v=="number"?`${v}px`:v})}typeof i=="number"||typeof i=="string"?g(i):typeof i=="object"?["top","right","bottom","left"].forEach(v=>{i[v]===void 0?o[`${h}-${v}`]=p:o[`${h}-${v}`]=typeof i[v]=="number"?`${i[v]}px`:i[v]}):g(p)}),o}var LA=m.forwardRef(function(a,l){let{invert:o,position:i="bottom-right",hotkey:u=["altKey","KeyT"],expand:d,closeButton:h,className:p,offset:g,mobileOffset:v,theme:x="light",richColors:y,duration:S,style:w,visibleToasts:C=RA,toastOptions:E,dir:j=fy(),gap:N=MA,loadingIcon:M,icons:T,containerAriaLabel:_="Notifications",pauseWhenPageIsHidden:O}=a,[A,H]=ie.useState([]),z=ie.useMemo(()=>Array.from(new Set([i].concat(A.filter(q=>q.position).map(q=>q.position)))),[A,i]),[K,se]=ie.useState([]),[X,I]=ie.useState(!1),[re,ee]=ie.useState(!1),[oe,U]=ie.useState(x!=="system"?x:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),$=ie.useRef(null),le=u.join("+").replace(/Key/g,"").replace(/Digit/g,""),B=ie.useRef(null),Z=ie.useRef(!1),D=ie.useCallback(q=>{H(Q=>{var ae;return(ae=Q.find(ce=>ce.id===q.id))!=null&&ae.delete||sn.dismiss(q.id),Q.filter(({id:ce})=>ce!==q.id)})},[]);return ie.useEffect(()=>sn.subscribe(q=>{if(q.dismiss){H(Q=>Q.map(ae=>ae.id===q.id?{...ae,delete:!0}:ae));return}setTimeout(()=>{G2.flushSync(()=>{H(Q=>{let ae=Q.findIndex(ce=>ce.id===q.id);return ae!==-1?[...Q.slice(0,ae),{...Q[ae],...q},...Q.slice(ae+1)]:[q,...Q]})})})}),[]),ie.useEffect(()=>{if(x!=="system"){U(x);return}if(x==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?U("dark"):U("light")),typeof window>"u")return;let q=window.matchMedia("(prefers-color-scheme: dark)");try{q.addEventListener("change",({matches:Q})=>{U(Q?"dark":"light")})}catch{q.addListener(({matches:ae})=>{try{U(ae?"dark":"light")}catch(ce){console.error(ce)}})}},[x]),ie.useEffect(()=>{A.length<=1&&I(!1)},[A]),ie.useEffect(()=>{let q=Q=>{var ae,ce;u.every(Se=>Q[Se]||Q.code===Se)&&(I(!0),(ae=$.current)==null||ae.focus()),Q.code==="Escape"&&(document.activeElement===$.current||(ce=$.current)!=null&&ce.contains(document.activeElement))&&I(!1)};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},[u]),ie.useEffect(()=>{if($.current)return()=>{B.current&&(B.current.focus({preventScroll:!0}),B.current=null,Z.current=!1)}},[$.current]),ie.createElement("section",{ref:l,"aria-label":`${_} ${le}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},z.map((q,Q)=>{var ae;let[ce,Se]=q.split("-");return A.length?ie.createElement("ol",{key:q,dir:j==="auto"?fy():j,tabIndex:-1,ref:$,className:p,"data-sonner-toaster":!0,"data-theme":oe,"data-y-position":ce,"data-lifted":X&&A.length>1&&!d,"data-x-position":Se,style:{"--front-toast-height":`${((ae=K[0])==null?void 0:ae.height)||0}px`,"--width":`${AA}px`,"--gap":`${N}px`,...w,...zA(g,v)},onBlur:ue=>{Z.current&&!ue.currentTarget.contains(ue.relatedTarget)&&(Z.current=!1,B.current&&(B.current.focus({preventScroll:!0}),B.current=null))},onFocus:ue=>{ue.target instanceof HTMLElement&&ue.target.dataset.dismissible==="false"||Z.current||(Z.current=!0,B.current=ue.relatedTarget)},onMouseEnter:()=>I(!0),onMouseMove:()=>I(!0),onMouseLeave:()=>{re||I(!1)},onDragEnd:()=>I(!1),onPointerDown:ue=>{ue.target instanceof HTMLElement&&ue.target.dataset.dismissible==="false"||ee(!0)},onPointerUp:()=>ee(!1)},A.filter(ue=>!ue.position&&Q===0||ue.position===q).map((ue,fe)=>{var xe,J;return ie.createElement(kA,{key:ue.id,icons:T,index:fe,toast:ue,defaultRichColors:y,duration:(xe=E==null?void 0:E.duration)!=null?xe:S,className:E==null?void 0:E.className,descriptionClassName:E==null?void 0:E.descriptionClassName,invert:o,visibleToasts:C,closeButton:(J=E==null?void 0:E.closeButton)!=null?J:h,interacting:re,position:q,style:E==null?void 0:E.style,unstyled:E==null?void 0:E.unstyled,classNames:E==null?void 0:E.classNames,cancelButtonStyle:E==null?void 0:E.cancelButtonStyle,actionButtonStyle:E==null?void 0:E.actionButtonStyle,removeToast:D,toasts:A.filter(me=>me.position==ue.position),heights:K.filter(me=>me.position==ue.position),setHeights:se,expandByDefault:d,gap:N,loadingIcon:M,expanded:X,pauseWhenPageIsHidden:O,swipeDirections:a.swipeDirections})})):null}))});function UA(){const{login:a}=Nh(),[l,o]=m.useState("admin"),[i,u]=m.useState(""),[d,h]=m.useState(""),[p,g]=m.useState(""),[v,x]=m.useState(!1),[y,S]=m.useState(!1),w=Do(),C=dn();return s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:s.jsxs(Xe,{className:"w-full max-w-sm",children:[s.jsxs(Fe,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:"/logo.png",alt:"LateDev Router",className:"h-8 w-8 object-contain"}),s.jsx(Qe,{children:"Sign in"})]}),s.jsx(on,{children:"Enter your admin credentials."})]}),s.jsxs(Ze,{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Username"}),s.jsx(Ae,{value:l,onChange:E=>o(E.target.value),autoFocus:!0})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Password"}),s.jsx(Ae,{type:"password",value:i,onChange:E=>u(E.target.value)})]}),v&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"2FA code (or recovery code)"}),s.jsx(Ae,{value:d,onChange:E=>h(E.target.value),placeholder:"123456",maxLength:6})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Recovery code (alternative)"}),s.jsx(Ae,{value:p,onChange:E=>g(E.target.value),placeholder:"ABCD12-EF3456"})]})]})]}),s.jsx("div",{className:"px-6 pb-6",children:s.jsx(he,{className:"w-full",disabled:y,onClick:async()=>{var E,j;S(!0);try{if((await a(l,i,d||void 0,p||void 0)).totpRequired){x(!0);return}const M=((j=(E=C.state)==null?void 0:E.from)==null?void 0:j.pathname)??"/";w(M,{replace:!0})}catch(N){ve.error(N.message)}finally{S(!1)}},children:"Sign in"})})]})})}function BA(){const[a,l]=m.useState("admin"),[o,i]=m.useState(""),[u,d]=m.useState(""),[h,p]=m.useState(!1),[g,v]=m.useState(!0);m.useEffect(()=>{we.get("/api/admin/setup/status").then(S=>v(!S.masterKeyConfigured)).catch(()=>v(!0))},[]);const x=!g||u.trim().length>=32,y=!h&&o.length>=12&&x;return s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:s.jsxs(Xe,{className:"w-full max-w-md",children:[s.jsxs(Fe,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:"/logo.png",alt:"LateDev Router",className:"h-8 w-8 object-contain rounded"}),s.jsx(Qe,{children:"Welcome to LateDev Router"})]}),s.jsx(on,{children:"Set up the administrator account to get started."})]}),s.jsxs(Ze,{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Username"}),s.jsx(Ae,{value:a,onChange:S=>l(S.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Password (12+ chars)"}),s.jsx(Ae,{type:"password",value:o,onChange:S=>i(S.target.value)})]}),g&&s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Master encryption key (required, 32+ chars)"}),s.jsx(Ae,{type:"password",value:u,onChange:S=>d(S.target.value),placeholder:"Paste or generate a 32+ character key"}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Provider API keys are encrypted with this key (AES-256-GCM). Store it somewhere safe — if it is lost, stored provider credentials cannot be recovered. Generate one with:"," ",s.jsx("code",{className:"break-all",children:`node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"`})]})]})]}),s.jsx(Gb,{children:s.jsx(he,{disabled:!y,onClick:async()=>{p(!0);try{await we.post("/api/admin/setup",{username:a,password:o,setupMasterKey:g?u.trim():void 0}),ve.success("Admin account created"),window.location.assign("/login")}catch(S){ve.error(S.message)}finally{p(!1)}},children:"Create admin"})})]})})}function wa({title:a,description:l,actions:o,className:i}){return s.jsxs("div",{className:Re("mb-6 flex items-start justify-between gap-4",i),children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:a}),l&&s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:l})]}),o&&s.jsx("div",{className:"flex items-center gap-2",children:o})]})}const HA=m0("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground",success:"border-transparent bg-emerald-600 text-white",warning:"border-transparent bg-amber-500 text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function et({className:a,variant:l,...o}){return s.jsx("div",{className:Re(HA({variant:l}),a),...o})}function PA(){const[a,l]=m.useState(null);return m.useEffect(()=>{we.get("/api/admin/dashboard").then(l).catch(()=>l(null))},[]),a?s.jsxs("div",{children:[s.jsx(wa,{title:"Dashboard",description:"Operational summary for today",actions:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(he,{asChild:!0,variant:"outline",size:"sm",children:s.jsxs(ur,{to:"/providers",children:[s.jsx(Oo,{className:"mr-1 h-4 w-4"})," Provider"]})}),s.jsx(he,{asChild:!0,variant:"outline",size:"sm",children:s.jsxs(ur,{to:"/combos",children:[s.jsx(Zy,{className:"mr-1 h-4 w-4"})," Combo"]})}),s.jsx(he,{asChild:!0,variant:"outline",size:"sm",children:s.jsxs(ur,{to:"/api-keys",children:[s.jsx(Qy,{className:"mr-1 h-4 w-4"})," API Key"]})})]})}),s.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-1",children:s.jsx(Qe,{className:"text-sm text-muted-foreground",children:"Requests today"})}),s.jsx(Ze,{className:"text-2xl font-semibold",children:Mt(a.today.total)})]}),s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-1",children:s.jsx(Qe,{className:"text-sm text-muted-foreground",children:"Success rate"})}),s.jsx(Ze,{className:"text-2xl font-semibold",children:a.today.total?kc(a.today.success/a.today.total):"—"})]}),s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-1",children:s.jsx(Qe,{className:"text-sm text-muted-foreground",children:"Failed"})}),s.jsx(Ze,{className:"text-2xl font-semibold",children:Mt(a.today.failed)})]}),s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-1",children:s.jsx(Qe,{className:"text-sm text-muted-foreground",children:"Tokens today"})}),s.jsx(Ze,{className:"text-2xl font-semibold",children:Mt(a.today.totalTokens)})]})]}),s.jsxs("div",{className:"mt-6 grid gap-4 lg:grid-cols-2",children:[s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"Provider health"}),s.jsxs(on,{children:[a.providers.length," configured"]})]}),s.jsxs(Ze,{className:"space-y-2",children:[a.providers.length===0&&s.jsxs("p",{className:"text-sm text-muted-foreground",children:["No providers yet. ",s.jsx(ur,{to:"/providers",className:"text-primary",children:"Add one"}),"."]}),a.providers.map(o=>s.jsxs("div",{className:"flex items-center justify-between rounded border p-2 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Jy,{className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"font-medium",children:o.name}),s.jsx("span",{className:"text-xs text-muted-foreground",children:o.slug}),s.jsx(et,{variant:"outline",className:"ml-2",children:o.type})]}),s.jsx(et,{variant:o.health==="healthy"?"success":o.health==="down"?"destructive":"secondary",children:o.health})]},o.id))]})]}),s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"Recent failures"}),s.jsx(on,{children:"Today"})]}),s.jsxs(Ze,{className:"space-y-1 text-sm",children:[a.recentFailures.length===0&&s.jsx("p",{className:"text-muted-foreground",children:"No failures today."}),a.recentFailures.map(o=>{var i;return s.jsxs("div",{className:"flex items-center justify-between border-b py-1 last:border-0",children:[s.jsxs("div",{children:[s.jsx("span",{className:"font-mono text-xs",children:o.requestedModel}),s.jsxs("div",{className:"text-xs text-muted-foreground",children:[o.errorType??`HTTP ${o.httpStatus}`," — ",(i=o.errorMessage)==null?void 0:i.slice(0,60)]})]}),s.jsx("span",{className:"text-xs text-muted-foreground",children:Ah(o.createdAt)})]},o.id)})]})]})]})]}):s.jsx("div",{className:"text-muted-foreground",children:"Loading…"})}const Kn=m.forwardRef(({className:a,...l},o)=>s.jsx("div",{className:"relative w-full overflow-auto",children:s.jsx("table",{ref:o,className:Re("w-full caption-bottom text-sm",a),...l})}));Kn.displayName="Table";const Xn=m.forwardRef(({className:a,...l},o)=>s.jsx("thead",{ref:o,className:Re("[&_tr]:border-b",a),...l}));Xn.displayName="TableHeader";const Fn=m.forwardRef(({className:a,...l},o)=>s.jsx("tbody",{ref:o,className:Re("[&_tr:last-child]:border-0",a),...l}));Fn.displayName="TableBody";const Ye=m.forwardRef(({className:a,...l},o)=>s.jsx("tr",{ref:o,className:Re("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",a),...l}));Ye.displayName="TableRow";const pe=m.forwardRef(({className:a,...l},o)=>s.jsx("th",{ref:o,className:Re("h-10 px-2 text-left align-middle font-medium text-muted-foreground",a),...l}));pe.displayName="TableHead";const de=m.forwardRef(({className:a,...l},o)=>s.jsx("td",{ref:o,className:Re("p-2 align-middle",a),...l}));de.displayName="TableCell";var qA=Object.defineProperty,An=(a,l)=>qA(a,"name",{value:l,configurable:!0}),Zh="Dialog",[Yb,$b]=fn(Zh),[IA,sa]=Yb(Zh),Kb=An(a=>{const{__scopeDialog:l,children:o,open:i,defaultOpen:u,onOpenChange:d,modal:h=!0}=a,p=m.useRef(null),g=m.useRef(null),[v,x]=Ja({prop:i,defaultProp:u??!1,onChange:d,caller:Zh}),[y,S]=m.useState(0),[w,C]=m.useState(0);return s.jsx(IA,{scope:l,triggerRef:p,contentRef:g,contentId:ga(),titleId:ga(),descriptionId:ga(),titlePresent:y>0,descriptionPresent:w>0,setTitleCount:S,setDescriptionCount:C,open:v,onOpenChange:x,onOpenToggle:m.useCallback(()=>x(E=>!E),[x]),modal:h,children:o})},"Dialog"),VA="DialogTrigger",Xb=m.forwardRef(An(function(l,o){const{__scopeDialog:i,...u}=l,d=sa(VA,i),h=Ie(o,d.triggerRef);return s.jsx(Be.button,{type:"button","aria-haspopup":"dialog","aria-expanded":d.open,"aria-controls":d.open?d.contentId:void 0,"data-state":Fc(d.open),...u,ref:h,onClick:Ee(l.onClick,d.onOpenToggle)})},"DialogTrigger")),Fb="DialogPortal",[GA,Qb]=Yb(Fb,{forceMount:void 0}),Zb=An(a=>{const{__scopeDialog:l,forceMount:o,children:i,container:u}=a,d=sa(Fb,l);return s.jsx(GA,{scope:l,forceMount:o,children:m.Children.map(i,h=>s.jsx(al,{present:o||d.open,children:s.jsx(Gh,{asChild:!0,container:u,children:h})}))})},"DialogPortal"),ih="DialogOverlay",Jh=m.forwardRef(An(function(l,o){const i=Qb(ih,l.__scopeDialog),{forceMount:u=i.forceMount,...d}=l,h=sa(ih,l.__scopeDialog);return h.modal?s.jsx(al,{present:u||h.open,children:s.jsx($A,{...d,ref:o})}):null},"DialogOverlay")),YA=va("DialogOverlay.RemoveScroll"),$A=m.forwardRef(An(function(l,o){const{__scopeDialog:i,...u}=l,d=sa(ih,i),h=T0(),p=Ie(o,h);return s.jsx(Kc,{as:YA,allowPinchZoom:!0,shards:[d.contentRef],children:s.jsx(Be.div,{"data-state":Fc(d.open),...u,ref:p,style:{pointerEvents:"auto",...u.style}})})},"DialogOverlayImpl")),No="DialogContent",Wh=m.forwardRef(An(function(l,o){const i=Qb(No,l.__scopeDialog),{forceMount:u=i.forceMount,...d}=l,h=sa(No,l.__scopeDialog);return s.jsx(al,{present:u||h.open,children:h.modal?s.jsx(KA,{...d,ref:o}):s.jsx(XA,{...d,ref:o})})},"DialogContent")),KA=m.forwardRef(An(function(l,o){const i=sa(No,l.__scopeDialog),u=m.useRef(null),d=Ie(o,i.contentRef,u);return m.useEffect(()=>{const h=u.current;if(h)return Kh(h)},[]),s.jsx(Jb,{...l,ref:d,trapFocus:i.open,disableOutsidePointerEvents:i.open,onCloseAutoFocus:Ee(l.onCloseAutoFocus,h=>{var p;h.preventDefault(),(p=i.triggerRef.current)==null||p.focus()}),onPointerDownOutside:Ee(l.onPointerDownOutside,h=>{const p=h.detail.originalEvent,g=p.button===0&&p.ctrlKey===!0;(p.button===2||g)&&h.preventDefault()}),onFocusOutside:Ee(l.onFocusOutside,h=>h.preventDefault())})},"DialogContentModal")),XA=m.forwardRef(An(function(l,o){const i=sa(No,l.__scopeDialog),u=m.useRef(!1),d=m.useRef(!1);return s.jsx(Jb,{...l,ref:o,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:h=>{var p,g;(p=l.onCloseAutoFocus)==null||p.call(l,h),h.defaultPrevented||(u.current||(g=i.triggerRef.current)==null||g.focus(),h.preventDefault()),u.current=!1,d.current=!1},onInteractOutside:h=>{var v,x;(v=l.onInteractOutside)==null||v.call(l,h),h.defaultPrevented||(u.current=!0,h.detail.originalEvent.type==="pointerdown"&&(d.current=!0));const p=h.target;((x=i.triggerRef.current)==null?void 0:x.contains(p))&&h.preventDefault(),h.detail.originalEvent.type==="focusin"&&d.current&&h.preventDefault()}})},"DialogContentNonModal")),Jb=m.forwardRef(An(function(l,o){const{__scopeDialog:i,trapFocus:u,onOpenAutoFocus:d,onCloseAutoFocus:h,...p}=l,g=sa(No,i);return Lo(),s.jsx(s.Fragment,{children:s.jsx(zh,{asChild:!0,loop:!0,trapped:u,onMountAutoFocus:d,onUnmountAutoFocus:h,children:s.jsx(Lc,{role:"dialog",id:g.contentId,"aria-describedby":g.descriptionPresent?g.descriptionId:void 0,"aria-labelledby":g.titlePresent?g.titleId:void 0,"data-state":Fc(g.open),...p,ref:o,deferPointerDownOutside:!0,onDismiss:()=>g.onOpenChange(!1)})})})},"DialogContentImpl")),FA="DialogTitle",em=m.forwardRef(An(function(l,o){const{__scopeDialog:i,...u}=l,d=sa(FA,i),{setTitleCount:h}=d;return Dt(()=>(h(p=>p+1),()=>h(p=>p-1)),[h]),s.jsx(Be.h2,{id:d.titleId,...u,ref:o})},"DialogTitle")),QA="DialogDescription",tm=m.forwardRef(An(function(l,o){const{__scopeDialog:i,...u}=l,d=sa(QA,i),{setDescriptionCount:h}=d;return Dt(()=>(h(p=>p+1),()=>h(p=>p-1)),[h]),s.jsx(Be.p,{id:d.descriptionId,...u,ref:o})},"DialogDescription")),ZA="DialogClose",nm=m.forwardRef(An(function(l,o){const{__scopeDialog:i,...u}=l,d=sa(ZA,i);return s.jsx(Be.button,{type:"button",...u,ref:o,onClick:Ee(l.onClick,()=>d.onOpenChange(!1))})},"DialogClose"));function Fc(a){return a?"open":"closed"}An(Fc,"getState");const qn=Kb,Bo=Xb,JA=Zb,Wb=m.forwardRef(({className:a,...l},o)=>s.jsx(Jh,{ref:o,className:Re("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...l}));Wb.displayName=Jh.displayName;const jn=m.forwardRef(({className:a,children:l,...o},i)=>s.jsxs(JA,{children:[s.jsx(Wb,{}),s.jsxs(Wh,{ref:i,className:Re("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 sm:rounded-lg",a),...o,children:[l,s.jsxs(nm,{className:"absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100",children:[s.jsx(Oc,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));jn.displayName=Wh.displayName;const Cn=({className:a,...l})=>s.jsx("div",{className:Re("flex flex-col space-y-1.5 text-center sm:text-left",a),...l});Cn.displayName="DialogHeader";const In=({className:a,...l})=>s.jsx("div",{className:Re("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...l});In.displayName="DialogFooter";const En=m.forwardRef(({className:a,...l},o)=>s.jsx(em,{ref:o,className:Re("text-lg font-semibold leading-none tracking-tight",a),...l}));En.displayName=em.displayName;const ch=m.forwardRef(({className:a,...l},o)=>s.jsx(tm,{ref:o,className:Re("text-sm text-muted-foreground",a),...l}));ch.displayName=tm.displayName;var WA=Object.defineProperty,ll=(a,l)=>WA(a,"name",{value:l,configurable:!0}),eM="AlertDialog",[tM,Y_]=fn(eM,[$b]),rl=$b(),nM=ll(a=>{const{__scopeAlertDialog:l,...o}=a,i=rl(l);return s.jsx(Kb,{...i,...o,modal:!0})},"AlertDialog"),aM=m.forwardRef(ll(function(l,o){const{__scopeAlertDialog:i,...u}=l,d=rl(i);return s.jsx(Xb,{...d,...u,ref:o})},"AlertDialogTrigger")),lM=ll(a=>{const{__scopeAlertDialog:l,...o}=a,i=rl(l);return s.jsx(Zb,{...i,...o})},"AlertDialogPortal"),rM=m.forwardRef(ll(function(l,o){const{__scopeAlertDialog:i,...u}=l,d=rl(i);return s.jsx(Jh,{...d,...u,ref:o})},"AlertDialogOverlay")),sM="AlertDialogContent",[oM,iM]=tM(sM),cM=m.forwardRef(ll(function(l,o){const{__scopeAlertDialog:i,children:u,...d}=l,h=rl(i),p=m.useRef(null),g=Ie(o,p),v=m.useRef(null);return s.jsx(oM,{scope:i,cancelRef:v,children:s.jsx(Wh,{role:"alertdialog",...h,...d,ref:g,onOpenAutoFocus:Ee(d.onOpenAutoFocus,x=>{var y;x.preventDefault(),(y=v.current)==null||y.focus({preventScroll:!0})}),onPointerDownOutside:x=>x.preventDefault(),onInteractOutside:x=>x.preventDefault(),children:u})})},"AlertDialogContent")),uM=m.forwardRef(ll(function(l,o){const{__scopeAlertDialog:i,...u}=l,d=rl(i);return s.jsx(em,{...d,...u,ref:o})},"AlertDialogTitle")),dM=m.forwardRef(ll(function(l,o){const{__scopeAlertDialog:i,...u}=l,d=rl(i);return s.jsx(tm,{...d,...u,ref:o})},"AlertDialogDescription")),fM=m.forwardRef(ll(function(l,o){const{__scopeAlertDialog:i,...u}=l,d=rl(i);return s.jsx(nm,{...d,...u,ref:o})},"AlertDialogAction")),hM="AlertDialogCancel",mM=m.forwardRef(ll(function(l,o){const{__scopeAlertDialog:i,...u}=l,{cancelRef:d}=iM(hM,i),h=rl(i),p=Ie(o,d);return s.jsx(nm,{...h,...u,ref:p})},"AlertDialogCancel")),pM=nM,gM=aM,vM=lM,e1=rM,t1=cM,n1=fM,a1=mM,l1=uM,r1=dM;const s1=pM,xM=gM,yM=vM,o1=m.forwardRef(({className:a,...l},o)=>s.jsx(e1,{ref:o,className:Re("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...l}));o1.displayName=e1.displayName;const am=m.forwardRef(({className:a,...l},o)=>s.jsxs(yM,{children:[s.jsx(o1,{}),s.jsx(t1,{ref:o,className:Re("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg sm:max-w-[425px]",a),...l})]}));am.displayName=t1.displayName;const i1=({className:a,...l})=>s.jsx("div",{className:Re("flex flex-col space-y-2 text-center sm:text-left",a),...l}),c1=({className:a,...l})=>s.jsx("div",{className:Re("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...l}),lm=m.forwardRef(({className:a,...l},o)=>s.jsx(l1,{ref:o,className:Re("text-lg font-semibold",a),...l}));lm.displayName=l1.displayName;const rm=m.forwardRef(({className:a,...l},o)=>s.jsx(r1,{ref:o,className:Re("text-sm text-muted-foreground",a),...l}));rm.displayName=r1.displayName;const sm=m.forwardRef(({className:a,...l},o)=>s.jsx(n1,{ref:o,className:Re("inline-flex h-9 items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90",a),...l}));sm.displayName=n1.displayName;const om=m.forwardRef(({className:a,...l},o)=>s.jsx(a1,{ref:o,className:Re("inline-flex h-9 items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium hover:bg-accent",a),...l}));om.displayName=a1.displayName;var bM=Object.defineProperty,SM=(a,l)=>bM(a,"name",{value:l,configurable:!0});function uh(a,[l,o]){return Math.min(o,Math.max(l,a))}SM(uh,"clamp");var wM=Object.defineProperty,jM=(a,l)=>wM(a,"name",{value:l,configurable:!0});function u1(a){const l=m.useRef({value:a,previous:a});return m.useMemo(()=>(l.current.value!==a&&(l.current.previous=l.current.value,l.current.value=a),l.current.previous),[a])}jM(u1,"usePrevious");var CM=Object.defineProperty,EM=(a,l)=>CM(a,"name",{value:l,configurable:!0}),d1=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),RM=m.forwardRef(EM(function(l,o){return s.jsx(Be.span,{...l,ref:o,style:{...d1,...l.style}})},"VisuallyHidden")),NM=RM,TM=Object.defineProperty,rt=(a,l)=>TM(a,"name",{value:l,configurable:!0}),AM=[" ","Enter","ArrowUp","ArrowDown"],MM=[" ","Enter"],ps="Select",[Qc,im,DM]=zc(ps),[yr,$_]=fn(ps,[DM,Es]),cm=Es(),[_M,Il]=yr(ps),[OM,kM]=yr(ps);function f1(a){const{__scopeSelect:l,children:o,open:i,defaultOpen:u,onOpenChange:d,value:h,defaultValue:p,onValueChange:g,dir:v,name:x,autoComplete:y,disabled:S,required:w,form:C,internal_do_not_use_render:E}=a,j=cm(l),[N,M]=m.useState(null),[T,_]=m.useState(null),[O,A]=m.useState(!1),H=zo(v),[z,K]=Ja({prop:i,defaultProp:u??!1,onChange:d,caller:ps}),[se,X]=Ja({prop:h,defaultProp:p,onChange:g,caller:ps}),I=m.useRef(null),re=m.useRef(se);m.useEffect(()=>{const q=C?N==null?void 0:N.ownerDocument.getElementById(C):N==null?void 0:N.form;if(q instanceof HTMLFormElement){const Q=rt(()=>X(re.current),"reset");return q.addEventListener("reset",Q),()=>q.removeEventListener("reset",Q)}},[C,N,X]);const ee=N?!!C||!!N.closest("form"):!0,[oe,U]=m.useState(new Set),$=ga(),le=Array.from(oe).map(q=>q.props.value).join(";"),B=m.useCallback(q=>{U(Q=>new Set(Q).add(q))},[]),Z=m.useCallback(q=>{U(Q=>{const ae=new Set(Q);return ae.delete(q),ae})},[]),D={required:w,trigger:N,onTriggerChange:M,valueNode:T,onValueNodeChange:_,valueNodeHasChildren:O,onValueNodeHasChildrenChange:A,contentId:$,value:se,onValueChange:X,open:z,onOpenChange:K,dir:H,triggerPointerDownPosRef:I,disabled:S,name:x,autoComplete:y,form:C,nativeOptions:oe,nativeSelectKey:le,isFormControl:ee};return s.jsx(W0,{...j,children:s.jsx(_M,{scope:l,...D,children:s.jsx(Qc.Provider,{scope:l,children:s.jsx(OM,{scope:l,onNativeOptionAdd:B,onNativeOptionRemove:Z,children:x1(E)?E(D):o})})})})}rt(f1,"SelectProvider");var zM=rt(a=>{const{__scopeSelect:l,children:o,...i}=a;return s.jsx(f1,{__scopeSelect:l,...i,internal_do_not_use_render:({isFormControl:u})=>s.jsxs(s.Fragment,{children:[o,u?s.jsx(aD,{__scopeSelect:l}):null]})})},"Select"),LM="SelectTrigger",h1=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,disabled:u=!1,...d}=l,h=cm(i),p=Il(LM,i),g=p.disabled||u,v=Ie(o,p.onTriggerChange),x=im(i),y=m.useRef("touch"),[S,w,C]=um(j=>{const N=x().filter(_=>!_.disabled),M=N.find(_=>_.value===p.value),T=dm(N,j,M);T!==void 0&&p.onValueChange(T.value)}),E=rt(j=>{g||(p.onOpenChange(!0),C()),j&&(p.triggerPointerDownPosRef.current={x:Math.round(j.pageX),y:Math.round(j.pageY)})},"handleOpen");return s.jsx(eb,{asChild:!0,...h,children:s.jsx(Be.button,{type:"button",role:"combobox","aria-controls":p.open?p.contentId:void 0,"aria-expanded":p.open,"aria-required":p.required,"aria-autocomplete":"none",dir:p.dir,"data-state":p.open?"open":"closed",disabled:g,"data-disabled":g?"":void 0,"data-placeholder":Ho(p.value)?"":void 0,...d,ref:v,onClick:Ee(d.onClick,j=>{j.currentTarget.focus(),y.current!=="mouse"&&E(j)}),onPointerDown:Ee(d.onPointerDown,j=>{y.current=j.pointerType;const N=j.target;N.hasPointerCapture(j.pointerId)&&N.releasePointerCapture(j.pointerId),j.button===0&&j.ctrlKey===!1&&j.pointerType==="mouse"&&(E(j),j.preventDefault())}),onKeyDown:Ee(d.onKeyDown,j=>{const N=S.current!=="";!(j.ctrlKey||j.altKey||j.metaKey)&&j.key.length===1&&w(j.key),!(N&&j.key===" ")&&AM.includes(j.key)&&(E(),j.preventDefault())})})})},"SelectTrigger")),UM="SelectValue",BM=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,className:u,style:d,children:h,placeholder:p="",...g}=l,v=Il(UM,i),{onValueNodeHasChildrenChange:x}=v,y=h!==void 0,S=Ie(o,v.onValueNodeChange);Dt(()=>{x(y)},[x,y]);const w=Ho(v.value);return s.jsx(Be.span,{...g,asChild:w?!1:g.asChild,ref:S,style:{pointerEvents:"none"},children:s.jsx(m.Fragment,{children:w?p:h},w?"placeholder":"value")})},"SelectValue")),HM=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,children:u,...d}=l;return s.jsx(Be.span,{"aria-hidden":!0,...d,ref:o,children:u||"▼"})},"SelectIcon")),PM="SelectPortal",[qM,IM]=yr(PM,{forceMount:void 0}),VM=rt(a=>{const{__scopeSelect:l,forceMount:o,...i}=a;return s.jsx(qM,{scope:a.__scopeSelect,forceMount:o,children:s.jsx(Gh,{asChild:!0,...i})})},"SelectPortal"),mr="SelectContent",m1=m.forwardRef(rt(function(l,o){const i=IM(mr,l.__scopeSelect),{forceMount:u=i.forceMount,...d}=l,h=Il(mr,l.__scopeSelect),[p,g]=m.useState();return Dt(()=>{g(new DocumentFragment)},[]),s.jsx(al,{present:u||h.open,children:({present:v})=>v?s.jsx($M,{...d,ref:o}):s.jsx(GM,{...d,fragment:p})})},"SelectContent")),GM=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,children:u,fragment:d}=l;return d?bs.createPortal(s.jsx(p1,{scope:i,children:s.jsx(Qc.Slot,{scope:i,children:s.jsx("div",{ref:o,children:u})})}),d):null},"SelectContentFragment")),aa=10,[p1,Zc]=yr(mr),YM=va("SelectContent.RemoveScroll"),$M=m.forwardRef(rt(function(l,o){const{__scopeSelect:i}=l,{position:u="item-aligned",onCloseAutoFocus:d,onEscapeKeyDown:h,onPointerDownOutside:p,side:g,sideOffset:v,align:x,alignOffset:y,arrowPadding:S,collisionBoundary:w,collisionPadding:C,sticky:E,hideWhenDetached:j,avoidCollisions:N,...M}=l,T=Il(mr,i),[_,O]=m.useState(null),[A,H]=m.useState(null),z=Ie(o,O),[K,se]=m.useState(null),[X,I]=m.useState(null),re=im(i),[ee,oe]=m.useState(!1),U=m.useRef(!1);m.useEffect(()=>{if(_)return Kh(_)},[_]),Lo();const $=m.useCallback(fe=>{const[xe,...J]=re().map(Me=>Me.ref.current),[me]=J.slice(-1),je=document.activeElement;for(const Me of fe)if(Me===je||(Me==null||Me.scrollIntoView({block:"nearest"}),Me===xe&&A&&(A.scrollTop=0),Me===me&&A&&(A.scrollTop=A.scrollHeight),Me==null||Me.focus(),document.activeElement!==je))return},[re,A]),le=m.useCallback(()=>$([K,_]),[$,K,_]);m.useEffect(()=>{ee&&le()},[ee,le]);const{onOpenChange:B,triggerPointerDownPosRef:Z}=T;m.useEffect(()=>{if(_){let fe={x:0,y:0};const xe=rt(me=>{var je,Me;fe={x:Math.abs(Math.round(me.pageX)-(((je=Z.current)==null?void 0:je.x)??0)),y:Math.abs(Math.round(me.pageY)-(((Me=Z.current)==null?void 0:Me.y)??0))}},"handlePointerMove"),J=rt(me=>{fe.x<=10&&fe.y<=10?me.preventDefault():me.composedPath().includes(_)||B(!1),document.removeEventListener("pointermove",xe),Z.current=null},"handlePointerUp");return Z.current!==null&&(document.addEventListener("pointermove",xe),document.addEventListener("pointerup",J,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",xe),document.removeEventListener("pointerup",J,{capture:!0})}}},[_,B,Z]),m.useEffect(()=>{const fe=rt(()=>B(!1),"close");return window.addEventListener("blur",fe),window.addEventListener("resize",fe),()=>{window.removeEventListener("blur",fe),window.removeEventListener("resize",fe)}},[B]);const[D,q]=um(fe=>{const xe=re().filter(je=>!je.disabled),J=xe.find(je=>je.ref.current===document.activeElement),me=dm(xe,fe,J);me&&setTimeout(()=>{var je;return(je=me.ref.current)==null?void 0:je.focus()})}),Q=m.useCallback((fe,xe,J)=>{const me=!U.current&&!J;(T.value!==void 0&&T.value===xe||me)&&(se(fe),me&&(U.current=!0))},[T.value]),ae=m.useCallback(()=>_==null?void 0:_.focus(),[_]),ce=m.useCallback((fe,xe,J)=>{const me=!U.current&&!J;(T.value!==void 0&&T.value===xe||me)&&I(fe)},[T.value]),Se=u==="popper"?hy:KM,ue=Se===hy?{side:g,sideOffset:v,align:x,alignOffset:y,arrowPadding:S,collisionBoundary:w,collisionPadding:C,sticky:E,hideWhenDetached:j,avoidCollisions:N}:{};return s.jsx(p1,{scope:i,content:_,viewport:A,onViewportChange:H,itemRefCallback:Q,selectedItem:K,onItemLeave:ae,itemTextRefCallback:ce,focusSelectedItem:le,selectedItemText:X,position:u,isPositioned:ee,searchRef:D,children:s.jsx(Kc,{as:YM,allowPinchZoom:!0,children:s.jsx(zh,{asChild:!0,trapped:T.open,onMountAutoFocus:fe=>{fe.preventDefault()},onUnmountAutoFocus:Ee(d,fe=>{var xe;(xe=T.trigger)==null||xe.focus({preventScroll:!0}),fe.preventDefault()}),children:s.jsx(Lc,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:h,onPointerDownOutside:p,onFocusOutside:fe=>fe.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:s.jsx(Se,{role:"listbox",id:T.contentId,"data-state":T.open?"open":"closed",dir:T.dir,onContextMenu:fe=>fe.preventDefault(),...M,...ue,onPlaced:()=>oe(!0),ref:z,style:{display:"flex",flexDirection:"column",outline:"none",...M.style},onKeyDown:Ee(M.onKeyDown,fe=>{const xe=fe.ctrlKey||fe.altKey||fe.metaKey;if(fe.key==="Tab"&&fe.preventDefault(),!xe&&fe.key.length===1&&q(fe.key),["ArrowUp","ArrowDown","Home","End"].includes(fe.key)){let me=re().filter(je=>!je.disabled).map(je=>je.ref.current);if(["ArrowUp","End"].includes(fe.key)&&(me=me.slice().reverse()),["ArrowUp","ArrowDown"].includes(fe.key)){const je=fe.target,Me=me.indexOf(je);me=me.slice(Me+1)}setTimeout(()=>$(me)),fe.preventDefault()}})})})})})})},"SelectContentImpl")),KM=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,onPlaced:u,...d}=l,h=Il(mr,i),p=Zc(mr,i),[g,v]=m.useState(null),[x,y]=m.useState(null),S=Ie(o,y),w=im(i),C=m.useRef(!1),E=m.useRef(!0),{viewport:j,selectedItem:N,selectedItemText:M,focusSelectedItem:T}=p,_=m.useCallback(()=>{if(h.trigger&&h.valueNode&&g&&x&&j&&N&&M){const z=h.trigger.getBoundingClientRect(),K=x.getBoundingClientRect(),se=h.valueNode.getBoundingClientRect(),X=M.getBoundingClientRect();if(h.dir!=="rtl"){const je=X.left-K.left,Me=se.left-je,mt=z.left-Me,pt=z.width+mt,bt=Math.max(pt,K.width),St=window.innerWidth-aa,Lt=uh(Me,[aa,Math.max(aa,St-bt)]);g.style.minWidth=pt+"px",g.style.left=Lt+"px"}else{const je=K.right-X.right,Me=window.innerWidth-se.right-je,mt=window.innerWidth-z.right-Me,pt=z.width+mt,bt=Math.max(pt,K.width),St=window.innerWidth-aa,Lt=uh(Me,[aa,Math.max(aa,St-bt)]);g.style.minWidth=pt+"px",g.style.right=Lt+"px"}const I=w(),re=window.innerHeight-aa*2,ee=j.scrollHeight,oe=window.getComputedStyle(x),U=parseInt(oe.borderTopWidth,10),$=parseInt(oe.paddingTop,10),le=parseInt(oe.borderBottomWidth,10),B=parseInt(oe.paddingBottom,10),Z=U+$+ee+B+le,D=Math.min(N.offsetHeight*5,Z),q=window.getComputedStyle(j),Q=parseInt(q.paddingTop,10),ae=parseInt(q.paddingBottom,10),ce=z.top+z.height/2-aa,Se=re-ce,ue=N.offsetHeight/2,fe=N.offsetTop+ue,xe=U+$+fe,J=Z-xe;if(xe<=ce){const je=I.length>0&&N===I[I.length-1].ref.current;g.style.bottom="0px";const Me=x.clientHeight-j.offsetTop-j.offsetHeight,mt=Math.max(Se,ue+(je?ae:0)+Me+le),pt=xe+mt;g.style.height=pt+"px"}else{const je=I.length>0&&N===I[0].ref.current;g.style.top="0px";const mt=Math.max(ce,U+j.offsetTop+(je?Q:0)+ue)+J;g.style.height=mt+"px",j.scrollTop=xe-ce+j.offsetTop}g.style.margin=`${aa}px 0`,g.style.minHeight=D+"px",g.style.maxHeight=re+"px",u==null||u(),requestAnimationFrame(()=>C.current=!0)}},[w,h.trigger,h.valueNode,g,x,j,N,M,h.dir,u]);Dt(()=>_(),[_]);const[O,A]=m.useState();Dt(()=>{x&&A(window.getComputedStyle(x).zIndex)},[x]);const H=m.useCallback(z=>{z&&E.current===!0&&(_(),T==null||T(),E.current=!1)},[_,T]);return s.jsx(XM,{scope:i,contentWrapper:g,shouldExpandOnScrollRef:C,onScrollButtonChange:H,children:s.jsx("div",{ref:v,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:O},children:s.jsx(Be.div,{...d,ref:S,style:{boxSizing:"border-box",maxHeight:"100%",...d.style}})})})},"SelectItemAlignedPosition")),hy=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,align:u="start",collisionPadding:d=aa,...h}=l,p=cm(i);return s.jsx(Vh,{...p,...h,ref:o,align:u,collisionPadding:d,style:{boxSizing:"border-box",...h.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[XM,FM]=yr(mr,{}),my="SelectViewport",QM=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,nonce:u,...d}=l,h=Zc(my,i),p=FM(my,i),g=Ie(o,h.onViewportChange),v=m.useRef(0);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:u}),s.jsx(Qc.Slot,{scope:i,children:s.jsx(Be.div,{"data-radix-select-viewport":"",role:"presentation",...d,ref:g,style:{position:"relative",flex:1,overflow:"hidden auto",...d.style},onScroll:Ee(d.onScroll,x=>{const y=x.currentTarget,{contentWrapper:S,shouldExpandOnScrollRef:w}=p;if(w!=null&&w.current&&S){const C=Math.abs(v.current-y.scrollTop);if(C>0){const E=window.innerHeight-aa*2,j=parseFloat(S.style.minHeight),N=parseFloat(S.style.height),M=Math.max(j,N);if(M<E){const T=M+C,_=Math.min(E,T),O=T-_;S.style.height=_+"px",S.style.bottom==="0px"&&(y.scrollTop=O>0?O:0,S.style.justifyContent="flex-end")}}}v.current=y.scrollTop})})})]})},"SelectViewport")),ZM="SelectGroup",[K_,X_]=yr(ZM),dh="SelectItem",[JM,g1]=yr(dh),v1=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,value:u,disabled:d=!1,textValue:h,...p}=l,g=Il(dh,i),v=Zc(dh,i),x=g.value===u,[y,S]=m.useState(h??""),[w,C]=m.useState(!1),E=$n(_=>{var O;return(O=v.itemRefCallback)==null?void 0:O.call(v,_,u,d)}),j=Ie(o,E),N=ga(),M=m.useRef("touch"),T=rt(()=>{d||(g.onValueChange(u),g.onOpenChange(!1))},"handleSelect");return s.jsx(JM,{scope:i,value:u,disabled:d,textId:N,isSelected:x,onItemTextChange:m.useCallback(_=>{S(O=>O||((_==null?void 0:_.textContent)??"").trim())},[]),children:s.jsx(Qc.ItemSlot,{scope:i,value:u,disabled:d,textValue:y,children:s.jsx(Be.div,{role:"option","aria-labelledby":N,"data-highlighted":w?"":void 0,"aria-selected":x&&w,"data-state":x?"checked":"unchecked","aria-disabled":d||void 0,"data-disabled":d?"":void 0,tabIndex:d?void 0:-1,...p,ref:j,onFocus:Ee(p.onFocus,()=>C(!0)),onBlur:Ee(p.onBlur,()=>C(!1)),onClick:Ee(p.onClick,()=>{M.current!=="mouse"&&T()}),onPointerUp:Ee(p.onPointerUp,()=>{M.current==="mouse"&&T()}),onPointerDown:Ee(p.onPointerDown,_=>{M.current=_.pointerType}),onPointerMove:Ee(p.onPointerMove,_=>{var O;M.current=_.pointerType,d?(O=v.onItemLeave)==null||O.call(v):M.current==="mouse"&&_.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ee(p.onPointerLeave,_=>{var O;_.currentTarget===document.activeElement&&((O=v.onItemLeave)==null||O.call(v))}),onKeyDown:Ee(p.onKeyDown,_=>{var A;d||_.target!==_.currentTarget||((A=v.searchRef)==null?void 0:A.current)!==""&&_.key===" "||(MM.includes(_.key)&&T(),_.key===" "&&_.preventDefault())})})})})},"SelectItem")),cc="SelectItemText",WM=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,className:u,style:d,...h}=l,p=Il(cc,i),g=Zc(cc,i),v=g1(cc,i),x=kM(cc,i),[y,S]=m.useState(null),w=$n(T=>{var _;return(_=g.itemTextRefCallback)==null?void 0:_.call(g,T,v.value,v.disabled)}),C=Ie(o,S,v.onItemTextChange,w),E=y==null?void 0:y.textContent,j=m.useMemo(()=>s.jsx("option",{value:v.value,disabled:v.disabled,children:E},v.value),[v.disabled,v.value,E]),{onNativeOptionAdd:N,onNativeOptionRemove:M}=x;return Dt(()=>(N(j),()=>M(j)),[N,M,j]),s.jsxs(s.Fragment,{children:[s.jsx(Be.span,{id:v.textId,...h,ref:C}),v.isSelected&&p.valueNode&&!p.valueNodeHasChildren&&!Ho(p.value)?bs.createPortal(h.children,p.valueNode):null]})},"SelectItemText")),eD="SelectItemIndicator",tD=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,...u}=l;return g1(eD,i).isSelected?s.jsx(Be.span,{"aria-hidden":!0,...u,ref:o}):null},"SelectItemIndicator")),nD="SelectBubbleInput",aD=m.forwardRef(rt(function({__scopeSelect:l,...o},i){const u=Il(nD,l),{value:d,onValueChange:h,required:p,disabled:g,name:v,autoComplete:x,form:y}=u,{nativeOptions:S,nativeSelectKey:w}=u,C=m.useRef(null),E=Ie(i,C),j=d??"",N=u1(j),M=Array.from(S).some(T=>(T.props.value??"")==="");return m.useEffect(()=>{const T=C.current;if(!T)return;const _=window.HTMLSelectElement.prototype,A=Object.getOwnPropertyDescriptor(_,"value").set;if(N!==j&&A){const H=new Event("change",{bubbles:!0});A.call(T,j),T.dispatchEvent(H)}},[N,j]),s.jsxs(Be.select,{"aria-hidden":!0,required:p,tabIndex:-1,name:v,autoComplete:x,disabled:g,form:y,onChange:T=>h(T.target.value),...o,style:{...d1,...o.style},ref:E,defaultValue:j,children:[Ho(d)&&!M?s.jsx("option",{value:""}):null,Array.from(S)]},w)},"SelectBubbleInput"));function x1(a){return typeof a=="function"}rt(x1,"isFunction");function Ho(a){return a===""||a===void 0}rt(Ho,"shouldShowPlaceholder");function um(a){const l=$n(a),o=m.useRef(""),i=m.useRef(0),u=m.useCallback(h=>{const p=o.current+h;l(p),rt((function g(v){o.current=v,window.clearTimeout(i.current),v!==""&&(i.current=window.setTimeout(()=>g(""),1e3))}),"updateSearch")(p)},[l]),d=m.useCallback(()=>{o.current="",window.clearTimeout(i.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(i.current),[]),[o,u,d]}rt(um,"useTypeaheadSearch");function dm(a,l,o){const u=l.length>1&&Array.from(l).every(v=>v===l[0])?l[0]:l,d=o?a.indexOf(o):-1;let h=y1(a,Math.max(d,0));u.length===1&&(h=h.filter(v=>v!==o));const g=h.find(v=>v.textValue.toLowerCase().startsWith(u.toLowerCase()));return g!==o?g:void 0}rt(dm,"findNextItem");function y1(a,l){return a.map((o,i)=>a[(l+i)%a.length])}rt(y1,"wrapArray");const Vn=zM,Gn=BM,Rn=m.forwardRef(({className:a,children:l,...o},i)=>s.jsxs(h1,{ref:i,className:Re("flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50",a),...o,children:[l,s.jsx(HM,{asChild:!0,children:s.jsx(eC,{className:"h-4 w-4 opacity-50"})})]}));Rn.displayName=h1.displayName;const Nn=m.forwardRef(({className:a,children:l,position:o="popper",...i},u)=>s.jsx(VM,{children:s.jsx(m1,{ref:u,className:Re("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",a),position:o,...i,children:s.jsx(QM,{className:Re("p-1",o==="popper"&&"w-full min-w-[var(--radix-select-trigger-width)]"),children:l})})}));Nn.displayName=m1.displayName;const lt=m.forwardRef(({className:a,children:l,...o},i)=>s.jsxs(v1,{ref:i,className:Re("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...o,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(tD,{children:s.jsx(Ky,{className:"h-4 w-4"})})}),s.jsx(WM,{children:l})]}));lt.displayName=v1.displayName;var lD=Object.defineProperty,Pl=(a,l)=>lD(a,"name",{value:l,configurable:!0}),fm="Switch",[rD,F_]=fn(fm),[sD,hm]=rD(fm);function b1(a){const{__scopeSwitch:l,checked:o,children:i,defaultChecked:u,disabled:d,form:h,name:p,onCheckedChange:g,required:v,value:x="on",internal_do_not_use_render:y}=a,[S,w]=Ja({prop:o,defaultProp:u??!1,onChange:g,caller:fm}),[C,E]=m.useState(null),[j,N]=m.useState(null),M=m.useRef(!1),[T,_]=m.useReducer(H=>H+1,0),O=C?!!h||!!C.closest("form"):!0,A={checked:S,setChecked:w,disabled:d,control:C,setControl:E,name:p,form:h,value:x,hasConsumerStoppedPropagationRef:M,userInteractionCount:T,onUserInteraction:_,required:v,defaultChecked:u,isFormControl:O,bubbleInput:j,setBubbleInput:N};return s.jsx(sD,{scope:l,...A,children:w1(y)?y(A):i})}Pl(b1,"SwitchProvider");var oD="SwitchTrigger",iD=m.forwardRef(Pl(function({__scopeSwitch:l,onClick:o,...i},u){const{control:d,form:h,value:p,disabled:g,checked:v,required:x,setControl:y,setChecked:S,hasConsumerStoppedPropagationRef:w,onUserInteraction:C,isFormControl:E,bubbleInput:j}=hm(oD,l),N=Ie(u,y),M=m.useRef(v);return m.useEffect(()=>{const T=h?d==null?void 0:d.ownerDocument.getElementById(h):d==null?void 0:d.form;if(T instanceof HTMLFormElement){const _=Pl(()=>S(M.current),"reset");return T.addEventListener("reset",_),()=>T.removeEventListener("reset",_)}},[d,h,S]),s.jsx(Be.button,{type:"button",role:"switch","aria-checked":v,"aria-required":x,"data-state":mm(v),"data-disabled":g?"":void 0,disabled:g,value:p,...i,ref:N,onClick:Ee(o,T=>{C(),S(_=>!_),j&&E&&(w.current=T.isPropagationStopped(),w.current||T.stopPropagation())})})},"SwitchTrigger")),S1=m.forwardRef(Pl(function(l,o){const{__scopeSwitch:i,name:u,checked:d,defaultChecked:h,required:p,disabled:g,value:v,onCheckedChange:x,form:y,...S}=l;return s.jsx(b1,{__scopeSwitch:i,checked:d,defaultChecked:h,disabled:g,required:p,onCheckedChange:x,name:u,form:y,value:v,internal_do_not_use_render:({isFormControl:w})=>s.jsxs(s.Fragment,{children:[s.jsx(iD,{...S,ref:o,__scopeSwitch:i}),w&&s.jsx(fD,{__scopeSwitch:i})]})})},"Switch")),cD="SwitchThumb",uD=m.forwardRef(Pl(function(l,o){const{__scopeSwitch:i,...u}=l,d=hm(cD,i);return s.jsx(Be.span,{"data-state":mm(d.checked),"data-disabled":d.disabled?"":void 0,...u,ref:o})},"SwitchThumb")),dD="SwitchBubbleInput",fD=m.forwardRef(Pl(function({__scopeSwitch:l,onClick:o,...i},u){const{control:d,hasConsumerStoppedPropagationRef:h,userInteractionCount:p,checked:g,defaultChecked:v,required:x,disabled:y,name:S,value:w,form:C,bubbleInput:E,setBubbleInput:j}=hm(dD,l),N=Ie(u,j),M=Ic(d),T=m.useRef(!1),_=m.useRef(g),O=m.useRef(p);m.useEffect(()=>{const H=E;if(!H)return;const z=window.HTMLInputElement.prototype,se=Object.getOwnPropertyDescriptor(z,"checked").set,X=p!==O.current;O.current=p;const I=_.current!==g;_.current=g;const re=!(X&&h.current);if(I&&se){T.current=!X;const ee=new Event("click",{bubbles:re});se.call(H,g),H.dispatchEvent(ee),T.current=!1}},[E,g,h,p]);const A=m.useRef(g);return s.jsx(Be.input,{type:"checkbox","aria-hidden":!0,defaultChecked:v??A.current,required:x,disabled:y,name:S,value:w,form:C,...i,tabIndex:-1,ref:N,onClick:Ee(o,H=>{T.current&&H.stopPropagation()}),style:{...i.style,...M,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"SwitchBubbleInput"));function w1(a){return typeof a=="function"}Pl(w1,"isFunction");function mm(a){return a?"checked":"unchecked"}Pl(mm,"getState");const ba=m.forwardRef(({className:a,...l},o)=>s.jsx(S1,{className:Re("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",a),...l,ref:o,children:s.jsx(uD,{className:Re("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));ba.displayName=S1.displayName;const cr={name:"",slug:"",type:"openai",baseUrl:"https://api.openai.com",apiKey:"",customHeaders:"",enabled:!0};function hD(){const[a,l]=m.useState([]),[o,i]=m.useState(!1),[u,d]=m.useState(cr),[h,p]=m.useState(!1),[g,v]=m.useState(null),[x,y]=m.useState(null),[S,w]=m.useState(cr),[C,E]=m.useState(null),[j,N]=m.useState(!1),M=()=>we.get("/api/admin/providers").then(z=>l(z.providers));m.useEffect(()=>{M()},[]);const T=async()=>{p(!0);try{let z;if(u.customHeaders.trim())try{z=JSON.parse(u.customHeaders)}catch{throw new Error("Custom headers must be valid JSON object")}await we.post("/api/admin/providers",{name:u.name,slug:u.slug||void 0,type:u.type,baseUrl:u.baseUrl,apiKey:u.apiKey,customHeaders:z,enabled:u.enabled}),ve.success("Provider created"),i(!1),d(cr),M()}catch(z){ve.error(z.message)}finally{p(!1)}},_=async z=>{v(z);try{const K=await we.post(`/api/admin/providers/${z}/test`);ve.success(K.ok?`Connection OK: ${K.detail}`:`Failed: ${K.detail}`),M()}catch(K){ve.error(K.message)}finally{v(null)}},O=z=>{y(z.id),w({...cr,name:z.name,slug:z.slug||"",type:z.type,baseUrl:z.baseUrl,apiKey:"",customHeaders:"",enabled:z.enabled})},A=async()=>{if(x){p(!0);try{let z;if(S.customHeaders.trim())try{z=JSON.parse(S.customHeaders)}catch{throw new Error("Custom headers must be valid JSON object")}await we.patch("/api/admin/providers",{id:x,name:S.name,slug:S.slug||void 0,type:S.type,baseUrl:S.baseUrl,apiKey:S.apiKey||void 0,customHeaders:z,enabled:S.enabled}),ve.success("Provider updated"),y(null),w(cr),M()}catch(z){ve.error(z.message)}finally{p(!1)}}},H=async z=>{N(!0);try{await we.del(`/api/admin/providers/${z}`),ve.success("Provider removed"),M()}catch(K){ve.error(K.message)}finally{N(!1),E(null)}};return s.jsxs("div",{children:[s.jsx(wa,{title:"Providers",description:"Upstream LLM providers and their credentials",actions:s.jsxs(qn,{open:o,onOpenChange:i,children:[s.jsx(Bo,{asChild:!0,children:s.jsxs(he,{children:[s.jsx(Oo,{className:"mr-1 h-4 w-4"})," Add provider"]})}),s.jsxs(jn,{children:[s.jsx(Cn,{children:s.jsx(En,{children:"New provider"})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx(be,{children:"Name"}),s.jsx(Ae,{value:u.name,onChange:z=>d({...u,name:z.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Slug (optional)"}),s.jsx(Ae,{value:u.slug,onChange:z=>d({...u,slug:z.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Type"}),s.jsxs(Vn,{value:u.type,onValueChange:z=>d({...u,type:z}),children:[s.jsx(Rn,{children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"openai",children:"OpenAI-compatible"}),s.jsx(lt,{value:"anthropic",children:"Anthropic-compatible"})]})]})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Base URL"}),s.jsx(Ae,{value:u.baseUrl,onChange:z=>d({...u,baseUrl:z.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"API key"}),s.jsx(Ae,{type:"password",value:u.apiKey,onChange:z=>d({...u,apiKey:z.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Custom headers (JSON)"}),s.jsx(Ae,{value:u.customHeaders,onChange:z=>d({...u,customHeaders:z.target.value}),placeholder:'{"X-Org":"acme"}'})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ba,{checked:u.enabled,onCheckedChange:z=>d({...u,enabled:z})}),s.jsx(be,{children:"Enabled"})]})]}),s.jsxs(In,{children:[s.jsx(he,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),s.jsx(he,{disabled:h||!u.name||!u.apiKey,onClick:T,children:"Create"})]})]})]})}),s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"All providers"}),s.jsxs(on,{children:[a.length," total"]})]}),s.jsx(Ze,{children:s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Name"}),s.jsx(pe,{children:"Type"}),s.jsx(pe,{children:"Base URL"}),s.jsx(pe,{children:"Models"}),s.jsx(pe,{children:"Health"}),s.jsx(pe,{children:"Enabled"}),s.jsx(pe,{className:"text-right",children:"Actions"})]})}),s.jsxs(Fn,{children:[a.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:7,className:"text-center text-muted-foreground",children:"No providers yet."})}),a.map(z=>s.jsxs(Ye,{children:[s.jsxs(de,{className:"font-medium",children:[z.name," ",s.jsx("span",{className:"text-xs text-muted-foreground",children:z.slug})]}),s.jsx(de,{children:s.jsx(et,{variant:"outline",children:z.type})}),s.jsx(de,{className:"text-xs text-muted-foreground",children:z.baseUrl}),s.jsx(de,{children:z.modelCount}),s.jsx(de,{children:s.jsx(et,{variant:z.health==="healthy"?"success":z.health==="down"?"destructive":"secondary",children:z.health})}),s.jsx(de,{children:z.enabled?"Yes":"No"}),s.jsx(de,{className:"text-right",children:s.jsxs("div",{className:"flex justify-end gap-1",children:[s.jsx(he,{size:"sm",variant:"outline",disabled:g===z.id,onClick:()=>_(z.id),children:s.jsx(pC,{className:"h-3 w-3"})}),s.jsx(he,{size:"sm",variant:"outline",onClick:()=>O(z),children:"✎"}),s.jsx(he,{size:"sm",variant:"outline",onClick:()=>E(z.id),children:s.jsx(_c,{className:"h-3 w-3"})})]})})]},z.id))]})]})})]}),s.jsx(qn,{open:!!x,onOpenChange:z=>{z||(y(null),w(cr))},children:s.jsxs(jn,{children:[s.jsx(Cn,{children:s.jsx(En,{children:"Edit provider"})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx(be,{children:"Name"}),s.jsx(Ae,{value:S.name,onChange:z=>w({...S,name:z.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Slug (optional)"}),s.jsx(Ae,{value:S.slug,onChange:z=>w({...S,slug:z.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Type"}),s.jsxs(Vn,{value:S.type,onValueChange:z=>w({...S,type:z}),children:[s.jsx(Rn,{children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"openai",children:"OpenAI-compatible"}),s.jsx(lt,{value:"anthropic",children:"Anthropic-compatible"})]})]})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Base URL"}),s.jsx(Ae,{value:S.baseUrl,onChange:z=>w({...S,baseUrl:z.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"API key (leave empty to keep current)"}),s.jsx(Ae,{type:"password",value:S.apiKey,onChange:z=>w({...S,apiKey:z.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Custom headers (JSON)"}),s.jsx(Ae,{value:S.customHeaders,onChange:z=>w({...S,customHeaders:z.target.value}),placeholder:'{"X-Org":"acme"}'})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ba,{checked:S.enabled,onCheckedChange:z=>w({...S,enabled:z})}),s.jsx(be,{children:"Enabled"})]})]}),s.jsxs(In,{children:[s.jsx(he,{variant:"outline",onClick:()=>{y(null),w(cr)},children:"Cancel"}),s.jsx(he,{disabled:h||!S.name,onClick:A,children:"Save changes"})]})]})}),s.jsx(s1,{open:!!C,onOpenChange:z=>{z||E(null)},children:s.jsxs(am,{children:[s.jsxs(i1,{children:[s.jsx(lm,{children:"Delete provider?"}),s.jsx(rm,{children:"This will soft-disable the provider if models depend on it."})]}),s.jsxs(c1,{children:[s.jsx(om,{children:"Cancel"}),s.jsx(sm,{disabled:j,onClick:z=>{C&&(z.preventDefault(),H(C))},children:j?"Deleting…":"Delete"})]})]})})]})}var mD=Object.defineProperty,tl=(a,l)=>mD(a,"name",{value:l,configurable:!0}),pm="Checkbox",[pD,Q_]=fn(pm),[gD,gm]=pD(pm);function j1(a){const{__scopeCheckbox:l,checked:o,children:i,defaultChecked:u,disabled:d,form:h,name:p,onCheckedChange:g,required:v,value:x="on",internal_do_not_use_render:y}=a,[S,w]=Ja({prop:o,defaultProp:u??!1,onChange:g,caller:pm}),[C,E]=m.useState(null),[j,N]=m.useState(null),M=m.useRef(!1),[T,_]=m.useReducer(H=>H+1,0),O=C?!!h||!!C.closest("form"):!0,A={checked:S,disabled:d,setChecked:w,control:C,setControl:E,name:p,form:h,value:x,hasConsumerStoppedPropagationRef:M,userInteractionCount:T,onUserInteraction:_,required:v,defaultChecked:Qa(u)?!1:u,isFormControl:O,bubbleInput:j,setBubbleInput:N};return s.jsx(gD,{scope:l,...A,children:E1(y)?y(A):i})}tl(j1,"CheckboxProvider");var vD="CheckboxTrigger",xD=m.forwardRef(tl(function({__scopeCheckbox:l,onKeyDown:o,onClick:i,...u},d){const{control:h,value:p,disabled:g,checked:v,required:x,setControl:y,setChecked:S,hasConsumerStoppedPropagationRef:w,onUserInteraction:C,isFormControl:E,bubbleInput:j}=gm(vD,l),N=Ie(d,y),M=m.useRef(v);return m.useEffect(()=>{const T=h==null?void 0:h.form;if(T){const _=tl(()=>S(M.current),"reset");return T.addEventListener("reset",_),()=>T.removeEventListener("reset",_)}},[h,S]),s.jsx(Be.button,{type:"button",role:"checkbox","aria-checked":Qa(v)?"mixed":v,"aria-required":x,"data-state":vm(v),"data-disabled":g?"":void 0,disabled:g,value:p,...u,ref:N,onKeyDown:Ee(o,T=>{T.key==="Enter"&&T.preventDefault()}),onClick:Ee(i,T=>{C(),S(_=>Qa(_)?!0:!_),j&&E&&(w.current=T.isPropagationStopped(),w.current||T.stopPropagation())})})},"CheckboxTrigger")),C1=m.forwardRef(tl(function(l,o){const{__scopeCheckbox:i,name:u,checked:d,defaultChecked:h,required:p,disabled:g,value:v,onCheckedChange:x,form:y,...S}=l;return s.jsx(j1,{__scopeCheckbox:i,checked:d,defaultChecked:h,disabled:g,required:p,onCheckedChange:x,name:u,form:y,value:v,internal_do_not_use_render:({isFormControl:w})=>s.jsxs(s.Fragment,{children:[s.jsx(xD,{...S,ref:o,__scopeCheckbox:i}),w&&s.jsx(wD,{__scopeCheckbox:i})]})})},"Checkbox")),yD="CheckboxIndicator",bD=m.forwardRef(tl(function(l,o){const{__scopeCheckbox:i,forceMount:u,...d}=l,h=gm(yD,i);return s.jsx(al,{present:u||Qa(h.checked)||h.checked===!0,children:s.jsx(Be.span,{"data-state":vm(h.checked),"data-disabled":h.disabled?"":void 0,...d,ref:o,style:{pointerEvents:"none",...l.style}})})},"CheckboxIndicator")),SD="CheckboxBubbleInput",wD=m.forwardRef(tl(function({__scopeCheckbox:l,onClick:o,...i},u){const{control:d,hasConsumerStoppedPropagationRef:h,userInteractionCount:p,checked:g,defaultChecked:v,required:x,disabled:y,name:S,value:w,form:C,bubbleInput:E,setBubbleInput:j}=gm(SD,l),N=Ie(u,j),M=Ic(d),T=m.useRef(!1),_=m.useRef(g),O=m.useRef(p);m.useEffect(()=>{const H=E;if(!H)return;const z=window.HTMLInputElement.prototype,se=Object.getOwnPropertyDescriptor(z,"checked").set,X=p!==O.current;O.current=p;const I=_.current!==g;_.current=g;const re=!(X&&h.current);if(I&&se){T.current=!X;const ee=new Event("click",{bubbles:re});H.indeterminate=Qa(g),se.call(H,Qa(g)?!1:g),H.dispatchEvent(ee),T.current=!1}},[E,g,h,p]);const A=m.useRef(Qa(g)?!1:g);return s.jsx(Be.input,{type:"checkbox","aria-hidden":!0,defaultChecked:v??A.current,required:x,disabled:y,name:S,value:w,form:C,...i,tabIndex:-1,ref:N,onClick:Ee(o,H=>{T.current&&H.stopPropagation()}),style:{...i.style,...M,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function E1(a){return typeof a=="function"}tl(E1,"isFunction");function Qa(a){return a==="indeterminate"}tl(Qa,"isIndeterminate");function vm(a){return Qa(a)?"indeterminate":a?"checked":"unchecked"}tl(vm,"getState");const xm=m.forwardRef(({className:a,...l},o)=>s.jsx(C1,{ref:o,className:Re("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",a),...l,children:s.jsx(bD,{className:Re("flex items-center justify-center text-current"),children:s.jsx(Ky,{className:"h-3.5 w-3.5"})})}));xm.displayName=C1.displayName;function jD(){const[a,l]=m.useState([]),[o,i]=m.useState([]),[u,d]=m.useState("all"),[h,p]=m.useState(!1),[g,v]=m.useState(""),[x,y]=m.useState([]),[S,w]=m.useState(new Set),[C,E]=m.useState(!1),[j,N]=m.useState(""),[M,T]=m.useState(""),[_,O]=m.useState(null),[A,H]=m.useState(!1),[z,K]=m.useState(null),[se,X]=m.useState(null),I=async()=>{const[B,Z]=await Promise.all([we.get("/api/admin/models"),we.get("/api/admin/providers")]);l(B.models),i(Z.providers)};m.useEffect(()=>{I()},[]);const re=a.filter(B=>!(u!=="all"&&B.providerId!==u||j&&!B.publicModelId.toLowerCase().includes(j.toLowerCase()))),ee=x.filter(B=>{if(!M)return!0;const Z=M.toLowerCase();return B.upstreamId.toLowerCase().includes(Z)||B.displayName.toLowerCase().includes(Z)}),oe=async()=>{if(g){E(!0);try{const B=await we.post(`/api/admin/providers/${g}/discover`);y(B.models),w(new Set)}catch(B){ve.error(B.message)}finally{E(!1)}}},U=async()=>{if(S.size!==0)try{const B=await we.post("/api/admin/models/import",{providerId:g,modelIds:Array.from(S)});ve.success(`Imported ${B.imported} of ${B.requested}`),p(!1),y([]),w(new Set),I()}catch(B){ve.error(B.message)}},$=async()=>{if(se)try{await we.del(`/api/admin/models/${se.id}`),ve.success("Model deleted"),X(null),I()}catch(B){ve.error(B.message)}},le=async B=>{var D,q,Q;O(B),H(!0);const Z=Date.now();K({phase:"streaming",startedAt:Z,text:"",progress:{}});try{const ae=await globalThis.fetch(`/api/admin/models/${B}/test-stream`,{method:"POST",headers:{"content-type":"application/json"},credentials:"include"});if(!ae.ok){const J=await ae.text().catch(()=>"");K({phase:"error",model:B,error:`HTTP ${ae.status}: ${J}`});return}const ce=(D=ae.body)==null?void 0:D.getReader();if(!ce){K({phase:"error",model:B,error:"No response body"});return}const Se=new TextDecoder;let ue="",fe="",xe=!1;for(;!xe;){const{value:J,done:me}=await ce.read();xe=me,J&&(ue+=Se.decode(J,{stream:!0}));let je;for(;(je=ue.indexOf(`
325
+ `)},lT=0,cs=[];function rT(a){var l=m.useRef([]),o=m.useRef([0,0]),i=m.useRef(),u=m.useState(lT++)[0],d=m.useState(y0)[0],h=m.useRef(a);m.useEffect(function(){h.current=a},[a]),m.useEffect(function(){if(a.inert){document.body.classList.add("block-interactivity-".concat(u));var E=RN([a.lockRef.current],(a.shards||[]).map(cy),!0).filter(Boolean);return E.forEach(function(j){return j.classList.add("allow-interactivity-".concat(u))}),function(){document.body.classList.remove("block-interactivity-".concat(u)),E.forEach(function(j){return j.classList.remove("allow-interactivity-".concat(u))})}}},[a.inert,a.lockRef.current,a.shards]);var p=m.useCallback(function(E,j){if("touches"in E&&E.touches.length===2||E.type==="wheel"&&E.ctrlKey)return!h.current.allowPinchZoom;var N=oc(E),M=o.current,T="deltaX"in E?E.deltaX:M[0]-N[0],_="deltaY"in E?E.deltaY:M[1]-N[1],O,A=E.target,H=Math.abs(T)>Math.abs(_)?"h":"v";if("touches"in E&&H==="h"&&A.type==="range")return!1;var z=window.getSelection(),K=z&&z.anchorNode,se=K?K===A||K.contains(A):!1;if(se)return!1;var X=oy(H,A);if(!X)return!0;if(X?O=H:(O=H==="v"?"h":"v",X=oy(H,A)),!X)return!1;if(!i.current&&"changedTouches"in E&&(T||_)&&(i.current=O),!O)return!0;var I=i.current||O;return tT(I,j,E,I==="h"?T:_)},[]),g=m.useCallback(function(E){var j=E;if(!(!cs.length||cs[cs.length-1]!==d)){var N="deltaY"in j?iy(j):oc(j),M=l.current.filter(function(O){return O.name===j.type&&(O.target===j.target||j.target===O.shadowParent)&&nT(O.delta,N)})[0];if(M&&M.should){j.cancelable&&j.preventDefault();return}if(!M){var T=(h.current.shards||[]).map(cy).filter(Boolean).filter(function(O){return O.contains(j.target)}),_=T.length>0?p(j,T[0]):!h.current.noIsolation;_&&j.cancelable&&j.preventDefault()}}},[]),v=m.useCallback(function(E,j,N,M){var T={name:E,delta:j,target:N,should:M,shadowParent:sT(N)};l.current.push(T),setTimeout(function(){l.current=l.current.filter(function(_){return _!==T})},1)},[]),x=m.useCallback(function(E){o.current=oc(E),i.current=void 0},[]),y=m.useCallback(function(E){v(E.type,iy(E),E.target,p(E,a.lockRef.current))},[]),S=m.useCallback(function(E){v(E.type,oc(E),E.target,p(E,a.lockRef.current))},[]);m.useEffect(function(){return cs.push(d),a.setCallbacks({onScrollCapture:y,onWheelCapture:y,onTouchMoveCapture:S}),document.addEventListener("wheel",g,is),document.addEventListener("touchmove",g,is),document.addEventListener("touchstart",x,is),function(){cs=cs.filter(function(E){return E!==d}),document.removeEventListener("wheel",g,is),document.removeEventListener("touchmove",g,is),document.removeEventListener("touchstart",x,is)}},[]);var w=a.removeScrollBar,C=a.inert;return m.createElement(m.Fragment,null,C?m.createElement(d,{styles:aT(u)}):null,w?m.createElement(XN,{noRelative:a.noRelative,gapMode:a.gapMode}):null)}function sT(a){for(var l=null;a!==null;)a instanceof ShadowRoot&&(l=a.host,a=a.host),a=a.parentNode;return l}const oT=zN(x0,rT);var Kc=m.forwardRef(function(a,l){return m.createElement($c,ma({},a,{ref:l,sideCar:oT}))});Kc.classNames=$c.classNames;var iT=Object.defineProperty,it=(a,l)=>iT(a,"name",{value:l,configurable:!0}),cT=["Enter"," "],uT=["ArrowDown","PageUp","Home"],j0=["ArrowUp","PageDown","End"],dT=[...uT,...j0],Xc="Menu",[rh,fT,hT]=zc(Xc),[gr,C0]=fn(Xc,[hT,Es,Yc]),Xh=Es(),E0=Yc(),[mT,Uo]=gr(Xc),[pT,Fh]=gr(Xc),gT=it(a=>{const{__scopeMenu:l,open:o=!1,children:i,dir:u,onOpenChange:d,modal:h=!0}=a,p=Xh(l),[g,v]=m.useState(null),x=m.useRef(!1),y=$n(d),S=zo(u);return m.useEffect(()=>{const w=it(()=>{x.current=!0,document.addEventListener("pointerdown",C,{capture:!0,once:!0}),document.addEventListener("pointermove",C,{capture:!0,once:!0})},"handleKeyDown"),C=it(()=>x.current=!1,"handlePointer");return document.addEventListener("keydown",w,{capture:!0}),()=>{document.removeEventListener("keydown",w,{capture:!0}),document.removeEventListener("pointerdown",C,{capture:!0}),document.removeEventListener("pointermove",C,{capture:!0})}},[]),m.useEffect(()=>{if(!o)return;const w=it(()=>y(!1),"handleBlur");return window.addEventListener("blur",w),()=>window.removeEventListener("blur",w)},[o,y]),s.jsx(Wb,{...p,children:s.jsx(mT,{scope:l,open:o,onOpenChange:y,content:g,onContentChange:v,children:s.jsx(pT,{scope:l,onClose:m.useCallback(()=>y(!1),[y]),isUsingKeyboardRef:x,dir:S,modal:h,children:i})})})},"Menu"),vT=m.forwardRef(it(function(l,o){const{__scopeMenu:i,...u}=l,d=Xh(i);return s.jsx(e0,{...d,...u,ref:o})},"MenuAnchor")),R0="MenuPortal",[xT,yT]=gr(R0,{forceMount:void 0}),bT=it(a=>{const{__scopeMenu:l,forceMount:o,children:i,container:u}=a,d=Uo(R0,l);return s.jsx(xT,{scope:l,forceMount:o,children:s.jsx(al,{present:o||d.open,children:s.jsx(Gh,{asChild:!0,container:u,children:i})})})},"MenuPortal"),Ul="MenuContent",[ST,N0]=gr(Ul),wT=m.forwardRef(it(function(l,o){const i=yT(Ul,l.__scopeMenu),{forceMount:u=i.forceMount,...d}=l,h=Uo(Ul,l.__scopeMenu),p=Fh(Ul,l.__scopeMenu);return s.jsx(rh.Provider,{scope:l.__scopeMenu,children:s.jsx(al,{present:u||h.open,children:s.jsx(rh.Slot,{scope:l.__scopeMenu,children:p.modal?s.jsx(jT,{...d,ref:o}):s.jsx(CT,{...d,ref:o})})})})},"MenuContent")),jT=m.forwardRef(it(function(l,o){const i=Uo(Ul,l.__scopeMenu),u=m.useRef(null),d=Ie(o,u);return m.useEffect(()=>{const h=u.current;if(h)return Kh(h)},[]),s.jsx(T0,{...l,ref:d,trapFocus:i.open,disableOutsidePointerEvents:i.open,disableOutsideScroll:!0,onFocusOutside:Ee(l.onFocusOutside,h=>h.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>i.onOpenChange(!1)})},"MenuRootContentModal")),CT=m.forwardRef(it(function(l,o){const i=Uo(Ul,l.__scopeMenu);return s.jsx(T0,{...l,ref:o,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>i.onOpenChange(!1)})},"MenuRootContentNonModal")),ET=va("MenuContent.ScrollLock"),T0=m.forwardRef(it(function(l,o){const{__scopeMenu:i,loop:u=!1,trapFocus:d,onOpenAutoFocus:h,onCloseAutoFocus:p,disableOutsidePointerEvents:g,onEntryFocus:v,onEscapeKeyDown:x,onPointerDownOutside:y,onFocusOutside:S,onInteractOutside:w,onDismiss:C,disableOutsideScroll:E,...j}=l,N=Uo(Ul,i),M=Fh(Ul,i),T=Xh(i),_=E0(i),O=fT(i),[A,H]=m.useState(null),z=m.useRef(null),K=Ie(o,z,N.onContentChange),se=m.useRef(0),X=m.useRef(""),I=m.useRef(0),re=m.useRef(null),ee=m.useRef("right"),oe=m.useRef(0),U=E?Kc:m.Fragment,$=E?{as:ET,allowPinchZoom:!0}:void 0,le=it(Z=>{var fe,xe;const D=X.current+Z,q=O().filter(J=>!J.disabled),Q=document.activeElement,ae=(fe=q.find(J=>J.ref.current===Q))==null?void 0:fe.textValue,ce=q.map(J=>J.textValue),Se=O0(ce,D,ae),ue=(xe=q.find(J=>J.textValue===Se))==null?void 0:xe.ref.current;it((function J(me){X.current=me,window.clearTimeout(se.current),me!==""&&(se.current=window.setTimeout(()=>J(""),1e3))}),"updateSearch")(D),ue&&setTimeout(()=>ue.focus())},"handleTypeaheadSearch");m.useEffect(()=>()=>window.clearTimeout(se.current),[]),Lo();const B=m.useCallback(Z=>{var q,Q;return ee.current===((q=re.current)==null?void 0:q.side)&&z0(Z,(Q=re.current)==null?void 0:Q.area)},[]);return s.jsx(ST,{scope:i,searchRef:X,onItemEnter:m.useCallback(Z=>{B(Z)&&Z.preventDefault()},[B]),onItemLeave:m.useCallback(Z=>{var D;B(Z)||((D=z.current)==null||D.focus(),H(null))},[B]),onTriggerLeave:m.useCallback(Z=>{B(Z)&&Z.preventDefault()},[B]),pointerGraceTimerRef:I,onPointerGraceIntentChange:m.useCallback(Z=>{re.current=Z},[]),children:s.jsx(U,{...$,children:s.jsx(zh,{asChild:!0,trapped:d,onMountAutoFocus:Ee(h,Z=>{var D;Z.preventDefault(),(D=z.current)==null||D.focus({preventScroll:!0})}),onUnmountAutoFocus:p,children:s.jsx(Lc,{asChild:!0,disableOutsidePointerEvents:g,onEscapeKeyDown:x,onPointerDownOutside:y,onFocusOutside:S,onInteractOutside:w,onDismiss:C,children:s.jsx(h0,{asChild:!0,..._,dir:M.dir,orientation:"vertical",loop:u,currentTabStopId:A,onCurrentTabStopIdChange:H,onEntryFocus:Ee(v,Z=>{M.isUsingKeyboardRef.current||Z.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(Vh,{role:"menu","aria-orientation":"vertical","data-state":A0(N.open),"data-radix-menu-content":"",dir:M.dir,...T,...j,ref:K,style:{outline:"none",...j.style},onKeyDown:Ee(j.onKeyDown,Z=>{const q=Z.target.closest("[data-radix-menu-content]")===Z.currentTarget,Q=Z.ctrlKey||Z.altKey||Z.metaKey,ae=Z.key.length===1;q&&(Z.key==="Tab"&&Z.preventDefault(),!Q&&ae&&le(Z.key));const ce=z.current;if(Z.target!==ce||!dT.includes(Z.key))return;Z.preventDefault();const ue=O().filter(fe=>!fe.disabled).map(fe=>fe.ref.current);j0.includes(Z.key)&&ue.reverse(),D0(ue)}),onBlur:Ee(l.onBlur,Z=>{Z.currentTarget.contains(Z.target)||(window.clearTimeout(se.current),X.current="")}),onPointerMove:Ee(l.onPointerMove,Rc(Z=>{const D=Z.target,q=oe.current!==Z.clientX;if(Z.currentTarget.contains(D)&&q){const Q=Z.clientX>oe.current?"right":"left";ee.current=Q,oe.current=Z.clientX}}))})})})})})})},"MenuContentImpl")),RT=m.forwardRef(it(function(l,o){const{__scopeMenu:i,...u}=l;return s.jsx(Be.div,{...u,ref:o})},"MenuLabel")),sh="MenuItem",uy="menu.itemSelect",NT=m.forwardRef(it(function(l,o){const{disabled:i=!1,onSelect:u,...d}=l,h=m.useRef(null),p=Fh(sh,l.__scopeMenu),g=N0(sh,l.__scopeMenu),v=Ie(o,h),x=m.useRef(!1),y=it(()=>{const S=h.current;if(!i&&S){const w=new CustomEvent(uy,{bubbles:!0,cancelable:!0});S.addEventListener(uy,C=>u==null?void 0:u(C),{once:!0}),Dh(S,w),w.defaultPrevented?x.current=!1:p.onClose()}},"handleSelect");return s.jsx(TT,{...d,ref:v,disabled:i,onClick:Ee(l.onClick,y),onPointerDown:S=>{var w;(w=l.onPointerDown)==null||w.call(l,S),x.current=!0},onPointerUp:Ee(l.onPointerUp,S=>{var w;x.current||(w=S.currentTarget)==null||w.click()}),onKeyDown:Ee(l.onKeyDown,S=>{i||S.target!==S.currentTarget||g.searchRef.current!==""&&S.key===" "||cT.includes(S.key)&&(S.currentTarget.click(),S.preventDefault())})})},"MenuItem")),TT=m.forwardRef(it(function(l,o){const{__scopeMenu:i,disabled:u=!1,textValue:d,...h}=l,p=N0(sh,i),g=E0(i),v=m.useRef(null),x=Ie(o,v),[y,S]=m.useState(!1),[w,C]=m.useState("");return m.useEffect(()=>{const E=v.current;E&&C((E.textContent??"").trim())},[h.children]),s.jsx(rh.ItemSlot,{scope:i,disabled:u,textValue:d??w,children:s.jsx(m0,{asChild:!0,...g,focusable:!u,children:s.jsx(Be.div,{role:"menuitem","data-highlighted":y?"":void 0,"aria-disabled":u||void 0,"data-disabled":u?"":void 0,...h,ref:x,onPointerMove:Ee(l.onPointerMove,Rc(E=>{u?p.onItemLeave(E):(p.onItemEnter(E),E.defaultPrevented||E.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ee(l.onPointerLeave,Rc(E=>p.onItemLeave(E))),onFocus:Ee(l.onFocus,()=>S(!0)),onBlur:Ee(l.onBlur,()=>S(!1))})})})},"MenuItemImpl")),AT="MenuRadioGroup",[B_,H_]=gr(AT,{value:void 0,onValueChange:it(()=>{},"onValueChange")}),MT="MenuItemIndicator",[P_,q_]=gr(MT,{checked:!1}),DT=m.forwardRef(it(function(l,o){const{__scopeMenu:i,...u}=l;return s.jsx(Be.div,{role:"separator","aria-orientation":"horizontal",...u,ref:o})},"MenuSeparator")),_T="MenuSub",[I_,V_]=gr(_T);function A0(a){return a?"open":"closed"}it(A0,"getOpenState");function M0(a){return a==="indeterminate"}it(M0,"isIndeterminate");function OT(a){return M0(a)?"indeterminate":a?"checked":"unchecked"}it(OT,"getCheckedState");function D0(a){const l=document.activeElement;for(const o of a)if(o===l||(o.focus(),document.activeElement!==l))return}it(D0,"focusFirst");function _0(a,l){return a.map((o,i)=>a[(l+i)%a.length])}it(_0,"wrapArray");function O0(a,l,o){const u=l.length>1&&Array.from(l).every(v=>v===l[0])?l[0]:l,d=o?a.indexOf(o):-1;let h=_0(a,Math.max(d,0));u.length===1&&(h=h.filter(v=>v!==o));const g=h.find(v=>v.toLowerCase().startsWith(u.toLowerCase()));return g!==o?g:void 0}it(O0,"getNextMatch");function k0(a,l){const{x:o,y:i}=a;let u=!1;for(let d=0,h=l.length-1;d<l.length;h=d++){const p=l[d],g=l[h],v=p.x,x=p.y,y=g.x,S=g.y;x>i!=S>i&&o<(y-v)*(i-x)/(S-x)+v&&(u=!u)}return u}it(k0,"isPointInPolygon");function z0(a,l){if(!l)return!1;const o={x:a.clientX,y:a.clientY};return k0(o,l)}it(z0,"isPointerInGraceArea");function Rc(a){return l=>l.pointerType==="mouse"?a(l):void 0}it(Rc,"whenMouse");var kT=gT,zT=vT,LT=bT,UT=wT,BT=RT,HT=NT,PT=DT,qT=Object.defineProperty,vr=(a,l)=>qT(a,"name",{value:l,configurable:!0}),Qh="DropdownMenu",[IT,G_]=fn(Qh,[C0]),xr=C0(),[VT,L0]=IT(Qh),GT=vr(a=>{const{__scopeDropdownMenu:l,children:o,dir:i,open:u,defaultOpen:d,onOpenChange:h,modal:p=!0}=a,g=xr(l),v=m.useRef(null),[x,y]=Ja({prop:u,defaultProp:d??!1,onChange:h,caller:Qh});return s.jsx(VT,{scope:l,triggerId:ga(),triggerRef:v,contentId:ga(),open:x,onOpenChange:y,onOpenToggle:m.useCallback(()=>y(S=>!S),[y]),modal:p,children:s.jsx(kT,{...g,open:x,onOpenChange:y,dir:i,modal:p,children:o})})},"DropdownMenu"),YT="DropdownMenuTrigger",$T=m.forwardRef(vr(function(l,o){const{__scopeDropdownMenu:i,disabled:u=!1,...d}=l,h=L0(YT,i),p=xr(i),g=Ie(o,h.triggerRef);return s.jsx(zT,{asChild:!0,...p,children:s.jsx(Be.button,{type:"button",id:h.triggerId,"aria-haspopup":"menu","aria-expanded":h.open,"aria-controls":h.open?h.contentId:void 0,"data-state":h.open?"open":"closed","data-disabled":u?"":void 0,disabled:u,...d,ref:g,onPointerDown:Ee(l.onPointerDown,v=>{!u&&v.button===0&&v.ctrlKey===!1&&(h.onOpenToggle(),h.open||v.preventDefault())}),onKeyDown:Ee(l.onKeyDown,v=>{u||(["Enter"," "].includes(v.key)&&h.onOpenToggle(),v.key==="ArrowDown"&&h.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(v.key)&&v.preventDefault())})})})},"DropdownMenuTrigger")),KT=vr(a=>{const{__scopeDropdownMenu:l,...o}=a,i=xr(l);return s.jsx(LT,{...i,...o})},"DropdownMenuPortal"),XT="DropdownMenuContent",FT=m.forwardRef(vr(function(l,o){const{__scopeDropdownMenu:i,...u}=l,d=L0(XT,i),h=xr(i),p=m.useRef(!1);return s.jsx(UT,{id:d.contentId,"aria-labelledby":d.triggerId,...h,...u,ref:o,onCloseAutoFocus:Ee(l.onCloseAutoFocus,g=>{var v;p.current||(v=d.triggerRef.current)==null||v.focus(),p.current=!1,g.preventDefault()}),onInteractOutside:Ee(l.onInteractOutside,g=>{const v=g.detail.originalEvent,x=v.button===0&&v.ctrlKey===!0,y=v.button===2||x;(!d.modal||y)&&(p.current=!0)}),style:{...l.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),QT=m.forwardRef(vr(function(l,o){const{__scopeDropdownMenu:i,...u}=l,d=xr(i);return s.jsx(BT,{...d,...u,ref:o})},"DropdownMenuLabel")),ZT=m.forwardRef(vr(function(l,o){const{__scopeDropdownMenu:i,...u}=l,d=xr(i);return s.jsx(HT,{...d,...u,ref:o})},"DropdownMenuItem")),JT=m.forwardRef(vr(function(l,o){const{__scopeDropdownMenu:i,...u}=l,d=xr(i);return s.jsx(PT,{...d,...u,ref:o})},"DropdownMenuSeparator")),WT=GT,eA=$T,tA=KT,U0=FT,B0=QT,H0=ZT,P0=JT;const nA=WT,aA=eA,q0=m.forwardRef(({className:a,sideOffset:l=4,...o},i)=>s.jsx(tA,{children:s.jsx(U0,{ref:i,sideOffset:l,className:Re("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",a),...o})}));q0.displayName=U0.displayName;const I0=m.forwardRef(({className:a,inset:l,...o},i)=>s.jsx(H0,{ref:i,className:Re("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",l&&"pl-8",a),...o}));I0.displayName=H0.displayName;const lA=m.forwardRef(({className:a,...l},o)=>s.jsx(B0,{ref:o,className:Re("px-2 py-1.5 text-sm font-semibold",a),...l}));lA.displayName=B0.displayName;const rA=m.forwardRef(({className:a,...l},o)=>s.jsx(P0,{ref:o,className:Re("-mx-1 my-1 h-px bg-muted",a),...l}));rA.displayName=P0.displayName;function sA(){const{theme:a,setTheme:l}=pE(),{user:o,logout:i}=Nh(),[u,d]=m.useState(!1),[h,p]=m.useState(null),g=Do(),v=a==="light"?bC:a==="dark"?hC:fC;return m.useEffect(()=>{we.get("/api/admin/update/check").then(x=>p(x)).catch(()=>{})},[]),s.jsxs("header",{className:"flex h-14 items-center justify-between border-b bg-background px-4",children:[s.jsx("div",{className:"text-sm text-muted-foreground",children:"Admin"}),s.jsxs("div",{className:"flex items-center gap-2",children:[(h==null?void 0:h.hasUpdate)&&s.jsxs(he,{variant:"ghost",size:"sm",title:`New version available: v${h.latestVersion} — go to Settings → System to update`,onClick:()=>g("/settings?tab=system"),children:[s.jsx(tC,{className:"mr-1 h-4 w-4 text-blue-500"}),"Update v",h.latestVersion]}),s.jsx(he,{variant:"ghost",size:"icon",onClick:()=>l(a==="dark"?"light":"dark"),children:s.jsx(v,{className:"h-4 w-4"})}),s.jsxs(nA,{open:u,onOpenChange:d,children:[s.jsx(aA,{asChild:!0,children:s.jsx(he,{variant:"ghost",children:(o==null?void 0:o.username)??"admin"})}),s.jsx(q0,{align:"end",children:s.jsxs(I0,{onClick:()=>void i(),children:[s.jsx(dC,{className:"mr-2 h-4 w-4"})," Sign out"]})})]})]})]})}const Ae=m.forwardRef(({className:a,type:l,...o},i)=>s.jsx("input",{type:l,className:Re("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",a),ref:i,...o}));Ae.displayName="Input";var oA=Object.defineProperty,iA=(a,l)=>oA(a,"name",{value:l,configurable:!0}),cA=m.forwardRef(iA(function(l,o){return s.jsx(Be.label,{...l,ref:o,onMouseDown:i=>{var d;i.target.closest("button, input, select, textarea")||((d=l.onMouseDown)==null||d.call(l,i),!i.defaultPrevented&&i.detail>1&&i.preventDefault())}})},"Label")),V0=cA;const be=m.forwardRef(({className:a,...l},o)=>s.jsx(V0,{ref:o,className:Re("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",a),...l}));be.displayName=V0.displayName;const Xe=m.forwardRef(({className:a,...l},o)=>s.jsx("div",{ref:o,className:Re("rounded-lg border bg-card text-card-foreground shadow-sm",a),...l}));Xe.displayName="Card";const Fe=m.forwardRef(({className:a,...l},o)=>s.jsx("div",{ref:o,className:Re("flex flex-col space-y-1.5 p-6",a),...l}));Fe.displayName="CardHeader";const Qe=m.forwardRef(({className:a,...l},o)=>s.jsx("h3",{ref:o,className:Re("text-lg font-semibold leading-none tracking-tight",a),...l}));Qe.displayName="CardTitle";const on=m.forwardRef(({className:a,...l},o)=>s.jsx("p",{ref:o,className:Re("text-sm text-muted-foreground",a),...l}));on.displayName="CardDescription";const Ze=m.forwardRef(({className:a,...l},o)=>s.jsx("div",{ref:o,className:Re("p-6 pt-0",a),...l}));Ze.displayName="CardContent";const G0=m.forwardRef(({className:a,...l},o)=>s.jsx("div",{ref:o,className:Re("flex items-center p-6 pt-0",a),...l}));G0.displayName="CardFooter";var uA=a=>{switch(a){case"success":return hA;case"info":return pA;case"warning":return mA;case"error":return gA;default:return null}},dA=Array(12).fill(0),fA=({visible:a,className:l})=>ie.createElement("div",{className:["sonner-loading-wrapper",l].filter(Boolean).join(" "),"data-visible":a},ie.createElement("div",{className:"sonner-spinner"},dA.map((o,i)=>ie.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${i}`})))),hA=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ie.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),mA=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ie.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),pA=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ie.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),gA=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ie.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),vA=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ie.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ie.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),xA=()=>{let[a,l]=ie.useState(document.hidden);return ie.useEffect(()=>{let o=()=>{l(document.hidden)};return document.addEventListener("visibilitychange",o),()=>window.removeEventListener("visibilitychange",o)},[]),a},oh=1,yA=class{constructor(){this.subscribe=a=>(this.subscribers.push(a),()=>{let l=this.subscribers.indexOf(a);this.subscribers.splice(l,1)}),this.publish=a=>{this.subscribers.forEach(l=>l(a))},this.addToast=a=>{this.publish(a),this.toasts=[...this.toasts,a]},this.create=a=>{var l;let{message:o,...i}=a,u=typeof(a==null?void 0:a.id)=="number"||((l=a.id)==null?void 0:l.length)>0?a.id:oh++,d=this.toasts.find(p=>p.id===u),h=a.dismissible===void 0?!0:a.dismissible;return this.dismissedToasts.has(u)&&this.dismissedToasts.delete(u),d?this.toasts=this.toasts.map(p=>p.id===u?(this.publish({...p,...a,id:u,title:o}),{...p,...a,id:u,dismissible:h,title:o}):p):this.addToast({title:o,...i,dismissible:h,id:u}),u},this.dismiss=a=>(this.dismissedToasts.add(a),a||this.toasts.forEach(l=>{this.subscribers.forEach(o=>o({id:l.id,dismiss:!0}))}),this.subscribers.forEach(l=>l({id:a,dismiss:!0})),a),this.message=(a,l)=>this.create({...l,message:a}),this.error=(a,l)=>this.create({...l,message:a,type:"error"}),this.success=(a,l)=>this.create({...l,type:"success",message:a}),this.info=(a,l)=>this.create({...l,type:"info",message:a}),this.warning=(a,l)=>this.create({...l,type:"warning",message:a}),this.loading=(a,l)=>this.create({...l,type:"loading",message:a}),this.promise=(a,l)=>{if(!l)return;let o;l.loading!==void 0&&(o=this.create({...l,promise:a,type:"loading",message:l.loading,description:typeof l.description!="function"?l.description:void 0}));let i=a instanceof Promise?a:a(),u=o!==void 0,d,h=i.then(async g=>{if(d=["resolve",g],ie.isValidElement(g))u=!1,this.create({id:o,type:"default",message:g});else if(SA(g)&&!g.ok){u=!1;let v=typeof l.error=="function"?await l.error(`HTTP error! status: ${g.status}`):l.error,x=typeof l.description=="function"?await l.description(`HTTP error! status: ${g.status}`):l.description;this.create({id:o,type:"error",message:v,description:x})}else if(l.success!==void 0){u=!1;let v=typeof l.success=="function"?await l.success(g):l.success,x=typeof l.description=="function"?await l.description(g):l.description;this.create({id:o,type:"success",message:v,description:x})}}).catch(async g=>{if(d=["reject",g],l.error!==void 0){u=!1;let v=typeof l.error=="function"?await l.error(g):l.error,x=typeof l.description=="function"?await l.description(g):l.description;this.create({id:o,type:"error",message:v,description:x})}}).finally(()=>{var g;u&&(this.dismiss(o),o=void 0),(g=l.finally)==null||g.call(l)}),p=()=>new Promise((g,v)=>h.then(()=>d[0]==="reject"?v(d[1]):g(d[1])).catch(v));return typeof o!="string"&&typeof o!="number"?{unwrap:p}:Object.assign(o,{unwrap:p})},this.custom=(a,l)=>{let o=(l==null?void 0:l.id)||oh++;return this.create({jsx:a(o),id:o,...l}),o},this.getActiveToasts=()=>this.toasts.filter(a=>!this.dismissedToasts.has(a.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},sn=new yA,bA=(a,l)=>{let o=(l==null?void 0:l.id)||oh++;return sn.addToast({title:a,...l,id:o}),o},SA=a=>a&&typeof a=="object"&&"ok"in a&&typeof a.ok=="boolean"&&"status"in a&&typeof a.status=="number",wA=bA,jA=()=>sn.toasts,CA=()=>sn.getActiveToasts(),ve=Object.assign(wA,{success:sn.success,info:sn.info,warning:sn.warning,error:sn.error,custom:sn.custom,message:sn.message,promise:sn.promise,dismiss:sn.dismiss,loading:sn.loading},{getHistory:jA,getToasts:CA});function EA(a,{insertAt:l}={}){if(typeof document>"u")return;let o=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",l==="top"&&o.firstChild?o.insertBefore(i,o.firstChild):o.appendChild(i),i.styleSheet?i.styleSheet.cssText=a:i.appendChild(document.createTextNode(a))}EA(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
326
+ `);function ic(a){return a.label!==void 0}var RA=3,NA="32px",TA="16px",dy=4e3,AA=356,MA=14,DA=20,_A=200;function na(...a){return a.filter(Boolean).join(" ")}function OA(a){let[l,o]=a.split("-"),i=[];return l&&i.push(l),o&&i.push(o),i}var kA=a=>{var l,o,i,u,d,h,p,g,v,x,y;let{invert:S,toast:w,unstyled:C,interacting:E,setHeights:j,visibleToasts:N,heights:M,index:T,toasts:_,expanded:O,removeToast:A,defaultRichColors:H,closeButton:z,style:K,cancelButtonStyle:se,actionButtonStyle:X,className:I="",descriptionClassName:re="",duration:ee,position:oe,gap:U,loadingIcon:$,expandByDefault:le,classNames:B,icons:Z,closeButtonAriaLabel:D="Close toast",pauseWhenPageIsHidden:q}=a,[Q,ae]=ie.useState(null),[ce,Se]=ie.useState(null),[ue,fe]=ie.useState(!1),[xe,J]=ie.useState(!1),[me,je]=ie.useState(!1),[Me,mt]=ie.useState(!1),[pt,bt]=ie.useState(!1),[St,Lt]=ie.useState(0),[hn,Qn]=ie.useState(0),mn=ie.useRef(w.duration||ee||dy),ja=ie.useRef(null),Ca=ie.useRef(null),$t=T===0,Jc=T+1<=N,Kt=w.type,Ea=w.dismissible!==!1,br=w.className||"",Wc=w.descriptionClassName||"",Vl=ie.useMemo(()=>M.findIndex(Te=>Te.toastId===w.id)||0,[M,w.id]),eu=ie.useMemo(()=>{var Te;return(Te=w.closeButton)!=null?Te:z},[w.closeButton,z]),Po=ie.useMemo(()=>w.duration||ee||dy,[w.duration,ee]),Ra=ie.useRef(0),wt=ie.useRef(0),Zn=ie.useRef(0),jt=ie.useRef(null),[tu,nu]=oe.split("-"),qo=ie.useMemo(()=>M.reduce((Te,Ke,st)=>st>=Vl?Te:Te+Ke.height,0),[M,Vl]),Gl=xA(),Sr=w.invert||S,sl=Kt==="loading";wt.current=ie.useMemo(()=>Vl*U+qo,[Vl,qo]),ie.useEffect(()=>{mn.current=Po},[Po]),ie.useEffect(()=>{fe(!0)},[]),ie.useEffect(()=>{let Te=Ca.current;if(Te){let Ke=Te.getBoundingClientRect().height;return Qn(Ke),j(st=>[{toastId:w.id,height:Ke,position:w.position},...st]),()=>j(st=>st.filter(Xt=>Xt.toastId!==w.id))}},[j,w.id]),ie.useLayoutEffect(()=>{if(!ue)return;let Te=Ca.current,Ke=Te.style.height;Te.style.height="auto";let st=Te.getBoundingClientRect().height;Te.style.height=Ke,Qn(st),j(Xt=>Xt.find(Ut=>Ut.toastId===w.id)?Xt.map(Ut=>Ut.toastId===w.id?{...Ut,height:st}:Ut):[{toastId:w.id,height:st,position:w.position},...Xt])},[ue,w.title,w.description,j,w.id]);let Vt=ie.useCallback(()=>{J(!0),Lt(wt.current),j(Te=>Te.filter(Ke=>Ke.toastId!==w.id)),setTimeout(()=>{A(w)},_A)},[w,A,j,wt]);ie.useEffect(()=>{if(w.promise&&Kt==="loading"||w.duration===1/0||w.type==="loading")return;let Te;return O||E||q&&Gl?(()=>{if(Zn.current<Ra.current){let Ke=new Date().getTime()-Ra.current;mn.current=mn.current-Ke}Zn.current=new Date().getTime()})():mn.current!==1/0&&(Ra.current=new Date().getTime(),Te=setTimeout(()=>{var Ke;(Ke=w.onAutoClose)==null||Ke.call(w,w),Vt()},mn.current)),()=>clearTimeout(Te)},[O,E,w,Kt,q,Gl,Vt]),ie.useEffect(()=>{w.delete&&Vt()},[Vt,w.delete]);function wr(){var Te,Ke,st;return Z!=null&&Z.loading?ie.createElement("div",{className:na(B==null?void 0:B.loader,(Te=w==null?void 0:w.classNames)==null?void 0:Te.loader,"sonner-loader"),"data-visible":Kt==="loading"},Z.loading):$?ie.createElement("div",{className:na(B==null?void 0:B.loader,(Ke=w==null?void 0:w.classNames)==null?void 0:Ke.loader,"sonner-loader"),"data-visible":Kt==="loading"},$):ie.createElement(fA,{className:na(B==null?void 0:B.loader,(st=w==null?void 0:w.classNames)==null?void 0:st.loader),visible:Kt==="loading"})}return ie.createElement("li",{tabIndex:0,ref:Ca,className:na(I,br,B==null?void 0:B.toast,(l=w==null?void 0:w.classNames)==null?void 0:l.toast,B==null?void 0:B.default,B==null?void 0:B[Kt],(o=w==null?void 0:w.classNames)==null?void 0:o[Kt]),"data-sonner-toast":"","data-rich-colors":(i=w.richColors)!=null?i:H,"data-styled":!(w.jsx||w.unstyled||C),"data-mounted":ue,"data-promise":!!w.promise,"data-swiped":pt,"data-removed":xe,"data-visible":Jc,"data-y-position":tu,"data-x-position":nu,"data-index":T,"data-front":$t,"data-swiping":me,"data-dismissible":Ea,"data-type":Kt,"data-invert":Sr,"data-swipe-out":Me,"data-swipe-direction":ce,"data-expanded":!!(O||le&&ue),style:{"--index":T,"--toasts-before":T,"--z-index":_.length-T,"--offset":`${xe?St:wt.current}px`,"--initial-height":le?"auto":`${hn}px`,...K,...w.style},onDragEnd:()=>{je(!1),ae(null),jt.current=null},onPointerDown:Te=>{sl||!Ea||(ja.current=new Date,Lt(wt.current),Te.target.setPointerCapture(Te.pointerId),Te.target.tagName!=="BUTTON"&&(je(!0),jt.current={x:Te.clientX,y:Te.clientY}))},onPointerUp:()=>{var Te,Ke,st,Xt;if(Me||!Ea)return;jt.current=null;let Ut=Number(((Te=Ca.current)==null?void 0:Te.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),oa=Number(((Ke=Ca.current)==null?void 0:Ke.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ia=new Date().getTime()-((st=ja.current)==null?void 0:st.getTime()),Zt=Q==="x"?Ut:oa,Jn=Math.abs(Zt)/ia;if(Math.abs(Zt)>=DA||Jn>.11){Lt(wt.current),(Xt=w.onDismiss)==null||Xt.call(w,w),Se(Q==="x"?Ut>0?"right":"left":oa>0?"down":"up"),Vt(),mt(!0),bt(!1);return}je(!1),ae(null)},onPointerMove:Te=>{var Ke,st,Xt,Ut;if(!jt.current||!Ea||((Ke=window.getSelection())==null?void 0:Ke.toString().length)>0)return;let oa=Te.clientY-jt.current.y,ia=Te.clientX-jt.current.x,Zt=(st=a.swipeDirections)!=null?st:OA(oe);!Q&&(Math.abs(ia)>1||Math.abs(oa)>1)&&ae(Math.abs(ia)>Math.abs(oa)?"x":"y");let Jn={x:0,y:0};Q==="y"?(Zt.includes("top")||Zt.includes("bottom"))&&(Zt.includes("top")&&oa<0||Zt.includes("bottom")&&oa>0)&&(Jn.y=oa):Q==="x"&&(Zt.includes("left")||Zt.includes("right"))&&(Zt.includes("left")&&ia<0||Zt.includes("right")&&ia>0)&&(Jn.x=ia),(Math.abs(Jn.x)>0||Math.abs(Jn.y)>0)&&bt(!0),(Xt=Ca.current)==null||Xt.style.setProperty("--swipe-amount-x",`${Jn.x}px`),(Ut=Ca.current)==null||Ut.style.setProperty("--swipe-amount-y",`${Jn.y}px`)}},eu&&!w.jsx?ie.createElement("button",{"aria-label":D,"data-disabled":sl,"data-close-button":!0,onClick:sl||!Ea?()=>{}:()=>{var Te;Vt(),(Te=w.onDismiss)==null||Te.call(w,w)},className:na(B==null?void 0:B.closeButton,(u=w==null?void 0:w.classNames)==null?void 0:u.closeButton)},(d=Z==null?void 0:Z.close)!=null?d:vA):null,w.jsx||m.isValidElement(w.title)?w.jsx?w.jsx:typeof w.title=="function"?w.title():w.title:ie.createElement(ie.Fragment,null,Kt||w.icon||w.promise?ie.createElement("div",{"data-icon":"",className:na(B==null?void 0:B.icon,(h=w==null?void 0:w.classNames)==null?void 0:h.icon)},w.promise||w.type==="loading"&&!w.icon?w.icon||wr():null,w.type!=="loading"?w.icon||(Z==null?void 0:Z[Kt])||uA(Kt):null):null,ie.createElement("div",{"data-content":"",className:na(B==null?void 0:B.content,(p=w==null?void 0:w.classNames)==null?void 0:p.content)},ie.createElement("div",{"data-title":"",className:na(B==null?void 0:B.title,(g=w==null?void 0:w.classNames)==null?void 0:g.title)},typeof w.title=="function"?w.title():w.title),w.description?ie.createElement("div",{"data-description":"",className:na(re,Wc,B==null?void 0:B.description,(v=w==null?void 0:w.classNames)==null?void 0:v.description)},typeof w.description=="function"?w.description():w.description):null),m.isValidElement(w.cancel)?w.cancel:w.cancel&&ic(w.cancel)?ie.createElement("button",{"data-button":!0,"data-cancel":!0,style:w.cancelButtonStyle||se,onClick:Te=>{var Ke,st;ic(w.cancel)&&Ea&&((st=(Ke=w.cancel).onClick)==null||st.call(Ke,Te),Vt())},className:na(B==null?void 0:B.cancelButton,(x=w==null?void 0:w.classNames)==null?void 0:x.cancelButton)},w.cancel.label):null,m.isValidElement(w.action)?w.action:w.action&&ic(w.action)?ie.createElement("button",{"data-button":!0,"data-action":!0,style:w.actionButtonStyle||X,onClick:Te=>{var Ke,st;ic(w.action)&&((st=(Ke=w.action).onClick)==null||st.call(Ke,Te),!Te.defaultPrevented&&Vt())},className:na(B==null?void 0:B.actionButton,(y=w==null?void 0:w.classNames)==null?void 0:y.actionButton)},w.action.label):null))};function fy(){if(typeof window>"u"||typeof document>"u")return"ltr";let a=document.documentElement.getAttribute("dir");return a==="auto"||!a?window.getComputedStyle(document.documentElement).direction:a}function zA(a,l){let o={};return[a,l].forEach((i,u)=>{let d=u===1,h=d?"--mobile-offset":"--offset",p=d?TA:NA;function g(v){["top","right","bottom","left"].forEach(x=>{o[`${h}-${x}`]=typeof v=="number"?`${v}px`:v})}typeof i=="number"||typeof i=="string"?g(i):typeof i=="object"?["top","right","bottom","left"].forEach(v=>{i[v]===void 0?o[`${h}-${v}`]=p:o[`${h}-${v}`]=typeof i[v]=="number"?`${i[v]}px`:i[v]}):g(p)}),o}var LA=m.forwardRef(function(a,l){let{invert:o,position:i="bottom-right",hotkey:u=["altKey","KeyT"],expand:d,closeButton:h,className:p,offset:g,mobileOffset:v,theme:x="light",richColors:y,duration:S,style:w,visibleToasts:C=RA,toastOptions:E,dir:j=fy(),gap:N=MA,loadingIcon:M,icons:T,containerAriaLabel:_="Notifications",pauseWhenPageIsHidden:O}=a,[A,H]=ie.useState([]),z=ie.useMemo(()=>Array.from(new Set([i].concat(A.filter(q=>q.position).map(q=>q.position)))),[A,i]),[K,se]=ie.useState([]),[X,I]=ie.useState(!1),[re,ee]=ie.useState(!1),[oe,U]=ie.useState(x!=="system"?x:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),$=ie.useRef(null),le=u.join("+").replace(/Key/g,"").replace(/Digit/g,""),B=ie.useRef(null),Z=ie.useRef(!1),D=ie.useCallback(q=>{H(Q=>{var ae;return(ae=Q.find(ce=>ce.id===q.id))!=null&&ae.delete||sn.dismiss(q.id),Q.filter(({id:ce})=>ce!==q.id)})},[]);return ie.useEffect(()=>sn.subscribe(q=>{if(q.dismiss){H(Q=>Q.map(ae=>ae.id===q.id?{...ae,delete:!0}:ae));return}setTimeout(()=>{G2.flushSync(()=>{H(Q=>{let ae=Q.findIndex(ce=>ce.id===q.id);return ae!==-1?[...Q.slice(0,ae),{...Q[ae],...q},...Q.slice(ae+1)]:[q,...Q]})})})}),[]),ie.useEffect(()=>{if(x!=="system"){U(x);return}if(x==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?U("dark"):U("light")),typeof window>"u")return;let q=window.matchMedia("(prefers-color-scheme: dark)");try{q.addEventListener("change",({matches:Q})=>{U(Q?"dark":"light")})}catch{q.addListener(({matches:ae})=>{try{U(ae?"dark":"light")}catch(ce){console.error(ce)}})}},[x]),ie.useEffect(()=>{A.length<=1&&I(!1)},[A]),ie.useEffect(()=>{let q=Q=>{var ae,ce;u.every(Se=>Q[Se]||Q.code===Se)&&(I(!0),(ae=$.current)==null||ae.focus()),Q.code==="Escape"&&(document.activeElement===$.current||(ce=$.current)!=null&&ce.contains(document.activeElement))&&I(!1)};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},[u]),ie.useEffect(()=>{if($.current)return()=>{B.current&&(B.current.focus({preventScroll:!0}),B.current=null,Z.current=!1)}},[$.current]),ie.createElement("section",{ref:l,"aria-label":`${_} ${le}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},z.map((q,Q)=>{var ae;let[ce,Se]=q.split("-");return A.length?ie.createElement("ol",{key:q,dir:j==="auto"?fy():j,tabIndex:-1,ref:$,className:p,"data-sonner-toaster":!0,"data-theme":oe,"data-y-position":ce,"data-lifted":X&&A.length>1&&!d,"data-x-position":Se,style:{"--front-toast-height":`${((ae=K[0])==null?void 0:ae.height)||0}px`,"--width":`${AA}px`,"--gap":`${N}px`,...w,...zA(g,v)},onBlur:ue=>{Z.current&&!ue.currentTarget.contains(ue.relatedTarget)&&(Z.current=!1,B.current&&(B.current.focus({preventScroll:!0}),B.current=null))},onFocus:ue=>{ue.target instanceof HTMLElement&&ue.target.dataset.dismissible==="false"||Z.current||(Z.current=!0,B.current=ue.relatedTarget)},onMouseEnter:()=>I(!0),onMouseMove:()=>I(!0),onMouseLeave:()=>{re||I(!1)},onDragEnd:()=>I(!1),onPointerDown:ue=>{ue.target instanceof HTMLElement&&ue.target.dataset.dismissible==="false"||ee(!0)},onPointerUp:()=>ee(!1)},A.filter(ue=>!ue.position&&Q===0||ue.position===q).map((ue,fe)=>{var xe,J;return ie.createElement(kA,{key:ue.id,icons:T,index:fe,toast:ue,defaultRichColors:y,duration:(xe=E==null?void 0:E.duration)!=null?xe:S,className:E==null?void 0:E.className,descriptionClassName:E==null?void 0:E.descriptionClassName,invert:o,visibleToasts:C,closeButton:(J=E==null?void 0:E.closeButton)!=null?J:h,interacting:re,position:q,style:E==null?void 0:E.style,unstyled:E==null?void 0:E.unstyled,classNames:E==null?void 0:E.classNames,cancelButtonStyle:E==null?void 0:E.cancelButtonStyle,actionButtonStyle:E==null?void 0:E.actionButtonStyle,removeToast:D,toasts:A.filter(me=>me.position==ue.position),heights:K.filter(me=>me.position==ue.position),setHeights:se,expandByDefault:d,gap:N,loadingIcon:M,expanded:X,pauseWhenPageIsHidden:O,swipeDirections:a.swipeDirections})})):null}))});function UA(){const{login:a}=Nh(),[l,o]=m.useState("admin"),[i,u]=m.useState(""),[d,h]=m.useState(""),[p,g]=m.useState(""),[v,x]=m.useState(!1),[y,S]=m.useState(!1),w=Do(),C=dn();return s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:s.jsxs(Xe,{className:"w-full max-w-sm",children:[s.jsxs(Fe,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:"/logo.png",alt:"LateDev Router",className:"h-8 w-8 object-contain"}),s.jsx(Qe,{children:"Sign in"})]}),s.jsx(on,{children:"Enter your admin credentials."})]}),s.jsxs(Ze,{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Username"}),s.jsx(Ae,{value:l,onChange:E=>o(E.target.value),autoFocus:!0})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Password"}),s.jsx(Ae,{type:"password",value:i,onChange:E=>u(E.target.value)})]}),v&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"2FA code (or recovery code)"}),s.jsx(Ae,{value:d,onChange:E=>h(E.target.value),placeholder:"123456",maxLength:6})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Recovery code (alternative)"}),s.jsx(Ae,{value:p,onChange:E=>g(E.target.value),placeholder:"ABCD12-EF3456"})]})]})]}),s.jsx("div",{className:"px-6 pb-6",children:s.jsx(he,{className:"w-full",disabled:y,onClick:async()=>{var E,j;S(!0);try{if((await a(l,i,d||void 0,p||void 0)).totpRequired){x(!0);return}const M=((j=(E=C.state)==null?void 0:E.from)==null?void 0:j.pathname)??"/";w(M,{replace:!0})}catch(N){ve.error(N.message)}finally{S(!1)}},children:"Sign in"})})]})})}function BA(){const[a,l]=m.useState("admin"),[o,i]=m.useState(""),[u,d]=m.useState(""),[h,p]=m.useState(!1),[g,v]=m.useState(!0);m.useEffect(()=>{we.get("/api/admin/setup/status").then(S=>v(!S.masterKeyConfigured)).catch(()=>v(!0))},[]);const x=!g||u.trim().length>=32,y=!h&&o.length>=12&&x;return s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:s.jsxs(Xe,{className:"w-full max-w-md",children:[s.jsxs(Fe,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:"/logo.png",alt:"LateDev Router",className:"h-8 w-8 object-contain rounded"}),s.jsx(Qe,{children:"Welcome to LateDev Router"})]}),s.jsx(on,{children:"Set up the administrator account to get started."})]}),s.jsxs(Ze,{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Username"}),s.jsx(Ae,{value:a,onChange:S=>l(S.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Password (12+ chars)"}),s.jsx(Ae,{type:"password",value:o,onChange:S=>i(S.target.value)})]}),g&&s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Master encryption key (required, 32+ chars)"}),s.jsx(Ae,{type:"password",value:u,onChange:S=>d(S.target.value),placeholder:"Paste or generate a 32+ character key"}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Provider API keys are encrypted with this key (AES-256-GCM). Store it somewhere safe — if it is lost, stored provider credentials cannot be recovered. Generate one with:"," ",s.jsx("code",{className:"break-all",children:`node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"`})]})]})]}),s.jsx(G0,{children:s.jsx(he,{disabled:!y,onClick:async()=>{p(!0);try{await we.post("/api/admin/setup",{username:a,password:o,setupMasterKey:g?u.trim():void 0}),ve.success("Admin account created"),window.location.assign("/login")}catch(S){ve.error(S.message)}finally{p(!1)}},children:"Create admin"})})]})})}function wa({title:a,description:l,actions:o,className:i}){return s.jsxs("div",{className:Re("mb-6 flex items-start justify-between gap-4",i),children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:a}),l&&s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:l})]}),o&&s.jsx("div",{className:"flex items-center gap-2",children:o})]})}const HA=mb("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground",success:"border-transparent bg-emerald-600 text-white",warning:"border-transparent bg-amber-500 text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function et({className:a,variant:l,...o}){return s.jsx("div",{className:Re(HA({variant:l}),a),...o})}function PA(){const[a,l]=m.useState(null);return m.useEffect(()=>{we.get("/api/admin/dashboard").then(l).catch(()=>l(null))},[]),a?s.jsxs("div",{children:[s.jsx(wa,{title:"Dashboard",description:"Operational summary for today",actions:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(he,{asChild:!0,variant:"outline",size:"sm",children:s.jsxs(ur,{to:"/providers",children:[s.jsx(Oo,{className:"mr-1 h-4 w-4"})," Provider"]})}),s.jsx(he,{asChild:!0,variant:"outline",size:"sm",children:s.jsxs(ur,{to:"/combos",children:[s.jsx(Zy,{className:"mr-1 h-4 w-4"})," Combo"]})}),s.jsx(he,{asChild:!0,variant:"outline",size:"sm",children:s.jsxs(ur,{to:"/api-keys",children:[s.jsx(Qy,{className:"mr-1 h-4 w-4"})," API Key"]})})]})}),s.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-1",children:s.jsx(Qe,{className:"text-sm text-muted-foreground",children:"Requests today"})}),s.jsx(Ze,{className:"text-2xl font-semibold",children:Mt(a.today.total)})]}),s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-1",children:s.jsx(Qe,{className:"text-sm text-muted-foreground",children:"Success rate"})}),s.jsx(Ze,{className:"text-2xl font-semibold",children:a.today.total?kc(a.today.success/a.today.total):"—"})]}),s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-1",children:s.jsx(Qe,{className:"text-sm text-muted-foreground",children:"Failed"})}),s.jsx(Ze,{className:"text-2xl font-semibold",children:Mt(a.today.failed)})]}),s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-1",children:s.jsx(Qe,{className:"text-sm text-muted-foreground",children:"Tokens today"})}),s.jsx(Ze,{className:"text-2xl font-semibold",children:Mt(a.today.totalTokens)})]})]}),s.jsxs("div",{className:"mt-6 grid gap-4 lg:grid-cols-2",children:[s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"Provider health"}),s.jsxs(on,{children:[a.providers.length," configured"]})]}),s.jsxs(Ze,{className:"space-y-2",children:[a.providers.length===0&&s.jsxs("p",{className:"text-sm text-muted-foreground",children:["No providers yet. ",s.jsx(ur,{to:"/providers",className:"text-primary",children:"Add one"}),"."]}),a.providers.map(o=>s.jsxs("div",{className:"flex items-center justify-between rounded border p-2 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Jy,{className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"font-medium",children:o.name}),s.jsx("span",{className:"text-xs text-muted-foreground",children:o.slug}),s.jsx(et,{variant:"outline",className:"ml-2",children:o.type})]}),s.jsx(et,{variant:o.health==="healthy"?"success":o.health==="down"?"destructive":"secondary",children:o.health})]},o.id))]})]}),s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"Recent failures"}),s.jsx(on,{children:"Today"})]}),s.jsxs(Ze,{className:"space-y-1 text-sm",children:[a.recentFailures.length===0&&s.jsx("p",{className:"text-muted-foreground",children:"No failures today."}),a.recentFailures.map(o=>{var i;return s.jsxs("div",{className:"flex items-center justify-between border-b py-1 last:border-0",children:[s.jsxs("div",{children:[s.jsx("span",{className:"font-mono text-xs",children:o.requestedModel}),s.jsxs("div",{className:"text-xs text-muted-foreground",children:[o.errorType??`HTTP ${o.httpStatus}`," — ",(i=o.errorMessage)==null?void 0:i.slice(0,60)]})]}),s.jsx("span",{className:"text-xs text-muted-foreground",children:Ah(o.createdAt)})]},o.id)})]})]})]})]}):s.jsx("div",{className:"text-muted-foreground",children:"Loading…"})}const Kn=m.forwardRef(({className:a,...l},o)=>s.jsx("div",{className:"relative w-full overflow-auto",children:s.jsx("table",{ref:o,className:Re("w-full caption-bottom text-sm",a),...l})}));Kn.displayName="Table";const Xn=m.forwardRef(({className:a,...l},o)=>s.jsx("thead",{ref:o,className:Re("[&_tr]:border-b",a),...l}));Xn.displayName="TableHeader";const Fn=m.forwardRef(({className:a,...l},o)=>s.jsx("tbody",{ref:o,className:Re("[&_tr:last-child]:border-0",a),...l}));Fn.displayName="TableBody";const Ye=m.forwardRef(({className:a,...l},o)=>s.jsx("tr",{ref:o,className:Re("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",a),...l}));Ye.displayName="TableRow";const pe=m.forwardRef(({className:a,...l},o)=>s.jsx("th",{ref:o,className:Re("h-10 px-2 text-left align-middle font-medium text-muted-foreground",a),...l}));pe.displayName="TableHead";const de=m.forwardRef(({className:a,...l},o)=>s.jsx("td",{ref:o,className:Re("p-2 align-middle",a),...l}));de.displayName="TableCell";var qA=Object.defineProperty,An=(a,l)=>qA(a,"name",{value:l,configurable:!0}),Zh="Dialog",[Y0,$0]=fn(Zh),[IA,sa]=Y0(Zh),K0=An(a=>{const{__scopeDialog:l,children:o,open:i,defaultOpen:u,onOpenChange:d,modal:h=!0}=a,p=m.useRef(null),g=m.useRef(null),[v,x]=Ja({prop:i,defaultProp:u??!1,onChange:d,caller:Zh}),[y,S]=m.useState(0),[w,C]=m.useState(0);return s.jsx(IA,{scope:l,triggerRef:p,contentRef:g,contentId:ga(),titleId:ga(),descriptionId:ga(),titlePresent:y>0,descriptionPresent:w>0,setTitleCount:S,setDescriptionCount:C,open:v,onOpenChange:x,onOpenToggle:m.useCallback(()=>x(E=>!E),[x]),modal:h,children:o})},"Dialog"),VA="DialogTrigger",X0=m.forwardRef(An(function(l,o){const{__scopeDialog:i,...u}=l,d=sa(VA,i),h=Ie(o,d.triggerRef);return s.jsx(Be.button,{type:"button","aria-haspopup":"dialog","aria-expanded":d.open,"aria-controls":d.open?d.contentId:void 0,"data-state":Fc(d.open),...u,ref:h,onClick:Ee(l.onClick,d.onOpenToggle)})},"DialogTrigger")),F0="DialogPortal",[GA,Q0]=Y0(F0,{forceMount:void 0}),Z0=An(a=>{const{__scopeDialog:l,forceMount:o,children:i,container:u}=a,d=sa(F0,l);return s.jsx(GA,{scope:l,forceMount:o,children:m.Children.map(i,h=>s.jsx(al,{present:o||d.open,children:s.jsx(Gh,{asChild:!0,container:u,children:h})}))})},"DialogPortal"),ih="DialogOverlay",Jh=m.forwardRef(An(function(l,o){const i=Q0(ih,l.__scopeDialog),{forceMount:u=i.forceMount,...d}=l,h=sa(ih,l.__scopeDialog);return h.modal?s.jsx(al,{present:u||h.open,children:s.jsx($A,{...d,ref:o})}):null},"DialogOverlay")),YA=va("DialogOverlay.RemoveScroll"),$A=m.forwardRef(An(function(l,o){const{__scopeDialog:i,...u}=l,d=sa(ih,i),h=Tb(),p=Ie(o,h);return s.jsx(Kc,{as:YA,allowPinchZoom:!0,shards:[d.contentRef],children:s.jsx(Be.div,{"data-state":Fc(d.open),...u,ref:p,style:{pointerEvents:"auto",...u.style}})})},"DialogOverlayImpl")),No="DialogContent",Wh=m.forwardRef(An(function(l,o){const i=Q0(No,l.__scopeDialog),{forceMount:u=i.forceMount,...d}=l,h=sa(No,l.__scopeDialog);return s.jsx(al,{present:u||h.open,children:h.modal?s.jsx(KA,{...d,ref:o}):s.jsx(XA,{...d,ref:o})})},"DialogContent")),KA=m.forwardRef(An(function(l,o){const i=sa(No,l.__scopeDialog),u=m.useRef(null),d=Ie(o,i.contentRef,u);return m.useEffect(()=>{const h=u.current;if(h)return Kh(h)},[]),s.jsx(J0,{...l,ref:d,trapFocus:i.open,disableOutsidePointerEvents:i.open,onCloseAutoFocus:Ee(l.onCloseAutoFocus,h=>{var p;h.preventDefault(),(p=i.triggerRef.current)==null||p.focus()}),onPointerDownOutside:Ee(l.onPointerDownOutside,h=>{const p=h.detail.originalEvent,g=p.button===0&&p.ctrlKey===!0;(p.button===2||g)&&h.preventDefault()}),onFocusOutside:Ee(l.onFocusOutside,h=>h.preventDefault())})},"DialogContentModal")),XA=m.forwardRef(An(function(l,o){const i=sa(No,l.__scopeDialog),u=m.useRef(!1),d=m.useRef(!1);return s.jsx(J0,{...l,ref:o,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:h=>{var p,g;(p=l.onCloseAutoFocus)==null||p.call(l,h),h.defaultPrevented||(u.current||(g=i.triggerRef.current)==null||g.focus(),h.preventDefault()),u.current=!1,d.current=!1},onInteractOutside:h=>{var v,x;(v=l.onInteractOutside)==null||v.call(l,h),h.defaultPrevented||(u.current=!0,h.detail.originalEvent.type==="pointerdown"&&(d.current=!0));const p=h.target;((x=i.triggerRef.current)==null?void 0:x.contains(p))&&h.preventDefault(),h.detail.originalEvent.type==="focusin"&&d.current&&h.preventDefault()}})},"DialogContentNonModal")),J0=m.forwardRef(An(function(l,o){const{__scopeDialog:i,trapFocus:u,onOpenAutoFocus:d,onCloseAutoFocus:h,...p}=l,g=sa(No,i);return Lo(),s.jsx(s.Fragment,{children:s.jsx(zh,{asChild:!0,loop:!0,trapped:u,onMountAutoFocus:d,onUnmountAutoFocus:h,children:s.jsx(Lc,{role:"dialog",id:g.contentId,"aria-describedby":g.descriptionPresent?g.descriptionId:void 0,"aria-labelledby":g.titlePresent?g.titleId:void 0,"data-state":Fc(g.open),...p,ref:o,deferPointerDownOutside:!0,onDismiss:()=>g.onOpenChange(!1)})})})},"DialogContentImpl")),FA="DialogTitle",em=m.forwardRef(An(function(l,o){const{__scopeDialog:i,...u}=l,d=sa(FA,i),{setTitleCount:h}=d;return Dt(()=>(h(p=>p+1),()=>h(p=>p-1)),[h]),s.jsx(Be.h2,{id:d.titleId,...u,ref:o})},"DialogTitle")),QA="DialogDescription",tm=m.forwardRef(An(function(l,o){const{__scopeDialog:i,...u}=l,d=sa(QA,i),{setDescriptionCount:h}=d;return Dt(()=>(h(p=>p+1),()=>h(p=>p-1)),[h]),s.jsx(Be.p,{id:d.descriptionId,...u,ref:o})},"DialogDescription")),ZA="DialogClose",nm=m.forwardRef(An(function(l,o){const{__scopeDialog:i,...u}=l,d=sa(ZA,i);return s.jsx(Be.button,{type:"button",...u,ref:o,onClick:Ee(l.onClick,()=>d.onOpenChange(!1))})},"DialogClose"));function Fc(a){return a?"open":"closed"}An(Fc,"getState");const qn=K0,Bo=X0,JA=Z0,W0=m.forwardRef(({className:a,...l},o)=>s.jsx(Jh,{ref:o,className:Re("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...l}));W0.displayName=Jh.displayName;const jn=m.forwardRef(({className:a,children:l,...o},i)=>s.jsxs(JA,{children:[s.jsx(W0,{}),s.jsxs(Wh,{ref:i,className:Re("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 sm:rounded-lg",a),...o,children:[l,s.jsxs(nm,{className:"absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100",children:[s.jsx(Oc,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));jn.displayName=Wh.displayName;const Cn=({className:a,...l})=>s.jsx("div",{className:Re("flex flex-col space-y-1.5 text-center sm:text-left",a),...l});Cn.displayName="DialogHeader";const In=({className:a,...l})=>s.jsx("div",{className:Re("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...l});In.displayName="DialogFooter";const En=m.forwardRef(({className:a,...l},o)=>s.jsx(em,{ref:o,className:Re("text-lg font-semibold leading-none tracking-tight",a),...l}));En.displayName=em.displayName;const ch=m.forwardRef(({className:a,...l},o)=>s.jsx(tm,{ref:o,className:Re("text-sm text-muted-foreground",a),...l}));ch.displayName=tm.displayName;var WA=Object.defineProperty,ll=(a,l)=>WA(a,"name",{value:l,configurable:!0}),eM="AlertDialog",[tM,Y_]=fn(eM,[$0]),rl=$0(),nM=ll(a=>{const{__scopeAlertDialog:l,...o}=a,i=rl(l);return s.jsx(K0,{...i,...o,modal:!0})},"AlertDialog"),aM=m.forwardRef(ll(function(l,o){const{__scopeAlertDialog:i,...u}=l,d=rl(i);return s.jsx(X0,{...d,...u,ref:o})},"AlertDialogTrigger")),lM=ll(a=>{const{__scopeAlertDialog:l,...o}=a,i=rl(l);return s.jsx(Z0,{...i,...o})},"AlertDialogPortal"),rM=m.forwardRef(ll(function(l,o){const{__scopeAlertDialog:i,...u}=l,d=rl(i);return s.jsx(Jh,{...d,...u,ref:o})},"AlertDialogOverlay")),sM="AlertDialogContent",[oM,iM]=tM(sM),cM=m.forwardRef(ll(function(l,o){const{__scopeAlertDialog:i,children:u,...d}=l,h=rl(i),p=m.useRef(null),g=Ie(o,p),v=m.useRef(null);return s.jsx(oM,{scope:i,cancelRef:v,children:s.jsx(Wh,{role:"alertdialog",...h,...d,ref:g,onOpenAutoFocus:Ee(d.onOpenAutoFocus,x=>{var y;x.preventDefault(),(y=v.current)==null||y.focus({preventScroll:!0})}),onPointerDownOutside:x=>x.preventDefault(),onInteractOutside:x=>x.preventDefault(),children:u})})},"AlertDialogContent")),uM=m.forwardRef(ll(function(l,o){const{__scopeAlertDialog:i,...u}=l,d=rl(i);return s.jsx(em,{...d,...u,ref:o})},"AlertDialogTitle")),dM=m.forwardRef(ll(function(l,o){const{__scopeAlertDialog:i,...u}=l,d=rl(i);return s.jsx(tm,{...d,...u,ref:o})},"AlertDialogDescription")),fM=m.forwardRef(ll(function(l,o){const{__scopeAlertDialog:i,...u}=l,d=rl(i);return s.jsx(nm,{...d,...u,ref:o})},"AlertDialogAction")),hM="AlertDialogCancel",mM=m.forwardRef(ll(function(l,o){const{__scopeAlertDialog:i,...u}=l,{cancelRef:d}=iM(hM,i),h=rl(i),p=Ie(o,d);return s.jsx(nm,{...h,...u,ref:p})},"AlertDialogCancel")),pM=nM,gM=aM,vM=lM,e1=rM,t1=cM,n1=fM,a1=mM,l1=uM,r1=dM;const s1=pM,xM=gM,yM=vM,o1=m.forwardRef(({className:a,...l},o)=>s.jsx(e1,{ref:o,className:Re("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...l}));o1.displayName=e1.displayName;const am=m.forwardRef(({className:a,...l},o)=>s.jsxs(yM,{children:[s.jsx(o1,{}),s.jsx(t1,{ref:o,className:Re("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg sm:max-w-[425px]",a),...l})]}));am.displayName=t1.displayName;const i1=({className:a,...l})=>s.jsx("div",{className:Re("flex flex-col space-y-2 text-center sm:text-left",a),...l}),c1=({className:a,...l})=>s.jsx("div",{className:Re("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...l}),lm=m.forwardRef(({className:a,...l},o)=>s.jsx(l1,{ref:o,className:Re("text-lg font-semibold",a),...l}));lm.displayName=l1.displayName;const rm=m.forwardRef(({className:a,...l},o)=>s.jsx(r1,{ref:o,className:Re("text-sm text-muted-foreground",a),...l}));rm.displayName=r1.displayName;const sm=m.forwardRef(({className:a,...l},o)=>s.jsx(n1,{ref:o,className:Re("inline-flex h-9 items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90",a),...l}));sm.displayName=n1.displayName;const om=m.forwardRef(({className:a,...l},o)=>s.jsx(a1,{ref:o,className:Re("inline-flex h-9 items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium hover:bg-accent",a),...l}));om.displayName=a1.displayName;var bM=Object.defineProperty,SM=(a,l)=>bM(a,"name",{value:l,configurable:!0});function uh(a,[l,o]){return Math.min(o,Math.max(l,a))}SM(uh,"clamp");var wM=Object.defineProperty,jM=(a,l)=>wM(a,"name",{value:l,configurable:!0});function u1(a){const l=m.useRef({value:a,previous:a});return m.useMemo(()=>(l.current.value!==a&&(l.current.previous=l.current.value,l.current.value=a),l.current.previous),[a])}jM(u1,"usePrevious");var CM=Object.defineProperty,EM=(a,l)=>CM(a,"name",{value:l,configurable:!0}),d1=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),RM=m.forwardRef(EM(function(l,o){return s.jsx(Be.span,{...l,ref:o,style:{...d1,...l.style}})},"VisuallyHidden")),NM=RM,TM=Object.defineProperty,rt=(a,l)=>TM(a,"name",{value:l,configurable:!0}),AM=[" ","Enter","ArrowUp","ArrowDown"],MM=[" ","Enter"],ps="Select",[Qc,im,DM]=zc(ps),[yr,$_]=fn(ps,[DM,Es]),cm=Es(),[_M,Il]=yr(ps),[OM,kM]=yr(ps);function f1(a){const{__scopeSelect:l,children:o,open:i,defaultOpen:u,onOpenChange:d,value:h,defaultValue:p,onValueChange:g,dir:v,name:x,autoComplete:y,disabled:S,required:w,form:C,internal_do_not_use_render:E}=a,j=cm(l),[N,M]=m.useState(null),[T,_]=m.useState(null),[O,A]=m.useState(!1),H=zo(v),[z,K]=Ja({prop:i,defaultProp:u??!1,onChange:d,caller:ps}),[se,X]=Ja({prop:h,defaultProp:p,onChange:g,caller:ps}),I=m.useRef(null),re=m.useRef(se);m.useEffect(()=>{const q=C?N==null?void 0:N.ownerDocument.getElementById(C):N==null?void 0:N.form;if(q instanceof HTMLFormElement){const Q=rt(()=>X(re.current),"reset");return q.addEventListener("reset",Q),()=>q.removeEventListener("reset",Q)}},[C,N,X]);const ee=N?!!C||!!N.closest("form"):!0,[oe,U]=m.useState(new Set),$=ga(),le=Array.from(oe).map(q=>q.props.value).join(";"),B=m.useCallback(q=>{U(Q=>new Set(Q).add(q))},[]),Z=m.useCallback(q=>{U(Q=>{const ae=new Set(Q);return ae.delete(q),ae})},[]),D={required:w,trigger:N,onTriggerChange:M,valueNode:T,onValueNodeChange:_,valueNodeHasChildren:O,onValueNodeHasChildrenChange:A,contentId:$,value:se,onValueChange:X,open:z,onOpenChange:K,dir:H,triggerPointerDownPosRef:I,disabled:S,name:x,autoComplete:y,form:C,nativeOptions:oe,nativeSelectKey:le,isFormControl:ee};return s.jsx(Wb,{...j,children:s.jsx(_M,{scope:l,...D,children:s.jsx(Qc.Provider,{scope:l,children:s.jsx(OM,{scope:l,onNativeOptionAdd:B,onNativeOptionRemove:Z,children:x1(E)?E(D):o})})})})}rt(f1,"SelectProvider");var zM=rt(a=>{const{__scopeSelect:l,children:o,...i}=a;return s.jsx(f1,{__scopeSelect:l,...i,internal_do_not_use_render:({isFormControl:u})=>s.jsxs(s.Fragment,{children:[o,u?s.jsx(aD,{__scopeSelect:l}):null]})})},"Select"),LM="SelectTrigger",h1=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,disabled:u=!1,...d}=l,h=cm(i),p=Il(LM,i),g=p.disabled||u,v=Ie(o,p.onTriggerChange),x=im(i),y=m.useRef("touch"),[S,w,C]=um(j=>{const N=x().filter(_=>!_.disabled),M=N.find(_=>_.value===p.value),T=dm(N,j,M);T!==void 0&&p.onValueChange(T.value)}),E=rt(j=>{g||(p.onOpenChange(!0),C()),j&&(p.triggerPointerDownPosRef.current={x:Math.round(j.pageX),y:Math.round(j.pageY)})},"handleOpen");return s.jsx(e0,{asChild:!0,...h,children:s.jsx(Be.button,{type:"button",role:"combobox","aria-controls":p.open?p.contentId:void 0,"aria-expanded":p.open,"aria-required":p.required,"aria-autocomplete":"none",dir:p.dir,"data-state":p.open?"open":"closed",disabled:g,"data-disabled":g?"":void 0,"data-placeholder":Ho(p.value)?"":void 0,...d,ref:v,onClick:Ee(d.onClick,j=>{j.currentTarget.focus(),y.current!=="mouse"&&E(j)}),onPointerDown:Ee(d.onPointerDown,j=>{y.current=j.pointerType;const N=j.target;N.hasPointerCapture(j.pointerId)&&N.releasePointerCapture(j.pointerId),j.button===0&&j.ctrlKey===!1&&j.pointerType==="mouse"&&(E(j),j.preventDefault())}),onKeyDown:Ee(d.onKeyDown,j=>{const N=S.current!=="";!(j.ctrlKey||j.altKey||j.metaKey)&&j.key.length===1&&w(j.key),!(N&&j.key===" ")&&AM.includes(j.key)&&(E(),j.preventDefault())})})})},"SelectTrigger")),UM="SelectValue",BM=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,className:u,style:d,children:h,placeholder:p="",...g}=l,v=Il(UM,i),{onValueNodeHasChildrenChange:x}=v,y=h!==void 0,S=Ie(o,v.onValueNodeChange);Dt(()=>{x(y)},[x,y]);const w=Ho(v.value);return s.jsx(Be.span,{...g,asChild:w?!1:g.asChild,ref:S,style:{pointerEvents:"none"},children:s.jsx(m.Fragment,{children:w?p:h},w?"placeholder":"value")})},"SelectValue")),HM=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,children:u,...d}=l;return s.jsx(Be.span,{"aria-hidden":!0,...d,ref:o,children:u||"▼"})},"SelectIcon")),PM="SelectPortal",[qM,IM]=yr(PM,{forceMount:void 0}),VM=rt(a=>{const{__scopeSelect:l,forceMount:o,...i}=a;return s.jsx(qM,{scope:a.__scopeSelect,forceMount:o,children:s.jsx(Gh,{asChild:!0,...i})})},"SelectPortal"),mr="SelectContent",m1=m.forwardRef(rt(function(l,o){const i=IM(mr,l.__scopeSelect),{forceMount:u=i.forceMount,...d}=l,h=Il(mr,l.__scopeSelect),[p,g]=m.useState();return Dt(()=>{g(new DocumentFragment)},[]),s.jsx(al,{present:u||h.open,children:({present:v})=>v?s.jsx($M,{...d,ref:o}):s.jsx(GM,{...d,fragment:p})})},"SelectContent")),GM=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,children:u,fragment:d}=l;return d?bs.createPortal(s.jsx(p1,{scope:i,children:s.jsx(Qc.Slot,{scope:i,children:s.jsx("div",{ref:o,children:u})})}),d):null},"SelectContentFragment")),aa=10,[p1,Zc]=yr(mr),YM=va("SelectContent.RemoveScroll"),$M=m.forwardRef(rt(function(l,o){const{__scopeSelect:i}=l,{position:u="item-aligned",onCloseAutoFocus:d,onEscapeKeyDown:h,onPointerDownOutside:p,side:g,sideOffset:v,align:x,alignOffset:y,arrowPadding:S,collisionBoundary:w,collisionPadding:C,sticky:E,hideWhenDetached:j,avoidCollisions:N,...M}=l,T=Il(mr,i),[_,O]=m.useState(null),[A,H]=m.useState(null),z=Ie(o,O),[K,se]=m.useState(null),[X,I]=m.useState(null),re=im(i),[ee,oe]=m.useState(!1),U=m.useRef(!1);m.useEffect(()=>{if(_)return Kh(_)},[_]),Lo();const $=m.useCallback(fe=>{const[xe,...J]=re().map(Me=>Me.ref.current),[me]=J.slice(-1),je=document.activeElement;for(const Me of fe)if(Me===je||(Me==null||Me.scrollIntoView({block:"nearest"}),Me===xe&&A&&(A.scrollTop=0),Me===me&&A&&(A.scrollTop=A.scrollHeight),Me==null||Me.focus(),document.activeElement!==je))return},[re,A]),le=m.useCallback(()=>$([K,_]),[$,K,_]);m.useEffect(()=>{ee&&le()},[ee,le]);const{onOpenChange:B,triggerPointerDownPosRef:Z}=T;m.useEffect(()=>{if(_){let fe={x:0,y:0};const xe=rt(me=>{var je,Me;fe={x:Math.abs(Math.round(me.pageX)-(((je=Z.current)==null?void 0:je.x)??0)),y:Math.abs(Math.round(me.pageY)-(((Me=Z.current)==null?void 0:Me.y)??0))}},"handlePointerMove"),J=rt(me=>{fe.x<=10&&fe.y<=10?me.preventDefault():me.composedPath().includes(_)||B(!1),document.removeEventListener("pointermove",xe),Z.current=null},"handlePointerUp");return Z.current!==null&&(document.addEventListener("pointermove",xe),document.addEventListener("pointerup",J,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",xe),document.removeEventListener("pointerup",J,{capture:!0})}}},[_,B,Z]),m.useEffect(()=>{const fe=rt(()=>B(!1),"close");return window.addEventListener("blur",fe),window.addEventListener("resize",fe),()=>{window.removeEventListener("blur",fe),window.removeEventListener("resize",fe)}},[B]);const[D,q]=um(fe=>{const xe=re().filter(je=>!je.disabled),J=xe.find(je=>je.ref.current===document.activeElement),me=dm(xe,fe,J);me&&setTimeout(()=>{var je;return(je=me.ref.current)==null?void 0:je.focus()})}),Q=m.useCallback((fe,xe,J)=>{const me=!U.current&&!J;(T.value!==void 0&&T.value===xe||me)&&(se(fe),me&&(U.current=!0))},[T.value]),ae=m.useCallback(()=>_==null?void 0:_.focus(),[_]),ce=m.useCallback((fe,xe,J)=>{const me=!U.current&&!J;(T.value!==void 0&&T.value===xe||me)&&I(fe)},[T.value]),Se=u==="popper"?hy:KM,ue=Se===hy?{side:g,sideOffset:v,align:x,alignOffset:y,arrowPadding:S,collisionBoundary:w,collisionPadding:C,sticky:E,hideWhenDetached:j,avoidCollisions:N}:{};return s.jsx(p1,{scope:i,content:_,viewport:A,onViewportChange:H,itemRefCallback:Q,selectedItem:K,onItemLeave:ae,itemTextRefCallback:ce,focusSelectedItem:le,selectedItemText:X,position:u,isPositioned:ee,searchRef:D,children:s.jsx(Kc,{as:YM,allowPinchZoom:!0,children:s.jsx(zh,{asChild:!0,trapped:T.open,onMountAutoFocus:fe=>{fe.preventDefault()},onUnmountAutoFocus:Ee(d,fe=>{var xe;(xe=T.trigger)==null||xe.focus({preventScroll:!0}),fe.preventDefault()}),children:s.jsx(Lc,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:h,onPointerDownOutside:p,onFocusOutside:fe=>fe.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:s.jsx(Se,{role:"listbox",id:T.contentId,"data-state":T.open?"open":"closed",dir:T.dir,onContextMenu:fe=>fe.preventDefault(),...M,...ue,onPlaced:()=>oe(!0),ref:z,style:{display:"flex",flexDirection:"column",outline:"none",...M.style},onKeyDown:Ee(M.onKeyDown,fe=>{const xe=fe.ctrlKey||fe.altKey||fe.metaKey;if(fe.key==="Tab"&&fe.preventDefault(),!xe&&fe.key.length===1&&q(fe.key),["ArrowUp","ArrowDown","Home","End"].includes(fe.key)){let me=re().filter(je=>!je.disabled).map(je=>je.ref.current);if(["ArrowUp","End"].includes(fe.key)&&(me=me.slice().reverse()),["ArrowUp","ArrowDown"].includes(fe.key)){const je=fe.target,Me=me.indexOf(je);me=me.slice(Me+1)}setTimeout(()=>$(me)),fe.preventDefault()}})})})})})})},"SelectContentImpl")),KM=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,onPlaced:u,...d}=l,h=Il(mr,i),p=Zc(mr,i),[g,v]=m.useState(null),[x,y]=m.useState(null),S=Ie(o,y),w=im(i),C=m.useRef(!1),E=m.useRef(!0),{viewport:j,selectedItem:N,selectedItemText:M,focusSelectedItem:T}=p,_=m.useCallback(()=>{if(h.trigger&&h.valueNode&&g&&x&&j&&N&&M){const z=h.trigger.getBoundingClientRect(),K=x.getBoundingClientRect(),se=h.valueNode.getBoundingClientRect(),X=M.getBoundingClientRect();if(h.dir!=="rtl"){const je=X.left-K.left,Me=se.left-je,mt=z.left-Me,pt=z.width+mt,bt=Math.max(pt,K.width),St=window.innerWidth-aa,Lt=uh(Me,[aa,Math.max(aa,St-bt)]);g.style.minWidth=pt+"px",g.style.left=Lt+"px"}else{const je=K.right-X.right,Me=window.innerWidth-se.right-je,mt=window.innerWidth-z.right-Me,pt=z.width+mt,bt=Math.max(pt,K.width),St=window.innerWidth-aa,Lt=uh(Me,[aa,Math.max(aa,St-bt)]);g.style.minWidth=pt+"px",g.style.right=Lt+"px"}const I=w(),re=window.innerHeight-aa*2,ee=j.scrollHeight,oe=window.getComputedStyle(x),U=parseInt(oe.borderTopWidth,10),$=parseInt(oe.paddingTop,10),le=parseInt(oe.borderBottomWidth,10),B=parseInt(oe.paddingBottom,10),Z=U+$+ee+B+le,D=Math.min(N.offsetHeight*5,Z),q=window.getComputedStyle(j),Q=parseInt(q.paddingTop,10),ae=parseInt(q.paddingBottom,10),ce=z.top+z.height/2-aa,Se=re-ce,ue=N.offsetHeight/2,fe=N.offsetTop+ue,xe=U+$+fe,J=Z-xe;if(xe<=ce){const je=I.length>0&&N===I[I.length-1].ref.current;g.style.bottom="0px";const Me=x.clientHeight-j.offsetTop-j.offsetHeight,mt=Math.max(Se,ue+(je?ae:0)+Me+le),pt=xe+mt;g.style.height=pt+"px"}else{const je=I.length>0&&N===I[0].ref.current;g.style.top="0px";const mt=Math.max(ce,U+j.offsetTop+(je?Q:0)+ue)+J;g.style.height=mt+"px",j.scrollTop=xe-ce+j.offsetTop}g.style.margin=`${aa}px 0`,g.style.minHeight=D+"px",g.style.maxHeight=re+"px",u==null||u(),requestAnimationFrame(()=>C.current=!0)}},[w,h.trigger,h.valueNode,g,x,j,N,M,h.dir,u]);Dt(()=>_(),[_]);const[O,A]=m.useState();Dt(()=>{x&&A(window.getComputedStyle(x).zIndex)},[x]);const H=m.useCallback(z=>{z&&E.current===!0&&(_(),T==null||T(),E.current=!1)},[_,T]);return s.jsx(XM,{scope:i,contentWrapper:g,shouldExpandOnScrollRef:C,onScrollButtonChange:H,children:s.jsx("div",{ref:v,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:O},children:s.jsx(Be.div,{...d,ref:S,style:{boxSizing:"border-box",maxHeight:"100%",...d.style}})})})},"SelectItemAlignedPosition")),hy=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,align:u="start",collisionPadding:d=aa,...h}=l,p=cm(i);return s.jsx(Vh,{...p,...h,ref:o,align:u,collisionPadding:d,style:{boxSizing:"border-box",...h.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[XM,FM]=yr(mr,{}),my="SelectViewport",QM=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,nonce:u,...d}=l,h=Zc(my,i),p=FM(my,i),g=Ie(o,h.onViewportChange),v=m.useRef(0);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:u}),s.jsx(Qc.Slot,{scope:i,children:s.jsx(Be.div,{"data-radix-select-viewport":"",role:"presentation",...d,ref:g,style:{position:"relative",flex:1,overflow:"hidden auto",...d.style},onScroll:Ee(d.onScroll,x=>{const y=x.currentTarget,{contentWrapper:S,shouldExpandOnScrollRef:w}=p;if(w!=null&&w.current&&S){const C=Math.abs(v.current-y.scrollTop);if(C>0){const E=window.innerHeight-aa*2,j=parseFloat(S.style.minHeight),N=parseFloat(S.style.height),M=Math.max(j,N);if(M<E){const T=M+C,_=Math.min(E,T),O=T-_;S.style.height=_+"px",S.style.bottom==="0px"&&(y.scrollTop=O>0?O:0,S.style.justifyContent="flex-end")}}}v.current=y.scrollTop})})})]})},"SelectViewport")),ZM="SelectGroup",[K_,X_]=yr(ZM),dh="SelectItem",[JM,g1]=yr(dh),v1=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,value:u,disabled:d=!1,textValue:h,...p}=l,g=Il(dh,i),v=Zc(dh,i),x=g.value===u,[y,S]=m.useState(h??""),[w,C]=m.useState(!1),E=$n(_=>{var O;return(O=v.itemRefCallback)==null?void 0:O.call(v,_,u,d)}),j=Ie(o,E),N=ga(),M=m.useRef("touch"),T=rt(()=>{d||(g.onValueChange(u),g.onOpenChange(!1))},"handleSelect");return s.jsx(JM,{scope:i,value:u,disabled:d,textId:N,isSelected:x,onItemTextChange:m.useCallback(_=>{S(O=>O||((_==null?void 0:_.textContent)??"").trim())},[]),children:s.jsx(Qc.ItemSlot,{scope:i,value:u,disabled:d,textValue:y,children:s.jsx(Be.div,{role:"option","aria-labelledby":N,"data-highlighted":w?"":void 0,"aria-selected":x&&w,"data-state":x?"checked":"unchecked","aria-disabled":d||void 0,"data-disabled":d?"":void 0,tabIndex:d?void 0:-1,...p,ref:j,onFocus:Ee(p.onFocus,()=>C(!0)),onBlur:Ee(p.onBlur,()=>C(!1)),onClick:Ee(p.onClick,()=>{M.current!=="mouse"&&T()}),onPointerUp:Ee(p.onPointerUp,()=>{M.current==="mouse"&&T()}),onPointerDown:Ee(p.onPointerDown,_=>{M.current=_.pointerType}),onPointerMove:Ee(p.onPointerMove,_=>{var O;M.current=_.pointerType,d?(O=v.onItemLeave)==null||O.call(v):M.current==="mouse"&&_.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ee(p.onPointerLeave,_=>{var O;_.currentTarget===document.activeElement&&((O=v.onItemLeave)==null||O.call(v))}),onKeyDown:Ee(p.onKeyDown,_=>{var A;d||_.target!==_.currentTarget||((A=v.searchRef)==null?void 0:A.current)!==""&&_.key===" "||(MM.includes(_.key)&&T(),_.key===" "&&_.preventDefault())})})})})},"SelectItem")),cc="SelectItemText",WM=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,className:u,style:d,...h}=l,p=Il(cc,i),g=Zc(cc,i),v=g1(cc,i),x=kM(cc,i),[y,S]=m.useState(null),w=$n(T=>{var _;return(_=g.itemTextRefCallback)==null?void 0:_.call(g,T,v.value,v.disabled)}),C=Ie(o,S,v.onItemTextChange,w),E=y==null?void 0:y.textContent,j=m.useMemo(()=>s.jsx("option",{value:v.value,disabled:v.disabled,children:E},v.value),[v.disabled,v.value,E]),{onNativeOptionAdd:N,onNativeOptionRemove:M}=x;return Dt(()=>(N(j),()=>M(j)),[N,M,j]),s.jsxs(s.Fragment,{children:[s.jsx(Be.span,{id:v.textId,...h,ref:C}),v.isSelected&&p.valueNode&&!p.valueNodeHasChildren&&!Ho(p.value)?bs.createPortal(h.children,p.valueNode):null]})},"SelectItemText")),eD="SelectItemIndicator",tD=m.forwardRef(rt(function(l,o){const{__scopeSelect:i,...u}=l;return g1(eD,i).isSelected?s.jsx(Be.span,{"aria-hidden":!0,...u,ref:o}):null},"SelectItemIndicator")),nD="SelectBubbleInput",aD=m.forwardRef(rt(function({__scopeSelect:l,...o},i){const u=Il(nD,l),{value:d,onValueChange:h,required:p,disabled:g,name:v,autoComplete:x,form:y}=u,{nativeOptions:S,nativeSelectKey:w}=u,C=m.useRef(null),E=Ie(i,C),j=d??"",N=u1(j),M=Array.from(S).some(T=>(T.props.value??"")==="");return m.useEffect(()=>{const T=C.current;if(!T)return;const _=window.HTMLSelectElement.prototype,A=Object.getOwnPropertyDescriptor(_,"value").set;if(N!==j&&A){const H=new Event("change",{bubbles:!0});A.call(T,j),T.dispatchEvent(H)}},[N,j]),s.jsxs(Be.select,{"aria-hidden":!0,required:p,tabIndex:-1,name:v,autoComplete:x,disabled:g,form:y,onChange:T=>h(T.target.value),...o,style:{...d1,...o.style},ref:E,defaultValue:j,children:[Ho(d)&&!M?s.jsx("option",{value:""}):null,Array.from(S)]},w)},"SelectBubbleInput"));function x1(a){return typeof a=="function"}rt(x1,"isFunction");function Ho(a){return a===""||a===void 0}rt(Ho,"shouldShowPlaceholder");function um(a){const l=$n(a),o=m.useRef(""),i=m.useRef(0),u=m.useCallback(h=>{const p=o.current+h;l(p),rt((function g(v){o.current=v,window.clearTimeout(i.current),v!==""&&(i.current=window.setTimeout(()=>g(""),1e3))}),"updateSearch")(p)},[l]),d=m.useCallback(()=>{o.current="",window.clearTimeout(i.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(i.current),[]),[o,u,d]}rt(um,"useTypeaheadSearch");function dm(a,l,o){const u=l.length>1&&Array.from(l).every(v=>v===l[0])?l[0]:l,d=o?a.indexOf(o):-1;let h=y1(a,Math.max(d,0));u.length===1&&(h=h.filter(v=>v!==o));const g=h.find(v=>v.textValue.toLowerCase().startsWith(u.toLowerCase()));return g!==o?g:void 0}rt(dm,"findNextItem");function y1(a,l){return a.map((o,i)=>a[(l+i)%a.length])}rt(y1,"wrapArray");const Vn=zM,Gn=BM,Rn=m.forwardRef(({className:a,children:l,...o},i)=>s.jsxs(h1,{ref:i,className:Re("flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50",a),...o,children:[l,s.jsx(HM,{asChild:!0,children:s.jsx(eC,{className:"h-4 w-4 opacity-50"})})]}));Rn.displayName=h1.displayName;const Nn=m.forwardRef(({className:a,children:l,position:o="popper",...i},u)=>s.jsx(VM,{children:s.jsx(m1,{ref:u,className:Re("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",a),position:o,...i,children:s.jsx(QM,{className:Re("p-1",o==="popper"&&"w-full min-w-[var(--radix-select-trigger-width)]"),children:l})})}));Nn.displayName=m1.displayName;const lt=m.forwardRef(({className:a,children:l,...o},i)=>s.jsxs(v1,{ref:i,className:Re("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...o,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(tD,{children:s.jsx(Ky,{className:"h-4 w-4"})})}),s.jsx(WM,{children:l})]}));lt.displayName=v1.displayName;var lD=Object.defineProperty,Pl=(a,l)=>lD(a,"name",{value:l,configurable:!0}),fm="Switch",[rD,F_]=fn(fm),[sD,hm]=rD(fm);function b1(a){const{__scopeSwitch:l,checked:o,children:i,defaultChecked:u,disabled:d,form:h,name:p,onCheckedChange:g,required:v,value:x="on",internal_do_not_use_render:y}=a,[S,w]=Ja({prop:o,defaultProp:u??!1,onChange:g,caller:fm}),[C,E]=m.useState(null),[j,N]=m.useState(null),M=m.useRef(!1),[T,_]=m.useReducer(H=>H+1,0),O=C?!!h||!!C.closest("form"):!0,A={checked:S,setChecked:w,disabled:d,control:C,setControl:E,name:p,form:h,value:x,hasConsumerStoppedPropagationRef:M,userInteractionCount:T,onUserInteraction:_,required:v,defaultChecked:u,isFormControl:O,bubbleInput:j,setBubbleInput:N};return s.jsx(sD,{scope:l,...A,children:w1(y)?y(A):i})}Pl(b1,"SwitchProvider");var oD="SwitchTrigger",iD=m.forwardRef(Pl(function({__scopeSwitch:l,onClick:o,...i},u){const{control:d,form:h,value:p,disabled:g,checked:v,required:x,setControl:y,setChecked:S,hasConsumerStoppedPropagationRef:w,onUserInteraction:C,isFormControl:E,bubbleInput:j}=hm(oD,l),N=Ie(u,y),M=m.useRef(v);return m.useEffect(()=>{const T=h?d==null?void 0:d.ownerDocument.getElementById(h):d==null?void 0:d.form;if(T instanceof HTMLFormElement){const _=Pl(()=>S(M.current),"reset");return T.addEventListener("reset",_),()=>T.removeEventListener("reset",_)}},[d,h,S]),s.jsx(Be.button,{type:"button",role:"switch","aria-checked":v,"aria-required":x,"data-state":mm(v),"data-disabled":g?"":void 0,disabled:g,value:p,...i,ref:N,onClick:Ee(o,T=>{C(),S(_=>!_),j&&E&&(w.current=T.isPropagationStopped(),w.current||T.stopPropagation())})})},"SwitchTrigger")),S1=m.forwardRef(Pl(function(l,o){const{__scopeSwitch:i,name:u,checked:d,defaultChecked:h,required:p,disabled:g,value:v,onCheckedChange:x,form:y,...S}=l;return s.jsx(b1,{__scopeSwitch:i,checked:d,defaultChecked:h,disabled:g,required:p,onCheckedChange:x,name:u,form:y,value:v,internal_do_not_use_render:({isFormControl:w})=>s.jsxs(s.Fragment,{children:[s.jsx(iD,{...S,ref:o,__scopeSwitch:i}),w&&s.jsx(fD,{__scopeSwitch:i})]})})},"Switch")),cD="SwitchThumb",uD=m.forwardRef(Pl(function(l,o){const{__scopeSwitch:i,...u}=l,d=hm(cD,i);return s.jsx(Be.span,{"data-state":mm(d.checked),"data-disabled":d.disabled?"":void 0,...u,ref:o})},"SwitchThumb")),dD="SwitchBubbleInput",fD=m.forwardRef(Pl(function({__scopeSwitch:l,onClick:o,...i},u){const{control:d,hasConsumerStoppedPropagationRef:h,userInteractionCount:p,checked:g,defaultChecked:v,required:x,disabled:y,name:S,value:w,form:C,bubbleInput:E,setBubbleInput:j}=hm(dD,l),N=Ie(u,j),M=Ic(d),T=m.useRef(!1),_=m.useRef(g),O=m.useRef(p);m.useEffect(()=>{const H=E;if(!H)return;const z=window.HTMLInputElement.prototype,se=Object.getOwnPropertyDescriptor(z,"checked").set,X=p!==O.current;O.current=p;const I=_.current!==g;_.current=g;const re=!(X&&h.current);if(I&&se){T.current=!X;const ee=new Event("click",{bubbles:re});se.call(H,g),H.dispatchEvent(ee),T.current=!1}},[E,g,h,p]);const A=m.useRef(g);return s.jsx(Be.input,{type:"checkbox","aria-hidden":!0,defaultChecked:v??A.current,required:x,disabled:y,name:S,value:w,form:C,...i,tabIndex:-1,ref:N,onClick:Ee(o,H=>{T.current&&H.stopPropagation()}),style:{...i.style,...M,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"SwitchBubbleInput"));function w1(a){return typeof a=="function"}Pl(w1,"isFunction");function mm(a){return a?"checked":"unchecked"}Pl(mm,"getState");const ba=m.forwardRef(({className:a,...l},o)=>s.jsx(S1,{className:Re("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",a),...l,ref:o,children:s.jsx(uD,{className:Re("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));ba.displayName=S1.displayName;const cr={name:"",slug:"",type:"openai",baseUrl:"https://api.openai.com",apiKey:"",customHeaders:"",enabled:!0};function hD(){const[a,l]=m.useState([]),[o,i]=m.useState(!1),[u,d]=m.useState(cr),[h,p]=m.useState(!1),[g,v]=m.useState(null),[x,y]=m.useState(null),[S,w]=m.useState(cr),[C,E]=m.useState(null),[j,N]=m.useState(!1),M=()=>we.get("/api/admin/providers").then(z=>l(z.providers));m.useEffect(()=>{M()},[]);const T=async()=>{p(!0);try{let z;if(u.customHeaders.trim())try{z=JSON.parse(u.customHeaders)}catch{throw new Error("Custom headers must be valid JSON object")}await we.post("/api/admin/providers",{name:u.name,slug:u.slug||void 0,type:u.type,baseUrl:u.baseUrl,apiKey:u.apiKey,customHeaders:z,enabled:u.enabled}),ve.success("Provider created"),i(!1),d(cr),M()}catch(z){ve.error(z.message)}finally{p(!1)}},_=async z=>{v(z);try{const K=await we.post(`/api/admin/providers/${z}/test`);ve.success(K.ok?`Connection OK: ${K.detail}`:`Failed: ${K.detail}`),M()}catch(K){ve.error(K.message)}finally{v(null)}},O=z=>{y(z.id),w({...cr,name:z.name,slug:z.slug||"",type:z.type,baseUrl:z.baseUrl,apiKey:"",customHeaders:"",enabled:z.enabled})},A=async()=>{if(x){p(!0);try{let z;if(S.customHeaders.trim())try{z=JSON.parse(S.customHeaders)}catch{throw new Error("Custom headers must be valid JSON object")}await we.patch("/api/admin/providers",{id:x,name:S.name,slug:S.slug||void 0,type:S.type,baseUrl:S.baseUrl,apiKey:S.apiKey||void 0,customHeaders:z,enabled:S.enabled}),ve.success("Provider updated"),y(null),w(cr),M()}catch(z){ve.error(z.message)}finally{p(!1)}}},H=async z=>{N(!0);try{await we.del(`/api/admin/providers/${z}`),ve.success("Provider removed"),M()}catch(K){ve.error(K.message)}finally{N(!1),E(null)}};return s.jsxs("div",{children:[s.jsx(wa,{title:"Providers",description:"Upstream LLM providers and their credentials",actions:s.jsxs(qn,{open:o,onOpenChange:i,children:[s.jsx(Bo,{asChild:!0,children:s.jsxs(he,{children:[s.jsx(Oo,{className:"mr-1 h-4 w-4"})," Add provider"]})}),s.jsxs(jn,{children:[s.jsx(Cn,{children:s.jsx(En,{children:"New provider"})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx(be,{children:"Name"}),s.jsx(Ae,{value:u.name,onChange:z=>d({...u,name:z.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Slug (optional)"}),s.jsx(Ae,{value:u.slug,onChange:z=>d({...u,slug:z.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Type"}),s.jsxs(Vn,{value:u.type,onValueChange:z=>d({...u,type:z}),children:[s.jsx(Rn,{children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"openai",children:"OpenAI-compatible"}),s.jsx(lt,{value:"anthropic",children:"Anthropic-compatible"})]})]})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Base URL"}),s.jsx(Ae,{value:u.baseUrl,onChange:z=>d({...u,baseUrl:z.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"API key"}),s.jsx(Ae,{type:"password",value:u.apiKey,onChange:z=>d({...u,apiKey:z.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Custom headers (JSON)"}),s.jsx(Ae,{value:u.customHeaders,onChange:z=>d({...u,customHeaders:z.target.value}),placeholder:'{"X-Org":"acme"}'})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ba,{checked:u.enabled,onCheckedChange:z=>d({...u,enabled:z})}),s.jsx(be,{children:"Enabled"})]})]}),s.jsxs(In,{children:[s.jsx(he,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),s.jsx(he,{disabled:h||!u.name||!u.apiKey,onClick:T,children:"Create"})]})]})]})}),s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"All providers"}),s.jsxs(on,{children:[a.length," total"]})]}),s.jsx(Ze,{children:s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Name"}),s.jsx(pe,{children:"Type"}),s.jsx(pe,{children:"Base URL"}),s.jsx(pe,{children:"Models"}),s.jsx(pe,{children:"Health"}),s.jsx(pe,{children:"Enabled"}),s.jsx(pe,{className:"text-right",children:"Actions"})]})}),s.jsxs(Fn,{children:[a.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:7,className:"text-center text-muted-foreground",children:"No providers yet."})}),a.map(z=>s.jsxs(Ye,{children:[s.jsxs(de,{className:"font-medium",children:[z.name," ",s.jsx("span",{className:"text-xs text-muted-foreground",children:z.slug})]}),s.jsx(de,{children:s.jsx(et,{variant:"outline",children:z.type})}),s.jsx(de,{className:"text-xs text-muted-foreground",children:z.baseUrl}),s.jsx(de,{children:z.modelCount}),s.jsx(de,{children:s.jsx(et,{variant:z.health==="healthy"?"success":z.health==="down"?"destructive":"secondary",children:z.health})}),s.jsx(de,{children:z.enabled?"Yes":"No"}),s.jsx(de,{className:"text-right",children:s.jsxs("div",{className:"flex justify-end gap-1",children:[s.jsx(he,{size:"sm",variant:"outline",disabled:g===z.id,onClick:()=>_(z.id),children:s.jsx(pC,{className:"h-3 w-3"})}),s.jsx(he,{size:"sm",variant:"outline",onClick:()=>O(z),children:"✎"}),s.jsx(he,{size:"sm",variant:"outline",onClick:()=>E(z.id),children:s.jsx(_c,{className:"h-3 w-3"})})]})})]},z.id))]})]})})]}),s.jsx(qn,{open:!!x,onOpenChange:z=>{z||(y(null),w(cr))},children:s.jsxs(jn,{children:[s.jsx(Cn,{children:s.jsx(En,{children:"Edit provider"})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx(be,{children:"Name"}),s.jsx(Ae,{value:S.name,onChange:z=>w({...S,name:z.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Slug (optional)"}),s.jsx(Ae,{value:S.slug,onChange:z=>w({...S,slug:z.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Type"}),s.jsxs(Vn,{value:S.type,onValueChange:z=>w({...S,type:z}),children:[s.jsx(Rn,{children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"openai",children:"OpenAI-compatible"}),s.jsx(lt,{value:"anthropic",children:"Anthropic-compatible"})]})]})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Base URL"}),s.jsx(Ae,{value:S.baseUrl,onChange:z=>w({...S,baseUrl:z.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"API key (leave empty to keep current)"}),s.jsx(Ae,{type:"password",value:S.apiKey,onChange:z=>w({...S,apiKey:z.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Custom headers (JSON)"}),s.jsx(Ae,{value:S.customHeaders,onChange:z=>w({...S,customHeaders:z.target.value}),placeholder:'{"X-Org":"acme"}'})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ba,{checked:S.enabled,onCheckedChange:z=>w({...S,enabled:z})}),s.jsx(be,{children:"Enabled"})]})]}),s.jsxs(In,{children:[s.jsx(he,{variant:"outline",onClick:()=>{y(null),w(cr)},children:"Cancel"}),s.jsx(he,{disabled:h||!S.name,onClick:A,children:"Save changes"})]})]})}),s.jsx(s1,{open:!!C,onOpenChange:z=>{z||E(null)},children:s.jsxs(am,{children:[s.jsxs(i1,{children:[s.jsx(lm,{children:"Delete provider?"}),s.jsx(rm,{children:"This will soft-disable the provider if models depend on it."})]}),s.jsxs(c1,{children:[s.jsx(om,{children:"Cancel"}),s.jsx(sm,{disabled:j,onClick:z=>{C&&(z.preventDefault(),H(C))},children:j?"Deleting…":"Delete"})]})]})})]})}var mD=Object.defineProperty,tl=(a,l)=>mD(a,"name",{value:l,configurable:!0}),pm="Checkbox",[pD,Q_]=fn(pm),[gD,gm]=pD(pm);function j1(a){const{__scopeCheckbox:l,checked:o,children:i,defaultChecked:u,disabled:d,form:h,name:p,onCheckedChange:g,required:v,value:x="on",internal_do_not_use_render:y}=a,[S,w]=Ja({prop:o,defaultProp:u??!1,onChange:g,caller:pm}),[C,E]=m.useState(null),[j,N]=m.useState(null),M=m.useRef(!1),[T,_]=m.useReducer(H=>H+1,0),O=C?!!h||!!C.closest("form"):!0,A={checked:S,disabled:d,setChecked:w,control:C,setControl:E,name:p,form:h,value:x,hasConsumerStoppedPropagationRef:M,userInteractionCount:T,onUserInteraction:_,required:v,defaultChecked:Qa(u)?!1:u,isFormControl:O,bubbleInput:j,setBubbleInput:N};return s.jsx(gD,{scope:l,...A,children:E1(y)?y(A):i})}tl(j1,"CheckboxProvider");var vD="CheckboxTrigger",xD=m.forwardRef(tl(function({__scopeCheckbox:l,onKeyDown:o,onClick:i,...u},d){const{control:h,value:p,disabled:g,checked:v,required:x,setControl:y,setChecked:S,hasConsumerStoppedPropagationRef:w,onUserInteraction:C,isFormControl:E,bubbleInput:j}=gm(vD,l),N=Ie(d,y),M=m.useRef(v);return m.useEffect(()=>{const T=h==null?void 0:h.form;if(T){const _=tl(()=>S(M.current),"reset");return T.addEventListener("reset",_),()=>T.removeEventListener("reset",_)}},[h,S]),s.jsx(Be.button,{type:"button",role:"checkbox","aria-checked":Qa(v)?"mixed":v,"aria-required":x,"data-state":vm(v),"data-disabled":g?"":void 0,disabled:g,value:p,...u,ref:N,onKeyDown:Ee(o,T=>{T.key==="Enter"&&T.preventDefault()}),onClick:Ee(i,T=>{C(),S(_=>Qa(_)?!0:!_),j&&E&&(w.current=T.isPropagationStopped(),w.current||T.stopPropagation())})})},"CheckboxTrigger")),C1=m.forwardRef(tl(function(l,o){const{__scopeCheckbox:i,name:u,checked:d,defaultChecked:h,required:p,disabled:g,value:v,onCheckedChange:x,form:y,...S}=l;return s.jsx(j1,{__scopeCheckbox:i,checked:d,defaultChecked:h,disabled:g,required:p,onCheckedChange:x,name:u,form:y,value:v,internal_do_not_use_render:({isFormControl:w})=>s.jsxs(s.Fragment,{children:[s.jsx(xD,{...S,ref:o,__scopeCheckbox:i}),w&&s.jsx(wD,{__scopeCheckbox:i})]})})},"Checkbox")),yD="CheckboxIndicator",bD=m.forwardRef(tl(function(l,o){const{__scopeCheckbox:i,forceMount:u,...d}=l,h=gm(yD,i);return s.jsx(al,{present:u||Qa(h.checked)||h.checked===!0,children:s.jsx(Be.span,{"data-state":vm(h.checked),"data-disabled":h.disabled?"":void 0,...d,ref:o,style:{pointerEvents:"none",...l.style}})})},"CheckboxIndicator")),SD="CheckboxBubbleInput",wD=m.forwardRef(tl(function({__scopeCheckbox:l,onClick:o,...i},u){const{control:d,hasConsumerStoppedPropagationRef:h,userInteractionCount:p,checked:g,defaultChecked:v,required:x,disabled:y,name:S,value:w,form:C,bubbleInput:E,setBubbleInput:j}=gm(SD,l),N=Ie(u,j),M=Ic(d),T=m.useRef(!1),_=m.useRef(g),O=m.useRef(p);m.useEffect(()=>{const H=E;if(!H)return;const z=window.HTMLInputElement.prototype,se=Object.getOwnPropertyDescriptor(z,"checked").set,X=p!==O.current;O.current=p;const I=_.current!==g;_.current=g;const re=!(X&&h.current);if(I&&se){T.current=!X;const ee=new Event("click",{bubbles:re});H.indeterminate=Qa(g),se.call(H,Qa(g)?!1:g),H.dispatchEvent(ee),T.current=!1}},[E,g,h,p]);const A=m.useRef(Qa(g)?!1:g);return s.jsx(Be.input,{type:"checkbox","aria-hidden":!0,defaultChecked:v??A.current,required:x,disabled:y,name:S,value:w,form:C,...i,tabIndex:-1,ref:N,onClick:Ee(o,H=>{T.current&&H.stopPropagation()}),style:{...i.style,...M,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function E1(a){return typeof a=="function"}tl(E1,"isFunction");function Qa(a){return a==="indeterminate"}tl(Qa,"isIndeterminate");function vm(a){return Qa(a)?"indeterminate":a?"checked":"unchecked"}tl(vm,"getState");const xm=m.forwardRef(({className:a,...l},o)=>s.jsx(C1,{ref:o,className:Re("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",a),...l,children:s.jsx(bD,{className:Re("flex items-center justify-center text-current"),children:s.jsx(Ky,{className:"h-3.5 w-3.5"})})}));xm.displayName=C1.displayName;function jD(){const[a,l]=m.useState([]),[o,i]=m.useState([]),[u,d]=m.useState("all"),[h,p]=m.useState(!1),[g,v]=m.useState(""),[x,y]=m.useState([]),[S,w]=m.useState(new Set),[C,E]=m.useState(!1),[j,N]=m.useState(""),[M,T]=m.useState(""),[_,O]=m.useState(null),[A,H]=m.useState(!1),[z,K]=m.useState(null),[se,X]=m.useState(null),I=async()=>{const[B,Z]=await Promise.all([we.get("/api/admin/models"),we.get("/api/admin/providers")]);l(B.models),i(Z.providers)};m.useEffect(()=>{I()},[]);const re=a.filter(B=>!(u!=="all"&&B.providerId!==u||j&&!B.publicModelId.toLowerCase().includes(j.toLowerCase()))),ee=x.filter(B=>{if(!M)return!0;const Z=M.toLowerCase();return B.upstreamId.toLowerCase().includes(Z)||B.displayName.toLowerCase().includes(Z)}),oe=async()=>{if(g){E(!0);try{const B=await we.post(`/api/admin/providers/${g}/discover`);y(B.models),w(new Set)}catch(B){ve.error(B.message)}finally{E(!1)}}},U=async()=>{if(S.size!==0)try{const B=await we.post("/api/admin/models/import",{providerId:g,modelIds:Array.from(S)});ve.success(`Imported ${B.imported} of ${B.requested}`),p(!1),y([]),w(new Set),I()}catch(B){ve.error(B.message)}},$=async()=>{if(se)try{await we.del(`/api/admin/models/${se.id}`),ve.success("Model deleted"),X(null),I()}catch(B){ve.error(B.message)}},le=async B=>{var D,q,Q;O(B),H(!0);const Z=Date.now();K({phase:"streaming",startedAt:Z,text:"",progress:{}});try{const ae=await globalThis.fetch(`/api/admin/models/${B}/test-stream`,{method:"POST",headers:{"content-type":"application/json"},credentials:"include",body:"{}"});if(!ae.ok){const J=await ae.text().catch(()=>"");K({phase:"error",model:B,error:`HTTP ${ae.status}: ${J}`});return}const ce=(D=ae.body)==null?void 0:D.getReader();if(!ce){K({phase:"error",model:B,error:"No response body"});return}const Se=new TextDecoder;let ue="",fe="",xe=!1;for(;!xe;){const{value:J,done:me}=await ce.read();xe=me,J&&(ue+=Se.decode(J,{stream:!0}));let je;for(;(je=ue.indexOf(`
327
327
 
328
328
  `))>=0;){const Me=ue.slice(0,je);ue=ue.slice(je+2);const mt=Me.split(`
329
- `);let pt="",bt="";for(const St of mt)St.startsWith("event: ")?pt=St.slice(7):St.startsWith("data: ")&&(bt=St.slice(6));if(bt){if(pt===""||pt==="message")try{const Lt=(q=JSON.parse(bt).choices)==null?void 0:q[0];(Q=Lt==null?void 0:Lt.delta)!=null&&Q.content&&(fe+=Lt.delta.content),K(hn=>{if(!hn||hn.phase!=="streaming")return hn;const Qn=Date.now()-Z,mn=hn.progress.ttftMs??Qn;return{...hn,text:fe,progress:{ttftMs:mn,elapsedMs:Qn}}})}catch{}if(pt==="test_meta")try{const St=JSON.parse(bt);K({phase:"done",model:B,result:St,text:fe})}catch{}if(pt==="test_error")try{const St=JSON.parse(bt);K({phase:"error",model:B,error:St.message})}catch{}}}}K(J=>!J||J.phase==="streaming"?{phase:"error",model:B,error:"Stream ended unexpectedly"}:J)}catch(ae){K({phase:"error",model:B,error:ae.message})}finally{O(null)}};return s.jsxs("div",{children:[s.jsx(wa,{title:"Models",description:"Physical models imported from providers",actions:s.jsxs(qn,{open:h,onOpenChange:p,children:[s.jsx(Bo,{asChild:!0,children:s.jsxs(he,{variant:"outline",children:[s.jsx(Xy,{className:"mr-1 h-4 w-4"})," Fetch models"]})}),s.jsxs(jn,{className:"max-w-2xl",children:[s.jsx(Cn,{children:s.jsx(En,{children:"Discover models"})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-end gap-2",children:[s.jsx("div",{className:"flex-1",children:s.jsxs(Vn,{value:g,onValueChange:v,children:[s.jsx(Rn,{children:s.jsx(Gn,{placeholder:"Choose provider"})}),s.jsx(Nn,{children:o.map(B=>s.jsx(lt,{value:B.id,children:B.name},B.id))})]})}),s.jsx(he,{onClick:oe,disabled:!g||C,children:C?"Fetching…":"Fetch"})]}),x.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"flex items-center gap-2 flex-1",children:s.jsxs("div",{className:"relative flex-1",children:[s.jsx(Wy,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),s.jsx(Ae,{className:"pl-8",placeholder:"Search models…",value:M,onChange:B=>T(B.target.value)}),M&&s.jsx("button",{className:"absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",onClick:()=>T(""),children:s.jsx(Oc,{className:"h-4 w-4"})})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-sm text-muted-foreground",children:[ee.length," / ",x.length," · ",S.size," selected"]}),s.jsx(he,{variant:"outline",size:"sm",onClick:()=>w(new Set(ee.filter(B=>!B.alreadyImported).map(B=>B.upstreamId))),children:"Select All (new)"}),s.jsx(he,{variant:"outline",size:"sm",onClick:()=>w(new Set),children:"Clear"})]})]}),s.jsx("div",{className:"max-h-80 space-y-1 overflow-auto rounded border p-2",children:ee.length===0&&x.length>0?s.jsx("div",{className:"text-center text-sm text-muted-foreground py-4",children:"No models match your search."}):ee.map(B=>s.jsxs("label",{className:"flex items-center gap-2 rounded p-1 text-sm hover:bg-accent",children:[s.jsx(xm,{checked:S.has(B.upstreamId),onCheckedChange:Z=>{const D=new Set(S);Z?D.add(B.upstreamId):D.delete(B.upstreamId),w(D)}}),s.jsx("span",{className:"font-mono text-xs",children:B.upstreamId}),B.alreadyImported&&s.jsx(et,{variant:"secondary",children:"imported"})]},B.upstreamId))})]})]}),s.jsxs(In,{children:[s.jsx(he,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),s.jsxs(he,{disabled:S.size===0,onClick:U,children:["Import ",S.size||""]})]})]})]})}),s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"All models"}),s.jsxs(on,{children:[a.length," total"]})]}),s.jsxs(Ze,{children:[s.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[s.jsxs(Vn,{value:u,onValueChange:d,children:[s.jsx(Rn,{className:"w-56",children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"all",children:"All providers"}),o.map(B=>s.jsx(lt,{value:B.id,children:B.name},B.id))]})]}),s.jsx(Ae,{className:"max-w-xs",placeholder:"Search public ID",value:j,onChange:B=>N(B.target.value)})]}),s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Public ID"}),s.jsx(pe,{children:"Provider"}),s.jsx(pe,{children:"Upstream ID"}),s.jsx(pe,{children:"Capabilities"}),s.jsx(pe,{children:"Available"}),s.jsx(pe,{children:"Enabled"}),s.jsx(pe,{})]})}),s.jsxs(Fn,{children:[re.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:7,className:"text-center text-muted-foreground",children:"No models"})}),re.map(B=>s.jsxs(Ye,{children:[s.jsx(de,{className:"font-mono text-xs",children:B.publicModelId}),s.jsx(de,{children:B.providerSlug}),s.jsx(de,{className:"text-xs text-muted-foreground",children:B.upstreamModelId}),s.jsx(de,{className:"space-x-1",children:Object.entries(B.capabilities).filter(([,Z])=>Z===!0).slice(0,4).map(([Z])=>s.jsx(et,{variant:"outline",className:"mr-1",children:Z},Z))}),s.jsx(de,{children:B.upstreamAvailable?s.jsx(et,{variant:"success",children:"up"}):s.jsx(et,{variant:"destructive",children:"down"})}),s.jsx(de,{children:B.enabled?"Yes":"No"}),s.jsx(de,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsxs(he,{size:"sm",variant:"outline",onClick:()=>void le(B.id),disabled:_!==null,children:[_===B.id?s.jsx(jo,{className:"h-3.5 w-3.5 animate-spin"}):s.jsx(uC,{className:"h-3.5 w-3.5"})," Test"]}),s.jsxs(he,{size:"sm",variant:"destructive",onClick:()=>X(B),disabled:_!==null,children:[s.jsx(_c,{className:"h-3.5 w-3.5"})," Xoá"]})]})})]},B.id))]})]})]})]}),s.jsx(qn,{open:!!se,onOpenChange:B=>{B||X(null)},children:s.jsxs(jn,{className:"max-w-md",children:[s.jsx(Cn,{children:s.jsx(En,{children:"Xoá model"})}),s.jsxs("div",{className:"space-y-2 text-sm",children:[s.jsxs("p",{children:["Bạn có chắc muốn xoá model ",s.jsx("span",{className:"font-mono",children:se==null?void 0:se.publicModelId}),"?"]}),s.jsx("p",{className:"text-muted-foreground",children:"Model đang được dùng trong combo sẽ bị soft-disable (vô hiệu hoá) thay vì xoá hẳn, để giữ lịch sử và tham chiếu combo."})]}),s.jsxs(In,{children:[s.jsx(he,{variant:"outline",onClick:()=>X(null),children:"Huỷ"}),s.jsx(he,{variant:"destructive",onClick:$,children:"Xoá"})]})]})}),s.jsx(qn,{open:A,onOpenChange:H,children:s.jsxs(jn,{className:"max-w-2xl",children:[s.jsx(Cn,{children:s.jsx(En,{children:"Kết quả test model"})}),z&&z.phase==="streaming"&&s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(jo,{className:"h-4 w-4 animate-spin"})," Đang stream…",s.jsxs("span",{className:"font-mono text-xs text-muted-foreground/60",children:["TTFT ",z.progress.ttftMs!=null?`${z.progress.ttftMs} ms`:"…"]}),s.jsxs("span",{className:"font-mono text-xs text-muted-foreground/60",children:["· ",z.progress.elapsedMs!=null?`${z.progress.elapsedMs} ms`:"…"]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Phản hồi (streaming)"}),s.jsxs("div",{className:"max-h-60 overflow-auto whitespace-pre-wrap rounded border bg-muted p-3 font-mono text-xs",children:[z.text||s.jsx("span",{className:"text-muted-foreground/60 animate-pulse",children:"waiting for first token…"}),z.phase==="streaming"&&s.jsx("span",{className:"ml-0.5 inline-block h-3.5 w-1.5 animate-pulse bg-primary/70"})]})]})]}),z&&z.phase==="done"&&s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(et,{variant:z.result.success?"success":"destructive",children:z.result.success?"Thành công":"Thất bại"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Thời gian phản hồi"}),s.jsxs("div",{className:"font-mono",children:[z.result.latencyMs," ms"]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"TTFT"}),s.jsx("div",{className:"font-mono",children:z.result.ttftMs!=null?`${z.result.ttftMs} ms`:"—"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Tokens (in / out)"}),s.jsxs("div",{className:"font-mono",children:[z.result.usage.input," / ",z.result.usage.output]})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Phản hồi của model"}),s.jsx("div",{className:"max-h-60 overflow-auto whitespace-pre-wrap rounded border bg-muted p-3 font-mono text-xs",children:z.text||z.result.text||"(trống)"})]}),z.result.attempts.length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Attempts"}),s.jsx("div",{className:"space-y-1",children:z.result.attempts.map((B,Z)=>s.jsxs("div",{className:"flex items-center gap-2 rounded border p-2 text-xs",children:[s.jsx(et,{variant:B.success?"success":"destructive",children:B.success?"OK":"FAIL"}),s.jsxs("span",{className:"font-mono",children:[B.providerName," / ",B.modelId]}),s.jsxs("span",{className:"text-muted-foreground",children:[B.latencyMs," ms"]}),B.failureReason&&s.jsx("span",{className:"text-destructive",children:B.failureReason})]},Z))})]})]}),z&&z.phase==="error"&&s.jsxs("div",{className:"space-y-2 text-sm",children:[s.jsx(et,{variant:"destructive",children:"Thất bại"}),s.jsx("p",{className:"text-destructive",children:z.error})]}),s.jsx(In,{children:s.jsx(he,{variant:"outline",onClick:()=>H(!1),children:"Đóng"})})]})})]})}function CD(){const[a,l]=m.useState([]),[o,i]=m.useState([]),[u,d]=m.useState(!1),[h,p]=m.useState(!1),[g,v]=m.useState(null),[x,y]=m.useState(!1),[S,w]=m.useState(!1),[C,E]=m.useState({name:"",slug:"",mode:"fallback",enabled:!0,members:[]}),[j,N]=m.useState({name:"",slug:"",mode:"fallback",enabled:!0,members:[]}),M=async()=>{const[X,I]=await Promise.all([we.get("/api/admin/combos"),we.get("/api/admin/models")]);l(X.combos),i(I.models)};m.useEffect(()=>{M()},[]);const T=X=>{E(I=>({...I,members:[...I.members,{modelId:X,weight:1,position:I.members.length,enabled:!0}]}))},_=X=>{E(I=>({...I,members:I.members.filter((re,ee)=>ee!==X).map((re,ee)=>({...re,position:ee}))}))},O=async()=>{if(C.members.length===0){ve.error("Add at least one member");return}y(!0);try{await we.post("/api/admin/combos",{name:C.name,slug:C.slug||void 0,mode:C.mode,enabled:C.enabled,members:C.members}),ve.success("Combo created"),d(!1),E({name:"",slug:"",mode:"fallback",enabled:!0,members:[]}),M()}catch(X){ve.error(X.message)}finally{y(!1)}},A=async X=>{try{const re=(await we.get(`/api/admin/combos/${X.id}`)).combo;v(re.id),N({name:re.name,slug:re.slug??"",mode:re.mode,enabled:re.enabled,members:re.members.map(ee=>({modelId:ee.modelId,weight:ee.weight,position:ee.position,enabled:ee.enabled}))}),p(!0)}catch(I){ve.error(I.message)}},H=async()=>{if(g){if(j.members.length===0){ve.error("Add at least one member");return}w(!0);try{await we.patch("/api/admin/combos",{id:g,name:j.name,slug:j.slug||void 0,mode:j.mode,enabled:j.enabled,members:j.members}),ve.success("Combo updated"),p(!1),v(null),M()}catch(X){ve.error(X.message)}finally{w(!1)}}},z=X=>{N(I=>({...I,members:[...I.members,{modelId:X,weight:1,position:I.members.length,enabled:!0}]}))},K=X=>{N(I=>({...I,members:I.members.filter((re,ee)=>ee!==X).map((re,ee)=>({...re,position:ee}))}))},se=async X=>{if(confirm("Delete this combo?"))try{await we.del(`/api/admin/combos/${X}`),ve.success("Combo removed"),M()}catch(I){ve.error(I.message)}};return s.jsxs("div",{children:[s.jsx(wa,{title:"Combos",description:"Virtual models combining physical models",actions:s.jsxs(qn,{open:u,onOpenChange:d,children:[s.jsx(Bo,{asChild:!0,children:s.jsxs(he,{children:[s.jsx(Oo,{className:"mr-1 h-4 w-4"})," New combo"]})}),s.jsxs(jn,{className:"max-w-2xl",children:[s.jsx(Cn,{children:s.jsx(En,{children:"New combo"})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx(be,{children:"Name"}),s.jsx(Ae,{value:C.name,onChange:X=>E({...C,name:X.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Slug (optional — leave empty to use the name as the model ID)"}),s.jsx(Ae,{value:C.slug,onChange:X=>E({...C,slug:X.target.value}),placeholder:"empty → gpt-5.5 · set → combo/gpt-5.5"})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Mode"}),s.jsxs(Vn,{value:C.mode,onValueChange:X=>E({...C,mode:X}),children:[s.jsx(Rn,{children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"fallback",children:"Fallback (ordered)"}),s.jsx(lt,{value:"weighted_round_robin",children:"Weighted round-robin"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ba,{checked:C.enabled,onCheckedChange:X=>E({...C,enabled:X})}),s.jsx(be,{children:"Enabled"})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Members"}),s.jsx(py,{models:o,addedIds:C.members.map(X=>X.modelId),onAdd:T}),s.jsx("div",{className:"mt-2 space-y-1",children:C.members.map((X,I)=>{var re;return s.jsxs("div",{className:"flex items-center gap-2 rounded border p-2 text-sm",children:[s.jsx("span",{className:"font-mono text-xs",children:(re=o.find(ee=>ee.id===X.modelId))==null?void 0:re.publicModelId}),s.jsx(Ae,{type:"number",min:1,value:X.weight,onChange:ee=>{const oe=Number(ee.target.value);E(U=>({...U,members:U.members.map(($,le)=>le===I?{...$,weight:oe}:$)}))},className:"w-20"}),s.jsx(he,{size:"sm",variant:"outline",onClick:()=>_(I),children:"Remove"})]},I)})})]})]}),s.jsxs(In,{children:[s.jsx(he,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),s.jsx(he,{disabled:!C.name||x,onClick:O,children:x?"Creating…":"Create"})]})]})]})}),s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"All combos"}),s.jsxs(on,{children:[a.length," total"]})]}),s.jsx(Ze,{children:s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Public ID"}),s.jsx(pe,{children:"Mode"}),s.jsx(pe,{children:"Members"}),s.jsx(pe,{children:"Healthy"}),s.jsx(pe,{children:"Enabled"}),s.jsx(pe,{})]})}),s.jsxs(Fn,{children:[a.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:6,className:"text-center text-muted-foreground",children:"No combos yet."})}),a.map(X=>s.jsxs(Ye,{children:[s.jsx(de,{className:"font-mono text-xs",children:X.publicModelId}),s.jsx(de,{children:s.jsx(et,{variant:"outline",children:X.mode})}),s.jsx(de,{children:X.memberCount}),s.jsx(de,{children:X.healthyMemberCount}),s.jsx(de,{children:X.enabled?"Yes":"No"}),s.jsx(de,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsxs(he,{size:"sm",variant:"outline",onClick:()=>void A(X),children:[s.jsx(yC,{className:"h-3.5 w-3.5"})," Sửa"]}),s.jsxs(he,{size:"sm",variant:"destructive",onClick:()=>se(X.id),children:[s.jsx(_c,{className:"h-3.5 w-3.5"})," Xoá"]})]})})]},X.id))]})]})})]}),s.jsx(qn,{open:h,onOpenChange:p,children:s.jsxs(jn,{className:"max-w-2xl",children:[s.jsx(Cn,{children:s.jsx(En,{children:"Edit combo"})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx(be,{children:"Name"}),s.jsx(Ae,{value:j.name,onChange:X=>N({...j,name:X.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Slug (optional — leave empty to use the name as the model ID)"}),s.jsx(Ae,{value:j.slug,onChange:X=>N({...j,slug:X.target.value}),placeholder:"empty → gpt-5.5 · set → combo/gpt-5.5"})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Mode"}),s.jsxs(Vn,{value:j.mode,onValueChange:X=>N({...j,mode:X}),children:[s.jsx(Rn,{children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"fallback",children:"Fallback (ordered)"}),s.jsx(lt,{value:"weighted_round_robin",children:"Weighted round-robin"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ba,{checked:j.enabled,onCheckedChange:X=>N({...j,enabled:X})}),s.jsx(be,{children:"Enabled"})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Members"}),s.jsx(py,{models:o,addedIds:j.members.map(X=>X.modelId),onAdd:z}),s.jsx("div",{className:"mt-2 space-y-1",children:j.members.map((X,I)=>{var re;return s.jsxs("div",{className:"flex items-center gap-2 rounded border p-2 text-sm",children:[s.jsx("span",{className:"font-mono text-xs",children:(re=o.find(ee=>ee.id===X.modelId))==null?void 0:re.publicModelId}),s.jsx(Ae,{type:"number",min:1,value:X.weight,onChange:ee=>{const oe=Number(ee.target.value);N(U=>({...U,members:U.members.map(($,le)=>le===I?{...$,weight:oe}:$)}))},className:"w-20"}),s.jsx(he,{size:"sm",variant:"outline",onClick:()=>K(I),children:"Remove"})]},I)})})]})]}),s.jsxs(In,{children:[s.jsx(he,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),s.jsx(he,{disabled:!j.name||S,onClick:H,children:S?"Saving…":"Save"})]})]})})]})}function py({models:a,addedIds:l,onAdd:o}){const[i,u]=m.useState(""),h=(i?a.filter(p=>{const g=i.toLowerCase();return p.publicModelId.toLowerCase().includes(g)||p.displayName.toLowerCase().includes(g)}):a).filter(p=>!l.includes(p.id));return s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Wy,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),s.jsx(Ae,{className:"pl-8",placeholder:"Search models…",value:i,onChange:p=>u(p.target.value)}),i&&s.jsx("button",{className:"absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",onClick:()=>u(""),children:s.jsx(Oc,{className:"h-4 w-4"})})]}),h.length===0?s.jsx("p",{className:"text-xs text-muted-foreground",children:"No models match."}):s.jsx("div",{className:"max-h-40 space-y-1 overflow-auto rounded border p-1",children:h.map(p=>s.jsxs("div",{className:"flex items-center justify-between rounded p-1 text-sm hover:bg-accent",children:[s.jsx("span",{className:"font-mono text-xs",children:p.publicModelId}),s.jsx(he,{size:"sm",variant:"ghost",onClick:()=>o(p.id),children:"+ Add"})]},p.id))})]})}function ED(){const[a,l]=m.useState([]),[o,i]=m.useState([]),[u,d]=m.useState([]),[h,p]=m.useState(!1),[g,v]=m.useState({alias:"",targetKind:"model",targetId:"",enabled:!0}),x=async()=>{const[S,w,C]=await Promise.all([we.get("/api/admin/aliases"),we.get("/api/admin/models"),we.get("/api/admin/combos")]);l(S.aliases),i(w.models),d(C.combos)};m.useEffect(()=>{x()},[]);const y=async()=>{try{await we.post("/api/admin/aliases",g),ve.success("Alias created"),p(!1),v({alias:"",targetKind:"model",targetId:"",enabled:!0}),x()}catch(S){ve.error(S.message)}};return s.jsxs("div",{children:[s.jsx(wa,{title:"Aliases",description:"Stable client-visible names for models or combos",actions:s.jsxs(qn,{open:h,onOpenChange:p,children:[s.jsx(Bo,{asChild:!0,children:s.jsxs(he,{children:[s.jsx(Oo,{className:"mr-1 h-4 w-4"})," New alias"]})}),s.jsxs(jn,{children:[s.jsx(Cn,{children:s.jsx(En,{children:"New alias"})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx(be,{children:"Alias"}),s.jsx(Ae,{value:g.alias,onChange:S=>v({...g,alias:S.target.value}),placeholder:"coding"})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Target type"}),s.jsxs(Vn,{value:g.targetKind,onValueChange:S=>v({...g,targetKind:S}),children:[s.jsx(Rn,{children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"model",children:"Model"}),s.jsx(lt,{value:"combo",children:"Combo"})]})]})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Target"}),s.jsxs(Vn,{value:g.targetId,onValueChange:S=>v({...g,targetId:S}),children:[s.jsx(Rn,{children:s.jsx(Gn,{placeholder:"Choose target"})}),s.jsx(Nn,{children:(g.targetKind==="model"?o:u).map(S=>s.jsx(lt,{value:S.id,children:S.publicModelId},S.id))})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ba,{checked:g.enabled,onCheckedChange:S=>v({...g,enabled:S})}),s.jsx(be,{children:"Enabled"})]})]}),s.jsxs(In,{children:[s.jsx(he,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),s.jsx(he,{disabled:!g.alias||!g.targetId,onClick:y,children:"Create"})]})]})]})}),s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"All aliases"}),s.jsxs(on,{children:[a.length," total"]})]}),s.jsx(Ze,{children:s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Alias"}),s.jsx(pe,{children:"Target"}),s.jsx(pe,{children:"Type"}),s.jsx(pe,{children:"Enabled"}),s.jsx(pe,{})]})}),s.jsxs(Fn,{children:[a.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:5,className:"text-center text-muted-foreground",children:"No aliases yet."})}),a.map(S=>s.jsxs(Ye,{children:[s.jsx(de,{className:"font-mono text-xs",children:S.alias}),s.jsx(de,{className:"font-mono text-xs",children:S.targetName??S.targetId}),s.jsx(de,{children:s.jsx(et,{variant:"outline",children:S.targetKind})}),s.jsx(de,{children:S.enabled?"Yes":"No"}),s.jsx(de,{className:"text-right",children:s.jsx(he,{size:"sm",variant:"outline",onClick:async()=>{await we.del(`/api/admin/aliases/${S.id}`),ve.success("Removed"),x()},children:"Delete"})})]},S.id))]})]})})]})]})}function RD(){const[a,l]=m.useState([]),[o,i]=m.useState([]),[u,d]=m.useState([]),[h,p]=m.useState(!1),[g,v]=m.useState(null),[x,y]=m.useState(null),[S,w]=m.useState(null),[C,E]=m.useState({name:"",expiresAt:"",allowAll:!0,permissions:[],rpmLimit:"",tpmLimit:"",concurrency:"",customSecret:""}),j=async()=>{const[A,H,z]=await Promise.all([we.get("/api/admin/api-keys"),we.get("/api/admin/models"),we.get("/api/admin/combos")]);l(A.apiKeys),i(H.models),d(z.combos)};m.useEffect(()=>{j()},[]);const N=async()=>{try{if(g){await we.patch("/api/admin/api-keys",{id:g,name:C.name,expiresAt:C.expiresAt||null,allowAllModels:C.allowAll,permissions:C.allowAll?[]:C.permissions,rpmLimit:C.rpmLimit?Number(C.rpmLimit):null,tpmLimit:C.tpmLimit?Number(C.tpmLimit):null,maxConcurrent:C.concurrency?Number(C.concurrency):null}),p(!1),v(null),E({name:"",expiresAt:"",allowAll:!0,permissions:[],rpmLimit:"",tpmLimit:"",concurrency:"",customSecret:""}),ve.success("Key updated"),j();return}const A=await we.post("/api/admin/api-keys",{name:C.name,expiresAt:C.expiresAt||null,allowAllModels:C.allowAll,permissions:C.allowAll?void 0:C.permissions,rpmLimit:C.rpmLimit?Number(C.rpmLimit):null,tpmLimit:C.tpmLimit?Number(C.tpmLimit):null,maxConcurrent:C.concurrency?Number(C.concurrency):null,...C.customSecret.trim()?{secret:C.customSecret.trim()}:{}});p(!1),y({secret:A.secret,name:A.name}),E({name:"",expiresAt:"",allowAll:!0,permissions:[],rpmLimit:"",tpmLimit:"",concurrency:"",customSecret:""}),j()}catch(A){ve.error(A.message)}},M=async A=>{try{const z=((await we.get(`/api/admin/api-keys/${A.id}`)).apiKey.permissions??[]).filter(K=>K.targetKind==="model"||K.targetKind==="combo");v(A.id),E({name:A.name,expiresAt:A.expiresAt?A.expiresAt.slice(0,16):"",allowAll:A.allowAllModels,permissions:z,rpmLimit:A.rpmLimit!=null?String(A.rpmLimit):"",tpmLimit:A.tpmLimit!=null?String(A.tpmLimit):"",concurrency:A.concurrencyLimit!=null?String(A.concurrencyLimit):"",customSecret:""}),p(!0)}catch(H){ve.error(H.message)}},T=()=>{p(!1),v(null),E({name:"",expiresAt:"",allowAll:!0,permissions:[],rpmLimit:"",tpmLimit:"",concurrency:"",customSecret:""})},_=async(A,H)=>{try{await we.patch("/api/admin/api-keys",{id:A,enabled:!H}),ve.success(H?"Key disabled":"Key enabled"),j()}catch(z){ve.error(z.message)}},O=async A=>{if(window.confirm("Delete this API key? This cannot be undone."))try{await we.del(`/api/admin/api-keys/${A}`),ve.success("Key deleted"),j()}catch(H){ve.error(H.message)}};return s.jsxs("div",{children:[s.jsx(wa,{title:"API Keys",description:"Gateway bearer keys for client applications",actions:s.jsxs(qn,{open:h,onOpenChange:A=>{A?p(!0):T()},children:[s.jsx(Bo,{asChild:!0,children:s.jsxs(he,{children:[s.jsx(Oo,{className:"mr-1 h-4 w-4"})," New key"]})}),s.jsxs(jn,{className:"max-w-2xl",children:[s.jsx(Cn,{children:s.jsx(En,{children:g?"Edit API key":"New API key"})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx(be,{children:"Name"}),s.jsx(Ae,{value:C.name,onChange:A=>E({...C,name:A.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Expires (optional)"}),s.jsx(Ae,{type:"datetime-local",value:C.expiresAt,onChange:A=>E({...C,expiresAt:A.target.value})})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[s.jsxs("div",{children:[s.jsx(be,{children:"RPM limit"}),s.jsx(Ae,{value:C.rpmLimit,onChange:A=>E({...C,rpmLimit:A.target.value}),type:"number"})]}),s.jsxs("div",{children:[s.jsx(be,{children:"TPM limit"}),s.jsx(Ae,{value:C.tpmLimit,onChange:A=>E({...C,tpmLimit:A.target.value}),type:"number"})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Concurrency"}),s.jsx(Ae,{value:C.concurrency,onChange:A=>E({...C,concurrency:A.target.value}),type:"number"})]})]}),!g&&s.jsxs("div",{children:[s.jsx(be,{children:"Key value (optional)"}),s.jsx(Ae,{value:C.customSecret,onChange:A=>E({...C,customSecret:A.target.value}),placeholder:"Leave empty to auto-generate ld-…"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"If provided, this exact value is stored as the key. Otherwise a random ld-… key is generated."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ba,{checked:C.allowAll,onCheckedChange:A=>E({...C,allowAll:A})}),s.jsx(be,{children:"Allow all current and future models"})]}),!C.allowAll&&s.jsxs("div",{children:[s.jsx(be,{children:"Scope"}),s.jsx("div",{className:"max-h-48 space-y-1 overflow-auto rounded border p-2",children:[...o.map(A=>({targetKind:"model",targetId:A.id,label:A.publicModelId})),...u.map(A=>({targetKind:"combo",targetId:A.id,label:A.publicModelId}))].map(A=>{const H=C.permissions.some(z=>z.targetKind===A.targetKind&&z.targetId===A.targetId);return s.jsxs("label",{className:"flex items-center gap-2 rounded p-1 text-sm hover:bg-accent",children:[s.jsx(xm,{checked:H,onCheckedChange:z=>{E(K=>({...K,permissions:z?[...K.permissions,{targetKind:A.targetKind,targetId:A.targetId}]:K.permissions.filter(se=>!(se.targetKind===A.targetKind&&se.targetId===A.targetId))}))}}),s.jsx("span",{className:"font-mono text-xs",children:A.label}),s.jsx(et,{variant:"outline",className:"ml-1",children:A.targetKind})]},`${A.targetKind}:${A.targetId}`)})})]})]}),s.jsxs(In,{children:[s.jsx(he,{variant:"outline",onClick:T,children:"Cancel"}),s.jsx(he,{disabled:!C.name,onClick:N,children:g?"Save changes":"Create"})]})]})]})}),s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"All keys"}),s.jsxs(on,{children:[a.length," total"]})]}),s.jsx(Ze,{children:s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Name"}),s.jsx(pe,{children:"Prefix"}),s.jsx(pe,{children:"Status"}),s.jsx(pe,{children:"Scope"}),s.jsx(pe,{children:"RPM/TPM/Conc"}),s.jsx(pe,{})]})}),s.jsxs(Fn,{children:[a.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:6,className:"text-center text-muted-foreground",children:"No API keys yet."})}),a.map(A=>s.jsxs(Ye,{children:[s.jsx(de,{className:"font-medium",children:A.name}),s.jsxs(de,{className:"font-mono text-xs",children:[A.keyPrefix,"…"]}),s.jsx(de,{children:A.enabled?s.jsx(et,{variant:"success",children:"enabled"}):s.jsx(et,{variant:"destructive",children:"disabled"})}),s.jsx(de,{children:A.allowAllModels?"all":`${A.modelScopeCount} scoped`}),s.jsx(de,{className:"text-xs",children:[A.rpmLimit,A.tpmLimit,A.concurrencyLimit].map((H,z)=>H?["","RPM","TPM","Conc"][z+1]:null).filter(Boolean).join(" / ")||"—"}),s.jsx(de,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[A.secret&&s.jsxs(s.Fragment,{children:[s.jsx(he,{size:"sm",variant:"ghost",title:"Copy secret",onClick:()=>{navigator.clipboard.writeText(A.secret),ve.success("Copied")},children:s.jsx(Ef,{className:"h-3.5 w-3.5"})}),s.jsx(he,{size:"sm",variant:"ghost",title:"Show secret",onClick:()=>w({secret:A.secret,name:A.name}),children:s.jsx(iC,{className:"h-3.5 w-3.5"})})]}),s.jsx(he,{size:"sm",variant:"ghost",title:"Edit",onClick:()=>void M(A),children:s.jsx(mC,{className:"h-3.5 w-3.5"})}),s.jsxs(he,{size:"sm",variant:"outline",onClick:()=>_(A.id,A.enabled),children:[A.enabled?s.jsx(Z2,{className:"mr-1 h-3.5 w-3.5"}):s.jsx(Dc,{className:"mr-1 h-3.5 w-3.5"}),A.enabled?"Disable":"Enable"]}),s.jsx(he,{size:"sm",variant:"destructive",onClick:()=>O(A.id),children:s.jsx(_c,{className:"h-3.5 w-3.5"})})]})})]},A.id))]})]})})]}),s.jsx(qn,{open:!!x,onOpenChange:A=>{A||y(null)},children:s.jsxs(jn,{children:[s.jsxs(Cn,{children:[s.jsx(En,{children:"API key created"}),s.jsx(ch,{children:"Copy now — this secret will not be shown again."})]}),s.jsx("div",{className:"rounded border bg-muted p-3 font-mono text-xs break-all",children:x==null?void 0:x.secret}),s.jsxs(In,{children:[s.jsxs(he,{onClick:()=>{x&&(navigator.clipboard.writeText(x.secret),ve.success("Copied"))},children:[s.jsx(Ef,{className:"mr-1 h-4 w-4"})," Copy"]}),s.jsx(he,{variant:"outline",onClick:()=>y(null),children:"I have saved it"})]})]})}),s.jsx(qn,{open:!!S,onOpenChange:A=>{A||w(null)},children:s.jsxs(jn,{children:[s.jsxs(Cn,{children:[s.jsxs(En,{children:["API key: ",S==null?void 0:S.name]}),s.jsx(ch,{children:"Full secret for this key, readable any time."})]}),s.jsx("div",{className:"rounded border bg-muted p-3 font-mono text-xs break-all",children:S==null?void 0:S.secret}),s.jsxs(In,{children:[s.jsxs(he,{onClick:()=>{S&&(navigator.clipboard.writeText(S.secret),ve.success("Copied"))},children:[s.jsx(Ef,{className:"mr-1 h-4 w-4"})," Copy"]}),s.jsx(he,{variant:"outline",onClick:()=>w(null),children:"Close"})]})]})})]})}const ND=3e3;function TD(a,l){return!(l.success!=="all"&&a.success!==(l.success==="true")||l.protocol!=="all"&&a.protocol!==l.protocol||l.streaming!=="all"&&a.streaming!==(l.streaming==="true")||l.model&&!a.requestedModel.toLowerCase().includes(l.model.toLowerCase()))}function AD(){const[a,l]=m.useState([]),[o,i]=m.useState(0),[u,d]=m.useState(0),[h,p]=m.useState({success:"all",protocol:"all",streaming:"all",model:""}),[g,v]=m.useState(null),[x,y]=m.useState(null),[S,w]=m.useState(0),C=50,E=m.useRef(Date.now()),j=m.useRef(new Set),N=m.useRef(h);N.current=h;const M=m.useRef(u);M.current=u;const T=m.useCallback(async()=>{const O=new URLSearchParams;O.set("limit",String(C)),O.set("offset",String(u)),h.success!=="all"&&O.set("success",h.success),h.protocol!=="all"&&O.set("protocol",h.protocol),h.streaming!=="all"&&O.set("streaming",h.streaming),h.model&&O.set("requestedModel",h.model);const A=await we.get(`/api/admin/requests?${O.toString()}`);l(A.requests),i(A.total);for(const H of A.requests)j.current.add(H.id)},[u,h]);m.useEffect(()=>{T()},[T]),m.useEffect(()=>{w(0)},[u,h]),m.useEffect(()=>{let O=!1,A=null;const H=new Set,z=()=>{O||(A=new EventSource(`/api/admin/requests/stream?since=${E.current}`),A.addEventListener("request",K=>{if(!O)try{const se=JSON.parse(K.data),X=new Date(se.createdAt).getTime();if(Number.isFinite(X)&&(E.current=Math.max(E.current,X)),j.current.has(se.id))return;j.current.add(se.id),w(I=>I+1),M.current===0&&TD(se,N.current)&&(l(I=>I.some(re=>re.id===se.id)?I:[se,...I].slice(0,C)),i(I=>I+1))}catch{}}),A.onerror=()=>{A==null||A.close(),A=null,O||H.add(setTimeout(z,ND))})};return z(),()=>{O=!0,A==null||A.close();for(const K of H)clearTimeout(K);H.clear()}},[]);const _=async O=>{v(O);const A=await we.get(`/api/admin/requests/${O}`);y(A)};return s.jsxs("div",{children:[s.jsx(wa,{title:"Requests",description:`${o} matching · live updates`}),s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(Vn,{value:h.success,onValueChange:O=>{d(0),p({...h,success:O})},children:[s.jsx(Rn,{className:"w-36",children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"all",children:"All"}),s.jsx(lt,{value:"true",children:"Success"}),s.jsx(lt,{value:"false",children:"Failed"})]})]}),s.jsxs(Vn,{value:h.protocol,onValueChange:O=>{d(0),p({...h,protocol:O})},children:[s.jsx(Rn,{className:"w-32",children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"all",children:"Any protocol"}),s.jsx(lt,{value:"openai",children:"OpenAI"}),s.jsx(lt,{value:"anthropic",children:"Anthropic"})]})]}),s.jsxs(Vn,{value:h.streaming,onValueChange:O=>{d(0),p({...h,streaming:O})},children:[s.jsx(Rn,{className:"w-32",children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"all",children:"Any"}),s.jsx(lt,{value:"true",children:"Streaming"}),s.jsx(lt,{value:"false",children:"Non-stream"})]})]}),s.jsx(Ae,{className:"max-w-xs",placeholder:"Model contains…",value:h.model,onChange:O=>{d(0),p({...h,model:O.target.value})}}),S>0&&s.jsxs(he,{size:"sm",variant:"secondary",onClick:()=>{w(0),T()},children:[S," new request",S>1?"s":""," — refresh"]})]}),s.jsx(Qe,{className:"mt-3 text-base",children:"Results"})]}),s.jsxs(Ze,{children:[s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Time"}),s.jsx(pe,{children:"Status"}),s.jsx(pe,{children:"Requested"}),s.jsx(pe,{children:"Final"}),s.jsx(pe,{children:"Tokens"}),s.jsx(pe,{children:"Latency"}),s.jsx(pe,{children:"Attempts"}),s.jsx(pe,{children:"Key"}),s.jsx(pe,{children:"IP"}),s.jsx(pe,{})]})}),s.jsxs(Fn,{children:[a.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:10,className:"text-center text-muted-foreground",children:"No requests yet."})}),a.map(O=>s.jsxs(Ye,{className:"cursor-pointer",onClick:()=>_(O.id),children:[s.jsx(de,{className:"text-xs",children:Ah(O.createdAt)}),s.jsx(de,{children:O.success?s.jsx(et,{variant:"success",children:O.httpStatus}):s.jsx(et,{variant:"destructive",children:O.httpStatus})}),s.jsx(de,{className:"font-mono text-xs",children:O.requestedModel}),s.jsx(de,{className:"font-mono text-xs text-muted-foreground",children:O.finalModelPublicId??"—"}),s.jsxs(de,{className:"text-xs",children:[Mt(O.inputTokens+O.outputTokens)," ",O.cacheReadTokens?s.jsxs("span",{className:"text-amber-600",children:["(+",O.cacheReadTokens," cache)"]}):null]}),s.jsxs(de,{className:"text-xs",children:[dr(O.totalLatencyMs),O.ttftMs?s.jsxs("span",{className:"text-muted-foreground",children:[" · ttft ",O.ttftMs,"ms"]}):null]}),s.jsxs(de,{className:"text-xs",children:[O.attemptsCount,O.gatewayCacheHit?s.jsx(et,{variant:"secondary",className:"ml-1",children:"cache"}):null]}),s.jsx(de,{className:"text-xs",children:O.apiKeyName??"—"}),s.jsx(de,{className:"text-xs",children:O.clientIp}),s.jsx(de,{className:"text-right",children:s.jsx(he,{size:"sm",variant:"ghost",children:"View"})})]},O.id))]})]}),s.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[s.jsxs("span",{className:"text-xs text-muted-foreground",children:["Showing ",u+1,"–",Math.min(u+C,o)," of ",o]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(he,{size:"sm",variant:"outline",disabled:u===0,onClick:()=>d(Math.max(0,u-C)),children:"Prev"}),s.jsx(he,{size:"sm",variant:"outline",disabled:u+C>=o,onClick:()=>d(u+C),children:"Next"})]})]})]})]}),s.jsx(qn,{open:!!g,onOpenChange:O=>{O||(v(null),y(null))},children:s.jsxs(jn,{className:"max-w-3xl",children:[s.jsx(Cn,{children:s.jsxs(En,{children:["Request ",nE(g,16)]})}),x?s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-muted-foreground text-xs",children:"Status"}),x.request.success?s.jsx(et,{variant:"success",children:x.request.httpStatus}):s.jsx(et,{variant:"destructive",children:x.request.httpStatus})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-muted-foreground text-xs",children:"Latency"}),dr(x.request.totalLatencyMs)]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-muted-foreground text-xs",children:"Tokens"}),"in ",Mt(x.request.inputTokens)," · out ",Mt(x.request.outputTokens)," · cache ",Mt(x.request.cacheReadTokens)]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-muted-foreground text-xs",children:"Attempts"}),x.request.attemptsCount]})]}),x.request.errorType&&s.jsxs("div",{className:"rounded border border-destructive/40 bg-destructive/10 p-2",children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Error"}),s.jsxs("div",{className:"font-mono text-xs",children:[x.request.errorType,": ",x.request.errorMessage]})]}),x.request.requestPayload&&s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Request content"}),s.jsx("pre",{className:"max-h-60 overflow-auto rounded bg-muted p-2 font-mono text-xs whitespace-pre-wrap",children:x.request.requestPayload})]}),x.request.responsePayload&&s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Response content"}),s.jsx("pre",{className:"max-h-60 overflow-auto rounded bg-muted p-2 font-mono text-xs whitespace-pre-wrap",children:x.request.responsePayload})]}),x.attempts.length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Attempts"}),s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"#"}),s.jsx(pe,{children:"Provider"}),s.jsx(pe,{children:"Model"}),s.jsx(pe,{children:"Status"}),s.jsx(pe,{children:"Latency"}),s.jsx(pe,{children:"Reason"})]})}),s.jsx(Fn,{children:x.attempts.map(O=>s.jsxs(Ye,{children:[s.jsx(de,{children:O.attemptNumber}),s.jsx(de,{children:O.providerName}),s.jsx(de,{className:"font-mono text-xs",children:O.modelPublicId}),s.jsx(de,{children:O.success?s.jsx(et,{variant:"success",children:String(O.statusCode??"OK")}):s.jsx(et,{variant:"destructive",children:String(O.statusCode??"err")})}),s.jsx(de,{className:"text-xs",children:dr(O.latencyMs)}),s.jsx(de,{className:"text-xs",children:O.failureReason??O.selectionReason})]},O.id))})]})]})]}):s.jsx("div",{className:"text-muted-foreground",children:"Loading…"})]})})]})}var MD=Object.defineProperty,Rs=(a,l)=>MD(a,"name",{value:l,configurable:!0}),ym="Tabs",[DD,Z_]=fn(ym,[Yc]),R1=Yc(),[_D,bm]=DD(ym),OD=m.forwardRef(Rs(function(l,o){const{__scopeTabs:i,value:u,onValueChange:d,defaultValue:h,orientation:p="horizontal",dir:g,activationMode:v="automatic",...x}=l,y=zo(g),[S,w]=Ja({prop:u,onChange:d,defaultProp:h??"",caller:ym});return s.jsx(_D,{scope:i,baseId:ga(),value:S,onValueChange:w,orientation:p,dir:y,activationMode:v,children:s.jsx(Be.div,{dir:y,"data-orientation":p,...x,ref:o})})},"Tabs")),kD="TabsList",zD=m.forwardRef(Rs(function(l,o){const{__scopeTabs:i,loop:u=!0,...d}=l,h=bm(kD,i),p=R1(i);return s.jsx(hb,{asChild:!0,...p,orientation:h.orientation,dir:h.dir,loop:u,children:s.jsx(Be.div,{role:"tablist","aria-orientation":h.orientation,...d,ref:o})})},"TabsList")),LD="TabsTrigger",UD=m.forwardRef(Rs(function(l,o){const{__scopeTabs:i,value:u,disabled:d=!1,...h}=l,p=bm(LD,i),g=R1(i),v=Sm(p.baseId,u),x=wm(p.baseId,u),y=u===p.value;return s.jsx(mb,{asChild:!0,...g,focusable:!d,active:y,children:s.jsx(Be.button,{type:"button",role:"tab","aria-selected":y,"aria-controls":x,"data-state":y?"active":"inactive","data-disabled":d?"":void 0,disabled:d,id:v,...h,ref:o,onMouseDown:Ee(l.onMouseDown,S=>{!d&&S.button===0&&S.ctrlKey===!1?p.onValueChange(u):S.preventDefault()}),onKeyDown:Ee(l.onKeyDown,S=>{d||S.target!==S.currentTarget||[" ","Enter"].includes(S.key)&&p.onValueChange(u)}),onFocus:Ee(l.onFocus,()=>{const S=p.activationMode!=="manual";!y&&!d&&S&&p.onValueChange(u)})})})},"TabsTrigger")),BD="TabsContent",HD=m.forwardRef(Rs(function(l,o){const{__scopeTabs:i,value:u,forceMount:d,children:h,...p}=l,g=bm(BD,i),v=Sm(g.baseId,u),x=wm(g.baseId,u),y=u===g.value,S=m.useRef(y);return m.useEffect(()=>{const w=requestAnimationFrame(()=>S.current=!1);return()=>cancelAnimationFrame(w)},[]),s.jsx(al,{present:d||y,children:({present:w})=>s.jsx(Be.div,{"data-state":y?"active":"inactive","data-orientation":g.orientation,role:"tabpanel","aria-labelledby":v,hidden:!w,id:x,tabIndex:0,...p,ref:o,style:{...l.style,animationDuration:S.current?"0s":void 0},children:w&&h})})},"TabsContent"));function Sm(a,l){return`${a}-trigger-${l}`}Rs(Sm,"makeTriggerId");function wm(a,l){return`${a}-content-${l}`}Rs(wm,"makeContentId");var PD=OD,N1=zD,T1=UD,A1=HD;const M1=PD,jm=m.forwardRef(({className:a,...l},o)=>s.jsx(N1,{ref:o,className:Re("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",a),...l}));jm.displayName=N1.displayName;const Ka=m.forwardRef(({className:a,...l},o)=>s.jsx(T1,{ref:o,className:Re("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",a),...l}));Ka.displayName=T1.displayName;const ds=m.forwardRef(({className:a,...l},o)=>s.jsx(A1,{ref:o,className:Re("mt-2 ring-offset-background focus-visible:outline-none",a),...l}));ds.displayName=A1.displayName;const qD=3e3,ID=1600,VD=10,GD=3,YD=12,$D=10*6e4;function KD(a,l){return{...a,totalRequests:a.totalRequests+1,successfulRequests:a.successfulRequests+(l.success?1:0),failedRequests:a.failedRequests+(l.success?0:1),successRate:a.totalRequests+1?(a.successfulRequests+(l.success?1:0))/(a.totalRequests+1):0,inputTokens:a.inputTokens+l.inputTokens,outputTokens:a.outputTokens+l.outputTokens,totalTokens:a.totalTokens+l.inputTokens+l.outputTokens,cacheReadTokens:a.cacheReadTokens+l.cacheReadTokens,averageLatencyMs:(a.averageLatencyMs*a.totalRequests+l.totalLatencyMs)/(a.totalRequests+1)}}function XD(a){const[l,o]=m.useState(null),[i,u]=m.useState(null),[d,h]=m.useState([]),[p,g]=m.useState([]),[v,x]=m.useState([]),[y,S]=m.useState([]),[w,C]=m.useState(!0),[E,j]=m.useState(null),N=m.useRef([]),M=m.useRef(null),T=m.useRef(new Set),_=m.useRef(Date.now()),O=m.useRef(0),A=m.useRef([]),H=m.useRef([]);return m.useEffect(()=>{let z=!1;return C(!0),j(null),T.current=new Set,_.current=Date.now(),we.get(`/api/admin/stats?preset=${a}`).then(K=>{if(!z){o(K),u(K.summary),M.current=K.summary,h(K.recent),g(K.providers),N.current=K.providers;for(const se of K.recent)T.current.add(se.id);C(!1)}}).catch(K=>{z||(j(K.message),C(!1))}),()=>{z=!0}},[a]),m.useEffect(()=>{let z=!1,K=null;const se=new Set,X=()=>{z||(K=new EventSource(`/api/admin/requests/stream?since=${_.current}`),K.addEventListener("request",re=>{if(!z)try{const ee=JSON.parse(re.data),oe=new Date(ee.createdAt).getTime();if(Number.isFinite(oe)&&(_.current=Math.max(_.current,oe)),T.current.has(ee.id))return;if(T.current.add(ee.id),M.current&&u(KD(M.current,ee)),h(U=>U.some($=>$.id===ee.id)?U:[ee,...U].slice(0,VD)),ee.providerId){N.current=N.current.map(B=>B.id===ee.providerId?{...B,requests:B.requests+1,errorRate:B.requests+1?(B.errorRate*B.requests+(ee.success?0:1))/(B.requests+1):0}:B),g(N.current);const U=`p${++O.current}`,$={id:U,providerId:ee.providerId,success:ee.success};A.current=[...A.current.slice(-(GD*4)),$],x(A.current);const le=setTimeout(()=>{A.current=A.current.filter(B=>B.id!==U),x(A.current)},ID);se.add(le)}H.current.some(U=>U.id===ee.id)&&(H.current=H.current.filter(U=>U.id!==ee.id),S(H.current))}catch{}}),K.addEventListener("request_started",re=>{if(!z)try{const ee=JSON.parse(re.data);if(!ee.providerId||ee.providerId==="")return;H.current=[...H.current.filter(oe=>oe.id!==ee.requestId).slice(-(YD-1)),{id:ee.requestId,providerId:ee.providerId,startedAt:Date.now(),ttftMs:ee.ttftMs??0}],S(H.current)}catch{}}),K.onerror=()=>{K==null||K.close(),K=null,z||se.add(setTimeout(X,qD))})};X();const I=setInterval(()=>{const re=Date.now()-$D;H.current.some(ee=>ee.startedAt<re)&&(H.current=H.current.filter(ee=>ee.startedAt>=re),S(H.current))},3e4);return()=>{z=!0,K==null||K.close();for(const re of se)clearTimeout(re);se.clear(),clearInterval(I)}},[]),m.useEffect(()=>{const z=setInterval(()=>{we.get("/api/admin/providers").then(K=>{const se=new Map(K.providers.map(X=>[X.id,X]));N.current=N.current.map(X=>{const I=se.get(X.id);return I?{...X,health:I.health,enabled:I.enabled}:X}),g(N.current)}).catch(()=>{})},3e4);return()=>clearInterval(z)},[]),{snapshot:l,live:i??(l==null?void 0:l.summary)??FD,recent:d,providers:p,pulses:v,activeRoutes:y,loading:w,error:E}}const FD={totalRequests:0,successfulRequests:0,failedRequests:0,successRate:0,inputTokens:0,outputTokens:0,totalTokens:0,cacheReadTokens:0,cacheWriteTokens:0,reasoningTokens:0,averageLatencyMs:0,p95LatencyMs:0,averageTtftMs:null,p95TtftMs:null,cacheHitRate:0,gatewayCacheHitRate:0,fallbackRate:0};function D1({data:a,className:l,strokeClass:o="stroke-primary",fillClass:i}){if(a.length===0)return s.jsx("svg",{className:Re("h-6 w-20",l),viewBox:"0 0 80 24"});const h=Math.max(...a),p=Math.min(...a),g=h-p||1,x=a.map((y,S)=>{const w=S/(a.length-1)*78+1,C=22-(y-p)/g*20;return`${w.toFixed(1)},${C.toFixed(1)}`}).join(" ");return s.jsxs("svg",{className:Re("h-6 w-20",l),viewBox:"0 0 80 24",preserveAspectRatio:"none",children:[i&&s.jsx("polygon",{points:`1,23 ${x} 79,23`,className:i}),s.jsx("polyline",{points:x,fill:"none",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:o})]})}function QD(a,l,o){const i=performance.now();let u=0;const d=h=>{const p=Math.min((h-i)/l,1),g=Math.round(a*p);g!==u&&(u=g,o(g)),p<1&&requestAnimationFrame(d)};requestAnimationFrame(d)}function ZD({delta:a,inverse:l}){if(Math.abs(a)<.005)return null;const o=a>0,i=l?!o:o,u=`${(Math.abs(a)*100).toFixed(1)}%`;return s.jsxs("span",{className:Re("ml-1.5 inline-flex items-center rounded-full px-1.5 py-0.5 text-[10px] font-semibold leading-none",i?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300":"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300"),children:[s.jsx("span",{className:"mr-0.5",children:o?"▲":"▼"}),u]})}function Ol({icon:a,label:l,value:o,format:i="number",delta:u,deltaInverse:d,sparkData:h,sparkStroke:p}){const[g,v]=m.useState(0),x=m.useRef(0);m.useEffect(()=>{const S=x.current,w=o;x.current=o,S!==w&&QD(Math.abs(w-S),600,C=>v(S+(w>S?C:-C)))},[o]);const y=i==="percent"?kc(g):i==="latency"?dr(g):Mt(Math.round(g));return s.jsxs(Xe,{children:[s.jsxs(Fe,{className:"flex flex-row items-center justify-between pb-1",children:[s.jsxs(Qe,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:[s.jsx(a,{className:"h-4 w-4"}),l]}),u!==void 0&&s.jsx(ZD,{delta:u,inverse:d})]}),s.jsxs(Ze,{className:"flex items-end justify-between",children:[s.jsx("span",{className:"text-2xl font-semibold tabular-nums",children:y}),h&&h.length>1&&s.jsx(D1,{data:h,strokeClass:p??"stroke-primary",fillClass:"fill-primary/10"})]})]})}const _1=1e3,gy=380,uc=60,kl=_1/2,zl=720,Hf=62,JD=260;function WD(a){return a==="healthy"?"fill-emerald-400":a==="degraded"?"fill-amber-400":"fill-red-400"}function dc(a,l,o,i){const u=a+(o-a)*.45,d=a+(o-a)*.55;return`M${a},${l} C${u},${l} ${d},${i} ${o},${i}`}function e_({liveRequests:a,successRate:l,providers:o,pulses:i,activeRoutes:u}){const d=gy/2,h=d,p=Math.max(1,o.reduce((x,y)=>x+y.requests,0)),g=new Set(u.map(x=>x.providerId)),v=g.size>0;return s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-2",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Qe,{className:"text-base",children:"Real-time Request Routing"}),s.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-emerald-400"})," healthy"]}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-amber-400"})," degraded"]}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-red-400"})," down"]})]})]})}),s.jsx(Ze,{className:"pt-0",children:s.jsx("div",{className:"relative w-full",children:s.jsxs("svg",{viewBox:`0 0 ${_1} ${gy}`,className:"w-full h-auto",preserveAspectRatio:"xMidYMid meet",children:[s.jsx("defs",{children:s.jsxs("filter",{id:"glow",x:"-50%",y:"-50%",width:"200%",height:"200%",children:[s.jsx("feGaussianBlur",{stdDeviation:"3",result:"blur"}),s.jsxs("feMerge",{children:[s.jsx("feMergeNode",{in:"blur"}),s.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),o.map(x=>{const S=60+o.indexOf(x)*Hf,w=x.requests/p,C=Math.max(1.5,Math.min(6,2+w*8)),E=g.has(x.id);return s.jsxs("g",{children:[E&&s.jsx("path",{d:dc(kl,d,zl-20,S),fill:"none",stroke:"hsl(var(--primary) / 0.25)",strokeWidth:C+6,strokeLinecap:"round"}),s.jsx("path",{d:dc(kl,d,zl-20,S),fill:"none",stroke:E?"hsl(var(--primary))":"hsl(var(--border))",strokeWidth:E?C+1:C,strokeLinecap:"round",opacity:E?.95:.6,className:E?"route-active":void 0})]},x.id)}),s.jsx("path",{d:dc(uc+30,h,kl-30,d),fill:"none",stroke:v?"hsl(var(--primary))":"hsl(var(--border))",strokeWidth:3,strokeLinecap:"round",strokeDasharray:"6 3",opacity:v?.9:.5,className:v?"route-active":void 0}),i.map(x=>{const y=o.findIndex(E=>E.id===x.providerId);if(y===-1)return null;const S=60+y*Hf,w=dc(kl,d,zl-20,S),C=x.success?"var(--primary)":"#f87171";return s.jsxs("g",{filter:"url(#glow)",children:[s.jsx("circle",{r:5,fill:C,opacity:.9,children:s.jsx("animateMotion",{dur:"1.4s",fill:"freeze",path:w})}),s.jsx("circle",{r:9,fill:C,opacity:.25,children:s.jsx("animateMotion",{dur:"1.4s",fill:"freeze",path:w})})]},x.id)}),s.jsx("circle",{cx:uc,cy:h,r:28,fill:"hsl(var(--card))",stroke:"hsl(var(--border))",strokeWidth:1.5}),s.jsx("text",{x:uc,y:h-4,textAnchor:"middle",className:"fill-foreground",fontSize:12,fontWeight:600,children:vy(a)}),s.jsx("text",{x:uc,y:h+10,textAnchor:"middle",className:"fill-muted-foreground",fontSize:9,children:"requests"}),s.jsx("circle",{cx:kl,cy:d,r:36,fill:"hsl(var(--card))",stroke:"var(--primary)",strokeWidth:2}),s.jsx("image",{x:kl-12,y:d-16,width:24,height:24,href:"/logo.png"}),s.jsx("text",{x:kl,y:d+28,textAnchor:"middle",className:"fill-muted-foreground",fontSize:9,children:"AI Gateway"}),s.jsxs("text",{x:kl,y:d+38,textAnchor:"middle",className:"fill-emerald-500",fontSize:10,fontWeight:600,children:[(l*100).toFixed(1),"%"]}),o.map((x,y)=>{const S=60+y*Hf,w=x.requests/p,C=!x.enabled||x.requests===0;return s.jsxs("g",{opacity:C?.4:1,children:[s.jsx("rect",{x:zl-20,y:S-14,width:JD,height:50,rx:8,fill:"hsl(var(--card))",stroke:"hsl(var(--border))",strokeWidth:1}),s.jsx("circle",{cx:zl-6,cy:S+10,r:4,className:WD(x.health)}),s.jsx("text",{x:zl+6,y:S-2,className:"fill-foreground",fontSize:12,fontWeight:500,children:x.name}),s.jsxs("text",{x:zl+6,y:S+12,className:"fill-muted-foreground",fontSize:10,children:[x.modelCount," model",x.modelCount!==1?"s":""," · ",vy(x.requests)," req"]}),s.jsxs("text",{x:zl+6,y:S+25,className:"fill-muted-foreground",fontSize:10,children:[(w*100).toFixed(1),"% traffic · ",x.avgLatencyMs<1e3?`${Math.round(x.avgLatencyMs)}ms`:`${(x.avgLatencyMs/1e3).toFixed(1)}s`," avg",x.errorRate>0&&s.jsxs("tspan",{className:"fill-red-500",children:[" · ",(x.errorRate*100).toFixed(0),"% err"]})]})]},x.id)})]})})})]})}function vy(a){return a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:String(a)}function t_({rows:a}){return s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-2",children:s.jsx(Qe,{className:"text-base",children:"Recent Requests"})}),s.jsx(Ze,{children:a.length===0?s.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"No requests yet — traffic will appear here live."}):s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Model"}),s.jsx(pe,{children:"Provider"}),s.jsx(pe,{children:"Tokens"}),s.jsx(pe,{children:"Status"}),s.jsx(pe,{children:"Time"})]})}),s.jsx(Fn,{children:a.map(l=>s.jsxs(Ye,{children:[s.jsx(de,{className:"font-mono text-xs",children:l.requestedModel}),s.jsx(de,{className:"text-xs text-muted-foreground",children:l.providerName??"—"}),s.jsxs(de,{className:"text-xs",children:[s.jsxs("span",{className:"font-mono",children:["in ",Mt(l.inputTokens)," · out ",Mt(l.outputTokens)]}),l.cacheReadTokens>0&&s.jsxs("span",{className:"ml-1 text-amber-600",children:["(+",Mt(l.cacheReadTokens)," cache)"]})]}),s.jsx(de,{children:s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:l.success?"h-2 w-2 rounded-full bg-emerald-400":"h-2 w-2 rounded-full bg-red-400"}),s.jsx("span",{className:"text-xs",children:l.success?l.httpStatus:`${l.httpStatus} err`})]})}),s.jsx(de,{className:"text-xs text-muted-foreground",children:aE(l.createdAt)})]},l.id))})]})})]})}const fh=34,xy=2*Math.PI*fh;function n_(a){return a>=.95?{stroke:"#4ade80",text:"text-emerald-500"}:a>=.8?{stroke:"#fbbf24",text:"text-amber-500"}:{stroke:"#f87171",text:"text-red-500"}}function a_({successRate:a,averageLatencyMs:l,latencySpark:o}){const{stroke:i,text:u}=n_(a),d=Math.min(1,Math.max(0,a)),h=xy*(1-d);return s.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-2",children:s.jsx(Qe,{className:"text-base",children:"Success Rate"})}),s.jsxs(Ze,{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"relative h-20 w-20",children:[s.jsxs("svg",{viewBox:"0 0 80 80",className:"h-20 w-20 -rotate-90",children:[s.jsx("circle",{cx:"40",cy:"40",r:fh,fill:"none",stroke:"hsl(var(--border))",strokeWidth:7}),s.jsx("circle",{cx:"40",cy:"40",r:fh,fill:"none",stroke:i,strokeWidth:7,strokeLinecap:"round",strokeDasharray:xy,strokeDashoffset:h,style:{transition:"stroke-dashoffset 0.6s ease, stroke 0.4s ease"}})]}),s.jsx("span",{className:`absolute inset-0 flex items-center justify-center text-sm font-semibold tabular-nums ${u}`,children:kc(a)})]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Share of requests that completed successfully over the selected window. Updated in real time."})]})]}),s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-2",children:s.jsx(Qe,{className:"text-base",children:"Average Latency"})}),s.jsxs(Ze,{className:"flex items-end justify-between",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-semibold tabular-nums",children:dr(l)}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Live average across the selected window"})]}),s.jsx(D1,{data:o,strokeClass:"stroke-amber-500",fillClass:"fill-amber-500/10",className:"h-10 w-28"})]})]})]})}function l_(){const[a,l]=m.useState("7d"),{snapshot:o,live:i,recent:u,providers:d,pulses:h,activeRoutes:p,loading:g,error:v}=XD(a);if(g)return s.jsx("div",{className:"text-muted-foreground",children:"Loading…"});if(v||!o)return s.jsxs("div",{className:"text-destructive",children:["Failed to load statistics: ",v??"unknown error"]});const x=i,y=o.previous,S=o.series;function w(j,N){return N>0?(j-N)/N:void 0}const C=S.map(j=>j.requests),E=S.map(j=>j.avgLatency);return s.jsxs("div",{children:[s.jsx(wa,{title:"Statistics",description:"Real-time monitoring dashboard",actions:s.jsx(M1,{value:a,onValueChange:j=>void l(j),children:s.jsxs(jm,{children:[s.jsx(Ka,{value:"today",children:"Today"}),s.jsx(Ka,{value:"7d",children:"7 days"}),s.jsx(Ka,{value:"30d",children:"30 days"})]})})}),s.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[s.jsx(Ol,{icon:$y,label:"Requests",value:x.totalRequests,delta:w(x.totalRequests,y.totalRequests),sparkData:C}),s.jsx(Ol,{icon:Dc,label:"Success rate",format:"percent",value:x.successRate,delta:w(x.successRate,y.successRate),sparkData:C,sparkStroke:"stroke-emerald-500"}),s.jsx(Ol,{icon:sC,label:"Total tokens",value:x.totalTokens,delta:w(x.totalTokens,y.totalTokens),sparkData:S.map(j=>j.inputTokens+j.outputTokens)}),s.jsx(Ol,{icon:oC,label:"Cache hit rate",format:"percent",value:x.cacheHitRate,delta:w(x.cacheHitRate,y.cacheHitRate),sparkData:S.map(j=>j.cacheRead)}),s.jsx(Ol,{icon:aC,label:"Avg latency",format:"latency",value:x.averageLatencyMs,delta:w(x.averageLatencyMs,y.averageLatencyMs),deltaInverse:!0,sparkData:E,sparkStroke:"stroke-amber-500"}),s.jsx(Ol,{icon:Fy,label:"p95 latency",format:"latency",value:x.p95LatencyMs}),s.jsx(Ol,{icon:SC,label:"Avg TTFT",format:"latency",value:x.averageTtftMs??0}),s.jsx(Ol,{icon:gC,label:"Fallback rate",format:"percent",value:x.fallbackRate,delta:w(x.fallbackRate,y.fallbackRate),deltaInverse:!0})]}),s.jsx("div",{className:"mt-6",children:s.jsx(e_,{liveRequests:x.totalRequests,successRate:x.successRate,providers:d,pulses:h,activeRoutes:p})}),s.jsxs("div",{className:"mt-6 grid gap-4 lg:grid-cols-3",children:[s.jsx("div",{className:"lg:col-span-2",children:s.jsx(t_,{rows:u})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-2",children:s.jsx(Qe,{className:"text-base",children:"Top Models"})}),s.jsx(Ze,{children:s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Model"}),s.jsx(pe,{children:"Req"}),s.jsx(pe,{children:"Errors"}),s.jsx(pe,{children:"Tokens"})]})}),s.jsxs(Fn,{children:[o.topModels.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:4,className:"text-muted-foreground text-center",children:"No data"})}),o.topModels.map(j=>s.jsxs(Ye,{children:[s.jsx(de,{className:"font-mono text-xs",children:j.publicId}),s.jsx(de,{className:"text-xs",children:Mt(j.requests)}),s.jsx(de,{className:"text-xs",children:s.jsx("span",{className:j.errorRate>.1?"text-destructive":"text-muted-foreground",children:kc(j.errorRate)})}),s.jsx(de,{className:"text-xs",children:Mt(j.totalTokens)})]},j.publicId))]})]})})]}),s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-2",children:s.jsx(Qe,{className:"text-base",children:"Top API Keys"})}),s.jsx(Ze,{children:s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Key"}),s.jsx(pe,{children:"Requests"}),s.jsx(pe,{children:"Tokens"})]})}),s.jsxs(Fn,{children:[o.topApiKeys.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:3,className:"text-muted-foreground text-center",children:"No data"})}),o.topApiKeys.map((j,N)=>s.jsxs(Ye,{children:[s.jsx(de,{className:"text-xs",children:j.name}),s.jsx(de,{className:"text-xs",children:Mt(j.requests)}),s.jsx(de,{className:"text-xs",children:Mt(j.totalTokens)})]},N))]})]})})]})]})]}),s.jsx("div",{className:"mt-6",children:s.jsx(a_,{successRate:x.successRate,averageLatencyMs:x.averageLatencyMs,latencySpark:E})})]})}function r_(){const[a,l]=m.useState([]),[o,i]=m.useState(0);return m.useEffect(()=>{we.get("/api/admin/audit?limit=200").then(u=>{l(u.rows),i(u.total)})},[]),s.jsxs("div",{children:[s.jsx(wa,{title:"Audit Logs",description:`${o} entries · immutable`}),s.jsxs(Xe,{children:[s.jsx(Fe,{children:s.jsx(Qe,{className:"text-base",children:"All entries"})}),s.jsx(Ze,{children:s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Time"}),s.jsx(pe,{children:"Action"}),s.jsx(pe,{children:"Status"}),s.jsx(pe,{children:"Target"}),s.jsx(pe,{children:"IP"}),s.jsx(pe,{children:"Actor"})]})}),s.jsxs(Fn,{children:[a.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:6,className:"text-center text-muted-foreground",children:"No audit events yet."})}),a.map(u=>s.jsxs(Ye,{children:[s.jsx(de,{className:"text-xs",children:Ah(u.createdAt)}),s.jsx(de,{className:"font-mono text-xs",children:u.action}),s.jsx(de,{children:u.success?s.jsx(et,{variant:"success",children:"ok"}):s.jsx(et,{variant:"destructive",children:"fail"})}),s.jsx(de,{className:"text-xs",children:u.targetName??u.targetId??"—"}),s.jsx(de,{className:"text-xs",children:u.ip}),s.jsx(de,{className:"text-xs",children:u.actor})]},u.id))]})]})})]})]})}const hh={enabled:!0,sound:!0};let To=hh,mh=!1,fc=null;const ph=new Set;function O1(){for(const a of ph)a()}function k1(a=!1){return mh&&!a?Promise.resolve():(!a&&fc||(fc=(async()=>{try{const l=await we.get("/api/admin/settings");To={enabled:l.settings.notificationsEnabled??hh.enabled,sound:l.settings.notificationSoundEnabled??hh.sound},mh=!0,O1()}catch{}})()),fc)}async function yy(a){const l={};a.enabled!==void 0&&(l.notificationsEnabled=a.enabled),a.sound!==void 0&&(l.notificationSoundEnabled=a.sound),await we.patch("/api/admin/settings",l),To={...To,...a},mh=!0,O1()}function s_(a){return ph.add(a),()=>ph.delete(a)}function z1(){return m.useSyncExternalStore(s_,()=>To,()=>To)}const gh=m.forwardRef(({className:a,...l},o)=>s.jsx("textarea",{ref:o,className:Re("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",a),...l}));gh.displayName="Textarea";function o_(){const[a]=B2(),[l,o]=m.useState(null),[i,u]=m.useState(null),[d,h]=m.useState({current:"",next:""}),[p,g]=m.useState(""),[v,x]=m.useState(""),[y,S]=m.useState(null),[w,C]=m.useState(!1),[E,j]=m.useState("idle"),[N,M]=m.useState(null),T=async(J=!1)=>{j("checking"),M(null);try{const me=await we.get(`/api/admin/update/check${J?"?force=1":""}`);S(me),j("idle")}catch(me){M(me.message),j("error")}},_=async()=>{C(!0),j("installing"),M(null);try{const J=await we.post("/api/admin/update/run");j("restarting"),ve.success(J.message||"Update started — the gateway will restart shortly.");const me=setInterval(()=>{fetch("/health").then(je=>{je.ok&&(clearInterval(me),window.location.reload())}).catch(()=>{})},3e3);setTimeout(()=>clearInterval(me),12e4)}catch(J){ve.error(J.message),M(J.message),j("error")}finally{C(!1)}},[O,A]=m.useState("disabled"),[H,z]=m.useState(""),[K,se]=m.useState(""),[X,I]=m.useState(""),[re,ee]=m.useState([]),[oe,U]=m.useState(""),[$,le]=m.useState(""),[B,Z]=m.useState(!1),[D,q]=m.useState(null),Q=async()=>{const J=await we.get("/api/admin/settings");o(J.settings),g(J.settings.adminIpAllow??""),x(J.settings.adminIpBlock??"");const me=await we.get("/api/admin/settings/system");u(me);try{const je=await we.get("/api/admin/me");A(je.totpEnabled?"enabled":"disabled")}catch{}};if(m.useEffect(()=>{k1(!0)},[]),m.useEffect(()=>{Q(),T()},[]),!l)return s.jsx("div",{className:"text-muted-foreground",children:"Loading…"});const ae=async J=>{try{await we.patch("/api/admin/settings",J),ve.success("Saved"),Q()}catch(me){ve.error(me.message)}},ce=async()=>{try{const J=await we.post("/api/admin/account/totp/begin");z(J.secret),se(J.qr),A("setup"),ve.info("Scan the QR code with your authenticator app")}catch(J){ve.error(J.message)}},Se=async()=>{if(!X||X.length!==6){ve.error("Enter a 6-digit code");return}try{const J=await we.post("/api/admin/account/totp/verify",{code:X});ee(J.recoveryCodes),A("showingRecovery"),ve.success("TOTP enabled successfully")}catch(J){ve.error(J.message)}},ue=async()=>{if(!oe){ve.error("Enter your password");return}if(!$){ve.error("Enter a TOTP code or recovery code");return}try{await we.post("/api/admin/account/totp/disable",{password:oe,totp:$}),A("disabled"),U(""),le(""),ve.success("TOTP disabled"),Q()}catch(J){ve.error(J.message)}},fe=async()=>{Z(!0);try{const J=await we.post("/api/admin/account/totp/recovery/regenerate",{password:oe,totp:$});ee(J.recoveryCodes),A("showingRecovery"),ve.success("Recovery codes regenerated")}catch(J){ve.error(J.message)}Z(!1)},xe=a.get("tab")||"logging";return s.jsxs("div",{children:[s.jsx(wa,{title:"Settings",description:"Logging, security, backup, and system info"}),s.jsxs(M1,{defaultValue:xe,children:[s.jsxs(jm,{children:[s.jsx(Ka,{value:"logging",children:"Logging"}),s.jsx(Ka,{value:"access",children:"Access Control"}),s.jsx(Ka,{value:"security",children:"Security"}),s.jsx(Ka,{value:"backup",children:"Backup"}),s.jsx(Ka,{value:"system",children:"System"})]}),s.jsx(ds,{value:"logging",children:s.jsxs(Xe,{children:[s.jsx(Fe,{children:s.jsx(Qe,{className:"text-base",children:"Logging policy"})}),s.jsxs(Ze,{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Request-content logging"}),s.jsxs(Vn,{value:l.contentLogMode,onValueChange:J=>ae({contentLogMode:J}),children:[s.jsx(Rn,{children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"off",children:"Off"}),s.jsx(lt,{value:"metadata",children:"Metadata only (default)"}),s.jsx(lt,{value:"prompt",children:"Prompt (sanitized)"}),s.jsx(lt,{value:"prompt_and_response",children:"Prompt + response (sanitized)"})]})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Retention (days)"}),s.jsx(Ae,{type:"number",min:1,max:3650,value:l.retentionDays,onChange:J=>ae({retentionDays:Number(J.target.value)})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Database size limit (MB)"}),s.jsx(Ae,{type:"number",min:64,value:l.dbSizeLimitMb,onChange:J=>ae({dbSizeLimitMb:Number(J.target.value)})})]}),s.jsx("div",{className:"flex items-center gap-2 pt-2",children:s.jsx(he,{onClick:async()=>{const J=await we.post("/api/admin/settings/cleanup");ve.success(`Deleted ${J.deletedRequests} old requests`)},children:"Run cleanup now"})})]})]})}),s.jsx(ds,{value:"access",children:s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"IP access control"}),s.jsx(on,{children:"Allowlist / Blocklist for this admin website (not model traffic)"})]}),s.jsxs(Ze,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(be,{children:"Allow only these IPs"}),s.jsx(gh,{placeholder:`192.168.1.0/24
330
- 10.0.0.1`,value:p,onChange:J=>g(J.target.value)}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Newlines-delimited CIDR ranges (IPv4 only). Leave empty = no allow restrictions. When you save a non-empty list, your current IP is auto-added to prevent lockout."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(be,{children:"Block these IPs"}),s.jsx(gh,{placeholder:"192.168.1.100",value:v,onChange:J=>x(J.target.value)}),s.jsx("p",{className:"text-xs text-muted-foreground",children:'Newlines-delimited CIDR ranges (IPv4 only). Blocked IPs are rejected with "Không có quyền truy cập" before any login page.'})]}),s.jsx(he,{onClick:()=>{const J={};p!==((l==null?void 0:l.adminIpAllow)??"")&&(J.adminIpAllow=p||null),v!==((l==null?void 0:l.adminIpBlock)??"")&&(J.adminIpBlock=v||null),we.patch("/api/admin/settings",J).then(me=>{ve.success("Saved"+(me.addedIp?` — added your IP: ${me.addedIp}`:"")),Q(),g(""),x("")}).catch(me=>ve.error(me.message))},children:"Save access control"}),s.jsxs("div",{className:"rounded bg-amber-50 border border-amber-200 p-3 dark:bg-amber-950/20 dark:border-amber-800",children:[s.jsx("p",{className:"text-sm font-medium text-amber-900 dark:text-amber-200",children:"⚠️ If you enable an allow list, you cannot access the gateway unless your IP matches."}),s.jsx("p",{className:"text-xs text-amber-800 dark:text-amber-300",children:"The server automatically adds your current IP when you save — but if you configure it from a different machine, that machine will be locked out immediately."})]})]})]})}),s.jsx(ds,{value:"security",children:s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"Security"}),s.jsx(on,{children:"Change password, 2FA, and trusted proxy configuration"})]}),s.jsxs(Ze,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(be,{children:"Trusted proxy hops"}),s.jsx(Ae,{type:"number",min:0,max:8,value:l.trustProxyHops,onChange:J=>ae({trustProxyHops:Number(J.target.value)})}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"0 = never trust X-Forwarded-For (direct exposure). 1+ only when behind a single trusted reverse proxy."})]}),s.jsxs("div",{className:"space-y-2 border-t pt-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(be,{className:"text-base",children:"TOTP 2FA"}),O==="enabled"?s.jsx("span",{className:"rounded bg-green-100 px-2 py-0.5 text-xs font-medium text-green-800 dark:bg-green-900 dark:text-green-200",children:"Enabled"}):null,O==="disabled"?s.jsx("span",{className:"rounded bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:"Disabled"}):null]}),O==="disabled"&&s.jsx(he,{variant:"outline",onClick:ce,children:"Enable TOTP"}),O==="setup"&&s.jsxs("div",{className:"space-y-3 rounded border p-3",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"Scan this QR code with your authenticator app, or enter the secret manually."}),K&&s.jsx("img",{src:K,alt:"TOTP QR code",className:"h-40 w-40"}),s.jsxs("div",{className:"text-xs font-mono text-muted-foreground",children:["Secret: ",H]}),s.jsxs("div",{className:"flex items-end gap-2",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx(be,{children:"Verify code"}),s.jsx(Ae,{value:X,onChange:J=>I(J.target.value),placeholder:"123456",maxLength:6})]}),s.jsx(he,{disabled:X.length<6,onClick:Se,children:"Verify & enable"})]})]}),O==="showingRecovery"&&s.jsxs("div",{className:"space-y-3 rounded border border-amber-500/40 bg-amber-50 p-3 dark:bg-amber-950/20",children:[s.jsx("p",{className:"text-sm font-medium",children:"Recovery codes — save these now!"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Each code can be used once to log in without your TOTP device. They will not be shown again."}),s.jsx("div",{className:"space-y-1",children:re.map((J,me)=>s.jsx("div",{className:"font-mono text-xs",children:J},me))}),s.jsx(he,{onClick:()=>{A("enabled"),ve.success("Recovery codes saved")},children:"I have saved them"})]}),O==="enabled"&&s.jsxs("div",{className:"space-y-3 rounded border p-3",children:[s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx(be,{children:"Password"}),s.jsx(Ae,{type:"password",value:oe,onChange:J=>U(J.target.value),placeholder:"Current password"})]}),s.jsxs("div",{children:[s.jsx(be,{children:"TOTP code"}),s.jsx(Ae,{value:$,onChange:J=>le(J.target.value),placeholder:"123456",maxLength:6})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(he,{variant:"outline",size:"sm",disabled:B||!oe||$.length<6,onClick:fe,children:"Regenerate recovery codes"}),s.jsx(he,{variant:"destructive",size:"sm",disabled:!oe||$.length<6,onClick:ue,children:"Disable TOTP"})]})]})]}),s.jsxs("div",{className:"space-y-2 border-t pt-4",children:[s.jsx(be,{children:"Change password"}),s.jsx(Ae,{type:"password",placeholder:"Current password",value:d.current,onChange:J=>h({...d,current:J.target.value})}),s.jsx(Ae,{type:"password",placeholder:"New password (12+ chars)",value:d.next,onChange:J=>h({...d,next:J.target.value})}),s.jsx(he,{disabled:!d.current||d.next.length<12,onClick:async()=>{try{await we.post("/api/admin/account/password",{currentPassword:d.current,newPassword:d.next}),ve.success("Password changed"),h({current:"",next:""})}catch(J){ve.error(J.message)}},children:"Change password"})]})]})]})}),s.jsx(ds,{value:"backup",children:s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"Backup & restore"}),s.jsx(on,{children:"Download a snapshot or restore from a previous backup"})]}),s.jsxs(Ze,{className:"space-y-3",children:[s.jsx(he,{onClick:async()=>{try{const J=await fetch("/api/admin/backup/create",{method:"POST",credentials:"include"});if(!J.ok)throw new Error("Backup failed");const me=await J.blob(),je=URL.createObjectURL(me),Me=document.createElement("a");Me.href=je,Me.download="latedev-backup.json",Me.click(),URL.revokeObjectURL(je),ve.success("Backup downloaded")}catch(J){ve.error(J.message)}},children:"Download backup"}),s.jsxs(s1,{open:D!==null,onOpenChange:J=>{J||q(null)},children:[s.jsx(xM,{asChild:!0,children:s.jsxs("div",{children:[s.jsx(be,{children:"Restore from backup file"}),s.jsx(Ae,{type:"file",accept:".json,application/json","data-testid":"restore-file",onChange:J=>{var je;const me=(je=J.target.files)==null?void 0:je[0];q(me??null)}})]})}),s.jsxs(am,{children:[s.jsxs(i1,{children:[s.jsx(lm,{children:"Restore backup?"}),s.jsxs(rm,{children:["Restoring will replace the entire current database with the selected backup (",(D==null?void 0:D.name)??"file","). This cannot be undone. A snapshot of the current database is kept for rollback only if validation fails."]})]}),s.jsxs(c1,{children:[s.jsx(om,{children:"Cancel"}),s.jsx(sm,{onClick:async()=>{var me,je;const J=D;if(J)try{const Me=await fetch("/api/admin/backup/restore",{method:"POST",body:J,credentials:"include",headers:{"content-type":"application/json"}});if(!Me.ok)throw new Error(((je=(me=await Me.json())==null?void 0:me.error)==null?void 0:je.message)??"Restore failed");ve.success("Restored. Reloading…"),q(null),setTimeout(()=>location.reload(),600)}catch(Me){ve.error(Me.message)}},children:"Restore"})]})]})]})]})]})}),s.jsxs(ds,{value:"system",children:[s.jsxs(Xe,{children:[s.jsx(Fe,{children:s.jsx(Qe,{className:"text-base",children:"System"})}),s.jsxs(Ze,{className:"space-y-2 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-muted-foreground",children:"App version:"})," ",i==null?void 0:i.appVersion]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-muted-foreground",children:"Data directory:"})," ",s.jsx("span",{className:"font-mono",children:i==null?void 0:i.dataDir})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-muted-foreground",children:"Encryption:"})," ",i!=null&&i.masterKeyConfigured?"Configured":"Not configured"," (v",i==null?void 0:i.masterKeyVersion,")"]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-muted-foreground",children:"Environment:"})," ",i==null?void 0:i.environment]}),s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsx(ba,{checked:l.gatewayCacheEnabled,onCheckedChange:J=>ae({gatewayCacheEnabled:J})}),s.jsx(be,{children:"Gateway response cache (disabled by default)"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx(be,{children:"Cache TTL (s)"}),s.jsx(Ae,{type:"number",min:1,value:l.gatewayCacheDefaultTtlSeconds,onChange:J=>ae({gatewayCacheDefaultTtlSeconds:Number(J.target.value)})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Cache max size (MB)"}),s.jsx(Ae,{type:"number",min:1,value:l.gatewayCacheMaxSizeMb,onChange:J=>ae({gatewayCacheMaxSizeMb:Number(J.target.value)})})]})]}),s.jsx(he,{variant:"outline",onClick:async()=>{const J=await we.post("/api/admin/settings/cache/clear");ve.success(`Cleared ${J.deleted} entries`)},children:"Clear gateway cache"})]})]}),s.jsx(i_,{}),s.jsxs(Xe,{className:"mt-4",children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"Updates"}),s.jsx(on,{children:"Automatic updates from the npm registry"})]}),s.jsxs(Ze,{className:"space-y-3 text-sm",children:[E==="checking"&&!y&&s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(jo,{className:"h-4 w-4 animate-spin"})," Checking for updates…"]}),y&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Current version"}),s.jsxs("div",{className:"font-mono",children:["v",y.currentVersion]})]}),s.jsx("span",{className:"text-muted-foreground",children:"→"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Latest version"}),s.jsx("div",{className:"font-mono",children:y.latestVersion?`v${y.latestVersion}`:"—"})]}),y.status.docker?s.jsx(et,{variant:"secondary",children:y.status.watchtower?"Docker + Watchtower":"Docker"}):y.latestVersion===null?s.jsx(et,{variant:"secondary",children:"Registry unreachable"}):y.hasUpdate?s.jsx(et,{variant:"success",children:"Update available"}):s.jsxs(et,{variant:"outline",children:[s.jsx(Dc,{className:"mr-1 h-3 w-3"})," Up to date"]})]}),y.status.docker&&y.status.watchtower&&y.watchtowerReachable&&s.jsx("p",{className:"text-muted-foreground",children:"Watchtower pulls new images automatically every hour — or use Update now for an instant update."}),y.status.docker&&y.status.watchtower&&y.watchtowerReachable===!1&&s.jsxs("p",{className:"text-muted-foreground",children:["The Watchtower sidecar is configured but not running — start it with ",s.jsx("code",{className:"rounded bg-muted px-1 text-xs",children:"docker compose --profile updater up -d"}),"."]}),y.status.docker&&!y.status.watchtower&&s.jsx("p",{className:"text-muted-foreground",children:y.status.reason??"This instance runs in Docker — update by pulling the new image tag."}),!y.status.docker&&y.latestVersion===null&&s.jsxs("p",{className:"text-muted-foreground",children:["Could not reach the npm registry (offline or blocked). ",N&&s.jsx("span",{className:"text-destructive",children:N})]}),E==="installing"&&s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(jo,{className:"h-4 w-4 animate-spin"})," Applying the update… this can take a minute."]}),E==="restarting"&&s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(jo,{className:"h-4 w-4 animate-spin"})," Update applied — the gateway is restarting on the new version. This page reloads automatically."]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[y.hasUpdate&&E==="idle"&&(!y.status.docker||y.status.watchtower&&y.watchtowerReachable!==!1)&&s.jsxs(he,{disabled:w||y.status.docker&&y.watchtowerReachable===!1,onClick:_,children:[s.jsx(Xy,{className:"mr-1 h-4 w-4"})," Update now"]}),y.hasUpdate&&y.changelogUrl&&s.jsx(he,{variant:"outline",asChild:!0,children:s.jsx("a",{href:y.changelogUrl,target:"_blank",rel:"noreferrer",children:"View changes"})}),E==="idle"&&s.jsx(he,{variant:"ghost",disabled:w,onClick:()=>T(!0),children:"Check again"})]})]})]})]})]})]})]})}function i_(){const a=z1();return s.jsxs(Xe,{className:"mt-4",children:[s.jsx(Fe,{children:s.jsxs(Qe,{className:"text-base flex items-center gap-2",children:[s.jsx(J2,{className:"h-4 w-4"})," Notifications"]})}),s.jsxs(Ze,{className:"space-y-3 text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{children:"Show request notifications"}),s.jsx(ba,{checked:a.enabled,onCheckedChange:l=>void yy({enabled:l})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(wC,{className:"h-3 w-3"})," Play notification sound"]}),s.jsx(ba,{checked:a.sound,onCheckedChange:l=>void yy({sound:l})})]}),s.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Notifications are disabled while muted. Changes apply immediately."})]})]})}function c_({items:a,onDismiss:l}){return a.length?s.jsx("div",{className:"fixed top-16 right-4 z-50 flex max-h-[calc(100vh-8rem)] w-80 flex-col gap-2 overflow-y-auto",children:a.map(o=>{const i=!o.success,u=o.success&&o.totalLatencyMs>15e3,d=Re("rounded-md border shadow-lg transition-all",i&&"bg-destructive text-destructive-foreground border-destructive",u&&"bg-amber-500/90 text-amber-950 border-amber-600/50",!i&&!u&&"bg-card text-card-foreground border-border");return s.jsxs(ur,{to:"/requests",className:Re("block shrink-0 p-3 hover:opacity-95",d),children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[i?s.jsx(nC,{className:"h-4 w-4 shrink-0"}):o.success?s.jsx(Dc,{className:"h-4 w-4 shrink-0"}):s.jsx(jC,{className:"h-4 w-4 shrink-0 opacity-70"}),s.jsx("div",{className:"min-w-0 truncate text-sm font-medium",title:o.requestedModel,children:o.requestedModel})]}),s.jsx("button",{className:"shrink-0 opacity-60 hover:opacity-100",onClick:h=>{h.preventDefault(),h.stopPropagation(),l(o.id)},"aria-label":"Dismiss",type:"button",children:s.jsx(Oc,{className:"h-3.5 w-3.5"})})]}),s.jsxs("div",{className:"mt-1 text-xs",children:[o.success?"Thành công":"Thất bại",!o.success&&o.errorType&&s.jsx("span",{className:"ml-1 inline-block rounded bg-black/15 px-1 py-0.5 align-text-bottom text-[10px]",children:o.errorType})]}),s.jsxs("div",{className:"mt-1 text-[11px] opacity-90",children:["in ",Mt(o.inputTokens)," · out ",Mt(o.outputTokens),(o.cacheReadTokens>0||o.cacheWriteTokens>0)&&s.jsxs(s.Fragment,{children:[" · cache ",o.cacheReadTokens>0&&s.jsxs("span",{children:["r",Mt(o.cacheReadTokens)]}),o.cacheReadTokens>0&&o.cacheWriteTokens>0&&"/",o.cacheWriteTokens>0&&s.jsxs("span",{children:["w",Mt(o.cacheWriteTokens)]})]})]}),s.jsxs("div",{className:"mt-1 text-[11px] opacity-90",children:[dr(o.totalLatencyMs),o.ttftMs!=null&&o.ttftMs>=0&&s.jsxs("span",{children:[" · TTFT ",dr(o.ttftMs)]})]})]},o.id)})}):null}const u_=5e3,d_=8,f_=3e3;let hc=null;function h_(){try{hc||(hc=new Audio("/notification.mp3")),hc.currentTime=0,hc.play().catch(()=>{})}catch{}}function m_(){const[a,l]=m.useState([]),o=m.useRef(null),i=m.useRef(new Map),u=m.useRef(Date.now()),d=m.useRef(new Set),h=z1(),p=m.useRef(h.sound);p.current=h.sound,m.useEffect(()=>{k1()},[]);const g=h.enabled;return m.useEffect(()=>{var w;if(!g){(w=o.current)==null||w.close(),o.current=null;const C=i.current;for(const E of C.values())clearTimeout(E);C.clear(),l([]);return}let x=!1;const y=i.current,S=()=>{if(x)return;const C=new EventSource(`/api/admin/requests/stream?since=${u.current}`);o.current=C,C.addEventListener("request",E=>{if(!x)try{const j=JSON.parse(E.data),N=new Date(j.createdAt).getTime();if(Number.isFinite(N)&&(u.current=Math.max(u.current,N)),d.current.has(j.id))return;d.current.add(j.id),l(T=>T.some(_=>_.id===j.id)?T:[j,...T].slice(0,d_));const M=setTimeout(()=>{l(T=>T.filter(_=>_.id!==j.id)),y.delete(j.id)},u_);y.set(j.id,M),p.current&&h_()}catch{}}),C.onerror=()=>{C.close(),o.current=null,x||setTimeout(S,f_)}};return S(),()=>{var C;x=!0,(C=o.current)==null||C.close(),o.current=null;for(const E of y.values())clearTimeout(E);y.clear()}},[g]),{items:a,dismiss:x=>{const y=i.current.get(x);y&&(clearTimeout(y),i.current.delete(x)),l(S=>S.filter(w=>w.id!==x))}}}function p_({children:a}){const{user:l,loading:o}=Nh(),i=dn();return o?s.jsx("div",{className:"flex h-screen items-center justify-center text-muted-foreground",children:"Loading…"}):l?s.jsx(s.Fragment,{children:a}):s.jsx(qf,{to:"/login",state:{from:i},replace:!0})}function g_(){const{items:a,dismiss:l}=m_();return s.jsxs("div",{className:"flex h-screen bg-background text-foreground",children:[s.jsx(rE,{}),s.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[s.jsx(sA,{}),s.jsx("main",{className:"flex-1 overflow-auto p-6",children:s.jsxs(Py,{children:[s.jsx(rn,{index:!0,element:s.jsx(PA,{})}),s.jsx(rn,{path:"/providers",element:s.jsx(hD,{})}),s.jsx(rn,{path:"/models",element:s.jsx(jD,{})}),s.jsx(rn,{path:"/combos",element:s.jsx(CD,{})}),s.jsx(rn,{path:"/aliases",element:s.jsx(ED,{})}),s.jsx(rn,{path:"/api-keys",element:s.jsx(RD,{})}),s.jsx(rn,{path:"/requests",element:s.jsx(AD,{})}),s.jsx(rn,{path:"/statistics",element:s.jsx(l_,{})}),s.jsx(rn,{path:"/audit",element:s.jsx(r_,{})}),s.jsx(rn,{path:"/settings/*",element:s.jsx(o_,{})})]})})]}),s.jsx(c_,{items:a,onDismiss:l})]})}function v_({children:a}){const[l,o]=m.useState(null),i=dn();return m.useEffect(()=>{we.get("/api/admin/setup/status").then(u=>o(u.setupComplete)).catch(()=>o(!0))},[]),l===null?s.jsx("div",{className:"flex h-screen items-center justify-center text-muted-foreground",children:"Loading…"}):!l&&i.pathname!=="/setup"?s.jsx(qf,{to:"/setup",replace:!0}):l&&i.pathname==="/setup"?s.jsx(qf,{to:"/",replace:!0}):s.jsx(s.Fragment,{children:a})}function x_(){return s.jsx(K2,{children:s.jsx(v_,{children:s.jsxs(Py,{children:[s.jsx(rn,{path:"/setup",element:s.jsx(BA,{})}),s.jsx(rn,{path:"/login",element:s.jsx(UA,{})}),s.jsx(rn,{path:"/*",element:s.jsx(p_,{children:s.jsx(g_,{})})})]})})})}const y_=LA;var b_=Object.defineProperty,cn=(a,l)=>b_(a,"name",{value:l,configurable:!0}),[Cm,J_]=fn("Tooltip",[Es]),S_=Es(),w_="TooltipProvider",j_=700,by="tooltip.open",[C_,E_]=Cm(w_),R_=cn(a=>{const{__scopeTooltip:l,delayDuration:o=j_,skipDelayDuration:i=300,disableHoverableContent:u=!1,children:d}=a,h=m.useRef(!0),p=m.useRef(!1),g=m.useRef(0);return m.useEffect(()=>{const v=g.current;return()=>window.clearTimeout(v)},[]),s.jsx(C_,{scope:l,isOpenDelayedRef:h,delayDuration:o,onOpen:m.useCallback(()=>{i<=0||(window.clearTimeout(g.current),h.current=!1)},[i]),onClose:m.useCallback(()=>{i<=0||(window.clearTimeout(g.current),g.current=window.setTimeout(()=>h.current=!0,i))},[i]),isPointerInTransitRef:p,onPointerInTransitChange:m.useCallback(v=>{p.current=v},[]),disableHoverableContent:u,children:d})},"TooltipProvider"),N_="Tooltip",[W_,Em]=Cm(N_),T_="TooltipPortal",[eO,A_]=Cm(T_,{forceMount:void 0}),Ao="TooltipContent",M_=m.forwardRef(cn(function(l,o){const i=A_(Ao,l.__scopeTooltip),{forceMount:u=i.forceMount,side:d="top",...h}=l,p=Em(Ao,l.__scopeTooltip);return s.jsx(al,{present:u||p.open,children:p.disableHoverableContent?s.jsx(L1,{side:d,...h,ref:o}):s.jsx(D_,{side:d,...h,ref:o})})},"TooltipContent")),D_=m.forwardRef(cn(function(l,o){const i=Em(Ao,l.__scopeTooltip),u=E_(Ao,l.__scopeTooltip),d=m.useRef(null),h=Ie(o,d),[p,g]=m.useState(null),{trigger:v,onClose:x}=i,y=d.current,{onPointerInTransitChange:S}=u,w=m.useCallback(()=>{g(null),S(!1)},[S]),C=m.useCallback((E,j)=>{const N=E.currentTarget,M={x:E.clientX,y:E.clientY},T=U1(M,N.getBoundingClientRect()),_=B1(M,T),O=H1(j.getBoundingClientRect()),A=q1([..._,...O]);g(A),S(!0)},[S]);return m.useEffect(()=>()=>w(),[w]),m.useEffect(()=>{if(v&&y){const E=cn(N=>C(N,y),"handleTriggerLeave"),j=cn(N=>C(N,v),"handleContentLeave");return v.addEventListener("pointerleave",E),y.addEventListener("pointerleave",j),()=>{v.removeEventListener("pointerleave",E),y.removeEventListener("pointerleave",j)}}},[v,y,C,w]),m.useEffect(()=>{if(p){const E=cn(j=>{const N=j.target,M={x:j.clientX,y:j.clientY},T=(v==null?void 0:v.contains(N))||(y==null?void 0:y.contains(N)),_=!P1(M,p);T?w():_&&(w(),x())},"handleTrackPointerGrace");return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[v,y,p,x,w]),s.jsx(L1,{...l,ref:h})},"TooltipContentHoverable")),__=c0("TooltipContent"),L1=m.forwardRef(cn(function(l,o){const{__scopeTooltip:i,children:u,"aria-label":d,id:h,onEscapeKeyDown:p,onPointerDownOutside:g,...v}=l,x=Em(Ao,i),y=S_(i),{onClose:S}=x;m.useEffect(()=>(document.addEventListener(by,S),()=>document.removeEventListener(by,S)),[S]),m.useEffect(()=>{if(x.trigger){const C=cn(E=>{E.target instanceof Node&&E.target.contains(x.trigger)&&S()},"handleScroll");return window.addEventListener("scroll",C,{capture:!0}),()=>window.removeEventListener("scroll",C,{capture:!0})}},[x.trigger,S]);const{setContentId:w}=x;return Dt(()=>(w(h),()=>{w(void 0)}),[h,w]),s.jsx(Lc,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:p,onPointerDownOutside:g,onFocusOutside:C=>C.preventDefault(),onDismiss:S,children:s.jsxs(Vh,{"data-state":x.stateAttribute,role:d?void 0:"tooltip",id:d?void 0:x.contentId,...y,...v,ref:o,style:{...v.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(__,{children:u}),d?s.jsx(NM,{id:x.contentId,role:"tooltip",children:d}):null]})})},"TooltipContentImpl"));function U1(a,l){const o=Math.abs(l.top-a.y),i=Math.abs(l.bottom-a.y),u=Math.abs(l.right-a.x),d=Math.abs(l.left-a.x);switch(Math.min(o,i,u,d)){case d:return"left";case u:return"right";case o:return"top";case i:return"bottom";default:throw new Error("unreachable")}}cn(U1,"getExitSideFromRect");function B1(a,l,o=5){const i=[];switch(l){case"top":i.push({x:a.x-o,y:a.y+o},{x:a.x+o,y:a.y+o});break;case"bottom":i.push({x:a.x-o,y:a.y-o},{x:a.x+o,y:a.y-o});break;case"left":i.push({x:a.x+o,y:a.y-o},{x:a.x+o,y:a.y+o});break;case"right":i.push({x:a.x-o,y:a.y-o},{x:a.x-o,y:a.y+o});break}return i}cn(B1,"getPaddedExitPoints");function H1(a){const{top:l,right:o,bottom:i,left:u}=a;return[{x:u,y:l},{x:o,y:l},{x:o,y:i},{x:u,y:i}]}cn(H1,"getPointsFromRect");function P1(a,l){const{x:o,y:i}=a;let u=!1;for(let d=0,h=l.length-1;d<l.length;h=d++){const p=l[d],g=l[h],v=p.x,x=p.y,y=g.x,S=g.y;x>i!=S>i&&o<(y-v)*(i-x)/(S-x)+v&&(u=!u)}return u}cn(P1,"isPointInPolygon");function q1(a){const l=a.slice();return l.sort((o,i)=>o.x<i.x?-1:o.x>i.x?1:o.y<i.y?-1:o.y>i.y?1:0),I1(l)}cn(q1,"getHull");function I1(a){if(a.length<=1)return a.slice();const l=[];for(let i=0;i<a.length;i++){const u=a[i];for(;l.length>=2;){const d=l[l.length-1],h=l[l.length-2];if((d.x-h.x)*(u.y-h.y)>=(d.y-h.y)*(u.x-h.x))l.pop();else break}l.push(u)}l.pop();const o=[];for(let i=a.length-1;i>=0;i--){const u=a[i];for(;o.length>=2;){const d=o[o.length-1],h=o[o.length-2];if((d.x-h.x)*(u.y-h.y)>=(d.y-h.y)*(u.x-h.x))o.pop();else break}o.push(u)}return o.pop(),l.length===1&&o.length===1&&l[0].x===o[0].x&&l[0].y===o[0].y?l:l.concat(o)}cn(I1,"getHullPresorted");var O_=R_,V1=M_;const k_=O_,z_=m.forwardRef(({className:a,sideOffset:l=4,...o},i)=>s.jsx(V1,{ref:i,sideOffset:l,className:Re("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95",a),...o}));z_.displayName=V1.displayName;dj.createRoot(document.getElementById("root")).render(s.jsx(ie.StrictMode,{children:s.jsx(mE,{defaultTheme:"dark",storageKey:"latedev-theme",children:s.jsxs(k_,{children:[s.jsx(k2,{children:s.jsx(x_,{})}),s.jsx(y_,{position:"top-right"})]})})}));
329
+ `);let pt="",bt="";for(const St of mt)St.startsWith("event: ")?pt=St.slice(7):St.startsWith("data: ")&&(bt=St.slice(6));if(bt){if(pt===""||pt==="message")try{const Lt=(q=JSON.parse(bt).choices)==null?void 0:q[0];(Q=Lt==null?void 0:Lt.delta)!=null&&Q.content&&(fe+=Lt.delta.content),K(hn=>{if(!hn||hn.phase!=="streaming")return hn;const Qn=Date.now()-Z,mn=hn.progress.ttftMs??Qn;return{...hn,text:fe,progress:{ttftMs:mn,elapsedMs:Qn}}})}catch{}if(pt==="test_meta")try{const St=JSON.parse(bt);K({phase:"done",model:B,result:St,text:fe})}catch{}if(pt==="test_error")try{const St=JSON.parse(bt);K({phase:"error",model:B,error:St.message})}catch{}}}}K(J=>!J||J.phase==="streaming"?{phase:"error",model:B,error:"Stream ended unexpectedly"}:J)}catch(ae){K({phase:"error",model:B,error:ae.message})}finally{O(null)}};return s.jsxs("div",{children:[s.jsx(wa,{title:"Models",description:"Physical models imported from providers",actions:s.jsxs(qn,{open:h,onOpenChange:p,children:[s.jsx(Bo,{asChild:!0,children:s.jsxs(he,{variant:"outline",children:[s.jsx(Xy,{className:"mr-1 h-4 w-4"})," Fetch models"]})}),s.jsxs(jn,{className:"max-w-2xl",children:[s.jsx(Cn,{children:s.jsx(En,{children:"Discover models"})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-end gap-2",children:[s.jsx("div",{className:"flex-1",children:s.jsxs(Vn,{value:g,onValueChange:v,children:[s.jsx(Rn,{children:s.jsx(Gn,{placeholder:"Choose provider"})}),s.jsx(Nn,{children:o.map(B=>s.jsx(lt,{value:B.id,children:B.name},B.id))})]})}),s.jsx(he,{onClick:oe,disabled:!g||C,children:C?"Fetching…":"Fetch"})]}),x.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"flex items-center gap-2 flex-1",children:s.jsxs("div",{className:"relative flex-1",children:[s.jsx(Wy,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),s.jsx(Ae,{className:"pl-8",placeholder:"Search models…",value:M,onChange:B=>T(B.target.value)}),M&&s.jsx("button",{className:"absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",onClick:()=>T(""),children:s.jsx(Oc,{className:"h-4 w-4"})})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-sm text-muted-foreground",children:[ee.length," / ",x.length," · ",S.size," selected"]}),s.jsx(he,{variant:"outline",size:"sm",onClick:()=>w(new Set(ee.filter(B=>!B.alreadyImported).map(B=>B.upstreamId))),children:"Select All (new)"}),s.jsx(he,{variant:"outline",size:"sm",onClick:()=>w(new Set),children:"Clear"})]})]}),s.jsx("div",{className:"max-h-80 space-y-1 overflow-auto rounded border p-2",children:ee.length===0&&x.length>0?s.jsx("div",{className:"text-center text-sm text-muted-foreground py-4",children:"No models match your search."}):ee.map(B=>s.jsxs("label",{className:"flex items-center gap-2 rounded p-1 text-sm hover:bg-accent",children:[s.jsx(xm,{checked:S.has(B.upstreamId),onCheckedChange:Z=>{const D=new Set(S);Z?D.add(B.upstreamId):D.delete(B.upstreamId),w(D)}}),s.jsx("span",{className:"font-mono text-xs",children:B.upstreamId}),B.alreadyImported&&s.jsx(et,{variant:"secondary",children:"imported"})]},B.upstreamId))})]})]}),s.jsxs(In,{children:[s.jsx(he,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),s.jsxs(he,{disabled:S.size===0,onClick:U,children:["Import ",S.size||""]})]})]})]})}),s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"All models"}),s.jsxs(on,{children:[a.length," total"]})]}),s.jsxs(Ze,{children:[s.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[s.jsxs(Vn,{value:u,onValueChange:d,children:[s.jsx(Rn,{className:"w-56",children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"all",children:"All providers"}),o.map(B=>s.jsx(lt,{value:B.id,children:B.name},B.id))]})]}),s.jsx(Ae,{className:"max-w-xs",placeholder:"Search public ID",value:j,onChange:B=>N(B.target.value)})]}),s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Public ID"}),s.jsx(pe,{children:"Provider"}),s.jsx(pe,{children:"Upstream ID"}),s.jsx(pe,{children:"Capabilities"}),s.jsx(pe,{children:"Available"}),s.jsx(pe,{children:"Enabled"}),s.jsx(pe,{})]})}),s.jsxs(Fn,{children:[re.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:7,className:"text-center text-muted-foreground",children:"No models"})}),re.map(B=>s.jsxs(Ye,{children:[s.jsx(de,{className:"font-mono text-xs",children:B.publicModelId}),s.jsx(de,{children:B.providerSlug}),s.jsx(de,{className:"text-xs text-muted-foreground",children:B.upstreamModelId}),s.jsx(de,{className:"space-x-1",children:Object.entries(B.capabilities).filter(([,Z])=>Z===!0).slice(0,4).map(([Z])=>s.jsx(et,{variant:"outline",className:"mr-1",children:Z},Z))}),s.jsx(de,{children:B.upstreamAvailable?s.jsx(et,{variant:"success",children:"up"}):s.jsx(et,{variant:"destructive",children:"down"})}),s.jsx(de,{children:B.enabled?"Yes":"No"}),s.jsx(de,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsxs(he,{size:"sm",variant:"outline",onClick:()=>void le(B.id),disabled:_!==null,children:[_===B.id?s.jsx(jo,{className:"h-3.5 w-3.5 animate-spin"}):s.jsx(uC,{className:"h-3.5 w-3.5"})," Test"]}),s.jsxs(he,{size:"sm",variant:"destructive",onClick:()=>X(B),disabled:_!==null,children:[s.jsx(_c,{className:"h-3.5 w-3.5"})," Xoá"]})]})})]},B.id))]})]})]})]}),s.jsx(qn,{open:!!se,onOpenChange:B=>{B||X(null)},children:s.jsxs(jn,{className:"max-w-md",children:[s.jsx(Cn,{children:s.jsx(En,{children:"Xoá model"})}),s.jsxs("div",{className:"space-y-2 text-sm",children:[s.jsxs("p",{children:["Bạn có chắc muốn xoá model ",s.jsx("span",{className:"font-mono",children:se==null?void 0:se.publicModelId}),"?"]}),s.jsx("p",{className:"text-muted-foreground",children:"Model đang được dùng trong combo sẽ bị soft-disable (vô hiệu hoá) thay vì xoá hẳn, để giữ lịch sử và tham chiếu combo."})]}),s.jsxs(In,{children:[s.jsx(he,{variant:"outline",onClick:()=>X(null),children:"Huỷ"}),s.jsx(he,{variant:"destructive",onClick:$,children:"Xoá"})]})]})}),s.jsx(qn,{open:A,onOpenChange:H,children:s.jsxs(jn,{className:"max-w-2xl",children:[s.jsx(Cn,{children:s.jsx(En,{children:"Kết quả test model"})}),z&&z.phase==="streaming"&&s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(jo,{className:"h-4 w-4 animate-spin"})," Đang stream…",s.jsxs("span",{className:"font-mono text-xs text-muted-foreground/60",children:["TTFT ",z.progress.ttftMs!=null?`${z.progress.ttftMs} ms`:"…"]}),s.jsxs("span",{className:"font-mono text-xs text-muted-foreground/60",children:["· ",z.progress.elapsedMs!=null?`${z.progress.elapsedMs} ms`:"…"]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Phản hồi (streaming)"}),s.jsxs("div",{className:"max-h-60 overflow-auto whitespace-pre-wrap rounded border bg-muted p-3 font-mono text-xs",children:[z.text||s.jsx("span",{className:"text-muted-foreground/60 animate-pulse",children:"waiting for first token…"}),z.phase==="streaming"&&s.jsx("span",{className:"ml-0.5 inline-block h-3.5 w-1.5 animate-pulse bg-primary/70"})]})]})]}),z&&z.phase==="done"&&s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(et,{variant:z.result.success?"success":"destructive",children:z.result.success?"Thành công":"Thất bại"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Thời gian phản hồi"}),s.jsxs("div",{className:"font-mono",children:[z.result.latencyMs," ms"]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"TTFT"}),s.jsx("div",{className:"font-mono",children:z.result.ttftMs!=null?`${z.result.ttftMs} ms`:"—"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Tokens (in / out)"}),s.jsxs("div",{className:"font-mono",children:[z.result.usage.input," / ",z.result.usage.output]})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Phản hồi của model"}),s.jsx("div",{className:"max-h-60 overflow-auto whitespace-pre-wrap rounded border bg-muted p-3 font-mono text-xs",children:z.text||z.result.text||"(trống)"})]}),z.result.attempts.length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Attempts"}),s.jsx("div",{className:"space-y-1",children:z.result.attempts.map((B,Z)=>s.jsxs("div",{className:"flex items-center gap-2 rounded border p-2 text-xs",children:[s.jsx(et,{variant:B.success?"success":"destructive",children:B.success?"OK":"FAIL"}),s.jsxs("span",{className:"font-mono",children:[B.providerName," / ",B.modelId]}),s.jsxs("span",{className:"text-muted-foreground",children:[B.latencyMs," ms"]}),B.failureReason&&s.jsx("span",{className:"text-destructive",children:B.failureReason})]},Z))})]})]}),z&&z.phase==="error"&&s.jsxs("div",{className:"space-y-2 text-sm",children:[s.jsx(et,{variant:"destructive",children:"Thất bại"}),s.jsx("p",{className:"text-destructive",children:z.error})]}),s.jsx(In,{children:s.jsx(he,{variant:"outline",onClick:()=>H(!1),children:"Đóng"})})]})})]})}function CD(){const[a,l]=m.useState([]),[o,i]=m.useState([]),[u,d]=m.useState(!1),[h,p]=m.useState(!1),[g,v]=m.useState(null),[x,y]=m.useState(!1),[S,w]=m.useState(!1),[C,E]=m.useState({name:"",slug:"",mode:"fallback",enabled:!0,members:[]}),[j,N]=m.useState({name:"",slug:"",mode:"fallback",enabled:!0,members:[]}),M=async()=>{const[X,I]=await Promise.all([we.get("/api/admin/combos"),we.get("/api/admin/models")]);l(X.combos),i(I.models)};m.useEffect(()=>{M()},[]);const T=X=>{E(I=>({...I,members:[...I.members,{modelId:X,weight:1,position:I.members.length,enabled:!0}]}))},_=X=>{E(I=>({...I,members:I.members.filter((re,ee)=>ee!==X).map((re,ee)=>({...re,position:ee}))}))},O=async()=>{if(C.members.length===0){ve.error("Add at least one member");return}y(!0);try{await we.post("/api/admin/combos",{name:C.name,slug:C.slug||void 0,mode:C.mode,enabled:C.enabled,members:C.members}),ve.success("Combo created"),d(!1),E({name:"",slug:"",mode:"fallback",enabled:!0,members:[]}),M()}catch(X){ve.error(X.message)}finally{y(!1)}},A=async X=>{try{const re=(await we.get(`/api/admin/combos/${X.id}`)).combo;v(re.id),N({name:re.name,slug:re.slug??"",mode:re.mode,enabled:re.enabled,members:re.members.map(ee=>({modelId:ee.modelId,weight:ee.weight,position:ee.position,enabled:ee.enabled}))}),p(!0)}catch(I){ve.error(I.message)}},H=async()=>{if(g){if(j.members.length===0){ve.error("Add at least one member");return}w(!0);try{await we.patch("/api/admin/combos",{id:g,name:j.name,slug:j.slug||void 0,mode:j.mode,enabled:j.enabled,members:j.members}),ve.success("Combo updated"),p(!1),v(null),M()}catch(X){ve.error(X.message)}finally{w(!1)}}},z=X=>{N(I=>({...I,members:[...I.members,{modelId:X,weight:1,position:I.members.length,enabled:!0}]}))},K=X=>{N(I=>({...I,members:I.members.filter((re,ee)=>ee!==X).map((re,ee)=>({...re,position:ee}))}))},se=async X=>{if(confirm("Delete this combo?"))try{await we.del(`/api/admin/combos/${X}`),ve.success("Combo removed"),M()}catch(I){ve.error(I.message)}};return s.jsxs("div",{children:[s.jsx(wa,{title:"Combos",description:"Virtual models combining physical models",actions:s.jsxs(qn,{open:u,onOpenChange:d,children:[s.jsx(Bo,{asChild:!0,children:s.jsxs(he,{children:[s.jsx(Oo,{className:"mr-1 h-4 w-4"})," New combo"]})}),s.jsxs(jn,{className:"max-w-2xl",children:[s.jsx(Cn,{children:s.jsx(En,{children:"New combo"})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx(be,{children:"Name"}),s.jsx(Ae,{value:C.name,onChange:X=>E({...C,name:X.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Slug (optional — leave empty to use the name as the model ID)"}),s.jsx(Ae,{value:C.slug,onChange:X=>E({...C,slug:X.target.value}),placeholder:"empty → gpt-5.5 · set → combo/gpt-5.5"})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Mode"}),s.jsxs(Vn,{value:C.mode,onValueChange:X=>E({...C,mode:X}),children:[s.jsx(Rn,{children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"fallback",children:"Fallback (ordered)"}),s.jsx(lt,{value:"weighted_round_robin",children:"Weighted round-robin"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ba,{checked:C.enabled,onCheckedChange:X=>E({...C,enabled:X})}),s.jsx(be,{children:"Enabled"})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Members"}),s.jsx(py,{models:o,addedIds:C.members.map(X=>X.modelId),onAdd:T}),s.jsx("div",{className:"mt-2 space-y-1",children:C.members.map((X,I)=>{var re;return s.jsxs("div",{className:"flex items-center gap-2 rounded border p-2 text-sm",children:[s.jsx("span",{className:"font-mono text-xs",children:(re=o.find(ee=>ee.id===X.modelId))==null?void 0:re.publicModelId}),s.jsx(Ae,{type:"number",min:1,value:X.weight,onChange:ee=>{const oe=Number(ee.target.value);E(U=>({...U,members:U.members.map(($,le)=>le===I?{...$,weight:oe}:$)}))},className:"w-20"}),s.jsx(he,{size:"sm",variant:"outline",onClick:()=>_(I),children:"Remove"})]},I)})})]})]}),s.jsxs(In,{children:[s.jsx(he,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),s.jsx(he,{disabled:!C.name||x,onClick:O,children:x?"Creating…":"Create"})]})]})]})}),s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"All combos"}),s.jsxs(on,{children:[a.length," total"]})]}),s.jsx(Ze,{children:s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Public ID"}),s.jsx(pe,{children:"Mode"}),s.jsx(pe,{children:"Members"}),s.jsx(pe,{children:"Healthy"}),s.jsx(pe,{children:"Enabled"}),s.jsx(pe,{})]})}),s.jsxs(Fn,{children:[a.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:6,className:"text-center text-muted-foreground",children:"No combos yet."})}),a.map(X=>s.jsxs(Ye,{children:[s.jsx(de,{className:"font-mono text-xs",children:X.publicModelId}),s.jsx(de,{children:s.jsx(et,{variant:"outline",children:X.mode})}),s.jsx(de,{children:X.memberCount}),s.jsx(de,{children:X.healthyMemberCount}),s.jsx(de,{children:X.enabled?"Yes":"No"}),s.jsx(de,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsxs(he,{size:"sm",variant:"outline",onClick:()=>void A(X),children:[s.jsx(yC,{className:"h-3.5 w-3.5"})," Sửa"]}),s.jsxs(he,{size:"sm",variant:"destructive",onClick:()=>se(X.id),children:[s.jsx(_c,{className:"h-3.5 w-3.5"})," Xoá"]})]})})]},X.id))]})]})})]}),s.jsx(qn,{open:h,onOpenChange:p,children:s.jsxs(jn,{className:"max-w-2xl",children:[s.jsx(Cn,{children:s.jsx(En,{children:"Edit combo"})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx(be,{children:"Name"}),s.jsx(Ae,{value:j.name,onChange:X=>N({...j,name:X.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Slug (optional — leave empty to use the name as the model ID)"}),s.jsx(Ae,{value:j.slug,onChange:X=>N({...j,slug:X.target.value}),placeholder:"empty → gpt-5.5 · set → combo/gpt-5.5"})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Mode"}),s.jsxs(Vn,{value:j.mode,onValueChange:X=>N({...j,mode:X}),children:[s.jsx(Rn,{children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"fallback",children:"Fallback (ordered)"}),s.jsx(lt,{value:"weighted_round_robin",children:"Weighted round-robin"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ba,{checked:j.enabled,onCheckedChange:X=>N({...j,enabled:X})}),s.jsx(be,{children:"Enabled"})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Members"}),s.jsx(py,{models:o,addedIds:j.members.map(X=>X.modelId),onAdd:z}),s.jsx("div",{className:"mt-2 space-y-1",children:j.members.map((X,I)=>{var re;return s.jsxs("div",{className:"flex items-center gap-2 rounded border p-2 text-sm",children:[s.jsx("span",{className:"font-mono text-xs",children:(re=o.find(ee=>ee.id===X.modelId))==null?void 0:re.publicModelId}),s.jsx(Ae,{type:"number",min:1,value:X.weight,onChange:ee=>{const oe=Number(ee.target.value);N(U=>({...U,members:U.members.map(($,le)=>le===I?{...$,weight:oe}:$)}))},className:"w-20"}),s.jsx(he,{size:"sm",variant:"outline",onClick:()=>K(I),children:"Remove"})]},I)})})]})]}),s.jsxs(In,{children:[s.jsx(he,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),s.jsx(he,{disabled:!j.name||S,onClick:H,children:S?"Saving…":"Save"})]})]})})]})}function py({models:a,addedIds:l,onAdd:o}){const[i,u]=m.useState(""),h=(i?a.filter(p=>{const g=i.toLowerCase();return p.publicModelId.toLowerCase().includes(g)||p.displayName.toLowerCase().includes(g)}):a).filter(p=>!l.includes(p.id));return s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Wy,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),s.jsx(Ae,{className:"pl-8",placeholder:"Search models…",value:i,onChange:p=>u(p.target.value)}),i&&s.jsx("button",{className:"absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",onClick:()=>u(""),children:s.jsx(Oc,{className:"h-4 w-4"})})]}),h.length===0?s.jsx("p",{className:"text-xs text-muted-foreground",children:"No models match."}):s.jsx("div",{className:"max-h-40 space-y-1 overflow-auto rounded border p-1",children:h.map(p=>s.jsxs("div",{className:"flex items-center justify-between rounded p-1 text-sm hover:bg-accent",children:[s.jsx("span",{className:"font-mono text-xs",children:p.publicModelId}),s.jsx(he,{size:"sm",variant:"ghost",onClick:()=>o(p.id),children:"+ Add"})]},p.id))})]})}function ED(){const[a,l]=m.useState([]),[o,i]=m.useState([]),[u,d]=m.useState([]),[h,p]=m.useState(!1),[g,v]=m.useState({alias:"",targetKind:"model",targetId:"",enabled:!0}),x=async()=>{const[S,w,C]=await Promise.all([we.get("/api/admin/aliases"),we.get("/api/admin/models"),we.get("/api/admin/combos")]);l(S.aliases),i(w.models),d(C.combos)};m.useEffect(()=>{x()},[]);const y=async()=>{try{await we.post("/api/admin/aliases",g),ve.success("Alias created"),p(!1),v({alias:"",targetKind:"model",targetId:"",enabled:!0}),x()}catch(S){ve.error(S.message)}};return s.jsxs("div",{children:[s.jsx(wa,{title:"Aliases",description:"Stable client-visible names for models or combos",actions:s.jsxs(qn,{open:h,onOpenChange:p,children:[s.jsx(Bo,{asChild:!0,children:s.jsxs(he,{children:[s.jsx(Oo,{className:"mr-1 h-4 w-4"})," New alias"]})}),s.jsxs(jn,{children:[s.jsx(Cn,{children:s.jsx(En,{children:"New alias"})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx(be,{children:"Alias"}),s.jsx(Ae,{value:g.alias,onChange:S=>v({...g,alias:S.target.value}),placeholder:"coding"})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Target type"}),s.jsxs(Vn,{value:g.targetKind,onValueChange:S=>v({...g,targetKind:S}),children:[s.jsx(Rn,{children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"model",children:"Model"}),s.jsx(lt,{value:"combo",children:"Combo"})]})]})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Target"}),s.jsxs(Vn,{value:g.targetId,onValueChange:S=>v({...g,targetId:S}),children:[s.jsx(Rn,{children:s.jsx(Gn,{placeholder:"Choose target"})}),s.jsx(Nn,{children:(g.targetKind==="model"?o:u).map(S=>s.jsx(lt,{value:S.id,children:S.publicModelId},S.id))})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ba,{checked:g.enabled,onCheckedChange:S=>v({...g,enabled:S})}),s.jsx(be,{children:"Enabled"})]})]}),s.jsxs(In,{children:[s.jsx(he,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),s.jsx(he,{disabled:!g.alias||!g.targetId,onClick:y,children:"Create"})]})]})]})}),s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"All aliases"}),s.jsxs(on,{children:[a.length," total"]})]}),s.jsx(Ze,{children:s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Alias"}),s.jsx(pe,{children:"Target"}),s.jsx(pe,{children:"Type"}),s.jsx(pe,{children:"Enabled"}),s.jsx(pe,{})]})}),s.jsxs(Fn,{children:[a.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:5,className:"text-center text-muted-foreground",children:"No aliases yet."})}),a.map(S=>s.jsxs(Ye,{children:[s.jsx(de,{className:"font-mono text-xs",children:S.alias}),s.jsx(de,{className:"font-mono text-xs",children:S.targetName??S.targetId}),s.jsx(de,{children:s.jsx(et,{variant:"outline",children:S.targetKind})}),s.jsx(de,{children:S.enabled?"Yes":"No"}),s.jsx(de,{className:"text-right",children:s.jsx(he,{size:"sm",variant:"outline",onClick:async()=>{await we.del(`/api/admin/aliases/${S.id}`),ve.success("Removed"),x()},children:"Delete"})})]},S.id))]})]})})]})]})}function RD(){const[a,l]=m.useState([]),[o,i]=m.useState([]),[u,d]=m.useState([]),[h,p]=m.useState(!1),[g,v]=m.useState(null),[x,y]=m.useState(null),[S,w]=m.useState(null),[C,E]=m.useState({name:"",expiresAt:"",allowAll:!0,permissions:[],rpmLimit:"",tpmLimit:"",concurrency:"",customSecret:""}),j=async()=>{const[A,H,z]=await Promise.all([we.get("/api/admin/api-keys"),we.get("/api/admin/models"),we.get("/api/admin/combos")]);l(A.apiKeys),i(H.models),d(z.combos)};m.useEffect(()=>{j()},[]);const N=async()=>{try{if(g){await we.patch("/api/admin/api-keys",{id:g,name:C.name,expiresAt:C.expiresAt||null,allowAllModels:C.allowAll,permissions:C.allowAll?[]:C.permissions,rpmLimit:C.rpmLimit?Number(C.rpmLimit):null,tpmLimit:C.tpmLimit?Number(C.tpmLimit):null,maxConcurrent:C.concurrency?Number(C.concurrency):null}),p(!1),v(null),E({name:"",expiresAt:"",allowAll:!0,permissions:[],rpmLimit:"",tpmLimit:"",concurrency:"",customSecret:""}),ve.success("Key updated"),j();return}const A=await we.post("/api/admin/api-keys",{name:C.name,expiresAt:C.expiresAt||null,allowAllModels:C.allowAll,permissions:C.allowAll?void 0:C.permissions,rpmLimit:C.rpmLimit?Number(C.rpmLimit):null,tpmLimit:C.tpmLimit?Number(C.tpmLimit):null,maxConcurrent:C.concurrency?Number(C.concurrency):null,...C.customSecret.trim()?{secret:C.customSecret.trim()}:{}});p(!1),y({secret:A.secret,name:A.name}),E({name:"",expiresAt:"",allowAll:!0,permissions:[],rpmLimit:"",tpmLimit:"",concurrency:"",customSecret:""}),j()}catch(A){ve.error(A.message)}},M=async A=>{try{const z=((await we.get(`/api/admin/api-keys/${A.id}`)).apiKey.permissions??[]).filter(K=>K.targetKind==="model"||K.targetKind==="combo");v(A.id),E({name:A.name,expiresAt:A.expiresAt?A.expiresAt.slice(0,16):"",allowAll:A.allowAllModels,permissions:z,rpmLimit:A.rpmLimit!=null?String(A.rpmLimit):"",tpmLimit:A.tpmLimit!=null?String(A.tpmLimit):"",concurrency:A.concurrencyLimit!=null?String(A.concurrencyLimit):"",customSecret:""}),p(!0)}catch(H){ve.error(H.message)}},T=()=>{p(!1),v(null),E({name:"",expiresAt:"",allowAll:!0,permissions:[],rpmLimit:"",tpmLimit:"",concurrency:"",customSecret:""})},_=async(A,H)=>{try{await we.patch("/api/admin/api-keys",{id:A,enabled:!H}),ve.success(H?"Key disabled":"Key enabled"),j()}catch(z){ve.error(z.message)}},O=async A=>{if(window.confirm("Delete this API key? This cannot be undone."))try{await we.del(`/api/admin/api-keys/${A}`),ve.success("Key deleted"),j()}catch(H){ve.error(H.message)}};return s.jsxs("div",{children:[s.jsx(wa,{title:"API Keys",description:"Gateway bearer keys for client applications",actions:s.jsxs(qn,{open:h,onOpenChange:A=>{A?p(!0):T()},children:[s.jsx(Bo,{asChild:!0,children:s.jsxs(he,{children:[s.jsx(Oo,{className:"mr-1 h-4 w-4"})," New key"]})}),s.jsxs(jn,{className:"max-w-2xl",children:[s.jsx(Cn,{children:s.jsx(En,{children:g?"Edit API key":"New API key"})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx(be,{children:"Name"}),s.jsx(Ae,{value:C.name,onChange:A=>E({...C,name:A.target.value})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Expires (optional)"}),s.jsx(Ae,{type:"datetime-local",value:C.expiresAt,onChange:A=>E({...C,expiresAt:A.target.value})})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[s.jsxs("div",{children:[s.jsx(be,{children:"RPM limit"}),s.jsx(Ae,{value:C.rpmLimit,onChange:A=>E({...C,rpmLimit:A.target.value}),type:"number"})]}),s.jsxs("div",{children:[s.jsx(be,{children:"TPM limit"}),s.jsx(Ae,{value:C.tpmLimit,onChange:A=>E({...C,tpmLimit:A.target.value}),type:"number"})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Concurrency"}),s.jsx(Ae,{value:C.concurrency,onChange:A=>E({...C,concurrency:A.target.value}),type:"number"})]})]}),!g&&s.jsxs("div",{children:[s.jsx(be,{children:"Key value (optional)"}),s.jsx(Ae,{value:C.customSecret,onChange:A=>E({...C,customSecret:A.target.value}),placeholder:"Leave empty to auto-generate ld-…"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"If provided, this exact value is stored as the key. Otherwise a random ld-… key is generated."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ba,{checked:C.allowAll,onCheckedChange:A=>E({...C,allowAll:A})}),s.jsx(be,{children:"Allow all current and future models"})]}),!C.allowAll&&s.jsxs("div",{children:[s.jsx(be,{children:"Scope"}),s.jsx("div",{className:"max-h-48 space-y-1 overflow-auto rounded border p-2",children:[...o.map(A=>({targetKind:"model",targetId:A.id,label:A.publicModelId})),...u.map(A=>({targetKind:"combo",targetId:A.id,label:A.publicModelId}))].map(A=>{const H=C.permissions.some(z=>z.targetKind===A.targetKind&&z.targetId===A.targetId);return s.jsxs("label",{className:"flex items-center gap-2 rounded p-1 text-sm hover:bg-accent",children:[s.jsx(xm,{checked:H,onCheckedChange:z=>{E(K=>({...K,permissions:z?[...K.permissions,{targetKind:A.targetKind,targetId:A.targetId}]:K.permissions.filter(se=>!(se.targetKind===A.targetKind&&se.targetId===A.targetId))}))}}),s.jsx("span",{className:"font-mono text-xs",children:A.label}),s.jsx(et,{variant:"outline",className:"ml-1",children:A.targetKind})]},`${A.targetKind}:${A.targetId}`)})})]})]}),s.jsxs(In,{children:[s.jsx(he,{variant:"outline",onClick:T,children:"Cancel"}),s.jsx(he,{disabled:!C.name,onClick:N,children:g?"Save changes":"Create"})]})]})]})}),s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"All keys"}),s.jsxs(on,{children:[a.length," total"]})]}),s.jsx(Ze,{children:s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Name"}),s.jsx(pe,{children:"Prefix"}),s.jsx(pe,{children:"Status"}),s.jsx(pe,{children:"Scope"}),s.jsx(pe,{children:"RPM/TPM/Conc"}),s.jsx(pe,{})]})}),s.jsxs(Fn,{children:[a.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:6,className:"text-center text-muted-foreground",children:"No API keys yet."})}),a.map(A=>s.jsxs(Ye,{children:[s.jsx(de,{className:"font-medium",children:A.name}),s.jsxs(de,{className:"font-mono text-xs",children:[A.keyPrefix,"…"]}),s.jsx(de,{children:A.enabled?s.jsx(et,{variant:"success",children:"enabled"}):s.jsx(et,{variant:"destructive",children:"disabled"})}),s.jsx(de,{children:A.allowAllModels?"all":`${A.modelScopeCount} scoped`}),s.jsx(de,{className:"text-xs",children:[A.rpmLimit,A.tpmLimit,A.concurrencyLimit].map((H,z)=>H?["","RPM","TPM","Conc"][z+1]:null).filter(Boolean).join(" / ")||"—"}),s.jsx(de,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[A.secret&&s.jsxs(s.Fragment,{children:[s.jsx(he,{size:"sm",variant:"ghost",title:"Copy secret",onClick:()=>{navigator.clipboard.writeText(A.secret),ve.success("Copied")},children:s.jsx(Ef,{className:"h-3.5 w-3.5"})}),s.jsx(he,{size:"sm",variant:"ghost",title:"Show secret",onClick:()=>w({secret:A.secret,name:A.name}),children:s.jsx(iC,{className:"h-3.5 w-3.5"})})]}),s.jsx(he,{size:"sm",variant:"ghost",title:"Edit",onClick:()=>void M(A),children:s.jsx(mC,{className:"h-3.5 w-3.5"})}),s.jsxs(he,{size:"sm",variant:"outline",onClick:()=>_(A.id,A.enabled),children:[A.enabled?s.jsx(Z2,{className:"mr-1 h-3.5 w-3.5"}):s.jsx(Dc,{className:"mr-1 h-3.5 w-3.5"}),A.enabled?"Disable":"Enable"]}),s.jsx(he,{size:"sm",variant:"destructive",onClick:()=>O(A.id),children:s.jsx(_c,{className:"h-3.5 w-3.5"})})]})})]},A.id))]})]})})]}),s.jsx(qn,{open:!!x,onOpenChange:A=>{A||y(null)},children:s.jsxs(jn,{children:[s.jsxs(Cn,{children:[s.jsx(En,{children:"API key created"}),s.jsx(ch,{children:"Copy now — this secret will not be shown again."})]}),s.jsx("div",{className:"rounded border bg-muted p-3 font-mono text-xs break-all",children:x==null?void 0:x.secret}),s.jsxs(In,{children:[s.jsxs(he,{onClick:()=>{x&&(navigator.clipboard.writeText(x.secret),ve.success("Copied"))},children:[s.jsx(Ef,{className:"mr-1 h-4 w-4"})," Copy"]}),s.jsx(he,{variant:"outline",onClick:()=>y(null),children:"I have saved it"})]})]})}),s.jsx(qn,{open:!!S,onOpenChange:A=>{A||w(null)},children:s.jsxs(jn,{children:[s.jsxs(Cn,{children:[s.jsxs(En,{children:["API key: ",S==null?void 0:S.name]}),s.jsx(ch,{children:"Full secret for this key, readable any time."})]}),s.jsx("div",{className:"rounded border bg-muted p-3 font-mono text-xs break-all",children:S==null?void 0:S.secret}),s.jsxs(In,{children:[s.jsxs(he,{onClick:()=>{S&&(navigator.clipboard.writeText(S.secret),ve.success("Copied"))},children:[s.jsx(Ef,{className:"mr-1 h-4 w-4"})," Copy"]}),s.jsx(he,{variant:"outline",onClick:()=>w(null),children:"Close"})]})]})})]})}const ND=3e3;function TD(a,l){return!(l.success!=="all"&&a.success!==(l.success==="true")||l.protocol!=="all"&&a.protocol!==l.protocol||l.streaming!=="all"&&a.streaming!==(l.streaming==="true")||l.model&&!a.requestedModel.toLowerCase().includes(l.model.toLowerCase()))}function AD(){const[a,l]=m.useState([]),[o,i]=m.useState(0),[u,d]=m.useState(0),[h,p]=m.useState({success:"all",protocol:"all",streaming:"all",model:""}),[g,v]=m.useState(null),[x,y]=m.useState(null),[S,w]=m.useState(0),C=50,E=m.useRef(Date.now()),j=m.useRef(new Set),N=m.useRef(h);N.current=h;const M=m.useRef(u);M.current=u;const T=m.useCallback(async()=>{const O=new URLSearchParams;O.set("limit",String(C)),O.set("offset",String(u)),h.success!=="all"&&O.set("success",h.success),h.protocol!=="all"&&O.set("protocol",h.protocol),h.streaming!=="all"&&O.set("streaming",h.streaming),h.model&&O.set("requestedModel",h.model);const A=await we.get(`/api/admin/requests?${O.toString()}`);l(A.requests),i(A.total);for(const H of A.requests)j.current.add(H.id)},[u,h]);m.useEffect(()=>{T()},[T]),m.useEffect(()=>{w(0)},[u,h]),m.useEffect(()=>{let O=!1,A=null;const H=new Set,z=()=>{O||(A=new EventSource(`/api/admin/requests/stream?since=${E.current}`),A.addEventListener("request",K=>{if(!O)try{const se=JSON.parse(K.data),X=new Date(se.createdAt).getTime();if(Number.isFinite(X)&&(E.current=Math.max(E.current,X)),j.current.has(se.id))return;j.current.add(se.id),w(I=>I+1),M.current===0&&TD(se,N.current)&&(l(I=>I.some(re=>re.id===se.id)?I:[se,...I].slice(0,C)),i(I=>I+1))}catch{}}),A.onerror=()=>{A==null||A.close(),A=null,O||H.add(setTimeout(z,ND))})};return z(),()=>{O=!0,A==null||A.close();for(const K of H)clearTimeout(K);H.clear()}},[]);const _=async O=>{v(O);const A=await we.get(`/api/admin/requests/${O}`);y(A)};return s.jsxs("div",{children:[s.jsx(wa,{title:"Requests",description:`${o} matching · live updates`}),s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(Vn,{value:h.success,onValueChange:O=>{d(0),p({...h,success:O})},children:[s.jsx(Rn,{className:"w-36",children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"all",children:"All"}),s.jsx(lt,{value:"true",children:"Success"}),s.jsx(lt,{value:"false",children:"Failed"})]})]}),s.jsxs(Vn,{value:h.protocol,onValueChange:O=>{d(0),p({...h,protocol:O})},children:[s.jsx(Rn,{className:"w-32",children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"all",children:"Any protocol"}),s.jsx(lt,{value:"openai",children:"OpenAI"}),s.jsx(lt,{value:"anthropic",children:"Anthropic"})]})]}),s.jsxs(Vn,{value:h.streaming,onValueChange:O=>{d(0),p({...h,streaming:O})},children:[s.jsx(Rn,{className:"w-32",children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"all",children:"Any"}),s.jsx(lt,{value:"true",children:"Streaming"}),s.jsx(lt,{value:"false",children:"Non-stream"})]})]}),s.jsx(Ae,{className:"max-w-xs",placeholder:"Model contains…",value:h.model,onChange:O=>{d(0),p({...h,model:O.target.value})}}),S>0&&s.jsxs(he,{size:"sm",variant:"secondary",onClick:()=>{w(0),T()},children:[S," new request",S>1?"s":""," — refresh"]})]}),s.jsx(Qe,{className:"mt-3 text-base",children:"Results"})]}),s.jsxs(Ze,{children:[s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Time"}),s.jsx(pe,{children:"Status"}),s.jsx(pe,{children:"Requested"}),s.jsx(pe,{children:"Final"}),s.jsx(pe,{children:"Tokens"}),s.jsx(pe,{children:"Latency"}),s.jsx(pe,{children:"Attempts"}),s.jsx(pe,{children:"Key"}),s.jsx(pe,{children:"IP"}),s.jsx(pe,{})]})}),s.jsxs(Fn,{children:[a.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:10,className:"text-center text-muted-foreground",children:"No requests yet."})}),a.map(O=>s.jsxs(Ye,{className:"cursor-pointer",onClick:()=>_(O.id),children:[s.jsx(de,{className:"text-xs",children:Ah(O.createdAt)}),s.jsx(de,{children:O.success?s.jsx(et,{variant:"success",children:O.httpStatus}):s.jsx(et,{variant:"destructive",children:O.httpStatus})}),s.jsx(de,{className:"font-mono text-xs",children:O.requestedModel}),s.jsx(de,{className:"font-mono text-xs text-muted-foreground",children:O.finalModelPublicId??"—"}),s.jsxs(de,{className:"text-xs",children:[Mt(O.inputTokens+O.outputTokens)," ",O.cacheReadTokens?s.jsxs("span",{className:"text-amber-600",children:["(+",O.cacheReadTokens," cache)"]}):null]}),s.jsxs(de,{className:"text-xs",children:[dr(O.totalLatencyMs),O.ttftMs?s.jsxs("span",{className:"text-muted-foreground",children:[" · ttft ",O.ttftMs,"ms"]}):null]}),s.jsxs(de,{className:"text-xs",children:[O.attemptsCount,O.gatewayCacheHit?s.jsx(et,{variant:"secondary",className:"ml-1",children:"cache"}):null]}),s.jsx(de,{className:"text-xs",children:O.apiKeyName??"—"}),s.jsx(de,{className:"text-xs",children:O.clientIp}),s.jsx(de,{className:"text-right",children:s.jsx(he,{size:"sm",variant:"ghost",children:"View"})})]},O.id))]})]}),s.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[s.jsxs("span",{className:"text-xs text-muted-foreground",children:["Showing ",u+1,"–",Math.min(u+C,o)," of ",o]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(he,{size:"sm",variant:"outline",disabled:u===0,onClick:()=>d(Math.max(0,u-C)),children:"Prev"}),s.jsx(he,{size:"sm",variant:"outline",disabled:u+C>=o,onClick:()=>d(u+C),children:"Next"})]})]})]})]}),s.jsx(qn,{open:!!g,onOpenChange:O=>{O||(v(null),y(null))},children:s.jsxs(jn,{className:"max-w-3xl",children:[s.jsx(Cn,{children:s.jsxs(En,{children:["Request ",nE(g,16)]})}),x?s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-muted-foreground text-xs",children:"Status"}),x.request.success?s.jsx(et,{variant:"success",children:x.request.httpStatus}):s.jsx(et,{variant:"destructive",children:x.request.httpStatus})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-muted-foreground text-xs",children:"Latency"}),dr(x.request.totalLatencyMs)]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-muted-foreground text-xs",children:"Tokens"}),"in ",Mt(x.request.inputTokens)," · out ",Mt(x.request.outputTokens)," · cache ",Mt(x.request.cacheReadTokens)]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-muted-foreground text-xs",children:"Attempts"}),x.request.attemptsCount]})]}),x.request.errorType&&s.jsxs("div",{className:"rounded border border-destructive/40 bg-destructive/10 p-2",children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Error"}),s.jsxs("div",{className:"font-mono text-xs",children:[x.request.errorType,": ",x.request.errorMessage]})]}),x.request.requestPayload&&s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Request content"}),s.jsx("pre",{className:"max-h-60 overflow-auto rounded bg-muted p-2 font-mono text-xs whitespace-pre-wrap",children:x.request.requestPayload})]}),x.request.responsePayload&&s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Response content"}),s.jsx("pre",{className:"max-h-60 overflow-auto rounded bg-muted p-2 font-mono text-xs whitespace-pre-wrap",children:x.request.responsePayload})]}),x.attempts.length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Attempts"}),s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"#"}),s.jsx(pe,{children:"Provider"}),s.jsx(pe,{children:"Model"}),s.jsx(pe,{children:"Status"}),s.jsx(pe,{children:"Latency"}),s.jsx(pe,{children:"Reason"})]})}),s.jsx(Fn,{children:x.attempts.map(O=>s.jsxs(Ye,{children:[s.jsx(de,{children:O.attemptNumber}),s.jsx(de,{children:O.providerName}),s.jsx(de,{className:"font-mono text-xs",children:O.modelPublicId}),s.jsx(de,{children:O.success?s.jsx(et,{variant:"success",children:String(O.statusCode??"OK")}):s.jsx(et,{variant:"destructive",children:String(O.statusCode??"err")})}),s.jsx(de,{className:"text-xs",children:dr(O.latencyMs)}),s.jsx(de,{className:"text-xs",children:O.failureReason??O.selectionReason})]},O.id))})]})]})]}):s.jsx("div",{className:"text-muted-foreground",children:"Loading…"})]})})]})}var MD=Object.defineProperty,Rs=(a,l)=>MD(a,"name",{value:l,configurable:!0}),ym="Tabs",[DD,Z_]=fn(ym,[Yc]),R1=Yc(),[_D,bm]=DD(ym),OD=m.forwardRef(Rs(function(l,o){const{__scopeTabs:i,value:u,onValueChange:d,defaultValue:h,orientation:p="horizontal",dir:g,activationMode:v="automatic",...x}=l,y=zo(g),[S,w]=Ja({prop:u,onChange:d,defaultProp:h??"",caller:ym});return s.jsx(_D,{scope:i,baseId:ga(),value:S,onValueChange:w,orientation:p,dir:y,activationMode:v,children:s.jsx(Be.div,{dir:y,"data-orientation":p,...x,ref:o})})},"Tabs")),kD="TabsList",zD=m.forwardRef(Rs(function(l,o){const{__scopeTabs:i,loop:u=!0,...d}=l,h=bm(kD,i),p=R1(i);return s.jsx(h0,{asChild:!0,...p,orientation:h.orientation,dir:h.dir,loop:u,children:s.jsx(Be.div,{role:"tablist","aria-orientation":h.orientation,...d,ref:o})})},"TabsList")),LD="TabsTrigger",UD=m.forwardRef(Rs(function(l,o){const{__scopeTabs:i,value:u,disabled:d=!1,...h}=l,p=bm(LD,i),g=R1(i),v=Sm(p.baseId,u),x=wm(p.baseId,u),y=u===p.value;return s.jsx(m0,{asChild:!0,...g,focusable:!d,active:y,children:s.jsx(Be.button,{type:"button",role:"tab","aria-selected":y,"aria-controls":x,"data-state":y?"active":"inactive","data-disabled":d?"":void 0,disabled:d,id:v,...h,ref:o,onMouseDown:Ee(l.onMouseDown,S=>{!d&&S.button===0&&S.ctrlKey===!1?p.onValueChange(u):S.preventDefault()}),onKeyDown:Ee(l.onKeyDown,S=>{d||S.target!==S.currentTarget||[" ","Enter"].includes(S.key)&&p.onValueChange(u)}),onFocus:Ee(l.onFocus,()=>{const S=p.activationMode!=="manual";!y&&!d&&S&&p.onValueChange(u)})})})},"TabsTrigger")),BD="TabsContent",HD=m.forwardRef(Rs(function(l,o){const{__scopeTabs:i,value:u,forceMount:d,children:h,...p}=l,g=bm(BD,i),v=Sm(g.baseId,u),x=wm(g.baseId,u),y=u===g.value,S=m.useRef(y);return m.useEffect(()=>{const w=requestAnimationFrame(()=>S.current=!1);return()=>cancelAnimationFrame(w)},[]),s.jsx(al,{present:d||y,children:({present:w})=>s.jsx(Be.div,{"data-state":y?"active":"inactive","data-orientation":g.orientation,role:"tabpanel","aria-labelledby":v,hidden:!w,id:x,tabIndex:0,...p,ref:o,style:{...l.style,animationDuration:S.current?"0s":void 0},children:w&&h})})},"TabsContent"));function Sm(a,l){return`${a}-trigger-${l}`}Rs(Sm,"makeTriggerId");function wm(a,l){return`${a}-content-${l}`}Rs(wm,"makeContentId");var PD=OD,N1=zD,T1=UD,A1=HD;const M1=PD,jm=m.forwardRef(({className:a,...l},o)=>s.jsx(N1,{ref:o,className:Re("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",a),...l}));jm.displayName=N1.displayName;const Ka=m.forwardRef(({className:a,...l},o)=>s.jsx(T1,{ref:o,className:Re("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",a),...l}));Ka.displayName=T1.displayName;const ds=m.forwardRef(({className:a,...l},o)=>s.jsx(A1,{ref:o,className:Re("mt-2 ring-offset-background focus-visible:outline-none",a),...l}));ds.displayName=A1.displayName;const qD=3e3,ID=1600,VD=10,GD=3,YD=12,$D=10*6e4;function KD(a,l){return{...a,totalRequests:a.totalRequests+1,successfulRequests:a.successfulRequests+(l.success?1:0),failedRequests:a.failedRequests+(l.success?0:1),successRate:a.totalRequests+1?(a.successfulRequests+(l.success?1:0))/(a.totalRequests+1):0,inputTokens:a.inputTokens+l.inputTokens,outputTokens:a.outputTokens+l.outputTokens,totalTokens:a.totalTokens+l.inputTokens+l.outputTokens,cacheReadTokens:a.cacheReadTokens+l.cacheReadTokens,averageLatencyMs:(a.averageLatencyMs*a.totalRequests+l.totalLatencyMs)/(a.totalRequests+1)}}function XD(a){const[l,o]=m.useState(null),[i,u]=m.useState(null),[d,h]=m.useState([]),[p,g]=m.useState([]),[v,x]=m.useState([]),[y,S]=m.useState([]),[w,C]=m.useState(!0),[E,j]=m.useState(null),N=m.useRef([]),M=m.useRef(null),T=m.useRef(new Set),_=m.useRef(Date.now()),O=m.useRef(0),A=m.useRef([]),H=m.useRef([]);return m.useEffect(()=>{let z=!1;return C(!0),j(null),T.current=new Set,_.current=Date.now(),we.get(`/api/admin/stats?preset=${a}`).then(K=>{if(!z){o(K),u(K.summary),M.current=K.summary,h(K.recent),g(K.providers),N.current=K.providers;for(const se of K.recent)T.current.add(se.id);C(!1)}}).catch(K=>{z||(j(K.message),C(!1))}),()=>{z=!0}},[a]),m.useEffect(()=>{let z=!1,K=null;const se=new Set,X=()=>{z||(K=new EventSource(`/api/admin/requests/stream?since=${_.current}`),K.addEventListener("request",re=>{if(!z)try{const ee=JSON.parse(re.data),oe=new Date(ee.createdAt).getTime();if(Number.isFinite(oe)&&(_.current=Math.max(_.current,oe)),T.current.has(ee.id))return;if(T.current.add(ee.id),M.current&&u(KD(M.current,ee)),h(U=>U.some($=>$.id===ee.id)?U:[ee,...U].slice(0,VD)),ee.providerId){N.current=N.current.map(B=>B.id===ee.providerId?{...B,requests:B.requests+1,errorRate:B.requests+1?(B.errorRate*B.requests+(ee.success?0:1))/(B.requests+1):0}:B),g(N.current);const U=`p${++O.current}`,$={id:U,providerId:ee.providerId,success:ee.success};A.current=[...A.current.slice(-(GD*4)),$],x(A.current);const le=setTimeout(()=>{A.current=A.current.filter(B=>B.id!==U),x(A.current)},ID);se.add(le)}H.current.some(U=>U.id===ee.id)&&(H.current=H.current.filter(U=>U.id!==ee.id),S(H.current))}catch{}}),K.addEventListener("request_started",re=>{if(!z)try{const ee=JSON.parse(re.data);if(!ee.providerId||ee.providerId==="")return;H.current=[...H.current.filter(oe=>oe.id!==ee.requestId).slice(-(YD-1)),{id:ee.requestId,providerId:ee.providerId,startedAt:Date.now(),ttftMs:ee.ttftMs??0}],S(H.current)}catch{}}),K.onerror=()=>{K==null||K.close(),K=null,z||se.add(setTimeout(X,qD))})};X();const I=setInterval(()=>{const re=Date.now()-$D;H.current.some(ee=>ee.startedAt<re)&&(H.current=H.current.filter(ee=>ee.startedAt>=re),S(H.current))},3e4);return()=>{z=!0,K==null||K.close();for(const re of se)clearTimeout(re);se.clear(),clearInterval(I)}},[]),m.useEffect(()=>{const z=setInterval(()=>{we.get("/api/admin/providers").then(K=>{const se=new Map(K.providers.map(X=>[X.id,X]));N.current=N.current.map(X=>{const I=se.get(X.id);return I?{...X,health:I.health,enabled:I.enabled}:X}),g(N.current)}).catch(()=>{})},3e4);return()=>clearInterval(z)},[]),{snapshot:l,live:i??(l==null?void 0:l.summary)??FD,recent:d,providers:p,pulses:v,activeRoutes:y,loading:w,error:E}}const FD={totalRequests:0,successfulRequests:0,failedRequests:0,successRate:0,inputTokens:0,outputTokens:0,totalTokens:0,cacheReadTokens:0,cacheWriteTokens:0,reasoningTokens:0,averageLatencyMs:0,p95LatencyMs:0,averageTtftMs:null,p95TtftMs:null,cacheHitRate:0,gatewayCacheHitRate:0,fallbackRate:0};function D1({data:a,className:l,strokeClass:o="stroke-primary",fillClass:i}){if(a.length===0)return s.jsx("svg",{className:Re("h-6 w-20",l),viewBox:"0 0 80 24"});const h=Math.max(...a),p=Math.min(...a),g=h-p||1,x=a.map((y,S)=>{const w=S/(a.length-1)*78+1,C=22-(y-p)/g*20;return`${w.toFixed(1)},${C.toFixed(1)}`}).join(" ");return s.jsxs("svg",{className:Re("h-6 w-20",l),viewBox:"0 0 80 24",preserveAspectRatio:"none",children:[i&&s.jsx("polygon",{points:`1,23 ${x} 79,23`,className:i}),s.jsx("polyline",{points:x,fill:"none",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:o})]})}function QD(a,l,o){const i=performance.now();let u=0;const d=h=>{const p=Math.min((h-i)/l,1),g=Math.round(a*p);g!==u&&(u=g,o(g)),p<1&&requestAnimationFrame(d)};requestAnimationFrame(d)}function ZD({delta:a,inverse:l}){if(Math.abs(a)<.005)return null;const o=a>0,i=l?!o:o,u=`${(Math.abs(a)*100).toFixed(1)}%`;return s.jsxs("span",{className:Re("ml-1.5 inline-flex items-center rounded-full px-1.5 py-0.5 text-[10px] font-semibold leading-none",i?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300":"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300"),children:[s.jsx("span",{className:"mr-0.5",children:o?"▲":"▼"}),u]})}function Ol({icon:a,label:l,value:o,format:i="number",delta:u,deltaInverse:d,sparkData:h,sparkStroke:p}){const[g,v]=m.useState(0),x=m.useRef(0);m.useEffect(()=>{const S=x.current,w=o;x.current=o,S!==w&&QD(Math.abs(w-S),600,C=>v(S+(w>S?C:-C)))},[o]);const y=i==="percent"?kc(g):i==="latency"?dr(g):Mt(Math.round(g));return s.jsxs(Xe,{children:[s.jsxs(Fe,{className:"flex flex-row items-center justify-between pb-1",children:[s.jsxs(Qe,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:[s.jsx(a,{className:"h-4 w-4"}),l]}),u!==void 0&&s.jsx(ZD,{delta:u,inverse:d})]}),s.jsxs(Ze,{className:"flex items-end justify-between",children:[s.jsx("span",{className:"text-2xl font-semibold tabular-nums",children:y}),h&&h.length>1&&s.jsx(D1,{data:h,strokeClass:p??"stroke-primary",fillClass:"fill-primary/10"})]})]})}const _1=1e3,gy=380,uc=60,kl=_1/2,zl=720,Hf=62,JD=260;function WD(a){return a==="healthy"?"fill-emerald-400":a==="degraded"?"fill-amber-400":"fill-red-400"}function dc(a,l,o,i){const u=a+(o-a)*.45,d=a+(o-a)*.55;return`M${a},${l} C${u},${l} ${d},${i} ${o},${i}`}function e_({liveRequests:a,successRate:l,providers:o,pulses:i,activeRoutes:u}){const d=gy/2,h=d,p=Math.max(1,o.reduce((x,y)=>x+y.requests,0)),g=new Set(u.map(x=>x.providerId)),v=g.size>0;return s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-2",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Qe,{className:"text-base",children:"Real-time Request Routing"}),s.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-emerald-400"})," healthy"]}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-amber-400"})," degraded"]}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-red-400"})," down"]})]})]})}),s.jsx(Ze,{className:"pt-0",children:s.jsx("div",{className:"relative w-full",children:s.jsxs("svg",{viewBox:`0 0 ${_1} ${gy}`,className:"w-full h-auto",preserveAspectRatio:"xMidYMid meet",children:[s.jsx("defs",{children:s.jsxs("filter",{id:"glow",x:"-50%",y:"-50%",width:"200%",height:"200%",children:[s.jsx("feGaussianBlur",{stdDeviation:"3",result:"blur"}),s.jsxs("feMerge",{children:[s.jsx("feMergeNode",{in:"blur"}),s.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),o.map(x=>{const S=60+o.indexOf(x)*Hf,w=x.requests/p,C=Math.max(1.5,Math.min(6,2+w*8)),E=g.has(x.id);return s.jsxs("g",{children:[E&&s.jsx("path",{d:dc(kl,d,zl-20,S),fill:"none",stroke:"hsl(var(--primary) / 0.25)",strokeWidth:C+6,strokeLinecap:"round"}),s.jsx("path",{d:dc(kl,d,zl-20,S),fill:"none",stroke:E?"hsl(var(--primary))":"hsl(var(--border))",strokeWidth:E?C+1:C,strokeLinecap:"round",opacity:E?.95:.6,className:E?"route-active":void 0})]},x.id)}),s.jsx("path",{d:dc(uc+30,h,kl-30,d),fill:"none",stroke:v?"hsl(var(--primary))":"hsl(var(--border))",strokeWidth:3,strokeLinecap:"round",strokeDasharray:"6 3",opacity:v?.9:.5,className:v?"route-active":void 0}),i.map(x=>{const y=o.findIndex(E=>E.id===x.providerId);if(y===-1)return null;const S=60+y*Hf,w=dc(kl,d,zl-20,S),C=x.success?"var(--primary)":"#f87171";return s.jsxs("g",{filter:"url(#glow)",children:[s.jsx("circle",{r:5,fill:C,opacity:.9,children:s.jsx("animateMotion",{dur:"1.4s",fill:"freeze",path:w})}),s.jsx("circle",{r:9,fill:C,opacity:.25,children:s.jsx("animateMotion",{dur:"1.4s",fill:"freeze",path:w})})]},x.id)}),s.jsx("circle",{cx:uc,cy:h,r:28,fill:"hsl(var(--card))",stroke:"hsl(var(--border))",strokeWidth:1.5}),s.jsx("text",{x:uc,y:h-4,textAnchor:"middle",className:"fill-foreground",fontSize:12,fontWeight:600,children:vy(a)}),s.jsx("text",{x:uc,y:h+10,textAnchor:"middle",className:"fill-muted-foreground",fontSize:9,children:"requests"}),s.jsx("circle",{cx:kl,cy:d,r:36,fill:"hsl(var(--card))",stroke:"var(--primary)",strokeWidth:2}),s.jsx("image",{x:kl-12,y:d-16,width:24,height:24,href:"/logo.png"}),s.jsx("text",{x:kl,y:d+28,textAnchor:"middle",className:"fill-muted-foreground",fontSize:9,children:"AI Gateway"}),s.jsxs("text",{x:kl,y:d+38,textAnchor:"middle",className:"fill-emerald-500",fontSize:10,fontWeight:600,children:[(l*100).toFixed(1),"%"]}),o.map((x,y)=>{const S=60+y*Hf,w=x.requests/p,C=!x.enabled||x.requests===0;return s.jsxs("g",{opacity:C?.4:1,children:[s.jsx("rect",{x:zl-20,y:S-14,width:JD,height:50,rx:8,fill:"hsl(var(--card))",stroke:"hsl(var(--border))",strokeWidth:1}),s.jsx("circle",{cx:zl-6,cy:S+10,r:4,className:WD(x.health)}),s.jsx("text",{x:zl+6,y:S-2,className:"fill-foreground",fontSize:12,fontWeight:500,children:x.name}),s.jsxs("text",{x:zl+6,y:S+12,className:"fill-muted-foreground",fontSize:10,children:[x.modelCount," model",x.modelCount!==1?"s":""," · ",vy(x.requests)," req"]}),s.jsxs("text",{x:zl+6,y:S+25,className:"fill-muted-foreground",fontSize:10,children:[(w*100).toFixed(1),"% traffic · ",x.avgLatencyMs<1e3?`${Math.round(x.avgLatencyMs)}ms`:`${(x.avgLatencyMs/1e3).toFixed(1)}s`," avg",x.errorRate>0&&s.jsxs("tspan",{className:"fill-red-500",children:[" · ",(x.errorRate*100).toFixed(0),"% err"]})]})]},x.id)})]})})})]})}function vy(a){return a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:String(a)}function t_({rows:a}){return s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-2",children:s.jsx(Qe,{className:"text-base",children:"Recent Requests"})}),s.jsx(Ze,{children:a.length===0?s.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"No requests yet — traffic will appear here live."}):s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Model"}),s.jsx(pe,{children:"Provider"}),s.jsx(pe,{children:"Tokens"}),s.jsx(pe,{children:"Status"}),s.jsx(pe,{children:"Time"})]})}),s.jsx(Fn,{children:a.map(l=>s.jsxs(Ye,{children:[s.jsx(de,{className:"font-mono text-xs",children:l.requestedModel}),s.jsx(de,{className:"text-xs text-muted-foreground",children:l.providerName??"—"}),s.jsxs(de,{className:"text-xs",children:[s.jsxs("span",{className:"font-mono",children:["in ",Mt(l.inputTokens)," · out ",Mt(l.outputTokens)]}),l.cacheReadTokens>0&&s.jsxs("span",{className:"ml-1 text-amber-600",children:["(+",Mt(l.cacheReadTokens)," cache)"]})]}),s.jsx(de,{children:s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:l.success?"h-2 w-2 rounded-full bg-emerald-400":"h-2 w-2 rounded-full bg-red-400"}),s.jsx("span",{className:"text-xs",children:l.success?l.httpStatus:`${l.httpStatus} err`})]})}),s.jsx(de,{className:"text-xs text-muted-foreground",children:aE(l.createdAt)})]},l.id))})]})})]})}const fh=34,xy=2*Math.PI*fh;function n_(a){return a>=.95?{stroke:"#4ade80",text:"text-emerald-500"}:a>=.8?{stroke:"#fbbf24",text:"text-amber-500"}:{stroke:"#f87171",text:"text-red-500"}}function a_({successRate:a,averageLatencyMs:l,latencySpark:o}){const{stroke:i,text:u}=n_(a),d=Math.min(1,Math.max(0,a)),h=xy*(1-d);return s.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-2",children:s.jsx(Qe,{className:"text-base",children:"Success Rate"})}),s.jsxs(Ze,{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"relative h-20 w-20",children:[s.jsxs("svg",{viewBox:"0 0 80 80",className:"h-20 w-20 -rotate-90",children:[s.jsx("circle",{cx:"40",cy:"40",r:fh,fill:"none",stroke:"hsl(var(--border))",strokeWidth:7}),s.jsx("circle",{cx:"40",cy:"40",r:fh,fill:"none",stroke:i,strokeWidth:7,strokeLinecap:"round",strokeDasharray:xy,strokeDashoffset:h,style:{transition:"stroke-dashoffset 0.6s ease, stroke 0.4s ease"}})]}),s.jsx("span",{className:`absolute inset-0 flex items-center justify-center text-sm font-semibold tabular-nums ${u}`,children:kc(a)})]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Share of requests that completed successfully over the selected window. Updated in real time."})]})]}),s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-2",children:s.jsx(Qe,{className:"text-base",children:"Average Latency"})}),s.jsxs(Ze,{className:"flex items-end justify-between",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-semibold tabular-nums",children:dr(l)}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Live average across the selected window"})]}),s.jsx(D1,{data:o,strokeClass:"stroke-amber-500",fillClass:"fill-amber-500/10",className:"h-10 w-28"})]})]})]})}function l_(){const[a,l]=m.useState("7d"),{snapshot:o,live:i,recent:u,providers:d,pulses:h,activeRoutes:p,loading:g,error:v}=XD(a);if(g)return s.jsx("div",{className:"text-muted-foreground",children:"Loading…"});if(v||!o)return s.jsxs("div",{className:"text-destructive",children:["Failed to load statistics: ",v??"unknown error"]});const x=i,y=o.previous,S=o.series;function w(j,N){return N>0?(j-N)/N:void 0}const C=S.map(j=>j.requests),E=S.map(j=>j.avgLatency);return s.jsxs("div",{children:[s.jsx(wa,{title:"Statistics",description:"Real-time monitoring dashboard",actions:s.jsx(M1,{value:a,onValueChange:j=>void l(j),children:s.jsxs(jm,{children:[s.jsx(Ka,{value:"today",children:"Today"}),s.jsx(Ka,{value:"7d",children:"7 days"}),s.jsx(Ka,{value:"30d",children:"30 days"})]})})}),s.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[s.jsx(Ol,{icon:$y,label:"Requests",value:x.totalRequests,delta:w(x.totalRequests,y.totalRequests),sparkData:C}),s.jsx(Ol,{icon:Dc,label:"Success rate",format:"percent",value:x.successRate,delta:w(x.successRate,y.successRate),sparkData:C,sparkStroke:"stroke-emerald-500"}),s.jsx(Ol,{icon:sC,label:"Total tokens",value:x.totalTokens,delta:w(x.totalTokens,y.totalTokens),sparkData:S.map(j=>j.inputTokens+j.outputTokens)}),s.jsx(Ol,{icon:oC,label:"Cache hit rate",format:"percent",value:x.cacheHitRate,delta:w(x.cacheHitRate,y.cacheHitRate),sparkData:S.map(j=>j.cacheRead)}),s.jsx(Ol,{icon:aC,label:"Avg latency",format:"latency",value:x.averageLatencyMs,delta:w(x.averageLatencyMs,y.averageLatencyMs),deltaInverse:!0,sparkData:E,sparkStroke:"stroke-amber-500"}),s.jsx(Ol,{icon:Fy,label:"p95 latency",format:"latency",value:x.p95LatencyMs}),s.jsx(Ol,{icon:SC,label:"Avg TTFT",format:"latency",value:x.averageTtftMs??0}),s.jsx(Ol,{icon:gC,label:"Fallback rate",format:"percent",value:x.fallbackRate,delta:w(x.fallbackRate,y.fallbackRate),deltaInverse:!0})]}),s.jsx("div",{className:"mt-6",children:s.jsx(e_,{liveRequests:x.totalRequests,successRate:x.successRate,providers:d,pulses:h,activeRoutes:p})}),s.jsxs("div",{className:"mt-6 grid gap-4 lg:grid-cols-3",children:[s.jsx("div",{className:"lg:col-span-2",children:s.jsx(t_,{rows:u})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-2",children:s.jsx(Qe,{className:"text-base",children:"Top Models"})}),s.jsx(Ze,{children:s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Model"}),s.jsx(pe,{children:"Req"}),s.jsx(pe,{children:"Errors"}),s.jsx(pe,{children:"Tokens"})]})}),s.jsxs(Fn,{children:[o.topModels.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:4,className:"text-muted-foreground text-center",children:"No data"})}),o.topModels.map(j=>s.jsxs(Ye,{children:[s.jsx(de,{className:"font-mono text-xs",children:j.publicId}),s.jsx(de,{className:"text-xs",children:Mt(j.requests)}),s.jsx(de,{className:"text-xs",children:s.jsx("span",{className:j.errorRate>.1?"text-destructive":"text-muted-foreground",children:kc(j.errorRate)})}),s.jsx(de,{className:"text-xs",children:Mt(j.totalTokens)})]},j.publicId))]})]})})]}),s.jsxs(Xe,{children:[s.jsx(Fe,{className:"pb-2",children:s.jsx(Qe,{className:"text-base",children:"Top API Keys"})}),s.jsx(Ze,{children:s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Key"}),s.jsx(pe,{children:"Requests"}),s.jsx(pe,{children:"Tokens"})]})}),s.jsxs(Fn,{children:[o.topApiKeys.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:3,className:"text-muted-foreground text-center",children:"No data"})}),o.topApiKeys.map((j,N)=>s.jsxs(Ye,{children:[s.jsx(de,{className:"text-xs",children:j.name}),s.jsx(de,{className:"text-xs",children:Mt(j.requests)}),s.jsx(de,{className:"text-xs",children:Mt(j.totalTokens)})]},N))]})]})})]})]})]}),s.jsx("div",{className:"mt-6",children:s.jsx(a_,{successRate:x.successRate,averageLatencyMs:x.averageLatencyMs,latencySpark:E})})]})}function r_(){const[a,l]=m.useState([]),[o,i]=m.useState(0);return m.useEffect(()=>{we.get("/api/admin/audit?limit=200").then(u=>{l(u.rows),i(u.total)})},[]),s.jsxs("div",{children:[s.jsx(wa,{title:"Audit Logs",description:`${o} entries · immutable`}),s.jsxs(Xe,{children:[s.jsx(Fe,{children:s.jsx(Qe,{className:"text-base",children:"All entries"})}),s.jsx(Ze,{children:s.jsxs(Kn,{children:[s.jsx(Xn,{children:s.jsxs(Ye,{children:[s.jsx(pe,{children:"Time"}),s.jsx(pe,{children:"Action"}),s.jsx(pe,{children:"Status"}),s.jsx(pe,{children:"Target"}),s.jsx(pe,{children:"IP"}),s.jsx(pe,{children:"Actor"})]})}),s.jsxs(Fn,{children:[a.length===0&&s.jsx(Ye,{children:s.jsx(de,{colSpan:6,className:"text-center text-muted-foreground",children:"No audit events yet."})}),a.map(u=>s.jsxs(Ye,{children:[s.jsx(de,{className:"text-xs",children:Ah(u.createdAt)}),s.jsx(de,{className:"font-mono text-xs",children:u.action}),s.jsx(de,{children:u.success?s.jsx(et,{variant:"success",children:"ok"}):s.jsx(et,{variant:"destructive",children:"fail"})}),s.jsx(de,{className:"text-xs",children:u.targetName??u.targetId??"—"}),s.jsx(de,{className:"text-xs",children:u.ip}),s.jsx(de,{className:"text-xs",children:u.actor})]},u.id))]})]})})]})]})}const hh={enabled:!0,sound:!0};let To=hh,mh=!1,fc=null;const ph=new Set;function O1(){for(const a of ph)a()}function k1(a=!1){return mh&&!a?Promise.resolve():(!a&&fc||(fc=(async()=>{try{const l=await we.get("/api/admin/settings");To={enabled:l.settings.notificationsEnabled??hh.enabled,sound:l.settings.notificationSoundEnabled??hh.sound},mh=!0,O1()}catch{}})()),fc)}async function yy(a){const l={};a.enabled!==void 0&&(l.notificationsEnabled=a.enabled),a.sound!==void 0&&(l.notificationSoundEnabled=a.sound),await we.patch("/api/admin/settings",l),To={...To,...a},mh=!0,O1()}function s_(a){return ph.add(a),()=>ph.delete(a)}function z1(){return m.useSyncExternalStore(s_,()=>To,()=>To)}const gh=m.forwardRef(({className:a,...l},o)=>s.jsx("textarea",{ref:o,className:Re("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",a),...l}));gh.displayName="Textarea";function o_(){const[a]=B2(),[l,o]=m.useState(null),[i,u]=m.useState(null),[d,h]=m.useState({current:"",next:""}),[p,g]=m.useState(""),[v,x]=m.useState(""),[y,S]=m.useState(null),[w,C]=m.useState(!1),[E,j]=m.useState("idle"),[N,M]=m.useState(null),T=async(J=!1)=>{j("checking"),M(null);try{const me=await we.get(`/api/admin/update/check${J?"?force=1":""}`);S(me),j("idle")}catch(me){M(me.message),j("error")}},_=async()=>{C(!0),j("installing"),M(null);try{const J=await we.post("/api/admin/update/run");j("restarting"),ve.success(J.message||"Update started — the gateway will restart shortly.");const me=setInterval(()=>{fetch("/health").then(je=>{je.ok&&(clearInterval(me),window.location.reload())}).catch(()=>{})},3e3);setTimeout(()=>clearInterval(me),12e4)}catch(J){ve.error(J.message),M(J.message),j("error")}finally{C(!1)}},[O,A]=m.useState("disabled"),[H,z]=m.useState(""),[K,se]=m.useState(""),[X,I]=m.useState(""),[re,ee]=m.useState([]),[oe,U]=m.useState(""),[$,le]=m.useState(""),[B,Z]=m.useState(!1),[D,q]=m.useState(null),Q=async()=>{const J=await we.get("/api/admin/settings");o(J.settings),g(J.settings.adminIpAllow??""),x(J.settings.adminIpBlock??"");const me=await we.get("/api/admin/settings/system");u(me);try{const je=await we.get("/api/admin/me");A(je.totpEnabled?"enabled":"disabled")}catch{}};if(m.useEffect(()=>{k1(!0)},[]),m.useEffect(()=>{Q(),T()},[]),!l)return s.jsx("div",{className:"text-muted-foreground",children:"Loading…"});const ae=async J=>{try{await we.patch("/api/admin/settings",J),ve.success("Saved"),Q()}catch(me){ve.error(me.message)}},ce=async()=>{try{const J=await we.post("/api/admin/account/totp/begin");z(J.secret),se(J.qr),A("setup"),ve.info("Scan the QR code with your authenticator app")}catch(J){ve.error(J.message)}},Se=async()=>{if(!X||X.length!==6){ve.error("Enter a 6-digit code");return}try{const J=await we.post("/api/admin/account/totp/verify",{code:X});ee(J.recoveryCodes),A("showingRecovery"),ve.success("TOTP enabled successfully")}catch(J){ve.error(J.message)}},ue=async()=>{if(!oe){ve.error("Enter your password");return}if(!$){ve.error("Enter a TOTP code or recovery code");return}try{await we.post("/api/admin/account/totp/disable",{password:oe,totp:$}),A("disabled"),U(""),le(""),ve.success("TOTP disabled"),Q()}catch(J){ve.error(J.message)}},fe=async()=>{Z(!0);try{const J=await we.post("/api/admin/account/totp/recovery/regenerate",{password:oe,totp:$});ee(J.recoveryCodes),A("showingRecovery"),ve.success("Recovery codes regenerated")}catch(J){ve.error(J.message)}Z(!1)},xe=a.get("tab")||"logging";return s.jsxs("div",{children:[s.jsx(wa,{title:"Settings",description:"Logging, security, backup, and system info"}),s.jsxs(M1,{defaultValue:xe,children:[s.jsxs(jm,{children:[s.jsx(Ka,{value:"logging",children:"Logging"}),s.jsx(Ka,{value:"access",children:"Access Control"}),s.jsx(Ka,{value:"security",children:"Security"}),s.jsx(Ka,{value:"backup",children:"Backup"}),s.jsx(Ka,{value:"system",children:"System"})]}),s.jsx(ds,{value:"logging",children:s.jsxs(Xe,{children:[s.jsx(Fe,{children:s.jsx(Qe,{className:"text-base",children:"Logging policy"})}),s.jsxs(Ze,{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Request-content logging"}),s.jsxs(Vn,{value:l.contentLogMode,onValueChange:J=>ae({contentLogMode:J}),children:[s.jsx(Rn,{children:s.jsx(Gn,{})}),s.jsxs(Nn,{children:[s.jsx(lt,{value:"off",children:"Off"}),s.jsx(lt,{value:"metadata",children:"Metadata only (default)"}),s.jsx(lt,{value:"prompt",children:"Prompt (sanitized)"}),s.jsx(lt,{value:"prompt_and_response",children:"Prompt + response (sanitized)"})]})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Retention (days)"}),s.jsx(Ae,{type:"number",min:1,max:3650,value:l.retentionDays,onChange:J=>ae({retentionDays:Number(J.target.value)})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(be,{children:"Database size limit (MB)"}),s.jsx(Ae,{type:"number",min:64,value:l.dbSizeLimitMb,onChange:J=>ae({dbSizeLimitMb:Number(J.target.value)})})]}),s.jsx("div",{className:"flex items-center gap-2 pt-2",children:s.jsx(he,{onClick:async()=>{const J=await we.post("/api/admin/settings/cleanup");ve.success(`Deleted ${J.deletedRequests} old requests`)},children:"Run cleanup now"})})]})]})}),s.jsx(ds,{value:"access",children:s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"IP access control"}),s.jsx(on,{children:"Allowlist / Blocklist for this admin website (not model traffic)"})]}),s.jsxs(Ze,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(be,{children:"Allow only these IPs"}),s.jsx(gh,{placeholder:`192.168.1.0/24
330
+ 10.0.0.1`,value:p,onChange:J=>g(J.target.value)}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Newlines-delimited CIDR ranges (IPv4 only). Leave empty = no allow restrictions. When you save a non-empty list, your current IP is auto-added to prevent lockout."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(be,{children:"Block these IPs"}),s.jsx(gh,{placeholder:"192.168.1.100",value:v,onChange:J=>x(J.target.value)}),s.jsx("p",{className:"text-xs text-muted-foreground",children:'Newlines-delimited CIDR ranges (IPv4 only). Blocked IPs are rejected with "Không có quyền truy cập" before any login page.'})]}),s.jsx(he,{onClick:()=>{const J={};p!==((l==null?void 0:l.adminIpAllow)??"")&&(J.adminIpAllow=p||null),v!==((l==null?void 0:l.adminIpBlock)??"")&&(J.adminIpBlock=v||null),we.patch("/api/admin/settings",J).then(me=>{ve.success("Saved"+(me.addedIp?` — added your IP: ${me.addedIp}`:"")),Q(),g(""),x("")}).catch(me=>ve.error(me.message))},children:"Save access control"}),s.jsxs("div",{className:"rounded bg-amber-50 border border-amber-200 p-3 dark:bg-amber-950/20 dark:border-amber-800",children:[s.jsx("p",{className:"text-sm font-medium text-amber-900 dark:text-amber-200",children:"⚠️ If you enable an allow list, you cannot access the gateway unless your IP matches."}),s.jsx("p",{className:"text-xs text-amber-800 dark:text-amber-300",children:"The server automatically adds your current IP when you save — but if you configure it from a different machine, that machine will be locked out immediately."})]})]})]})}),s.jsx(ds,{value:"security",children:s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"Security"}),s.jsx(on,{children:"Change password, 2FA, and trusted proxy configuration"})]}),s.jsxs(Ze,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(be,{children:"Trusted proxy hops"}),s.jsx(Ae,{type:"number",min:0,max:8,value:l.trustProxyHops,onChange:J=>ae({trustProxyHops:Number(J.target.value)})}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"0 = never trust X-Forwarded-For (direct exposure). 1+ only when behind a single trusted reverse proxy."})]}),s.jsxs("div",{className:"space-y-2 border-t pt-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(be,{className:"text-base",children:"TOTP 2FA"}),O==="enabled"?s.jsx("span",{className:"rounded bg-green-100 px-2 py-0.5 text-xs font-medium text-green-800 dark:bg-green-900 dark:text-green-200",children:"Enabled"}):null,O==="disabled"?s.jsx("span",{className:"rounded bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:"Disabled"}):null]}),O==="disabled"&&s.jsx(he,{variant:"outline",onClick:ce,children:"Enable TOTP"}),O==="setup"&&s.jsxs("div",{className:"space-y-3 rounded border p-3",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"Scan this QR code with your authenticator app, or enter the secret manually."}),K&&s.jsx("img",{src:K,alt:"TOTP QR code",className:"h-40 w-40"}),s.jsxs("div",{className:"text-xs font-mono text-muted-foreground",children:["Secret: ",H]}),s.jsxs("div",{className:"flex items-end gap-2",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx(be,{children:"Verify code"}),s.jsx(Ae,{value:X,onChange:J=>I(J.target.value),placeholder:"123456",maxLength:6})]}),s.jsx(he,{disabled:X.length<6,onClick:Se,children:"Verify & enable"})]})]}),O==="showingRecovery"&&s.jsxs("div",{className:"space-y-3 rounded border border-amber-500/40 bg-amber-50 p-3 dark:bg-amber-950/20",children:[s.jsx("p",{className:"text-sm font-medium",children:"Recovery codes — save these now!"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Each code can be used once to log in without your TOTP device. They will not be shown again."}),s.jsx("div",{className:"space-y-1",children:re.map((J,me)=>s.jsx("div",{className:"font-mono text-xs",children:J},me))}),s.jsx(he,{onClick:()=>{A("enabled"),ve.success("Recovery codes saved")},children:"I have saved them"})]}),O==="enabled"&&s.jsxs("div",{className:"space-y-3 rounded border p-3",children:[s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx(be,{children:"Password"}),s.jsx(Ae,{type:"password",value:oe,onChange:J=>U(J.target.value),placeholder:"Current password"})]}),s.jsxs("div",{children:[s.jsx(be,{children:"TOTP code"}),s.jsx(Ae,{value:$,onChange:J=>le(J.target.value),placeholder:"123456",maxLength:6})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(he,{variant:"outline",size:"sm",disabled:B||!oe||$.length<6,onClick:fe,children:"Regenerate recovery codes"}),s.jsx(he,{variant:"destructive",size:"sm",disabled:!oe||$.length<6,onClick:ue,children:"Disable TOTP"})]})]})]}),s.jsxs("div",{className:"space-y-2 border-t pt-4",children:[s.jsx(be,{children:"Change password"}),s.jsx(Ae,{type:"password",placeholder:"Current password",value:d.current,onChange:J=>h({...d,current:J.target.value})}),s.jsx(Ae,{type:"password",placeholder:"New password (12+ chars)",value:d.next,onChange:J=>h({...d,next:J.target.value})}),s.jsx(he,{disabled:!d.current||d.next.length<12,onClick:async()=>{try{await we.post("/api/admin/account/password",{currentPassword:d.current,newPassword:d.next}),ve.success("Password changed"),h({current:"",next:""})}catch(J){ve.error(J.message)}},children:"Change password"})]})]})]})}),s.jsx(ds,{value:"backup",children:s.jsxs(Xe,{children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"Backup & restore"}),s.jsx(on,{children:"Download a snapshot or restore from a previous backup"})]}),s.jsxs(Ze,{className:"space-y-3",children:[s.jsx(he,{onClick:async()=>{try{const J=await fetch("/api/admin/backup/create",{method:"POST",credentials:"include"});if(!J.ok)throw new Error("Backup failed");const me=await J.blob(),je=URL.createObjectURL(me),Me=document.createElement("a");Me.href=je,Me.download="latedev-backup.json",Me.click(),URL.revokeObjectURL(je),ve.success("Backup downloaded")}catch(J){ve.error(J.message)}},children:"Download backup"}),s.jsxs(s1,{open:D!==null,onOpenChange:J=>{J||q(null)},children:[s.jsx(xM,{asChild:!0,children:s.jsxs("div",{children:[s.jsx(be,{children:"Restore from backup file"}),s.jsx(Ae,{type:"file",accept:".json,application/json","data-testid":"restore-file",onChange:J=>{var je;const me=(je=J.target.files)==null?void 0:je[0];q(me??null)}})]})}),s.jsxs(am,{children:[s.jsxs(i1,{children:[s.jsx(lm,{children:"Restore backup?"}),s.jsxs(rm,{children:["Restoring will replace the entire current database with the selected backup (",(D==null?void 0:D.name)??"file","). This cannot be undone. A snapshot of the current database is kept for rollback only if validation fails."]})]}),s.jsxs(c1,{children:[s.jsx(om,{children:"Cancel"}),s.jsx(sm,{onClick:async()=>{var me,je;const J=D;if(J)try{const Me=await fetch("/api/admin/backup/restore",{method:"POST",body:J,credentials:"include",headers:{"content-type":"application/json"}});if(!Me.ok)throw new Error(((je=(me=await Me.json())==null?void 0:me.error)==null?void 0:je.message)??"Restore failed");ve.success("Restored. Reloading…"),q(null),setTimeout(()=>location.reload(),600)}catch(Me){ve.error(Me.message)}},children:"Restore"})]})]})]})]})]})}),s.jsxs(ds,{value:"system",children:[s.jsxs(Xe,{children:[s.jsx(Fe,{children:s.jsx(Qe,{className:"text-base",children:"System"})}),s.jsxs(Ze,{className:"space-y-2 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-muted-foreground",children:"App version:"})," ",i==null?void 0:i.appVersion]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-muted-foreground",children:"Data directory:"})," ",s.jsx("span",{className:"font-mono",children:i==null?void 0:i.dataDir})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-muted-foreground",children:"Encryption:"})," ",i!=null&&i.masterKeyConfigured?"Configured":"Not configured"," (v",i==null?void 0:i.masterKeyVersion,")"]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-muted-foreground",children:"Environment:"})," ",i==null?void 0:i.environment]}),s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsx(ba,{checked:l.gatewayCacheEnabled,onCheckedChange:J=>ae({gatewayCacheEnabled:J})}),s.jsx(be,{children:"Gateway response cache (disabled by default)"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx(be,{children:"Cache TTL (s)"}),s.jsx(Ae,{type:"number",min:1,value:l.gatewayCacheDefaultTtlSeconds,onChange:J=>ae({gatewayCacheDefaultTtlSeconds:Number(J.target.value)})})]}),s.jsxs("div",{children:[s.jsx(be,{children:"Cache max size (MB)"}),s.jsx(Ae,{type:"number",min:1,value:l.gatewayCacheMaxSizeMb,onChange:J=>ae({gatewayCacheMaxSizeMb:Number(J.target.value)})})]})]}),s.jsx(he,{variant:"outline",onClick:async()=>{const J=await we.post("/api/admin/settings/cache/clear");ve.success(`Cleared ${J.deleted} entries`)},children:"Clear gateway cache"})]})]}),s.jsx(i_,{}),s.jsxs(Xe,{className:"mt-4",children:[s.jsxs(Fe,{children:[s.jsx(Qe,{className:"text-base",children:"Updates"}),s.jsx(on,{children:"Automatic updates from the npm registry"})]}),s.jsxs(Ze,{className:"space-y-3 text-sm",children:[E==="checking"&&!y&&s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(jo,{className:"h-4 w-4 animate-spin"})," Checking for updates…"]}),y&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Current version"}),s.jsxs("div",{className:"font-mono",children:["v",y.currentVersion]})]}),s.jsx("span",{className:"text-muted-foreground",children:"→"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Latest version"}),s.jsx("div",{className:"font-mono",children:y.latestVersion?`v${y.latestVersion}`:"—"})]}),y.status.docker?s.jsx(et,{variant:"secondary",children:y.status.watchtower?"Docker + Watchtower":"Docker"}):y.latestVersion===null?s.jsx(et,{variant:"secondary",children:"Registry unreachable"}):y.hasUpdate?s.jsx(et,{variant:"success",children:"Update available"}):s.jsxs(et,{variant:"outline",children:[s.jsx(Dc,{className:"mr-1 h-3 w-3"})," Up to date"]})]}),y.status.docker&&y.status.watchtower&&y.watchtowerReachable&&s.jsx("p",{className:"text-muted-foreground",children:"Watchtower pulls new images automatically every hour — or use Update now for an instant update."}),y.status.docker&&y.status.watchtower&&y.watchtowerReachable===!1&&s.jsxs("p",{className:"text-muted-foreground",children:["The Watchtower sidecar is configured but not running — start it with ",s.jsx("code",{className:"rounded bg-muted px-1 text-xs",children:"docker compose --profile updater up -d"}),"."]}),y.status.docker&&!y.status.watchtower&&s.jsx("p",{className:"text-muted-foreground",children:y.status.reason??"This instance runs in Docker — update by pulling the new image tag."}),!y.status.docker&&y.latestVersion===null&&s.jsxs("p",{className:"text-muted-foreground",children:["Could not reach the npm registry (offline or blocked). ",N&&s.jsx("span",{className:"text-destructive",children:N})]}),E==="installing"&&s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(jo,{className:"h-4 w-4 animate-spin"})," Applying the update… this can take a minute."]}),E==="restarting"&&s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(jo,{className:"h-4 w-4 animate-spin"})," Update applied — the gateway is restarting on the new version. This page reloads automatically."]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[y.hasUpdate&&E==="idle"&&(!y.status.docker||y.status.watchtower&&y.watchtowerReachable!==!1)&&s.jsxs(he,{disabled:w||y.status.docker&&y.watchtowerReachable===!1,onClick:_,children:[s.jsx(Xy,{className:"mr-1 h-4 w-4"})," Update now"]}),y.hasUpdate&&y.changelogUrl&&s.jsx(he,{variant:"outline",asChild:!0,children:s.jsx("a",{href:y.changelogUrl,target:"_blank",rel:"noreferrer",children:"View changes"})}),E==="idle"&&s.jsx(he,{variant:"ghost",disabled:w,onClick:()=>T(!0),children:"Check again"})]})]})]})]})]})]})]})}function i_(){const a=z1();return s.jsxs(Xe,{className:"mt-4",children:[s.jsx(Fe,{children:s.jsxs(Qe,{className:"text-base flex items-center gap-2",children:[s.jsx(J2,{className:"h-4 w-4"})," Notifications"]})}),s.jsxs(Ze,{className:"space-y-3 text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{children:"Show request notifications"}),s.jsx(ba,{checked:a.enabled,onCheckedChange:l=>void yy({enabled:l})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(wC,{className:"h-3 w-3"})," Play notification sound"]}),s.jsx(ba,{checked:a.sound,onCheckedChange:l=>void yy({sound:l})})]}),s.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Notifications are disabled while muted. Changes apply immediately."})]})]})}function c_({items:a,onDismiss:l}){return a.length?s.jsx("div",{className:"fixed top-16 right-4 z-50 flex max-h-[calc(100vh-8rem)] w-80 flex-col gap-2 overflow-y-auto",children:a.map(o=>{const i=!o.success,u=o.success&&o.totalLatencyMs>15e3,d=Re("rounded-md border shadow-lg transition-all",i&&"bg-destructive text-destructive-foreground border-destructive",u&&"bg-amber-500/90 text-amber-950 border-amber-600/50",!i&&!u&&"bg-card text-card-foreground border-border");return s.jsxs(ur,{to:"/requests",className:Re("block shrink-0 p-3 hover:opacity-95",d),children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[i?s.jsx(nC,{className:"h-4 w-4 shrink-0"}):o.success?s.jsx(Dc,{className:"h-4 w-4 shrink-0"}):s.jsx(jC,{className:"h-4 w-4 shrink-0 opacity-70"}),s.jsx("div",{className:"min-w-0 truncate text-sm font-medium",title:o.requestedModel,children:o.requestedModel})]}),s.jsx("button",{className:"shrink-0 opacity-60 hover:opacity-100",onClick:h=>{h.preventDefault(),h.stopPropagation(),l(o.id)},"aria-label":"Dismiss",type:"button",children:s.jsx(Oc,{className:"h-3.5 w-3.5"})})]}),s.jsxs("div",{className:"mt-1 text-xs",children:[o.success?"Thành công":"Thất bại",!o.success&&o.errorType&&s.jsx("span",{className:"ml-1 inline-block rounded bg-black/15 px-1 py-0.5 align-text-bottom text-[10px]",children:o.errorType})]}),s.jsxs("div",{className:"mt-1 text-[11px] opacity-90",children:["in ",Mt(o.inputTokens)," · out ",Mt(o.outputTokens),(o.cacheReadTokens>0||o.cacheWriteTokens>0)&&s.jsxs(s.Fragment,{children:[" · cache ",o.cacheReadTokens>0&&s.jsxs("span",{children:["r",Mt(o.cacheReadTokens)]}),o.cacheReadTokens>0&&o.cacheWriteTokens>0&&"/",o.cacheWriteTokens>0&&s.jsxs("span",{children:["w",Mt(o.cacheWriteTokens)]})]})]}),s.jsxs("div",{className:"mt-1 text-[11px] opacity-90",children:[dr(o.totalLatencyMs),o.ttftMs!=null&&o.ttftMs>=0&&s.jsxs("span",{children:[" · TTFT ",dr(o.ttftMs)]})]})]},o.id)})}):null}const u_=5e3,d_=8,f_=3e3;let hc=null;function h_(){try{hc||(hc=new Audio("/notification.mp3")),hc.currentTime=0,hc.play().catch(()=>{})}catch{}}function m_(){const[a,l]=m.useState([]),o=m.useRef(null),i=m.useRef(new Map),u=m.useRef(Date.now()),d=m.useRef(new Set),h=z1(),p=m.useRef(h.sound);p.current=h.sound,m.useEffect(()=>{k1()},[]);const g=h.enabled;return m.useEffect(()=>{var w;if(!g){(w=o.current)==null||w.close(),o.current=null;const C=i.current;for(const E of C.values())clearTimeout(E);C.clear(),l([]);return}let x=!1;const y=i.current,S=()=>{if(x)return;const C=new EventSource(`/api/admin/requests/stream?since=${u.current}`);o.current=C,C.addEventListener("request",E=>{if(!x)try{const j=JSON.parse(E.data),N=new Date(j.createdAt).getTime();if(Number.isFinite(N)&&(u.current=Math.max(u.current,N)),d.current.has(j.id))return;d.current.add(j.id),l(T=>T.some(_=>_.id===j.id)?T:[j,...T].slice(0,d_));const M=setTimeout(()=>{l(T=>T.filter(_=>_.id!==j.id)),y.delete(j.id)},u_);y.set(j.id,M),p.current&&h_()}catch{}}),C.onerror=()=>{C.close(),o.current=null,x||setTimeout(S,f_)}};return S(),()=>{var C;x=!0,(C=o.current)==null||C.close(),o.current=null;for(const E of y.values())clearTimeout(E);y.clear()}},[g]),{items:a,dismiss:x=>{const y=i.current.get(x);y&&(clearTimeout(y),i.current.delete(x)),l(S=>S.filter(w=>w.id!==x))}}}function p_({children:a}){const{user:l,loading:o}=Nh(),i=dn();return o?s.jsx("div",{className:"flex h-screen items-center justify-center text-muted-foreground",children:"Loading…"}):l?s.jsx(s.Fragment,{children:a}):s.jsx(qf,{to:"/login",state:{from:i},replace:!0})}function g_(){const{items:a,dismiss:l}=m_();return s.jsxs("div",{className:"flex h-screen bg-background text-foreground",children:[s.jsx(rE,{}),s.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[s.jsx(sA,{}),s.jsx("main",{className:"flex-1 overflow-auto p-6",children:s.jsxs(Py,{children:[s.jsx(rn,{index:!0,element:s.jsx(PA,{})}),s.jsx(rn,{path:"/providers",element:s.jsx(hD,{})}),s.jsx(rn,{path:"/models",element:s.jsx(jD,{})}),s.jsx(rn,{path:"/combos",element:s.jsx(CD,{})}),s.jsx(rn,{path:"/aliases",element:s.jsx(ED,{})}),s.jsx(rn,{path:"/api-keys",element:s.jsx(RD,{})}),s.jsx(rn,{path:"/requests",element:s.jsx(AD,{})}),s.jsx(rn,{path:"/statistics",element:s.jsx(l_,{})}),s.jsx(rn,{path:"/audit",element:s.jsx(r_,{})}),s.jsx(rn,{path:"/settings/*",element:s.jsx(o_,{})})]})})]}),s.jsx(c_,{items:a,onDismiss:l})]})}function v_({children:a}){const[l,o]=m.useState(null),i=dn();return m.useEffect(()=>{we.get("/api/admin/setup/status").then(u=>o(u.setupComplete)).catch(()=>o(!0))},[]),l===null?s.jsx("div",{className:"flex h-screen items-center justify-center text-muted-foreground",children:"Loading…"}):!l&&i.pathname!=="/setup"?s.jsx(qf,{to:"/setup",replace:!0}):l&&i.pathname==="/setup"?s.jsx(qf,{to:"/",replace:!0}):s.jsx(s.Fragment,{children:a})}function x_(){return s.jsx(K2,{children:s.jsx(v_,{children:s.jsxs(Py,{children:[s.jsx(rn,{path:"/setup",element:s.jsx(BA,{})}),s.jsx(rn,{path:"/login",element:s.jsx(UA,{})}),s.jsx(rn,{path:"/*",element:s.jsx(p_,{children:s.jsx(g_,{})})})]})})})}const y_=LA;var b_=Object.defineProperty,cn=(a,l)=>b_(a,"name",{value:l,configurable:!0}),[Cm,J_]=fn("Tooltip",[Es]),S_=Es(),w_="TooltipProvider",j_=700,by="tooltip.open",[C_,E_]=Cm(w_),R_=cn(a=>{const{__scopeTooltip:l,delayDuration:o=j_,skipDelayDuration:i=300,disableHoverableContent:u=!1,children:d}=a,h=m.useRef(!0),p=m.useRef(!1),g=m.useRef(0);return m.useEffect(()=>{const v=g.current;return()=>window.clearTimeout(v)},[]),s.jsx(C_,{scope:l,isOpenDelayedRef:h,delayDuration:o,onOpen:m.useCallback(()=>{i<=0||(window.clearTimeout(g.current),h.current=!1)},[i]),onClose:m.useCallback(()=>{i<=0||(window.clearTimeout(g.current),g.current=window.setTimeout(()=>h.current=!0,i))},[i]),isPointerInTransitRef:p,onPointerInTransitChange:m.useCallback(v=>{p.current=v},[]),disableHoverableContent:u,children:d})},"TooltipProvider"),N_="Tooltip",[W_,Em]=Cm(N_),T_="TooltipPortal",[eO,A_]=Cm(T_,{forceMount:void 0}),Ao="TooltipContent",M_=m.forwardRef(cn(function(l,o){const i=A_(Ao,l.__scopeTooltip),{forceMount:u=i.forceMount,side:d="top",...h}=l,p=Em(Ao,l.__scopeTooltip);return s.jsx(al,{present:u||p.open,children:p.disableHoverableContent?s.jsx(L1,{side:d,...h,ref:o}):s.jsx(D_,{side:d,...h,ref:o})})},"TooltipContent")),D_=m.forwardRef(cn(function(l,o){const i=Em(Ao,l.__scopeTooltip),u=E_(Ao,l.__scopeTooltip),d=m.useRef(null),h=Ie(o,d),[p,g]=m.useState(null),{trigger:v,onClose:x}=i,y=d.current,{onPointerInTransitChange:S}=u,w=m.useCallback(()=>{g(null),S(!1)},[S]),C=m.useCallback((E,j)=>{const N=E.currentTarget,M={x:E.clientX,y:E.clientY},T=U1(M,N.getBoundingClientRect()),_=B1(M,T),O=H1(j.getBoundingClientRect()),A=q1([..._,...O]);g(A),S(!0)},[S]);return m.useEffect(()=>()=>w(),[w]),m.useEffect(()=>{if(v&&y){const E=cn(N=>C(N,y),"handleTriggerLeave"),j=cn(N=>C(N,v),"handleContentLeave");return v.addEventListener("pointerleave",E),y.addEventListener("pointerleave",j),()=>{v.removeEventListener("pointerleave",E),y.removeEventListener("pointerleave",j)}}},[v,y,C,w]),m.useEffect(()=>{if(p){const E=cn(j=>{const N=j.target,M={x:j.clientX,y:j.clientY},T=(v==null?void 0:v.contains(N))||(y==null?void 0:y.contains(N)),_=!P1(M,p);T?w():_&&(w(),x())},"handleTrackPointerGrace");return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[v,y,p,x,w]),s.jsx(L1,{...l,ref:h})},"TooltipContentHoverable")),__=cb("TooltipContent"),L1=m.forwardRef(cn(function(l,o){const{__scopeTooltip:i,children:u,"aria-label":d,id:h,onEscapeKeyDown:p,onPointerDownOutside:g,...v}=l,x=Em(Ao,i),y=S_(i),{onClose:S}=x;m.useEffect(()=>(document.addEventListener(by,S),()=>document.removeEventListener(by,S)),[S]),m.useEffect(()=>{if(x.trigger){const C=cn(E=>{E.target instanceof Node&&E.target.contains(x.trigger)&&S()},"handleScroll");return window.addEventListener("scroll",C,{capture:!0}),()=>window.removeEventListener("scroll",C,{capture:!0})}},[x.trigger,S]);const{setContentId:w}=x;return Dt(()=>(w(h),()=>{w(void 0)}),[h,w]),s.jsx(Lc,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:p,onPointerDownOutside:g,onFocusOutside:C=>C.preventDefault(),onDismiss:S,children:s.jsxs(Vh,{"data-state":x.stateAttribute,role:d?void 0:"tooltip",id:d?void 0:x.contentId,...y,...v,ref:o,style:{...v.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(__,{children:u}),d?s.jsx(NM,{id:x.contentId,role:"tooltip",children:d}):null]})})},"TooltipContentImpl"));function U1(a,l){const o=Math.abs(l.top-a.y),i=Math.abs(l.bottom-a.y),u=Math.abs(l.right-a.x),d=Math.abs(l.left-a.x);switch(Math.min(o,i,u,d)){case d:return"left";case u:return"right";case o:return"top";case i:return"bottom";default:throw new Error("unreachable")}}cn(U1,"getExitSideFromRect");function B1(a,l,o=5){const i=[];switch(l){case"top":i.push({x:a.x-o,y:a.y+o},{x:a.x+o,y:a.y+o});break;case"bottom":i.push({x:a.x-o,y:a.y-o},{x:a.x+o,y:a.y-o});break;case"left":i.push({x:a.x+o,y:a.y-o},{x:a.x+o,y:a.y+o});break;case"right":i.push({x:a.x-o,y:a.y-o},{x:a.x-o,y:a.y+o});break}return i}cn(B1,"getPaddedExitPoints");function H1(a){const{top:l,right:o,bottom:i,left:u}=a;return[{x:u,y:l},{x:o,y:l},{x:o,y:i},{x:u,y:i}]}cn(H1,"getPointsFromRect");function P1(a,l){const{x:o,y:i}=a;let u=!1;for(let d=0,h=l.length-1;d<l.length;h=d++){const p=l[d],g=l[h],v=p.x,x=p.y,y=g.x,S=g.y;x>i!=S>i&&o<(y-v)*(i-x)/(S-x)+v&&(u=!u)}return u}cn(P1,"isPointInPolygon");function q1(a){const l=a.slice();return l.sort((o,i)=>o.x<i.x?-1:o.x>i.x?1:o.y<i.y?-1:o.y>i.y?1:0),I1(l)}cn(q1,"getHull");function I1(a){if(a.length<=1)return a.slice();const l=[];for(let i=0;i<a.length;i++){const u=a[i];for(;l.length>=2;){const d=l[l.length-1],h=l[l.length-2];if((d.x-h.x)*(u.y-h.y)>=(d.y-h.y)*(u.x-h.x))l.pop();else break}l.push(u)}l.pop();const o=[];for(let i=a.length-1;i>=0;i--){const u=a[i];for(;o.length>=2;){const d=o[o.length-1],h=o[o.length-2];if((d.x-h.x)*(u.y-h.y)>=(d.y-h.y)*(u.x-h.x))o.pop();else break}o.push(u)}return o.pop(),l.length===1&&o.length===1&&l[0].x===o[0].x&&l[0].y===o[0].y?l:l.concat(o)}cn(I1,"getHullPresorted");var O_=R_,V1=M_;const k_=O_,z_=m.forwardRef(({className:a,sideOffset:l=4,...o},i)=>s.jsx(V1,{ref:i,sideOffset:l,className:Re("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95",a),...o}));z_.displayName=V1.displayName;dj.createRoot(document.getElementById("root")).render(s.jsx(ie.StrictMode,{children:s.jsx(mE,{defaultTheme:"dark",storageKey:"latedev-theme",children:s.jsxs(k_,{children:[s.jsx(k2,{children:s.jsx(x_,{})}),s.jsx(y_,{position:"top-right"})]})})}));