| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import{j as t,u as et,a as ne,b as ae,Q as Os,c as Ms}from"./query-C_q0vuOo.js";import{a as Rt,r as l,N as Ds,b as Tt,u as pe,L as Te,O as Ls,c as Sr,d as se,e as Cr,f as Pt,g as _r,h as Ce,i as Fs,j as Is}from"./react-C4-CelXw.js";import{B as Er,R as kr,S as $s,A as zs,I as qs,a as Bs,b as Xe,c as Us,M as Ws,d as Vs,C as Hs,L as Gs,u as O,X as Qs,P as Rr,e as Tr,f as yt,T as Ks,E as Ys,g as Xs,h as Js,K as Zs,i as en,$ as tn}from"./ui-DcUwFLzq.js";import{o as rn,r as sn,a as nn,b as tt,c as _e,n as rt,s as F,u as st,l as He,e as Pr}from"./forms-BRRx31Es.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&n(i)}).observe(document,{childList:!0,subtree:!0});function s(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(a){if(a.ep)return;a.ep=!0;const o=s(a);fetch(a.href,o)}})();var Ar,Kt=Rt;Ar=Kt.createRoot,Kt.hydrateRoot;function Or(e){var r,s,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(r=0;r<a;r++)e[r]&&(s=Or(e[r]))&&(n&&(n+=" "),n+=s)}else for(s in e)e[s]&&(n&&(n+=" "),n+=s);return n}function Mr(){for(var e,r,s=0,n="",a=arguments.length;s<a;s++)(e=arguments[s])&&(r=Or(e))&&(n&&(n+=" "),n+=r);return n}const At="-",an=e=>{const r=cn(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:i=>{const c=i.split(At);return c[0]===""&&c.length!==1&&c.shift(),Dr(c,r)||on(i)},getConflictingClassGroupIds:(i,c)=>{const d=s[i]||[];return c&&n[i]?[...d,...n[i]]:d}}},Dr=(e,r)=>{if(e.length===0)return r.classGroupId;const s=e[0],n=r.nextPart.get(s),a=n?Dr(e.slice(1),n):void 0;if(a)return a;if(r.validators.length===0)return;const o=e.join(At);return r.validators.find(({validator:i})=>i(o))?.classGroupId},Yt=/^\[(.+)\]$/,on=e=>{if(Yt.test(e)){const r=Yt.exec(e)[1],s=r?.substring(0,r.indexOf(":"));if(s)return"arbitrary.."+s}},cn=e=>{const{theme:r,prefix:s}=e,n={nextPart:new Map,validators:[]};return dn(Object.entries(e.classGroups),s).forEach(([o,i])=>{jt(i,n,o,r)}),n},jt=(e,r,s,n)=>{e.forEach(a=>{if(typeof a=="string"){const o=a===""?r:Xt(r,a);o.classGroupId=s;return}if(typeof a=="function"){if(ln(a)){jt(a(n),r,s,n);return}r.validators.push({validator:a,classGroupId:s});return}Object.entries(a).forEach(([o,i])=>{jt(i,Xt(r,o),s,n)})})},Xt=(e,r)=>{let s=e;return r.split(At).forEach(n=>{s.nextPart.has(n)||s.nextPart.set(n,{nextPart:new Map,validators:[]}),s=s.nextPart.get(n)}),s},ln=e=>e.isThemeGetter,dn=(e,r)=>r?e.map(([s,n])=>{const a=n.map(o=>typeof o=="string"?r+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(([i,c])=>[r+i,c])):o);return[s,a]}):e,un=e=>{if(e<1)return{get:()=>{},set:()=>{}};let r=0,s=new Map,n=new Map;const a=(o,i)=>{s.set(o,i),r++,r>e&&(r=0,n=s,s=new Map)};return{get(o){let i=s.get(o);if(i!==void 0)return i;if((i=n.get(o))!==void 0)return a(o,i),i},set(o,i){s.has(o)?s.set(o,i):a(o,i)}}},Lr="!",mn=e=>{const{separator:r,experimentalParseClassName:s}=e,n=r.length===1,a=r[0],o=r.length,i=c=>{const d=[];let f=0,m=0,h;for(let v=0;v<c.length;v++){let y=c[v];if(f===0){if(y===a&&(n||c.slice(v,v+o)===r)){d.push(c.slice(m,v)),m=v+o;continue}if(y==="/"){h=v;continue}}y==="["?f++:y==="]"&&f--}const p=d.length===0?c:c.substring(m),x=p.startsWith(Lr),g=x?p.substring(1):p,u=h&&h>m?h-m:void 0;return{modifiers:d,hasImportantModifier:x,baseClassName:g,maybePostfixModifierPosition:u}};return s?c=>s({className:c,parseClassName:i}):i},fn=e=>{if(e.length<=1)return e;const r=[];let s=[];return e.forEach(n=>{n[0]==="["?(r.push(...s.sort(),n),s=[]):s.push(n)}),r.push(...s.sort()),r},hn=e=>({cache:un(e.cacheSize),parseClassName:mn(e),...an(e)}),pn=/\s+/,xn=(e,r)=>{const{parseClassName:s,getClassGroupId:n,getConflictingClassGroupIds:a}=r,o=[],i=e.trim().split(pn);let c="";for(let d=i.length-1;d>=0;d-=1){const f=i[d],{modifiers:m,hasImportantModifier:h,baseClassName:p,maybePostfixModifierPosition:x}=s(f);let g=!!x,u=n(g?p.substring(0,x):p);if(!u){if(!g){c=f+(c.length>0?" "+c:c);continue}if(u=n(p),!u){c=f+(c.length>0?" "+c:c);continue}g=!1}const v=fn(m).join(":"),y=h?v+Lr:v,j=y+u;if(o.includes(j))continue;o.push(j);const N=a(u,g);for(let b=0;b<N.length;++b){const S=N[b];o.push(y+S)}c=f+(c.length>0?" "+c:c)}return c};function gn(){let e=0,r,s,n="";for(;e<arguments.length;)(r=arguments[e++])&&(s=Fr(r))&&(n&&(n+=" "),n+=s);return n}const Fr=e=>{if(typeof e=="string")return e;let r,s="";for(let n=0;n<e.length;n++)e[n]&&(r=Fr(e[n]))&&(s&&(s+=" "),s+=r);return s};function vn(e,...r){let s,n,a,o=i;function i(d){const f=r.reduce((m,h)=>h(m),e());return s=hn(f),n=s.cache.get,a=s.cache.set,o=c,c(d)}function c(d){const f=n(d);if(f)return f;const m=xn(d,s);return a(d,m),m}return function(){return o(gn.apply(null,arguments))}}const T=e=>{const r=s=>s[e]||[];return r.isThemeGetter=!0,r},Ir=/^\[(?:([a-z-]+):)?(.+)\]$/i,bn=/^\d+\/\d+$/,yn=new Set(["px","full","screen"]),jn=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,wn=/\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$/,Nn=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Sn=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Cn=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Q=e=>me(e)||yn.has(e)||bn.test(e),Y=e=>xe(e,"length",On),me=e=>!!e&&!Number.isNaN(Number(e)),mt=e=>xe(e,"number",me),je=e=>!!e&&Number.isInteger(Number(e)),_n=e=>e.endsWith("%")&&me(e.slice(0,-1)),w=e=>Ir.test(e),X=e=>jn.test(e),En=new Set(["length","size","percentage"]),kn=e=>xe(e,En,$r),Rn=e=>xe(e,"position",$r),Tn=new Set(["image","url"]),Pn=e=>xe(e,Tn,Dn),An=e=>xe(e,"",Mn),we=()=>!0,xe=(e,r,s)=>{const n=Ir.exec(e);return n?n[1]?typeof r=="string"?n[1]===r:r.has(n[1]):s(n[2]):!1},On=e=>wn.test(e)&&!Nn.test(e),$r=()=>!1,Mn=e=>Sn.test(e),Dn=e=>Cn.test(e),Ln=()=>{const e=T("colors"),r=T("spacing"),s=T("blur"),n=T("brightness"),a=T("borderColor"),o=T("borderRadius"),i=T("borderSpacing"),c=T("borderWidth"),d=T("contrast"),f=T("grayscale"),m=T("hueRotate"),h=T("invert"),p=T("gap"),x=T("gradientColorStops"),g=T("gradientColorStopPositions"),u=T("inset"),v=T("margin"),y=T("opacity"),j=T("padding"),N=T("saturate"),b=T("scale"),S=T("sepia"),P=T("skew"),L=T("space"),K=T("translate"),R=()=>["auto","contain","none"],I=()=>["auto","hidden","clip","visible","scroll"],$=()=>["auto",w,r],_=()=>[w,r],Vt=()=>["",Q,Y],Fe=()=>["auto",me,w],Ht=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Ie=()=>["solid","dashed","dotted","double","none"],Gt=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ut=()=>["start","end","center","between","around","evenly","stretch"],ye=()=>["","0",w],Qt=()=>["auto","avoid","all","avoid-page","page","left","right","column"],G=()=>[me,w];return{cacheSize:500,separator:":",theme:{colors:[we],spacing:[Q,Y],blur:["none","",X,w],brightness:G(),borderColor:[e],borderRadius:["none","","full",X,w],borderSpacing:_(),borderWidth:Vt(),contrast:G(),grayscale:ye(),hueRotate:G(),invert:ye(),gap:_(),gradientColorStops:[e],gradientColorStopPositions:[_n,Y],inset:$(),margin:$(),opacity:G(),padding:_(),saturate:G(),scale:G(),sepia:ye(),skew:G(),space:_(),translate:_()},classGroups:{aspect:[{aspect:["auto","square","video",w]}],container:["container"],columns:[{columns:[X]}],"break-after":[{"break-after":Qt()}],"break-before":[{"break-before":Qt()}],"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:[...Ht(),w]}],overflow:[{overflow:I()}],"overflow-x":[{"overflow-x":I()}],"overflow-y":[{"overflow-y":I()}],overscroll:[{overscroll:R()}],"overscroll-x":[{"overscroll-x":R()}],"overscroll-y":[{"overscroll-y":R()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[u]}],"inset-x":[{"inset-x":[u]}],"inset-y":[{"inset-y":[u]}],start:[{start:[u]}],end:[{end:[u]}],top:[{top:[u]}],right:[{right:[u]}],bottom:[{bottom:[u]}],left:[{left:[u]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",je,w]}],basis:[{basis:$()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",w]}],grow:[{grow:ye()}],shrink:[{shrink:ye()}],order:[{order:["first","last","none",je,w]}],"grid-cols":[{"grid-cols":[we]}],"col-start-end":[{col:["auto",{span:["full",je,w]},w]}],"col-start":[{"col-start":Fe()}],"col-end":[{"col-end":Fe()}],"grid-rows":[{"grid-rows":[we]}],"row-start-end":[{row:["auto",{span:[je,w]},w]}],"row-start":[{"row-start":Fe()}],"row-end":[{"row-end":Fe()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",w]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",w]}],gap:[{gap:[p]}],"gap-x":[{"gap-x":[p]}],"gap-y":[{"gap-y":[p]}],"justify-content":[{justify:["normal",...ut()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ut(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ut(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[j]}],px:[{px:[j]}],py:[{py:[j]}],ps:[{ps:[j]}],pe:[{pe:[j]}],pt:[{pt:[j]}],pr:[{pr:[j]}],pb:[{pb:[j]}],pl:[{pl:[j]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[L]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[L]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",w,r]}],"min-w":[{"min-w":[w,r,"min","max","fit"]}],"max-w":[{"max-w":[w,r,"none","full","min","max","fit","prose",{screen:[X]},X]}],h:[{h:[w,r,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[w,r,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[w,r,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[w,r,"auto","min","max","fit"]}],"font-size":[{text:["base",X,Y]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",mt]}],"font-family":[{font:[we]}],"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",w]}],"line-clamp":[{"line-clamp":["none",me,mt]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Q,w]}],"list-image":[{"list-image":["none",w]}],"list-style-type":[{list:["none","disc","decimal",w]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[y]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[y]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Ie(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Q,Y]}],"underline-offset":[{"underline-offset":["auto",Q,w]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:_()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",w]}],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",w]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[y]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Ht(),Rn]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",kn]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Pn]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[g]}],"gradient-via-pos":[{via:[g]}],"gradient-to-pos":[{to:[g]}],"gradient-from":[{from:[x]}],"gradient-via":[{via:[x]}],"gradient-to":[{to:[x]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[c]}],"border-w-x":[{"border-x":[c]}],"border-w-y":[{"border-y":[c]}],"border-w-s":[{"border-s":[c]}],"border-w-e":[{"border-e":[c]}],"border-w-t":[{"border-t":[c]}],"border-w-r":[{"border-r":[c]}],"border-w-b":[{"border-b":[c]}],"border-w-l":[{"border-l":[c]}],"border-opacity":[{"border-opacity":[y]}],"border-style":[{border:[...Ie(),"hidden"]}],"divide-x":[{"divide-x":[c]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[c]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[y]}],"divide-style":[{divide:Ie()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...Ie()]}],"outline-offset":[{"outline-offset":[Q,w]}],"outline-w":[{outline:[Q,Y]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:Vt()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[y]}],"ring-offset-w":[{"ring-offset":[Q,Y]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",X,An]}],"shadow-color":[{shadow:[we]}],opacity:[{opacity:[y]}],"mix-blend":[{"mix-blend":[...Gt(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Gt()}],filter:[{filter:["","none"]}],blur:[{blur:[s]}],brightness:[{brightness:[n]}],contrast:[{contrast:[d]}],"drop-shadow":[{"drop-shadow":["","none",X,w]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[m]}],invert:[{invert:[h]}],saturate:[{saturate:[N]}],sepia:[{sepia:[S]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[s]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[d]}],"backdrop-grayscale":[{"backdrop-grayscale":[f]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[m]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[y]}],"backdrop-saturate":[{"backdrop-saturate":[N]}],"backdrop-sepia":[{"backdrop-sepia":[S]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",w]}],duration:[{duration:G()}],ease:[{ease:["linear","in","out","in-out",w]}],delay:[{delay:G()}],animate:[{animate:["none","spin","ping","pulse","bounce",w]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[b]}],"scale-x":[{"scale-x":[b]}],"scale-y":[{"scale-y":[b]}],rotate:[{rotate:[je,w]}],"translate-x":[{"translate-x":[K]}],"translate-y":[{"translate-y":[K]}],"skew-x":[{"skew-x":[P]}],"skew-y":[{"skew-y":[P]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",w]}],accent:[{accent:["auto",e]}],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",w]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"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",w]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Q,Y,mt]}],stroke:[{stroke:[e,"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"]}}},Fn=vn(Ln);function k(...e){return Fn(Mr(e))}let Ot=null,zr=null;function wt(e){Ot=e.access,e.refresh}function qr(){Ot=null}function Jt(){return Ot}function In(e){zr=e}function $n(){return zr}let Ne=null;async function zn(){return Ne||(Ne=(async()=>{try{const e=await fetch("/v1/auth/refresh",{method:"POST",credentials:"include"});if(!e.ok)return!1;const r=await e.json();return!r.access_token||!r.refresh_token?!1:(wt({access:r.access_token,refresh:r.refresh_token}),!0)}catch{return!1}finally{Ne=null}})(),Ne)}class Pe extends Error{status;body;constructor(r,s,n){super(n),this.status=r,this.body=s}}async function Br(e,r={}){const s=new Headers(r.headers),n=Jt();n&&!s.has("Authorization")&&s.set("Authorization",`Bearer ${n}`);const a=await fetch(e,{...r,headers:s,credentials:"include"});if(a.status!==401||r.skipRefresh)return a;if(!await zn()){qr();const d=$n();return d&&typeof window<"u"&&(window.location.href=d),a}const i=new Headers(r.headers),c=Jt();return c&&!i.has("Authorization")&&i.set("Authorization",`Bearer ${c}`),fetch(e,{...r,headers:i,credentials:"include"})}async function Ae(e){const r=await Br(e);if(!r.ok){const s=await Ur(r);throw new Pe(r.status,s,`${r.status} ${r.statusText}`)}return r.json()}async function oe(e,r,s){const n=await Br(r,{method:e,headers:s?{"Content-Type":"application/json"}:void 0,body:s?JSON.stringify(s):void 0});if(!n.ok){const a=await Ur(n);throw new Pe(n.status,a,`${e} ${r} → ${n.status}`)}if(n.status!==204)return n.json()}async function Ur(e){try{return await e.json()}catch{return null}}const Wr=l.createContext(null);function te(){const e=l.useContext(Wr);if(!e)throw new Error("useAuth must be used inside <AuthProvider>");return e}function qn({children:e}){const[r,s]=l.useState(null),[n,a]=l.useState(!0),[o,i]=l.useState(null),c=l.useCallback(async()=>{try{return await Ae("/v1/auth/me")}catch(p){if(p instanceof Pe&&p.status===401)return null;throw p}},[]);l.useEffect(()=>{let p=!1;return(async()=>{try{const x=await fetch("/v1/auth/refresh",{method:"POST",credentials:"include"});if(x.ok){const u=await x.json();u.access_token&&u.refresh_token&&wt({access:u.access_token,refresh:u.refresh_token})}const g=await c();p||(s(g),i(null))}catch(x){p||(i(x instanceof Error?x.message:"unknown"),s(null))}finally{p||a(!1)}})(),()=>{p=!0}},[c]);const d=l.useCallback(async(p,x)=>{In(window.location.pathname+window.location.search);const g=await fetch("/v1/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:p,password:x})});if(!g.ok){const y=(await g.json().catch(()=>null))?.message??`${g.status} ${g.statusText}`;throw new Error(y)}const u=await g.json();wt({access:u.access_token,refresh:u.refresh_token}),s(u.user),i(null)},[]),f=l.useCallback(async()=>{try{await fetch("/v1/auth/logout",{method:"POST",credentials:"include"})}catch{}qr(),s(null)},[]),m=l.useCallback(async()=>{const p=await c();s(p)},[c]),h=l.useMemo(()=>({user:r,loading:n,bootError:o,login:d,logout:f,refresh:m}),[r,n,o,d,f,m]);return t.jsx(Wr.Provider,{value:h,children:e})}function Mt(e){return e==="super_admin"}function Vr(e){return e==="super_admin"}function Bn(e){return e==="super_admin"||e==="tenant_admin"}function Nt(e){return e==="super_admin"||e==="tenant_admin"}function Un(e){return e==="super_admin"||e==="tenant_admin"||e==="viewer"}const Wn=[{to:"/companies",label:"Companies",icon:Er,show:e=>Vr(e?.role)},{to:"/sources",label:"Sources",icon:kr,show:e=>Nt(e?.role)},{to:"/telegram",label:"Telegram",icon:$s,show:e=>Nt(e?.role)},{to:"/tail",label:"Live tail",icon:zs},{to:"/dlq",label:"DLQ",icon:qs,show:e=>Un(e?.role),badge:"M13c"},{to:"/audit",label:"Audit log",icon:Bs,badge:"M13c"}];function Vn(){const{user:e}=te(),r=Wn.filter(s=>!s.show||s.show(e));return t.jsxs("aside",{className:"hidden w-56 shrink-0 border-r bg-card md:block",children:[t.jsx("nav",{className:"flex flex-col gap-0.5 p-3",children:r.map(s=>t.jsxs(Ds,{to:s.to,className:({isActive:n})=>k("flex items-center justify-between rounded-md px-3 py-2 text-sm transition-colors",n?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(s.icon,{className:"h-4 w-4","aria-hidden":!0}),s.label]}),s.badge?t.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:s.badge}):null]},s.to))}),t.jsx("div",{className:"border-t p-3 text-xs text-muted-foreground",children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Xe,{className:"h-3.5 w-3.5"}),t.jsx("span",{children:"M13b W0 · SPA shell"})]})})]})}function Zt(e,r){if(typeof e=="function")return e(r);e!=null&&(e.current=r)}function Hn(...e){return r=>{let s=!1;const n=e.map(a=>{const o=Zt(a,r);return!s&&typeof o=="function"&&(s=!0),o});if(s)return()=>{for(let a=0;a<n.length;a++){const o=n[a];typeof o=="function"?o():Zt(e[a],null)}}}}function ie(...e){return l.useCallback(Hn(...e),e)}function Dt(e){const r=l.forwardRef((s,n)=>{let{children:a,...o}=s,i=null,c=!1;const d=[];er(a)&&typeof $e=="function"&&(a=$e(a._payload)),l.Children.forEach(a,p=>{if(Jn(p)){c=!0;const x=p;let g="child"in x.props?x.props.child:x.props.children;er(g)&&typeof $e=="function"&&(g=$e(g._payload)),i=Kn(x,g),d.push(i?.props?.children)}else d.push(p)}),i?i=l.cloneElement(i,void 0,d):!c&&l.Children.count(a)===1&&l.isValidElement(a)&&(i=a);const f=i?Xn(i):void 0,m=ie(n,f);if(!i){if(a||a===0)throw new Error(c?ra(e):ta(e));return a}const h=Yn(o,i.props??{});return i.type!==l.Fragment&&(h.ref=n?m:f),l.cloneElement(i,h)});return r.displayName=`${e}.Slot`,r}var Gn=Dt("Slot"),Qn=Symbol.for("radix.slottable"),Kn=(e,r)=>{if("child"in e.props){const s=e.props.child;return l.isValidElement(s)?l.cloneElement(s,void 0,e.props.children(s.props.children)):null}return l.isValidElement(r)?r:null};function Yn(e,r){const s={...r};for(const n in r){const a=e[n],o=r[n];/^on[A-Z]/.test(n)?a&&o?s[n]=(...c)=>{const d=o(...c);return a(...c),d}:a&&(s[n]=a):n==="style"?s[n]={...a,...o}:n==="className"&&(s[n]=[a,o].filter(Boolean).join(" "))}return{...e,...s}}function Xn(e){let r=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=r&&"isReactWarning"in r&&r.isReactWarning;return s?e.ref:(r=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=r&&"isReactWarning"in r&&r.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}function Jn(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Qn}var Zn=Symbol.for("react.lazy");function er(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Zn&&"_payload"in e&&ea(e._payload)}function ea(e){return typeof e=="object"&&e!==null&&"then"in e}var ta=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,ra=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,$e=Tt[" use ".trim().toString()];const tr=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,rr=Mr,Hr=(e,r)=>s=>{var n;if(r?.variants==null)return rr(e,s?.class,s?.className);const{variants:a,defaultVariants:o}=r,i=Object.keys(a).map(f=>{const m=s?.[f],h=o?.[f];if(m===null)return null;const p=tr(m)||tr(h);return a[f][p]}),c=s&&Object.entries(s).reduce((f,m)=>{let[h,p]=m;return p===void 0||(f[h]=p),f},{}),d=r==null||(n=r.compoundVariants)===null||n===void 0?void 0:n.reduce((f,m)=>{let{class:h,className:p,...x}=m;return Object.entries(x).every(g=>{let[u,v]=g;return Array.isArray(v)?v.includes({...o,...c}[u]):{...o,...c}[u]===v})?[...f,h,p]:f},[]);return rr(e,i,d,s?.class,s?.className)},sa=Hr("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium 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-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),C=l.forwardRef(({className:e,variant:r,size:s,asChild:n=!1,...a},o)=>{const i=n?Gn:"button";return t.jsx(i,{ref:o,className:k(sa({variant:r,size:s,className:e})),...a})});C.displayName="Button";const Gr="ba.theme";function St(){if(typeof window>"u")return"system";const e=window.localStorage.getItem(Gr);return e==="light"||e==="dark"||e==="system"?e:"system"}function Ct(e){const r=document.documentElement,s=e==="dark"||e==="system"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches;r.classList.toggle("dark",s),r.style.colorScheme=s?"dark":"light"}function na(){Ct(St()),St()==="system"&&window.matchMedia?.("(prefers-color-scheme: dark)").addEventListener("change",()=>{Ct("system")})}function aa(e){window.localStorage.setItem(Gr,e),Ct(e)}function oa(){const[e,r]=l.useState(St),s=l.useCallback(n=>{aa(n),r(n)},[]);return l.useEffect(()=>{if(e!=="system")return;const n=window.matchMedia("(prefers-color-scheme: dark)"),a=()=>r("system");return n.addEventListener("change",a),()=>n.removeEventListener("change",a)},[e]),{theme:e,setTheme:s}}function ia(){const{user:e,logout:r}=te(),{theme:s,setTheme:n}=oa(),a=pe(),[o,i]=l.useState(!1);if(!e)return null;const c=async()=>{await r(),a("/login",{replace:!0})};return t.jsxs("header",{className:"flex h-14 items-center justify-between border-b bg-card px-4",children:[t.jsxs(Te,{to:"/",className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-block h-6 w-6 rounded bg-primary","aria-hidden":!0}),t.jsx("span",{className:"text-sm font-semibold",children:"broad-announce"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[Mt(e.role)?t.jsx("span",{className:"hidden text-xs text-muted-foreground sm:inline",children:"all companies"}):e.tenant_slug?t.jsx("span",{className:"hidden rounded-md bg-muted px-2 py-1 text-xs sm:inline",children:e.tenant_slug}):null,t.jsxs(C,{variant:"ghost",size:"icon","aria-label":"Toggle theme",onClick:()=>{n(s==="light"?"dark":s==="dark"?"system":"light")},children:[s==="light"&&t.jsx(Us,{className:"h-4 w-4"}),s==="dark"&&t.jsx(Ws,{className:"h-4 w-4"}),s==="system"&&t.jsx(Vs,{className:"h-4 w-4"})]}),t.jsxs("div",{className:"relative",children:[t.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>i(d=>!d),"aria-haspopup":"menu","aria-expanded":o,children:[t.jsxs("span",{className:"hidden text-right sm:block",children:[t.jsx("span",{className:"block text-xs font-medium",children:e.email}),t.jsx("span",{className:"block text-[10px] uppercase tracking-wider text-muted-foreground",children:e.role.replace("_"," ")})]}),t.jsx(Hs,{className:"h-4 w-4 opacity-60"})]}),o?t.jsx("div",{role:"menu",className:k("absolute right-0 top-full z-50 mt-1 w-48 rounded-md border bg-card p-1 shadow-md"),onMouseLeave:()=>i(!1),children:t.jsxs("button",{type:"button",onClick:c,className:"flex w-full items-center gap-2 rounded px-3 py-2 text-left text-sm hover:bg-accent",children:[t.jsx(Gs,{className:"h-4 w-4"}),"Sign out"]})}):null]})]})]})}function ca(){return t.jsxs("div",{className:"flex h-full flex-col",children:[t.jsx(ia,{}),t.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[t.jsx(Vn,{}),t.jsx("main",{className:"flex-1 overflow-auto bg-background p-6",children:t.jsx(Ls,{})})]})]})}function la({children:e}){const{user:r,loading:s}=te(),n=Sr();return s?t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):r?t.jsx(t.Fragment,{children:e}):t.jsx(se,{to:"/login",state:{from:n.pathname+n.search},replace:!0})}const A=l.forwardRef(({className:e,type:r,...s},n)=>t.jsx("input",{type:r,className:k("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...s}));A.displayName="Input";var da=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],H=da.reduce((e,r)=>{const s=Dt(`Primitive.${r}`),n=l.forwardRef((a,o)=>{const{asChild:i,...c}=a,d=i?s:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(d,{...c,ref:o})});return n.displayName=`Primitive.${r}`,{...e,[r]:n}},{});function ua(e,r){e&&Rt.flushSync(()=>e.dispatchEvent(r))}var ma="Label",Qr=l.forwardRef((e,r)=>t.jsx(H.label,{...e,ref:r,onMouseDown:s=>{s.target.closest("button, input, select, textarea")||(e.onMouseDown?.(s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));Qr.displayName=ma;var Kr=Qr;const E=l.forwardRef(({className:e,...r},s)=>t.jsx(Kr,{ref:s,className:k("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",e),...r}));E.displayName=Kr.displayName;const q=l.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:k("rounded-lg border bg-card text-card-foreground shadow-sm",e),...r}));q.displayName="Card";const B=l.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:k("flex flex-col space-y-1.5 p-6",e),...r}));B.displayName="CardHeader";const U=l.forwardRef(({className:e,...r},s)=>t.jsx("h3",{ref:s,className:k("text-lg font-semibold leading-none tracking-tight",e),...r}));U.displayName="CardTitle";const Z=l.forwardRef(({className:e,...r},s)=>t.jsx("p",{ref:s,className:k("text-sm text-muted-foreground",e),...r}));Z.displayName="CardDescription";const W=l.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:k("p-6 pt-0",e),...r}));W.displayName="CardContent";const fa=l.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:k("flex items-center p-6 pt-0",e),...r}));fa.displayName="CardFooter";function ha(){const{user:e,login:r,loading:s}=te(),n=pe(),o=Sr().state,[i,c]=l.useState(""),[d,f]=l.useState(""),[m,h]=l.useState(!1),[p,x]=l.useState(null);if(s)return null;if(e){const u=o?.from??"/";return t.jsx(se,{to:u,replace:!0})}const g=async u=>{u.preventDefault(),x(null),h(!0);try{await r(i,d),O.success("Signed in");const v=o?.from??"/";n(v,{replace:!0})}catch(v){const y=v instanceof Error?v.message:"Sign-in failed";x(y),O.error(y)}finally{h(!1)}};return t.jsx("div",{className:"flex h-full items-center justify-center bg-muted/30 p-4",children:t.jsxs(q,{className:"w-full max-w-sm",children:[t.jsxs(B,{children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[t.jsx("span",{className:"inline-block h-6 w-6 rounded bg-primary","aria-hidden":!0}),t.jsx("span",{className:"text-sm font-semibold",children:"broad-announce"})]}),t.jsx(U,{children:"Sign in"}),t.jsx(Z,{children:"Operator console for the notification router."})]}),t.jsxs(W,{children:[t.jsxs("form",{onSubmit:g,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(E,{htmlFor:"email",children:"Email"}),t.jsx(A,{id:"email",type:"email",autoComplete:"email",required:!0,value:i,onChange:u=>c(u.target.value),placeholder:"super@broad-announce.test",disabled:m})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(E,{htmlFor:"password",children:"Password"}),t.jsx(A,{id:"password",type:"password",autoComplete:"current-password",required:!0,value:d,onChange:u=>f(u.target.value),disabled:m})]}),p?t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:p}):null,t.jsx(C,{type:"submit",className:"w-full",disabled:m,children:m?"Signing in…":"Sign in"})]}),t.jsxs("p",{className:"mt-4 text-center text-xs text-muted-foreground",children:["Bootstrap the first super-admin with"," ",t.jsx("code",{className:"rounded bg-muted px-1",children:"scripts/bootstrap-super-admin.sh"}),"."]})]})]})})}function pa(){const{user:e}=te();if(!e)return t.jsx(se,{to:"/login",replace:!0});switch(e.role){case"super_admin":return t.jsx(se,{to:"/companies",replace:!0});case"tenant_admin":return t.jsx(se,{to:"/sources",replace:!0});case"viewer":return t.jsx(se,{to:"/dlq",replace:!0});default:return t.jsx(se,{to:"/login",replace:!0})}}function Yr({title:e,description:r,action:s,icon:n,className:a}){return t.jsxs("div",{className:k("flex flex-col items-center justify-center gap-3 rounded-md border border-dashed bg-card p-10 text-center",a),children:[n?t.jsx("div",{className:"text-muted-foreground",children:n}):null,t.jsx("h3",{className:"text-base font-semibold",children:e}),r?t.jsx("p",{className:"max-w-md text-sm text-muted-foreground",children:r}):null,s?t.jsx("div",{className:"mt-2",children:s}):null]})}const Lt=l.forwardRef(({className:e,...r},s)=>t.jsx("div",{className:"relative w-full overflow-auto",children:t.jsx("table",{ref:s,className:k("w-full caption-bottom text-sm",e),...r})}));Lt.displayName="Table";const Ft=l.forwardRef(({className:e,...r},s)=>t.jsx("thead",{ref:s,className:k("[&_tr]:border-b bg-muted/40",e),...r}));Ft.displayName="TableHeader";const It=l.forwardRef(({className:e,...r},s)=>t.jsx("tbody",{ref:s,className:k("[&_tr:last-child]:border-0",e),...r}));It.displayName="TableBody";const Ee=l.forwardRef(({className:e,...r},s)=>t.jsx("tr",{ref:s,className:k("border-b transition-colors hover:bg-muted/40 data-[state=selected]:bg-muted",e),...r}));Ee.displayName="TableRow";const M=l.forwardRef(({className:e,...r},s)=>t.jsx("th",{ref:s,className:k("h-10 px-3 text-left align-middle text-xs font-medium uppercase tracking-wider text-muted-foreground",e),...r}));M.displayName="TableHead";const D=l.forwardRef(({className:e,...r},s)=>t.jsx("td",{ref:s,className:k("p-3 align-middle",e),...r}));D.displayName="TableCell";const nt={list:e=>["tenants","list",e],detail:e=>["tenants","detail",e]};function xa(e){const r=new URLSearchParams;e.q&&r.set("q",e.q),e.status&&r.set("status",e.status),e.limit&&r.set("limit",String(e.limit)),e.offset&&r.set("offset",String(e.offset));const s=r.toString();return s?`/v1/tenants?${s}`:"/v1/tenants"}function Xr(e){return et({queryKey:nt.list(e),queryFn:()=>Ae(xa(e)),staleTime:15e3})}function ga(e){return et({queryKey:nt.detail(e),queryFn:()=>Ae(`/v1/tenants/${e}`),enabled:!!e})}function va(){const e=ne();return ae({mutationFn:r=>oe("POST","/v1/tenants",r),onSuccess:()=>{e.invalidateQueries({queryKey:["tenants","list"]})}})}function ba(e){const r=ne();return ae({mutationFn:s=>oe("PATCH",`/v1/tenants/${e}`,s),onSuccess:s=>{r.setQueryData(nt.detail(e),s),r.invalidateQueries({queryKey:["tenants","list"]})}})}function ya(e){const r=ne();return ae({mutationFn:s=>oe("POST",`/v1/tenants/${e}/status`,{status:s}),onSuccess:s=>{r.setQueryData(nt.detail(e),s),r.invalidateQueries({queryKey:["tenants","list"]})}})}function Ge(e){if(e instanceof Pe){const r=e.body;return r?.message??r?.error??e.message}return e instanceof Error?e.message:"Unknown error"}var ja=function(e,r){for(var s={};e.length;){var n=e[0],a=n.code,o=n.message,i=n.path.join(".");if(!s[i])if("unionErrors"in n){var c=n.unionErrors[0].errors[0];s[i]={message:c.message,type:c.code}}else s[i]={message:o,type:a};if("unionErrors"in n&&n.unionErrors.forEach(function(m){return m.errors.forEach(function(h){return e.push(h)})}),r){var d=s[i].types,f=d&&d[n.code];s[i]=nn(i,r,s,a,f?[].concat(f,n.message):n.message)}e.shift()}return s},at=function(e,r,s){return s===void 0&&(s={}),function(n,a,o){try{return Promise.resolve(function(i,c){try{var d=Promise.resolve(e[s.mode==="sync"?"parse":"parseAsync"](n,r)).then(function(f){return o.shouldUseNativeValidation&&rn({},o),{errors:{},values:s.raw?n:f}})}catch(f){return c(f)}return d&&d.then?d.then(void 0,c):d}(0,function(i){if(function(c){return Array.isArray(c?.errors)}(i))return{values:{},errors:sn(ja(i.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw i}))}catch(i){return Promise.reject(i)}}};function ee(e,r,{checkForDefaultPrevented:s=!0}={}){return function(a){if(e?.(a),s===!1||!a.defaultPrevented)return r?.(a)}}function wa(e,r=[]){let s=[];function n(o,i){const c=l.createContext(i);c.displayName=o+"Context";const d=s.length;s=[...s,i];const f=h=>{const{scope:p,children:x,...g}=h,u=p?.[e]?.[d]||c,v=l.useMemo(()=>g,Object.values(g));return t.jsx(u.Provider,{value:v,children:x})};f.displayName=o+"Provider";function m(h,p){const x=p?.[e]?.[d]||c,g=l.useContext(x);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${o}\``)}return[f,m]}const a=()=>{const o=s.map(i=>l.createContext(i));return function(c){const d=c?.[e]||o;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return a.scopeName=e,[n,Na(a,...r)]}function Na(...e){const r=e[0];if(e.length===1)return r;const s=()=>{const n=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(o){const i=n.reduce((c,{useScope:d,scopeName:f})=>{const h=d(o)[`__scope${f}`];return{...c,...h}},{});return l.useMemo(()=>({[`__scope${r.scopeName}`]:i}),[i])}};return s.scopeName=r.scopeName,s}var ke=globalThis?.document?l.useLayoutEffect:()=>{},Sa=Tt[" useId ".trim().toString()]||(()=>{}),Ca=0;function ft(e){const[r,s]=l.useState(Sa());return ke(()=>{s(n=>n??String(Ca++))},[e]),e||(r?`radix-${r}`:"")}var _a=Tt[" useInsertionEffect ".trim().toString()]||ke;function Ea({prop:e,defaultProp:r,onChange:s=()=>{},caller:n}){const[a,o,i]=ka({defaultProp:r,onChange:s}),c=e!==void 0,d=c?e:a;{const m=l.useRef(e!==void 0);l.useEffect(()=>{const h=m.current;h!==c&&console.warn(`${n} is changing from ${h?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),m.current=c},[c,n])}const f=l.useCallback(m=>{if(c){const h=Ra(m)?m(e):m;h!==e&&i.current?.(h)}else o(m)},[c,e,o,i]);return[d,f]}function ka({defaultProp:e,onChange:r}){const[s,n]=l.useState(e),a=l.useRef(s),o=l.useRef(r);return _a(()=>{o.current=r},[r]),l.useEffect(()=>{a.current!==s&&(o.current?.(s),a.current=s)},[s,a]),[s,n,o]}function Ra(e){return typeof e=="function"}function Re(e){const r=l.useRef(e);return l.useEffect(()=>{r.current=e}),l.useMemo(()=>(...s)=>r.current?.(...s),[])}function Ta(e,r=globalThis?.document){const s=Re(e);l.useEffect(()=>{const n=a=>{a.key==="Escape"&&s(a)};return r.addEventListener("keydown",n,{capture:!0}),()=>r.removeEventListener("keydown",n,{capture:!0})},[s,r])}var Pa="DismissableLayer",_t="dismissableLayer.update",Aa="dismissableLayer.pointerDownOutside",Oa="dismissableLayer.focusOutside",sr,$t=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Jr=l.forwardRef((e,r)=>{const{disableOutsidePointerEvents:s=!1,deferPointerDownOutside:n=!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:c,onDismiss:d,...f}=e,m=l.useContext($t),[h,p]=l.useState(null),x=h?.ownerDocument??globalThis?.document,[,g]=l.useState({}),u=ie(r,R=>p(R)),v=Array.from(m.layers),[y]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),j=v.indexOf(y),N=h?v.indexOf(h):-1,b=m.layersWithOutsidePointerEventsDisabled.size>0,S=N>=j,P=l.useRef(!1),L=Fa(R=>{const I=R.target;if(!(I instanceof Node))return;const $=[...m.branches].some(_=>_.contains(I));!S||$||(o?.(R),c?.(R),R.defaultPrevented||d?.())},{ownerDocument:x,deferPointerDownOutside:n,isDeferredPointerDownOutsideRef:P,dismissableSurfaces:m.dismissableSurfaces}),K=Ia(R=>{if(n&&P.current)return;const I=R.target;[...m.branches].some(_=>_.contains(I))||(i?.(R),c?.(R),R.defaultPrevented||d?.())},x);return Ta(R=>{N===m.layers.size-1&&(a?.(R),!R.defaultPrevented&&d&&(R.preventDefault(),d()))},x),l.useEffect(()=>{if(h)return s&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(sr=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(h)),m.layers.add(h),nr(),()=>{s&&(m.layersWithOutsidePointerEventsDisabled.delete(h),m.layersWithOutsidePointerEventsDisabled.size===0&&(x.body.style.pointerEvents=sr))}},[h,x,s,m]),l.useEffect(()=>()=>{h&&(m.layers.delete(h),m.layersWithOutsidePointerEventsDisabled.delete(h),nr())},[h,m]),l.useEffect(()=>{const R=()=>g({});return document.addEventListener(_t,R),()=>document.removeEventListener(_t,R)},[]),t.jsx(H.div,{...f,ref:u,style:{pointerEvents:b?S?"auto":"none":void 0,...e.style},onFocusCapture:ee(e.onFocusCapture,K.onFocusCapture),onBlurCapture:ee(e.onBlurCapture,K.onBlurCapture),onPointerDownCapture:ee(e.onPointerDownCapture,L.onPointerDownCapture)})});Jr.displayName=Pa;var Ma="DismissableLayerBranch",Da=l.forwardRef((e,r)=>{const s=l.useContext($t),n=l.useRef(null),a=ie(r,n);return l.useEffect(()=>{const o=n.current;if(o)return s.branches.add(o),()=>{s.branches.delete(o)}},[s.branches]),t.jsx(H.div,{...e,ref:a})});Da.displayName=Ma;function La(){const e=l.useContext($t),[r,s]=l.useState(null);return l.useEffect(()=>{if(r)return e.dismissableSurfaces.add(r),()=>{e.dismissableSurfaces.delete(r)}},[r,e.dismissableSurfaces]),s}function Fa(e,r){const{ownerDocument:s=globalThis?.document,deferPointerDownOutside:n=!1,isDeferredPointerDownOutsideRef:a,dismissableSurfaces:o}=r,i=Re(e),c=l.useRef(!1),d=l.useRef(!1),f=l.useRef(new Map),m=l.useRef(()=>{});return l.useEffect(()=>{function h(){d.current=!1,a.current=!1,f.current.clear()}function p(){return Array.from(f.current.values()).some(Boolean)}function x(j){if(!d.current)return;const N=j.target;N instanceof Node&&[...o].some(S=>S.contains(N))||f.current.set(j.type,!0),j.type==="click"&&window.setTimeout(()=>{d.current&&m.current()},0)}function g(j){d.current&&f.current.set(j.type,!1)}const u=j=>{if(j.target&&!c.current){let N=function(){s.removeEventListener("click",m.current);const S=p();h(),S||Zr(Aa,i,b,{discrete:!0})};const b={originalEvent:j};d.current=!0,a.current=n&&j.button===0,f.current.clear(),!n||j.button!==0?N():(s.removeEventListener("click",m.current),m.current=N,s.addEventListener("click",m.current,{once:!0}))}else s.removeEventListener("click",m.current),h();c.current=!1},v=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const j of v)s.addEventListener(j,x,!0),s.addEventListener(j,g);const y=window.setTimeout(()=>{s.addEventListener("pointerdown",u)},0);return()=>{window.clearTimeout(y),s.removeEventListener("pointerdown",u),s.removeEventListener("click",m.current);for(const j of v)s.removeEventListener(j,x,!0),s.removeEventListener(j,g)}},[s,i,n,a,o]),{onPointerDownCapture:()=>c.current=!0}}function Ia(e,r=globalThis?.document){const s=Re(e),n=l.useRef(!1);return l.useEffect(()=>{const a=o=>{o.target&&!n.current&&Zr(Oa,s,{originalEvent:o},{discrete:!1})};return r.addEventListener("focusin",a),()=>r.removeEventListener("focusin",a)},[r,s]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function nr(){const e=new CustomEvent(_t);document.dispatchEvent(e)}function Zr(e,r,s,{discrete:n}){const a=s.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});r&&a.addEventListener(e,r,{once:!0}),n?ua(a,o):a.dispatchEvent(o)}var ht="focusScope.autoFocusOnMount",pt="focusScope.autoFocusOnUnmount",ar={bubbles:!1,cancelable:!0},$a="FocusScope",es=l.forwardRef((e,r)=>{const{loop:s=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...i}=e,[c,d]=l.useState(null),f=Re(a),m=Re(o),h=l.useRef(null),p=ie(r,u=>d(u)),x=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(n){let u=function(N){if(x.paused||!c)return;const b=N.target;c.contains(b)?h.current=b:J(h.current,{select:!0})},v=function(N){if(x.paused||!c)return;const b=N.relatedTarget;b!==null&&(c.contains(b)||J(h.current,{select:!0}))},y=function(N){if(document.activeElement===document.body)for(const S of N)S.removedNodes.length>0&&J(c)};document.addEventListener("focusin",u),document.addEventListener("focusout",v);const j=new MutationObserver(y);return c&&j.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",u),document.removeEventListener("focusout",v),j.disconnect()}}},[n,c,x.paused]),l.useEffect(()=>{if(c){ir.add(x);const u=document.activeElement;if(!c.contains(u)){const y=new CustomEvent(ht,ar);c.addEventListener(ht,f),c.dispatchEvent(y),y.defaultPrevented||(za(Va(ts(c)),{select:!0}),document.activeElement===u&&J(c))}return()=>{c.removeEventListener(ht,f),setTimeout(()=>{const y=new CustomEvent(pt,ar);c.addEventListener(pt,m),c.dispatchEvent(y),y.defaultPrevented||J(u??document.body,{select:!0}),c.removeEventListener(pt,m),ir.remove(x)},0)}}},[c,f,m,x]);const g=l.useCallback(u=>{if(!s&&!n||x.paused)return;const v=u.key==="Tab"&&!u.altKey&&!u.ctrlKey&&!u.metaKey,y=document.activeElement;if(v&&y){const j=u.currentTarget,[N,b]=qa(j);N&&b?!u.shiftKey&&y===b?(u.preventDefault(),s&&J(N,{select:!0})):u.shiftKey&&y===N&&(u.preventDefault(),s&&J(b,{select:!0})):y===j&&u.preventDefault()}},[s,n,x.paused]);return t.jsx(H.div,{tabIndex:-1,...i,ref:p,onKeyDown:g})});es.displayName=$a;function za(e,{select:r=!1}={}){const s=document.activeElement;for(const n of e)if(J(n,{select:r}),document.activeElement!==s)return}function qa(e){const r=ts(e),s=or(r,e),n=or(r.reverse(),e);return[s,n]}function ts(e){const r=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)r.push(s.currentNode);return r}function or(e,r){for(const s of e)if(!Ba(s,{upTo:r}))return s}function Ba(e,{upTo:r}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(r!==void 0&&e===r)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Ua(e){return e instanceof HTMLInputElement&&"select"in e}function J(e,{select:r=!1}={}){if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&Ua(e)&&r&&e.select()}}var ir=Wa();function Wa(){let e=[];return{add(r){const s=e[0];r!==s&&s?.pause(),e=cr(e,r),e.unshift(r)},remove(r){e=cr(e,r),e[0]?.resume()}}}function cr(e,r){const s=[...e],n=s.indexOf(r);return n!==-1&&s.splice(n,1),s}function Va(e){return e.filter(r=>r.tagName!=="A")}var Ha="Portal",rs=l.forwardRef((e,r)=>{const{container:s,...n}=e,[a,o]=l.useState(!1);ke(()=>o(!0),[]);const i=s||a&&globalThis?.document?.body;return i?Rt.createPortal(t.jsx(H.div,{...n,ref:r}),i):null});rs.displayName=Ha;function Ga(e,r){return l.useReducer((s,n)=>r[s][n]??s,e)}var ot=e=>{const{present:r,children:s}=e,n=Qa(r),a=typeof s=="function"?s({present:n.isPresent}):l.Children.only(s),o=Ka(n.ref,Ya(a));return typeof s=="function"||n.isPresent?l.cloneElement(a,{ref:o}):null};ot.displayName="Presence";function Qa(e){const[r,s]=l.useState(),n=l.useRef(null),a=l.useRef(e),o=l.useRef("none"),i=e?"mounted":"unmounted",[c,d]=Ga(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const f=ze(n.current);o.current=c==="mounted"?f:"none"},[c]),ke(()=>{const f=n.current,m=a.current;if(m!==e){const p=o.current,x=ze(f);e?d("MOUNT"):x==="none"||f?.display==="none"?d("UNMOUNT"):d(m&&p!==x?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,d]),ke(()=>{if(r){let f;const m=r.ownerDocument.defaultView??window,h=x=>{const u=ze(n.current).includes(CSS.escape(x.animationName));if(x.target===r&&u&&(d("ANIMATION_END"),!a.current)){const v=r.style.animationFillMode;r.style.animationFillMode="forwards",f=m.setTimeout(()=>{r.style.animationFillMode==="forwards"&&(r.style.animationFillMode=v)})}},p=x=>{x.target===r&&(o.current=ze(n.current))};return r.addEventListener("animationstart",p),r.addEventListener("animationcancel",h),r.addEventListener("animationend",h),()=>{m.clearTimeout(f),r.removeEventListener("animationstart",p),r.removeEventListener("animationcancel",h),r.removeEventListener("animationend",h)}}else d("ANIMATION_END")},[r,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:l.useCallback(f=>{n.current=f?getComputedStyle(f):null,s(f)},[])}}function lr(e,r){if(typeof e=="function")return e(r);e!=null&&(e.current=r)}function Ka(...e){const r=l.useRef(e);return r.current=e,l.useCallback(s=>{const n=r.current;let a=!1;const o=n.map(i=>{const c=lr(i,s);return!a&&typeof c=="function"&&(a=!0),c});if(a)return()=>{for(let i=0;i<o.length;i++){const c=o[i];typeof c=="function"?c():lr(n[i],null)}}},[])}function ze(e){return e?.animationName||"none"}function Ya(e){let r=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=r&&"isReactWarning"in r&&r.isReactWarning;return s?e.ref:(r=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=r&&"isReactWarning"in r&&r.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}var qe=0,ce=null;function Xa(){l.useEffect(()=>{ce||(ce={start:dr(),end:dr()});const{start:e,end:r}=ce;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==r&&document.body.insertAdjacentElement("beforeend",r),qe++,()=>{qe===1&&(ce?.start.remove(),ce?.end.remove(),ce=null),qe=Math.max(0,qe-1)}},[])}function dr(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var V=function(){return V=Object.assign||function(r){for(var s,n=1,a=arguments.length;n<a;n++){s=arguments[n];for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])}return r},V.apply(this,arguments)};function ss(e,r){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(s[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)r.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(s[n[a]]=e[n[a]]);return s}function Ja(e,r,s){if(s||arguments.length===2)for(var n=0,a=r.length,o;n<a;n++)(o||!(n in r))&&(o||(o=Array.prototype.slice.call(r,0,n)),o[n]=r[n]);return e.concat(o||Array.prototype.slice.call(r))}var Qe="right-scroll-bar-position",Ke="width-before-scroll-bar",Za="with-scroll-bars-hidden",eo="--removed-body-scroll-bar-size";function xt(e,r){return typeof e=="function"?e(r):e&&(e.current=r),e}function to(e,r){var s=l.useState(function(){return{value:e,callback:r,facade:{get current(){return s.value},set current(n){var a=s.value;a!==n&&(s.value=n,s.callback(n,a))}}}})[0];return s.callback=r,s.facade}var ro=typeof window<"u"?l.useLayoutEffect:l.useEffect,ur=new WeakMap;function so(e,r){var s=to(null,function(n){return e.forEach(function(a){return xt(a,n)})});return ro(function(){var n=ur.get(s);if(n){var a=new Set(n),o=new Set(e),i=s.current;a.forEach(function(c){o.has(c)||xt(c,null)}),o.forEach(function(c){a.has(c)||xt(c,i)})}ur.set(s,e)},[e]),s}function no(e){return e}function ao(e,r){r===void 0&&(r=no);var s=[],n=!1,a={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return s.length?s[s.length-1]:e},useMedium:function(o){var i=r(o,n);return s.push(i),function(){s=s.filter(function(c){return c!==i})}},assignSyncMedium:function(o){for(n=!0;s.length;){var i=s;s=[],i.forEach(o)}s={push:function(c){return o(c)},filter:function(){return s}}},assignMedium:function(o){n=!0;var i=[];if(s.length){var c=s;s=[],c.forEach(o),i=s}var d=function(){var m=i;i=[],m.forEach(o)},f=function(){return Promise.resolve().then(d)};f(),s={push:function(m){i.push(m),f()},filter:function(m){return i=i.filter(m),s}}}};return a}function oo(e){e===void 0&&(e={});var r=ao(null);return r.options=V({async:!0,ssr:!1},e),r}var ns=function(e){var r=e.sideCar,s=ss(e,["sideCar"]);if(!r)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=r.read();if(!n)throw new Error("Sidecar medium not found");return l.createElement(n,V({},s))};ns.isSideCarExport=!0;function io(e,r){return e.useMedium(r),ns}var as=oo(),gt=function(){},it=l.forwardRef(function(e,r){var s=l.useRef(null),n=l.useState({onScrollCapture:gt,onWheelCapture:gt,onTouchMoveCapture:gt}),a=n[0],o=n[1],i=e.forwardProps,c=e.children,d=e.className,f=e.removeScrollBar,m=e.enabled,h=e.shards,p=e.sideCar,x=e.noRelative,g=e.noIsolation,u=e.inert,v=e.allowPinchZoom,y=e.as,j=y===void 0?"div":y,N=e.gapMode,b=ss(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=p,P=so([s,r]),L=V(V({},b),a);return l.createElement(l.Fragment,null,m&&l.createElement(S,{sideCar:as,removeScrollBar:f,shards:h,noRelative:x,noIsolation:g,inert:u,setCallbacks:o,allowPinchZoom:!!v,lockRef:s,gapMode:N}),i?l.cloneElement(l.Children.only(c),V(V({},L),{ref:P})):l.createElement(j,V({},L,{className:d,ref:P}),c))});it.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};it.classNames={fullWidth:Ke,zeroRight:Qe};var co=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function lo(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var r=co();return r&&e.setAttribute("nonce",r),e}function uo(e,r){e.styleSheet?e.styleSheet.cssText=r:e.appendChild(document.createTextNode(r))}function mo(e){var r=document.head||document.getElementsByTagName("head")[0];r.appendChild(e)}var fo=function(){var e=0,r=null;return{add:function(s){e==0&&(r=lo())&&(uo(r,s),mo(r)),e++},remove:function(){e--,!e&&r&&(r.parentNode&&r.parentNode.removeChild(r),r=null)}}},ho=function(){var e=fo();return function(r,s){l.useEffect(function(){return e.add(r),function(){e.remove()}},[r&&s])}},os=function(){var e=ho(),r=function(s){var n=s.styles,a=s.dynamic;return e(n,a),null};return r},po={left:0,top:0,right:0,gap:0},vt=function(e){return parseInt(e||"",10)||0},xo=function(e){var r=window.getComputedStyle(document.body),s=r[e==="padding"?"paddingLeft":"marginLeft"],n=r[e==="padding"?"paddingTop":"marginTop"],a=r[e==="padding"?"paddingRight":"marginRight"];return[vt(s),vt(n),vt(a)]},go=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return po;var r=xo(e),s=document.documentElement.clientWidth,n=window.innerWidth;return{left:r[0],top:r[1],right:r[2],gap:Math.max(0,n-s+r[2]-r[0])}},vo=os(),fe="data-scroll-locked",bo=function(e,r,s,n){var a=e.left,o=e.top,i=e.right,c=e.gap;return s===void 0&&(s="margin"),`
- .`.concat(Za,` {
- overflow: hidden `).concat(n,`;
- padding-right: `).concat(c,"px ").concat(n,`;
- }
- body[`).concat(fe,`] {
- overflow: hidden `).concat(n,`;
- overscroll-behavior: contain;
- `).concat([r&&"position: relative ".concat(n,";"),s==="margin"&&`
- padding-left: `.concat(a,`px;
- padding-top: `).concat(o,`px;
- padding-right: `).concat(i,`px;
- margin-left:0;
- margin-top:0;
- margin-right: `).concat(c,"px ").concat(n,`;
- `),s==="padding"&&"padding-right: ".concat(c,"px ").concat(n,";")].filter(Boolean).join(""),`
- }
-
- .`).concat(Qe,` {
- right: `).concat(c,"px ").concat(n,`;
- }
-
- .`).concat(Ke,` {
- margin-right: `).concat(c,"px ").concat(n,`;
- }
-
- .`).concat(Qe," .").concat(Qe,` {
- right: 0 `).concat(n,`;
- }
-
- .`).concat(Ke," .").concat(Ke,` {
- margin-right: 0 `).concat(n,`;
- }
-
- body[`).concat(fe,`] {
- `).concat(eo,": ").concat(c,`px;
- }
- `)},mr=function(){var e=parseInt(document.body.getAttribute(fe)||"0",10);return isFinite(e)?e:0},yo=function(){l.useEffect(function(){return document.body.setAttribute(fe,(mr()+1).toString()),function(){var e=mr()-1;e<=0?document.body.removeAttribute(fe):document.body.setAttribute(fe,e.toString())}},[])},jo=function(e){var r=e.noRelative,s=e.noImportant,n=e.gapMode,a=n===void 0?"margin":n;yo();var o=l.useMemo(function(){return go(a)},[a]);return l.createElement(vo,{styles:bo(o,!r,a,s?"":"!important")})},Et=!1;if(typeof window<"u")try{var Be=Object.defineProperty({},"passive",{get:function(){return Et=!0,!0}});window.addEventListener("test",Be,Be),window.removeEventListener("test",Be,Be)}catch{Et=!1}var le=Et?{passive:!1}:!1,wo=function(e){return e.tagName==="TEXTAREA"},is=function(e,r){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return s[r]!=="hidden"&&!(s.overflowY===s.overflowX&&!wo(e)&&s[r]==="visible")},No=function(e){return is(e,"overflowY")},So=function(e){return is(e,"overflowX")},fr=function(e,r){var s=r.ownerDocument,n=r;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=cs(e,n);if(a){var o=ls(e,n),i=o[1],c=o[2];if(i>c)return!0}n=n.parentNode}while(n&&n!==s.body);return!1},Co=function(e){var r=e.scrollTop,s=e.scrollHeight,n=e.clientHeight;return[r,s,n]},_o=function(e){var r=e.scrollLeft,s=e.scrollWidth,n=e.clientWidth;return[r,s,n]},cs=function(e,r){return e==="v"?No(r):So(r)},ls=function(e,r){return e==="v"?Co(r):_o(r)},Eo=function(e,r){return e==="h"&&r==="rtl"?-1:1},ko=function(e,r,s,n,a){var o=Eo(e,window.getComputedStyle(r).direction),i=o*n,c=s.target,d=r.contains(c),f=!1,m=i>0,h=0,p=0;do{if(!c)break;var x=ls(e,c),g=x[0],u=x[1],v=x[2],y=u-v-o*g;(g||y)&&cs(e,c)&&(h+=y,p+=g);var j=c.parentNode;c=j&&j.nodeType===Node.DOCUMENT_FRAGMENT_NODE?j.host:j}while(!d&&c!==document.body||d&&(r.contains(c)||r===c));return(m&&Math.abs(h)<1||!m&&Math.abs(p)<1)&&(f=!0),f},Ue=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},hr=function(e){return[e.deltaX,e.deltaY]},pr=function(e){return e&&"current"in e?e.current:e},Ro=function(e,r){return e[0]===r[0]&&e[1]===r[1]},To=function(e){return`
- .block-interactivity-`.concat(e,` {pointer-events: none;}
- .allow-interactivity-`).concat(e,` {pointer-events: all;}
- `)},Po=0,de=[];function Ao(e){var r=l.useRef([]),s=l.useRef([0,0]),n=l.useRef(),a=l.useState(Po++)[0],o=l.useState(os)[0],i=l.useRef(e);l.useEffect(function(){i.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var u=Ja([e.lockRef.current],(e.shards||[]).map(pr),!0).filter(Boolean);return u.forEach(function(v){return v.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),u.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var c=l.useCallback(function(u,v){if("touches"in u&&u.touches.length===2||u.type==="wheel"&&u.ctrlKey)return!i.current.allowPinchZoom;var y=Ue(u),j=s.current,N="deltaX"in u?u.deltaX:j[0]-y[0],b="deltaY"in u?u.deltaY:j[1]-y[1],S,P=u.target,L=Math.abs(N)>Math.abs(b)?"h":"v";if("touches"in u&&L==="h"&&P.type==="range")return!1;var K=window.getSelection(),R=K&&K.anchorNode,I=R?R===P||R.contains(P):!1;if(I)return!1;var $=fr(L,P);if(!$)return!0;if($?S=L:(S=L==="v"?"h":"v",$=fr(L,P)),!$)return!1;if(!n.current&&"changedTouches"in u&&(N||b)&&(n.current=S),!S)return!0;var _=n.current||S;return ko(_,v,u,_==="h"?N:b)},[]),d=l.useCallback(function(u){var v=u;if(!(!de.length||de[de.length-1]!==o)){var y="deltaY"in v?hr(v):Ue(v),j=r.current.filter(function(S){return S.name===v.type&&(S.target===v.target||v.target===S.shadowParent)&&Ro(S.delta,y)})[0];if(j&&j.should){v.cancelable&&v.preventDefault();return}if(!j){var N=(i.current.shards||[]).map(pr).filter(Boolean).filter(function(S){return S.contains(v.target)}),b=N.length>0?c(v,N[0]):!i.current.noIsolation;b&&v.cancelable&&v.preventDefault()}}},[]),f=l.useCallback(function(u,v,y,j){var N={name:u,delta:v,target:y,should:j,shadowParent:Oo(y)};r.current.push(N),setTimeout(function(){r.current=r.current.filter(function(b){return b!==N})},1)},[]),m=l.useCallback(function(u){s.current=Ue(u),n.current=void 0},[]),h=l.useCallback(function(u){f(u.type,hr(u),u.target,c(u,e.lockRef.current))},[]),p=l.useCallback(function(u){f(u.type,Ue(u),u.target,c(u,e.lockRef.current))},[]);l.useEffect(function(){return de.push(o),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:p}),document.addEventListener("wheel",d,le),document.addEventListener("touchmove",d,le),document.addEventListener("touchstart",m,le),function(){de=de.filter(function(u){return u!==o}),document.removeEventListener("wheel",d,le),document.removeEventListener("touchmove",d,le),document.removeEventListener("touchstart",m,le)}},[]);var x=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(o,{styles:To(a)}):null,x?l.createElement(jo,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Oo(e){for(var r=null;e!==null;)e instanceof ShadowRoot&&(r=e.host,e=e.host),e=e.parentNode;return r}const Mo=io(as,Ao);var ds=l.forwardRef(function(e,r){return l.createElement(it,V({},e,{ref:r,sideCar:Mo}))});ds.classNames=it.classNames;var Do=function(e){if(typeof document>"u")return null;var r=Array.isArray(e)?e[0]:e;return r.ownerDocument.body},ue=new WeakMap,We=new WeakMap,Ve={},bt=0,us=function(e){return e&&(e.host||us(e.parentNode))},Lo=function(e,r){return r.map(function(s){if(e.contains(s))return s;var n=us(s);return n&&e.contains(n)?n:(console.error("aria-hidden",s,"in not contained inside",e,". Doing nothing"),null)}).filter(function(s){return!!s})},Fo=function(e,r,s,n){var a=Lo(r,Array.isArray(e)?e:[e]);Ve[s]||(Ve[s]=new WeakMap);var o=Ve[s],i=[],c=new Set,d=new Set(a),f=function(h){!h||c.has(h)||(c.add(h),f(h.parentNode))};a.forEach(f);var m=function(h){!h||d.has(h)||Array.prototype.forEach.call(h.children,function(p){if(c.has(p))m(p);else try{var x=p.getAttribute(n),g=x!==null&&x!=="false",u=(ue.get(p)||0)+1,v=(o.get(p)||0)+1;ue.set(p,u),o.set(p,v),i.push(p),u===1&&g&&We.set(p,!0),v===1&&p.setAttribute(s,"true"),g||p.setAttribute(n,"true")}catch(y){console.error("aria-hidden: cannot operate on ",p,y)}})};return m(r),c.clear(),bt++,function(){i.forEach(function(h){var p=ue.get(h)-1,x=o.get(h)-1;ue.set(h,p),o.set(h,x),p||(We.has(h)||h.removeAttribute(n),We.delete(h)),x||h.removeAttribute(s)}),bt--,bt||(ue=new WeakMap,ue=new WeakMap,We=new WeakMap,Ve={})}},Io=function(e,r,s){s===void 0&&(s="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),a=Do(e);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live], script"))),Fo(n,a,s,"aria-hidden")):function(){return null}},ct="Dialog",[ms]=wa(ct),[$o,z]=ms(ct),fs=e=>{const{__scopeDialog:r,children:s,open:n,defaultOpen:a,onOpenChange:o,modal:i=!0}=e,c=l.useRef(null),d=l.useRef(null),[f,m]=Ea({prop:n,defaultProp:a??!1,onChange:o,caller:ct});return t.jsx($o,{scope:r,triggerRef:c,contentRef:d,contentId:ft(),titleId:ft(),descriptionId:ft(),open:f,onOpenChange:m,onOpenToggle:l.useCallback(()=>m(h=>!h),[m]),modal:i,children:s})};fs.displayName=ct;var hs="DialogTrigger",ps=l.forwardRef((e,r)=>{const{__scopeDialog:s,...n}=e,a=z(hs,s),o=ie(r,a.triggerRef);return t.jsx(H.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":Bt(a.open),...n,ref:o,onClick:ee(e.onClick,a.onOpenToggle)})});ps.displayName=hs;var zt="DialogPortal",[zo,xs]=ms(zt,{forceMount:void 0}),gs=e=>{const{__scopeDialog:r,forceMount:s,children:n,container:a}=e,o=z(zt,r);return t.jsx(zo,{scope:r,forceMount:s,children:l.Children.map(n,i=>t.jsx(ot,{present:s||o.open,children:t.jsx(rs,{asChild:!0,container:a,children:i})}))})};gs.displayName=zt;var Je="DialogOverlay",vs=l.forwardRef((e,r)=>{const s=xs(Je,e.__scopeDialog),{forceMount:n=s.forceMount,...a}=e,o=z(Je,e.__scopeDialog);return o.modal?t.jsx(ot,{present:n||o.open,children:t.jsx(Bo,{...a,ref:r})}):null});vs.displayName=Je;var qo=Dt("DialogOverlay.RemoveScroll"),Bo=l.forwardRef((e,r)=>{const{__scopeDialog:s,...n}=e,a=z(Je,s),o=La(),i=ie(r,o);return t.jsx(ds,{as:qo,allowPinchZoom:!0,shards:[a.contentRef],children:t.jsx(H.div,{"data-state":Bt(a.open),...n,ref:i,style:{pointerEvents:"auto",...n.style}})})}),he="DialogContent",bs=l.forwardRef((e,r)=>{const s=xs(he,e.__scopeDialog),{forceMount:n=s.forceMount,...a}=e,o=z(he,e.__scopeDialog);return t.jsx(ot,{present:n||o.open,children:o.modal?t.jsx(Uo,{...a,ref:r}):t.jsx(Wo,{...a,ref:r})})});bs.displayName=he;var Uo=l.forwardRef((e,r)=>{const s=z(he,e.__scopeDialog),n=l.useRef(null),a=ie(r,s.contentRef,n);return l.useEffect(()=>{const o=n.current;if(o)return Io(o)},[]),t.jsx(ys,{...e,ref:a,trapFocus:s.open,disableOutsidePointerEvents:s.open,onCloseAutoFocus:ee(e.onCloseAutoFocus,o=>{o.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:ee(e.onPointerDownOutside,o=>{const i=o.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&o.preventDefault()}),onFocusOutside:ee(e.onFocusOutside,o=>o.preventDefault())})}),Wo=l.forwardRef((e,r)=>{const s=z(he,e.__scopeDialog),n=l.useRef(!1),a=l.useRef(!1);return t.jsx(ys,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{e.onCloseAutoFocus?.(o),o.defaultPrevented||(n.current||s.triggerRef.current?.focus(),o.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:o=>{e.onInteractOutside?.(o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const i=o.target;s.triggerRef.current?.contains(i)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),ys=l.forwardRef((e,r)=>{const{__scopeDialog:s,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,...i}=e,c=z(he,s);return Xa(),t.jsx(t.Fragment,{children:t.jsx(es,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:t.jsx(Jr,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Bt(c.open),...i,ref:r,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})}),js="DialogTitle",ws=l.forwardRef((e,r)=>{const{__scopeDialog:s,...n}=e,a=z(js,s);return t.jsx(H.h2,{id:a.titleId,...n,ref:r})});ws.displayName=js;var Ns="DialogDescription",Ss=l.forwardRef((e,r)=>{const{__scopeDialog:s,...n}=e,a=z(Ns,s);return t.jsx(H.p,{id:a.descriptionId,...n,ref:r})});Ss.displayName=Ns;var Cs="DialogClose",qt=l.forwardRef((e,r)=>{const{__scopeDialog:s,...n}=e,a=z(Cs,s);return t.jsx(H.button,{type:"button",...n,ref:r,onClick:ee(e.onClick,()=>a.onOpenChange(!1))})});qt.displayName=Cs;function Bt(e){return e?"open":"closed"}const Oe=fs,Ut=ps,Vo=gs,Ho=qt,_s=l.forwardRef(({className:e,...r},s)=>t.jsx(vs,{ref:s,className:k("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...r}));_s.displayName="DialogOverlay";const ge=l.forwardRef(({className:e,children:r,...s},n)=>t.jsxs(Vo,{children:[t.jsx(_s,{}),t.jsxs(bs,{ref:n,className:k("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border bg-background p-6 shadow-lg sm:rounded-lg","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","max-h-[90vh] overflow-y-auto",e),...s,children:[r,t.jsxs(qt,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[t.jsx(Qs,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ge.displayName="DialogContent";function Me({className:e,...r}){return t.jsx("div",{className:k("flex flex-col gap-1.5 text-left",e),...r})}function De({className:e,...r}){return t.jsx("div",{className:k("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end sm:gap-2",e),...r})}const ve=l.forwardRef(({className:e,...r},s)=>t.jsx(ws,{ref:s,className:k("text-lg font-semibold leading-none tracking-tight",e),...r}));ve.displayName="DialogTitle";const be=l.forwardRef(({className:e,...r},s)=>t.jsx(Ss,{ref:s,className:k("text-sm text-muted-foreground",e),...r}));be.displayName="DialogDescription";const Go=/^[a-z0-9][a-z0-9-]{0,62}[a-z0-9]$/,Qo=tt({slug:F().min(2,"Slug must be 2–64 characters").max(64,"Slug must be 2–64 characters").regex(Go,"Lowercase letters, digits, and dashes only"),display_name:F().min(1,"Display name is required"),contact_email:F().email("Enter a valid email"),rate_limit_per_sec:rt({invalid_type_error:"Enter a number"}).int("Whole number only").min(1,"Must be at least 1").max(1e6,"Must be at most 1,000,000"),fcm_shared:_e()});function xr(){const[e,r]=l.useState(!1),s=pe(),n=va(),a=st({resolver:at(Qo),defaultValues:{slug:"",display_name:"",contact_email:"",rate_limit_per_sec:1e4,fcm_shared:!0}});l.useEffect(()=>{e&&a.reset()},[e,a]);const o=a.handleSubmit(async i=>{const c={slug:i.slug.trim(),display_name:i.display_name.trim(),contact_email:i.contact_email.trim(),rate_limit_per_sec:i.rate_limit_per_sec,fcm_shared:i.fcm_shared};try{const d=await n.mutateAsync(c);O.success(`Created ${d.display_name}`),r(!1),s(`/companies/${d.id}`)}catch(d){const f=Ge(d);O.error(f),f.toLowerCase().includes("slug")&&a.setError("slug",{message:f})}});return t.jsxs(Oe,{open:e,onOpenChange:r,children:[t.jsx(Ut,{asChild:!0,children:t.jsxs(C,{children:[t.jsx(Rr,{className:"h-4 w-4"}),"New company"]})}),t.jsxs(ge,{children:[t.jsxs(Me,{children:[t.jsx(ve,{children:"New company"}),t.jsx(be,{children:"The slug becomes part of every event this tenant sends (and shows up in the audit log). Choose carefully — it cannot be changed after creation."})]}),t.jsxs("form",{onSubmit:o,className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(E,{htmlFor:"slug",children:"Slug"}),t.jsx(A,{id:"slug",placeholder:"acme-corp",autoComplete:"off",...a.register("slug"),"aria-invalid":!!a.formState.errors.slug}),a.formState.errors.slug?t.jsx("p",{className:"text-xs text-destructive",children:a.formState.errors.slug.message}):t.jsx("p",{className:"text-xs text-muted-foreground",children:"2–64 chars, lowercase + digits + dashes."})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(E,{htmlFor:"rate_limit_per_sec",children:"Rate limit (events/sec)"}),t.jsx(A,{id:"rate_limit_per_sec",type:"number",min:1,max:1e6,...a.register("rate_limit_per_sec",{valueAsNumber:!0}),"aria-invalid":!!a.formState.errors.rate_limit_per_sec}),a.formState.errors.rate_limit_per_sec?t.jsx("p",{className:"text-xs text-destructive",children:a.formState.errors.rate_limit_per_sec.message}):null]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(E,{htmlFor:"display_name",children:"Display name"}),t.jsx(A,{id:"display_name",placeholder:"Acme Corporation",...a.register("display_name"),"aria-invalid":!!a.formState.errors.display_name}),a.formState.errors.display_name?t.jsx("p",{className:"text-xs text-destructive",children:a.formState.errors.display_name.message}):null]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(E,{htmlFor:"contact_email",children:"Contact email"}),t.jsx(A,{id:"contact_email",type:"email",placeholder:"ops@acme.example",autoComplete:"off",...a.register("contact_email"),"aria-invalid":!!a.formState.errors.contact_email}),a.formState.errors.contact_email?t.jsx("p",{className:"text-xs text-destructive",children:a.formState.errors.contact_email.message}):null]}),t.jsxs("div",{className:"flex items-start gap-2 rounded-md border bg-muted/40 p-3",children:[t.jsx("input",{id:"fcm_shared",type:"checkbox",className:"mt-0.5 h-4 w-4 rounded border-input",...a.register("fcm_shared")}),t.jsxs("div",{className:"space-y-0.5",children:[t.jsx(E,{htmlFor:"fcm_shared",className:"cursor-pointer",children:"Use shared FCM pool"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Default. Only turn this off for high-volume tenants that need a dedicated sender ID (M13b W3 territory)."})]})]}),t.jsxs(De,{children:[t.jsx(C,{type:"button",variant:"ghost",onClick:()=>r(!1),disabled:n.isPending,children:"Cancel"}),t.jsx(C,{type:"submit",disabled:n.isPending,children:n.isPending?"Creating…":"Create company"})]})]})]})]})}const Ko=Hr("inline-flex items-center rounded-md border px-2 py-0.5 text-xs font-medium transition-colors",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",outline:"text-foreground",success:"border-transparent bg-emerald-100 text-emerald-800 dark:bg-emerald-900/30 dark:text-emerald-300",warning:"border-transparent bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-300",danger:"border-transparent bg-rose-100 text-rose-800 dark:bg-rose-900/30 dark:text-rose-300",muted:"border-transparent bg-muted text-muted-foreground"}},defaultVariants:{variant:"default"}}),lt=l.forwardRef(({className:e,variant:r,...s},n)=>t.jsx("span",{ref:n,className:k(Ko({variant:r}),e),...s}));lt.displayName="Badge";const Yo={active:"Active",suspended:"Suspended",archived:"Archived"},Xo={active:"success",suspended:"warning",archived:"muted"};function Jo(e){return Yo[e]??e}function Zo(e){return Xo[e]??"muted"}function Es({status:e}){return t.jsx(lt,{variant:Zo(e),children:Jo(e)})}function ks(e){return e>=1e6?`${(e/1e6).toFixed(1)}M/s`:e>=1e3?`${(e/1e3).toFixed(1)}k/s`:`${e}/s`}function Se(e){if(!e)return"—";const r=new Date(e);return Number.isNaN(r.getTime())?e:r.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}const ei=[{value:"",label:"All"},{value:"active",label:"Active"},{value:"suspended",label:"Suspended"},{value:"archived",label:"Archived"}];function ti(){const[e,r]=Cr(),[s,n]=l.useState(e.get("q")??""),a=e.get("status")??"",{user:o}=te(),i=Vr(o?.role);l.useEffect(()=>{const x=setTimeout(()=>{const g=new URLSearchParams(e);s.trim()?g.set("q",s.trim()):g.delete("q"),r(g,{replace:!0})},300);return()=>clearTimeout(x)},[s]);const c=l.useMemo(()=>({q:e.get("q")??void 0,status:a||void 0,limit:100}),[e,a]),{data:d,isPending:f,isError:m,error:h,refetch:p}=Xr(c);return t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Companies"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage the tenants that send events to the router."})]}),i?t.jsx(xr,{}):null]}),t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[t.jsxs("div",{className:"relative flex-1 sm:max-w-sm",children:[t.jsx(Tr,{className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(A,{placeholder:"Search by slug or name",className:"pl-8",value:s,onChange:x=>n(x.target.value),"aria-label":"Search companies"})]}),t.jsx("div",{className:"flex gap-1",children:ei.map(x=>{const g=a===x.value;return t.jsx(C,{variant:g?"secondary":"ghost",size:"sm",onClick:()=>{const u=new URLSearchParams(e);x.value?u.set("status",x.value):u.delete("status"),r(u,{replace:!0})},children:x.label},x.value)})})]}),m?t.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 p-4 text-sm text-destructive",children:[t.jsx("p",{className:"font-medium",children:"Failed to load companies."}),t.jsx("p",{className:"mt-1 text-xs opacity-80",children:h instanceof Error?h.message:"Unknown error"}),t.jsx(C,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>p(),children:"Retry"})]}):null,f?t.jsx("div",{className:"rounded-md border bg-card p-8 text-center text-sm text-muted-foreground",children:"Loading…"}):d&&d.items.length===0?t.jsx(Yr,{icon:t.jsx(Er,{className:"h-8 w-8"}),title:"No companies yet",description:i?"Create the first company to start routing events.":"You will see your company here once it has been set up.",action:i?t.jsx(xr,{}):null}):d?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"rounded-md border bg-card",children:t.jsxs(Lt,{children:[t.jsx(Ft,{children:t.jsxs(Ee,{children:[t.jsx(M,{children:"Name"}),t.jsx(M,{children:"Slug"}),t.jsx(M,{children:"Status"}),t.jsx(M,{className:"text-right",children:"Rate limit"}),t.jsx(M,{children:"FCM"}),t.jsx(M,{children:"Created"})]})}),t.jsx(It,{children:d.items.map(x=>t.jsxs(Ee,{children:[t.jsx(D,{children:t.jsx(Te,{to:`/companies/${x.id}`,className:"font-medium text-foreground hover:underline",children:x.display_name})}),t.jsx(D,{children:t.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:x.slug})}),t.jsx(D,{children:t.jsx(Es,{status:x.status})}),t.jsx(D,{className:"text-right tabular-nums",children:ks(x.rate_limit_per_sec)}),t.jsx(D,{className:"text-xs text-muted-foreground",children:x.fcm_shared?"shared":"dedicated"}),t.jsx(D,{className:"text-xs text-muted-foreground",children:Se(x.created_at)})]},x.id))})]})}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Showing ",d.items.length," of ",d.total]})]}):null]})}const ri=tt({display_name:F().min(1,"Display name is required"),contact_email:F().email("Enter a valid email"),rate_limit_per_sec:rt({invalid_type_error:"Enter a number"}).int("Whole number only").min(1).max(1e6),fcm_shared:_e()}),si={display_name:"",contact_email:"",rate_limit_per_sec:1e4,fcm_shared:!0};function ni(){const{id:e=""}=Pt(),r=pe(),{user:s}=te(),n=Mt(s?.role),a=Bn(s?.role),o=ga(e),i=ba(e),c=ya(e),d=st({resolver:at(ri),defaultValues:si});if(l.useEffect(()=>{const p=o.data;p&&(d.setValue("display_name",p.display_name),d.setValue("contact_email",p.contact_email),d.setValue("rate_limit_per_sec",p.rate_limit_per_sec),d.setValue("fcm_shared",p.fcm_shared))},[o.data,d]),!a)return t.jsx("div",{className:"rounded-md border bg-card p-6 text-sm text-muted-foreground",children:"You do not have access to this company."});if(o.isError){const p=Ge(o.error);return t.jsxs("div",{className:"space-y-3",children:[t.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>r("/companies"),children:[t.jsx(yt,{className:"h-4 w-4"}),"Back"]}),t.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 p-4 text-sm text-destructive",children:p})]})}if(!o.data)return t.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading…"});const f=o.data,m=d.handleSubmit(async p=>{try{await i.mutateAsync({display_name:p.display_name.trim(),contact_email:p.contact_email.trim(),rate_limit_per_sec:p.rate_limit_per_sec,fcm_shared:p.fcm_shared}),O.success("Saved")}catch(x){O.error(Ge(x))}}),h=async p=>{try{await c.mutateAsync(p),O.success(`Status set to ${p}`)}catch(x){O.error(Ge(x))}};return t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs(C,{variant:"ghost",size:"sm",className:"self-start",onClick:()=>r("/companies"),children:[t.jsx(yt,{className:"h-4 w-4"}),"Back to companies"]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:f.display_name}),t.jsx(Es,{status:f.status})]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:f.slug}),t.jsx("span",{className:"mx-2 opacity-50",children:"·"}),"created ",Se(f.created_at)]})]}),t.jsxs("div",{className:"grid gap-6 md:grid-cols-3",children:[t.jsxs(q,{className:"md:col-span-2",children:[t.jsxs(B,{children:[t.jsx(U,{children:"Details"}),t.jsx(Z,{children:n?"All fields are editable.":"Display name and contact email are editable. Other fields require a super-admin."})]}),t.jsx(W,{children:t.jsxs("form",{onSubmit:m,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(E,{htmlFor:"display_name",children:"Display name"}),t.jsx(A,{id:"display_name",...d.register("display_name"),"aria-invalid":!!d.formState.errors.display_name}),d.formState.errors.display_name?t.jsx("p",{className:"text-xs text-destructive",children:d.formState.errors.display_name.message}):null]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(E,{htmlFor:"contact_email",children:"Contact email"}),t.jsx(A,{id:"contact_email",type:"email",autoComplete:"off",...d.register("contact_email"),"aria-invalid":!!d.formState.errors.contact_email}),d.formState.errors.contact_email?t.jsx("p",{className:"text-xs text-destructive",children:d.formState.errors.contact_email.message}):null]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(E,{htmlFor:"rate_limit_per_sec",children:"Rate limit"}),t.jsx(A,{id:"rate_limit_per_sec",type:"number",min:1,max:1e6,disabled:!n,...d.register("rate_limit_per_sec",{valueAsNumber:!0}),"aria-invalid":!!d.formState.errors.rate_limit_per_sec}),d.formState.errors.rate_limit_per_sec?t.jsx("p",{className:"text-xs text-destructive",children:d.formState.errors.rate_limit_per_sec.message}):null]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(E,{children:"FCM pool"}),t.jsxs("label",{className:"flex items-center gap-2 rounded-md border bg-muted/40 p-2 text-sm",children:[t.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-input",disabled:!n,...d.register("fcm_shared")}),"Use shared FCM pool"]})]})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(C,{type:"submit",disabled:i.isPending,children:i.isPending?"Saving…":"Save changes"})})]})})]}),t.jsxs("div",{className:"space-y-4",children:[n?t.jsxs(q,{children:[t.jsxs(B,{children:[t.jsx(U,{children:"Status"}),t.jsx(Z,{children:"Suspending stops new ingest immediately. Archiving is permanent and is only used to retire a tenant."})]}),t.jsxs(W,{className:"space-y-2",children:[f.status==="active"?t.jsx(C,{variant:"outline",className:"w-full",disabled:c.isPending,onClick:()=>void h("suspended"),children:"Suspend"}):f.status==="suspended"?t.jsx(C,{variant:"default",className:"w-full",disabled:c.isPending,onClick:()=>void h("active"),children:"Activate"}):null,f.status!=="archived"?t.jsx(ai,{onConfirm:()=>void h("archived"),pending:c.isPending}):t.jsx("p",{className:"rounded-md border bg-muted/40 p-3 text-xs text-muted-foreground",children:"Archived. Status changes are not allowed."})]})]}):null,t.jsxs(q,{children:[t.jsx(B,{children:t.jsx(U,{className:"text-base",children:"Metadata"})}),t.jsxs(W,{className:"space-y-2 text-sm",children:[t.jsx(re,{label:"ID",value:t.jsx("code",{className:"text-xs",children:f.id})}),t.jsx(re,{label:"Slug",value:t.jsx("code",{className:"text-xs",children:f.slug})}),t.jsx(re,{label:"Rate limit",value:ks(f.rate_limit_per_sec)}),t.jsx(re,{label:"FCM",value:f.fcm_shared?"shared":"dedicated"}),t.jsx(re,{label:"Created",value:Se(f.created_at)}),t.jsx(re,{label:"Updated",value:Se(f.updated_at)}),f.archived_at?t.jsx(re,{label:"Archived",value:Se(f.archived_at)}):null]})]})]})]})]})}function re({label:e,value:r}){return t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:e}),t.jsx("span",{className:"text-right",children:r})]})}function ai({onConfirm:e,pending:r}){return t.jsxs(Oe,{children:[t.jsx(Ut,{asChild:!0,children:t.jsx(C,{variant:"destructive",className:"w-full",disabled:r,children:"Archive…"})}),t.jsxs(ge,{children:[t.jsxs(Me,{children:[t.jsxs(ve,{className:"flex items-center gap-2",children:[t.jsx(Ks,{className:"h-4 w-4 text-destructive"}),"Archive this company?"]}),t.jsxs(be,{children:["Archiving is ",t.jsx("strong",{children:"permanent"}),": the tenant cannot be reactivated, and new events will be rejected. Existing rows (deliveries, audit, DLQ) are kept for compliance but are not surfaced in the UI."]})]}),t.jsxs(De,{children:[t.jsx(Ho,{asChild:!0,children:t.jsx(C,{variant:"ghost",disabled:r,children:"Cancel"})}),t.jsx(C,{variant:"destructive",disabled:r,onClick:e,children:r?"Archiving…":"Archive company"})]})]})]})}function oi(){return t.jsxs(_r,{children:[t.jsx(Ce,{index:!0,element:t.jsx(ti,{})}),t.jsx(Ce,{path:":id",element:t.jsx(ni,{})})]})}const Le={list:(e,r)=>["sources","list",e,r],detail:(e,r)=>["sources","detail",e,r]};function ii(e,r){const s=new URLSearchParams;r.q&&s.set("q",r.q),r.type&&s.set("type",r.type),r.status&&s.set("status",r.status),r.limit&&s.set("limit",String(r.limit)),r.offset&&s.set("offset",String(r.offset));const n=s.toString();return n?`/v1/tenants/${e}/sources?${n}`:`/v1/tenants/${e}/sources`}function ci(e,r){return et({queryKey:Le.list(e,r),queryFn:()=>Ae(ii(e,r)),enabled:!!e,staleTime:15e3})}function li(e,r){return et({queryKey:Le.detail(e,r),queryFn:()=>Ae(`/v1/tenants/${e}/sources/${r}`),enabled:!!e&&!!r})}function di(e){const r=ne();return ae({mutationFn:s=>oe("POST",`/v1/tenants/${e}/sources`,s),onSuccess:()=>{r.invalidateQueries({queryKey:["sources","list",e]})}})}function ui(e,r){const s=ne();return ae({mutationFn:n=>oe("PATCH",`/v1/tenants/${e}/sources/${r}`,n),onSuccess:n=>{s.setQueryData(Le.detail(e,r),n),s.invalidateQueries({queryKey:["sources","list",e]})}})}function mi(e,r){const s=ne();return ae({mutationFn:n=>oe("POST",`/v1/tenants/${e}/sources/${r}/status`,{status:n}),onSuccess:n=>{s.setQueryData(Le.detail(e,r),n),s.invalidateQueries({queryKey:["sources","list",e]})}})}function fi(e,r){const s=ne();return ae({mutationFn:()=>oe("POST",`/v1/tenants/${e}/sources/${r}/rotate-secrets`,{}),onSuccess:n=>{s.setQueryData(Le.detail(e,r),n.source),s.invalidateQueries({queryKey:["sources","list",e]})}})}function Ye(e){if(e instanceof Pe){const r=e.body;return r?.message??r?.error??e.message}return e instanceof Error?e.message:"Unknown error"}const Wt=l.forwardRef(({className:e,...r},s)=>t.jsx("textarea",{ref:s,className:k("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50",e),...r}));Wt.displayName="Textarea";const Ze=l.forwardRef(({className:e,...r},s)=>t.jsx("input",{ref:s,type:"checkbox",className:k("h-4 w-4 shrink-0 rounded-sm border border-input bg-background","cursor-pointer accent-primary","disabled:cursor-not-allowed disabled:opacity-50","focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",e),...r}));Ze.displayName="Checkbox";const hi=/^[a-z0-9][a-z0-9-]{0,62}[a-z0-9]$/,pi=tt({id:F().min(2,"Source id must be 2–64 characters").max(64,"Source id must be 2–64 characters").regex(hi,"Lowercase letters, digits, and dashes only"),name:F().min(1,"Name is required").max(200,"Name must be ≤ 200 characters"),type:Pr(["http","mqtt","ws","grpc"]),rate_limit_per_sec:rt({invalid_type_error:"Enter a number"}).int("Whole number only").min(1,"Must be at least 1").max(1e6,"Must be at most 1,000,000"),description:F().max(500,"Description must be ≤ 500 characters").optional().or(He("")),mtls_required:_e(),auto_secrets:_e(),hmac_secret:F().optional().or(He("")),api_key:F().optional().or(He(""))}),gr={id:"",name:"",type:"http",rate_limit_per_sec:1e3,description:"",mtls_required:!1,auto_secrets:!0,hmac_secret:"",api_key:""};function vr({tenantId:e}){const[r,s]=l.useState(!1),[n,a]=l.useState(null),o=di(e),i=st({resolver:at(pi),defaultValues:gr});l.useEffect(()=>{r&&i.reset(gr)},[r,i]);const c=i.handleSubmit(async d=>{const f={id:d.id.trim(),name:d.name.trim(),type:d.type,rate_limit_per_sec:d.rate_limit_per_sec,description:d.description??"",mtls_required:d.mtls_required,hmac_secret:d.auto_secrets?void 0:d.hmac_secret||void 0,api_key:d.auto_secrets?void 0:d.api_key||void 0};try{const m=await o.mutateAsync(f);s(!1),m.secrets?a(m):O.success(`Source "${m.source.name}" created.`)}catch(m){O.error(Ye(m))}});return t.jsxs(t.Fragment,{children:[t.jsxs(Oe,{open:r,onOpenChange:s,children:[t.jsx(Ut,{asChild:!0,children:t.jsxs(C,{children:[t.jsx(Rr,{className:"mr-2 h-4 w-4"}),"New source"]})}),t.jsxs(ge,{className:"sm:max-w-lg",children:[t.jsxs(Me,{children:[t.jsx(ve,{children:"New source"}),t.jsxs(be,{children:["Create a new ingest endpoint for this company. Secrets are generated and shown ",t.jsx("strong",{children:"only once"}),"; save them before closing the next dialog."]})]}),t.jsxs("form",{onSubmit:c,className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"col-span-1 flex flex-col gap-1",children:[t.jsx(E,{htmlFor:"src-id",children:"ID"}),t.jsx(A,{id:"src-id",placeholder:"primary",...i.register("id")}),i.formState.errors.id?t.jsx("p",{className:"text-xs text-destructive",children:i.formState.errors.id.message}):null]}),t.jsxs("div",{className:"col-span-1 flex flex-col gap-1",children:[t.jsx(E,{htmlFor:"src-type",children:"Type"}),t.jsxs("select",{id:"src-type",className:"h-9 rounded-md border border-input bg-background px-3 text-sm",...i.register("type"),children:[t.jsx("option",{value:"http",children:"HTTP"}),t.jsx("option",{value:"mqtt",children:"MQTT"}),t.jsx("option",{value:"ws",children:"WebSocket"}),t.jsx("option",{value:"grpc",children:"gRPC"})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(E,{htmlFor:"src-name",children:"Name"}),t.jsx(A,{id:"src-name",placeholder:"Primary Source",...i.register("name")}),i.formState.errors.name?t.jsx("p",{className:"text-xs text-destructive",children:i.formState.errors.name.message}):null]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"col-span-1 flex flex-col gap-1",children:[t.jsx(E,{htmlFor:"src-rl",children:"Rate limit (/s)"}),t.jsx(A,{id:"src-rl",type:"number",min:1,...i.register("rate_limit_per_sec",{valueAsNumber:!0})}),i.formState.errors.rate_limit_per_sec?t.jsx("p",{className:"text-xs text-destructive",children:i.formState.errors.rate_limit_per_sec.message}):null]}),t.jsxs("div",{className:"col-span-1 flex items-center gap-2 pt-6",children:[t.jsx(Ze,{id:"src-mtls",...i.register("mtls_required")}),t.jsx(E,{htmlFor:"src-mtls",className:"cursor-pointer",children:"Require mTLS"})]})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(E,{htmlFor:"src-desc",children:"Description"}),t.jsx(Wt,{id:"src-desc",rows:2,placeholder:"Optional. What does this source do?",...i.register("description")})]}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ze,{id:"src-auto",...i.register("auto_secrets")}),t.jsx(E,{htmlFor:"src-auto",className:"cursor-pointer",children:"Auto-generate HMAC secret + API key"})]}),i.watch("auto_secrets")?null:t.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-2",children:[t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(E,{htmlFor:"src-hmac",className:"text-xs",children:"HMAC secret (32–128 chars)"}),t.jsx(A,{id:"src-hmac",...i.register("hmac_secret")})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(E,{htmlFor:"src-apikey",className:"text-xs",children:"API key (16–128 chars)"}),t.jsx(A,{id:"src-apikey",...i.register("api_key")})]})]})]}),t.jsxs(De,{children:[t.jsx(C,{type:"button",variant:"ghost",onClick:()=>s(!1),children:"Cancel"}),t.jsx(C,{type:"submit",disabled:o.isPending,children:o.isPending?"Creating…":"Create source"})]})]})]})]}),t.jsx(xi,{state:n,onClose:()=>{n&&O.success(`Source "${n.source.name}" created.`),a(null)}})]})}function xi({state:e,onClose:r}){return t.jsx(Oe,{open:!!e,onOpenChange:s=>!s&&r(),children:t.jsxs(ge,{className:"sm:max-w-lg",children:[t.jsxs(Me,{children:[t.jsxs(ve,{className:"flex items-center gap-2",children:[t.jsx(Xe,{className:"h-5 w-5 text-amber-500"}),"Save these secrets now"]}),t.jsxs(be,{children:["These are the HMAC secret and API key for the source. They are shown ",t.jsx("strong",{children:"once"}),". After you close this dialog, only the hashes are stored; the plaintext is gone from the server."]})]}),e?t.jsx(gi,{secrets:e.secrets}):null,t.jsx(De,{children:t.jsx(C,{onClick:r,children:"I have saved these — close"})})]})})}function gi({secrets:e}){const[r,s]=l.useState(!1),[n,a]=l.useState(!1);return t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx(br,{label:"HMAC secret",value:e?.hmac_secret??"",show:r,onToggle:()=>s(o=>!o)}),t.jsx(br,{label:"API key",value:e?.api_key??"",show:n,onToggle:()=>a(o=>!o)})]})}function br({label:e,value:r,show:s,onToggle:n}){const[a,o]=l.useState(!1);return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:e}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(C,{type:"button",size:"sm",variant:"ghost",onClick:n,"aria-label":s?"Hide":"Show",children:s?t.jsx(Ys,{className:"h-3 w-3"}):t.jsx(Xs,{className:"h-3 w-3"})}),t.jsxs(C,{type:"button",size:"sm",variant:"ghost",onClick:async()=>{try{await navigator.clipboard.writeText(r),o(!0),setTimeout(()=>o(!1),1500)}catch{}},"aria-label":"Copy",children:[t.jsx(Js,{className:"h-3 w-3"}),t.jsx("span",{className:"ml-1 text-xs",children:a?"Copied":"Copy"})]})]})]}),t.jsx("pre",{className:"overflow-x-auto rounded-md border bg-muted/40 p-2 text-xs leading-relaxed",children:t.jsx("code",{children:s?r:"•".repeat(Math.min(r.length||8,32))})})]})}const vi={active:"Active",suspended:"Suspended"},bi={active:"success",suspended:"warning"};function yi(e){return vi[e]??e}function ji(e){return bi[e]??"warning"}function Rs({status:e}){return t.jsx(lt,{variant:ji(e),children:yi(e)})}const wi={http:"HTTP",mqtt:"MQTT",ws:"WebSocket",grpc:"gRPC"},Ni={http:"Standard HTTP POST ingest with HMAC",mqtt:"MQTT topic subscription",ws:"WebSocket long-lived connection",grpc:"gRPC bidi-streaming ingest (high-volume)"};function kt(e){return wi[e]??e}function Si(e){return Ni[e]??""}function Ci({type:e}){return t.jsx(lt,{variant:"muted",children:kt(e)})}function Ts(e){return e>=1e6?`${(e/1e6).toFixed(1)}M/s`:e>=1e3?`${(e/1e3).toFixed(1)}k/s`:`${e}/s`}function Ps(e){if(!e)return"—";const r=new Date(e);return Number.isNaN(r.getTime())?e:r.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function yr({value:e}){if(e==null)return t.jsx("span",{className:"text-xs text-muted-foreground",children:"\\u2014"});let r;try{r=JSON.stringify(e,null,2)}catch{r=String(e)}return t.jsx("pre",{className:"max-h-48 overflow-auto rounded-md border bg-muted/40 p-3 text-xs leading-relaxed",children:t.jsx("code",{children:r})})}const _i=[{value:"",label:"All types"},{value:"http",label:"HTTP"},{value:"mqtt",label:"MQTT"},{value:"ws",label:"WebSocket"},{value:"grpc",label:"gRPC"}],Ei=[{value:"",label:"All"},{value:"active",label:"Active"},{value:"suspended",label:"Suspended"}];function jr(){const e=pe(),r=Pt(),{user:s}=te(),n=Nt(s?.role),a=Mt(s?.role),o=r.id,[i,c]=Cr(),[d,f]=l.useState(i.get("q")??""),m=i.get("type")??"",h=i.get("status")??"",p=Xr({limit:200});l.useEffect(()=>{if(o||!a)return;const b=p.data&&p.data.items[0];b&&e(`/sources/${b.id}`,{replace:!0})},[o,a,p.data,e]),l.useEffect(()=>{const b=setTimeout(()=>{const S=new URLSearchParams(i);d.trim()?S.set("q",d.trim()):S.delete("q"),c(S,{replace:!0})},300);return()=>clearTimeout(b)},[d]);const x=l.useMemo(()=>({q:i.get("q")??void 0,type:m||void 0,status:h||void 0,limit:100}),[i,m,h]),{data:g,isPending:u,isError:v,error:y,refetch:j}=ci(o,x),N=b=>{e(b?`/sources/${b}`:"/sources")};return t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Sources"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage the ingest endpoints per company. Each source has its own credentials, rate limit, and routing rules."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[a&&p.data?t.jsxs("select",{className:"h-9 rounded-md border border-input bg-background px-3 text-sm",value:o??"",onChange:b=>N(b.target.value),"aria-label":"Company",children:[t.jsx("option",{value:"",children:"Select a company"}),p.data.items.map(b=>t.jsx("option",{value:b.id,children:b.display_name},b.id))]}):null,n&&o?t.jsx(vr,{tenantId:o}):null]})]}),o?t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[t.jsxs("div",{className:"relative flex-1 sm:max-w-sm",children:[t.jsx(Tr,{className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(A,{placeholder:"Search by id or name",className:"pl-8",value:d,onChange:b=>f(b.target.value),"aria-label":"Search sources"})]}),t.jsx("div",{className:"flex flex-wrap gap-1",children:_i.map(b=>{const S=m===b.value;return t.jsx(C,{variant:S?"secondary":"ghost",size:"sm",onClick:()=>{const P=new URLSearchParams(i);b.value?P.set("type",b.value):P.delete("type"),c(P,{replace:!0})},children:b.label},b.value)})}),t.jsx("div",{className:"flex gap-1",children:Ei.map(b=>{const S=h===b.value;return t.jsx(C,{variant:S?"secondary":"ghost",size:"sm",onClick:()=>{const P=new URLSearchParams(i);b.value?P.set("status",b.value):P.delete("status"),c(P,{replace:!0})},children:b.label},b.value)})})]}):null,o?v?t.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 p-4 text-sm text-destructive",children:[t.jsx("p",{className:"font-medium",children:"Failed to load sources."}),t.jsx("p",{className:"mt-1 text-xs opacity-80",children:y instanceof Error?y.message:"Unknown error"}),t.jsx(C,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>j(),children:"Retry"})]}):u?t.jsx("div",{className:"rounded-md border bg-card p-8 text-center text-sm text-muted-foreground",children:"Loading…"}):g&&g.items.length===0?t.jsx(Yr,{icon:t.jsx(kr,{className:"h-8 w-8"}),title:"No sources yet",description:n?"Create the first source for this company.":"Your operator has not set up any sources for this company yet.",action:n?t.jsx(vr,{tenantId:o}):null}):g?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"rounded-md border bg-card",children:t.jsxs(Lt,{children:[t.jsx(Ft,{children:t.jsxs(Ee,{children:[t.jsx(M,{children:"Name"}),t.jsx(M,{children:"ID"}),t.jsx(M,{children:"Type"}),t.jsx(M,{children:"Status"}),t.jsx(M,{className:"text-right",children:"Rate limit"}),t.jsx(M,{children:"Secrets"}),t.jsx(M,{children:"Created"})]})}),t.jsx(It,{children:g.items.map(b=>t.jsxs(Ee,{children:[t.jsx(D,{children:t.jsx(Te,{to:`/sources/${o}/${b.id}`,className:"font-medium text-foreground hover:underline",children:b.name})}),t.jsx(D,{children:t.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:b.id})}),t.jsx(D,{children:t.jsx(Ci,{type:b.type})}),t.jsx(D,{children:t.jsx(Rs,{status:b.status})}),t.jsx(D,{className:"text-right tabular-nums",children:Ts(b.rate_limit_per_sec)}),t.jsx(D,{className:"text-xs text-muted-foreground",children:ki(b.hmac_set,b.api_key_set)}),t.jsx(D,{className:"text-xs text-muted-foreground",children:Ps(b.created_at)})]},`${b.company_id}:${b.id}`))})]})}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Showing ",g.items.length," of ",g.total]})]}):null:t.jsx("div",{className:"rounded-md border bg-card p-8 text-center text-sm text-muted-foreground",children:a?"Select a company above to see its sources.":"You will see sources here once your company is set up."})]})}function ki(e,r){return e&&r?"HMAC + API":e?"HMAC only":r?"API only":"none"}const Ri=tt({name:F().min(1,"Name is required").max(200,"Name must be ≤ 200 characters"),type:Pr(["http","mqtt","ws","grpc"]),rate_limit_per_sec:rt({invalid_type_error:"Enter a number"}).int("Whole number only").min(1).max(1e6),description:F().max(500).optional().or(He("")),mtls_required:_e()}),Ti={name:"",type:"http",rate_limit_per_sec:1e3,description:"",mtls_required:!1};function Pi(){const e=Pt(),r=pe(),s=e.id??"",n=e.sid??"",a=li(s,n),o=ui(s,n),i=mi(s,n),c=fi(s,n),[d,f]=l.useState(null),m=st({resolver:at(Ri),defaultValues:Ti});l.useEffect(()=>{const u=a.data;u&&(m.setValue("name",u.name),m.setValue("type",u.type),m.setValue("rate_limit_per_sec",u.rate_limit_per_sec),m.setValue("description",u.description??""),m.setValue("mtls_required",u.mtls_required))},[a.data,m]);const h=m.handleSubmit(async u=>{try{await o.mutateAsync({name:u.name.trim(),type:u.type,rate_limit_per_sec:u.rate_limit_per_sec,description:u.description??"",mtls_required:u.mtls_required}),O.success("Source updated.")}catch(v){O.error(Ye(v))}}),p=async u=>{try{await i.mutateAsync(u),O.success(`Source ${u}.`)}catch(v){O.error(Ye(v))}},x=async()=>{try{const u=await c.mutateAsync();f(u)}catch(u){O.error(Ye(u))}};if(a.isError)return t.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 p-4 text-sm text-destructive",children:[t.jsx("p",{className:"font-medium",children:"Failed to load source."}),t.jsx("p",{className:"mt-1 text-xs opacity-80",children:a.error instanceof Error?a.error.message:"Unknown error"})]});if(!a.data)return t.jsx("div",{className:"rounded-md border bg-card p-8 text-center text-sm text-muted-foreground",children:"Loading…"});const g=a.data;return t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>r(`/sources/${s}`),children:[t.jsx(yt,{className:"mr-1 h-3 w-3"}),"Sources"]})}),t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:g.name}),t.jsx(Rs,{status:g.status})]}),t.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[t.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:g.id}),t.jsx("span",{className:"mx-2",children:"\\u00b7"}),kt(g.type)," (",Si(g.type),")"]})]}),t.jsx("div",{className:"flex items-center gap-2",children:g.status==="active"?t.jsx(C,{variant:"outline",size:"sm",onClick:()=>p("suspended"),disabled:i.isPending,children:"Suspend"}):t.jsx(C,{variant:"outline",size:"sm",onClick:()=>p("active"),disabled:i.isPending,children:"Activate"})})]}),t.jsxs(q,{children:[t.jsxs(B,{children:[t.jsx(U,{children:"Configuration"}),t.jsx(Z,{children:"Edit the source's name, type, rate limit, and mTLS requirement."})]}),t.jsx(W,{children:t.jsxs("form",{onSubmit:h,className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"col-span-2 flex flex-col gap-1",children:[t.jsx(E,{htmlFor:"d-name",children:"Name"}),t.jsx(A,{id:"d-name",...m.register("name")}),m.formState.errors.name?t.jsx("p",{className:"text-xs text-destructive",children:m.formState.errors.name.message}):null]}),t.jsxs("div",{className:"col-span-1 flex flex-col gap-1",children:[t.jsx(E,{htmlFor:"d-type",children:"Type"}),t.jsxs("select",{id:"d-type",className:"h-9 rounded-md border border-input bg-background px-3 text-sm",...m.register("type"),children:[t.jsx("option",{value:"http",children:"HTTP"}),t.jsx("option",{value:"mqtt",children:"MQTT"}),t.jsx("option",{value:"ws",children:"WebSocket"}),t.jsx("option",{value:"grpc",children:"gRPC"})]})]}),t.jsxs("div",{className:"col-span-1 flex flex-col gap-1",children:[t.jsx(E,{htmlFor:"d-rl",children:"Rate limit (/s)"}),t.jsx(A,{id:"d-rl",type:"number",min:1,...m.register("rate_limit_per_sec",{valueAsNumber:!0})})]}),t.jsxs("div",{className:"col-span-2 flex flex-col gap-1",children:[t.jsx(E,{htmlFor:"d-desc",children:"Description"}),t.jsx(Wt,{id:"d-desc",rows:2,...m.register("description")})]}),t.jsxs("div",{className:"col-span-2 flex items-center gap-2 pt-1",children:[t.jsx(Ze,{id:"d-mtls",...m.register("mtls_required")}),t.jsx(E,{htmlFor:"d-mtls",className:"cursor-pointer",children:"Require mTLS client cert (M14)"})]}),t.jsx("div",{className:"col-span-2 flex items-center gap-2 pt-2",children:t.jsx(C,{type:"submit",disabled:o.isPending,children:o.isPending?"Saving…":"Save changes"})})]})})]}),t.jsxs(q,{children:[t.jsxs(B,{children:[t.jsxs(U,{className:"flex items-center gap-2",children:[t.jsx(Zs,{className:"h-4 w-4"}),"Secrets"]}),t.jsx(Z,{children:"The plaintext values are not stored — only their bcrypt hashes. Use rotate to generate new values (returned once)."})]}),t.jsxs(W,{children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[t.jsx(wr,{label:"HMAC secret",set:g.hmac_set}),t.jsx(wr,{label:"API key",set:g.api_key_set})]}),t.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[t.jsx(C,{variant:"outline",size:"sm",onClick:x,disabled:c.isPending,children:c.isPending?"Rotating…":"Rotate both secrets"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"Old values are invalidated immediately. The source's clients must be updated to the new values within their cache TTL."})]})]})]}),t.jsxs(q,{children:[t.jsxs(B,{children:[t.jsxs(U,{className:"flex items-center gap-2",children:[t.jsx(Xe,{className:"h-4 w-4"}),"mTLS / Client cert"]}),t.jsxs(Z,{children:["M14 will wire up client cert provisioning, rotation, and revocation for sources with ",t.jsx("code",{children:"mtls_required"})," = true."]})]}),t.jsx(W,{children:t.jsx("div",{className:"text-sm text-muted-foreground",children:t.jsxs("p",{children:[t.jsx("strong",{className:"text-foreground",children:"Currently:"})," ",g.mtls_required?t.jsxs("span",{children:["mTLS is required. Cert lifecycle: ",t.jsx("em",{children:"coming in M14."})]}):t.jsx("span",{children:"Not required. Toggle the flag above when you want to enforce client certs."})]})})})]}),t.jsxs(q,{children:[t.jsxs(B,{children:[t.jsxs(U,{className:"flex items-center gap-2",children:[t.jsx(en,{className:"h-4 w-4"}),"Routing (read-only in W2)"]}),t.jsx(Z,{children:"M13c adds the routing-rule editor. W2 only shows the current allowed_targets and match_expr as JSONB."})]}),t.jsxs(W,{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(E,{children:"Allowed targets"}),t.jsx(yr,{value:g.allowed_targets})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(E,{children:"Match expression"}),t.jsx(yr,{value:g.match_expr})]})]})]}),t.jsxs(q,{children:[t.jsx(B,{children:t.jsx(U,{children:"Metadata"})}),t.jsx(W,{children:t.jsxs("dl",{className:"grid grid-cols-2 gap-x-6 gap-y-2 text-sm",children:[t.jsx("dt",{className:"text-muted-foreground",children:"Source ID"}),t.jsx("dd",{children:t.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:g.id})}),t.jsx("dt",{className:"text-muted-foreground",children:"Company"}),t.jsx("dd",{children:t.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:g.company_id})}),t.jsx("dt",{className:"text-muted-foreground",children:"Type"}),t.jsx("dd",{children:kt(g.type)}),t.jsx("dt",{className:"text-muted-foreground",children:"Rate limit"}),t.jsx("dd",{children:Ts(g.rate_limit_per_sec)}),t.jsx("dt",{className:"text-muted-foreground",children:"Created"}),t.jsx("dd",{children:Ps(g.created_at)})]})})]}),t.jsx(Oe,{open:!!d,onOpenChange:u=>!u&&f(null),children:t.jsxs(ge,{className:"sm:max-w-lg",children:[t.jsxs(Me,{children:[t.jsxs(ve,{className:"flex items-center gap-2",children:[t.jsx(Xe,{className:"h-5 w-5 text-amber-500"}),"New secrets — save them now"]}),t.jsxs(be,{children:["Rotation succeeded. The new HMAC secret and API key are shown",t.jsx("strong",{children:" once"}),". After you close this dialog, only the hashes are stored."]})]}),d?t.jsx(Ai,{secrets:d.secrets}):null,t.jsx(De,{children:t.jsx(C,{onClick:()=>f(null),children:"I have saved these — close"})})]})})]})}function wr({label:e,set:r}){return t.jsxs("div",{className:"flex items-center justify-between rounded-md border bg-muted/20 p-3",children:[t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e}),t.jsx("span",{className:"text-sm font-medium",children:r?"Configured":"Not set"})]}),t.jsx("span",{className:r?"inline-flex h-2 w-2 rounded-full bg-emerald-500":"inline-flex h-2 w-2 rounded-full bg-amber-400","aria-label":r?"set":"not set"})]})}function Ai({secrets:e}){const[r,s]=l.useState(!1),[n,a]=l.useState(!1);return t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx(Nr,{label:"New HMAC secret",value:e?.hmac_secret??"",show:r,onToggle:()=>s(o=>!o)}),t.jsx(Nr,{label:"New API key",value:e?.api_key??"",show:n,onToggle:()=>a(o=>!o)})]})}function Nr({label:e,value:r,show:s,onToggle:n}){const[a,o]=l.useState(!1);return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:e}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(C,{type:"button",size:"sm",variant:"ghost",onClick:n,children:s?"Hide":"Show"}),t.jsx(C,{type:"button",size:"sm",variant:"ghost",onClick:async()=>{try{await navigator.clipboard.writeText(r),o(!0),setTimeout(()=>o(!1),1500)}catch{}},children:a?"Copied":"Copy"})]})]}),t.jsx("pre",{className:"overflow-x-auto rounded-md border bg-muted/40 p-2 text-xs leading-relaxed",children:t.jsx("code",{children:s?r:"•".repeat(Math.min(r.length||8,32))})})]})}function Oi(){return t.jsxs(_r,{children:[t.jsx(Ce,{index:!0,element:t.jsx(jr,{})}),t.jsx(Ce,{path:":id",element:t.jsx(jr,{})}),t.jsx(Ce,{path:":id/:sid",element:t.jsx(Pi,{})})]})}function dt({title:e,description:r,badge:s,children:n,className:a}){return t.jsx("div",{className:k("mx-auto max-w-2xl py-12",a),children:t.jsxs("div",{className:"rounded-lg border bg-card p-8 shadow-sm",children:[t.jsx("div",{className:"mb-4 flex items-center gap-2",children:t.jsx("span",{className:"rounded-md bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:s??"coming soon"})}),t.jsx("h2",{className:"mb-2 text-2xl font-semibold tracking-tight",children:e}),r?t.jsx("p",{className:"mb-6 text-sm text-muted-foreground",children:r}):null,n]})})}function Mi(){return t.jsx(dt,{title:"Telegram bots",badge:"M13b W3",description:"Per-company bot config, invite codes, bindings table. Bot token is never displayed after save.",children:t.jsxs("ul",{className:"ml-5 list-disc space-y-1 text-sm text-muted-foreground",children:[t.jsx("li",{children:"Set / rotate bot token (encrypted at rest in admind)"}),t.jsx("li",{children:"Generate invite codes with magic link"}),t.jsx("li",{children:"List bindings: chat_id → individual_id mapping"})]})})}function Di(){return t.jsx(dt,{title:"Live tail",badge:"M13c",description:"SSE feed of incoming alerts, filterable by company / severity / source / text. Replaces the per-company dump that lives on /v1/tail today.",children:t.jsxs("ul",{className:"ml-5 list-disc space-y-1 text-sm text-muted-foreground",children:[t.jsx("li",{children:"EventSource('/v1/tail/stream') with auth via short-lived SSE token"}),t.jsx("li",{children:"Filter bar (severity, source, search) + pause-on-scroll-up"}),t.jsx("li",{children:"Click row → modal with full payload + dedupe history"})]})})}function Li(){return t.jsxs(dt,{title:"DLQ",badge:"M13c",description:"React replacement for cmd/admind/ui/dlq.html. Same list/replay/discard flow plus filters and audit hooks.",children:[t.jsxs("p",{className:"mb-4 text-sm text-muted-foreground",children:["Until the React surface ships, the M8 HTML UI is still served at"," ",t.jsx("code",{className:"rounded bg-muted px-1",children:"/dlq"})," by the admind binary."]}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Per-channel admin endpoints (",t.jsx("code",{children:"/v1/admin/dlq"})," on deliverd-fcm and deliverd-telegram, JWT-gated) are also available for ops who want to inspect a single channel."]})]})}function Fi(){return t.jsx(dt,{title:"Audit log",badge:"M13c",description:"Read-only table of audit_log rows, filterable by actor / action / entity / time.",children:t.jsxs("ul",{className:"ml-5 list-disc space-y-1 text-sm text-muted-foreground",children:[t.jsx("li",{children:"Filter bar: actor (user_id), action, entity_type, time range"}),t.jsx("li",{children:"Row expand: full JSON payload"}),t.jsx("li",{children:"Export to CSV (super-admin only)"})]})})}function Ii(){return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"404"}),t.jsx("h1",{className:"mt-2 text-2xl font-semibold tracking-tight",children:"Page not found"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"The route you followed isn't part of the admin console."}),t.jsx(C,{asChild:!0,className:"mt-6",children:t.jsx(Te,{to:"/",children:"Back to dashboard"})})]})})}function $i(){return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"403"}),t.jsx("h1",{className:"mt-2 text-2xl font-semibold tracking-tight",children:"Forbidden"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Your role doesn't grant access to this page."}),t.jsx(C,{asChild:!0,className:"mt-6",children:t.jsx(Te,{to:"/",children:"Back to dashboard"})})]})})}const zi=Fs([{path:"/login",element:t.jsx(ha,{})},{path:"/forbidden",element:t.jsx($i,{})},{element:t.jsx(la,{children:t.jsx(ca,{})}),children:[{path:"/",element:t.jsx(pa,{})},{path:"/companies/*",element:t.jsx(oi,{})},{path:"/sources/*",element:t.jsx(Oi,{})},{path:"/telegram/*",element:t.jsx(Mi,{})},{path:"/tail",element:t.jsx(Di,{})},{path:"/dlq",element:t.jsx(Li,{})},{path:"/audit",element:t.jsx(Fi,{})}]},{path:"*",element:t.jsx(Ii,{})}]);na();const qi=new Os({defaultOptions:{queries:{staleTime:3e4,retry:1,refetchOnWindowFocus:!0}}}),As=document.getElementById("root");if(!As)throw new Error("#root element not found in index.html");Ar(As).render(t.jsx(l.StrictMode,{children:t.jsx(Ms,{client:qi,children:t.jsxs(qn,{children:[t.jsx(Is,{router:zi}),t.jsx(tn,{position:"top-right",richColors:!0})]})})}));
|