adminizer 5.0.0-build.7 → 5.0.0-build.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{add-DOjh2NLm.js → add-DED_wpga.js} +1 -1
- package/assets/{add-group-B2FdiaVg.js → add-group-CL80RdYb.js} +1 -1
- package/assets/{add-user-C07In-rU.js → add-user-BRmwvQB8.js} +1 -1
- package/assets/{app-layout-CvW8DKyk.js → app-layout-86yxiZOy.js} +1 -1
- package/assets/app.js +2 -2
- package/assets/catalog-BEvJZYJP.js +6 -0
- package/assets/{dashboard-DRxpsbtY.js → dashboard-ZP6K2s_8.js} +1 -1
- package/assets/{history-srOjJz94.js → history-M61Bcv02.js} +1 -1
- package/assets/{list-BObKdaDd.js → list-DhK0McVn.js} +1 -1
- package/assets/manifest.json +24 -24
- package/assets/{module-CdaN8Pkb.js → module-DfBneaUl.js} +1 -1
- package/assets/{notification-DMwIGHiv.js → notification-CVnQf3ef.js} +1 -1
- package/assets/{user-filters-list-CnRaXLuv.js → user-filters-list-DXhGLFTn.js} +1 -1
- package/assets/{welcome-DrLD1BEN.js → welcome-CLxvXkcg.js} +1 -1
- package/lib/model/adapter/sequelize.d.ts +4 -3
- package/lib/model/adapter/sequelize.js +19 -1
- package/package.json +1 -1
- package/assets/catalog-CObbOCOb.js +0 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as e,r as a,t,j as o,q as c,A as u}from"./app.js";import{A as p}from"./app-layout-
|
|
1
|
+
import{u as e,r as a,t,j as o,q as c,A as u}from"./app.js";import{A as p}from"./app-layout-86yxiZOy.js";import"./use-appearance-_EbbjHTh.js";const f=[];function m(){const r=e();return a.useEffect(()=>{const s=r.props.flash;s&&(s.success&&t.success(s.success),s.error&&t.error(s.error))},[r.props.flash]),o.jsxs(p,{breadcrumbs:f,className:"overflow-auto h-[calc(100svh-16px)]",children:[o.jsx(c,{position:"top-center",richColors:!0,closeButton:!0}),o.jsx(u,{page:r,catalog:!1})]})}export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as N,a as C,r as x,j as e,B as u,L as k,I as b,M as w,b as F,c as h,d as j,C as T,T as y,e as L,f as E,g as I,h as A}from"./app.js";import{A as B}from"./app-layout-
|
|
1
|
+
import{u as N,a as C,r as x,j as e,B as u,L as k,I as b,M as w,b as F,c as h,d as j,C as T,T as y,e as L,f as E,g as I,h as A}from"./app.js";import{A as B}from"./app-layout-86yxiZOy.js";import"./use-appearance-_EbbjHTh.js";const g=x.memo(({field:s,disabled:c,value:p,onCheckedChange:i,tooltip:t})=>{const m=x.useCallback(l=>{i(s.name,l)},[s.name,i]);return e.jsxs("div",{className:"flex gap-3 items-center",children:[e.jsx(T,{id:s.name,className:"cursor-pointer size-5",disabled:c,checked:p,onCheckedChange:m}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(h,{className:"cursor-pointer",htmlFor:s.name,children:s.label}),t&&e.jsx(y,{children:e.jsxs(L,{children:[e.jsx(E,{onClick:l=>l.preventDefault(),children:e.jsx(b,{iconNode:I,className:"text-primary w-5 h-5 cursor-pointer"})}),e.jsx(A,{align:"center",side:"top",children:e.jsx("p",{children:s.tooltip})})]})})]})]})});function D(){const s=N(),{fields:c,groupedTokens:p,users:i}=s.props,{data:t,setData:m,clearErrors:l,post:v,processing:o}=C({...Object.fromEntries(c.map(a=>[a.name,a.value])),...Object.fromEntries(i.map(a=>[a.name,a.value])),...Object.fromEntries(p.flatMap(a=>a.fields.map(n=>[n.name,n.value])))}),r=a=>s.props.fields.find(n=>n.name===a),d=x.useCallback((a,n)=>{l(),m(a,n)},[]),f=a=>{a.preventDefault(),v(s.props.postLink)};return e.jsxs("div",{className:"flex h-full flex-1 flex-col gap-4 rounded-xl p-4",children:[e.jsxs("div",{className:"w-full sticky z-[1001] py-4 pb-8 top-0 h-fit bg-background flex gap-4",children:[e.jsx(u,{className:"mb-3 w-fit",asChild:!0,children:e.jsxs(k,{href:s.props.btnBack.link,children:[e.jsx(b,{iconNode:w}),s.props.btnBack.title]})}),e.jsxs(u,{variant:"green",type:"submit",className:"w-fit",form:"addUserForm",disabled:o||s.props.view,children:[o&&e.jsx(F,{className:"h-4 w-4 animate-spin"}),s.props.btnSave.title]})]}),e.jsx("form",{id:"addUserForm",onSubmit:f,className:`${s.props.view?"cursor-not-allowed":""}`,children:e.jsxs("div",{className:"flex flex-col gap-6 max-w-[1144px]",children:[e.jsx("h2",{className:"font-bold text-xl",children:s.props.head}),e.jsxs("div",{className:"grid gap-4",children:[e.jsx(h,{htmlFor:r("name")?.name,children:r("name")?.label}),e.jsx(j,{id:r("name")?.name,type:"text",required:!0,tabIndex:1,autoComplete:r("name")?.name,value:t.name,onChange:a=>d("name",a.target.value),disabled:o||s.props.view,placeholder:r("name")?.label})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsx(h,{htmlFor:r("description")?.name,children:r("description")?.label}),e.jsx(j,{id:r("description")?.name,type:"text",required:!0,tabIndex:1,autoComplete:r("description")?.name,value:t.description,onChange:a=>d("description",a.target.value),disabled:o||s.props.view,placeholder:r("description")?.label})]}),s.props.users.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-bold text-xl",children:s.props.userHead}),s.props.users.map(a=>e.jsx(g,{field:a,disabled:o||s.props.view,value:t[a.name],onCheckedChange:d},a.name))]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 xl:grid-cols-4 gap-4",children:s.props.groupedTokens?.length>0&&s.props.groupedTokens.map(a=>e.jsxs("div",{className:"grid gap-4 content-start justify-between",children:[e.jsx("h2",{className:"font-bold text-xl mt-3",children:a.header}),a.fields.map(n=>e.jsx(g,{field:n,disabled:o||s.props.view,value:t[n.name],onCheckedChange:d,tooltip:!0},n.name))]},a.header))})]})})]})}const M=[];function G(){return e.jsx(B,{breadcrumbs:M,children:e.jsx(D,{})})}export{G as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as B,r as m,a as M,j as e,B as d,L as j,I as f,M as H,b as O,c as n,d as c,S as w,i as b,k as v,l as N,m as y,C as g,T as Y,e as $,f as _,g as G,h as J,n as Q,K as W,o as X,R as Z,p as C,t as h}from"./app.js";import{M as ee,A as se}from"./app-layout-
|
|
1
|
+
import{u as B,r as m,a as M,j as e,B as d,L as j,I as f,M as H,b as O,c as n,d as c,S as w,i as b,k as v,l as N,m as y,C as g,T as Y,e as $,f as _,g as G,h as J,n as Q,K as W,o as X,R as Z,p as C,t as h}from"./app.js";import{M as ee,A as se}from"./app-layout-86yxiZOy.js";import"./use-appearance-_EbbjHTh.js";function ae(){const l=B(),[k,P]=m.useState(),{fields:A,groups:F,auth:I}=l.props,[p,z]=m.useState(!1),[x,U]=m.useState(l.props.apiKey),[K,u]=m.useState(!1),{data:r,setData:S,errors:R,setError:T,clearErrors:L,post:E,processing:i}=M({...Object.fromEntries(A.map(s=>[s.name,s.value])),...Object.fromEntries(F.map(s=>[s.name,s.value]))});m.useEffect(()=>{(async()=>{const o=await C.get(`${window.routePrefix}/get-timezones`);P(o.data.timezones)})()},[]);const a=s=>l.props.fields.find(o=>o.name===s),D=s=>{if(s.preventDefault(),r.userPassword!==r.repeatUserPassword){T("repeatUserPassword",l.props.passwordError);return}E(l.props.postLink)},t=(s,o)=>{L(),S(s,o)},q=async()=>{try{const s=await C.post(`${window.routePrefix}/api/user-key/regenerate`);U(s.data.apiKey),h.success("User API key regenerated")}catch(s){console.error("Failed to regenerate user API key:",s),h.error("Failed to regenerate user API key")}u(!1)},V=async()=>{if(x)try{await navigator.clipboard.writeText(x),h.success("API key copied to clipboard")}catch{h.error("Failed to copy")}};return e.jsxs("div",{className:"flex h-full flex-1 flex-col gap-4 rounded-xl p-4",children:[e.jsxs("div",{className:"w-full sticky z-[1001] py-4 pb-8 top-0 h-fit bg-background flex gap-4",children:[e.jsx(d,{className:"mb-3 w-fit",asChild:!0,children:e.jsxs(j,{href:l.props.btnBack.link,children:[e.jsx(f,{iconNode:H}),l.props.btnBack.title]})}),e.jsxs(d,{variant:"green",type:"submit",className:"w-fit",form:"addUserForm",disabled:i||l.props.view,children:[i&&e.jsx(O,{className:"h-4 w-4 animate-spin"}),l.props.btnSave.title]})]}),e.jsx("form",{id:"addUserForm",onSubmit:D,className:l.props.view?"cursor-not-allowed":"",children:e.jsxs("div",{className:"flex flex-col gap-10 max-w-[1144px]",children:[e.jsx("h2",{className:"font-bold text-xl",children:l.props.head}),e.jsxs("div",{className:"flex-col xl:flex-row flex gap-16",children:[e.jsxs("div",{className:"basis-1/2 flex flex-col gap-6",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsx(n,{htmlFor:a("login")?.name,children:a("login")?.label}),e.jsx(c,{id:a("login")?.name,type:"text",required:!0,tabIndex:1,autoComplete:"username",value:r.login,onChange:s=>t("login",s.target.value),disabled:i||l.props.view,placeholder:a("login")?.label})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsx(n,{htmlFor:a("fullName")?.name,children:a("fullName")?.label}),e.jsx(c,{id:a("fullName")?.name,type:"text",required:!0,tabIndex:1,autoComplete:"additional-name",value:r.fullName,onChange:s=>t("fullName",s.target.value),disabled:i||l.props.view,placeholder:a("fullName")?.label})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsx(n,{htmlFor:a("email")?.name,children:a("email")?.label}),e.jsx(c,{id:a("email")?.name,type:"email",required:!0,tabIndex:1,autoComplete:"email",value:r.email,onChange:s=>t("email",s.target.value),disabled:i||l.props.view,placeholder:a("email")?.label})]})]}),e.jsxs("div",{className:"basis-1/2 flex flex-col gap-6",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsx(n,{htmlFor:a("timezone")?.name,children:a("timezone")?.label}),e.jsxs(w,{onValueChange:s=>t("timezone",s),defaultValue:r.timezone,disabled:i||l.props.view,children:[e.jsx(b,{className:"w-full cursor-pointer",children:e.jsx(v,{placeholder:a("timezone")?.name})}),e.jsx(N,{children:(k??[]).map(s=>e.jsx(y,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("div",{className:"flex flex-col md:flex-row justify-start gap-4 xl:justify-between items-start md:items-center",children:[a("date")&&e.jsxs("div",{className:"grid gap-4",children:[e.jsx(n,{htmlFor:a("date")?.name,children:a("date")?.label}),e.jsx(c,{id:a("date")?.name,type:"date",className:"max-w-fit",tabIndex:1,value:r.date,onChange:s=>t("date",s.target.value),disabled:i})]}),e.jsxs("div",{className:"flex gap-6",children:[a("isAdmin")&&e.jsxs("div",{className:"grid gap-4",children:[e.jsx(n,{className:"cursor-pointer",htmlFor:a("isAdmin")?.name,children:a("isAdmin")?.label}),e.jsx(g,{id:a("isAdmin")?.name,className:"cursor-pointer size-5",disabled:i||l.props.view,checked:r.isAdmin,onCheckedChange:s=>t("isAdmin",s)})]}),a("isConfirmed")&&e.jsxs("div",{className:"grid gap-4",children:[e.jsx(n,{className:"cursor-pointer",htmlFor:a("isConfirmed")?.name,children:a("isConfirmed")?.label}),e.jsx(g,{id:a("isConfirmed")?.name,className:"cursor-pointer size-5",disabled:i||l.props.view,checked:r.isConfirmed,onCheckedChange:s=>t("isConfirmed",s)})]})]})]}),a("locale")&&e.jsxs("div",{className:"grid gap-4",children:[e.jsx(n,{htmlFor:a("locale")?.name,children:a("locale")?.label}),e.jsxs(w,{onValueChange:s=>t("locale",s),defaultValue:r.locale,disabled:i||l.props.view,children:[e.jsx(b,{className:"w-full cursor-pointer",children:e.jsx(v,{placeholder:a("locale")?.name})}),e.jsx(N,{children:(l.props.locales??[]).map(s=>e.jsx(y,{value:s.value,children:s.label},s.value))})]})]})]})]}),I.user.isAdministrator&&e.jsx(d,{className:"w-fit",asChild:!0,variant:"outline",children:e.jsxs(j,{href:l.props.userPretend.postLink,method:"post",data:{login:r.login,pretend:!0},children:[e.jsx(ee,{name:"masks",className:"!text-[18px]"}),l.props.userPretend.label]})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("label",{className:"font-bold text-xl",children:a("userPassword")?.label}),e.jsx(Y,{children:e.jsxs($,{children:[e.jsx(_,{onClick:s=>s.preventDefault(),children:e.jsx(f,{iconNode:G,className:"text-primary w-5 h-5 cursor-pointer"})}),e.jsx(J,{align:"center",side:"top",children:e.jsx("p",{children:a("userPassword")?.tooltip})})]})})]}),e.jsxs("div",{className:"grid grid-col-1 lg:grid-cols-2 grid-rows-2 gap-x-16 gap-y-6",children:[e.jsxs("div",{className:"grid gap-4 col-span-1",children:[e.jsx(n,{htmlFor:a("userPassword")?.name,children:a("userPassword")?.label}),e.jsx(c,{id:a("userPassword")?.name,type:"password",required:!l.props.edit,tabIndex:1,autoComplete:"new-password",value:r.password,onChange:s=>t("userPassword",s.target.value),disabled:i||l.props.view,placeholder:a("userPassword")?.label})]}),e.jsxs("div",{className:"grid gap-4 col-span-1 col-start-1",children:[e.jsx(n,{htmlFor:a("repeatUserPassword")?.name,children:a("repeatUserPassword")?.label}),e.jsx(c,{id:a("repeatUserPassword")?.name,type:"password",required:!l.props.edit,tabIndex:1,autoComplete:"new-password",value:r.repeatUserPassword,onChange:s=>t("repeatUserPassword",s.target.value),disabled:i||l.props.view,placeholder:a("repeatUserPassword")?.label}),e.jsx(Q,{message:R.repeatUserPassword})]})]}),l.props.groups.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-bold text-xl",children:l.props.groupHead}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-5 xl:grid-cols-6 gap-4",children:l.props.groups.map(s=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(n,{className:"cursor-pointer",htmlFor:s.name,children:s.label}),e.jsx(g,{id:s.name,disabled:i||l.props.view,className:"cursor-pointer size-5",checked:r[s.name],onCheckedChange:o=>t(s.name,o)})]},s.name))})]}),l.props.edit&&!l.props.view&&e.jsxs(e.Fragment,{children:[e.jsxs("h2",{className:"font-bold text-xl flex items-center gap-2",children:[e.jsx(W,{className:"w-5 h-5"}),"User API Key (for feeds)"]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[x&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 text-sm bg-muted px-3 py-2 rounded font-mono truncate",children:p?x:"••••••••••••••••••••••••"}),e.jsx(d,{variant:"outline",size:"sm",type:"button",onClick:()=>z(!p),children:p?"Hide":"Show"}),p&&e.jsx(d,{variant:"outline",size:"sm",type:"button",onClick:V,children:e.jsx(X,{className:"w-4 h-4"})})]}),e.jsxs(d,{variant:"outline",size:"sm",type:"button",className:"w-fit",onClick:()=>u(!0),children:[e.jsx(Z,{className:"w-4 h-4 mr-2"}),"Regenerate User API Key"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Regenerating this key will invalidate all existing feed URLs. You will need to update the ",e.jsx("code",{className:"bg-muted px-1 text-xs",children:"?userKey="})," parameter in all feed links."]})]})]}),K&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"bg-background rounded-lg shadow-lg max-w-md w-full p-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Regenerate User API Key"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"This will invalidate all existing feed URLs. You will need to update them with the new userKey."}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(d,{variant:"outline",type:"button",onClick:()=>u(!1),children:"Cancel"}),e.jsx(d,{variant:"destructive",type:"button",onClick:q,children:"Regenerate"})]})]})})]})})]})}const le=[];function ne(){return e.jsx(se,{breadcrumbs:le,children:e.jsx(ae,{})})}export{ne as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as e,bl as Ne,aV as ve,u as F,bm as se,bn as we,w as J,bo as ye,bp as L,bq as ke,br as O,bs as H,bt as _,bu as Ce,bv as V,bw as K,bx as q,L as z,G as te,D as Se,aa as Ae,by as Me,bz as Ee,y as Pe,z as De,F as Te,bA as Ie,b1 as ze,ab as Fe,c as U,d as $e,b9 as ae,B as I,bB as Oe,aW as ne,b8 as _e,b as R,p as T,bC as Le,bD as Re,bE as Be,bF as Ge,bG as Je,bH as re,bI as Ue,bJ as He,bK as Ve,bL as Ke,bM as Q,bN as X,bO as W,bP as qe,bQ as Ye,bR as Ze,bS as Qe,bT as Xe,bU as We,bV as es,bW as ss,bX as ts,bY as as,bZ as ns,aC as rs,aD as ie,bd as le,b_ as is,b$ as ls,c0 as os,aA as oe,W as ce,Y as de,I as cs,c1 as ds,c2 as us,c3 as xs,v as hs,c4 as ps,Z as fs,e as ue,f as xe,E as ms,h as he,H as js,c5 as pe,c6 as Y,c7 as gs,c8 as bs,c9 as Ns,ca as vs,S as ws,i as ys,k as ks,l as Cs,m as Ss,cb as As}from"./app.js";import{u as Ms}from"./use-appearance-_EbbjHTh.js";const Es=r.memo(({children:a,variant:s="header"})=>{const[t,i]=r.useState(()=>typeof window<"u"?localStorage.getItem("sidebar")!=="false":!0),o=d=>{i(d),typeof window<"u"&&localStorage.setItem("sidebar",String(d))};return s==="header"?e.jsx("div",{className:"flex min-h-screen w-full flex-col",children:a}):e.jsx(Ne,{defaultOpen:t,open:t,onOpenChange:o,children:a})});function S({name:a,className:s,style:t}){return e.jsx("span",{className:ve("material-icons-outlined",s),style:t,children:a})}function Ps({items:a=[]}){const s=F(),t=n=>n.split("?")[0].replace(/\/$/,""),i=a.reduce((n,l)=>{const f=l.section||"Platform";return n[f]||(n[f]=[]),n[f].push(l),n},{}),o=Object.keys(i).sort((n,l)=>n==="Platform"?-1:l==="Platform"||n==="System"?1:l==="System"?-1:n.localeCompare(l)),[d,m]=r.useState(()=>{const n={};return a.forEach(l=>{const f=l.section||"Platform";n[f]=!1}),n}),[w,p]=r.useState(()=>{const n={};return a.forEach(l=>{const f=l.section||"Platform";n[f]=!1}),n}),u=n=>{const l=t(s.url),f=t(n);return l===f||l.startsWith(`${f}/`)},v=r.useRef(d),g=r.useRef(w);v.current=d,g.current=w;const k=({item:n})=>n.actions?.length>0?e.jsx(ke,{asChild:!0,defaultOpen:u(n.link),className:"group/collapsible",children:e.jsxs(O,{children:[e.jsx(H,{asChild:!0,children:e.jsxs(_,{tooltip:n.title,children:[e.jsx(S,{name:n.icon,className:"!text-[18px]"}),e.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:n.title}),e.jsx(J,{className:"ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"})]})}),e.jsx(Ce,{children:e.jsx(V,{children:n.actions?.map(l=>e.jsx(K,{children:e.jsx(q,{asChild:!0,isActive:u(l.link),children:l.type==="blank"?e.jsxs("a",{href:l.link,target:"_blank",rel:"noopener noreferrer",children:[l.icon&&e.jsx(S,{name:l.icon,className:"!text-[18px]"}),e.jsx("span",{children:l.title})]}):e.jsxs(z,{href:l.link,children:[l.icon&&e.jsx(S,{name:l.icon,className:"!text-[18px]"}),e.jsx("span",{children:l.title})]})})},l.id))})})]})},n.title):e.jsx(O,{children:e.jsx(_,{asChild:!0,isActive:u(n.link),tooltip:{children:n.title},children:n.type==="blank"?e.jsxs("a",{href:n.link,target:"_blank",rel:"noopener noreferrer",children:[n.icon&&e.jsx(S,{name:n.icon,className:"!text-[18px]"}),e.jsx("span",{children:n.title})]}):e.jsxs(z,{href:n.link,children:[n.icon&&e.jsx(S,{name:n.icon,className:"!text-[18px]"}),e.jsx("span",{children:n.title})]})})},n.title);return e.jsx(e.Fragment,{children:o.map(n=>{const l=i[n],f=l.some(b=>b.actions?.length>0?b.actions.some(c=>u(c.link)):u(b.link)),E=w[n]?d[n]:f;return e.jsxs(se,{className:"px-2 py-0",children:[e.jsx(we,{asChild:!0,className:"cursor-pointer",onClick:()=>{const A=!(g.current[n]?v.current[n]:f);p(P=>({...P,[n]:!0})),m(P=>({...P,[n]:A}))},children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(J,{className:`transform transition-transform duration-200 ${E?"rotate-90":""}`}),e.jsx("span",{children:n})]})}),E&&e.jsx(ye,{children:e.jsx(L,{children:l.map(b=>e.jsx(k,{item:b},b.id||b.title))})})]},n)})})}const Ds=5*1024*1024,Ts=(a,s)=>{const t=a?.response?.data;if(!t)return s;if(typeof t=="string")try{const i=JSON.parse(t);return i.error??i.message??s}catch{return t||s}if(typeof t=="object"){const i=t;return i.error??i.message??s}return s},fe=r.memo(({routePrefix:a,triggerLabel:s,placeholder:t,t:i,onClose:o})=>{const[d,m]=r.useState(""),[w,p]=r.useState(""),[u,v]=r.useState([]),[g,k]=r.useState({}),[n,l]=r.useState(!1),[f,E]=r.useState(!1),b=r.useRef(null),c=j=>{if(!j)return;const C={},D=[];Array.from(j).forEach(M=>{M.size>Ds?C[M.name]=i("File size exceeds the 5 MB limit"):D.push(M)}),v(M=>[...M,...D]),Object.keys(C).length&&k(M=>({...M,...C}))},A=j=>v(C=>C.filter((D,M)=>M!==j)),P=async j=>{if(j.preventDefault(),!d.trim()){k({title:i("Title is required")});return}l(!0),k({});const C=new FormData;C.append("title",d.trim()),C.append("description",w.trim()),u.forEach(D=>C.append("files",D));try{await T.post(`${a}/api/feedback`,C),E(!0)}catch(D){const M=Ts(D,i("Internal server error"));k({_global:M}),l(!1)}};return r.useEffect(()=>{if(!f)return;const j=setTimeout(o,2e3);return()=>clearTimeout(j)},[f,o]),f?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 py-24 text-center",children:[e.jsx(Ie,{size:48,className:"text-green-500 dark:text-green-400"}),e.jsx("p",{className:"text-base font-medium",children:i("Feedback sent successfully")})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ze,{className:"mb-4",children:[e.jsx(Fe,{children:s??i("Feedback")}),t&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t})]}),e.jsxs("form",{onSubmit:P,className:"space-y-5",noValidate:!0,children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(U,{htmlFor:"fb-title",children:i("Title")}),e.jsx($e,{id:"fb-title",value:d,onChange:j=>m(j.target.value),disabled:n,placeholder:i("Title"),className:g.title?"border-destructive":""}),g.title&&e.jsx("p",{className:"text-xs text-destructive",children:g.title})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(U,{htmlFor:"fb-desc",children:i("Description")}),e.jsx(ae,{id:"fb-desc",value:w,onChange:j=>p(j.target.value),disabled:n,placeholder:i("Description"),rows:5,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(U,{children:i("Attach files")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(I,{type:"button",variant:"outline",size:"sm",onClick:()=>b.current?.click(),disabled:n,children:[e.jsx(Oe,{size:14,className:"mr-1"}),i("Attach files")]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i("Max 5 MB per file")})]}),e.jsx("input",{ref:b,type:"file",multiple:!0,className:"hidden",onChange:j=>c(j.target.files),disabled:n}),u.length>0&&e.jsx("ul",{className:"mt-2 space-y-1",children:u.map((j,C)=>e.jsxs("li",{className:"flex items-center justify-between rounded-md border bg-muted/40 px-3 py-1.5 text-xs",children:[e.jsx("span",{className:"truncate max-w-[340px]",children:j.name}),e.jsx("button",{type:"button",onClick:()=>A(C),className:"ml-2 text-muted-foreground hover:text-destructive transition-colors","aria-label":i("Remove file"),disabled:n,children:e.jsx(ne,{size:13})})]},C))}),Object.entries(g).filter(([j])=>j!=="title"&&j!=="_global").map(([j,C])=>e.jsx("p",{className:"text-xs text-destructive",children:C},j))]}),g._global&&e.jsx("p",{className:"text-xs text-destructive",children:g._global}),e.jsx(_e,{children:e.jsx(I,{type:"submit",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(R,{size:14,className:"mr-1.5 animate-spin"}),i("Sending...")]}):i("Send")})})]})]})});fe.displayName="FeedbackForm";function Is(){const a=F(),{t:s}=te(),t=a.props.routePrefix??window.routePrefix??"",i=a.props.feedbackTriggerLabel??null,o=a.props.feedbackPlaceholder??null,[d,m]=r.useState(!1),[w,p]=r.useState(0),u=r.useCallback(()=>m(!1),[]),v=r.useCallback(g=>{m(g),g||p(k=>k+1)},[]);return e.jsxs(Se,{open:d,onOpenChange:v,children:[e.jsx(Ae,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 text-xs opacity-60 hover:opacity-100 transition-opacity cursor-pointer mt-1 mx-auto","aria-label":i??s("Send feedback"),children:[e.jsx(Me,{size:13}),i??s("Send feedback")]})}),Ee.createPortal(e.jsx(Pe,{}),document.body),e.jsx(De,{children:e.jsx(Te,{children:e.jsx(fe,{routePrefix:t,triggerLabel:i,placeholder:o,t:s,onClose:u},w)})})]})}function zs(){const a=F();return e.jsxs(Le,{collapsible:"icon",variant:"inset",children:[e.jsx(Re,{children:e.jsx(L,{children:e.jsxs(O,{children:[e.jsx(Be,{className:"p-0 shadow-none border-none bg-transparent hidden md:block",children:e.jsxs(Ge,{children:[e.jsx(Je,{asChild:!0,className:"text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground rounded-md",children:e.jsx(_,{asChild:!0,children:e.jsx(I,{variant:"ghost",asChild:!0,className:`w-full ${a.props.section?"":"pointer-events-none"}`,children:e.jsxs("div",{children:[e.jsx(S,{name:"rocket_launch",className:"!text-[18px]"}),e.jsx("span",{className:"group-data-[state=collapsed]:hidden",children:a.props.brand}),a.props.section&&e.jsx(re,{className:"ml-auto group-data-[state=collapsed]:hidden"})]})})})}),a.props.section&&e.jsx(Ue,{side:"right",className:"z-[1003]",children:a.props.section.map(s=>e.jsx("div",{children:s.subItems?e.jsxs(He,{children:[e.jsxs(Ve,{className:"flex gap-2 items-center cursor-pointer",children:[e.jsx(S,{name:s.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:s.title})]}),e.jsx(Ke,{children:s.subItems.map(t=>e.jsx(Q,{children:t.type==="blank"?e.jsxs("a",{href:t.link,target:"_blank",className:"flex gap-2 items-center",children:[t.icon&&e.jsx(S,{name:t.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:t.title})]},t.id):e.jsxs(z,{href:t.link,className:"flex gap-2 items-center",children:[t.icon&&e.jsx(S,{name:t.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:t.title})]},t.id)},t.id))})]}):e.jsx(Q,{children:s.type==="blank"?e.jsxs("a",{href:s.link,target:"_blank",className:"flex gap-2 items-center",children:[s.icon&&e.jsx(S,{name:s.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:s.title})]}):e.jsxs(z,{href:s.link,className:"flex gap-2 items-center",children:[s.icon&&e.jsx(S,{name:s.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:s.title})]})})},s.id))})]})}),e.jsx(se,{className:"px-2 py-0 block md:hidden",children:e.jsx(L,{children:e.jsx(X,{asChild:!0,className:"group/collapsible",children:e.jsxs(O,{children:[e.jsx(H,{asChild:!0,children:e.jsxs(_,{children:[e.jsx(S,{name:"rocket_launch",className:"!text-[18px]"}),e.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:a.props.brand}),a.props.section&&e.jsx(J,{className:"ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"})]})}),a.props.section&&e.jsx(W,{children:e.jsx(V,{children:a.props.section&&a.props.section.map(s=>s.subItems?e.jsx(L,{children:e.jsx(X,{asChild:!0,className:"group/collapsible-sub",children:e.jsxs(O,{children:[e.jsx(H,{asChild:!0,children:e.jsxs(_,{children:[e.jsx(S,{name:s.icon,className:"!text-[18px]"}),e.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:s.title}),e.jsx(J,{className:"ml-auto transition-transform duration-200 group-data-[state=open]/collapsible-sub:rotate-90"})]})}),e.jsx(W,{children:e.jsx(V,{children:s.subItems.map(t=>e.jsx(K,{children:e.jsx(q,{asChild:!0,children:t.type==="blank"?e.jsxs("a",{href:t.link,target:"_blank",className:"flex gap-2 items-center",children:[t.icon&&e.jsx(S,{name:t.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:t.title})]}):e.jsxs(z,{href:t.link,className:"flex gap-2 items-center",children:[t.icon&&e.jsx(S,{name:t.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:t.title})]})})},t.id))})})]})})},s.id):e.jsx(K,{children:e.jsx(q,{asChild:!0,children:s.type==="blank"?e.jsxs("a",{href:s.link,target:"_blank",className:"flex gap-2 items-center",children:[s.icon&&e.jsx(S,{name:s.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:s.title})]}):e.jsxs(z,{href:s.link,className:"flex gap-2 items-center",children:[s.icon&&e.jsx(S,{name:s.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:s.title})]})})},s.id))})})]})})})})]},a.props.brand)})}),e.jsx(qe,{children:e.jsx(Ps,{items:a.props.menu})}),e.jsx(Ye,{children:e.jsxs("div",{className:"flex flex-col items-center",children:[a.props.version&&(()=>{const s=a.props.version,t=s.text||"5.0.0",i=new Date("2026-07-28T04:06:49.597Z").toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),o=s.text?`v.${t}`:`v.${t} · ${i}`,d="text-center opacity-70 hover:opacity-100 transition-opacity text-xs";return s.link?e.jsx("a",{href:s.link,target:"_blank",rel:"noreferrer",title:s.hint??void 0,className:d,children:o}):e.jsx("span",{title:s.hint??void 0,className:d,children:o})})(),a.props.showFeedback&&e.jsx(Is,{})]})})]})}function Fs({breadcrumbs:a}){return e.jsx(e.Fragment,{children:a.length>0&&e.jsx(Ze,{children:e.jsx(Qe,{children:a.map((s,t)=>{const i=t===a.length-1;return e.jsxs(r.Fragment,{children:[e.jsx(Xe,{children:i?e.jsx(We,{children:s.title}):e.jsx(es,{asChild:!0,children:e.jsx(z,{href:s.href,children:s.title})})}),!i&&e.jsx(ss,{})]},t)})})})})}function $s(){return r.useCallback(s=>{const t=s.trim().split(" ");if(t.length===0)return"";if(t.length===1)return t[0].charAt(0).toUpperCase();const i=t[0].charAt(0),o=t[t.length-1].charAt(0);return`${i}${o}`.toUpperCase()},[])}function me({user:a,showEmail:s=!1}){const t=$s();return e.jsxs(e.Fragment,{children:[e.jsxs(ts,{className:"h-8 w-8 overflow-hidden rounded-full",children:[e.jsx(as,{src:a.avatar,alt:a.login}),e.jsx(ns,{className:"rounded-lg bg-neutral-200 text-black dark:bg-neutral-700 dark:text-white",children:t(a.login)})]}),e.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[e.jsx("span",{className:"truncate font-medium",children:a.login}),s&&e.jsx("span",{className:"text-muted-foreground truncate text-xs",children:a.email})]})]})}function Os(){return r.useCallback(()=>{document.body.style.removeProperty("pointer-events")},[])}function _s({user:a,logout:s,logoutBtn:t}){const i=Os();return e.jsxs(e.Fragment,{children:[e.jsx(rs,{className:"p-0 font-normal",children:e.jsx("div",{className:"flex items-center gap-2 px-1 py-1.5 text-left text-sm",children:e.jsx(me,{user:a,showEmail:!0})})}),e.jsx(ie,{}),e.jsx(le,{asChild:!0,children:e.jsxs(z,{className:"block w-full cursor-pointer",method:"get",href:s,as:"button",onClick:i,children:[e.jsx(is,{className:"mr-2"}),t]})})]})}function Ls(){const{auth:a,logout:s,logoutBtn:t}=F().props,{state:i}=ls(),o=os();return e.jsx(L,{children:e.jsx(O,{children:e.jsxs(oe,{children:[e.jsx(ce,{asChild:!0,children:e.jsxs(_,{size:"lg",className:"text-sidebar-accent-foreground data-[state=open]:bg-sidebar-accent group focus-visible:ring-0 cursor-pointer",children:[e.jsx(me,{user:a.user}),e.jsx(re,{className:"ml-auto size-4"})]})}),e.jsx(de,{className:"w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg z-[1002]",align:"end",side:o?"bottom":i==="collapsed"?"left":"bottom",children:e.jsx(_s,{user:a.user,logout:s,logoutBtn:t})})]})})})}function Rs(){const{appearance:a,updateAppearance:s}=Ms(),t={light:"dark",dark:"system",system:"light"},i={light:xs,dark:us,system:ds},o=()=>s(t[a]),d=i[a];return e.jsx(I,{variant:"ghost",size:"icon",onClick:o,className:"shrink-0",children:e.jsx(cs,{iconNode:d})})}const je=r.createContext(void 0),Bs=({children:a})=>{const[s,t]=r.useState([]),[i,o]=r.useState([]),[d,m]=r.useState([]),[w,p]=r.useState(!1),[u,v]=r.useState(null),[g,k]=r.useState(""),n=F(),{t:l}=te(),f=hs.useMemo(()=>({"Make read":l("Make read"),"View All":l("View All"),Search:l("Search"),"Make all read":l("Make all read"),Title:l("Title"),Message:l("Message"),Date:l("Date"),Diff:l("Diff"),"No notifications":l("No notifications"),"No notifications found":l("No notifications found"),"The end of the list has been reached":l("The end of the list has been reached")}),[l]),E=[...i,...d],b=async()=>{try{const x=await T.getJson(`${window.routePrefix}/notifications/api`,{params:{unreadOnly:!0,limit:4}});t(x.data)}catch(x){console.error("Error fetching bell notifications:",x)}},c=async()=>{await b()},A=async()=>{try{const x=await T.getJson(`${window.routePrefix}/notifications/api/get-classes`);x.data&&(v(x.data.activeServices),k(x.data.initTab))}catch(x){console.error("Error fetching tabs:",x)}},P=async(x,y)=>{try{if(!x){await j(y);return}const h=await T.postJson(`${window.routePrefix}/notifications/api/search`,{s:x,notificationClass:y});m(h.data)}catch(h){console.error("Error searching notifications:",h)}},j=async x=>{p(!0);try{const y=`${window.routePrefix}/notifications/api/${x}`,h=await T.getJson(y,{params:{limit:20,skip:0,unreadOnly:!1}});return o([]),m(h.data),h.data}catch(y){return console.error("Error fetching all notifications:",y),[]}finally{p(!1)}},C=async(x,y)=>{try{const h=`${window.routePrefix}/notifications/api/${x}`,N=await T.getJson(h,{params:{limit:20,skip:y,unreadOnly:!1}});return m(G=>[...G,...N.data]),N.data}catch(h){return console.error("Error paginating notifications:",h),[]}};r.useEffect(()=>{if(!n.props.notifications)return;b();const x=new EventSource(`${window.routePrefix}/notifications/api/stream`);return x.addEventListener("connected",y=>{A()}),x.addEventListener("notification",y=>{const h=JSON.parse(y.data);o(N=>[h,...N]),t(N=>[h,...N].slice(0,4))}),x.onerror=()=>{console.error("SSE connection error")},()=>x.close()},[]);const D=async(x,y)=>{try{await T.putJson(`${window.routePrefix}/notifications/api/${x}/${y}/read`,{}),o(h=>h.map(N=>N.id===y?{...N,read:!0}:N)),m(h=>h.map(N=>N.id===y?{...N,read:!0}:N)),t([])}catch(h){console.error("Error marking as read:",h)}},M=async()=>{try{await T.putJson(`${window.routePrefix}/notifications/api/read-all`,{}),o(x=>x.map(y=>({...y,read:!0}))),m(x=>x.map(y=>({...y,read:!0}))),await b()}catch(x){console.error("Error marking all as read:",x)}},B=s.filter(x=>!x.read).length;return e.jsx(je.Provider,{value:{bellNotifications:s,allNotifications:E,unreadCount:B,getTabs:A,tabs:u,initTab:g,search:P,markAsRead:D,markAllAsRead:M,messages:f,fetchAllNotifications:j,paginateNotifications:C,loading:w,refreshBellNotifications:c},children:a})},ge=()=>{const a=r.useContext(je);if(a===void 0)throw new Error("useNotifications must be used within a NotificationProvider");return a};function Gs(){const{bellNotifications:a,markAsRead:s,unreadCount:t,refreshBellNotifications:i,messages:o}=ge(),[d,m]=r.useState(!1),w=async(u,v)=>{m(!0);try{await s(u,v),await i()}catch(g){console.error("Error marking as read:",g)}finally{m(!1)}},p=u=>{const v=new Date,g=new Date(u),k=v.getTime()-g.getTime(),n=Math.floor(k/1e3),l=new Intl.RelativeTimeFormat("en",{numeric:"auto"});if(n<60)return l.format(-n,"second");const f=Math.floor(n/60);if(f<60)return l.format(-f,"minute");const E=Math.floor(f/60);if(E<24)return l.format(-E,"hour");const b=Math.floor(E/24);if(b<30)return l.format(-b,"day");const c=Math.floor(b/30);if(c<12)return l.format(-c,"month");const A=Math.floor(c/12);return l.format(-A,"year")};return e.jsxs(oe,{children:[e.jsx(ce,{asChild:!0,className:"cursor-pointer data-[state=open]:bg-sidebar-accent",children:e.jsxs(I,{variant:"ghost",className:"relative",children:[e.jsx(ps,{}),t>0&&e.jsx("div",{className:"absolute top-1.5 right-1.5 size-1.5 rounded-full bg-destructive"})]})}),e.jsxs(de,{className:"z-[1002] p-2",align:"end",onCloseAutoFocus:u=>u.preventDefault(),children:[e.jsx(fs,{className:`${d?"opacity-50 pointer-events-none":""}`,children:a.length===0?e.jsx("div",{className:"p-4 text-center text-muted-foreground",children:o["No notifications"]}):a.map(u=>e.jsxs("div",{children:[e.jsx(le,{asChild:!0,className:"cursor-pointer",onSelect:v=>{v.preventDefault(),js.visit(`${window.routePrefix}/notifications?type=${u.notificationClass}`)},children:e.jsxs("div",{className:"grid grid-cols-[32px_250px] grid-rows-[auto_1fr] items-start gap-x-4 gap-y-2",children:[u.icon?e.jsx(S,{name:u.icon.icon,style:{color:u.icon.iconColor},className:"!text-[32px]"}):e.jsx("div",{}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:u.title}),e.jsx("span",{className:"truncate",children:u.message})]}),e.jsxs("div",{className:"col-start-2 flex justify-between flex-nowrap items-center",children:[e.jsx("div",{className:"flex flex-nowrap gap-2 items-center",children:e.jsx("div",{children:p(u.createdAt)})}),e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"size-4",onClick:v=>{v.stopPropagation(),w(u.notificationClass,u.id)},children:e.jsx(ms,{className:"text-primary"})})}),e.jsx(he,{side:"left",className:"z-[1003]",children:e.jsx("p",{children:o["Make read"]})})]})]})]})}),e.jsx(ie,{})]},u.id))}),e.jsx(I,{variant:"secondary",asChild:!0,children:e.jsxs(z,{href:`${window.routePrefix}/notifications`,className:`w-full ${d?"opacity-50 pointer-events-none":""}`,children:[o["View All"],d&&e.jsx(R,{className:"h-4 w-4 animate-spin"})]})})]})]})}const Js=()=>{if(!(typeof window>"u"))return window.__adminizerAiAssistantState__??void 0},Us=a=>{typeof window>"u"||(window.__adminizerAiAssistantState__=a)},be=r.createContext(void 0),Hs=({children:a})=>{const t=F().props.aiAssistant,i=r.useMemo(()=>Js(),[]),[o,d]=r.useState(()=>i?.isOpen??!1),[m,w]=r.useState([]),[p,u]=r.useState(()=>i?.activeModel??t?.defaultModel??void 0),[v,g]=r.useState([]),[k,n]=r.useState(!1),[l,f]=r.useState(!1),[E,b]=r.useState(null),c=t?.enabled??!1,A=r.useCallback(async()=>{if(c)try{n(!0);const{data:h}=await T.getJson(`${window.routePrefix}/api/ai-assistant/models`);w(h),u(N=>N||(t?.defaultModel&&h.some($=>$.id===t.defaultModel)?t.defaultModel:h[0]?.id))}catch(h){console.error("Failed to load AI assistant models",h),b("Unable to load AI assistant models")}finally{n(!1)}},[t?.defaultModel,c]),P=r.useCallback(async h=>{if(!(!c||!h))try{n(!0);const{data:N}=await T.getJson(`${window.routePrefix}/api/ai-assistant/history/${h}`);g(N.history??[])}catch(N){console.error("Failed to load AI assistant history",N),b("Unable to load AI assistant history")}finally{n(!1)}},[c]);r.useEffect(()=>{if(!c){g([]);return}A()},[A,c]),r.useEffect(()=>{!c||!p||P(p)},[p,P,c]);const j=r.useCallback(h=>{u(h)},[]),C=r.useCallback(()=>d(!0),[]),D=r.useCallback(()=>d(!1),[]),M=r.useCallback(()=>d(h=>!h),[]),B=r.useCallback(async h=>{if(!c||!p)return;const N=h.trim();if(!N)return;const G={id:`tmp-${Date.now()}`,role:"user",content:N,timestamp:new Date().toISOString(),modelId:p};g($=>[...$,G]),f(!0),b(null);try{const{data:$}=await T.postJson(`${window.routePrefix}/api/ai-assistant/query`,{modelId:p,message:N});g($.history??[])}catch($){console.error("Failed to send AI assistant message",$),b("Unable to reach AI assistant"),await P(p)}finally{f(!1)}},[p,P,c]),x=r.useCallback(async()=>{p&&await P(p)},[p,P]);r.useEffect(()=>{c||d(!1)},[c]),r.useEffect(()=>{Us({isOpen:o,activeModel:p})},[p,o]);const y=r.useMemo(()=>({isEnabled:c,isOpen:o,openChat:C,closeChat:D,toggleChat:M,models:m,activeModel:p,setActiveModel:j,messages:v,loading:k,sending:l,error:E,sendMessage:B,refreshHistory:x}),[p,D,E,c,o,k,v,m,C,x,B,l,j,M]);return e.jsx(be.Provider,{value:y,children:a})},Z=()=>{const a=r.useContext(be);if(!a)throw new Error("useAiAssistant must be used within an AiAssistantProvider");return a};function Vs(){const{isEnabled:a,isOpen:s,toggleChat:t,models:i,sending:o,loading:d}=Z();if(!a)return null;const m=i.length>0;return e.jsx(e.Fragment,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(I,{variant:"ghost",className:Y("relative",{"text-primary":s}),onClick:t,"aria-expanded":s,"aria-haspopup":"true","aria-controls":"ai-assistant-panel",disabled:!m&&d,children:o?e.jsx(R,{className:"size-4 animate-spin"}):e.jsx(pe,{className:"size-4"})})}),e.jsx(he,{side:"bottom",className:"z-[1002]",children:e.jsx("span",{children:"AI assistant"})})]})})}function Ks({breadcrumbs:a=[]}){const{tabs:s}=ge(),t=F();return e.jsx("header",{className:"border-sidebar-border/50 flex h-16 shrink-0 items-center gap-2 border-b px-6 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12 md:px-4",children:e.jsxs("div",{className:"flex justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gs,{className:"-ml-1"}),e.jsx(Fs,{breadcrumbs:a})]}),e.jsxs("div",{className:"flex gap-4 items-center",children:[e.jsx(Vs,{}),t.props.history&&e.jsx(z,{href:`${window.routePrefix}/history/view-all`,children:e.jsx(I,{variant:"ghost",size:"icon",className:"shrink-0",children:e.jsx(bs,{})})}),e.jsx(Rs,{}),t.props.notifications&&(s===null?e.jsx("div",{className:"w-[40px] flex-none flex justify-center",children:e.jsx(R,{className:"size-4 animate-spin"})}):s.length?e.jsx(Gs,{}):null),e.jsx(Ls,{})]})]})})}const qs=r.memo(({children:a,breadcrumbs:s=[],className:t})=>{const i=F();return e.jsxs(Es,{variant:"sidebar",children:[e.jsx(Ns,{title:i.props.title}),e.jsx(zs,{}),e.jsxs(vs,{className:t,children:[e.jsx(Ks,{breadcrumbs:s}),e.jsx("div",{className:"relative flex min-h-0 flex-1 overflow-auto",children:e.jsx("div",{className:"flex h-full min-h-0 w-full flex-col",children:a})})]})]})});function Ys({width:a="min(25vw, 420px)"}){const{isEnabled:s,isOpen:t,closeChat:i,models:o,activeModel:d,setActiveModel:m,messages:w,loading:p,sending:u,error:v,sendMessage:g}=Z(),[k,n]=r.useState(""),l=r.useRef(null);r.useEffect(()=>{t||n("")},[t]),r.useEffect(()=>{l.current&&l.current.scrollIntoView({behavior:"smooth"})},[w]);const f=o.length>0,E=async c=>{c.preventDefault();const A=k.trim();A&&(await g(A),n(""))},b=c=>{if((c.ctrlKey||c.metaKey)&&c.key==="Enter"){c.preventDefault();const A=k.trim();A&&!u&&(g(A),n(""))}};return s?e.jsxs("aside",{id:"ai-assistant-panel","aria-label":"AI assistant chat","aria-hidden":!t,className:Y("bg-card text-card-foreground fixed bottom-0 right-0 top-0 z-[60] flex h-full flex-col border-l shadow-xl transition-all duration-300 ease-in-out","md:w-auto w-full",t?"translate-x-0 opacity-100":"translate-x-full opacity-0 pointer-events-none"),style:{width:"var(--ai-assistant-panel-actual-width, "+a+")"},children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pe,{className:"size-5 text-primary"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-semibold leading-tight",children:"AI assistant"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Chat with your selected model."})]})]}),e.jsx(I,{variant:"ghost",size:"icon",onClick:i,"aria-label":"Close AI assistant",children:e.jsx(ne,{className:"size-4"})})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-hidden px-4 py-4",children:[!f&&!p&&e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-md border border-dashed p-6 text-sm text-muted-foreground",children:"No AI models are available for your account."}),f&&e.jsxs(e.Fragment,{children:[e.jsxs(ws,{value:d,onValueChange:m,children:[e.jsx(ys,{className:"w-full",children:e.jsx(ks,{placeholder:"Select a model"})}),e.jsx(Cs,{className:"z-[70]",children:o.map(c=>e.jsx(Ss,{value:c.id,children:e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("span",{className:"font-medium",children:c.name}),c.description&&e.jsx("span",{className:"text-xs text-muted-foreground",children:c.description})]})},c.id))})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-3 overflow-hidden rounded-md border bg-background p-4",children:[e.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto pr-2","data-ai-assistant-messages":!0,children:[p&&e.jsx("div",{className:"flex justify-center py-6 text-sm text-muted-foreground",children:"Loading conversation..."}),!p&&w.length===0&&e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Start a conversation to see responses here."}),w.map(c=>e.jsxs("div",{className:Y("flex flex-col gap-1 rounded-md border p-3 text-sm shadow-xs",c.role==="assistant"?"border-primary/30 bg-primary/5":"border-border bg-background"),children:[e.jsx("span",{className:"font-semibold",children:c.role==="assistant"?"Assistant":"You"}),e.jsx("p",{className:"whitespace-pre-wrap leading-relaxed",children:c.content}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(c.timestamp).toLocaleTimeString()})]},c.id)),e.jsx("div",{ref:l})]}),e.jsxs("form",{className:"space-y-2",onSubmit:E,children:[e.jsx(ae,{placeholder:f?"Type your question... (Ctrl+Enter to send)":"No models available",value:k,onChange:c=>n(c.target.value),onKeyDown:b,disabled:!f||u,rows:3}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[v&&e.jsx("span",{className:"text-xs text-destructive",children:v}),e.jsx(I,{type:"submit",disabled:!f||u||!k.trim(),children:u?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(R,{className:"size-4 animate-spin"}),"Sending…"]}):"Send"})]})]})]})]})]})]}):null}const Zs="min(25vw, 420px)",ee="margin-right 300ms ease-in-out";function Qs({children:a,panelWidth:s=Zs}){const{isEnabled:t,isOpen:i}=Z();return r.useEffect(()=>{const o=document.getElementById("app");if(!o)return;const d=o.style.transition,m=d?.includes("margin-right");return m||(o.style.transition=d?`${d}, ${ee}`:ee),o.classList.add("ai-assistant-host"),o.style.setProperty("--ai-assistant-panel-width",s),()=>{o.classList.remove("ai-assistant-host"),o.style.removeProperty("--ai-assistant-panel-width"),o.style.removeProperty("--ai-assistant-panel-actual-width"),o.style.removeProperty("margin-right"),delete o.dataset.aiAssistantOpen,m||(o.style.transition=d)}},[s]),r.useEffect(()=>{const o=document.getElementById("app");if(!o)return;const d=window.innerWidth<768,m=d?"100vw":s;o.style.setProperty("--ai-assistant-panel-actual-width",m),t&&i?(o.style.marginRight=d?"0":s,o.dataset.aiAssistantOpen="true"):(o.style.removeProperty("margin-right"),o.dataset.aiAssistantOpen="false");const w=()=>{const p=window.innerWidth<768,u=p?"100vw":s;o.style.setProperty("--ai-assistant-panel-actual-width",u),t&&i&&(o.style.marginRight=p?"0":s)};return window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[t,i,s]),e.jsxs(e.Fragment,{children:[a,e.jsx(Ys,{width:s})]})}const et=r.memo(({children:a,className:s,breadcrumbs:t,...i})=>e.jsx(Bs,{children:e.jsx(Hs,{children:e.jsxs(As,{children:[e.jsx(qs,{breadcrumbs:t,className:s,...i,children:a}),e.jsx(Qs,{})]})})}));export{et as A,S as M,ge as u};
|
|
1
|
+
import{r,j as e,bl as Ne,aV as ve,u as F,bm as se,bn as we,w as J,bo as ye,bp as L,bq as ke,br as O,bs as H,bt as _,bu as Ce,bv as V,bw as K,bx as q,L as z,G as te,D as Se,aa as Ae,by as Me,bz as Ee,y as Pe,z as De,F as Te,bA as Ie,b1 as ze,ab as Fe,c as U,d as $e,b9 as ae,B as I,bB as Oe,aW as ne,b8 as _e,b as R,p as T,bC as Le,bD as Re,bE as Be,bF as Ge,bG as Je,bH as re,bI as Ue,bJ as He,bK as Ve,bL as Ke,bM as Q,bN as X,bO as W,bP as qe,bQ as Ye,bR as Ze,bS as Qe,bT as Xe,bU as We,bV as es,bW as ss,bX as ts,bY as as,bZ as ns,aC as rs,aD as ie,bd as le,b_ as is,b$ as ls,c0 as os,aA as oe,W as ce,Y as de,I as cs,c1 as ds,c2 as us,c3 as xs,v as hs,c4 as ps,Z as fs,e as ue,f as xe,E as ms,h as he,H as js,c5 as pe,c6 as Y,c7 as gs,c8 as bs,c9 as Ns,ca as vs,S as ws,i as ys,k as ks,l as Cs,m as Ss,cb as As}from"./app.js";import{u as Ms}from"./use-appearance-_EbbjHTh.js";const Es=r.memo(({children:a,variant:s="header"})=>{const[t,i]=r.useState(()=>typeof window<"u"?localStorage.getItem("sidebar")!=="false":!0),o=d=>{i(d),typeof window<"u"&&localStorage.setItem("sidebar",String(d))};return s==="header"?e.jsx("div",{className:"flex min-h-screen w-full flex-col",children:a}):e.jsx(Ne,{defaultOpen:t,open:t,onOpenChange:o,children:a})});function S({name:a,className:s,style:t}){return e.jsx("span",{className:ve("material-icons-outlined",s),style:t,children:a})}function Ps({items:a=[]}){const s=F(),t=n=>n.split("?")[0].replace(/\/$/,""),i=a.reduce((n,l)=>{const f=l.section||"Platform";return n[f]||(n[f]=[]),n[f].push(l),n},{}),o=Object.keys(i).sort((n,l)=>n==="Platform"?-1:l==="Platform"||n==="System"?1:l==="System"?-1:n.localeCompare(l)),[d,m]=r.useState(()=>{const n={};return a.forEach(l=>{const f=l.section||"Platform";n[f]=!1}),n}),[w,p]=r.useState(()=>{const n={};return a.forEach(l=>{const f=l.section||"Platform";n[f]=!1}),n}),u=n=>{const l=t(s.url),f=t(n);return l===f||l.startsWith(`${f}/`)},v=r.useRef(d),g=r.useRef(w);v.current=d,g.current=w;const k=({item:n})=>n.actions?.length>0?e.jsx(ke,{asChild:!0,defaultOpen:u(n.link),className:"group/collapsible",children:e.jsxs(O,{children:[e.jsx(H,{asChild:!0,children:e.jsxs(_,{tooltip:n.title,children:[e.jsx(S,{name:n.icon,className:"!text-[18px]"}),e.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:n.title}),e.jsx(J,{className:"ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"})]})}),e.jsx(Ce,{children:e.jsx(V,{children:n.actions?.map(l=>e.jsx(K,{children:e.jsx(q,{asChild:!0,isActive:u(l.link),children:l.type==="blank"?e.jsxs("a",{href:l.link,target:"_blank",rel:"noopener noreferrer",children:[l.icon&&e.jsx(S,{name:l.icon,className:"!text-[18px]"}),e.jsx("span",{children:l.title})]}):e.jsxs(z,{href:l.link,children:[l.icon&&e.jsx(S,{name:l.icon,className:"!text-[18px]"}),e.jsx("span",{children:l.title})]})})},l.id))})})]})},n.title):e.jsx(O,{children:e.jsx(_,{asChild:!0,isActive:u(n.link),tooltip:{children:n.title},children:n.type==="blank"?e.jsxs("a",{href:n.link,target:"_blank",rel:"noopener noreferrer",children:[n.icon&&e.jsx(S,{name:n.icon,className:"!text-[18px]"}),e.jsx("span",{children:n.title})]}):e.jsxs(z,{href:n.link,children:[n.icon&&e.jsx(S,{name:n.icon,className:"!text-[18px]"}),e.jsx("span",{children:n.title})]})})},n.title);return e.jsx(e.Fragment,{children:o.map(n=>{const l=i[n],f=l.some(b=>b.actions?.length>0?b.actions.some(c=>u(c.link)):u(b.link)),E=w[n]?d[n]:f;return e.jsxs(se,{className:"px-2 py-0",children:[e.jsx(we,{asChild:!0,className:"cursor-pointer",onClick:()=>{const A=!(g.current[n]?v.current[n]:f);p(P=>({...P,[n]:!0})),m(P=>({...P,[n]:A}))},children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(J,{className:`transform transition-transform duration-200 ${E?"rotate-90":""}`}),e.jsx("span",{children:n})]})}),E&&e.jsx(ye,{children:e.jsx(L,{children:l.map(b=>e.jsx(k,{item:b},b.id||b.title))})})]},n)})})}const Ds=5*1024*1024,Ts=(a,s)=>{const t=a?.response?.data;if(!t)return s;if(typeof t=="string")try{const i=JSON.parse(t);return i.error??i.message??s}catch{return t||s}if(typeof t=="object"){const i=t;return i.error??i.message??s}return s},fe=r.memo(({routePrefix:a,triggerLabel:s,placeholder:t,t:i,onClose:o})=>{const[d,m]=r.useState(""),[w,p]=r.useState(""),[u,v]=r.useState([]),[g,k]=r.useState({}),[n,l]=r.useState(!1),[f,E]=r.useState(!1),b=r.useRef(null),c=j=>{if(!j)return;const C={},D=[];Array.from(j).forEach(M=>{M.size>Ds?C[M.name]=i("File size exceeds the 5 MB limit"):D.push(M)}),v(M=>[...M,...D]),Object.keys(C).length&&k(M=>({...M,...C}))},A=j=>v(C=>C.filter((D,M)=>M!==j)),P=async j=>{if(j.preventDefault(),!d.trim()){k({title:i("Title is required")});return}l(!0),k({});const C=new FormData;C.append("title",d.trim()),C.append("description",w.trim()),u.forEach(D=>C.append("files",D));try{await T.post(`${a}/api/feedback`,C),E(!0)}catch(D){const M=Ts(D,i("Internal server error"));k({_global:M}),l(!1)}};return r.useEffect(()=>{if(!f)return;const j=setTimeout(o,2e3);return()=>clearTimeout(j)},[f,o]),f?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 py-24 text-center",children:[e.jsx(Ie,{size:48,className:"text-green-500 dark:text-green-400"}),e.jsx("p",{className:"text-base font-medium",children:i("Feedback sent successfully")})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ze,{className:"mb-4",children:[e.jsx(Fe,{children:s??i("Feedback")}),t&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t})]}),e.jsxs("form",{onSubmit:P,className:"space-y-5",noValidate:!0,children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(U,{htmlFor:"fb-title",children:i("Title")}),e.jsx($e,{id:"fb-title",value:d,onChange:j=>m(j.target.value),disabled:n,placeholder:i("Title"),className:g.title?"border-destructive":""}),g.title&&e.jsx("p",{className:"text-xs text-destructive",children:g.title})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(U,{htmlFor:"fb-desc",children:i("Description")}),e.jsx(ae,{id:"fb-desc",value:w,onChange:j=>p(j.target.value),disabled:n,placeholder:i("Description"),rows:5,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(U,{children:i("Attach files")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(I,{type:"button",variant:"outline",size:"sm",onClick:()=>b.current?.click(),disabled:n,children:[e.jsx(Oe,{size:14,className:"mr-1"}),i("Attach files")]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i("Max 5 MB per file")})]}),e.jsx("input",{ref:b,type:"file",multiple:!0,className:"hidden",onChange:j=>c(j.target.files),disabled:n}),u.length>0&&e.jsx("ul",{className:"mt-2 space-y-1",children:u.map((j,C)=>e.jsxs("li",{className:"flex items-center justify-between rounded-md border bg-muted/40 px-3 py-1.5 text-xs",children:[e.jsx("span",{className:"truncate max-w-[340px]",children:j.name}),e.jsx("button",{type:"button",onClick:()=>A(C),className:"ml-2 text-muted-foreground hover:text-destructive transition-colors","aria-label":i("Remove file"),disabled:n,children:e.jsx(ne,{size:13})})]},C))}),Object.entries(g).filter(([j])=>j!=="title"&&j!=="_global").map(([j,C])=>e.jsx("p",{className:"text-xs text-destructive",children:C},j))]}),g._global&&e.jsx("p",{className:"text-xs text-destructive",children:g._global}),e.jsx(_e,{children:e.jsx(I,{type:"submit",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(R,{size:14,className:"mr-1.5 animate-spin"}),i("Sending...")]}):i("Send")})})]})]})});fe.displayName="FeedbackForm";function Is(){const a=F(),{t:s}=te(),t=a.props.routePrefix??window.routePrefix??"",i=a.props.feedbackTriggerLabel??null,o=a.props.feedbackPlaceholder??null,[d,m]=r.useState(!1),[w,p]=r.useState(0),u=r.useCallback(()=>m(!1),[]),v=r.useCallback(g=>{m(g),g||p(k=>k+1)},[]);return e.jsxs(Se,{open:d,onOpenChange:v,children:[e.jsx(Ae,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 text-xs opacity-60 hover:opacity-100 transition-opacity cursor-pointer mt-1 mx-auto","aria-label":i??s("Send feedback"),children:[e.jsx(Me,{size:13}),i??s("Send feedback")]})}),Ee.createPortal(e.jsx(Pe,{}),document.body),e.jsx(De,{children:e.jsx(Te,{children:e.jsx(fe,{routePrefix:t,triggerLabel:i,placeholder:o,t:s,onClose:u},w)})})]})}function zs(){const a=F();return e.jsxs(Le,{collapsible:"icon",variant:"inset",children:[e.jsx(Re,{children:e.jsx(L,{children:e.jsxs(O,{children:[e.jsx(Be,{className:"p-0 shadow-none border-none bg-transparent hidden md:block",children:e.jsxs(Ge,{children:[e.jsx(Je,{asChild:!0,className:"text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground rounded-md",children:e.jsx(_,{asChild:!0,children:e.jsx(I,{variant:"ghost",asChild:!0,className:`w-full ${a.props.section?"":"pointer-events-none"}`,children:e.jsxs("div",{children:[e.jsx(S,{name:"rocket_launch",className:"!text-[18px]"}),e.jsx("span",{className:"group-data-[state=collapsed]:hidden",children:a.props.brand}),a.props.section&&e.jsx(re,{className:"ml-auto group-data-[state=collapsed]:hidden"})]})})})}),a.props.section&&e.jsx(Ue,{side:"right",className:"z-[1003]",children:a.props.section.map(s=>e.jsx("div",{children:s.subItems?e.jsxs(He,{children:[e.jsxs(Ve,{className:"flex gap-2 items-center cursor-pointer",children:[e.jsx(S,{name:s.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:s.title})]}),e.jsx(Ke,{children:s.subItems.map(t=>e.jsx(Q,{children:t.type==="blank"?e.jsxs("a",{href:t.link,target:"_blank",className:"flex gap-2 items-center",children:[t.icon&&e.jsx(S,{name:t.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:t.title})]},t.id):e.jsxs(z,{href:t.link,className:"flex gap-2 items-center",children:[t.icon&&e.jsx(S,{name:t.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:t.title})]},t.id)},t.id))})]}):e.jsx(Q,{children:s.type==="blank"?e.jsxs("a",{href:s.link,target:"_blank",className:"flex gap-2 items-center",children:[s.icon&&e.jsx(S,{name:s.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:s.title})]}):e.jsxs(z,{href:s.link,className:"flex gap-2 items-center",children:[s.icon&&e.jsx(S,{name:s.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:s.title})]})})},s.id))})]})}),e.jsx(se,{className:"px-2 py-0 block md:hidden",children:e.jsx(L,{children:e.jsx(X,{asChild:!0,className:"group/collapsible",children:e.jsxs(O,{children:[e.jsx(H,{asChild:!0,children:e.jsxs(_,{children:[e.jsx(S,{name:"rocket_launch",className:"!text-[18px]"}),e.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:a.props.brand}),a.props.section&&e.jsx(J,{className:"ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"})]})}),a.props.section&&e.jsx(W,{children:e.jsx(V,{children:a.props.section&&a.props.section.map(s=>s.subItems?e.jsx(L,{children:e.jsx(X,{asChild:!0,className:"group/collapsible-sub",children:e.jsxs(O,{children:[e.jsx(H,{asChild:!0,children:e.jsxs(_,{children:[e.jsx(S,{name:s.icon,className:"!text-[18px]"}),e.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:s.title}),e.jsx(J,{className:"ml-auto transition-transform duration-200 group-data-[state=open]/collapsible-sub:rotate-90"})]})}),e.jsx(W,{children:e.jsx(V,{children:s.subItems.map(t=>e.jsx(K,{children:e.jsx(q,{asChild:!0,children:t.type==="blank"?e.jsxs("a",{href:t.link,target:"_blank",className:"flex gap-2 items-center",children:[t.icon&&e.jsx(S,{name:t.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:t.title})]}):e.jsxs(z,{href:t.link,className:"flex gap-2 items-center",children:[t.icon&&e.jsx(S,{name:t.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:t.title})]})})},t.id))})})]})})},s.id):e.jsx(K,{children:e.jsx(q,{asChild:!0,children:s.type==="blank"?e.jsxs("a",{href:s.link,target:"_blank",className:"flex gap-2 items-center",children:[s.icon&&e.jsx(S,{name:s.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:s.title})]}):e.jsxs(z,{href:s.link,className:"flex gap-2 items-center",children:[s.icon&&e.jsx(S,{name:s.icon,className:"!text-[18px]"}),e.jsx("span",{className:"hover:underline",children:s.title})]})})},s.id))})})]})})})})]},a.props.brand)})}),e.jsx(qe,{children:e.jsx(Ps,{items:a.props.menu})}),e.jsx(Ye,{children:e.jsxs("div",{className:"flex flex-col items-center",children:[a.props.version&&(()=>{const s=a.props.version,t=s.text||"5.0.0",i=new Date("2026-07-28T16:22:19.996Z").toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),o=s.text?`v.${t}`:`v.${t} · ${i}`,d="text-center opacity-70 hover:opacity-100 transition-opacity text-xs";return s.link?e.jsx("a",{href:s.link,target:"_blank",rel:"noreferrer",title:s.hint??void 0,className:d,children:o}):e.jsx("span",{title:s.hint??void 0,className:d,children:o})})(),a.props.showFeedback&&e.jsx(Is,{})]})})]})}function Fs({breadcrumbs:a}){return e.jsx(e.Fragment,{children:a.length>0&&e.jsx(Ze,{children:e.jsx(Qe,{children:a.map((s,t)=>{const i=t===a.length-1;return e.jsxs(r.Fragment,{children:[e.jsx(Xe,{children:i?e.jsx(We,{children:s.title}):e.jsx(es,{asChild:!0,children:e.jsx(z,{href:s.href,children:s.title})})}),!i&&e.jsx(ss,{})]},t)})})})})}function $s(){return r.useCallback(s=>{const t=s.trim().split(" ");if(t.length===0)return"";if(t.length===1)return t[0].charAt(0).toUpperCase();const i=t[0].charAt(0),o=t[t.length-1].charAt(0);return`${i}${o}`.toUpperCase()},[])}function me({user:a,showEmail:s=!1}){const t=$s();return e.jsxs(e.Fragment,{children:[e.jsxs(ts,{className:"h-8 w-8 overflow-hidden rounded-full",children:[e.jsx(as,{src:a.avatar,alt:a.login}),e.jsx(ns,{className:"rounded-lg bg-neutral-200 text-black dark:bg-neutral-700 dark:text-white",children:t(a.login)})]}),e.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[e.jsx("span",{className:"truncate font-medium",children:a.login}),s&&e.jsx("span",{className:"text-muted-foreground truncate text-xs",children:a.email})]})]})}function Os(){return r.useCallback(()=>{document.body.style.removeProperty("pointer-events")},[])}function _s({user:a,logout:s,logoutBtn:t}){const i=Os();return e.jsxs(e.Fragment,{children:[e.jsx(rs,{className:"p-0 font-normal",children:e.jsx("div",{className:"flex items-center gap-2 px-1 py-1.5 text-left text-sm",children:e.jsx(me,{user:a,showEmail:!0})})}),e.jsx(ie,{}),e.jsx(le,{asChild:!0,children:e.jsxs(z,{className:"block w-full cursor-pointer",method:"get",href:s,as:"button",onClick:i,children:[e.jsx(is,{className:"mr-2"}),t]})})]})}function Ls(){const{auth:a,logout:s,logoutBtn:t}=F().props,{state:i}=ls(),o=os();return e.jsx(L,{children:e.jsx(O,{children:e.jsxs(oe,{children:[e.jsx(ce,{asChild:!0,children:e.jsxs(_,{size:"lg",className:"text-sidebar-accent-foreground data-[state=open]:bg-sidebar-accent group focus-visible:ring-0 cursor-pointer",children:[e.jsx(me,{user:a.user}),e.jsx(re,{className:"ml-auto size-4"})]})}),e.jsx(de,{className:"w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg z-[1002]",align:"end",side:o?"bottom":i==="collapsed"?"left":"bottom",children:e.jsx(_s,{user:a.user,logout:s,logoutBtn:t})})]})})})}function Rs(){const{appearance:a,updateAppearance:s}=Ms(),t={light:"dark",dark:"system",system:"light"},i={light:xs,dark:us,system:ds},o=()=>s(t[a]),d=i[a];return e.jsx(I,{variant:"ghost",size:"icon",onClick:o,className:"shrink-0",children:e.jsx(cs,{iconNode:d})})}const je=r.createContext(void 0),Bs=({children:a})=>{const[s,t]=r.useState([]),[i,o]=r.useState([]),[d,m]=r.useState([]),[w,p]=r.useState(!1),[u,v]=r.useState(null),[g,k]=r.useState(""),n=F(),{t:l}=te(),f=hs.useMemo(()=>({"Make read":l("Make read"),"View All":l("View All"),Search:l("Search"),"Make all read":l("Make all read"),Title:l("Title"),Message:l("Message"),Date:l("Date"),Diff:l("Diff"),"No notifications":l("No notifications"),"No notifications found":l("No notifications found"),"The end of the list has been reached":l("The end of the list has been reached")}),[l]),E=[...i,...d],b=async()=>{try{const x=await T.getJson(`${window.routePrefix}/notifications/api`,{params:{unreadOnly:!0,limit:4}});t(x.data)}catch(x){console.error("Error fetching bell notifications:",x)}},c=async()=>{await b()},A=async()=>{try{const x=await T.getJson(`${window.routePrefix}/notifications/api/get-classes`);x.data&&(v(x.data.activeServices),k(x.data.initTab))}catch(x){console.error("Error fetching tabs:",x)}},P=async(x,y)=>{try{if(!x){await j(y);return}const h=await T.postJson(`${window.routePrefix}/notifications/api/search`,{s:x,notificationClass:y});m(h.data)}catch(h){console.error("Error searching notifications:",h)}},j=async x=>{p(!0);try{const y=`${window.routePrefix}/notifications/api/${x}`,h=await T.getJson(y,{params:{limit:20,skip:0,unreadOnly:!1}});return o([]),m(h.data),h.data}catch(y){return console.error("Error fetching all notifications:",y),[]}finally{p(!1)}},C=async(x,y)=>{try{const h=`${window.routePrefix}/notifications/api/${x}`,N=await T.getJson(h,{params:{limit:20,skip:y,unreadOnly:!1}});return m(G=>[...G,...N.data]),N.data}catch(h){return console.error("Error paginating notifications:",h),[]}};r.useEffect(()=>{if(!n.props.notifications)return;b();const x=new EventSource(`${window.routePrefix}/notifications/api/stream`);return x.addEventListener("connected",y=>{A()}),x.addEventListener("notification",y=>{const h=JSON.parse(y.data);o(N=>[h,...N]),t(N=>[h,...N].slice(0,4))}),x.onerror=()=>{console.error("SSE connection error")},()=>x.close()},[]);const D=async(x,y)=>{try{await T.putJson(`${window.routePrefix}/notifications/api/${x}/${y}/read`,{}),o(h=>h.map(N=>N.id===y?{...N,read:!0}:N)),m(h=>h.map(N=>N.id===y?{...N,read:!0}:N)),t([])}catch(h){console.error("Error marking as read:",h)}},M=async()=>{try{await T.putJson(`${window.routePrefix}/notifications/api/read-all`,{}),o(x=>x.map(y=>({...y,read:!0}))),m(x=>x.map(y=>({...y,read:!0}))),await b()}catch(x){console.error("Error marking all as read:",x)}},B=s.filter(x=>!x.read).length;return e.jsx(je.Provider,{value:{bellNotifications:s,allNotifications:E,unreadCount:B,getTabs:A,tabs:u,initTab:g,search:P,markAsRead:D,markAllAsRead:M,messages:f,fetchAllNotifications:j,paginateNotifications:C,loading:w,refreshBellNotifications:c},children:a})},ge=()=>{const a=r.useContext(je);if(a===void 0)throw new Error("useNotifications must be used within a NotificationProvider");return a};function Gs(){const{bellNotifications:a,markAsRead:s,unreadCount:t,refreshBellNotifications:i,messages:o}=ge(),[d,m]=r.useState(!1),w=async(u,v)=>{m(!0);try{await s(u,v),await i()}catch(g){console.error("Error marking as read:",g)}finally{m(!1)}},p=u=>{const v=new Date,g=new Date(u),k=v.getTime()-g.getTime(),n=Math.floor(k/1e3),l=new Intl.RelativeTimeFormat("en",{numeric:"auto"});if(n<60)return l.format(-n,"second");const f=Math.floor(n/60);if(f<60)return l.format(-f,"minute");const E=Math.floor(f/60);if(E<24)return l.format(-E,"hour");const b=Math.floor(E/24);if(b<30)return l.format(-b,"day");const c=Math.floor(b/30);if(c<12)return l.format(-c,"month");const A=Math.floor(c/12);return l.format(-A,"year")};return e.jsxs(oe,{children:[e.jsx(ce,{asChild:!0,className:"cursor-pointer data-[state=open]:bg-sidebar-accent",children:e.jsxs(I,{variant:"ghost",className:"relative",children:[e.jsx(ps,{}),t>0&&e.jsx("div",{className:"absolute top-1.5 right-1.5 size-1.5 rounded-full bg-destructive"})]})}),e.jsxs(de,{className:"z-[1002] p-2",align:"end",onCloseAutoFocus:u=>u.preventDefault(),children:[e.jsx(fs,{className:`${d?"opacity-50 pointer-events-none":""}`,children:a.length===0?e.jsx("div",{className:"p-4 text-center text-muted-foreground",children:o["No notifications"]}):a.map(u=>e.jsxs("div",{children:[e.jsx(le,{asChild:!0,className:"cursor-pointer",onSelect:v=>{v.preventDefault(),js.visit(`${window.routePrefix}/notifications?type=${u.notificationClass}`)},children:e.jsxs("div",{className:"grid grid-cols-[32px_250px] grid-rows-[auto_1fr] items-start gap-x-4 gap-y-2",children:[u.icon?e.jsx(S,{name:u.icon.icon,style:{color:u.icon.iconColor},className:"!text-[32px]"}):e.jsx("div",{}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:u.title}),e.jsx("span",{className:"truncate",children:u.message})]}),e.jsxs("div",{className:"col-start-2 flex justify-between flex-nowrap items-center",children:[e.jsx("div",{className:"flex flex-nowrap gap-2 items-center",children:e.jsx("div",{children:p(u.createdAt)})}),e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"size-4",onClick:v=>{v.stopPropagation(),w(u.notificationClass,u.id)},children:e.jsx(ms,{className:"text-primary"})})}),e.jsx(he,{side:"left",className:"z-[1003]",children:e.jsx("p",{children:o["Make read"]})})]})]})]})}),e.jsx(ie,{})]},u.id))}),e.jsx(I,{variant:"secondary",asChild:!0,children:e.jsxs(z,{href:`${window.routePrefix}/notifications`,className:`w-full ${d?"opacity-50 pointer-events-none":""}`,children:[o["View All"],d&&e.jsx(R,{className:"h-4 w-4 animate-spin"})]})})]})]})}const Js=()=>{if(!(typeof window>"u"))return window.__adminizerAiAssistantState__??void 0},Us=a=>{typeof window>"u"||(window.__adminizerAiAssistantState__=a)},be=r.createContext(void 0),Hs=({children:a})=>{const t=F().props.aiAssistant,i=r.useMemo(()=>Js(),[]),[o,d]=r.useState(()=>i?.isOpen??!1),[m,w]=r.useState([]),[p,u]=r.useState(()=>i?.activeModel??t?.defaultModel??void 0),[v,g]=r.useState([]),[k,n]=r.useState(!1),[l,f]=r.useState(!1),[E,b]=r.useState(null),c=t?.enabled??!1,A=r.useCallback(async()=>{if(c)try{n(!0);const{data:h}=await T.getJson(`${window.routePrefix}/api/ai-assistant/models`);w(h),u(N=>N||(t?.defaultModel&&h.some($=>$.id===t.defaultModel)?t.defaultModel:h[0]?.id))}catch(h){console.error("Failed to load AI assistant models",h),b("Unable to load AI assistant models")}finally{n(!1)}},[t?.defaultModel,c]),P=r.useCallback(async h=>{if(!(!c||!h))try{n(!0);const{data:N}=await T.getJson(`${window.routePrefix}/api/ai-assistant/history/${h}`);g(N.history??[])}catch(N){console.error("Failed to load AI assistant history",N),b("Unable to load AI assistant history")}finally{n(!1)}},[c]);r.useEffect(()=>{if(!c){g([]);return}A()},[A,c]),r.useEffect(()=>{!c||!p||P(p)},[p,P,c]);const j=r.useCallback(h=>{u(h)},[]),C=r.useCallback(()=>d(!0),[]),D=r.useCallback(()=>d(!1),[]),M=r.useCallback(()=>d(h=>!h),[]),B=r.useCallback(async h=>{if(!c||!p)return;const N=h.trim();if(!N)return;const G={id:`tmp-${Date.now()}`,role:"user",content:N,timestamp:new Date().toISOString(),modelId:p};g($=>[...$,G]),f(!0),b(null);try{const{data:$}=await T.postJson(`${window.routePrefix}/api/ai-assistant/query`,{modelId:p,message:N});g($.history??[])}catch($){console.error("Failed to send AI assistant message",$),b("Unable to reach AI assistant"),await P(p)}finally{f(!1)}},[p,P,c]),x=r.useCallback(async()=>{p&&await P(p)},[p,P]);r.useEffect(()=>{c||d(!1)},[c]),r.useEffect(()=>{Us({isOpen:o,activeModel:p})},[p,o]);const y=r.useMemo(()=>({isEnabled:c,isOpen:o,openChat:C,closeChat:D,toggleChat:M,models:m,activeModel:p,setActiveModel:j,messages:v,loading:k,sending:l,error:E,sendMessage:B,refreshHistory:x}),[p,D,E,c,o,k,v,m,C,x,B,l,j,M]);return e.jsx(be.Provider,{value:y,children:a})},Z=()=>{const a=r.useContext(be);if(!a)throw new Error("useAiAssistant must be used within an AiAssistantProvider");return a};function Vs(){const{isEnabled:a,isOpen:s,toggleChat:t,models:i,sending:o,loading:d}=Z();if(!a)return null;const m=i.length>0;return e.jsx(e.Fragment,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(I,{variant:"ghost",className:Y("relative",{"text-primary":s}),onClick:t,"aria-expanded":s,"aria-haspopup":"true","aria-controls":"ai-assistant-panel",disabled:!m&&d,children:o?e.jsx(R,{className:"size-4 animate-spin"}):e.jsx(pe,{className:"size-4"})})}),e.jsx(he,{side:"bottom",className:"z-[1002]",children:e.jsx("span",{children:"AI assistant"})})]})})}function Ks({breadcrumbs:a=[]}){const{tabs:s}=ge(),t=F();return e.jsx("header",{className:"border-sidebar-border/50 flex h-16 shrink-0 items-center gap-2 border-b px-6 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12 md:px-4",children:e.jsxs("div",{className:"flex justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gs,{className:"-ml-1"}),e.jsx(Fs,{breadcrumbs:a})]}),e.jsxs("div",{className:"flex gap-4 items-center",children:[e.jsx(Vs,{}),t.props.history&&e.jsx(z,{href:`${window.routePrefix}/history/view-all`,children:e.jsx(I,{variant:"ghost",size:"icon",className:"shrink-0",children:e.jsx(bs,{})})}),e.jsx(Rs,{}),t.props.notifications&&(s===null?e.jsx("div",{className:"w-[40px] flex-none flex justify-center",children:e.jsx(R,{className:"size-4 animate-spin"})}):s.length?e.jsx(Gs,{}):null),e.jsx(Ls,{})]})]})})}const qs=r.memo(({children:a,breadcrumbs:s=[],className:t})=>{const i=F();return e.jsxs(Es,{variant:"sidebar",children:[e.jsx(Ns,{title:i.props.title}),e.jsx(zs,{}),e.jsxs(vs,{className:t,children:[e.jsx(Ks,{breadcrumbs:s}),e.jsx("div",{className:"relative flex min-h-0 flex-1 overflow-auto",children:e.jsx("div",{className:"flex h-full min-h-0 w-full flex-col",children:a})})]})]})});function Ys({width:a="min(25vw, 420px)"}){const{isEnabled:s,isOpen:t,closeChat:i,models:o,activeModel:d,setActiveModel:m,messages:w,loading:p,sending:u,error:v,sendMessage:g}=Z(),[k,n]=r.useState(""),l=r.useRef(null);r.useEffect(()=>{t||n("")},[t]),r.useEffect(()=>{l.current&&l.current.scrollIntoView({behavior:"smooth"})},[w]);const f=o.length>0,E=async c=>{c.preventDefault();const A=k.trim();A&&(await g(A),n(""))},b=c=>{if((c.ctrlKey||c.metaKey)&&c.key==="Enter"){c.preventDefault();const A=k.trim();A&&!u&&(g(A),n(""))}};return s?e.jsxs("aside",{id:"ai-assistant-panel","aria-label":"AI assistant chat","aria-hidden":!t,className:Y("bg-card text-card-foreground fixed bottom-0 right-0 top-0 z-[60] flex h-full flex-col border-l shadow-xl transition-all duration-300 ease-in-out","md:w-auto w-full",t?"translate-x-0 opacity-100":"translate-x-full opacity-0 pointer-events-none"),style:{width:"var(--ai-assistant-panel-actual-width, "+a+")"},children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pe,{className:"size-5 text-primary"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-semibold leading-tight",children:"AI assistant"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Chat with your selected model."})]})]}),e.jsx(I,{variant:"ghost",size:"icon",onClick:i,"aria-label":"Close AI assistant",children:e.jsx(ne,{className:"size-4"})})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-hidden px-4 py-4",children:[!f&&!p&&e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-md border border-dashed p-6 text-sm text-muted-foreground",children:"No AI models are available for your account."}),f&&e.jsxs(e.Fragment,{children:[e.jsxs(ws,{value:d,onValueChange:m,children:[e.jsx(ys,{className:"w-full",children:e.jsx(ks,{placeholder:"Select a model"})}),e.jsx(Cs,{className:"z-[70]",children:o.map(c=>e.jsx(Ss,{value:c.id,children:e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("span",{className:"font-medium",children:c.name}),c.description&&e.jsx("span",{className:"text-xs text-muted-foreground",children:c.description})]})},c.id))})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-3 overflow-hidden rounded-md border bg-background p-4",children:[e.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto pr-2","data-ai-assistant-messages":!0,children:[p&&e.jsx("div",{className:"flex justify-center py-6 text-sm text-muted-foreground",children:"Loading conversation..."}),!p&&w.length===0&&e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Start a conversation to see responses here."}),w.map(c=>e.jsxs("div",{className:Y("flex flex-col gap-1 rounded-md border p-3 text-sm shadow-xs",c.role==="assistant"?"border-primary/30 bg-primary/5":"border-border bg-background"),children:[e.jsx("span",{className:"font-semibold",children:c.role==="assistant"?"Assistant":"You"}),e.jsx("p",{className:"whitespace-pre-wrap leading-relaxed",children:c.content}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(c.timestamp).toLocaleTimeString()})]},c.id)),e.jsx("div",{ref:l})]}),e.jsxs("form",{className:"space-y-2",onSubmit:E,children:[e.jsx(ae,{placeholder:f?"Type your question... (Ctrl+Enter to send)":"No models available",value:k,onChange:c=>n(c.target.value),onKeyDown:b,disabled:!f||u,rows:3}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[v&&e.jsx("span",{className:"text-xs text-destructive",children:v}),e.jsx(I,{type:"submit",disabled:!f||u||!k.trim(),children:u?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(R,{className:"size-4 animate-spin"}),"Sending…"]}):"Send"})]})]})]})]})]})]}):null}const Zs="min(25vw, 420px)",ee="margin-right 300ms ease-in-out";function Qs({children:a,panelWidth:s=Zs}){const{isEnabled:t,isOpen:i}=Z();return r.useEffect(()=>{const o=document.getElementById("app");if(!o)return;const d=o.style.transition,m=d?.includes("margin-right");return m||(o.style.transition=d?`${d}, ${ee}`:ee),o.classList.add("ai-assistant-host"),o.style.setProperty("--ai-assistant-panel-width",s),()=>{o.classList.remove("ai-assistant-host"),o.style.removeProperty("--ai-assistant-panel-width"),o.style.removeProperty("--ai-assistant-panel-actual-width"),o.style.removeProperty("margin-right"),delete o.dataset.aiAssistantOpen,m||(o.style.transition=d)}},[s]),r.useEffect(()=>{const o=document.getElementById("app");if(!o)return;const d=window.innerWidth<768,m=d?"100vw":s;o.style.setProperty("--ai-assistant-panel-actual-width",m),t&&i?(o.style.marginRight=d?"0":s,o.dataset.aiAssistantOpen="true"):(o.style.removeProperty("margin-right"),o.dataset.aiAssistantOpen="false");const w=()=>{const p=window.innerWidth<768,u=p?"100vw":s;o.style.setProperty("--ai-assistant-panel-actual-width",u),t&&i&&(o.style.marginRight=p?"0":s)};return window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[t,i,s]),e.jsxs(e.Fragment,{children:[a,e.jsx(Ys,{width:s})]})}const et=r.memo(({children:a,className:s,breadcrumbs:t,...i})=>e.jsx(Bs,{children:e.jsx(Hs,{children:e.jsxs(As,{children:[e.jsx(qs,{breadcrumbs:t,className:s,...i,children:a}),e.jsx(Qs,{})]})})}));export{et as A,S as M,ge as u};
|