forlogic-core 1.14.9 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/README.md +111 -110
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/vite/index.esm.js +10 -3
- package/dist/vite/index.js +10 -3
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("react"),a=require("@radix-ui/react-slot"),s=require("class-variance-authority"),r=require("clsx"),n=require("tailwind-merge"),i=require("date-fns"),o=require("i18next"),l=require("sonner"),d=require("lucide-react"),c=require("@radix-ui/react-label"),u=require("@radix-ui/react-dialog"),m=require("@radix-ui/react-separator"),h=require("react-hook-form"),p=require("@radix-ui/react-select"),f=require("@radix-ui/react-checkbox"),x=require("@radix-ui/react-dropdown-menu"),g=require("@radix-ui/react-tooltip"),b=require("@radix-ui/react-popover"),v=require("react-i18next"),w=require("@supabase/supabase-js"),N=require("@tanstack/react-query"),y=require("react-router-dom"),j=require("@radix-ui/react-context-menu"),C=require("@radix-ui/react-scroll-area"),k=require("@radix-ui/react-switch"),S=require("@radix-ui/react-collapsible"),T=require("@radix-ui/react-accordion"),P=require("@radix-ui/react-alert-dialog"),M=require("@radix-ui/react-avatar"),I=require("react-day-picker"),A=require("vaul"),E=require("@radix-ui/react-hover-card"),D=require("@radix-ui/react-navigation-menu"),_=require("@radix-ui/react-progress"),R=require("@radix-ui/react-radio-group"),z=require("react-resizable-panels"),F=require("@radix-ui/react-slider"),L=require("@radix-ui/react-tabs"),O=require("@radix-ui/react-toggle"),U=require("@radix-ui/react-toggle-group"),$=require("@radix-ui/react-menubar"),q=require("recharts"),H=require("@tiptap/react"),B=require("@tiptap/starter-kit"),W=require("@tiptap/extension-underline"),V=require("@tiptap/extension-link"),G=require("@tiptap/extension-text-style"),Y=require("@tiptap/extension-color"),Q=require("@tiptap/extension-highlight"),X=require("zod"),K=require("@hookform/resolvers");function Z(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(a){if("default"!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,Object.freeze(t)}var J=Z(t),ee=Z(c),te=Z(u),ae=Z(m),se=Z(p),re=Z(f),ne=Z(x),ie=Z(g),oe=Z(b),le=Z(j),de=Z(C),ce=Z(k),ue=Z(S),me=Z(T),he=Z(P),pe=Z(M),fe=Z(E),xe=Z(D),ge=Z(_),be=Z(R),ve=Z(z),we=Z(F),Ne=Z(L),ye=Z(O),je=Z(U),Ce=Z($),ke=Z(q);function Se(e,t){t?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{l.toast.info(o.t("link_copied"))})}function Te(...e){return n.twMerge(r.clsx(e))}const Pe=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Pe);if("object"==typeof e&&e.constructor===Object){const t={};for(const[a,s]of Object.entries(e))t[a]=Pe(s);return t}return e},Me=s.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{primary:"bg-primary text-primary-foreground hover:bg-primary-hover shadow-sm hover:shadow-md active:scale-[0.98]",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary-hover border border-input shadow-sm",tertiary:"bg-background text-foreground hover:bg-accent hover:text-accent-foreground border border-border",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",ghost:"hover:bg-accent hover:text-accent-foreground",subtle:"text-muted-foreground hover:text-foreground hover:bg-accent/50",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm hover:shadow-md",danger:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm hover:shadow-md",link:"text-primary underline-offset-4 hover:underline",icon:"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2",loading:"bg-primary/50 text-primary-foreground cursor-wait",default:"bg-primary text-primary-foreground hover:bg-primary/90",action:"bg-primary/10 text-primary hover:bg-primary/20 border border-primary/30","icon-only":"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2","external-link":"bg-transparent text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors","action-primary":"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm","action-secondary":"bg-secondary text-secondary-foreground hover:bg-secondary/80 border border-input"},size:{sm:"h-8 px-3 text-xs rounded",md:"h-10 px-4 py-2 text-sm rounded-md",lg:"h-12 px-8 text-base rounded-lg",xl:"h-14 px-10 text-lg rounded-lg",icon:"h-10 w-10","icon-sm":"h-8 w-8","icon-xs":"h-6 w-6",default:"h-10 px-4 py-2"}},defaultVariants:{variant:"primary",size:"md"}}),Ie=J.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...i},o)=>{const l=n?a.Slot:"button";return e.jsx(l,{className:Te(Me({variant:s,size:r,className:t})),ref:o,...i})});Ie.displayName="Button";const Ae=t.forwardRef(({className:t,children:a,...s},r)=>e.jsx(Ie,{ref:r,variant:"action",size:"sm",className:Te("h-7 px-2 text-xs",t),...s,children:a||e.jsx(d.EllipsisVertical,{size:12})}));Ae.displayName="ActionButton";const Ee=J.forwardRef(({className:t,type:a,...s},r)=>e.jsx("input",{type:a,className:Te("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:r,...s}));Ee.displayName="Input";const De=s.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),_e=J.forwardRef(({className:t,...a},s)=>e.jsx(ee.Root,{ref:s,className:Te(De(),t),...a}));_e.displayName=ee.Root.displayName;const Re=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("rounded-lg border bg-card text-card-foreground shadow-sm",t),...a}));Re.displayName="Card";const ze=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("flex flex-col space-y-1.5 p-6",t),...a}));ze.displayName="CardHeader";const Fe=J.forwardRef(({className:t,...a},s)=>e.jsx("h3",{ref:s,className:Te("text-2xl font-semibold leading-none tracking-tight",t),...a}));Fe.displayName="CardTitle";const Le=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Te("text-sm text-muted-foreground",t),...a}));Le.displayName="CardDescription";const Oe=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("p-6 pt-0",t),...a}));Oe.displayName="CardContent";const Ue=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("flex items-center p-6 pt-0",t),...a}));Ue.displayName="CardFooter";const $e=J.forwardRef(({className:t,orientation:a="horizontal",decorative:s=!0,...r},n)=>e.jsx(ae.Root,{ref:n,decorative:s,orientation:a,className:Te("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",t),...r}));$e.displayName=ae.Root.displayName;const qe=te.Root,He=te.Trigger,Be=te.Portal,We=te.Close,Ve=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Overlay,{ref:s,className:Te("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a}));Ve.displayName=te.Overlay.displayName;const Ge={sm:{width:"30vw",minWidth:"320px",maxWidth:"480px",maxHeight:"320px"},md:{width:"50vw",minWidth:"480px",maxWidth:"720px",maxHeight:"70vh"},lg:{width:"85vw",height:"85vh",minWidth:"720px",maxWidth:"1440px",minHeight:"480px",maxHeight:"900px"}},Ye=J.forwardRef(({className:t,children:a,size:s="md",customWidth:r,customMinWidth:n,customMaxWidth:i,customHeight:o,customMinHeight:l,customMaxHeight:c,style:u,...m},h)=>{const p=Ge[s],f={width:r??p.width,minWidth:n??p.minWidth,maxWidth:i??p.maxWidth,height:o??p.height,minHeight:l??p.minHeight,maxHeight:c??p.maxHeight,...u};return e.jsxs(Be,{children:[e.jsx(Ve,{}),e.jsxs(te.Content,{ref:h,className:Te("fixed left-[50%] top-[50%] z-50 flex flex-col translate-x-[-50%] translate-y-[-50%] border bg-background p-6 shadow-lg duration-200 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 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",t),style:f,...m,children:[a,e.jsxs(te.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-0 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(d.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Ye.displayName=te.Content.displayName;const Qe=({className:t,showSeparator:a=!1,children:s,...r})=>e.jsxs("div",{className:Te("flex flex-col flex-shrink-0",t),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),a&&e.jsx($e,{className:"mt-2"})]});Qe.displayName="DialogHeader";const Xe=({className:t,...a})=>e.jsx("div",{className:Te("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",t),...a});Xe.displayName="DialogBody";const Ke=({className:t,children:a,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx($e,{className:"mb-4"}),e.jsx("div",{className:Te("flex flex-row justify-end gap-2",t),...s,children:a})]});Ke.displayName="DialogFooter";const Ze=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Title,{ref:s,className:Te("text-lg font-semibold leading-none tracking-tight",t),...a}));Ze.displayName=te.Title.displayName;const Je=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Description,{ref:s,className:Te("text-sm text-muted-foreground",t),...a}));Je.displayName=te.Description.displayName;const et=h.FormProvider,tt=J.createContext({}),at=()=>{const e=J.useContext(tt),t=J.useContext(st),{getFieldState:a,formState:s}=h.useFormContext(),r=a(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=t;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...r}},st=J.createContext({}),rt=J.forwardRef(({className:t,...a},s)=>{const r=J.useId();return e.jsx(st.Provider,{value:{id:r},children:e.jsx("div",{ref:s,className:Te("space-y-2",t),...a})})});rt.displayName="FormItem";const nt=J.forwardRef(({className:t,...a},s)=>{const{error:r,formItemId:n}=at();return e.jsx(_e,{ref:s,className:Te(r&&"text-destructive",t),htmlFor:n,...a})});nt.displayName="FormLabel";const it=J.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:i,formMessageId:o}=at();return e.jsx(a.Slot,{ref:s,id:n,"aria-describedby":r?`${i} ${o}`:`${i}`,"aria-invalid":!!r,...t})});it.displayName="FormControl";const ot=J.forwardRef(({className:t,...a},s)=>{const{formDescriptionId:r}=at();return e.jsx("p",{ref:s,id:r,className:Te("text-sm text-muted-foreground",t),...a})});ot.displayName="FormDescription";const lt=J.forwardRef(({className:t,children:a,...s},r)=>{const{error:n,formMessageId:i}=at(),o=n?String(n?.message):a;return o?e.jsx("p",{ref:r,id:i,className:Te("text-sm font-medium text-destructive",t),...s,children:o}):null});lt.displayName="FormMessage";const dt=se.Root,ct=se.Group,ut=se.Value,mt=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(se.Trigger,{ref:r,className:Te("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...s,children:[a,e.jsx(se.Icon,{asChild:!0,children:e.jsx(d.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));mt.displayName=se.Trigger.displayName;const ht=J.forwardRef(({className:t,...a},s)=>e.jsx(se.ScrollUpButton,{ref:s,className:Te("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(d.ChevronUp,{className:"h-4 w-4"})}));ht.displayName=se.ScrollUpButton.displayName;const pt=J.forwardRef(({className:t,...a},s)=>e.jsx(se.ScrollDownButton,{ref:s,className:Te("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(d.ChevronDown,{className:"h-4 w-4"})}));pt.displayName=se.ScrollDownButton.displayName;const ft=J.forwardRef(({className:t,children:a,position:s="popper",container:r,collisionBoundary:n,...i},o)=>e.jsx(se.Portal,{container:r,children:e.jsxs(se.Content,{ref:o,className:Te("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,collisionBoundary:n,...i,children:[e.jsx(ht,{}),e.jsx(se.Viewport,{className:Te("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),e.jsx(pt,{})]})}));ft.displayName=se.Content.displayName;const xt=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Label,{ref:s,className:Te("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...a}));xt.displayName=se.Label.displayName;const gt=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(se.Item,{ref:r,className:Te("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(se.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),e.jsx(se.ItemText,{children:a})]}));gt.displayName=se.Item.displayName;const bt=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Separator,{ref:s,className:Te("-mx-1 my-1 h-px bg-muted",t),...a}));bt.displayName=se.Separator.displayName;const vt=J.forwardRef(({className:t,...a},s)=>e.jsx(re.Root,{ref:s,className:Te("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...a,children:e.jsx(re.Indicator,{className:Te("flex items-center justify-center text-current"),children:e.jsx(d.Check,{className:"h-4 w-4"})})}));vt.displayName=re.Root.displayName;const wt=J.forwardRef(({className:t,...a},s)=>e.jsx("textarea",{className:Te("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",t),ref:s,...a}));wt.displayName="Textarea";const Nt=s.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",danger:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-success text-success-foreground hover:bg-success/90",warning:"border-transparent bg-warning text-warning-foreground hover:bg-warning/90",info:"border-transparent bg-primary/10 text-primary hover:bg-primary/20",sharp:"border-transparent bg-[hsl(78,70%,46%)] text-foreground hover:bg-[hsl(78,70%,40%)]"}},defaultVariants:{variant:"default"}}),yt=J.forwardRef(({className:t,variant:a,...s},r)=>e.jsx("div",{ref:r,className:Te(Nt({variant:a}),t),...s}));yt.displayName="Badge";const jt={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Ct({size:t="md",className:a}){return e.jsx(d.Loader2,{className:Te("animate-spin text-muted-foreground",jt[t],a)})}const kt=({...t})=>e.jsx(l.Toaster,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:e.jsx(d.CircleCheckIcon,{className:"h-4 w-4"}),info:e.jsx(d.InfoIcon,{className:"h-4 w-4"}),warning:e.jsx(d.TriangleAlertIcon,{className:"h-4 w-4"}),error:e.jsx(d.OctagonXIcon,{className:"h-4 w-4"}),loading:e.jsx(d.Loader2Icon,{className:"h-4 w-4 animate-spin"})},toastOptions:{classNames:{toast:"group toast group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg group-[.toaster]:relative",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",closeButton:"group-[.toast]:absolute group-[.toast]:right-2 group-[.toast]:top-2 group-[.toast]:left-auto group-[.toast]:transform-none group-[.toast]:border-0 group-[.toast]:bg-transparent group-[.toast]:opacity-70 group-[.toast]:hover:opacity-100 group-[.toast]:hover:bg-transparent group-[.toast]:transition-opacity",success:"!bg-success-light !border-success-light",error:"!bg-destructive/10 !border-destructive/10",warning:"!bg-warning-light !border-warning-light",info:"!bg-info-light !border-info-light"}},...t}),St=ne.Root,Tt=ne.Trigger,Pt=ne.Group,Mt=ne.Portal,It=ne.Sub,At=ne.RadioGroup,Et=J.forwardRef(({className:t,inset:a,children:s,...r},n)=>e.jsxs(ne.SubTrigger,{ref:n,className:Te("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",a&&"pl-8",t),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Et.displayName=ne.SubTrigger.displayName;const Dt=J.forwardRef(({className:t,...a},s)=>e.jsx(ne.SubContent,{ref:s,className:Te("z-50 min-w-[8rem] overflow-hidden border bg-popover p-1 text-popover-foreground shadow-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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a}));Dt.displayName=ne.SubContent.displayName;const _t=J.forwardRef(({className:t,sideOffset:a=4,...s},r)=>e.jsx(ne.Portal,{children:e.jsx(ne.Content,{ref:r,sideOffset:a,className:Te("z-[100] min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground p-1 shadow-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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s})}));_t.displayName=ne.Content.displayName;const Rt=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(ne.Item,{ref:r,className:Te("relative flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",t),...s}));Rt.displayName=ne.Item.displayName;const zt=J.forwardRef(({className:t,children:a,checked:s,...r},n)=>e.jsxs(ne.CheckboxItem,{ref:n,className:Te("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ne.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),a]}));zt.displayName=ne.CheckboxItem.displayName;const Ft=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(ne.RadioItem,{ref:r,className:Te("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ne.ItemIndicator,{children:e.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));Ft.displayName=ne.RadioItem.displayName;const Lt=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(ne.Label,{ref:r,className:Te("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",t),...s}));Lt.displayName=ne.Label.displayName;const Ot=J.forwardRef(({className:t,...a},s)=>e.jsx(ne.Separator,{ref:s,className:Te("-mx-1 my-1 h-px bg-muted",t),...a}));Ot.displayName=ne.Separator.displayName;const Ut=({className:t,...a})=>e.jsx("span",{className:Te("ml-auto text-xs tracking-widest opacity-60",t),...a});Ut.displayName="DropdownMenuShortcut";const $t=({delayDuration:t=300,...a})=>e.jsx(ie.Provider,{delayDuration:t,...a}),qt=ie.Root,Ht=ie.Trigger,Bt=J.forwardRef(({className:t,sideOffset:a=4,...s},r)=>e.jsx(ie.Content,{ref:r,sideOffset:a,className:Te("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s}));Bt.displayName=ie.Content.displayName;const Wt=J.forwardRef(({children:t,disabledReason:a,className:s},r)=>{const n=e.jsx(Rt,{ref:r,className:Te("opacity-50 cursor-not-allowed pointer-events-auto",s),onSelect:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation()},children:t});return a?e.jsx($t,{delayDuration:100,children:e.jsxs(qt,{children:[e.jsx(Ht,{asChild:!0,children:e.jsx("div",{className:"w-full",children:n})}),e.jsx(Bt,{side:"right",sideOffset:8,className:"max-w-[200px] z-[100]",children:a})]})}):n});Wt.displayName="DisabledMenuItem";const Vt=oe.Root,Gt=oe.Trigger,Yt=J.forwardRef(({className:t,align:a="center",sideOffset:s=4,container:r,...n},i)=>e.jsx(oe.Portal,{container:r,children:e.jsx(oe.Content,{ref:i,align:a,sideOffset:s,className:Te("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));Yt.displayName=oe.Content.displayName;const Qt=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...a}));Qt.displayName="Command";const Xt=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:e.jsx("input",{ref:s,className:Te("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...a})}));Xt.displayName="CommandInput";const Kt=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...a}));Kt.displayName="CommandList";const Zt=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("py-6 text-center text-sm text-muted-foreground",t),...a}));Zt.displayName="CommandEmpty";const Jt=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...a}));Jt.displayName="CommandGroup";const ea=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("-mx-1 h-px bg-border",t),...a}));ea.displayName="CommandSeparator";const ta=J.forwardRef(({className:t,disabled:a,onSelect:s,value:r,...n},i)=>e.jsx("div",{ref:i,className:Te("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",t),"data-disabled":a,onClick:()=>!a&&s?.(r||""),...n}));ta.displayName="CommandItem";const aa=({className:t,...a})=>e.jsx("span",{className:Te("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});function sa({className:t,...a}){return e.jsx("div",{className:Te("animate-pulse rounded-md bg-muted",t),...a})}aa.displayName="CommandShortcut";const ra=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function na({multiple:a,options:s,value:r,onChange:n,getOptionValue:i,getOptionLabel:o,placeholder:l,label:c,icon:u,emptyMessage:m,searchPlaceholder:h,disabled:p,required:f,className:x,sortOptions:g,maxDisplayedBadges:b,popoverContainer:w,onOpen:N,onClose:y}){const{t:j}=v.useTranslation(),[C,k]=t.useState(!1),[S,T]=t.useState(""),P=t.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),M=t.useMemo(()=>{if(!w)return;let e=w,t=0;try{for(;e&&t<3;){const a=window.getComputedStyle(e),s=a.overflowY||a.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,t++}}catch{}return e??void 0},[w]),I=t.useMemo(()=>{const e=s.map(e=>({original:e,value:i(e),label:o(e)}));return g?e.sort((e,t)=>e.label.localeCompare(t.label,"pt-BR",{sensitivity:"base"})):e},[s,i,o,g]),A=t.useMemo(()=>{if(!S)return I;const e=ra(S);return I.filter(t=>ra(t.label).includes(e))},[I,S]),E=t.useMemo(()=>I.filter(e=>P.includes(e.value)),[I,P]),D=e=>{k(e),e?N?.():(T(""),y?.())},_=(e,t)=>{t.preventDefault(),t.stopPropagation(),n&&n(a?P.filter(t=>t!==e):"")},R=b?E.slice(0,b):E,z=b&&E.length>b?E.length-b:0;return e.jsxs("div",{className:Te("space-y-2",x),children:[c&&e.jsxs(_e,{children:[c,f&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(Vt,{open:C,onOpenChange:D,modal:!1,children:[e.jsx(Gt,{asChild:!0,children:a?e.jsxs("div",{role:"combobox","aria-expanded":C,"aria-disabled":p,tabIndex:p?-1:0,onKeyDown:e=>{p||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),D(!C))},className:Te("flex w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","min-h-10 h-auto cursor-pointer",p&&"pointer-events-none opacity-50 cursor-not-allowed",0===E.length&&"text-muted-foreground"),children:[0===E.length?e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),l]}):e.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[R.map(t=>e.jsxs(yt,{variant:"secondary",className:"gap-1 pr-1",children:[t.label,e.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:e=>{"Enter"===e.key&&_(t.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>_(t.value,e),children:e.jsx(d.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},t.value)),z>0&&e.jsxs(yt,{variant:"outline",className:"gap-1",children:["+",z]})]}),e.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):e.jsxs(Ie,{variant:"outline",role:"combobox","aria-expanded":C,disabled:p,className:Te("w-full justify-between min-h-10 h-auto",0===E.length&&"text-muted-foreground"),children:[0===E.length?e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),l]}):e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),E[0]?.label]}),e.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Yt,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:M,collisionBoundary:M,children:e.jsxs(Qt,{children:[e.jsx(Xt,{placeholder:h,value:S,onChange:e=>T(e.target.value)}),e.jsx(Kt,{children:0===s.length?e.jsx(Zt,{children:m}):0===A.length?e.jsx(Zt,{children:j("no_results")}):e.jsx(Jt,{children:A.map(t=>e.jsxs(ta,{value:t.value,onSelect:()=>(e=>{if(n)if(a){const t=P.includes(e)?P.filter(t=>t!==e):[...P,e];n(t)}else n(e),k(!1)})(t.value),className:"cursor-pointer",children:[e.jsx(d.Check,{className:Te("mr-2 h-4 w-4",P.includes(t.value)?"opacity-100":"opacity-0")}),t.label]},t.value))})})]})})]})]})}function ia({multiple:t=!1,options:a,items:s,value:r,onChange:n,onValueChange:i,getOptionValue:o=e=>e.value,getOptionLabel:l=e=>e.label,placeholder:c,label:u,icon:m,emptyMessage:h,searchPlaceholder:p,disabled:f=!1,required:x=!1,isLoading:g=!1,error:b,className:w,sortOptions:N=!0,maxDisplayedBadges:y,popoverContainer:j,onOpen:C,onClose:k}){const{t:S}=v.useTranslation(),T=s||a||[],P=i||n,M=c||S("select_placeholder"),I=h||S("no_results"),A=p||S("search_placeholder");if(g)return e.jsxs("div",{className:Te("space-y-2",w),children:[u&&e.jsxs(_e,{children:[u,x&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(sa,{className:"h-10 w-full"})]});const E="string"==typeof b?b:b instanceof Error?b.message:b?"Erro ao carregar dados":void 0;return E?e.jsxs("div",{className:Te("space-y-2",w),children:[u&&e.jsxs(_e,{children:[u,x&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[e.jsx(d.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:E})]})]}):e.jsx(na,{multiple:t,options:T,value:r||(t?[]:""),onChange:P,getOptionValue:o,getOptionLabel:l,placeholder:M,label:u,icon:m,emptyMessage:I,searchPlaceholder:A,disabled:f,required:x,className:w,sortOptions:N,maxDisplayedBadges:y,popoverContainer:j,onOpen:C,onClose:k})}var oa=Object.defineProperty;class la{static normalizeBase64Url(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const a=(4-t.length%4)%4;return t+="=".repeat(a),t}static parseJwtPayload(e){try{const r=e.split(".");if(3!==r.length)return null;const n=r[1];n.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(n),t=atob(e),a=new Uint8Array(t.length);for(let r=0;r<t.length;r++)a[r]=t.charCodeAt(r);const s=new TextDecoder("utf-8").decode(a);return JSON.parse(s)}catch(t){try{const e=this.normalizeBase64Url(n),t=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(t)}catch(a){try{const e=this.normalizeBase64Url(n),t=atob(e);return JSON.parse(t)}catch(s){throw s}}}}catch(r){return null}}static validateTokens(e,t){const a=[],s=[];try{t.split(".")[1],e.split(".")[1];const r=this.parseJwtPayload(t),n=this.parseJwtPayload(e);if(!r){const e="ID token decode falhou - possível problema com base64url encoding";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:s}}let i=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";a.push(e),i=!1}const o=Math.floor(Date.now()/1e3);if(n?.exp&&n.exp<o){const e="Access token expirado - pode precisar de refresh";a.push(e),i=!1}if(r.exp&&r.exp<o){const e="ID token expirado - autenticação inválida";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:i,warnings:a,errors:s}}return{isValid:!0,idTokenValid:!0,accessTokenValid:i,warnings:a,errors:s}}catch(r){const e=`Erro na validação de tokens: ${r}`;return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:s}}}static isTokenExpired(e){const t=this.parseJwtPayload(e);return!t||!t.exp||1e3*t.exp<Date.now()}static extractTokenData(e){return this.parseJwtPayload(e)}}((e,t,a)=>{t in e?oa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a})(la,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const da="qualiex_access_token",ca="qualiex_id_token",ua="supabase_token",ma="oauth_state",ha="oauth_nonce",pa="selected_alias",fa="manual_logout",xa={setAccessToken:e=>localStorage.setItem(da,e),getAccessToken:()=>localStorage.getItem(da),setIdToken:e=>localStorage.setItem(ca,e),getIdToken:()=>localStorage.getItem(ca),getSupabaseToken:()=>localStorage.getItem(ua),setOAuthState:e=>sessionStorage.setItem(ma,e),getOAuthState:()=>sessionStorage.getItem(ma),clearOAuthState:()=>sessionStorage.removeItem(ma),setOAuthNonce:e=>sessionStorage.setItem(ha,e),getOAuthNonce:()=>sessionStorage.getItem(ha),clearOAuthNonce:()=>sessionStorage.removeItem(ha),setSelectedAlias:e=>localStorage.setItem(pa,e),getSelectedAlias:()=>localStorage.getItem(pa),clearSelectedAlias:()=>localStorage.removeItem(pa),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!xa.getAccessToken()||!xa.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(ua,e),xa._clearValidationCache()},areAllTokensValid:()=>{const e=xa.getAccessToken(),t=xa.getIdToken();if(!e||!t)return!1;try{const a=la.validateTokens(e,t);return!!a.idTokenValid&&a.idTokenValid}catch(a){return!1}},clearExpiredTokens:()=>{let e=!1;const t=xa.getAccessToken(),a=xa.getIdToken(),s=xa.getSupabaseToken();return t&&xa.isTokenExpired(t)&&(localStorage.removeItem(da),e=!0),a&&xa.isTokenExpired(a)&&(localStorage.removeItem(ca),e=!0),s&&xa.isTokenExpired(s)&&(localStorage.removeItem(ua),e=!0),e},clearAll:()=>{localStorage.removeItem(da),localStorage.removeItem(ca),localStorage.removeItem(ua),localStorage.removeItem(pa),localStorage.removeItem(fa),sessionStorage.removeItem(ma),sessionStorage.removeItem(ha)},setManualLogout:()=>localStorage.setItem(fa,"true"),isManualLogout:()=>"true"===localStorage.getItem(fa),clearManualLogout:()=>localStorage.removeItem(fa),isTokenExpired:e=>{try{return la.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{xa._validationCache.isValid=!1,xa._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=xa.getSupabaseToken();if(!e)return!1;if(xa.isTokenExpired(e))return xa._clearValidationCache(),xa._handleExpiredToken(),!1;const t=Date.now();return t-xa._validationCache.timestamp<xa._validationCache.cacheValidityMs?xa._validationCache.isValid:(xa._validationCache.isValid=!0,xa._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>xa.isSupabaseTokenValid()?xa.getSupabaseToken():null,_handleExpiredToken:()=>{xa.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!xa.isSupabaseTokenValid())return null;const e=xa.getSupabaseToken();if(!e)return null;try{const t=la.parseJwtPayload(e);if(!t)return null;const a=t.alias||t.default||t.user_alias,s=t.place_id||null,r=t.place_name||null;let n=t.company_id;if(!n&&a)for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=t[e];if(s&&"string"==typeof s){const e=s.split(";");if(e.length>7&&e[0]===a){n=e[7];break}}}return{alias:a,companyId:n,placeId:s,placeName:r,payload:t}}catch(t){return xa._handleExpiredToken(),null}},getCompanyId:e=>{const t=xa.getAccessToken();if(t)try{const a=la.parseJwtPayload(t);if(a)for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const s=a[t];if(s&&"string"==typeof s){const t=s.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(r){}const a=xa.extractTokenData();if(a?.companyId)return a.companyId;const s=xa.getIdToken();if(s)try{const t=la.parseJwtPayload(s);if(t)for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const s=t[a];if(s&&"string"==typeof s){const t=s.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(r){}return null},getCurrentCompanyId:()=>{const e=xa.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=xa.getIdToken();if(!e)return[];try{const t=la.parseJwtPayload(e);if(!t)return[];const a=[];for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=t[e];if(s&&"string"==typeof s){const e=s.split(";");e.length>=4&&a.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:t})}}return a}catch{return[]}}};var ga=Object.defineProperty,ba=(e,t,a)=>((e,t,a)=>t in e?ga(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const va=new class{constructor(){ba(this,"errors",[]),ba(this,"toastCount",0),ba(this,"lastToastTime",0)}handleError(e,t=!0){const a="string"==typeof e?e:e.message;if(this.errors.push({id:Date.now().toString(),message:a,timestamp:Date.now(),count:1}),t&&this.shouldShowToast()){const e=this.getErrorTitle(a);l.toast.error(e,{description:a})}}getErrorTitle(e){const t=e.toLowerCase();return t.includes("401")||t.includes("unauthorized")||t.includes("expirou")?"Sessão Expirada":t.includes("token")||t.includes("autenticação")?"Erro de Autenticação":t.includes("api")||t.includes("network")?"Erro de Conexão":"Erro"}success(e,t){l.toast.success(e,{description:t})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}};var wa=Object.defineProperty,Na=(e,t,a)=>((e,t,a)=>t in e?wa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const ya=(void 0).VITE_SUPABASE_URL,ja=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY,Ca=class e{constructor(){Na(this,"client"),Na(this,"currentToken",null),Na(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:ja};e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`);return w.createClient(ya,ja,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:t,fetch:async(e,t)=>("string"==typeof e?e:e.url).includes("/auth/v1/user")?new Response(JSON.stringify({error:"blocked"}),{status:401,headers:{"Content-Type":"application/json"}}):fetch(e,t)}})}static getInstance(){return e.instance||(e.instance=new e),e.instance}getClient(){const e=xa.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{const t=JSON.parse(atob(e.split(".")[1])),a=Math.floor(Date.now()/1e3);return t.exp>a}catch(t){return va.handleError(t instanceof Error?t:"❌ Supabase - Error validating token",!1),!1}}};Na(Ca,"instance");let ka=Ca;function Sa(){return ka.getInstance().getClient()}class Ta{static async generateToken(e,t,a,s=!1){try{if(!s){const e=xa.getSupabaseToken();if(e&&xa.isSupabaseTokenValid())return e}const r=Sa(),{data:n,error:i}=await r.functions.invoke("validate-token",{body:{access_token:e,alias:t}});return i&&(i.message?.includes("401")||i.message?.includes("Unauthorized"))?(a?.(),null):n?.access_token&&n.access_token?(xa.setSupabaseToken(n.access_token),n.access_token):null}catch(r){return r instanceof Error&&(r.message.includes("401")||r.message.includes("Unauthorized"))&&a?.(),null}}}var Pa=Object.defineProperty,Ma=(e,t,a)=>((e,t,a)=>t in e?Pa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);class Ia{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=xa.getAccessToken(),t=xa.getSelectedAlias();if(!e||!t)return null;const a=await Ta.generateToken(e,t,this.onLogoutCallback||void 0,!1);return a?(xa.setSupabaseToken(a),a):null}catch(e){return null}finally{this.isRegenerating=!1}}}Ma(Ia,"isRegenerating",!1),Ma(Ia,"onLogoutCallback",null);class Aa{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&(xa.clearAll(),window.location.href="/",!0)}static isAuthenticationError(e,t){if(401===e.status||401===e.statusCode)return!0;const a=t.toLowerCase();return["401","unauthorized","token","expired","invalid","authentication","login","session"].some(e=>a.includes(e))}static async wrapAsync(e){try{return await e}catch(t){if(!this.handleError(t))throw t;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}var Ea=Object.defineProperty;class Da{static async handleApiError(e){if(!e||this.isRetrying)return!1;const t=e.status||e.statusCode,a=e.message||e.toString();if(401===t||a.includes("401")||a.includes("Unauthorized")){this.isRetrying=!0;try{return await Ia.attemptRegeneration()?(this.isRetrying=!1,!0):(Aa.handleError(e),this.isRetrying=!1,!1)}catch(s){return Aa.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=xa.getAccessToken();return e?xa.isTokenExpired(e)?{valid:!1,message:"Sua sessão expirou. Você será redirecionado para fazer login."}:{valid:!0}:{valid:!1,message:"Token OAuth não encontrado. Faça login novamente."}}}((e,t,a)=>{((e,t,a)=>{t in e?Ea(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a})(e,t+"",a)})(Da,"isRetrying",!1);var _a=Object.defineProperty,Ra=(e,t,a)=>((e,t,a)=>t in e?_a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);const za=new class{constructor(){Ra(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,t,a){const s=Da.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=xa.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!a||""===a.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const n=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{n.searchParams.append(e,t)});const i=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!i.ok){const e=new Error(`API call failed: ${i.status} ${i.statusText}`);throw e.status=i.status,e.statusCode=i.status,e}return await i.json()}mapToQualiexUser(e){return{id:e.id||e.ID||"",userId:e.userId||String(e.ID),userName:e.userName||"Nome não disponível",userEmail:e.userEmail||"Email não disponível",placeId:null,placeName:e.placeName||null,roleId:e.roleId||void 0,roleName:e.roleName||void 0,companyId:e.companyId||void 0,companyName:e.companyName||void 0}}async fetchUsers(e,t){try{const a=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"active"},e);let s=a;if(a.data)s=a.data;else{if(!Array.isArray(a))return va.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];s=a}if(!Array.isArray(s))return va.handleError("[QualiexApi] Resposta não é um array",!1),[];return s.map(this.mapToQualiexUser)}catch(a){if(await Da.handleApiError(a))try{const a=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"active"},e);let s=a;if(a.data)s=a.data;else{if(!Array.isArray(a))return va.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];s=a}return Array.isArray(s)?s.map(this.mapToQualiexUser):(va.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(s){return va.handleError(s instanceof Error?s:"Erro ao buscar usuários após renovação de token",!0),[]}const r=a instanceof Error?a.message:"Erro ao buscar usuários da API Qualiex";return va.handleError(r,!0),[]}}async fetchUserById(e,t,a){try{return(await this.fetchUsers(t,a)).find(t=>t.userId===e)||null}catch(s){return va.handleError(s instanceof Error?s:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,t){const a=await this.fetchUsers(e,t),s=new Map;return a.forEach(e=>{s.set(e.userId,e)}),s}async getUsers(e){const t=xa.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId):[]}async getAllUsers(e){return this.getUsers(e)}},Fa={oauth:{authUrl:(void 0).VITE_OAUTH_AUTH_URL,clientId:(void 0).VITE_OAUTH_CLIENT_ID,responseType:"id_token token",scope:"openid profile email"}},La={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Oa={debounceDelay:500},Ua=()=>{const e=window.location.origin;return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("id-preview")||e.includes("lovable.dev")||(void 0).DEV},$a={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},qa=()=>$a,Ha={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},Ba={success:{created:e=>`${e} criado com sucesso`,updated:e=>`${e} atualizado com sucesso`,deleted:e=>`${e} removido com sucesso`},error:{create:e=>`Erro ao criar ${e}`,update:e=>`Erro ao atualizar ${e}`,delete:e=>`Erro ao remover ${e}`,load:e=>`Erro ao carregar ${e}`}};function Wa(e,t){const a=qa(),s=t||a.userNameFieldSuffix||"_name";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function Va(e,t){const a=qa(),s=t||a.userEmailFieldSuffix||"_email";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function Ga(e,t){const a=qa(),s=t||a.userUsernameFieldSuffix||"_username";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function Ya(e,t){return t&&t.length>0?t.map(e=>({idField:e.idField,nameField:e.nameField||Wa(e.idField),emailField:e.emailField||Va(e.idField),usernameField:e.usernameField||Ga(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:Wa(e),emailField:Va(e),usernameField:Ga(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const Qa=new Map;class Xa{static async fetchQualiexUsers(e,t){const a=`${t}_${e}`,s=Qa.get(a);if(s&&Date.now()-s.timestamp<3e5)return s.users;const r=await za.fetchUsers(e,t);return Qa.set(a,{users:r,timestamp:Date.now()}),r}static extractUserIds(e,t){const a=new Set;for(const s of e)for(const e of t){const t=s[e.idField];t&&"string"==typeof t&&""!==t.trim()&&a.add(t)}return a}static indexUsers(e){const t=new Map;for(const a of e)a.id&&t.set(a.id,a),a.userId&&t.set(a.userId,a);return t}static enrichEntity(e,t,a){const s={...e};for(const r of t){const t=e[r.idField];if(!t)continue;const n=a.get(t);if(n){if(r.nameField){s[r.nameField]||(s[r.nameField]=n.userName||n.displayName||null)}if(r.emailField){s[r.emailField]||(s[r.emailField]=n.userEmail||null)}if(r.usernameField){s[r.usernameField]||(s[r.usernameField]=n.userName||null)}}}return s}static async enrichWithUserData(e,t){if(!Array.isArray(e)||0===e.length)return e;try{if(!xa.areAllTokensValid())return e;const a=xa.extractTokenData();if(!a)return e;const{alias:s,companyId:r}=a;if(!s||!r)return e;const n=Ya(t.userIdFields,t.userFieldsMapping);if(0===this.extractUserIds(e,n).size)return e;const i=await this.fetchQualiexUsers(s,r),o=this.indexUsers(i);return e.map(e=>this.enrichEntity(e,n,o))}catch(a){return va.handleError(a instanceof Error?a:new Error(`[QualiexEnrichment.${t.entityName}] Erro crítico`),!1),e}}static async enrichWithResponsibleNames(e,t){return this.enrichWithUserData(e,{entityName:t.entityName,userIdFields:["id_user"],userFieldsMapping:[{idField:"id_user",nameField:"responsible_name"}]})}}const Ka=["responsible_name"],Za=e=>Ka.includes(e);function Ja(e,t,a){const s="string"==typeof e?{tableName:e,searchFields:t||[],schemaName:a||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:r,searchFields:n,selectFields:i,schemaName:o,entityName:l,enableQualiexEnrichment:d=!1}=s,c=()=>{if(!xa.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return Sa().schema(o).from(r)},u=(e,t,a,s)=>{let r=c().select(i||"*",{count:"exact"});r=r.eq("is_removed",!1),Object.entries(s).forEach(([e,t])=>{void 0!==t&&""!==t&&(Array.isArray(t)?r=r.in(e,t):"object"==typeof t&&t&&"operator"in t?"not_null"===t.operator?r=r.not(e,"is",null):"is_null"===t.operator&&(r=r.is(e,null)):null!==t&&(r=r.eq(e,t)))}),r=((e,t)=>{if(t&&n.length>0){const a=n.map(e=>`${e}.ilike.%${t}%`).join(",");return e.or(a)}return e})(r,e);const o=t.includes(".");return o||Za(t)||(r=r.order(t,{ascending:"asc"===a})),{query:r,isForeignKey:o}},m=async(e,t,a,r,n)=>{const i=Ya(s.userIdFields,s.userFieldsMapping).some(e=>e.nameField===t||e.emailField===t||e.usernameField===t),o=t.includes(".");if(Za(t)||o||i){const e={search:"",sortField:void 0,sortDirection:void 0,page:1,limit:500},i=await this.getAll(e);if(!i?.data?.length)return i;const d=await Xa.enrichWithUserData(i.data,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping});let c;c=o?d.sort((e,s)=>{const r=t.split(".").reduce((e,t)=>e?.[t],e)||"",n=t.split(".").reduce((e,t)=>e?.[t],s)||"",i=String(r).localeCompare(String(n),"pt-BR");return"asc"===a?i:-i}):((e,t,a)=>[...e].sort((e,s)=>{const r=e[t]||"",n=s[t]||"",i=r.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===a?i:-i}))(d,t,a);const u=((e,t=1,a=25)=>{const s=(t-1)*a,r=s+a,n=e.slice(s,r);return{data:n,pagination:{currentPage:t,totalPages:Math.ceil(e.length/a),totalItems:n.length,totalCount:e.length,itemsPerPage:a,hasNextPage:r<e.length,hasPreviousPage:t>1}}})(c,r,n);return{data:u.data,currentPage:u.pagination.currentPage,totalPages:u.pagination.totalPages,totalItems:u.pagination.totalCount,itemsPerPage:u.pagination.itemsPerPage,hasNextPage:u.pagination.hasNextPage,hasPreviousPage:u.pagination.hasPreviousPage}}return await Xa.enrichWithUserData(e,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping})};return{async getAll(e={}){const{search:t,sortField:a,sortDirection:n,page:i,limit:o,additionalFilters:c}=(e=>{const{search:t="",sortField:a="updated_at",sortDirection:s="desc",page:r=1,limit:n=25,...i}=e;return{search:t,sortField:a,sortDirection:s,page:r,limit:n,additionalFilters:i}})(e),{query:h}=u(t,a,n,c),p=((e,t,a)=>{const s=(t-1)*a,r=s+a-1;return e.range(s,r)})(h,i,o),{data:f,error:x,count:g}=await p;if(x)throw new Error(`Error fetching ${r}: ${x.message}`);let b=((e,t,a,s)=>{const r=Math.ceil((t||0)/s);return{data:e,currentPage:a,totalPages:r,totalItems:t||0,itemsPerPage:s,hasNextPage:a<r,hasPreviousPage:a>1}})(f||[],g,i,o);if((e=>{if(!d||!l||0===e.length)return!1;const t=Ya(s.userIdFields,s.userFieldsMapping);return e.some(e=>t.some(t=>e[t.idField]))})(b.data)){const e=await m(b.data,a,n,i,o);if(!Array.isArray(e))return e;b={...b,data:e}}return b},async getById(e){const{data:t,error:a}=await c().select(i||"*").eq("id",e).maybeSingle();if(a)throw new Error(`Error fetching ${r}: ${a.message}`);return t},async create(e){const t=Pe(e),a=Object.entries(t).reduce((e,[t,a])=>(void 0!==a&&(e[t]=a),e),{}),{data:s,error:n}=await c().insert(a).select().single();if(n)throw new Error(`Error creating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from create ${r} operation`);return s},async update(e,t){const a={...Pe(t),updated_at:(new Date).toISOString()},{data:s,error:n}=await c().update(a).eq("id",e).select().single();if(n)throw new Error(`Error updating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from update ${r} operation`);return s},async delete(e){const t={is_removed:!0,updated_at:(new Date).toISOString()},{error:a}=await c().update(t).eq("id",e);if(a)throw new Error(`Error soft deleting ${r}: ${a.message}`)}}}const es=()=>{xa.clearManualLogout()},ts=e=>e?.placeId||null,as=e=>e?.placeName||null,ss=e=>({placeId:ts(e),placeName:as(e)}),rs=class{static async initialize(){try{if(!xa.hasAllTokens()||!xa.areAllTokensValid())return xa.clearExpiredTokens(),{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null};const t=xa.getAccessToken(),a=xa.getIdToken();es();const s=this.extractUserFromIdToken(a),r=this.extractCompaniesFromIdToken(a),n=this.extractAliasFromAccessToken(t),i=xa.extractTokenData(),o=i?.alias;let l=null;if(o&&r.some(e=>e.alias===o))l=o;else{const e=xa.getSelectedAlias(),t=e&&r.some(t=>t.alias===e);l=t?e:n||r[0]?.alias||null}!xa.isSupabaseTokenValid()&&l&&await Ia.attemptRegeneration();let d=null;if(l){const e=xa.getCompanyId(l),t=r.find(e=>e.alias===l);t&&(d={id:e||t.id,name:t.name,alias:t.alias})}let c=null,u=null;if(s?.id&&l){const t=xa.getCompanyId(l);if(t)try{const e=(await za.fetchActiveUsersMap(l,t)).get(s.id);if(e){const t=ss(e);c=t.placeId,u=t.placeName}}catch(e){}}return{isAuthenticated:!0,isLoading:!1,user:s,alias:l,companies:r,selectedUnit:d,userId:s?.id||null,userAlias:s?.id||null,placeId:c,placeName:u,activePlaceId:c,activePlaceName:u}}catch(e){return{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null}}}static async loginDev(){try{const e=Sa(),{data:t,error:a}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(a)return!1;if(!t?.access_token||!t?.id_token)return!1;const s=new URL("/callback",window.location.origin);return s.hash=`access_token=${t.access_token}&id_token=${t.id_token}&token_type=bearer`,window.location.href=s.toString(),!0}catch(e){return!1}}static loginProd(){const e=xa.generateOAuthState();xa.setOAuthState(e);const t=xa.generateOAuthNonce();xa.setOAuthNonce(t);const a=`${window.location.origin}/callback`,s=new URL(Fa.oauth.authUrl);s.searchParams.set("client_id",Fa.oauth.clientId),s.searchParams.set("response_type",Fa.oauth.responseType),s.searchParams.set("scope",Fa.oauth.scope),s.searchParams.set("redirect_uri",a),s.searchParams.set("state",e),s.searchParams.set("nonce",t),s.searchParams.set("response_mode","fragment"),Ua(),window.location.href=s.toString()}static async processCallback(){try{if(xa.hasAllTokens()){if(!xa.getValidSupabaseToken()){xa.getAccessToken();await Ia.attemptRegeneration()}return!0}const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),t=new URLSearchParams(window.location.search),a=a=>e.get(a)||t.get(a),s=a("access_token"),r=a("id_token"),n=a("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(!s||!r)throw new Error("Tokens não encontrados na URL de callback");xa.setAccessToken(s),xa.setIdToken(r),es();const i=this.extractAliasFromAccessToken(s);if(i)xa.setSelectedAlias(i);else{const e=this.extractCompaniesFromIdToken(r);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");xa.setSelectedAlias(e[0].alias)}if(!await Ia.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return xa.clearOAuthState(),xa.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){xa.setManualLogout(),xa.clearAll(),localStorage.removeItem("auth_return_url"),window.location.href="/login"}static decodeToken(e){return la.parseJwtPayload(e)}static extractUserFromIdToken(e){const t=this.decodeToken(e);return t?{id:t.subNewId,email:t.email,name:t.name,identifier:t.identifier}:null}static extractCompaniesFromIdToken(e){const t=this.decodeToken(e);if(!t)return[];const a=[];return Object.keys(t).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof t[e]){const s=t[e].split(";");if(s.length>=4)a.push({id:s.length>7?s[7].trim():"",alias:s[0].trim(),name:s[3].trim()});else{const[s,r]=t[e].split("|");s&&r&&a.push({id:"",alias:s.trim(),name:r.trim()})}}}),a}static extractAliasFromAccessToken(e){const t=this.decodeToken(e);return t?.default||null}};Ia.setLogoutCallback(()=>{rs.logout()});let ns=rs;const is=t.createContext(void 0),os=({children:a})=>{const[s,r]=t.useState({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let n=null;try{n=N.useQueryClient()}catch{}const[i,o]=t.useState(!1),[l,d]=t.useState(0),c=t.useCallback(e=>{r(t=>({...t,...e}))},[]),u=t.useCallback(e=>{r(t=>({...t,isLoading:e}))},[]),m=t.useCallback(()=>{r({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),h=t.useCallback(async e=>{try{u(!0);const a=xa.getAccessToken();if(!a)return;const r=await Ta.generateToken(a,e.alias,void 0,!0);if(!r)return;xa.setSupabaseToken(r),xa.setSelectedAlias(e.alias);const i=xa.extractTokenData(),o=i?.alias||e.alias,l=i?.companyId||xa.getCompanyId(e.alias),d={id:l||e.id,name:e.name,alias:o};let m=null,h=null;if(s.user?.id&&o&&l)try{const e=(await za.fetchActiveUsersMap(o,l)).get(s.user.id);if(e){const t=ss(e);m=t.placeId,h=t.placeName}}catch(t){}c({alias:o,selectedUnit:d,placeId:m,placeName:h,activePlaceId:m,activePlaceName:h}),n&&(await n.clear(),await new Promise(e=>setTimeout(e,100)))}catch(t){}finally{u(!1)}},[c,n,u,s.user]),p=t.useCallback(async()=>await ns.processCallback(),[]),f=t.useCallback(async()=>{ns.logout(),m(),n&&await n.clear()},[m,n]),x=t.useCallback(e=>{o(e)},[]),g=t.useCallback(()=>{d(e=>e+1)},[]),b=t.useCallback(()=>{d(e=>e+1)},[]);t.useEffect(()=>{if(!s.isAuthenticated)return;let e=!0;const t=setInterval(()=>{e&&(xa.areAllTokensValid()||e&&f())},6e5);return()=>{e=!1,clearInterval(t)}},[s.isAuthenticated,f]),t.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const t=await ns.initialize();if(!e)return;t&&t.isAuthenticated?c({user:t.user,companies:t.companies,alias:t.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:t.selectedUnit,userId:t.userId,userAlias:t.userAlias,placeId:t.placeId,placeName:t.placeName,activePlaceId:t.activePlaceId,activePlaceName:t.activePlaceName}):e&&u(!1)}catch(t){e&&(Aa.handleError(t),u(!1))}})(),()=>{e=!1}},[c,u,f]);const v=t.useMemo(()=>({...s,logout:f,processCallback:p,switchUnit:h,availableUnits:s.companies,isSearchVisible:i,setSearchVisible:x,clearSearch:g,refreshData:b}),[s.user,s.companies,s.alias,s.isAuthenticated,s.isLoading,s.selectedUnit,s.userId,s.userAlias,s.placeId,s.placeName,s.activePlaceId,s.activePlaceName,f,p,h,i,x,g,b]);return e.jsx(is.Provider,{value:v,children:a})},ls=()=>{const e=t.useContext(is);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function ds({queryKey:e,service:a,entityName:s,searchFields:r,additionalFilters:n={},onSuccess:i}){const[o,d]=y.useSearchParams(),c=N.useQueryClient(),{alias:u,userId:m,isAuthenticated:h}=ls(),p=t.useCallback(t=>{const a=`${e}_${t}`,s=o.get(a);return s||(o.get(t)||"")},[o,e]),f=p("search"),x=p("sortField")||La.sorting.defaultField,g=p("sortDirection")||La.sorting.defaultDirection,b=parseInt(p("page")||"1"),v=parseInt(p("limit")||String(La.pagination.defaultPageSize)),w=f,j=t.useMemo(()=>({search:w,sortField:x,sortDirection:g,page:b,limit:v,...n}),[w,x,g,b,v,n]),C=t.useCallback(()=>a.getAll(j),[a,j]),k=N.useQuery({queryKey:[e,u,m,j],queryFn:C,enabled:!!u&&h});if(!k)throw new Error(`useCrud: Query initialization failed for "${s}". Ensure QueryClientProvider is configured in your app root.`);const S=N.useMutation({mutationFn:a.create,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(Ba.success.created(s)),i?.()},onError:e=>{l.toast.error(`${Ba.error.create(s)}: ${e.message}`)}}),T=N.useMutation({mutationFn:({id:e,data:t})=>a.update(e,t),onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(Ba.success.updated(s)),i?.()},onError:e=>{l.toast.error(`${Ba.error.update(s)}: ${e.message}`)}}),P=N.useMutation({mutationFn:a.delete,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(Ba.success.deleted(s))},onError:e=>{l.toast.error(`${Ba.error.delete(s)}: ${e.message}`)}}),M=t.useCallback(t=>{const a={...Object.fromEntries(o)};Object.entries(t).forEach(([t,s])=>{const r=`${e}_${t}`;""===s||0===s?delete a[r]:a[r]=String(s)}),delete a.sortField,delete a.sortDirection,d(a)},[o,d,e]),I=t.useCallback(e=>{M({search:e,page:1})},[M]),A=t.useCallback(e=>{M({sortField:e,sortDirection:x===e&&"asc"===g?"desc":"asc",page:1})},[x,g,M]),E=t.useCallback(e=>{M({page:e})},[M]),D=t.useCallback(e=>{M({limit:e,page:1})},[M]),_=t.useCallback(()=>{const t=Object.fromEntries(o),a=`${e}_`,s=Object.fromEntries(Object.entries(t).filter(([e])=>!e.startsWith(a)));d(s)},[d,o,e]),[R,z]=t.useState([]),F=t.useCallback(e=>{z(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),L=t.useCallback(()=>{const e=k?.data?.data.map(e=>e.id)||[];z(t=>t.length===e.length?[]:e)},[k?.data?.data]),O=t.useCallback(()=>{z([])},[]),U=t.useMemo(()=>{const e=k?.data?.data.map(e=>e.id)||[];return e.length>0&&R.length===e.length},[R,k?.data?.data]),$=N.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>a.delete(e)))},onSuccess:(t,a)=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(`${a.length} ${s}(s) deletado(s) com sucesso`),O()},onError:e=>{l.toast.error(`Erro ao deletar itens: ${e.message}`)}}),q=t.useCallback((e,t)=>{const a=t?t(e):e;e.id?T.mutate({id:e.id,data:a}):S.mutate({...a,alias:u})},[u,S,T]);return{entities:k?.data?.data||[],pagination:{data:k?.data?.data||[],currentPage:k?.data?.currentPage||1,totalPages:k?.data?.totalPages||1,totalItems:k?.data?.totalItems||0,itemsPerPage:k?.data?.itemsPerPage||La.pagination.defaultPageSize,hasNextPage:k?.data?.hasNextPage||!1,hasPreviousPage:k?.data?.hasPreviousPage||!1},isLoading:k?.isLoading??!0,isCreating:S?.isPending??!1,isUpdating:T?.isPending??!1,isDeleting:P?.isPending??!1,error:k?.error||null,searchTerm:f,sortField:x,sortDirection:g,currentPage:b,itemsPerPage:v,queryKey:e,createEntity:S.mutate,updateEntity:(e,t)=>T.mutate({id:e,data:t}),deleteEntity:P.mutate,save:q,handleSearch:I,handleSort:A,handlePageChange:E,handleItemsPerPageChange:D,clearFilters:_,refetch:k.refetch,selectedIds:R,selectItem:F,selectAll:L,clearSelection:O,isAllSelected:U,bulkDelete:e=>$.mutateAsync(e),isBulkDeleting:$.isPending}}const cs=J.forwardRef(({className:t,...a},s)=>e.jsx("table",{ref:s,className:Te("w-full caption-bottom text-sm table-fixed",t),...a}));cs.displayName="Table";const us=J.forwardRef(({className:t,...a},s)=>e.jsx("thead",{ref:s,className:Te("[&_tr]:border-b sticky top-0 z-[1] bg-background",t),...a}));us.displayName="TableHeader";const ms=J.forwardRef(({className:t,...a},s)=>e.jsx("tbody",{ref:s,className:Te("[&_tr:last-child]:border-0",t),...a}));ms.displayName="TableBody";const hs=J.forwardRef(({className:t,...a},s)=>e.jsx("tfoot",{ref:s,className:Te("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...a}));hs.displayName="TableFooter";const ps=J.forwardRef(({className:t,...a},s)=>e.jsx("tr",{ref:s,className:Te("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",t),...a}));ps.displayName="TableRow";const fs=J.forwardRef(({className:t,...a},s)=>e.jsx("th",{ref:s,className:Te("h-12 px-4 py-3 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",t),...a}));fs.displayName="TableHead";const xs=J.forwardRef(({className:t,...a},s)=>e.jsx("td",{ref:s,className:Te("px-4 py-3 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",t),...a}));xs.displayName="TableCell";const gs=J.forwardRef(({className:t,...a},s)=>e.jsx("caption",{ref:s,className:Te("mt-4 text-sm text-muted-foreground",t),...a}));function bs({rows:t=5,columns:a=4}){return e.jsx("div",{className:"w-full",children:e.jsxs("div",{className:"rounded-md border",children:[e.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:e.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((t,a)=>e.jsx(sa,{className:"h-4 w-24"},a))})}),e.jsx("div",{children:Array.from({length:t}).map((t,s)=>e.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:e.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((t,a)=>e.jsx(sa,{className:"h-4 w-20"},a))})},s))})]})})}function vs({count:t=3}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:t}).map((t,a)=>e.jsxs(Re,{children:[e.jsxs(ze,{children:[e.jsx(sa,{className:"h-4 w-3/4"}),e.jsx(sa,{className:"h-3 w-1/2"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(sa,{className:"h-3 w-full"}),e.jsx(sa,{className:"h-3 w-2/3"})]})})]},a))})}gs.displayName="TableCaption";const ws={default:d.FileX,search:d.Search,error:d.AlertCircle};function Ns({icon:t,title:a,description:s,action:r,className:n,variant:i="default"}){const o=t?()=>t:ws[i];return e.jsxs("div",{className:Te("flex flex-col items-center justify-center py-12 px-4 text-center",n),children:[e.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:e.jsx(o,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:a}),s&&e.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),r&&e.jsx(Ie,{onClick:r.onClick,variant:"outline",children:r.label})]})}function ys({children:t,className:a}){const s=J.useRef(null),[r,n]=J.useState(!1);J.useEffect(()=>{const e=()=>{const e=s.current;e&&n(e.scrollWidth>e.clientWidth)};e();const t=new ResizeObserver(e);return s.current&&t.observe(s.current),()=>t.disconnect()},[t]);const i=e.jsx("div",{ref:s,className:`truncate w-full max-w-full ${a||""}`,children:t});return r?e.jsx($t,{delayDuration:300,children:e.jsxs(qt,{children:[e.jsx(Ht,{asChild:!0,children:i}),e.jsx(Bt,{side:"top",className:"max-w-[400px] break-words",children:t})]})}):i}const js=J.forwardRef(({direction:t,onMouseDown:a,isDragging:s,className:r},n)=>{const i="horizontal"===t;return e.jsx("div",{ref:n,onMouseDown:a,className:Te("absolute z-20 select-none touch-none","transition-colors duration-150",i&&["top-0 right-0 h-full w-2 -mr-1","cursor-col-resize","hover:bg-primary/20","group flex items-center justify-center"],!i&&["bottom-0 left-0 w-full h-2 -mb-1","cursor-row-resize","hover:bg-primary/20","group flex items-center justify-center"],s&&"bg-primary/30",r),children:e.jsx("div",{className:Te("rounded-full bg-border transition-colors group-hover:bg-primary",s&&"bg-primary",i?"h-6 w-0.5":"w-6 h-0.5")})})});js.displayName="TableResizeHandle";const Cs=le.Root,ks=le.Trigger,Ss=le.Group,Ts=le.Portal,Ps=le.Sub,Ms=le.RadioGroup,Is=J.forwardRef(({className:t,inset:a,children:s,...r},n)=>e.jsxs(le.SubTrigger,{ref:n,className:Te("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",a&&"pl-8",t),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Is.displayName=le.SubTrigger.displayName;const As=J.forwardRef(({className:t,...a},s)=>e.jsx(le.SubContent,{ref:s,className:Te("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a}));As.displayName=le.SubContent.displayName;const Es=J.forwardRef(({className:t,...a},s)=>e.jsx(le.Portal,{children:e.jsx(le.Content,{ref:s,className:Te("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a})}));Es.displayName=le.Content.displayName;const Ds=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(le.Item,{ref:r,className:Te("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",t),...s}));Ds.displayName=le.Item.displayName;const _s=J.forwardRef(({className:t,children:a,checked:s,...r},n)=>e.jsxs(le.CheckboxItem,{ref:n,className:Te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(le.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),a]}));_s.displayName=le.CheckboxItem.displayName;const Rs=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(le.RadioItem,{ref:r,className:Te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(le.ItemIndicator,{children:e.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));Rs.displayName=le.RadioItem.displayName;const zs=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(le.Label,{ref:r,className:Te("px-2 py-1.5 text-sm font-semibold text-foreground",a&&"pl-8",t),...s}));zs.displayName=le.Label.displayName;const Fs=J.forwardRef(({className:t,...a},s)=>e.jsx(le.Separator,{ref:s,className:Te("-mx-1 my-1 h-px bg-border",t),...a}));Fs.displayName=le.Separator.displayName;const Ls=({className:t,...a})=>e.jsx("span",{className:Te("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});Ls.displayName="ContextMenuShortcut";const Os=({onEdit:t,onDelete:a,onToggleStatus:s,isActive:r=!0,canDelete:n=!0,customActions:i=[],renderAs:o})=>{const{t:l}=v.useTranslation(),c=[];if(t){const e={icon:d.Edit,label:l("edit"),onClick:t};c.push(e)}if(i.forEach(e=>{c.push(e)}),s){const e={icon:r?d.PowerOff:d.Power,label:l(r?"deactivate":"activate"),onClick:s};c.push(e)}if(n&&a){const e={icon:d.Trash2,label:l("delete"),onClick:a,destructive:!0};c.push(e)}const u="dropdown"===o?Rt:Ds;return e.jsx(e.Fragment,{children:c.map((t,a)=>e.jsxs(u,{onClick:t.onClick,className:Te("whitespace-normal cursor-pointer",t.destructive&&"text-destructive focus:text-destructive"),children:[e.jsx(t.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),t.label]},a))})},Us=({onEdit:t,onDelete:a,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:i=[]})=>e.jsxs(St,{children:[e.jsx(Tt,{asChild:!0,children:e.jsx(Ie,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:e.jsx(d.EllipsisVertical,{size:12})})}),e.jsx(_t,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:e.jsx(Os,{onEdit:t?e=>{e?.stopPropagation(),t?.()}:void 0,onDelete:a?e=>{e?.stopPropagation(),a?.()}:void 0,onToggleStatus:r?e=>{e?.stopPropagation(),r?.()}:void 0,isActive:n,canDelete:s&&!!a,customActions:i,renderAs:"dropdown"})})]}),$s=150;function qs({columns:e,storageKey:a,onResize:s,enabled:r=!0}){const[n,i]=t.useState(()=>{if(!r||"undefined"==typeof window)return e.reduce((e,t)=>(e[t.key]=t.defaultWidth??$s,e),{});if(a){const e=localStorage.getItem(a);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,t)=>(e[t.key]=t.defaultWidth??$s,e),{})}),[o,l]=t.useState(!1),[d,c]=t.useState(null),u=t.useRef(0),m=t.useRef(0),h=t.useCallback((e,t)=>{r&&(t.preventDefault(),t.stopPropagation(),l(!0),c(e),u.current=t.clientX,m.current=n[e]??$s)},[r,n]);t.useEffect(()=>{if(!o||!d)return;const t=e.find(e=>e.key===d),r=t?.minWidth??60,n=t?.maxWidth??500,h=e=>{const t=e.clientX-u.current,a=Math.max(r,Math.min(n,m.current+t));i(e=>{const t={...e,[d]:a};return s?.(t),t})},p=()=>{l(!1),c(null),a&&i(e=>(localStorage.setItem(a,JSON.stringify(e)),e))};return document.addEventListener("mousemove",h),document.addEventListener("mouseup",p),()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)}},[o,d,e,a,s]),t.useEffect(()=>{o?(document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[o]);const p=t.useCallback(()=>{const t=e.reduce((e,t)=>(e[t.key]=t.defaultWidth??$s,e),{});i(t),a&&localStorage.removeItem(a),s?.(t)},[e,a,s]);return{columnWidths:n,isDragging:o,activeColumn:d,handleMouseDown:h,resetWidths:p}}function Hs({rowIds:e,defaultHeight:a=48,minHeight:s=32,maxHeight:r=120,storageKey:n,onResize:i,enabled:o=!0}){const[l,d]=t.useState(()=>{if(!o||"undefined"==typeof window)return{};if(n){const e=localStorage.getItem(n);if(e)try{return JSON.parse(e)}catch{}}return{}}),[c,u]=t.useState(!1),[m,h]=t.useState(null),p=t.useRef(0),f=t.useRef(0),x=t.useCallback(e=>l[e]??a,[l,a]),g=t.useCallback((e,t)=>{o&&(t.preventDefault(),t.stopPropagation(),u(!0),h(e),p.current=t.clientY,f.current=l[e]??a)},[o,l,a]);t.useEffect(()=>{if(!c||!m)return;const e=e=>{const t=e.clientY-p.current,a=Math.max(s,Math.min(r,f.current+t));d(e=>{const t={...e,[m]:a};return i?.(t),t})},t=()=>{u(!1),h(null),n&&d(e=>(localStorage.setItem(n,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[c,m,s,r,n,i]),t.useEffect(()=>{c?(document.body.style.cursor="row-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[c]);const b=t.useCallback(()=>{d({}),n&&localStorage.removeItem(n),i?.({})},[n,i]);return{rowHeights:l,isDragging:c,activeRow:m,handleMouseDown:g,resetHeights:b,getRowHeight:x}}const Bs=t.memo(({checked:t,onCheckedChange:a})=>e.jsx(vt,{checked:t,onCheckedChange:a}),(e,t)=>e.checked===t.checked),Ws=({manager:a,columns:s,onEdit:r,onView:n,onToggleStatus:i,onDelete:o,renderActions:l,customRowActions:c,enableBulkActions:u=!1,onNew:m,newButtonLabel:h,showNewButton:p=!0,customActions:f=[],hideActionBar:x=!1,enableColumnResize:g=!0,resizeStorageKey:b})=>{const{t:w}=v.useTranslation(),{setSearchVisible:N}=ls(),[y,j]=t.useState(!1);t.useEffect(()=>(N(!0),()=>N(!1)),[N]),t.useEffect(()=>{const e=()=>j(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const{columnWidths:C,isDragging:k,activeColumn:S,handleMouseDown:T}=qs({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:b?`${b}-columns`:void 0,enabled:g}),{isDragging:P,activeRow:M,handleMouseDown:I,getRowHeight:A}=Hs({rowIds:a.entities.map(e=>e.id),storageKey:b?`${b}-rows`:void 0,enabled:!1}),E=t.useMemo(()=>(()=>{if(g)return s.map(e=>{const t=C[String(e.key)]??e.width??e.minWidth??150;return{...e,calculatedWidth:t,style:{width:`${t}px`}}});let e=0;const t=s.map(t=>{if(t.width)return e+=t.width,{...t,calculatedWidth:t.width,isFixed:!0};{const a=t.minWidth||120,s=t.weight||1;return e+=a,{...t,calculatedWidth:a,weight:s,isFixed:!1}}});return e+=50,t.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})(),[s,g,C]),D=!x&&(m||f.length>0);return y?a.isLoading?e.jsx(vs,{count:3}):0===a.entities.length?e.jsx(Ns,{title:w("empty_title"),description:w("empty_description"),variant:"search"}):e.jsxs("div",{className:"flex flex-col h-full",children:[D&&e.jsx("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[m&&p&&e.jsxs(Ie,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),h||w("new")]}),f.map((t,a)=>{const s=t.icon;return e.jsxs(Ie,{onClick:t.action,variant:t.variant||"outline",children:[s&&e.jsx(s,{size:16,className:"mr-2"}),t.label]},a)})]})}),e.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:a.entities.map(t=>e.jsxs(Cs,{children:[e.jsx(ks,{asChild:!0,children:e.jsx(Re,{className:Te("overflow-hidden cursor-pointer hover:bg-muted/50",u&&a.selectedIds.includes(t.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),u?a.selectItem(t.id):r?.(t)},children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[u&&e.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e.jsx(Bs,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),e.jsxs("div",{className:"flex-1",children:[s.map(a=>e.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[a.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:a.render?a.render(t):String(t[a.key]??"")})]},String(a.key))),(r||n||l)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(t):e.jsx(Us,{onEdit:r?()=>{r(t)}:void 0,onDelete:o?()=>o(t):void 0,onToggleStatus:i?()=>i(t):void 0,isActive:t.is_actived,customActions:c?c(t):[]})})]})]})})})}),e.jsx(Es,{className:"w-[160px]",children:e.jsx(Os,{onEdit:r?()=>r(t):void 0,onDelete:o?()=>o(t):void 0,onToggleStatus:i?()=>i(t):void 0,isActive:t.is_actived,canDelete:!!o,customActions:c?c(t):[],renderAs:"context"})})]},t.id))})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[D&&e.jsx("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[m&&p&&e.jsxs(Ie,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),h||w("new")]}),f.map((t,a)=>{const s=t.icon;return e.jsxs(Ie,{onClick:t.action,variant:t.variant||"outline",children:[s&&e.jsx(s,{size:16,className:"mr-2"}),t.label]},a)})]})}),a.isLoading?e.jsx(bs,{rows:5,columns:s.length}):e.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs(cs,{className:"table-auto",children:[e.jsxs("colgroup",{children:[u&&e.jsx("col",{style:{width:"50px"}}),E.map((t,a)=>e.jsx("col",{style:t.style},a)),e.jsx("col",{style:{width:"50px"}})]}),e.jsx(us,{children:e.jsxs(ps,{children:[u&&e.jsx(fs,{className:"w-[50px]",children:e.jsx(Bs,{checked:a.isAllSelected,onCheckedChange:a.selectAll})}),s.map(t=>{const s=g&&!1!==t.resizable,r=S===String(t.key);return e.jsxs(fs,{className:Te(t.className,t.sortable&&"cursor-pointer hover:bg-muted/50","relative"),onClick:t.sortable?()=>a.handleSort(String(t.key)):void 0,children:[e.jsxs("div",{className:"flex items-center "+(t.className?.includes("text-center")?"justify-center":""),children:[t.header,t.sortable&&(n=String(t.key),a.sortField!==n?e.jsx(d.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===a.sortDirection?e.jsx(d.ArrowUp,{size:14,className:"ml-1"}):e.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}),s&&e.jsx(js,{direction:"horizontal",onMouseDown:e=>T(String(t.key),e),isDragging:r})]},String(t.key));var n}),e.jsx(fs,{className:"w-[50px] text-center",children:w("actions")})]})}),e.jsx(ms,{children:0===a.entities.length?e.jsx(ps,{children:e.jsx(xs,{colSpan:u?s.length+2:s.length+1,className:"h-32",children:e.jsx(Ns,{title:w("empty_title"),description:w("empty_description"),variant:"search"})})}):a.entities.map(t=>{const n=A(t.id);return t.id,e.jsxs(Cs,{children:[e.jsx(ks,{asChild:!0,children:e.jsxs(ps,{className:Te("cursor-pointer hover:bg-muted/50 relative",u&&a.selectedIds.includes(t.id)&&"bg-muted"),style:n?{height:`${n}px`}:void 0,onClick:e=>{e.stopPropagation(),u?a.selectItem(t.id):r?.(t)},children:[u&&e.jsx(xs,{onClick:e=>e.stopPropagation(),children:e.jsx(Bs,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),s.map(a=>e.jsx(xs,{className:a.className,children:e.jsx(ys,{children:a.render?a.render(t):String(t[a.key]??"")})},String(a.key))),e.jsx(xs,{className:"text-center",children:l?l(t):e.jsx(Us,{onEdit:r?()=>r(t):void 0,onDelete:o?()=>o(t):void 0,onToggleStatus:i?()=>i(t):void 0,isActive:t.is_actived,customActions:c?c(t):[]})})]})}),e.jsx(Es,{className:"w-[160px]",children:e.jsx(Os,{onEdit:r?()=>r(t):void 0,onDelete:o?()=>o(t):void 0,onToggleStatus:i?()=>i(t):void 0,isActive:t.is_actived,canDelete:!!o,customActions:c?c(t):[],renderAs:"context"})})]},t.id)})})]})})})]})};function Vs(e,a,s,r){const[n,i]=t.useState({}),[o,l]=t.useState({}),d=t.useMemo(()=>e,[e]),c=e=>e instanceof Date&&!isNaN(e.getTime()),u=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},m=(e,t)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(t)}catch(a){return u(e)}},h=(e,t,a)=>{if(e.required&&(""===t||null==t||Array.isArray(t)&&0===t.length))return`${e.label} é obrigatório`;if(e.validation){let r;if("function"==typeof e.validation?r=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(r=e.validation.custom),r)try{const e=r(t,a);if(e)return e}catch(s){}}};t.useEffect(()=>{if(!r)return;const e=t=>{const a=[];return t.forEach(t=>{a.push(t),t.fields&&a.push(...e(t.fields))}),a},t=e(d),n={};t.forEach(e=>{let t;if(a&&void 0!==a[e.name]){if(t=a[e.name],null==t&&(t=""),"date"===e.type&&t)if("string"==typeof t){const e=new Date(t);c(e)&&(t=e.toISOString().split("T")[0])}else c(t)&&(t=t.toISOString().split("T")[0])}else t=u(e);n[e.name]=t}),t.forEach(e=>{const t=m(e,n);void 0!==t&&(n[e.name]=t)}),a&&Object.keys(a).forEach(e=>{t.find(t=>t.name===e)||void 0===a[e]||(n[e]=a[e])}),i(n),l({}),s&&s(n)},[d,a,s,r]);const p=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...p(e.fields))}),t},f=()=>{const e=p(d),t={};return e.forEach(e=>{const a=h(e,n[e.name],n);a&&(t[e.name]=a)}),l(t),0===Object.keys(t).length};return{formData:n,errors:o,updateField:(e,t)=>{i(a=>{const r={...a,[e]:t},n=((e,t)=>{let a={...t};const s=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...s(e.fields))}),t};return s(d).filter(t=>t.dependsOn===e).forEach(e=>{const t=m(e,a);void 0!==t&&(a={...a,[e.name]:t})}),a})(e,r);return s&&s(n),n}),o[e]&&l(t=>{const a={...t};return delete a[e],a});const a=p(d).find(t=>t.name===e);if(a){const s=h(a,t,n);s&&l(t=>({...t,[e]:s}))}},validateForm:f,handleSubmit:e=>t=>{t&&(t.preventDefault(),t.stopPropagation()),f()&&e(n)}}}const Gs=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Ys=({value:t="#3b82f6",onChange:a,label:s})=>e.jsxs("div",{className:"space-y-2",children:[s&&e.jsx(_e,{children:s}),e.jsxs(Vt,{children:[e.jsx(Gt,{asChild:!0,children:e.jsxs(Ie,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:t}}),t]})}),e.jsx(Yt,{className:"w-64",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"color-input",children:"Cor personalizada"}),e.jsx(Ee,{id:"color-input",type:"color",value:t,onChange:e=>a?.(e.target.value),className:"h-10 w-full"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Cores predefinidas"}),e.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:Gs.map(t=>e.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:t},onClick:()=>a?.(t),"aria-label":`Selecionar cor ${t}`},t))})]})]})})]})]}),Qs=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(de.Root,{ref:r,className:Te("relative overflow-hidden",t),...s,children:[e.jsx(de.Viewport,{className:"h-full w-full rounded-[inherit]",children:a}),e.jsx(Xs,{}),e.jsx(de.Corner,{})]}));Qs.displayName=de.Root.displayName;const Xs=J.forwardRef(({className:t,orientation:a="vertical",...s},r)=>e.jsx(de.ScrollAreaScrollbar,{ref:r,orientation:a,className:Te("flex touch-none select-none transition-colors","vertical"===a&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===a&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...s,children:e.jsx(de.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Xs.displayName=de.ScrollAreaScrollbar.displayName;const Ks={Star:d.Star,Heart:d.Heart,Home:d.Home,User:d.User,Settings:d.Settings,Mail:d.Mail,Phone:d.Phone,Calendar:d.Calendar,MapPin:d.MapPin,Camera:d.Camera,Image:d.Image,Music:d.Music,Video:d.Video,Book:d.Book,Bookmark:d.Bookmark,Search:d.Search,Filter:d.Filter,Edit:d.Edit,Trash2:d.Trash2,Plus:d.Plus,Minus:d.Minus,Check:d.Check,X:d.X,ChevronDown:d.ChevronDown,ChevronUp:d.ChevronUp,ChevronLeft:d.ChevronLeft,ChevronRight:d.ChevronRight,ArrowUp:d.ArrowUp,ArrowDown:d.ArrowDown,ArrowLeft:d.ArrowLeft,ArrowRight:d.ArrowRight,Clock:d.Clock,Bell:d.Bell,AlertCircle:d.AlertCircle,Info:d.Info,HelpCircle:d.HelpCircle,Download:d.Download,Upload:d.Upload,Share:d.Share,Copy:d.Copy,Save:d.Save,FileText:d.FileText,Folder:d.Folder,FolderOpen:d.FolderOpen,Archive:d.Archive,Lock:d.Lock,Unlock:d.Unlock,Eye:d.Eye,EyeOff:d.EyeOff,Shield:d.Shield,Key:d.Key,Zap:d.Zap,Flame:d.Flame,Sparkles:d.Sparkles,Award:d.Award,Trophy:d.Trophy,Target:d.Target},Zs=({value:a="Star",onChange:s,label:r})=>{const{t:n}=v.useTranslation(),[i,o]=t.useState(""),l=Object.entries(Ks).filter(([e])=>e.toLowerCase().includes(i.toLowerCase())),c=Ks[a]||d.Star;return e.jsxs("div",{className:"space-y-2",children:[r&&e.jsx(_e,{children:r}),e.jsxs(Vt,{children:[e.jsx(Gt,{asChild:!0,children:e.jsxs(Ie,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx(c,{className:"h-4 w-4 mr-2"}),a]})}),e.jsx(Yt,{className:"w-80",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"icon-search",children:n("search")}),e.jsx(Ee,{id:"icon-search",placeholder:n("search"),value:i,onChange:e=>o(e.target.value)})]}),e.jsx(Qs,{className:"h-48",children:e.jsx("div",{className:"grid grid-cols-6 gap-2",children:l.map(([t,r])=>e.jsx("button",{className:"p-2 rounded border-2 hover:border-primary "+(a===t?"border-primary bg-primary/10":"border-border"),onClick:()=>s?.(t),title:t,children:e.jsx(r,{className:"h-4 w-4"})},t))})})]})})]})]})},Js=J.forwardRef(({className:t,...a},s)=>e.jsx(ce.Root,{className:Te("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...a,ref:s,children:e.jsx(ce.Thumb,{className:Te("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Js.displayName=ce.Root.displayName;const er=(e={})=>{const{user:t,alias:a}=ls(),{enabled:s=!0}=e;return N.useQuery({queryKey:["qualiex-users",a],queryFn:()=>za.getUsers(a),enabled:s&&!!a&&!!t,retry:2,retryDelay:1e3})},tr=({value:a,onChange:s,multiple:r=!1,label:n,required:i,placeholder:o,icon:l,maxDisplayedBadges:d,className:c,disabled:u,enabled:m,displayFormat:h="name",customDisplayFn:p,filterFn:f,sortOptions:x=!0,popoverContainer:g,onOpen:b,onClose:w})=>{const{t:N}=v.useTranslation(),{data:y=[],isLoading:j,error:C}=er({enabled:m}),k=t.useMemo(()=>f?y.filter(f):y,[y,f]),S=t.useCallback(e=>{if("custom"===h&&p)return p(e);const t=e.userName||e.displayName||"";switch(h){case"name-email":return e.userEmail?`${t} (${e.userEmail})`:t;case"name-role":return e.roleName?`${t} - ${e.roleName}`:t;default:return t}},[h,p]);return e.jsx(ia,{multiple:r,value:a??(r?[]:""),onChange:s,options:k,isLoading:j,error:C,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:S,placeholder:o||N("search_placeholder"),searchPlaceholder:N("search_placeholder"),emptyMessage:N("no_results"),label:n,required:i,icon:l,maxDisplayedBadges:d,disabled:u,className:c,sortOptions:x,popoverContainer:g,onOpen:b,onClose:w})};function ar({title:a,sections:s,initialData:r,onSubmit:n,onCancel:i,open:o,submitButtonText:l,isLoading:d=!1,usersData:c}){const{t:u}=v.useTranslation(),[m,h]=t.useState(s?.[0]?.id||""),p=t.useRef(null),[f,x]=t.useState(null),g=t.useCallback(e=>{p.current=e,x(e)},[]),b=t.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:w,errors:N,updateField:y,handleSubmit:j}=Vs(b,r,void 0,o),C=t.useMemo(()=>s&&Array.isArray(s)?s.map(e=>({...e,disabled:e.condition?!e.condition(w):e.disabled||!1})):[],[s,w]),k=t.useMemo(()=>{const e=C.find(e=>e.id===m);if(e&&!e.disabled)return m;const t=C.find(e=>!e.disabled);return t?.id||m},[C,m]);t.useEffect(()=>{k!==m&&h(k)},[k,m]);const S=C.find(e=>e.id===k),T=t=>{const a=(t.computedValue,w[t.name]),s=void 0!==a?a:"",r=N[t.name];switch(t.type){case"group":const a="horizontal"===t.layout,n=a?`flex gap-3 w-full ${t.className||""}`:"space-y-3",i=a?Te("space-y-2 w-full",t.wrapperClassName):Te("space-y-2",t.className,t.wrapperClassName);return e.jsxs("div",{className:i,children:[t.label,e.jsx("div",{className:n,children:t.fields?.map(e=>T(e))})]},t.name);case"user-select":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(_e,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(tr,{value:s||"",onChange:e=>y(t.name,e),placeholder:t.placeholder,disabled:t.disabled,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"textarea":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(_e,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(wt,{id:t.name,value:s||"",onChange:e=>{y(t.name,e.target.value)},placeholder:t.placeholder,disabled:t.disabled,rows:t.rows,maxLength:t.maxLength,className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"select":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(_e,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(dt,{value:String(s),onValueChange:e=>{y(t.name,e),t.onValueChange&&t.onValueChange(e)},disabled:t.disabled,children:[e.jsx(mt,{className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,children:e.jsx(ut,{placeholder:t.placeholder})}),e.jsx(ft,{children:t.options?.map(t=>e.jsx(gt,{value:t.value,children:t.label},t.value))})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"multiselect":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(_e,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ia,{options:t.options||[],value:Array.isArray(s)?s:[],onChange:e=>y(t.name,e),placeholder:t.placeholder,disabled:t.disabled,error:r,popoverContainer:f,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"date":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(_e,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:t.name,type:"date",value:String(s),onChange:e=>y(t.name,e.target.value),placeholder:t.placeholder,disabled:t.disabled,className:Te("w-full",r?"border-destructive":"",t.disabled?"bg-muted cursor-not-allowed":"")}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"color":return e.jsxs("div",{children:[e.jsxs(_e,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:t.name,type:"color",value:s||t.defaultValue||"#000000",onChange:e=>y(t.name,e.target.value),className:"h-10"}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},t.name);case"color-picker":return e.jsxs("div",{children:[e.jsxs(_e,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ys,{value:s||t.defaultValue||"#3b82f6",onChange:e=>y(t.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},t.name);case"icon-picker":return e.jsxs("div",{children:[e.jsxs(_e,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Zs,{value:s||t.defaultValue||"Star",onChange:e=>y(t.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},t.name);case"custom":if(!t.component)return null;const o=t.component,l="function"==typeof t.componentProps?t.componentProps(w):t.componentProps||{};return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[t.label&&e.jsxs(_e,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(o,{value:s,onChange:e=>{y(t.name,e),t.onValueChange&&t.onValueChange(e)},disabled:t.disabled,error:r,popoverContainer:f,...l}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"number":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(_e,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:t.name,type:"number",value:null!=s?String(s):"",onChange:e=>{const a=e.target.value,s=""===a?null:Number(a);y(t.name,s)},placeholder:t.placeholder,disabled:t.disabled,className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,min:t.min,step:t.step||"1"}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"checkbox":return e.jsxs("div",{className:`flex items-center space-x-2 ${t.className||""}`,children:[e.jsx(vt,{id:t.name,checked:!!s,onCheckedChange:e=>y(t.name,e),disabled:t.disabled}),e.jsxs(_e,{htmlFor:t.name,className:"cursor-pointer",children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"switch":return e.jsxs("div",{className:`flex items-center justify-between space-x-2 ${t.className||""}`,children:[e.jsxs(_e,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Js,{id:t.name,checked:!!s,onCheckedChange:e=>y(t.name,e),disabled:t.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:r})]},t.name);default:return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(_e,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:t.name,type:"text",value:s||"",onChange:e=>{y(t.name,e.target.value)},placeholder:t.placeholder,disabled:t.disabled,className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:t.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name)}},P=t.useCallback(()=>{if(!S)return null;if(S.disabled)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:e.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),e.jsx("p",{className:"text-muted-foreground max-w-sm",children:'Complete as informações obrigatórias na seção "Informações Gerais" para acessar esta seção.'})]});if(S.component){const t=S.component;return e.jsx(t,{formData:w,updateField:y,errors:N,users:c,disabled:S.disabled})}return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:S.fields.map(T)})},[S,w,y,N,c,T]),M=e.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[C.length>1&&e.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:e.jsx("div",{className:"flex space-x-2",children:C.map(t=>e.jsx(Ie,{variant:k===t.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const t=C.find(t=>t.id===e);t&&!t.disabled&&h(e)})(t.id),disabled:t.disabled,className:t.disabled?"opacity-50 cursor-not-allowed":"",children:t.title},t.id))})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 py-4",children:d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"text-muted-foreground",children:u("loading")})}):e.jsxs("form",{onSubmit:j(n),className:"space-y-3 md:space-y-4",children:[P(),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(Ie,{type:"button",variant:"outline",onClick:i,children:u("cancel")}),e.jsx(Ie,{type:"submit",disabled:d,children:l||u("save")})]})]})})]});return e.jsx(qe,{open:o,onOpenChange:e=>{!1===e&&!0===o&&i()},children:e.jsxs(Ye,{ref:g,className:"max-w-4xl max-h-[90vh] overflow-visible",children:[e.jsxs(Qe,{showSeparator:!0,children:[e.jsx(Ze,{children:a}),e.jsx(Je,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),M]})})}function sr({currentPage:t,totalPages:a,totalItems:s,itemsPerPage:r,onPageChange:n,onItemsPerPageChange:i,variant:o="full"}){const l=(t-1)*r+1,c=Math.min(t*r,s);return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:"full"===o&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Itens por página"}),e.jsxs(dt,{value:String(r),onValueChange:e=>i(Number(e)),children:[e.jsx(mt,{className:"h-8 w-[70px]",children:e.jsx(ut,{})}),e.jsxs(ft,{children:[e.jsx(gt,{value:"10",children:"10"}),e.jsx(gt,{value:"25",children:"25"}),e.jsx(gt,{value:"50",children:"50"}),e.jsx(gt,{value:"100",children:"100"})]})]})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[l,"-",c," de ",s," itens"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ie,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===t,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronsLeft,{size:16})}),e.jsx(Ie,{variant:"outline",size:"sm",onClick:()=>n(t-1),disabled:1===t,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronLeft,{size:16})}),e.jsxs("div",{className:"flex items-center gap-1 px-2",children:[e.jsx("span",{className:"text-sm font-medium",children:t}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"de"}),e.jsx("span",{className:"text-sm font-medium",children:a})]}),e.jsx(Ie,{variant:"outline",size:"sm",onClick:()=>n(t+1),disabled:t===a,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronRight,{size:16})}),e.jsx(Ie,{variant:"outline",size:"sm",onClick:()=>n(a),disabled:t===a,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronsRight,{size:16})})]})]})}function rr({manager:t}){return e.jsx(sr,{currentPage:t.pagination.currentPage,totalPages:t.pagination.totalPages,totalItems:t.pagination.totalItems,itemsPerPage:t.pagination.itemsPerPage,onPageChange:t.handlePageChange,onItemsPerPageChange:t.handleItemsPerPageChange,variant:"full"})}const nr=({selectedCount:t,onClearSelection:a,onBulkDelete:s,customActions:r=[],isLoading:n=!1})=>{const{t:i}=v.useTranslation();return e.jsx($t,{delayDuration:200,children:e.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium",children:i("selected_count",{count:t})}),e.jsxs(Ie,{variant:"ghost",size:"sm",onClick:a,className:"h-7 px-2",children:[e.jsx(d.X,{size:14,className:"mr-1"}),i("clear")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[r.map((t,a)=>{const s=t.icon,r=n||t.disabled,i=e.jsxs(Ie,{variant:t.variant||"outline",size:"sm",onClick:()=>!t.disabled&&t.action([]),disabled:r,className:"h-7",children:[s&&e.jsx(s,{size:14,className:"mr-1"}),t.label]},a);return t.disabled&&t.disabledReason?e.jsxs(qt,{children:[e.jsx(Ht,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:i})}),e.jsx(Bt,{className:"max-w-[200px]",children:t.disabledReason})]},a):i}),s&&e.jsxs(Ie,{variant:"destructive",size:"sm",onClick:s,disabled:n,className:"h-7",children:[e.jsx(d.Trash2,{size:14,className:"mr-1"}),i("delete")]})]})]})})},ir={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},or={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},lr={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function dr({children:t,direction:a="column",gap:s="md",align:r="stretch",justify:n="start",wrap:i=!1,className:o}){return e.jsx("div",{className:Te("flex","column"===a?"flex-col":"flex-row",ir[s],or[r],lr[n],i&&"flex-wrap",o),children:t})}function cr({manager:t,filters:a,inline:s=!1}){const{t:r}=v.useTranslation(),{isSearchVisible:n}=ls(),i=t.searchTerm,o=e.jsxs(e.Fragment,{children:[a.some(e=>"search"===e.type)&&!n&&e.jsxs("div",{className:"relative flex-1",children:[e.jsx(d.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Ee,{placeholder:r("search"),value:t.searchTerm,onChange:e=>t.handleSearch(e.target.value),className:"pl-10"})]}),a.filter(e=>"select"===e.type&&e.options).map((t,a)=>e.jsxs("select",{value:t.value||"",onChange:e=>t.onChange?.(e.target.value),className:"h-10 px-3 rounded-md border border-input bg-background text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[t.placeholder&&e.jsx("option",{value:"",children:t.placeholder}),t.options.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))]},`select-${a}`)),a.filter(e=>"custom"===e.type&&e.component).map((t,a)=>{const r=t.component;return e.jsx("div",{className:s?"":"w-full sm:w-auto",children:e.jsx(r,{...t.props})},`custom-${a}`)}),i&&e.jsxs(Ie,{variant:"outline",onClick:t.clearFilters,className:"whitespace-nowrap",children:[e.jsx(d.X,{className:"h-4 w-4 mr-2"}),r("clear")]})]});return s?e.jsx("div",{className:"flex items-center gap-2",children:o}):e.jsx(dr,{direction:"column",gap:"md",className:"mb-6",children:e.jsx(dr,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:o})})}function ur({manager:a,config:s,formSections:r,onSave:n,onToggleStatus:i,defaultSort:o}){a&&a.queryKey;const{t:l}=v.useTranslation(),{setSearchVisible:c}=ls(),[u,m]=y.useSearchParams(),[h,p]=t.useState(!1),[f,x]=t.useState(null),[g,b]=t.useState({isOpen:!1,entityId:null,entityName:""}),[w,N]=t.useState({isOpen:!1,count:0});t.useEffect(()=>(c(!0),()=>{c(!1)}),[c]),t.useEffect(()=>{if(o&&a){const e=`${a.queryKey}_sortField`,t=`${a.queryKey}_sortDirection`;if(!u.has(e)&&!u.has(t)){const a=Object.fromEntries(u);a[e]=o.column,a[t]=o.direction,m(a)}}},[]);const j=r.length>0?e=>{s.onEdit?s.onEdit(e):(x(e),p(!0))}:void 0,C="function"==typeof a?.deleteEntity?e=>{b({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})}:void 0,k=()=>{b({isOpen:!1,entityId:null,entityName:""})};return e.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[s.enableBulkActions&&a.selectedIds.length>0&&e.jsx(nr,{selectedCount:a.selectedIds.length,onClearSelection:a.clearSelection,onBulkDelete:s.bulkActions&&s.bulkActions.length>0?void 0:()=>{N({isOpen:!0,count:a.selectedIds.length})},customActions:s.bulkActions,isLoading:a.isBulkDeleting}),e.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[!s.hideNewButton&&e.jsxs(Ie,{onClick:()=>{s.onNew?s.onNew():(x(null),p(!0))},children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),l("new")]}),s.customActions?.map((t,a)=>e.jsxs(Ie,{onClick:t.action,variant:t.variant||"outline",children:[t.icon&&e.jsx(t.icon,{size:16,className:"mr-2"}),t.label]},a))]}),s.filters&&s.filters.length>0&&e.jsx("div",{className:"flex items-center gap-2 flex-1 justify-end",children:e.jsx(cr,{manager:a,filters:s.filters,inline:!0})})]}),e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:s.customListView?e.jsx("div",{className:"flex-1 overflow-auto p-4",children:s.customListView(a.entities,a)}):e.jsx(Ws,{manager:a,columns:s.columns,onEdit:j,onDelete:C,onToggleStatus:i,enableBulkActions:s.enableBulkActions,customRowActions:s.customRowActions})}),e.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:e.jsx(rr,{manager:a})}),!s.useCustomRouting&&!s.onNew&&r.length>0&&e.jsx(ar,{open:h,title:f?`Editar ${s.entityName}`:`Novo ${s.entityName}`,sections:r,initialData:f||void 0,onSubmit:e=>{n(e),p(!1),x(null)},onCancel:()=>{p(!1),x(null)},isLoading:a.isLoading,submitButtonText:l(f?"update":"create")}),e.jsx(qe,{open:g.isOpen,onOpenChange:k,children:e.jsxs(Ye,{size:"sm",children:[e.jsx(Qe,{showSeparator:!0,children:e.jsx(Ze,{children:"Você tem certeza absoluta?"})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e.jsx("strong",{children:g.entityName}),". Esta ação não pode ser desfeita."]})}),e.jsxs(Ke,{children:[e.jsx(Ie,{variant:"outline",onClick:k,children:"Cancelar"}),e.jsx(Ie,{variant:"destructive",onClick:()=>{g.entityId&&"function"==typeof a?.deleteEntity&&(a.deleteEntity(g.entityId),b({isOpen:!1,entityId:null,entityName:""}))},disabled:a.isDeleting,children:a.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),e.jsx(qe,{open:w.isOpen,onOpenChange:()=>N({isOpen:!1,count:0}),children:e.jsxs(Ye,{size:"sm",children:[e.jsx(Qe,{showSeparator:!0,children:e.jsx(Ze,{children:"Você tem certeza absoluta?"})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e.jsx("strong",{children:w.count})," ",1===w.count?s.entityName:s.entityNamePlural,". Esta ação não pode ser desfeita."]})}),e.jsxs(Ke,{children:[e.jsx(Ie,{variant:"outline",onClick:()=>N({isOpen:!1,count:0}),children:"Cancelar"}),e.jsx(Ie,{variant:"destructive",onClick:()=>{a.bulkDelete?.(a.selectedIds),N({isOpen:!1,count:0})},disabled:a.isBulkDeleting,children:a.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function mr(e,t){const a=e.toLowerCase();return a.includes("email")?{type:"email",required:!0}:a.includes("phone")||a.includes("tel")?{type:"tel"}:a.includes("description")||a.includes("content")||a.includes("notes")?{type:"textarea"}:a.includes("status")||a.includes("type")||a.includes("category")?{type:"select",options:[]}:"boolean"==typeof t?{type:"boolean"}:"number"==typeof t?{type:"number"}:t instanceof Date?{type:"date"}:{type:"text"}}function hr(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const pr=s.cva("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4",{variants:{variant:{info:"bg-[hsl(var(--alert-info-bg))] border-[hsl(var(--alert-info-border))] text-[hsl(var(--alert-info-foreground))] [&>svg]:text-[hsl(var(--alert-info-foreground))]",warning:"bg-[hsl(var(--alert-warning-bg))] border-[hsl(var(--alert-warning-border))] text-[hsl(var(--alert-warning-foreground))] [&>svg]:text-[hsl(var(--alert-warning-foreground))]",danger:"bg-[hsl(var(--alert-danger-bg))] border-[hsl(var(--alert-danger-border))] text-[hsl(var(--alert-danger-foreground))] [&>svg]:text-[hsl(var(--alert-danger-foreground))]",success:"bg-[hsl(var(--alert-success-bg))] border-[hsl(var(--alert-success-border))] text-[hsl(var(--alert-success-foreground))] [&>svg]:text-[hsl(var(--alert-success-foreground))]"}},defaultVariants:{variant:"info"}}),fr={info:d.Info,warning:d.Info,danger:d.AlertTriangle,success:d.CheckCircle},xr=J.forwardRef(({className:t,variant:a="info",showIcon:s=!0,children:r,...n},i)=>{const o=fr[a||"info"];return e.jsxs("div",{ref:i,role:"alert",className:Te(pr({variant:a}),t),...n,children:[s&&e.jsx(o,{className:"h-4 w-4"}),r]})});xr.displayName="Alert";const gr=J.forwardRef(({className:t,...a},s)=>e.jsx("h5",{ref:s,className:Te("mb-1 font-medium leading-none tracking-tight",t),...a}));gr.displayName="AlertTitle";const br=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("text-sm [&_p]:leading-relaxed",t),...a}));br.displayName="AlertDescription";const vr=t.createContext(void 0);function wr({children:a,actions:s}){const[r,n]=t.useState({}),[i,o]=t.useState(s);return t.useEffect(()=>{o(s)},[s]),e.jsx(vr.Provider,{value:{metadata:r,setMetadata:n,clearMetadata:()=>n({}),headerActions:i,setHeaderActions:o},children:a})}function Nr(){const e=t.useContext(vr);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}const yr=(void 0).VITE_SUPABASE_URL,jr=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;let Cr=null;var kr=Object.defineProperty,Sr=(e,t,a)=>((e,t,a)=>t in e?kr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const Tr=new class{constructor(){Sr(this,"cache",{}),Sr(this,"cacheTimestamps",new Map),Sr(this,"CACHE_TTL",3e5),Sr(this,"loadingPromises",new Map)}isCacheValid(e){const t=this.cacheTimestamps.get(e);return!!t&&Date.now()-t<this.CACHE_TTL}async loadTranslations(e){if(this.isCacheValid(e))return this.cache[e]||{};const t=this.loadingPromises.get(e);if(t)return t;const a=this.fetchTranslations(e);this.loadingPromises.set(e,a);try{return await a}finally{this.loadingPromises.delete(e)}}async fetchTranslations(e){try{const t=(!Cr&&yr&&jr&&(Cr=w.createClient(yr,jr,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1}})),Cr),{data:a,error:s}=await t.schema("common").from("translations").select("key, pt, en, es").eq("is_removed",!1);if(s)return"42501"===s.code||"PGRST301"===s.code||s.message?.includes("permission denied")||s.message?.includes("No suitable key"),{};const r={};return a?.forEach(t=>{let a;a="pt-BR"===e?t.pt:"en-US"===e?t.en||t.pt:"es-ES"===e&&t.es||t.pt,a&&(r[t.key]=a)}),this.cache[e]=r,this.cacheTimestamps.set(e,Date.now()),r}catch(t){return{}}}async upsertTranslation(e,t,a,s){const r=Sa(),{error:n}=await r.schema("common").from("translations").upsert({key:e,pt:t,en:a,es:s},{onConflict:"key"});if(n)throw n;this.clearCache()}async bulkUpsertTranslations(e){const t=Sa(),{error:a}=await t.schema("common").from("translations").upsert(e.map(e=>({key:e.key,pt:e.pt,en:e.en,es:e.es})),{onConflict:"key"});if(a)throw a;this.clearCache()}clearCache(){this.cache={},this.cacheTimestamps.clear()}clearCacheForLocale(e){delete this.cache[e],this.cacheTimestamps.delete(e)}};var Pr=Object.defineProperty,Mr=(e,t,a)=>((e,t,a)=>t in e?Pr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const Ir="true"===(void 0).VITE_I18N_DEBUG_MODE;o.use(new class{constructor(e=!1){Mr(this,"type","backend"),Mr(this,"isDebugMode"),Mr(this,"cache",new Map),Mr(this,"loadingPromises",new Map),this.isDebugMode=e}read(e,t,a){if(this.cache.has(e))return void a(null,this.cache.get(e));if(this.loadingPromises.has(e))return void this.loadingPromises.get(e).then(()=>{a(null,this.cache.get(e)||{})});const s=Tr.loadTranslations(e).then(t=>{if(this.isDebugMode){const a={};Object.keys(t).forEach(e=>{a[e]=`[${e} ✅]`}),this.cache.set(e,a)}else this.cache.set(e,t)}).catch(t=>{this.cache.set(e,{})}).finally(()=>{this.loadingPromises.delete(e)});this.loadingPromises.set(e,s),s.then(()=>{a(null,this.cache.get(e)||{})})}create(e,t,a,s){}}(Ir)).use(v.initReactI18next).init({fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"translations",ns:["translations"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:(e,t)=>Ir?`[${e} ❌]`:`[⚠️ ${e}]`});const Ar=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],Er=[{value:"dd/MM/yyyy HH:mm",label:"dd/MM/yyyy HH:mm",example:"28/11/2024 14:30",description:"Padrão Brasileiro"},{value:"MM/dd/yyyy hh:mm a",label:"MM/dd/yyyy hh:mm a",example:"11/28/2024 02:30 PM",description:"Padrão Americano (12h)"},{value:"MM/dd/yyyy HH:mm",label:"MM/dd/yyyy HH:mm",example:"11/28/2024 14:30",description:"Padrão Americano (24h)"},{value:"yyyy-MM-dd HH:mm",label:"yyyy-MM-dd HH:mm",example:"2024-11-28 14:30",description:"ISO 8601"},{value:"dd.MM.yyyy HH:mm",label:"dd.MM.yyyy HH:mm",example:"28.11.2024 14:30",description:"Padrão Europeu"},{value:"d MMM yyyy, HH:mm",label:"d MMM yyyy, HH:mm",example:"28 Nov 2024, 14:30",description:"Formato Longo"}],Dr=[{value:"America/Sao_Paulo",label:"Brasília (UTC-3)",offset:"-03:00"},{value:"America/Noronha",label:"Fernando de Noronha (UTC-2)",offset:"-02:00"},{value:"America/Manaus",label:"Manaus (UTC-4)",offset:"-04:00"},{value:"America/Rio_Branco",label:"Rio Branco (UTC-5)",offset:"-05:00"},{value:"America/Buenos_Aires",label:"Buenos Aires (UTC-3)",offset:"-03:00"},{value:"America/Santiago",label:"Santiago (UTC-4)",offset:"-04:00"},{value:"America/Bogota",label:"Bogotá (UTC-5)",offset:"-05:00"},{value:"America/Mexico_City",label:"Cidade do México (UTC-6)",offset:"-06:00"},{value:"America/New_York",label:"New York (UTC-5)",offset:"-05:00"},{value:"America/Chicago",label:"Chicago (UTC-6)",offset:"-06:00"},{value:"America/Denver",label:"Denver (UTC-7)",offset:"-07:00"},{value:"America/Los_Angeles",label:"Los Angeles (UTC-8)",offset:"-08:00"},{value:"America/Toronto",label:"Toronto (UTC-5)",offset:"-05:00"},{value:"America/Vancouver",label:"Vancouver (UTC-8)",offset:"-08:00"},{value:"Europe/London",label:"Londres (UTC+0)",offset:"+00:00"},{value:"Europe/Lisbon",label:"Lisboa (UTC+0)",offset:"+00:00"},{value:"Europe/Paris",label:"Paris (UTC+1)",offset:"+01:00"},{value:"Europe/Berlin",label:"Berlim (UTC+1)",offset:"+01:00"},{value:"Europe/Madrid",label:"Madrid (UTC+1)",offset:"+01:00"},{value:"Europe/Rome",label:"Roma (UTC+1)",offset:"+01:00"},{value:"Europe/Amsterdam",label:"Amsterdã (UTC+1)",offset:"+01:00"},{value:"Europe/Moscow",label:"Moscou (UTC+3)",offset:"+03:00"},{value:"Asia/Dubai",label:"Dubai (UTC+4)",offset:"+04:00"},{value:"Asia/Kolkata",label:"Mumbai (UTC+5:30)",offset:"+05:30"},{value:"Asia/Singapore",label:"Singapura (UTC+8)",offset:"+08:00"},{value:"Asia/Hong_Kong",label:"Hong Kong (UTC+8)",offset:"+08:00"},{value:"Asia/Shanghai",label:"Xangai (UTC+8)",offset:"+08:00"},{value:"Asia/Tokyo",label:"Tóquio (UTC+9)",offset:"+09:00"},{value:"Asia/Seoul",label:"Seul (UTC+9)",offset:"+09:00"},{value:"Australia/Perth",label:"Perth (UTC+8)",offset:"+08:00"},{value:"Australia/Sydney",label:"Sydney (UTC+10)",offset:"+10:00"},{value:"Pacific/Auckland",label:"Auckland (UTC+12)",offset:"+12:00"},{value:"UTC",label:"UTC (UTC+0)",offset:"+00:00"}],_r="pt-BR",Rr="dd/MM/yyyy HH:mm",zr="America/Sao_Paulo",Fr=e=>Ar.some(t=>t.value===e),Lr=e=>Dr.some(t=>t.value===e),Or=()=>{if("undefined"==typeof navigator)return _r;const e=navigator.language;if(Fr(e))return e;const t=e.split("-")[0],a=Ar.find(e=>e.value.startsWith(t));return a?.value||_r},Ur=()=>{if("undefined"==typeof Intl)return zr;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;return Lr(e)?e:zr}catch{return zr}},$r=e=>({"pt-BR":"dd/MM/yyyy HH:mm","en-US":"MM/dd/yyyy hh:mm a","es-ES":"dd/MM/yyyy HH:mm"}[e]||Rr),qr=()=>{const e=Or();return{locale:e,timezone:Ur(),datetimeFormat:$r(e)}};const Hr=new class{async getUserPreferences(e){if(!xa.areAllTokensValid())return null;const t=Sa();try{const{data:a,error:s}=await t.schema("common").from("user_preferences").select("*").eq("id_user",e).maybeSingle();if(s)return"PGRST116"===s.code?this.createDefaultPreferences(e):("42501"===s.code||"PGRST301"===s.code||s.message?.includes("permission denied"),null);if(!a)return this.createDefaultPreferences(e);const r=a;return{locale:r.locale,timezone:r.timezone,datetimeFormat:r.datetime_format}}catch(a){return null}}async createDefaultPreferences(e){const t=Sa(),a=qr(),s={id_user:e,locale:a.locale,timezone:a.timezone,datetime_format:a.datetimeFormat};try{const{data:e,error:a}=await t.schema("common").from("user_preferences").insert(s).select().single();if(a)throw a;const r=e;return{locale:r.locale,timezone:r.timezone,datetimeFormat:r.datetime_format}}catch(r){throw r}}async updatePreferences(e,t){const a=Sa();try{const{error:s}=await a.schema("common").from("user_preferences").update(t).eq("id_user",e);if(s)throw s}catch(s){throw s}}},Br=t.createContext(void 0),Wr=()=>qr(),Vr=({children:a})=>{const{user:s}=ls(),[r,n]=t.useState(Wr),[i,l]=t.useState(!0);t.useEffect(()=>{(async()=>{if(s?.id)try{const e=await Hr.getUserPreferences(s.id);e&&(n({locale:e.locale,timezone:e.timezone,datetimeFormat:e.datetimeFormat}),await o.changeLanguage(e.locale),localStorage.setItem("i18nextLng",e.locale))}catch(e){}finally{l(!1)}else l(!1)})()},[s?.id]);const d=t.useCallback(async e=>{if(s?.id)try{await Hr.updatePreferences(s.id,{locale:e}),n(t=>({...t,locale:e})),await o.changeLanguage(e),localStorage.setItem("i18nextLng",e)}catch(t){throw t}},[s?.id]),c=t.useCallback(async e=>{if(s?.id)try{await Hr.updatePreferences(s.id,{timezone:e}),n(t=>({...t,timezone:e}))}catch(t){throw t}},[s?.id]),u=t.useCallback(async e=>{if(s?.id)try{await Hr.updatePreferences(s.id,{datetime_format:e}),n(t=>({...t,datetimeFormat:e}))}catch(t){throw t}},[s?.id]);return e.jsx(Br.Provider,{value:{...r,setLocale:d,setTimezone:c,setDatetimeFormat:u,isLoading:i},children:a})},Gr=()=>{const e=t.useContext(Br);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e};function Yr({children:a}){const{ready:s}=v.useTranslation(),[r,n]=t.useState(!0);return t.useEffect(()=>{s&&r&&n(!1)},[s,r]),r&&!s?e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-background",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(Ct,{size:"lg"}),e.jsx("p",{className:"text-sm text-muted-foreground animate-pulse",children:"Carregando traduções..."})]})}):e.jsx(e.Fragment,{children:a})}const Qr=ue.Root,Xr=ue.CollapsibleTrigger,Kr=ue.CollapsibleContent;var Zr=Object.defineProperty,Jr=(e,t,a)=>((e,t,a)=>t in e?Zr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);class en extends t.Component{constructor(e){super(e),Jr(this,"copyErrorDetails",()=>{const e=va.getErrors().slice(0,2),t=`\n=== ERRO ATUAL ===\n${this.state.error?.message||"Erro desconhecido"}\n\nStack Trace:\n${this.state.error?.stack||"Não disponível"}\n\n=== ÚLTIMOS ERROS ===\n${e.map((e,t)=>`${t+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||"Nenhum erro registrado"}\n `.trim();navigator.clipboard.writeText(t),l.toast.success("Detalhes copiados!",{description:"Os detalhes do erro foram copiados para a área de transferência."})}),this.state={hasError:!1,showDetails:!1}}static getDerivedStateFromError(e){if((void 0).DEV)throw e;return{hasError:!0,error:e}}componentDidCatch(e,t){if((void 0).DEV)throw e;va.handleError(e,!1),this.setState({errorInfo:t})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const t=va.getErrors().slice(0,2);return e.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:e.jsxs(Re,{className:"w-full max-w-2xl",children:[e.jsxs(ze,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(d.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),e.jsx(Fe,{children:"Algo deu errado"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),e.jsxs(Qr,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[e.jsx(Xr,{asChild:!0,children:e.jsxs(Ie,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[e.jsx(d.ChevronDown,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),e.jsxs(Kr,{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),e.jsxs("div",{className:"text-sm space-y-2",children:[e.jsx("p",{className:"font-medium text-destructive",children:this.state.error?.message||"Erro desconhecido"}),this.state.error?.stack&&e.jsx(Qs,{className:"h-32 w-full rounded border bg-muted p-2",children:e.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),t.length>0&&e.jsxs("div",{className:"pt-3 border-t",children:[e.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),e.jsx("div",{className:"space-y-2",children:t.map((t,a)=>e.jsx("div",{className:"text-sm p-2 rounded bg-muted/50",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"font-medium text-muted-foreground shrink-0",children:[a+1,"."]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:e.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",new Date(t.timestamp).toLocaleTimeString(),"]"]})}),e.jsx("p",{className:"text-sm break-words",children:t.message})]})]})},t.id))})]})]}),e.jsxs(Ie,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[e.jsx(d.Copy,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),e.jsx(Ie,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const tn=me.Root,an=J.forwardRef(({className:t,...a},s)=>e.jsx(me.Item,{ref:s,className:Te("border-b",t),...a}));an.displayName="AccordionItem";const sn=J.forwardRef(({className:t,children:a,...s},r)=>e.jsx(me.Header,{className:"flex",children:e.jsxs(me.Trigger,{ref:r,className:Te("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",t),...s,children:[a,e.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));sn.displayName=me.Trigger.displayName;const rn=J.forwardRef(({className:t,children:a,...s},r)=>e.jsx(me.Content,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...s,children:e.jsx("div",{className:Te("pb-4 pt-0",t),children:a})}));rn.displayName=me.Content.displayName;const nn=he.Root,on=he.Trigger,ln=he.Portal,dn=J.forwardRef(({className:t,...a},s)=>e.jsx(he.Overlay,{className:Te("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a,ref:s}));dn.displayName=he.Overlay.displayName;const cn=J.forwardRef(({className:t,...a},s)=>e.jsxs(ln,{children:[e.jsx(dn,{}),e.jsx(he.Content,{ref:s,className:Te("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...a})]}));cn.displayName=he.Content.displayName;const un=({className:t,...a})=>e.jsx("div",{className:Te("flex flex-col space-y-2 text-center sm:text-left",t),...a});un.displayName="AlertDialogHeader";const mn=({className:t,...a})=>e.jsx("div",{className:Te("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a});mn.displayName="AlertDialogFooter";const hn=J.forwardRef(({className:t,...a},s)=>e.jsx(he.Title,{ref:s,className:Te("text-lg font-semibold",t),...a}));hn.displayName=he.Title.displayName;const pn=J.forwardRef(({className:t,...a},s)=>e.jsx(he.Description,{ref:s,className:Te("text-sm text-muted-foreground",t),...a}));pn.displayName=he.Description.displayName;const fn=J.forwardRef(({className:t,...a},s)=>e.jsx(he.Action,{ref:s,className:Te(Me(),t),...a}));fn.displayName=he.Action.displayName;const xn=J.forwardRef(({className:t,...a},s)=>e.jsx(he.Cancel,{ref:s,className:Te(Me({variant:"outline"}),"mt-2 sm:mt-0",t),...a}));xn.displayName=he.Cancel.displayName;const gn=J.forwardRef(({className:t,...a},s)=>e.jsx(pe.Root,{ref:s,className:Te("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...a}));gn.displayName=pe.Root.displayName;const bn=J.forwardRef(({className:t,...a},s)=>e.jsx(pe.Image,{ref:s,className:Te("aspect-square h-full w-full",t),...a}));bn.displayName=pe.Image.displayName;const vn=J.forwardRef(({className:t,...a},s)=>e.jsx(pe.Fallback,{ref:s,className:Te("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...a}));vn.displayName=pe.Fallback.displayName;const wn=J.forwardRef(({...t},a)=>e.jsx("nav",{ref:a,"aria-label":"breadcrumb",...t}));wn.displayName="Breadcrumb";const Nn=J.forwardRef(({className:t,...a},s)=>e.jsx("ol",{ref:s,className:Te("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...a}));Nn.displayName="BreadcrumbList";const yn=J.forwardRef(({className:t,...a},s)=>e.jsx("li",{ref:s,className:Te("inline-flex items-center gap-1.5",t),...a}));yn.displayName="BreadcrumbItem";const jn=J.forwardRef(({asChild:t,className:s,...r},n)=>{const i=t?a.Slot:"a";return e.jsx(i,{ref:n,className:Te("transition-colors hover:text-foreground",s),...r})});jn.displayName="BreadcrumbLink";const Cn=J.forwardRef(({className:t,...a},s)=>e.jsx("span",{ref:s,role:"link","aria-disabled":"true","aria-current":"page",className:Te("font-normal text-foreground",t),...a}));Cn.displayName="BreadcrumbPage";const kn=({children:t,className:a,...s})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Te("[&>svg]:h-3.5 [&>svg]:w-3.5",a),...s,children:t??e.jsx(d.ChevronRight,{})});kn.displayName="BreadcrumbSeparator";const Sn=({className:t,...a})=>e.jsxs("span",{role:"presentation","aria-hidden":"true",className:Te("flex h-9 w-9 items-center justify-center",t),...a,children:[e.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Mais"})]});Sn.displayName="BreadcrumbEllipsis";const Tn=s.cva("flex items-center",{variants:{orientation:{horizontal:"flex-row [&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}}),Pn=J.forwardRef(({className:t,orientation:a,...s},r)=>e.jsx("div",{ref:r,className:Te(Tn({orientation:a}),t),...s}));function Mn(e){return(t={})=>{const a=t.width?String(t.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}function In(e){return(t,a)=>{let s;if("formatting"===(a?.context?String(a.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,r=a?.width?String(a.width):t;s=e.formattingValues[r]||e.formattingValues[t]}else{const t=e.defaultWidth,r=a?.width?String(a.width):e.defaultWidth;s=e.values[r]||e.values[t]}return s[e.argumentCallback?e.argumentCallback(t):t]}}function An(e){return(t,a={})=>{const s=a.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],n=t.match(r);if(!n)return null;const i=n[0],o=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?function(e,t){for(let a=0;a<e.length;a++)if(t(e[a]))return a;return}(o,e=>e.test(i)):function(e,t){for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&t(e[a]))return a;return}(o,e=>e.test(i));let d;d=e.valueCallback?e.valueCallback(l):l,d=a.valueCallback?a.valueCallback(d):d;return{value:d,rest:t.slice(i.length)}}}function En(e){return(t,a={})=>{const s=t.match(e.matchPattern);if(!s)return null;const r=s[0],n=t.match(e.parsePattern);if(!n)return null;let i=e.valueCallback?e.valueCallback(n[0]):n[0];i=a.valueCallback?a.valueCallback(i):i;return{value:i,rest:t.slice(r.length)}}}function Dn(e){const t=Object.prototype.toString.call(e);return e instanceof Date||"object"==typeof e&&"[object Date]"===t?new e.constructor(+e):"number"==typeof e||"[object Number]"===t||"string"==typeof e||"[object String]"===t?new Date(e):new Date(NaN)}Pn.displayName="ButtonGroup";let _n={};function Rn(){return _n}function zn(e,t){const a=Rn(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,r=Dn(e),n=r.getDay(),i=(n<s?7:0)+n-s;return r.setDate(r.getDate()-i),r.setHours(0,0,0,0),r}const Fn={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Ln={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},On={ordinalNumber:(e,t)=>{const a=Number(e),s=a%100;if(s>20||s<10)switch(s%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},era:In({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:In({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:In({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:In({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:In({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},Un={ordinalNumber:En({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:An({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:An({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:An({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:An({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:An({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},$n={code:"en-US",formatDistance:(e,t,a)=>{let s;const r=Fn[e];return s="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"in "+s:s+" ago":s},formatLong:{date:Mn({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Mn({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:Mn({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},formatRelative:(e,t,a,s)=>Ln[e],localize:On,match:Un,options:{weekStartsOn:0,firstWeekContainsDate:1}},qn={lessThanXSeconds:{one:"menos de un segundo",other:"menos de {{count}} segundos"},xSeconds:{one:"1 segundo",other:"{{count}} segundos"},halfAMinute:"medio minuto",lessThanXMinutes:{one:"menos de un minuto",other:"menos de {{count}} minutos"},xMinutes:{one:"1 minuto",other:"{{count}} minutos"},aboutXHours:{one:"alrededor de 1 hora",other:"alrededor de {{count}} horas"},xHours:{one:"1 hora",other:"{{count}} horas"},xDays:{one:"1 día",other:"{{count}} días"},aboutXWeeks:{one:"alrededor de 1 semana",other:"alrededor de {{count}} semanas"},xWeeks:{one:"1 semana",other:"{{count}} semanas"},aboutXMonths:{one:"alrededor de 1 mes",other:"alrededor de {{count}} meses"},xMonths:{one:"1 mes",other:"{{count}} meses"},aboutXYears:{one:"alrededor de 1 año",other:"alrededor de {{count}} años"},xYears:{one:"1 año",other:"{{count}} años"},overXYears:{one:"más de 1 año",other:"más de {{count}} años"},almostXYears:{one:"casi 1 año",other:"casi {{count}} años"}},Hn={date:Mn({formats:{full:"EEEE, d 'de' MMMM 'de' y",long:"d 'de' MMMM 'de' y",medium:"d MMM y",short:"dd/MM/y"},defaultWidth:"full"}),time:Mn({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Mn({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Bn={lastWeek:"'el' eeee 'pasado a la' p",yesterday:"'ayer a la' p",today:"'hoy a la' p",tomorrow:"'mañana a la' p",nextWeek:"eeee 'a la' p",other:"P"},Wn={lastWeek:"'el' eeee 'pasado a las' p",yesterday:"'ayer a las' p",today:"'hoy a las' p",tomorrow:"'mañana a las' p",nextWeek:"eeee 'a las' p",other:"P"},Vn={ordinalNumber:(e,t)=>Number(e)+"º",era:In({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:In({values:{narrow:["1","2","3","4"],abbreviated:["T1","T2","T3","T4"],wide:["1º trimestre","2º trimestre","3º trimestre","4º trimestre"]},defaultWidth:"wide",argumentCallback:e=>Number(e)-1}),month:In({values:{narrow:["e","f","m","a","m","j","j","a","s","o","n","d"],abbreviated:["ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic"],wide:["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"]},defaultWidth:"wide"}),day:In({values:{narrow:["d","l","m","m","j","v","s"],short:["do","lu","ma","mi","ju","vi","sá"],abbreviated:["dom","lun","mar","mié","jue","vie","sáb"],wide:["domingo","lunes","martes","miércoles","jueves","viernes","sábado"]},defaultWidth:"wide"}),dayPeriod:In({values:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"},abbreviated:{am:"AM",pm:"PM",midnight:"medianoche",noon:"mediodia",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"},wide:{am:"a.m.",pm:"p.m.",midnight:"medianoche",noon:"mediodia",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"},abbreviated:{am:"AM",pm:"PM",midnight:"medianoche",noon:"mediodia",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"},wide:{am:"a.m.",pm:"p.m.",midnight:"medianoche",noon:"mediodia",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"}},defaultFormattingWidth:"wide"})},Gn={ordinalNumber:En({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:An({matchPatterns:{narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|a\.?\s?e\.?\s?c\.?|d\.?\s?c\.?|e\.?\s?c\.?)/i,wide:/^(antes de cristo|antes de la era com[uú]n|despu[eé]s de cristo|era com[uú]n)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^ac/i,/^dc/i],wide:[/^(antes de cristo|antes de la era com[uú]n)/i,/^(despu[eé]s de cristo|era com[uú]n)/i]},defaultParseWidth:"any"}),quarter:An({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:An({matchPatterns:{narrow:/^[efmajsond]/i,abbreviated:/^(ene|feb|mar|abr|may|jun|jul|ago|sep|oct|nov|dic)/i,wide:/^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^e/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^en/i,/^feb/i,/^mar/i,/^abr/i,/^may/i,/^jun/i,/^jul/i,/^ago/i,/^sep/i,/^oct/i,/^nov/i,/^dic/i]},defaultParseWidth:"any"}),day:An({matchPatterns:{narrow:/^[dlmjvs]/i,short:/^(do|lu|ma|mi|ju|vi|s[áa])/i,abbreviated:/^(dom|lun|mar|mi[ée]|jue|vie|s[áa]b)/i,wide:/^(domingo|lunes|martes|mi[ée]rcoles|jueves|viernes|s[áa]bado)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^d/i,/^l/i,/^m/i,/^m/i,/^j/i,/^v/i,/^s/i],any:[/^do/i,/^lu/i,/^ma/i,/^mi/i,/^ju/i,/^vi/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:An({matchPatterns:{narrow:/^(a|p|mn|md|(de la|a las) (mañana|tarde|noche))/i,any:/^([ap]\.?\s?m\.?|medianoche|mediodia|(de la|a las) (mañana|tarde|noche))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mn/i,noon:/^md/i,morning:/mañana/i,afternoon:/tarde/i,evening:/tarde/i,night:/noche/i}},defaultParseWidth:"any"})},Yn={code:"es",formatDistance:(e,t,a)=>{let s;const r=qn[e];return s="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"en "+s:"hace "+s:s},formatLong:Hn,formatRelative:(e,t,a,s)=>1!==t.getHours()?Wn[e]:Bn[e],localize:Vn,match:Gn,options:{weekStartsOn:1,firstWeekContainsDate:1}},Qn={lessThanXSeconds:{one:"menos de um segundo",other:"menos de {{count}} segundos"},xSeconds:{one:"1 segundo",other:"{{count}} segundos"},halfAMinute:"meio minuto",lessThanXMinutes:{one:"menos de um minuto",other:"menos de {{count}} minutos"},xMinutes:{one:"1 minuto",other:"{{count}} minutos"},aboutXHours:{one:"cerca de 1 hora",other:"cerca de {{count}} horas"},xHours:{one:"1 hora",other:"{{count}} horas"},xDays:{one:"1 dia",other:"{{count}} dias"},aboutXWeeks:{one:"cerca de 1 semana",other:"cerca de {{count}} semanas"},xWeeks:{one:"1 semana",other:"{{count}} semanas"},aboutXMonths:{one:"cerca de 1 mês",other:"cerca de {{count}} meses"},xMonths:{one:"1 mês",other:"{{count}} meses"},aboutXYears:{one:"cerca de 1 ano",other:"cerca de {{count}} anos"},xYears:{one:"1 ano",other:"{{count}} anos"},overXYears:{one:"mais de 1 ano",other:"mais de {{count}} anos"},almostXYears:{one:"quase 1 ano",other:"quase {{count}} anos"}},Xn={date:Mn({formats:{full:"EEEE, d 'de' MMMM 'de' y",long:"d 'de' MMMM 'de' y",medium:"d MMM y",short:"dd/MM/yyyy"},defaultWidth:"full"}),time:Mn({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Mn({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Kn={lastWeek:e=>{const t=e.getDay();return"'"+(0===t||6===t?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},Zn={ordinalNumber:(e,t)=>{const a=Number(e);return"week"===t?.unit?a+"ª":a+"º"},era:In({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:In({values:{narrow:["1","2","3","4"],abbreviated:["T1","T2","T3","T4"],wide:["1º trimestre","2º trimestre","3º trimestre","4º trimestre"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:In({values:{narrow:["j","f","m","a","m","j","j","a","s","o","n","d"],abbreviated:["jan","fev","mar","abr","mai","jun","jul","ago","set","out","nov","dez"],wide:["janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"]},defaultWidth:"wide"}),day:In({values:{narrow:["D","S","T","Q","Q","S","S"],short:["dom","seg","ter","qua","qui","sex","sab"],abbreviated:["domingo","segunda","terça","quarta","quinta","sexta","sábado"],wide:["domingo","segunda-feira","terça-feira","quarta-feira","quinta-feira","sexta-feira","sábado"]},defaultWidth:"wide"}),dayPeriod:In({values:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"}},defaultFormattingWidth:"wide"})},Jn={ordinalNumber:En({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:An({matchPatterns:{narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|d\.?\s?c\.?)/i,wide:/^(antes de cristo|depois de cristo)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^ac/i,/^dc/i],wide:[/^antes de cristo/i,/^depois de cristo/i]},defaultParseWidth:"any"}),quarter:An({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:An({matchPatterns:{narrow:/^[jfmajsond]/i,abbreviated:/^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,wide:/^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^fev/i,/^mar/i,/^abr/i,/^mai/i,/^jun/i,/^jul/i,/^ago/i,/^set/i,/^out/i,/^nov/i,/^dez/i]},defaultParseWidth:"any"}),day:An({matchPatterns:{narrow:/^(dom|[23456]ª?|s[aá]b)/i,short:/^(dom|[23456]ª?|s[aá]b)/i,abbreviated:/^(dom|seg|ter|qua|qui|sex|s[aá]b)/i,wide:/^(domingo|(segunda|ter[cç]a|quarta|quinta|sexta)([- ]feira)?|s[aá]bado)/i},defaultMatchWidth:"wide",parsePatterns:{short:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],narrow:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],any:[/^d/i,/^seg/i,/^t/i,/^qua/i,/^qui/i,/^sex/i,/^s[aá]b/i]},defaultParseWidth:"any"}),dayPeriod:An({matchPatterns:{narrow:/^(a|p|mn|md|(da) (manhã|tarde|noite))/i,any:/^([ap]\.?\s?m\.?|meia[-\s]noite|meio[-\s]dia|(da) (manhã|tarde|noite))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mn|^meia[-\s]noite/i,noon:/^md|^meio[-\s]dia/i,morning:/manhã/i,afternoon:/tarde/i,evening:/tarde/i,night:/noite/i}},defaultParseWidth:"any"})},ei={code:"pt-BR",formatDistance:(e,t,a)=>{let s;const r=Qn[e];return s="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",String(t)),a?.addSuffix?a.comparison&&a.comparison>0?"em "+s:"há "+s:s},formatLong:Xn,formatRelative:(e,t,a,s)=>{const r=Kn[e];return"function"==typeof r?r(t):r},localize:Zn,match:Jn,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ti({className:t,classNames:a,showOutsideDays:s=!0,...r}){return e.jsx(I.DayPicker,{showOutsideDays:s,className:Te("p-3 pointer-events-auto",t),locale:ei,classNames:{months:"relative flex flex-col gap-4 sm:flex-row",month:"flex flex-col gap-4",month_caption:"flex h-9 w-full items-center justify-center px-8",caption_label:"text-sm font-medium",nav:"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1 px-1",button_previous:Te(Me({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),button_next:Te(Me({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),month_grid:"w-full border-collapse",weekdays:"flex",weekday:"text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal w-9",week:"mt-2 flex w-full",day:"group/day relative h-9 w-9 select-none p-0 text-center text-sm [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md focus-within:relative focus-within:z-20",day_button:Te(Me({variant:"ghost"}),"h-9 w-9 p-0 font-normal transition-none aria-selected:opacity-100"),range_start:"bg-accent rounded-l-md",range_end:"bg-accent rounded-r-md",range_middle:"rounded-none aria-selected:bg-accent aria-selected:text-accent-foreground",selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground rounded-md",today:"bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",outside:"text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",disabled:"text-muted-foreground opacity-50",hidden:"invisible",...a},components:{Chevron:({orientation:t})=>"left"===t?e.jsx(d.ChevronLeft,{className:"h-4 w-4"}):e.jsx(d.ChevronRight,{className:"h-4 w-4"})},...r})}ti.displayName="Calendar";const ai={Root:function({children:t,className:a}){return e.jsx("div",{className:Te("space-y-4",a),children:t})},Item:function({children:t,onClick:a,className:s}){return e.jsx(Re,{className:Te("transition-colors",a&&"cursor-pointer hover:bg-muted/50",s),onClick:a,children:e.jsx(Oe,{className:"p-4",children:t})})},Field:function({label:t,value:a,className:s}){return e.jsxs("div",{className:Te("flex justify-between items-center text-sm",s),children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[t,":"]}),e.jsx("span",{className:"text-foreground",children:a})]})}};const si=({shouldScaleBackground:t=!0,...a})=>e.jsx(A.Drawer.Root,{shouldScaleBackground:t,...a});si.displayName="Drawer";const ri=A.Drawer.Trigger,ni=A.Drawer.Portal,ii=A.Drawer.Close,oi=J.forwardRef(({className:t,...a},s)=>e.jsx(A.Drawer.Overlay,{ref:s,className:Te("fixed inset-0 z-50 bg-black/80",t),...a}));oi.displayName=A.Drawer.Overlay.displayName;const li=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(ni,{children:[e.jsx(oi,{}),e.jsxs(A.Drawer.Content,{ref:r,className:Te("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",t),...s,children:[e.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),a]})]}));li.displayName="DrawerContent";const di=({className:t,...a})=>e.jsx("div",{className:Te("grid gap-1.5 p-4 text-center sm:text-left",t),...a});di.displayName="DrawerHeader";const ci=({className:t,...a})=>e.jsx("div",{className:Te("mt-auto flex flex-col gap-2 p-4",t),...a});ci.displayName="DrawerFooter";const ui=J.forwardRef(({className:t,...a},s)=>e.jsx(A.Drawer.Title,{ref:s,className:Te("text-lg font-semibold leading-none tracking-tight",t),...a}));ui.displayName=A.Drawer.Title.displayName;const mi=J.forwardRef(({className:t,...a},s)=>e.jsx(A.Drawer.Description,{ref:s,className:Te("text-sm text-muted-foreground",t),...a}));mi.displayName=A.Drawer.Description.displayName;const hi={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5",6:"grid-cols-6","auto-fit":"grid-cols-[repeat(auto-fit,minmax(250px,1fr))]","auto-fill":"grid-cols-[repeat(auto-fill,minmax(250px,1fr))]"},pi={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};const fi=fe.Root,xi=fe.Trigger,gi=J.forwardRef(({className:t,align:a="center",sideOffset:s=4,...r},n)=>e.jsx(fe.Content,{ref:n,align:a,sideOffset:s,className:Te("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r}));gi.displayName=fe.Content.displayName;const bi=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-slot":"input-group",className:Te("flex min-w-0 items-center rounded-md border border-input bg-background","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background","has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50","has-[textarea:disabled]:cursor-not-allowed has-[textarea:disabled]:opacity-50",t),...a}));bi.displayName="InputGroup";const vi=s.cva("flex items-center justify-center text-sm text-muted-foreground shrink-0",{variants:{align:{"inline-start":"border-r border-input px-3","inline-end":"border-l border-input px-3","block-start":"border-b border-input px-3 py-2 w-full justify-start","block-end":"border-t border-input px-3 py-2 w-full justify-start"}},defaultVariants:{align:"inline-start"}}),wi=J.forwardRef(({className:t,align:a,...s},r)=>e.jsx("div",{ref:r,"data-slot":"input-group-addon",className:Te(vi({align:a}),t),...s}));wi.displayName="InputGroupAddon";const Ni=s.cva("",{variants:{size:{xs:"h-6 px-2 text-xs","icon-xs":"h-6 w-6",sm:"h-7 px-3 text-xs","icon-sm":"h-7 w-7"}},defaultVariants:{size:"xs"}}),yi=J.forwardRef(({className:t,size:a,variant:s="ghost",...r},n)=>e.jsx(Ie,{ref:n,"data-slot":"input-group-button",variant:s,className:Te(Ni({size:a}),"rounded-none first:rounded-l-md last:rounded-r-md",t),...r}));yi.displayName="InputGroupButton";const ji=J.forwardRef(({className:t,...a},s)=>e.jsx(Ee,{ref:s,"data-slot":"input-group-control",className:Te("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",t),...a}));ji.displayName="InputGroupInput";const Ci=J.forwardRef(({className:t,...a},s)=>e.jsx(wt,{ref:s,"data-slot":"input-group-control",className:Te("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",t),...a}));Ci.displayName="InputGroupTextarea";const ki=J.forwardRef(({className:t,...a},s)=>e.jsx("h1",{ref:s,className:Te("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",t),...a}));ki.displayName="H1";const Si=J.forwardRef(({className:t,...a},s)=>e.jsx("h2",{ref:s,className:Te("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",t),...a}));Si.displayName="H2";const Ti=J.forwardRef(({className:t,...a},s)=>e.jsx("h3",{ref:s,className:Te("scroll-m-20 text-2xl font-semibold tracking-tight",t),...a}));Ti.displayName="H3";const Pi=J.forwardRef(({className:t,...a},s)=>e.jsx("h4",{ref:s,className:Te("scroll-m-20 text-xl font-semibold tracking-tight",t),...a}));Pi.displayName="H4";const Mi=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Te("leading-7 [&:not(:first-child)]:mt-6",t),...a}));Mi.displayName="P";const Ii=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Te("text-xl text-muted-foreground",t),...a}));Ii.displayName="Lead";const Ai=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("text-lg font-semibold",t),...a}));Ai.displayName="Large";const Ei=J.forwardRef(({className:t,...a},s)=>e.jsx("small",{ref:s,className:Te("text-sm font-medium leading-none",t),...a}));Ei.displayName="Small";const Di=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Te("text-sm text-muted-foreground",t),...a}));Di.displayName="Muted";const _i=J.forwardRef(({className:t,...a},s)=>e.jsx("code",{ref:s,className:Te("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",t),...a}));_i.displayName="InlineCode";const Ri=J.forwardRef(({className:t,...a},s)=>e.jsx("blockquote",{ref:s,className:Te("mt-6 border-l-2 pl-6 italic",t),...a}));Ri.displayName="Blockquote";const zi=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,className:Te("my-6 ml-6 list-disc [&>li]:mt-2",t),...a}));zi.displayName="List";const Fi=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(xe.Root,{ref:r,className:Te("relative z-10 flex max-w-max flex-1 items-center justify-center",t),...s,children:[a,e.jsx(Bi,{})]}));Fi.displayName=xe.Root.displayName;const Li=J.forwardRef(({className:t,...a},s)=>e.jsx(xe.List,{ref:s,className:Te("group flex flex-1 list-none items-center justify-center space-x-1",t),...a}));Li.displayName=xe.List.displayName;const Oi=xe.Item,Ui=s.cva("group inline-flex h-10 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50"),$i=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(xe.Trigger,{ref:r,className:Te(Ui(),"group",t),...s,children:[a," ",e.jsx(d.ChevronDown,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));$i.displayName=xe.Trigger.displayName;const qi=J.forwardRef(({className:t,...a},s)=>e.jsx(xe.Content,{ref:s,className:Te("left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto ",t),...a}));qi.displayName=xe.Content.displayName;const Hi=xe.Link,Bi=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{className:Te("absolute left-0 top-full flex justify-center"),children:e.jsx(xe.Viewport,{className:Te("origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]",t),ref:s,...a})}));Bi.displayName=xe.Viewport.displayName;const Wi=J.forwardRef(({className:t,...a},s)=>e.jsx(xe.Indicator,{ref:s,className:Te("top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in",t),...a,children:e.jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));Wi.displayName=xe.Indicator.displayName;const Vi=({className:t,...a})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:Te("mx-auto flex w-full justify-center",t),...a});Vi.displayName="Pagination";const Gi=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,className:Te("flex flex-row items-center gap-1",t),...a}));Gi.displayName="PaginationContent";const Yi=J.forwardRef(({className:t,...a},s)=>e.jsx("li",{ref:s,className:Te("",t),...a}));Yi.displayName="PaginationItem";const Qi=({className:t,isActive:a,size:s="icon",...r})=>e.jsx("a",{"aria-current":a?"page":void 0,className:Te(Me({variant:a?"outline":"ghost",size:s}),t),...r});Qi.displayName="PaginationLink";const Xi=({className:t,...a})=>e.jsxs(Qi,{"aria-label":"Go to previous page",size:"default",className:Te("gap-1 pl-2.5",t),...a,children:[e.jsx(d.ChevronLeft,{className:"h-4 w-4"}),e.jsx("span",{children:"Previous"})]});Xi.displayName="PaginationPrevious";const Ki=({className:t,...a})=>e.jsxs(Qi,{"aria-label":"Go to next page",size:"default",className:Te("gap-1 pr-2.5",t),...a,children:[e.jsx("span",{children:"Next"}),e.jsx(d.ChevronRight,{className:"h-4 w-4"})]});Ki.displayName="PaginationNext";const Zi=({className:t,...a})=>e.jsxs("span",{"aria-hidden":!0,className:Te("flex h-9 w-9 items-center justify-center",t),...a,children:[e.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]});Zi.displayName="PaginationEllipsis";const Ji=J.forwardRef(({className:t,value:a,...s},r)=>e.jsx(ge.Root,{ref:r,className:Te("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",t),...s,children:e.jsx(ge.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(a||0)}%)`}})}));Ji.displayName=ge.Root.displayName;const eo=J.forwardRef(({className:t,...a},s)=>e.jsx(be.Root,{className:Te("grid gap-2",t),...a,ref:s}));eo.displayName=be.Root.displayName;const to=J.forwardRef(({className:t,...a},s)=>e.jsx(be.Item,{ref:s,className:Te("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...a,children:e.jsx(be.Indicator,{className:"flex items-center justify-center",children:e.jsx(d.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));to.displayName=be.Item.displayName;const ao=ve.Panel,so=te.Root,ro=te.Trigger,no=te.Close,io=te.Portal,oo=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Overlay,{className:Te("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a,ref:s}));oo.displayName=te.Overlay.displayName;const lo=s.cva("fixed z-50 flex flex-col bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b max-h-[70vh] data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t max-h-[70vh] data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),co=J.forwardRef(({side:t="right",className:a,children:s,...r},n)=>e.jsxs(io,{children:[e.jsx(oo,{}),e.jsxs(te.Content,{ref:n,className:Te(lo({side:t}),a),...r,children:[s,e.jsxs(te.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-0 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[e.jsx(d.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));co.displayName=te.Content.displayName;const uo=({className:t,showSeparator:a=!1,children:s,...r})=>e.jsxs("div",{className:Te("flex flex-col flex-shrink-0",t),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),a&&e.jsx($e,{className:"mt-2"})]});uo.displayName="SheetHeader";const mo=({className:t,...a})=>e.jsx("div",{className:Te("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",t),...a});mo.displayName="SheetBody";const ho=({className:t,children:a,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx($e,{className:"mb-4"}),e.jsx("div",{className:Te("flex flex-row justify-end gap-2",t),...s,children:a})]});ho.displayName="SheetFooter";const po=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Title,{ref:s,className:Te("text-lg font-semibold text-foreground",t),...a}));po.displayName=te.Title.displayName;const fo=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Description,{ref:s,className:Te("text-sm text-muted-foreground",t),...a}));fo.displayName=te.Description.displayName;const xo="sidebar:state",go=J.createContext(null);function bo(){const e=J.useContext(go);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const vo=J.forwardRef(({defaultOpen:t=!0,open:a,onOpenChange:s,className:r,style:n,children:i,...o},l)=>{const[d,c]=J.useState(!1);J.useEffect(()=>{const e=()=>c(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[u,m]=J.useState(!1),[h,p]=J.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(xo);return null!==e?"true"===e:t}return t}),f=a??h,x=J.useCallback(e=>{const t="function"==typeof e?e(f):e;s?s(t):p(t),"undefined"!=typeof window&&localStorage.setItem(xo,String(t))},[s,f]),g=J.useCallback(()=>d?m(e=>!e):x(e=>!e),[d,x,m]);J.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),g())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[g]);const b=f?"expanded":"collapsed",v=J.useMemo(()=>({state:b,open:f,setOpen:x,isMobile:d,openMobile:u,setOpenMobile:m,toggleSidebar:g}),[b,f,x,d,u,m,g]);return e.jsx(go.Provider,{value:v,children:e.jsx($t,{delayDuration:0,children:e.jsx("div",{className:Te("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",r),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4.5rem",...n},ref:l,...o,children:i})})})});vo.displayName="SidebarProvider";const wo=J.forwardRef(({side:t="left",variant:a="sidebar",collapsible:s="offcanvas",className:r,children:n,...i},o)=>{const{isMobile:l,state:d,openMobile:c,setOpenMobile:u}=bo();return"none"===s?e.jsx("div",{className:Te("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:o,...i,children:n}):l?e.jsx(so,{open:c,onOpenChange:u,...i,children:e.jsxs(co,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden sidebar-mobile",style:{"--sidebar-width":"18rem"},side:t,children:[e.jsx(po,{className:"sr-only",children:"Menu de Navegação"}),e.jsx("div",{className:"flex h-full w-full flex-col",children:n})]})}):e.jsxs("div",{ref:o,className:"group peer hidden md:block text-sidebar-foreground","data-state":d,"data-collapsible":"collapsed"===d?s:"","data-variant":a,"data-side":t,children:[e.jsx("div",{className:Te("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===a||"inset"===a?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),e.jsx("div",{className:Te("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex","left"===t?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===a||"inset"===a?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...i,children:e.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow bg-white",children:n})})]})});wo.displayName="Sidebar";const No=J.forwardRef(({className:t,onClick:a,...s},r)=>{const{toggleSidebar:n}=bo();return e.jsxs(Ie,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Te("h-7 w-7",t),onClick:e=>{a?.(e),n()},...s,children:[e.jsx(d.PanelLeft,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});No.displayName="SidebarTrigger";const yo=J.forwardRef(({className:t,...a},s)=>{const{toggleSidebar:r}=bo();return e.jsx("button",{ref:s,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Te("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",t),...a})});yo.displayName="SidebarRail";const jo=J.forwardRef(({className:t,...a},s)=>e.jsx("main",{ref:s,className:Te("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",t),...a}));jo.displayName="SidebarInset";const Co=J.forwardRef(({className:t,...a},s)=>e.jsx(Ee,{ref:s,"data-sidebar":"input",className:Te("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",t),...a}));Co.displayName="SidebarInput";const ko=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"header",className:Te("flex flex-col gap-2 p-2",t),...a}));ko.displayName="SidebarHeader";const So=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"footer",className:Te("flex flex-col gap-2 p-2",t),...a}));So.displayName="SidebarFooter";const To=J.forwardRef(({className:t,...a},s)=>e.jsx($e,{ref:s,"data-sidebar":"separator",className:Te("mx-2 w-auto bg-sidebar-border",t),...a}));To.displayName="SidebarSeparator";const Po=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"content",className:Te("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),...a}));Po.displayName="SidebarContent";const Mo=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"group",className:Te("relative flex w-full min-w-0 flex-col p-2",t),...a}));Mo.displayName="SidebarGroup";const Io=J.forwardRef(({className:t,asChild:s=!1,...r},n)=>{const i=s?a.Slot:"div";return e.jsx(i,{ref:n,"data-sidebar":"group-label",className:Te("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",t),...r})});Io.displayName="SidebarGroupLabel";const Ao=J.forwardRef(({className:t,asChild:s=!1,...r},n)=>{const i=s?a.Slot:"button";return e.jsx(i,{ref:n,"data-sidebar":"group-action",className:Te("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",t),...r})});Ao.displayName="SidebarGroupAction";const Eo=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"group-content",className:Te("w-full text-sm",t),...a}));Eo.displayName="SidebarGroupContent";const Do=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu",className:Te("flex w-full min-w-0 flex-col gap-1",t),...a}));Do.displayName="SidebarMenu";const _o=J.forwardRef(({className:t,...a},s)=>e.jsx("li",{ref:s,"data-sidebar":"menu-item",className:Te("group/menu-item relative",t),...a}));_o.displayName="SidebarMenuItem";const Ro=s.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-primary data-[active=true]:font-medium data-[active=true]:text-sidebar-primary-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 group-data-[collapsible=icon]:[&>*]:!mr-0 group-data-[collapsible=icon]:[&>*]:!ml-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-10 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),zo=J.forwardRef(({asChild:t=!1,isActive:s=!1,variant:r="default",size:n="default",tooltip:i,className:o,...l},d)=>{const c=t?a.Slot:"button",{isMobile:u,state:m}=bo(),h=e.jsx(c,{ref:d,"data-sidebar":"menu-button","data-size":n,"data-active":s,className:Te(Ro({variant:r,size:n}),o),...l});return i?("string"==typeof i&&(i={children:i}),e.jsxs(qt,{children:[e.jsx(Ht,{asChild:!0,children:h}),e.jsx(Bt,{side:"right",align:"center",hidden:"collapsed"!==m||u,...i})]})):h});zo.displayName="SidebarMenuButton";const Fo=J.forwardRef(({className:t,asChild:s=!1,showOnHover:r=!1,...n},i)=>{const o=s?a.Slot:"button";return e.jsx(o,{ref:i,"data-sidebar":"menu-action",className:Te("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",r&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",t),...n})});Fo.displayName="SidebarMenuAction";const Lo=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"menu-badge",className:Te("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",t),...a}));Lo.displayName="SidebarMenuBadge";const Oo=J.forwardRef(({className:t,showIcon:a=!1,...s},r)=>{const n=J.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return e.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:Te("rounded-md h-8 flex gap-2 px-2 items-center",t),...s,children:[a&&e.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),e.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});Oo.displayName="SidebarMenuSkeleton";const Uo=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu-sub",className:Te("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",t),...a}));Uo.displayName="SidebarMenuSub";const $o=J.forwardRef(({...t},a)=>e.jsx("li",{ref:a,...t}));$o.displayName="SidebarMenuSubItem";const qo=J.forwardRef(({asChild:t=!1,size:s="md",isActive:r,className:n,...i},o)=>{const l=t?a.Slot:"a";return e.jsx(l,{ref:o,"data-sidebar":"menu-sub-button","data-size":s,"data-active":r,className:Te("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground","sm"===s&&"text-xs","md"===s&&"text-sm","group-data-[collapsible=icon]:hidden",n),...i})});qo.displayName="SidebarMenuSubButton";const Ho=J.forwardRef(({className:t,value:a,defaultValue:s,...r},n)=>{const i=a||s||[0];return e.jsxs(we.Root,{ref:n,value:a,defaultValue:s,className:Te("relative flex w-full touch-none select-none items-center",t),...r,children:[e.jsx(we.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(we.Range,{className:"absolute h-full bg-primary"})}),i.map((t,a)=>e.jsx(we.Thumb,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"},a))]})});Ho.displayName=we.Root.displayName;const Bo=Ne.Root,Wo=J.forwardRef(({className:t,...a},s)=>e.jsx(Ne.List,{ref:s,className:Te("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...a}));Wo.displayName=Ne.List.displayName;const Vo=J.forwardRef(({className:t,...a},s)=>e.jsx(Ne.Trigger,{ref:s,className:Te("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t),...a}));Vo.displayName=Ne.Trigger.displayName;const Go=J.forwardRef(({className:t,...a},s)=>e.jsx(Ne.Content,{ref:s,className:Te("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...a}));Go.displayName=Ne.Content.displayName;const Yo=s.cva("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),Qo=J.forwardRef(({className:t,variant:a,size:s,...r},n)=>e.jsx(ye.Root,{ref:n,className:Te(Yo({variant:a,size:s,className:t})),...r}));Qo.displayName=ye.Root.displayName;const Xo=J.createContext({size:"default",variant:"default"}),Ko=J.forwardRef(({className:t,variant:a,size:s,children:r,...n},i)=>e.jsx(je.Root,{ref:i,className:Te("flex items-center justify-center gap-1",t),...n,children:e.jsx(Xo.Provider,{value:{variant:a,size:s},children:r})}));Ko.displayName=je.Root.displayName;const Zo=J.forwardRef(({className:t,children:a,variant:s,size:r,...n},i)=>{const o=J.useContext(Xo);return e.jsx(je.Item,{ref:i,className:Te(Yo({variant:o.variant||s,size:o.size||r}),t),...n,children:a})});Zo.displayName=je.Item.displayName;const Jo=Ce.Menu,el=Ce.Group,tl=Ce.Portal,al=Ce.Sub,sl=Ce.RadioGroup,rl=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.Root,{ref:s,className:Te("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",t),...a}));rl.displayName=Ce.Root.displayName;const nl=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.Trigger,{ref:s,className:Te("flex cursor-default select-none items-center rounded-sm px-3 py-1.5 text-sm font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",t),...a}));nl.displayName=Ce.Trigger.displayName;const il=J.forwardRef(({className:t,inset:a,children:s,...r},n)=>e.jsxs(Ce.SubTrigger,{ref:n,className:Te("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",a&&"pl-8",t),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));il.displayName=Ce.SubTrigger.displayName;const ol=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.SubContent,{ref:s,className:Te("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a}));ol.displayName=Ce.SubContent.displayName;const ll=J.forwardRef(({className:t,align:a="start",alignOffset:s=-4,sideOffset:r=8,...n},i)=>e.jsx(Ce.Portal,{children:e.jsx(Ce.Content,{ref:i,align:a,alignOffset:s,sideOffset:r,className:Te("z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));ll.displayName=Ce.Content.displayName;const dl=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(Ce.Item,{ref:r,className:Te("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",t),...s}));dl.displayName=Ce.Item.displayName;const cl=J.forwardRef(({className:t,children:a,checked:s,...r},n)=>e.jsxs(Ce.CheckboxItem,{ref:n,className:Te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Ce.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),a]}));cl.displayName=Ce.CheckboxItem.displayName;const ul=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(Ce.RadioItem,{ref:r,className:Te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Ce.ItemIndicator,{children:e.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));ul.displayName=Ce.RadioItem.displayName;const ml=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(Ce.Label,{ref:r,className:Te("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",t),...s}));ml.displayName=Ce.Label.displayName;const hl=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.Separator,{ref:s,className:Te("-mx-1 my-1 h-px bg-muted",t),...a}));hl.displayName=Ce.Separator.displayName;const pl=({className:t,...a})=>e.jsx("span",{className:Te("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});pl.displayname="MenubarShortcut";const fl={light:"",dark:".dark"},xl=J.createContext(null);function gl(){const e=J.useContext(xl);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const bl=J.forwardRef(({id:t,className:a,children:s,config:r,...n},i)=>{const o=J.useId(),l=`chart-${t||o.replace(/:/g,"")}`;return e.jsx(xl.Provider,{value:{config:r},children:e.jsxs("div",{"data-chart":l,ref:i,className:Te("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",a),...n,children:[e.jsx(vl,{id:l,config:r}),e.jsx(ke.ResponsiveContainer,{children:s})]})})});bl.displayName="Chart";const vl=({id:t,config:a})=>{const s=Object.entries(a).filter(([,e])=>e.theme||e.color);return s.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(fl).map(([e,a])=>`\n${a} [data-chart=${t}] {\n${s.map(([t,a])=>{const s=a.theme?.[e]||a.color;return s?` --color-${t}: ${s};`:null}).join("\n")}\n}\n`).join("\n")}}):null},wl=ke.Tooltip,Nl=J.forwardRef(({active:t,payload:a,className:s,indicator:r="dot",hideLabel:n=!1,hideIndicator:i=!1,label:o,labelFormatter:l,labelClassName:d,formatter:c,color:u,nameKey:m,labelKey:h},p)=>{const{config:f}=gl(),x=J.useMemo(()=>{if(n||!a?.length)return null;const[t]=a,s=Cl(f,t,`${h||t?.dataKey||t?.name||"value"}`),r=h||"string"!=typeof o?s?.label:f[o]?.label||o;return l?e.jsx("div",{className:Te("font-medium",d),children:l(r,a)}):r?e.jsx("div",{className:Te("font-medium",d),children:r}):null},[o,l,a,n,d,f,h]);if(!t||!a?.length)return null;const g=1===a.length&&"dot"!==r;return e.jsxs("div",{ref:p,className:Te("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",s),children:[g?null:x,e.jsx("div",{className:"grid gap-1.5",children:a.map((t,a)=>{const s=`${m||t.name||t.dataKey||"value"}`,n=Cl(f,t,s),o=u||t.payload?.fill||t.color;return e.jsx("div",{className:Te("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===r&&"items-center"),children:c&&void 0!==t?.value&&t.name?c(t.value,t.name,t,a,t.payload):e.jsxs(e.Fragment,{children:[n?.icon?e.jsx(n.icon,{}):!i&&e.jsx("div",{className:Te("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":"dot"===r,"w-1":"line"===r,"w-0 border-[1.5px] border-dashed bg-transparent":"dashed"===r,"my-0.5":g&&"dashed"===r}),style:{"--color-bg":o,"--color-border":o}}),e.jsxs("div",{className:Te("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[g?x:null,e.jsx("span",{className:"text-muted-foreground",children:n?.label||t.name})]}),void 0!==t.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof t.value?t.value.toLocaleString():t.value})]})]})},t.dataKey||a)})})]})});Nl.displayName="ChartTooltip";const yl=ke.Legend,jl=J.forwardRef(({className:t,hideIcon:a=!1,payload:s,verticalAlign:r="bottom",nameKey:n},i)=>{const{config:o}=gl();return s?.length?e.jsx("div",{ref:i,className:Te("flex items-center justify-center gap-4","top"===r?"pb-3":"pt-3",t),children:s.map(t=>{const s=`${n||t.dataKey||"value"}`,r=Cl(o,t,s);return e.jsxs("div",{className:Te("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[r?.icon&&!a?e.jsx(r.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:t.color}}),r?.label]},t.value)})}):null});function Cl(e,t,a){if("object"!=typeof t||null===t)return;const s="payload"in t&&"object"==typeof t.payload&&null!==t.payload?t.payload:void 0;let r=a;return a in t&&"string"==typeof t[a]?r=t[a]:s&&a in s&&"string"==typeof s[a]&&(r=s[a]),r in e?e[r]:e[a]}jl.displayName="ChartLegend";const kl=({onClick:t,isActive:a,disabled:s,children:r,title:n})=>e.jsx("button",{type:"button",onClick:t,disabled:s,title:n,className:Te("p-1.5 rounded hover:bg-muted transition-colors",a?"bg-muted text-primary":"text-muted-foreground",s&&"opacity-50 cursor-not-allowed"),children:r}),Sl=()=>e.jsx("div",{className:"w-px h-5 bg-border mx-1"});function Tl({image:t,title:a,className:s}){return e.jsx("div",{className:Te("relative w-full aspect-video bg-muted rounded-lg overflow-hidden",s),children:t?e.jsx("img",{src:t,alt:a,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(d.ImageIcon,{className:"w-16 h-16 text-muted-foreground"})})})}function Pl({steps:t,currentStepIndex:a,onStepSelect:s,stepLabel:r,className:n}){const i=t.length,o=(a+1)/i*100;return e.jsxs("div",{className:Te("flex items-center gap-3",n),children:[e.jsxs(St,{children:[e.jsx(Tt,{asChild:!0,children:e.jsxs(Ie,{variant:"ghost",size:"sm",className:"h-8 px-2 text-sm",children:[r," ",a+1,"/",i,e.jsx(d.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),e.jsx(_t,{align:"start",children:t.map((t,r)=>e.jsxs(Rt,{onClick:()=>s(r),className:Te(r===a&&"bg-accent"),children:[r+1,". ",t.title]},t.id))})]}),e.jsx(Ji,{value:o,className:"w-32 h-2"})]})}function Ml({currentStepIndex:t,totalSteps:a,onBack:s,onNext:r,onComplete:n,backButtonText:i,continueButtonText:o,finishButtonText:l,className:c}){const u=0===t,m=t===a-1;return e.jsxs("div",{className:Te("flex items-center gap-2",c),children:[!u&&e.jsxs(Ie,{variant:"outline",onClick:s,size:"sm",children:[e.jsx(d.ArrowLeft,{className:"h-4 w-4 mr-2"}),i]}),e.jsxs(Ie,{onClick:m?n:r,size:"sm",children:[m?l:o,!m&&e.jsx(d.ArrowRight,{className:"h-4 w-4 ml-2"})]})]})}const Il=J.forwardRef(({open:t,onOpenChange:a,steps:s,onComplete:r,onStepChange:n,continueButtonText:i="Continuar",backButtonText:o="Voltar",finishButtonText:l="Concluir",stepLabel:c="Etapa",size:u="md",showProgressIndicator:m=!0,currentStepIndex:h,onCurrentStepChange:p,className:f},x)=>{const[g,b]=J.useState(0),v=void 0!==h,w=v?h:g,N=J.useCallback(e=>{v?p?.(e):b(e),n?.(e)},[v,p,n]);J.useEffect(()=>{t||v||b(0)},[t,v]);const y=s[w],j=s.length;return y?e.jsx(qe,{open:t,onOpenChange:a,children:e.jsxs(Ye,{ref:x,size:u,className:Te("p-0 gap-0",f),children:[e.jsxs(We,{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 data-[state=open]:bg-accent data-[state=open]:text-muted-foreground z-10",children:[e.jsx(d.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Fechar"})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx(Tl,{image:y.image,title:y.title}),e.jsx(Ze,{className:"text-xl font-semibold",children:y.title}),e.jsx(Je,{className:"text-muted-foreground",children:y.description})]}),e.jsx($e,{}),e.jsxs("div",{className:"p-4 flex items-center justify-between",children:[m&&j>1?e.jsx(Pl,{steps:s,currentStepIndex:w,onStepSelect:e=>{N(e)},stepLabel:c}):e.jsx("div",{}),e.jsx(Ml,{currentStepIndex:w,totalSteps:j,onBack:()=>{w>0&&N(w-1)},onNext:()=>{w<j-1&&N(w+1)},onComplete:()=>{r?.(),a(!1)},backButtonText:o,continueButtonText:i,finishButtonText:l})]})]})}):null});Il.displayName="OnboardingDialog";const Al=t.memo(({checked:t,onCheckedChange:a})=>e.jsx(vt,{checked:t,onCheckedChange:a}),(e,t)=>e.checked===t.checked);function El({onEdit:t,onDelete:a,onToggleStatus:s,isActive:r=!0,canEdit:n=!0,canDelete:i=!0,customActions:o=[],renderAs:l="dropdown",variant:c="default"}){const{t:u}=v.useTranslation(),m=[];return t&&n&&m.push({icon:d.Edit,label:u("edit"),onClick:t,variant:"default"}),s&&m.push({icon:r?d.PowerOff:d.Power,label:u(r?"deactivate":"activate"),onClick:s,variant:"default"}),o.forEach(e=>{!1!==e.show&&m.push({icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default",disabled:e.disabled,disabledReason:e.disabledReason})}),a&&i&&m.push({icon:d.Trash2,label:u("remove"),onClick:a,variant:"destructive"}),0===m.length?null:"dropdown"===l?e.jsx($t,{delayDuration:200,children:e.jsxs(St,{children:[e.jsx(Tt,{asChild:!0,children:e.jsx(Ie,{variant:"ghost",size:"compact"===c?"sm":"default",className:"compact"===c?"h-7 px-2":"",children:e.jsx(d.EllipsisVertical,{size:"compact"===c?14:16})})}),e.jsx(_t,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:m.map((t,a)=>t.disabled?e.jsxs(Wt,{disabledReason:t.disabledReason,className:"destructive"===t.variant?"text-destructive":"",children:[t.icon&&e.jsx(t.icon,{className:"mr-2 h-4 w-4"}),t.label]},a):e.jsxs(Rt,{onClick:t.onClick,className:"destructive"===t.variant?"text-destructive":"",children:[t.icon&&e.jsx(t.icon,{className:"mr-2 h-4 w-4"}),t.label]},a))})]})}):e.jsx("div",{className:"flex items-center gap-1",children:m.map((t,a)=>e.jsxs(Ie,{variant:"destructive"===t.variant?"destructive":"ghost",size:"compact"===c?"sm":"default",onClick:t.onClick,className:"compact"===c?"h-7 px-2":"",children:[t.icon&&e.jsx(t.icon,{size:"compact"===c?14:16}),"compact"!==c&&e.jsx("span",{className:"ml-1",children:t.label})]},a))})}function Dl(e){const t=y.useNavigate();return{onNew:()=>{const a=e.newPath||`${e.basePath}/new`;t(a)},onEdit:a=>{const s=e.editPath?e.editPath.replace(":id",a.id):`${e.basePath}/${a.id}/edit`;t(s)}}}const _l=()=>{const{locale:t,datetimeFormat:a,timezone:s,setLocale:r,setDatetimeFormat:n,setTimezone:i}=Gr(),{t:o}=v.useTranslation();return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:o("preferences")||"Preferências"}),e.jsxs(Ie,{variant:"ghost",size:"sm",onClick:()=>{const e=qr();r(e.locale),i(e.timezone),n(e.datetimeFormat)},className:"h-8 gap-1.5 text-xs",children:[e.jsx(d.RotateCcw,{className:"h-3.5 w-3.5"}),o("useSystemDefaults")||"Usar padrão do sistema"]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(d.Globe,{className:"h-4 w-4"}),o("language")]}),e.jsxs(dt,{value:t,onValueChange:r,children:[e.jsx(mt,{children:e.jsx(ut,{})}),e.jsx(ft,{children:Ar.map(t=>e.jsxs(gt,{value:t.value,children:[t.flag," ",t.label]},t.value))})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(d.Clock,{className:"h-4 w-4"}),o("timezone")||"Fuso Horário"]}),e.jsx(ia,{options:Dr,value:s,onChange:e=>{"string"==typeof e&&i(e)},getOptionValue:e=>e.value,getOptionLabel:e=>e.label,placeholder:o("selectTimezone")||"Selecione o fuso horário",searchPlaceholder:o("searchTimezone")||"Buscar fuso horário...",sortOptions:!1})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(d.Calendar,{className:"h-4 w-4"}),o("dateTimeFormat")||"Formato de Data/Hora"]}),e.jsx(ia,{options:Er,value:a,onChange:e=>"string"==typeof e&&n(e),getOptionValue:e=>e.value,getOptionLabel:e=>`${e.label} • ${e.example}`,placeholder:o("selectDateFormat")||"Selecione o formato",searchPlaceholder:o("searchDateFormat")||"Buscar formato...",sortOptions:!1})]})]})},Rl=t.memo(({variant:a="card",className:s="",selectedUnit:r,onUnitChange:n})=>{const{user:i,companies:o,alias:l,isAuthenticated:c,logout:u,switchUnit:m}=ls(),[h,p]=t.useState(!1),f="true"===(void 0).VITE_SHOW_USER_PREFERENCES,x=o?.[0]||null,g=l?o?.find(e=>e.alias===l):x,b=o||[],v=r||g||x||x,w=t.useCallback(e=>{n?n(e):m(e)},[n,m]),N=t.useMemo(()=>{if(!b?.length)return[];const e=new Map;b.forEach(t=>{e.set(t.alias,t)});const t=Array.from(e.values()),a=t.find(e=>e.alias===v?.alias),s=t.filter(e=>e.alias!==v?.alias);return s.sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"})),a?[a,...s]:s},[b,v?.alias]);if(!c||!i)return null;const y=()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:e.jsx(d.User,{className:"h-5 w-5 text-primary-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:i.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",v?.name||"N/A"]})]})]}),v&&e.jsx("div",{className:"mt-3",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:v.name})]})}),N.length>1&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",N.length]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[N.slice(0,3).map(t=>e.jsx(yt,{variant:t.alias===v?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>w(t),children:t.name},t.alias)),N.length>3&&e.jsxs(yt,{variant:"outline",className:"text-xs",children:["+",N.length-3]})]})]})]});return"dropdown"===a?e.jsxs(St,{children:[e.jsx(Tt,{asChild:!0,children:e.jsx(Ie,{variant:"ghost",className:`h-auto p-2 ${s}`,children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("div",{className:"hidden md:block text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:i.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:v?.name||"N/A"})]}),e.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:e.jsx(d.User,{className:"h-4 w-4 text-primary-foreground"})}),e.jsx(d.ChevronDown,{className:"h-4 w-4"})]})})}),e.jsxs(_t,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[e.jsxs(It,{children:[e.jsxs(Et,{children:[e.jsx(d.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),e.jsx(Dt,{children:N.map(t=>e.jsxs(Rt,{onClick:()=>w(t),className:t.alias===v?.alias?"bg-muted":"",children:[e.jsx(d.Building2,{className:"mr-2 h-4 w-4"}),t.name,t.alias===v?.alias&&e.jsx(yt,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},t.alias))})]}),f&&e.jsx(Ot,{}),f&&e.jsxs(Rt,{onClick:()=>p(!0),children:[e.jsx(d.Settings,{className:"mr-2 h-4 w-4"}),"Preferências"]}),e.jsxs(Rt,{onClick:u,children:[e.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]}),f&&e.jsx(qe,{open:h,onOpenChange:p,children:e.jsxs(Ye,{children:[e.jsx(Qe,{showSeparator:!0,children:e.jsx(Ze,{children:"Preferências de Internacionalização"})}),e.jsx(Xe,{children:e.jsx(_l,{})})]})})]}):e.jsxs(Re,{className:s,children:[e.jsx(ze,{children:e.jsx(Fe,{className:"text-lg",children:"Informações do Usuário"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(y,{}),e.jsx($e,{}),f&&e.jsxs(Ie,{variant:"outline",onClick:()=>p(!0),size:"sm",className:"w-full",children:[e.jsx(d.Settings,{className:"mr-2 h-4 w-4"}),"Preferências"]}),e.jsxs(Ie,{variant:"outline",onClick:u,size:"sm",className:"w-full",children:[e.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]}),f&&e.jsx(qe,{open:h,onOpenChange:p,children:e.jsxs(Ye,{children:[e.jsx(Qe,{showSeparator:!0,children:e.jsx(Ze,{children:"Preferências de Internacionalização"})}),e.jsx(Xe,{children:e.jsx(_l,{})})]})})]})]})}),zl=t.createContext({});function Fl({children:a,config:s}){const r=t.useMemo(()=>({navigation:s?.navigation,appName:s?.appName}),[s?.navigation,s?.appName]);return e.jsx(zl.Provider,{value:r,children:a})}function Ll(){return t.useContext(zl)}function Ol(){const e=y.useLocation(),{navigation:t}=Ll(),{t:a}=v.useTranslation();if(!t)return a("page");const s=t.find(t=>t.path===e.pathname);if(s)return s.label;const r=t.find(t=>e.pathname.startsWith(t.path+"/"));return r?.label||a("page")}function Ul(e,a){const[s,r]=t.useState(e),n=t.useRef(),i=t.useCallback(()=>{n.current&&(clearTimeout(n.current),n.current=void 0)},[]);return t.useEffect(()=>(i(),n.current=setTimeout(()=>{r(e)},a),i),[e,a,i]),[s,i]}const $l=t.memo(function({actions:a}){const s=y.useLocation(),r=Ol(),{navigation:n,appName:i}=Ll(),{metadata:o,headerActions:l}=Nr(),{t:c}=v.useTranslation(),{companies:u,alias:m,isSearchVisible:h,clearSearch:p,refreshData:f,switchUnit:x}=ls(),g=m?u?.find(e=>e.alias===m)||u?.[0]||null:u?.[0]||null,[b,w]=y.useSearchParams(),[N,j]=t.useState(()=>b.get("search")||""),[C,k]=Ul(N,Oa.debounceDelay);t.useEffect(()=>{if(!h)return;const e=new URLSearchParams(b);C?(e.set("search",C),e.set("page","1")):e.delete("search"),w(e)},[C,w,h]);const S=n?.find(e=>e.path===s.pathname)||n?.find(e=>s.pathname.startsWith(e.path+"/")),T=o.title||r,P=o.subtitle||S?.complementaryText||c("item_details");return e.jsx("header",{className:"bg-background border-b border-border px-2 md:px-4 py-2",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:T}),e.jsx(yt,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:i||c("module")})]}),P&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:P})]}),h&&e.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(d.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Ee,{placeholder:c("search"),value:N,onChange:e=>(e=>{j(e)})(e.target.value),className:"w-full pl-10 pr-8"}),N&&e.jsx(Ie,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-muted",onClick:()=>{k(),j("");const e=new URLSearchParams(b);e.delete("search"),e.delete("page"),w(e)},title:c("clear_search"),children:e.jsx(d.X,{size:14})})]}),e.jsx(Ie,{variant:"outline",size:"sm",onClick:f,className:"flex-shrink-0 h-10 w-10 p-0",title:c("refresh_data"),children:e.jsx(d.RefreshCw,{size:14})})]}),e.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(l||a)&&e.jsx("div",{className:"flex items-center gap-2",children:l||a}),(void 0).VITE_WIKI_URL&&e.jsx(Ie,{variant:"secondary",size:"sm",className:"h-8 px-3",onClick:e=>Se((void 0).VITE_WIKI_URL,e),title:c("open_wiki"),children:"Wiki"}),e.jsx("div",{className:"text-sm",children:e.jsx(Rl,{variant:"dropdown",selectedUnit:g,onUnitChange:x})})]})]})})}),ql=({key:e,enabled:t,checkFn:a,staleTime:s=3e5,gcTime:r=6e5})=>N.useQuery({queryKey:["permission",e],queryFn:a,enabled:t,staleTime:s,gcTime:r,retry:0,refetchOnWindowFocus:!1}),Hl=(e={})=>{const{enabled:t=!0}=e,{alias:a}=ls();return N.useQuery({queryKey:["active-modules",a],queryFn:async()=>{if(!a)return[];const e=Sa(),{data:t,error:s}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",a).eq("status","active").order("name");if(s){if(!Aa.handleError(s))throw s;return[]}return t||[]},enabled:t&&!!a})},Bl="forlogic-sidebar-pinned",Wl=()=>{try{const e=localStorage.getItem(Bl);return!!e&&JSON.parse(e)}catch{return!1}},Vl=e=>{const t=["border-l-yellow-400","border-l-green-400","border-l-blue-400","border-l-red-400","border-l-purple-400","border-l-pink-400"];return t[e%t.length]},Gl=`https://${(void 0).VITE_SUPABASE_PROJECT_ID_STORAGE??(void 0).VITE_SUPABASE_PROJECT_ID}.supabase.co/storage/v1/object/public/library-assets`,Yl={logo:`${Gl}/${Ha.isQualiex?"logo-qualiex.svg":"logo.svg"}`,smallLogo:`${Gl}/${Ha.isQualiex?"small-forlogic.svg":"small.svg"}`},Ql=Yl.logo,Xl=Yl.smallLogo;function Kl({appName:t,isPinned:a,onPinToggle:s,open:r,dropdownOpen:n,onDropdownChange:i}){const{t:o}=v.useTranslation(),{data:l,isLoading:c,error:u}=Hl({enabled:n}),m=e=>{((e,t)=>{const a=e?.find(e=>e.url===t);a?.url&&window.open(a.url,"_blank")})(l,e)};return e.jsxs(ko,{className:"p-0 gap-0",children:[e.jsx("div",{className:"flex items-center justify-between h-[34px]",children:r?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center pl-[12px]",children:e.jsx("img",{src:Yl.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),e.jsx("button",{onClick:s,className:"h-8 w-8 flex items-center justify-center rounded-md transition-colors duration-200 "+(a?"bg-primary/20 text-primary":"hover:bg-muted text-muted-foreground"),children:e.jsx(d.PanelLeft,{className:"h-4 w-4"})})]}):e.jsx("div",{className:"flex items-center justify-center w-full h-[34px]",children:e.jsx("img",{src:Yl.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),e.jsx("div",{className:"mt-2 pt-0",children:e.jsxs(St,{onOpenChange:i,children:[e.jsx(Tt,{asChild:!0,children:r?e.jsxs("div",{className:"bg-muted hover:bg-muted/80 text-foreground font-medium text-sm flex items-center justify-between cursor-pointer transition-all duration-200 h-8 px-3 gap-3 rounded-md w-full",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("img",{src:"https://ccjfvpnndclajkleyqkc.supabase.co/storage/v1/object/public/library-assets/composit.svg",alt:"Menu",className:"h-6 w-6 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:t})]}),e.jsx(d.ChevronDown,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):e.jsx("div",{className:"flex items-center justify-center w-full h-8 bg-muted hover:bg-muted/80 rounded-md cursor-pointer transition-all duration-200 p-[5px]",children:e.jsx(d.ChevronDown,{className:"h-6 w-6 text-muted-foreground"})})}),e.jsx(_t,{className:r?"w-80 bg-popover rounded-lg shadow-lg border border-border p-4 z-50":"w-[58px] bg-popover rounded-lg shadow-lg border border-border p-2 z-50",align:r?"start":"center",children:c?e.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[e.jsx(d.Loader2,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:o("loading")})]}):u?e.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[e.jsx(d.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:o("error")})]}):l&&0!==l.length?e.jsx("div",{className:"space-y-2",children:l.map((t,a)=>e.jsx("div",{onClick:()=>m(t.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${Vl(a)} transition-colors duration-200\n `,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium text-foreground text-sm",children:t.name}),t.url&&e.jsx(d.ExternalLink,{className:"h-4 w-4 text-muted-foreground"})]})},t.id))}):e.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:o("no_results")})})]})})]})}function Zl({config:t,isCollapsed:a=!1,isDisabled:s=!1,className:r}){const{actions:n,triggerLabel:i="Criar",triggerIcon:o=d.Plus}=t;if(!n||0===n.length)return null;const l=(t,s,r=!1)=>e.jsxs(e.Fragment,{children:[t,!a&&s&&e.jsx("span",{className:"truncate",children:s}),!a&&r&&e.jsx(d.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(n.length>1)){const t=n[0],i=t.icon||o,d=s||t.disabled,c=e.jsx(Ie,{onClick:t.onClick,disabled:d,className:Te("w-full gap-2 justify-start",a&&"justify-center px-2",r),variant:"outline",size:"default",children:l(e.jsx(i,{className:"h-4 w-4 shrink-0"}),t.label)});return a?e.jsxs(qt,{children:[e.jsx(Ht,{asChild:!0,children:c}),e.jsx(Bt,{side:"right",children:e.jsx("p",{children:t.label})})]}):c}const c=e.jsx(Ie,{disabled:s,className:Te("w-full gap-2 justify-start",a&&"justify-center px-2",r),variant:"outline",size:"default",children:l(e.jsx(o,{className:"h-4 w-4 shrink-0"}),i,!0)});return e.jsxs(St,{children:[e.jsx(Tt,{asChild:!0,children:a?e.jsxs(qt,{children:[e.jsx(Ht,{asChild:!0,children:c}),e.jsx(Bt,{side:"right",children:e.jsx("p",{children:i})})]}):c}),e.jsx(_t,{align:"start",side:a?"right":"bottom",className:"w-56 bg-popover",children:n.map(t=>{const a=t.icon;return e.jsxs(Rt,{onClick:t.onClick,disabled:t.disabled,className:"cursor-pointer",children:[a&&e.jsx(a,{className:"mr-2 h-4 w-4"}),t.label]},t.id)})})]})}function Jl({direction:e="right",minWidth:a=224,maxWidth:s=384,defaultWidth:r=240,storageKey:n="sidebar-width",onResize:i,isOpen:o=!0}={}){const[l,d]=t.useState(()=>{if("undefined"==typeof window)return r;const e=localStorage.getItem(n);return e?parseInt(e):r}),[c,u]=t.useState(!1),m=t.useRef(null);t.useEffect(()=>{const e=document.querySelector(".sidebar-container");e&&e instanceof HTMLElement&&(o?e.style.setProperty("--sidebar-width",`${l}px`):e.style.setProperty("--sidebar-width","240px"))},[l,o]);const h=t.useCallback(e=>{e.preventDefault(),u(!0)},[]);return t.useEffect(()=>{if(!c)return;const t=t=>{let r;r="left"===e?window.innerWidth-t.clientX:t.clientX,r=Math.max(a,Math.min(s,r)),d(r),i?.(r)},r=()=>{u(!1),localStorage.setItem(n,l.toString())};return document.addEventListener("mousemove",t),document.addEventListener("mouseup",r),()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r)}},[c,e,a,s,l,n,i]),t.useEffect(()=>{c?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[c,e]),{width:l,isDragging:c,dragRef:m,handleMouseDown:h}}const ed=t.createContext(void 0);function td(){const e=t.useContext(ed);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function ad({config:a,customContent:s,resizable:r=!1,minWidth:n=224,maxWidth:i=384}={}){const{t:o}=v.useTranslation(),{open:l,setOpen:c}=bo(),u=y.useLocation(),{alias:m,user:h}=ls(),{hasOpenModal:p}=td(),[f,x]=t.useState(!1),[g,b]=t.useState(Wl),[w,N]=t.useState(!1),j=t.useRef(!1),C=r?Jl({minWidth:n,maxWidth:i,storageKey:"app-sidebar-width",isOpen:l}):null;t.useEffect(()=>{c(!!g||!(!w&&!f))},[g,w,f,c]);return e.jsxs(wo,{collapsible:"icon",onMouseEnter:()=>{g||j.current||N(!0)},onMouseLeave:()=>{g||N(!1)},className:"app-sidebar bg-background border-r border-border py-6 px-3",style:C&&l?{width:`${C.width}px`,transition:"none"}:{transition:"all 300ms ease-in-out"},children:[e.jsx(Kl,{appName:a?.appName||o("module_title"),isPinned:g,onPinToggle:()=>{const e=!g;b(e),(e=>{try{localStorage.setItem(Bl,JSON.stringify(e))}catch{}})(e),e||(j.current=!0,N(!1),c(!1),setTimeout(()=>{j.current=!1},300))},open:l,dropdownOpen:f,onDropdownChange:x}),a?.moduleActions&&a.moduleActions.actions.length>0&&e.jsx("div",{className:"px-3 py-2",children:e.jsx($t,{children:e.jsx(Zl,{config:a.moduleActions,isCollapsed:!l,isDisabled:p})})}),e.jsx(Po,{children:s||e.jsx(Mo,{className:"p-0 mt-6",children:e.jsx(Eo,{children:e.jsx(Do,{className:"space-y-2",children:e.jsx($t,{children:a?.navigation?.map((t,a)=>{const s=({item:t,index:a})=>{const r=`${t.path}-${a}-${m??"noalias"}-${h?.id??"nouser"}`,{data:n=!0,isLoading:i}=ql({key:r,enabled:Boolean(t.permissionCheck&&m&&h?.id),checkFn:t.permissionCheck||(()=>Promise.resolve(!0))}),l=t.permissionCheck&&!n;if(l&&"Admin"===t.label)return null;const c=i?d.Loader2:l?d.Lock:t.icon;l?o("restricted_access"):t.complementaryText;return t.children&&t.children.length>0?e.jsx(Qr,{defaultOpen:!0,className:"group/collapsible",children:e.jsxs(_o,{children:[e.jsx(Xr,{asChild:!0,children:e.jsx(zo,{size:"lg",className:"h-10",children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e.jsx(c,{className:"h-5 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:t.label}),e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90 group-data-[collapsible=icon]:hidden"})]})})}),e.jsx(Kr,{children:e.jsx(Uo,{children:t.children.map((t,a)=>e.jsx(s,{item:t,index:a},t.path))})})]})},t.path):e.jsx(_o,{children:l||i?e.jsxs(qt,{children:[e.jsx(Ht,{asChild:!0,children:e.jsx(zo,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e.jsx(c,{className:"h-4 w-4 "+(i?"animate-spin":"")})}),e.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:t.label})]})})}),e.jsx(Bt,{children:e.jsx("p",{children:o(i?"checking_access":"restricted_access")})})]}):e.jsx(zo,{asChild:!0,isActive:(p=t.path,u.pathname===p||u.pathname.startsWith(p+"/")),size:"lg",className:"h-10",children:e.jsxs(y.Link,{to:t.path,className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:e.jsx(c,{className:"h-5 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:t.label})]})})},t.path);var p};return e.jsx(s,{item:t,index:a},t.path)})})})})})}),r&&C&&l&&e.jsx("div",{ref:C.dragRef,onMouseDown:C.handleMouseDown,className:Te("absolute inset-y-0 right-0 w-1 cursor-ew-resize","hover:bg-primary/20 transition-colors","after:absolute after:inset-y-0 after:-left-1 after:-right-1 after:content-['']",C.isDragging&&"bg-primary/40")})]})}const sd=t.memo(function({children:a,sidebar:s,sidebarConfig:r,showHeader:n=!0}){const i=t.useMemo(()=>s||e.jsx(ad,{config:r}),[s,r]),o=t.useMemo(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return e.jsx(Fl,{config:r,children:e.jsx(wr,{children:e.jsx(vo,{defaultOpen:!1,style:o,children:e.jsxs("div",{className:"sidebar-container min-h-screen flex w-full",children:[i,e.jsxs("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[n&&e.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:e.jsx($l,{})}),e.jsx("div",{className:"flex-1 overflow-hidden bg-muted/30",children:a})]})]})})})})});const rd=6048e5;function nd(e){const t=Dn(e);return t.setHours(0,0,0,0),t}function id(e){const t=Dn(e),a=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return a.setUTCFullYear(t.getFullYear()),+e-+a}function od(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function ld(e){const t=Dn(e),a=function(e,t){const a=nd(e),s=nd(t),r=+a-id(a),n=+s-id(s);return Math.round((r-n)/864e5)}(t,function(e){const t=Dn(e),a=od(e,0);return a.setFullYear(t.getFullYear(),0,1),a.setHours(0,0,0,0),a}(t));return a+1}function dd(e){return zn(e,{weekStartsOn:1})}function cd(e){const t=Dn(e),a=t.getFullYear(),s=od(e,0);s.setFullYear(a+1,0,4),s.setHours(0,0,0,0);const r=dd(s),n=od(e,0);n.setFullYear(a,0,4),n.setHours(0,0,0,0);const i=dd(n);return t.getTime()>=r.getTime()?a+1:t.getTime()>=i.getTime()?a:a-1}function ud(e){const t=Dn(e),a=+dd(t)-+function(e){const t=cd(e),a=od(e,0);return a.setFullYear(t,0,4),a.setHours(0,0,0,0),dd(a)}(t);return Math.round(a/rd)+1}function md(e,t){const a=Dn(e),s=a.getFullYear(),r=Rn(),n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,i=od(e,0);i.setFullYear(s+1,0,n),i.setHours(0,0,0,0);const o=zn(i,t),l=od(e,0);l.setFullYear(s,0,n),l.setHours(0,0,0,0);const d=zn(l,t);return a.getTime()>=o.getTime()?s+1:a.getTime()>=d.getTime()?s:s-1}function hd(e,t){const a=Dn(e),s=+zn(a,t)-+function(e,t){const a=Rn(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,r=md(e,t),n=od(e,0);return n.setFullYear(r,0,s),n.setHours(0,0,0,0),zn(n,t)}(a,t);return Math.round(s/rd)+1}function pd(e,t){return(e<0?"-":"")+Math.abs(e).toString().padStart(t,"0")}const fd={y(e,t){const a=e.getFullYear(),s=a>0?a:1-a;return pd("yy"===t?s%100:s,t.length)},M(e,t){const a=e.getMonth();return"M"===t?String(a+1):pd(a+1,2)},d:(e,t)=>pd(e.getDate(),t.length),a(e,t){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.toUpperCase();case"aaa":return a;case"aaaaa":return a[0];default:return"am"===a?"a.m.":"p.m."}},h:(e,t)=>pd(e.getHours()%12||12,t.length),H:(e,t)=>pd(e.getHours(),t.length),m:(e,t)=>pd(e.getMinutes(),t.length),s:(e,t)=>pd(e.getSeconds(),t.length),S(e,t){const a=t.length,s=e.getMilliseconds();return pd(Math.trunc(s*Math.pow(10,a-3)),t.length)}},xd="midnight",gd="noon",bd="morning",vd="afternoon",wd="evening",Nd="night",yd={G:function(e,t,a){const s=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return a.era(s,{width:"abbreviated"});case"GGGGG":return a.era(s,{width:"narrow"});default:return a.era(s,{width:"wide"})}},y:function(e,t,a){if("yo"===t){const t=e.getFullYear(),s=t>0?t:1-t;return a.ordinalNumber(s,{unit:"year"})}return fd.y(e,t)},Y:function(e,t,a,s){const r=md(e,s),n=r>0?r:1-r;if("YY"===t){return pd(n%100,2)}return"Yo"===t?a.ordinalNumber(n,{unit:"year"}):pd(n,t.length)},R:function(e,t){return pd(cd(e),t.length)},u:function(e,t){return pd(e.getFullYear(),t.length)},Q:function(e,t,a){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(s);case"QQ":return pd(s,2);case"Qo":return a.ordinalNumber(s,{unit:"quarter"});case"QQQ":return a.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return a.quarter(s,{width:"narrow",context:"formatting"});default:return a.quarter(s,{width:"wide",context:"formatting"})}},q:function(e,t,a){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(s);case"qq":return pd(s,2);case"qo":return a.ordinalNumber(s,{unit:"quarter"});case"qqq":return a.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return a.quarter(s,{width:"narrow",context:"standalone"});default:return a.quarter(s,{width:"wide",context:"standalone"})}},M:function(e,t,a){const s=e.getMonth();switch(t){case"M":case"MM":return fd.M(e,t);case"Mo":return a.ordinalNumber(s+1,{unit:"month"});case"MMM":return a.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return a.month(s,{width:"narrow",context:"formatting"});default:return a.month(s,{width:"wide",context:"formatting"})}},L:function(e,t,a){const s=e.getMonth();switch(t){case"L":return String(s+1);case"LL":return pd(s+1,2);case"Lo":return a.ordinalNumber(s+1,{unit:"month"});case"LLL":return a.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return a.month(s,{width:"narrow",context:"standalone"});default:return a.month(s,{width:"wide",context:"standalone"})}},w:function(e,t,a,s){const r=hd(e,s);return"wo"===t?a.ordinalNumber(r,{unit:"week"}):pd(r,t.length)},I:function(e,t,a){const s=ud(e);return"Io"===t?a.ordinalNumber(s,{unit:"week"}):pd(s,t.length)},d:function(e,t,a){return"do"===t?a.ordinalNumber(e.getDate(),{unit:"date"}):fd.d(e,t)},D:function(e,t,a){const s=ld(e);return"Do"===t?a.ordinalNumber(s,{unit:"dayOfYear"}):pd(s,t.length)},E:function(e,t,a){const s=e.getDay();switch(t){case"E":case"EE":case"EEE":return a.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return a.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return a.day(s,{width:"short",context:"formatting"});default:return a.day(s,{width:"wide",context:"formatting"})}},e:function(e,t,a,s){const r=e.getDay(),n=(r-s.weekStartsOn+8)%7||7;switch(t){case"e":return String(n);case"ee":return pd(n,2);case"eo":return a.ordinalNumber(n,{unit:"day"});case"eee":return a.day(r,{width:"abbreviated",context:"formatting"});case"eeeee":return a.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(r,{width:"short",context:"formatting"});default:return a.day(r,{width:"wide",context:"formatting"})}},c:function(e,t,a,s){const r=e.getDay(),n=(r-s.weekStartsOn+8)%7||7;switch(t){case"c":return String(n);case"cc":return pd(n,t.length);case"co":return a.ordinalNumber(n,{unit:"day"});case"ccc":return a.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return a.day(r,{width:"narrow",context:"standalone"});case"cccccc":return a.day(r,{width:"short",context:"standalone"});default:return a.day(r,{width:"wide",context:"standalone"})}},i:function(e,t,a){const s=e.getDay(),r=0===s?7:s;switch(t){case"i":return String(r);case"ii":return pd(r,t.length);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return a.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return a.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return a.day(s,{width:"short",context:"formatting"});default:return a.day(s,{width:"wide",context:"formatting"})}},a:function(e,t,a){const s=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return a.dayPeriod(s,{width:"narrow",context:"formatting"});default:return a.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,t,a){const s=e.getHours();let r;switch(r=12===s?gd:0===s?xd:s/12>=1?"pm":"am",t){case"b":case"bb":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return a.dayPeriod(r,{width:"narrow",context:"formatting"});default:return a.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(e,t,a){const s=e.getHours();let r;switch(r=s>=17?wd:s>=12?vd:s>=4?bd:Nd,t){case"B":case"BB":case"BBB":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return a.dayPeriod(r,{width:"narrow",context:"formatting"});default:return a.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(e,t,a){if("ho"===t){let t=e.getHours()%12;return 0===t&&(t=12),a.ordinalNumber(t,{unit:"hour"})}return fd.h(e,t)},H:function(e,t,a){return"Ho"===t?a.ordinalNumber(e.getHours(),{unit:"hour"}):fd.H(e,t)},K:function(e,t,a){const s=e.getHours()%12;return"Ko"===t?a.ordinalNumber(s,{unit:"hour"}):pd(s,t.length)},k:function(e,t,a){let s=e.getHours();return 0===s&&(s=24),"ko"===t?a.ordinalNumber(s,{unit:"hour"}):pd(s,t.length)},m:function(e,t,a){return"mo"===t?a.ordinalNumber(e.getMinutes(),{unit:"minute"}):fd.m(e,t)},s:function(e,t,a){return"so"===t?a.ordinalNumber(e.getSeconds(),{unit:"second"}):fd.s(e,t)},S:function(e,t){return fd.S(e,t)},X:function(e,t,a){const s=e.getTimezoneOffset();if(0===s)return"Z";switch(t){case"X":return Cd(s);case"XXXX":case"XX":return kd(s);default:return kd(s,":")}},x:function(e,t,a){const s=e.getTimezoneOffset();switch(t){case"x":return Cd(s);case"xxxx":case"xx":return kd(s);default:return kd(s,":")}},O:function(e,t,a){const s=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+jd(s,":");default:return"GMT"+kd(s,":")}},z:function(e,t,a){const s=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+jd(s,":");default:return"GMT"+kd(s,":")}},t:function(e,t,a){return pd(Math.trunc(e.getTime()/1e3),t.length)},T:function(e,t,a){return pd(e.getTime(),t.length)}};function jd(e,t=""){const a=e>0?"-":"+",s=Math.abs(e),r=Math.trunc(s/60),n=s%60;return 0===n?a+String(r):a+String(r)+t+pd(n,2)}function Cd(e,t){if(e%60==0){return(e>0?"-":"+")+pd(Math.abs(e)/60,2)}return kd(e,t)}function kd(e,t=""){const a=e>0?"-":"+",s=Math.abs(e);return a+pd(Math.trunc(s/60),2)+t+pd(s%60,2)}const Sd=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},Td=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},Pd={p:Td,P:(e,t)=>{const a=e.match(/(P+)(p+)?/)||[],s=a[1],r=a[2];if(!r)return Sd(e,t);let n;switch(s){case"P":n=t.dateTime({width:"short"});break;case"PP":n=t.dateTime({width:"medium"});break;case"PPP":n=t.dateTime({width:"long"});break;default:n=t.dateTime({width:"full"})}return n.replace("{{date}}",Sd(s,t)).replace("{{time}}",Td(r,t))}},Md=/^D+$/,Id=/^Y+$/,Ad=["D","DD","YY","YYYY"];function Ed(e){if(!function(e){return e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e)}(e)&&"number"!=typeof e)return!1;const t=Dn(e);return!isNaN(Number(t))}const Dd=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,_d=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Rd=/^'([^]*?)'?$/,zd=/''/g,Fd=/[a-zA-Z]/;function Ld(e,t,a){const s=Rn(),r=a?.locale??s.locale??$n,n=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,i=a?.weekStartsOn??a?.locale?.options?.weekStartsOn??s.weekStartsOn??s.locale?.options?.weekStartsOn??0,o=Dn(e);if(!Ed(o))throw new RangeError("Invalid time value");let l=t.match(_d).map(e=>{const t=e[0];if("p"===t||"P"===t){return(0,Pd[t])(e,r.formatLong)}return e}).join("").match(Dd).map(e=>{if("''"===e)return{isToken:!1,value:"'"};const t=e[0];if("'"===t)return{isToken:!1,value:Od(e)};if(yd[t])return{isToken:!0,value:e};if(t.match(Fd))throw new RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});r.localize.preprocessor&&(l=r.localize.preprocessor(o,l));const d={firstWeekContainsDate:n,weekStartsOn:i,locale:r};return l.map(s=>{if(!s.isToken)return s.value;const n=s.value;(!a?.useAdditionalWeekYearTokens&&function(e){return Id.test(e)}(n)||!a?.useAdditionalDayOfYearTokens&&function(e){return Md.test(e)}(n))&&function(e,t,a){const s=function(e,t,a){const s="Y"===e[0]?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${s} to the input \`${a}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(e,t,a);if(Ad.includes(e))throw new RangeError(s)}(n,t,String(e));return(0,yd[n[0]])(o,n,r.localize,d)}).join("")}function Od(e){const t=e.match(Rd);return t?t[1].replace(zd,"'"):e}function Ud(e,t,a){const s=i.getDefaultOptions(),r=function(e,t,a){return new Intl.DateTimeFormat(a?[a.code,"en-US"]:void 0,{timeZone:t,timeZoneName:e})}(e,a.timeZone,a.locale??s.locale);return"formatToParts"in r?function(e,t){const a=e.formatToParts(t);for(let s=a.length-1;s>=0;--s)if("timeZoneName"===a[s].type)return a[s].value;return}(r,t):function(e,t){const a=e.format(t).replace(/\u200E/g,""),s=/ [\w-+ ]+$/.exec(a);return s?s[0].substr(1):""}(r,t)}function $d(e,t){const a=function(e){Hd[e]||(Hd[e]=Wd?new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}));return Hd[e]}(t);return"formatToParts"in a?function(e,t){try{const a=e.formatToParts(t),s=[];for(let e=0;e<a.length;e++){const t=qd[a[e].type];void 0!==t&&(s[t]=parseInt(a[e].value,10))}return s}catch(a){if(a instanceof RangeError)return[NaN];throw a}}(a,e):function(e,t){const a=e.format(t),s=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(a);return[parseInt(s[3],10),parseInt(s[1],10),parseInt(s[2],10),parseInt(s[4],10),parseInt(s[5],10),parseInt(s[6],10)]}(a,e)}const qd={year:0,month:1,day:2,hour:3,minute:4,second:5};const Hd={},Bd=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),Wd="06/25/2014, 00:00:00"===Bd||"06/25/2014 00:00:00"===Bd;function Vd(e,t,a,s,r,n,i){const o=new Date(0);return o.setUTCFullYear(e,t,a),o.setUTCHours(s,r,n,i),o}const Gd=36e5,Yd={timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function Qd(e,t,a){if(!e)return 0;let s,r,n=Yd.timezoneZ.exec(e);if(n)return 0;if(n=Yd.timezoneHH.exec(e),n)return s=parseInt(n[1],10),Kd(s)?-s*Gd:NaN;if(n=Yd.timezoneHHMM.exec(e),n){s=parseInt(n[2],10);const e=parseInt(n[3],10);return Kd(s,e)?(r=Math.abs(s)*Gd+6e4*e,"+"===n[1]?-r:r):NaN}if(function(e){if(Zd[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),Zd[e]=!0,!0}catch(t){return!1}}(e)){t=new Date(t||Date.now());const s=a?t:function(e){return Vd(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t),r=Xd(s,e),n=a?r:function(e,t,a){const s=e.getTime();let r=s-t;const n=Xd(new Date(r),a);if(t===n)return t;r-=n-t;const i=Xd(new Date(r),a);if(n===i)return n;return Math.max(n,i)}(t,r,e);return-n}return NaN}function Xd(e,t){const a=$d(e,t),s=Vd(a[0],a[1]-1,a[2],a[3]%24,a[4],a[5],0).getTime();let r=e.getTime();const n=r%1e3;return r-=n>=0?n:1e3+n,s-r}function Kd(e,t){return-23<=e&&e<=23&&(null==t||0<=t&&t<=59)}const Zd={};const Jd={X:function(e,t,a){const s=ec(a.timeZone,e);if(0===s)return"Z";switch(t){case"X":return sc(s);case"XXXX":case"XX":return ac(s);default:return ac(s,":")}},x:function(e,t,a){const s=ec(a.timeZone,e);switch(t){case"x":return sc(s);case"xxxx":case"xx":return ac(s);default:return ac(s,":")}},O:function(e,t,a){const s=ec(a.timeZone,e);switch(t){case"O":case"OO":case"OOO":return"GMT"+function(e,t=""){const a=e>0?"-":"+",s=Math.abs(e),r=Math.floor(s/60),n=s%60;if(0===n)return a+String(r);return a+String(r)+t+tc(n,2)}(s,":");default:return"GMT"+ac(s,":")}},z:function(e,t,a){switch(t){case"z":case"zz":case"zzz":return Ud("short",e,a);default:return Ud("long",e,a)}}};function ec(e,t){const a=e?Qd(e,t,!0)/6e4:t?.getTimezoneOffset()??0;if(Number.isNaN(a))throw new RangeError("Invalid time zone specified: "+e);return a}function tc(e,t){const a=e<0?"-":"";let s=Math.abs(e).toString();for(;s.length<t;)s="0"+s;return a+s}function ac(e,t=""){const a=e>0?"-":"+",s=Math.abs(e);return a+tc(Math.floor(s/60),2)+t+tc(Math.floor(s%60),2)}function sc(e,t){if(e%60==0){return(e>0?"-":"+")+tc(Math.abs(e)/60,2)}return ac(e,t)}function rc(e){const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+e-+t}const nc=36e5,ic=6e4,oc={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/};function lc(e,t={}){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(null===e)return new Date(NaN);const a=null==t.additionalDigits?2:Number(t.additionalDigits);if(2!==a&&1!==a&&0!==a)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e))return new Date(e.getTime());if("number"==typeof e||"[object Number]"===Object.prototype.toString.call(e))return new Date(e);if("[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);const s=function(e){const t={};let a,s=oc.dateTimePattern.exec(e);s?(t.date=s[1],a=s[3]):(s=oc.datePattern.exec(e),s?(t.date=s[1],a=s[2]):(t.date=null,a=e));if(a){const e=oc.timeZone.exec(a);e?(t.time=a.replace(e[1],""),t.timeZone=e[1].trim()):t.time=a}return t}(e),{year:r,restDateString:n}=function(e,t){if(e){const a=oc.YYY[t],s=oc.YYYYY[t];let r=oc.YYYY.exec(e)||s.exec(e);if(r){const t=r[1];return{year:parseInt(t,10),restDateString:e.slice(t.length)}}if(r=oc.YY.exec(e)||a.exec(e),r){const t=r[1];return{year:100*parseInt(t,10),restDateString:e.slice(t.length)}}}return{year:null}}(s.date,a),i=function(e,t){if(null===t)return null;let a,s,r;if(!e||!e.length)return a=new Date(0),a.setUTCFullYear(t),a;let n=oc.MM.exec(e);if(n)return a=new Date(0),s=parseInt(n[1],10)-1,hc(t,s)?(a.setUTCFullYear(t,s),a):new Date(NaN);if(n=oc.DDD.exec(e),n){a=new Date(0);const e=parseInt(n[1],10);return function(e,t){if(t<1)return!1;const a=mc(e);if(a&&t>366)return!1;if(!a&&t>365)return!1;return!0}(t,e)?(a.setUTCFullYear(t,0,e),a):new Date(NaN)}if(n=oc.MMDD.exec(e),n){a=new Date(0),s=parseInt(n[1],10)-1;const e=parseInt(n[2],10);return hc(t,s,e)?(a.setUTCFullYear(t,s,e),a):new Date(NaN)}if(n=oc.Www.exec(e),n)return r=parseInt(n[1],10)-1,pc(r)?dc(t,r):new Date(NaN);if(n=oc.WwwD.exec(e),n){r=parseInt(n[1],10)-1;const e=parseInt(n[2],10)-1;return pc(r,e)?dc(t,r,e):new Date(NaN)}return null}(n,r);if(null===i||isNaN(i.getTime()))return new Date(NaN);if(i){const e=i.getTime();let a,r=0;if(s.time&&(r=function(e){let t,a,s=oc.HH.exec(e);if(s)return t=parseFloat(s[1].replace(",",".")),fc(t)?t%24*nc:NaN;if(s=oc.HHMM.exec(e),s)return t=parseInt(s[1],10),a=parseFloat(s[2].replace(",",".")),fc(t,a)?t%24*nc+a*ic:NaN;if(s=oc.HHMMSS.exec(e),s){t=parseInt(s[1],10),a=parseInt(s[2],10);const e=parseFloat(s[3].replace(",","."));return fc(t,a,e)?t%24*nc+a*ic+1e3*e:NaN}return null}(s.time),null===r||isNaN(r)))return new Date(NaN);if(s.timeZone||t.timeZone){if(a=Qd(s.timeZone||t.timeZone,new Date(e+r)),isNaN(a))return new Date(NaN)}else a=rc(new Date(e+r)),a=rc(new Date(e+r+a));return new Date(e+r+a)}return new Date(NaN)}function dc(e,t,a){t=t||0,a=a||0;const s=new Date(0);s.setUTCFullYear(e,0,4);const r=7*t+a+1-(s.getUTCDay()||7);return s.setUTCDate(s.getUTCDate()+r),s}const cc=[31,28,31,30,31,30,31,31,30,31,30,31],uc=[31,29,31,30,31,30,31,31,30,31,30,31];function mc(e){return e%400==0||e%4==0&&e%100!=0}function hc(e,t,a){if(t<0||t>11)return!1;if(null!=a){if(a<1)return!1;const s=mc(e);if(s&&a>uc[t])return!1;if(!s&&a>cc[t])return!1}return!0}function pc(e,t){return!(e<0||e>52)&&(null==t||!(t<0||t>6))}function fc(e,t,a){return!(e<0||e>=25)&&((null==t||!(t<0||t>=60))&&(null==a||!(a<0||a>=60)))}const xc=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function gc(e,t,a,s){return function(e,t,a={}){const s=(t=String(t)).match(xc);if(s){const r=lc(a.originalDate||e,a);t=s.reduce(function(e,t){if("'"===t[0])return e;const s=e.indexOf(t),n="'"===e[s-1],i=e.replace(t,"'"+Jd[t[0]](r,t,a)+"'");return n?i.substring(0,s-1)+i.substring(s+1):i},t)}return Ld(e,t,a)}(function(e,t,a){const s=Qd(t,e=lc(e,a),!0),r=new Date(e.getTime()-s),n=new Date(0);return n.setFullYear(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate()),n.setHours(r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()),n}(e,t,{timeZone:(s={...s,timeZone:t,originalDate:e}).timeZone}),a,s)}const bc={"pt-BR":ei,"en-US":$n,"es-ES":Yn},vc=(e,t=_r,a=zr)=>{if(!e)return"";const s=i.parseISO(e);if(!i.isValid(s))return"Data inválida";const r=bc[t]||ei;try{return gc(s,a,"PP",{locale:r})}catch(n){return gc(s,zr,"PP",{locale:r})}};class wc{static async sendEmail(e){const t=Sa(),{data:a,error:s}=await t.functions.invoke("send-email",{body:{template_code:e.templateCode,to:e.to,variables:e.variables,cc:e.cc,bcc:e.bcc,replyTo:e.replyTo}});if(s)throw s;return a}}const Nc=wc;function yc({open:a,onOpenChange:s,placeId:r,placeName:n,onMakeManager:i,onMakeMembers:o,currentManagerId:l,currentMemberIds:c=[]}){const{t:u}=v.useTranslation(),[m,h]=t.useState([]),[p,f]=t.useState(!1),[x,g]=t.useState(""),{data:b=[],isLoading:w}=er({enabled:a}),N=t.useMemo(()=>{let e=[...b];if(e.sort((e,t)=>{const a=e.userName?.toLowerCase()||"",s=t.userName?.toLowerCase()||"";return a.localeCompare(s)}),x){const t=x.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(t)||e.userEmail?.toLowerCase().includes(t))}return e},[b,x]),y=e=>{h(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},j=1===m.length,C=m.length>0;return e.jsx(qe,{open:a,onOpenChange:s,children:e.jsxs(Ye,{className:"max-w-2xl",children:[e.jsx(Qe,{showSeparator:!0,children:e.jsxs(Ze,{className:"flex items-center gap-2",children:[e.jsx(d.Users,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),e.jsxs(Xe,{children:[e.jsxs("div",{className:"relative mb-4",children:[e.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ee,{placeholder:u("search_placeholder"),value:x,onChange:e=>g(e.target.value),className:"pl-9"})]}),e.jsx(Qs,{className:"h-[400px] pr-4",children:w?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((t,a)=>e.jsx(sa,{className:"h-16 w-full"},a))}):0===N.length?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(d.Users,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:x?"Nenhum usuário encontrado":"Nenhum usuário disponível"})]}):e.jsx("div",{className:"space-y-2",children:N.map(t=>{const a=t.userId===l,s=c.includes(t.userId||""),r=m.includes(t.userId||"");return e.jsxs("div",{className:Te("flex items-center gap-3 p-3 rounded-lg border transition-colors",r&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>y(t.userId||""),children:[e.jsx(vt,{checked:r,onCheckedChange:()=>y(t.userId||""),onClick:e=>e.stopPropagation()}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:t.userName}),a&&e.jsx(d.Crown,{className:"h-4 w-4 text-yellow-500"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t.userEmail})]}),(a||s)&&e.jsx("div",{className:"text-xs text-muted-foreground",children:a?"Gestor":"Membro"})]},t.userId)})})})]}),e.jsxs(Ke,{className:"flex gap-2 sm:gap-2",children:[e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:m.length>0&&e.jsxs("span",{children:[m.length," selecionado(s)"]})}),j&&i&&e.jsxs(Ie,{onClick:async()=>{if(i&&1===m.length){f(!0);try{await i(m[0],r),h([])}finally{f(!1)}}},disabled:p,variant:"outline",children:[e.jsx(d.Crown,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),C&&o&&e.jsxs(Ie,{onClick:async()=>{if(o&&0!==m.length){f(!0);try{await o(m,r),h([])}finally{f(!1)}}},disabled:p,children:[e.jsx(d.UserPlus,{className:"h-4 w-4 mr-2"}),"Tornar ",m.length>1?"Membros":"Membro"]})]})]})})}function jc({place:a,level:s=0,manageAccessConfig:r}){const[n,i]=t.useState(!1),[o,l]=t.useState(!1),c=a.subPlaces&&a.subPlaces.length>0,u=a.isActive??!0,m=a.usersCount??0;return e.jsxs("div",{children:[e.jsxs(Qr,{open:n,onOpenChange:i,children:[e.jsxs("div",{className:"flex items-center gap-2 py-3 px-4 hover:bg-accent/50 transition-colors",style:{paddingLeft:2*s+1+"rem"},children:[c?e.jsxs(Xr,{className:"flex items-center gap-2 flex-1",children:[e.jsx(d.ChevronRight,{className:Te("h-4 w-4 transition-transform shrink-0",n&&"rotate-90")}),e.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:a.name}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",a.subPlaces.length,")"]})]}):e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx("div",{className:"w-4 shrink-0"}),e.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:a.name})]}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(d.Users,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:m})]}),e.jsx(yt,{variant:u?"default":"secondary",className:"text-xs",children:u?"Ativo":"Inativo"}),r&&e.jsx(El,{customActions:[{label:"Gerenciar Acessos",icon:d.Settings,onClick:()=>l(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),c&&e.jsx(Kr,{children:a.subPlaces.map(t=>e.jsx(jc,{place:t,level:s+1,manageAccessConfig:r},t.id))})]}),0===s&&e.jsx($e,{}),r&&e.jsx(yc,{open:o,onOpenChange:l,placeId:a.id,placeName:a.name,onMakeManager:r.onMakeManager,onMakeMembers:r.onMakeMembers,currentManagerId:r.getCurrentManagerId?.(a.id),currentMemberIds:r.getCurrentMemberIds?.(a.id)})]})}var Cc=Object.defineProperty,kc=(e,t,a)=>((e,t,a)=>t in e?Cc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);const Sc=new class{constructor(){kc(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,t,a){const s=Da.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=xa.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!a||""===a.trim())throw new Error("Alias da unidade é obrigatório");const n=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{n.searchParams.append(e,t)});const i=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!i.ok){const e=new Error(`API call failed: ${i.status}`);throw e.status=i.status,e}return i.json()}buildHierarchy(e){const t=new Map,a=[];return e.forEach(e=>{t.set(e.id,{...e,subPlaces:[]})}),e.forEach(e=>{const s=t.get(e.id);if(e.parentId){const r=t.get(e.parentId);r?(r.subPlaces=r.subPlaces||[],r.subPlaces.push(s)):a.push(s)}else a.push(s)}),a}async getPlaces(e,t){try{const a=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),s=a.data||a||[];return this.buildHierarchy(s)}catch(a){if(await Da.handleApiError(a))try{const a=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),s=a.data||a||[];return this.buildHierarchy(s)}catch(s){return va.handleError(s instanceof Error?s:"Erro ao buscar locais após renovação de token",!0),[]}return va.handleError(a instanceof Error?a.message:"Erro ao buscar locais",!0),[]}}};function Tc(e){const t=new Map,a=new Map,s=[];e.forEach(e=>{const s={...e,children:[],level:0};t.set(e.id,s),a.set(e.id_user,s)}),e.forEach(e=>{const r=t.get(e.id);if(e.id_leader){const t=a.get(e.id_leader);if(t)return void t.children.push(r)}s.push(r)});const r=(e,t)=>{e.level=t,e.children.forEach(e=>r(e,t+1))};s.forEach(e=>r(e,0));const n=e=>{e.sort((e,t)=>{const a=e.name||e.id_user||e.email||"",s=t.name||t.id_user||t.email||"";return a.localeCompare(s)}),e.forEach(e=>e.children.length>0&&n(e.children))};return n(s),s}function Pc(e){const t=[],a=e=>{t.push(e),e.children.forEach(a)};return e.forEach(a),t}function Mc(){const{alias:e,isAuthenticated:t}=ls(),a=xa.getAccessToken(),{data:s=[]}=er({enabled:!0});return N.useQuery({queryKey:["leadership",e,s.length],queryFn:async()=>{if(!a||!e)throw new Error("Usuário não autenticado ou unidade não selecionada");const t=Sa(),{data:r,error:n}=await t.schema("common").from("leaders").select("*").eq("is_removed",!1).eq("alias",e);if(n)throw new Error("Erro ao buscar hierarquia de liderança");if(!r||0===r.length)return[];const i={};s.forEach(e=>{i[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const o=r.map(e=>({...e,name:i[e.id_user]?.name||"[Não encontrado]",email:i[e.id_user]?.email||"",subordinatesCount:r.filter(t=>t.id_leader===e.id_user).length})),l=new Set(r.map(e=>e.id_user));return new Set(r.filter(e=>e.id_leader&&!l.has(e.id_leader)).map(e=>e.id_leader)).forEach(e=>{const t=i[e];o.push({id:`virtual-${e}`,alias:r[0]?.alias||"",id_user:e,id_leader:null,is_removed:!1,is_active:!0,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),name:t?.name||"[Não encontrado]",email:t?.email||"",subordinatesCount:r.filter(t=>t.id_leader===e).length})}),Tc(o)},enabled:!!a&&!!e&&t&&s.length>0})}function Ic(){const e="common",{alias:t}=ls(),a=N.useQueryClient(),s=Sa();return N.useMutation({mutationFn:async a=>{if(!t)throw new Error("Unidade não selecionada");if(a.id_user===a.id_leader)throw new Error("Usuário não pode ser seu próprio líder");a.id_leader&&await Rc(s,t,e,a.id_user,a.id_leader);const{data:r,error:n}=await s.schema(e).from("leaders").insert({alias:t,id_user:a.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return r},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",t]}),l.toast.success("Líder virtual promovido com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao criar líder")}})}function Ac(){const e="common",{alias:t}=ls(),a=N.useQueryClient(),s=Sa();return N.useMutation({mutationFn:async a=>{if(!t)throw new Error("Unidade não selecionada");if(!a.users.length)throw new Error("Selecione pelo menos um liderado");const r=a.users.map(e=>e.id_user),{data:n}=await s.schema(e).from("leaders").select("id_user").eq("alias",t).in("id_user",r).eq("is_removed",!1);if(n&&n.length>0){const e=n.map(e=>e.id_user);throw new Error(`Alguns usuários já estão cadastrados como líderes: ${e.join(", ")}`)}for(const d of a.users){if(a.id_leader&&d.id_user===a.id_leader)throw new Error("Usuário não pode ser seu próprio líder");a.id_leader&&await Rc(s,t,e,d.id_user,a.id_leader)}const i=a.users.map(e=>({alias:t,id_user:e.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1})),{data:o,error:l}=await s.schema(e).from("leaders").insert(i).select();if(l)throw l;return o},onSuccess:e=>{a.invalidateQueries({queryKey:["leadership",t]}),l.toast.success(`${e?.length||0} liderado(s) adicionado(s) com sucesso`)},onError:e=>{l.toast.error(e.message||"Erro ao adicionar liderados")}})}function Ec(){const e="common",{alias:t}=ls(),a=N.useQueryClient(),s=Sa();return N.useMutation({mutationFn:async a=>{if(!t)throw new Error("Unidade não selecionada");const{data:r}=await s.schema(e).from("leaders").select("id_user").eq("id",a.id).eq("alias",t).single();if(!r)throw new Error("Líder não encontrado");if(r.id_user===a.id_leader)throw new Error("Usuário não pode ser seu próprio líder");a.id_leader&&await Rc(s,t,e,r.id_user,a.id_leader,a.id);const{data:n,error:i}=await s.schema(e).from("leaders").update({id_leader:a.id_leader}).eq("id",a.id).eq("alias",t).select().single();if(i)throw i;return n},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",t]}),l.toast.success("Líder atualizado com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao atualizar líder")}})}function Dc(){const{alias:e}=ls(),t=N.useQueryClient(),a=Sa();return N.useMutation({mutationFn:async t=>{if(!e)throw new Error("Unidade não selecionada");const{error:s}=await a.schema("common").from("leaders").update({is_removed:!0}).eq("id",t).eq("alias",e);if(s)throw s},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",e]}),l.toast.success("Líder removido com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao remover líder")}})}function _c(){const e="common",{alias:t}=ls(),a=N.useQueryClient(),s=Sa();return N.useMutation({mutationFn:async({leaderUserId:a,selectedUsers:r})=>{if(!t)throw new Error("Unidade não selecionada");const n=r.map(e=>e.id_user),i=await Promise.all([s.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1).eq("id_leader",a),s.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1).in("id_user",n.length?n:["__none__"])]),[{data:o,error:l},{data:d,error:c}]=i;if(l)throw l;if(c)throw c;const u=o||[],m=d||[],h=new Set(n),p=u.filter(e=>!h.has(e.id_user)),f=m.filter(e=>e.id_leader!==a),x=new Set(m.map(e=>e.id_user)),g=r.filter(e=>!x.has(e.id_user));for(const w of f)await Rc(s,t,e,w.id_user,a,w.id);for(const w of g){if(w.id_user===a)throw new Error("Usuário não pode ser seu próprio líder");await Rc(s,t,e,w.id_user,a)}const b=[];if(p.length){const a=p.map(e=>e.id);b.push(s.schema(e).from("leaders").update({is_removed:!0}).in("id",a).eq("alias",t))}if(f.length){const r=f.map(e=>e.id);b.push(s.schema(e).from("leaders").update({id_leader:a}).in("id",r).eq("alias",t))}if(g.length){const r=g.map(e=>({alias:t,id_user:e.id_user,id_leader:a,is_active:!0,is_removed:!1}));b.push(s.schema(e).from("leaders").insert(r))}const v=(await Promise.all(b)).find(e=>e?.error);if(v?.error)throw v.error;return{unlinked:p.length,updated:f.length,created:g.length}},onSuccess:e=>{a.invalidateQueries({queryKey:["leadership",t]}),l.toast.success(`Subordinados sincronizados (${e.created} adicionados, ${e.updated} atualizados, ${e.unlinked} removidos)`)},onError:e=>{l.toast.error(e.message||"Erro ao sincronizar subordinados")}})}async function Rc(e,t,a,s,r,n){const{data:i,error:o}=await e.schema(a).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1);if(o)throw o;const l=n?i.filter(e=>e.id!==n):i,d=new Set;let c=r;for(;c;){if(d.has(c))throw new Error("Esta associação criaria um ciclo na hierarquia");if(c===s)throw new Error("Esta associação criaria um ciclo na hierarquia");d.add(c);const e=l.find(e=>e.id_user===c);c=e?.id_leader||null}}function zc({leader:t,expandedIds:a,onToggleExpand:s,onEdit:r}){const n=a.has(t.id),i=t.children.length>0,o=32*t.level;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[e.jsx("td",{className:"py-3 px-4",children:e.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${o}px`},children:[i?e.jsx("button",{onClick:()=>s(t.id),className:"p-1 hover:bg-accent rounded",children:n?e.jsx(d.ChevronDown,{className:"h-4 w-4"}):e.jsx(d.ChevronRight,{className:"h-4 w-4"})}):e.jsx("div",{className:"w-6"}),e.jsx(d.User,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("button",{onClick:()=>{r(t)},className:"font-medium hover:text-primary hover:underline text-left",children:t.name||t.id_user||t.email})]})}),e.jsx("td",{className:"py-3 px-4 text-center",children:e.jsx("span",{className:"text-sm",children:t.subordinatesCount||0})})]}),i&&n&&t.children.map(t=>e.jsx(zc,{leader:t,expandedIds:a,onToggleExpand:s,onEdit:r},t.id))]})}var Fc=function(e,t){for(var a={};e.length;){var s=e[0],r=s.code,n=s.message,i=s.path.join(".");if(!a[i])if("unionErrors"in s){var o=s.unionErrors[0].errors[0];a[i]={message:o.message,type:o.code}}else a[i]={message:n,type:r};if("unionErrors"in s&&s.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var l=a[i].types,d=l&&l[s.code];a[i]=h.appendErrors(i,t,a,r,d?[].concat(d,s.message):s.message)}e.shift()}return a},Lc=function(e,t,a){return void 0===a&&(a={}),function(s,r,n){try{return Promise.resolve(function(r,i){try{var o=Promise.resolve(e["sync"===a.mode?"parse":"parseAsync"](s,t)).then(function(e){return n.shouldUseNativeValidation&&K.validateFieldsNatively({},n),{errors:{},values:a.raw?s:e}})}catch(l){return i(l)}return o&&o.then?o.then(void 0,i):o}(0,function(e){if(function(e){return Array.isArray(null==e?void 0:e.errors)}(e))return{values:{},errors:K.toNestErrors(Fc(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(i){return Promise.reject(i)}}};const Oc=X.z.object({id_leader:X.z.string().nullable(),id_users:X.z.array(X.z.string()).min(1,"Selecione pelo menos um liderado")}),Uc=X.z.object({id_leader:X.z.string().nullable(),id_users:X.z.array(X.z.string())});function $c({value:a,onChange:s,excludeUserIds:r=[],error:n}){const{data:i=[],isLoading:o}=er(),[l,c]=t.useState(""),u=t.useRef(null),m=t.useRef(0),{t:h}=v.useTranslation(),p=i.filter(e=>!r.includes(e.userId||"")).filter(e=>{const t=l.toLowerCase(),a=e.userName?.toLowerCase().includes(t);return a}).sort((e,t)=>{const s=a.includes(e.userId),r=a.includes(t.userId);if(s&&!r)return-1;if(!s&&r)return 1;const n=e.userName||e.userEmail||"",i=t.userName||t.userEmail||"";return n.localeCompare(i)});return t.useEffect(()=>{u.current&&m.current>0&&(u.current.scrollTop=m.current)},[p]),o?e.jsxs("div",{className:"flex items-center justify-center p-4",children:[e.jsx(d.Loader2,{className:"h-6 w-6 animate-spin"}),e.jsx("span",{className:"ml-2",children:h("loading_data")})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ee,{placeholder:h("search_user"),value:l,onChange:e=>c(e.target.value)}),e.jsx("div",{ref:u,className:"border rounded-md p-4 max-h-[300px] overflow-y-auto",children:0===p.length?e.jsx("p",{className:"text-sm text-muted-foreground",children:h("search_user")}):e.jsx("div",{className:"space-y-2",children:p.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(vt,{id:t.userId,checked:a.includes(t.userId),onCheckedChange:()=>{return e=t.userId,u.current&&(m.current=u.current.scrollTop),void(a.includes(e)?s(a.filter(t=>t!==e)):s([...a,e]));var e}}),e.jsx(_e,{htmlFor:t.userId,className:"flex-1 cursor-pointer",children:t.userName||t.userEmail})]},t.userId))})}),a.length>0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:h("selected_count",{count:a.length})}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function qc({leader:a,prefilledLeaderId:s,onSuccess:r}){const{t:n}=v.useTranslation(),{alias:i}=ls(),o=!!a,l=a?.id.startsWith("virtual-"),c=Ac(),u=Ic(),m=Ec(),p=_c(),f=Dc(),{data:x=[]}=Mc(),{data:g=[]}=er(),[b,w]=t.useState(""),N=Pc(x).map(e=>e.id_user),y=o?Pc(x).filter(e=>e.id_leader===a.id_user).map(e=>e.id_user):[],j=h.useForm({resolver:Lc(o?Uc:Oc),defaultValues:{id_leader:s||(o?a?.id_leader:null)||null,id_users:o?y:[]}});t.useEffect(()=>{if(a){const e=Pc(x).filter(e=>e.id_leader===a.id_user).map(e=>e.id_user);j.reset({id_leader:a.id_leader||null,id_users:e})}else s?j.reset({id_leader:s,id_users:[]}):j.reset({id_leader:null,id_users:[]})},[i,a?.id,a?.id_user,a?.id_leader,s,x]);const C=c.isPending||u.isPending||m.isPending||p.isPending||f.isPending,k=j.watch("id_leader"),S=j.watch("id_users"),T=o?[a.id_user,...N.filter(e=>e!==a.id_user&&!S.includes(e)&&!y.includes(e))]:[k,...N.filter(e=>!S.includes(e))].filter(Boolean);return e.jsxs("form",{onSubmit:j.handleSubmit(async e=>{try{if(o)if(l){await u.mutateAsync({id_user:a.id_user,id_leader:e.id_leader});const t=g.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await p.mutateAsync({leaderUserId:a.id_user,selectedUsers:t})}else{await m.mutateAsync({id:a.id,id_leader:e.id_leader});const t=g.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await p.mutateAsync({leaderUserId:a.id_user,selectedUsers:t})}else{const t=g.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await c.mutateAsync({id_leader:e.id_leader,users:t})}r?.()}catch(t){}}),className:"space-y-4",children:[o&&e.jsxs("div",{children:[e.jsx(_e,{children:n("leader")}),e.jsx(Ee,{value:g.find(e=>e.userId===a.id_user)?.userName||a.name||a.id_user,disabled:!0,className:"bg-muted"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:n("superior")}),e.jsxs(dt,{value:k||"none",onValueChange:e=>j.setValue("id_leader","none"===e?null:e),children:[e.jsx(mt,{children:e.jsx(ut,{placeholder:n("select_placeholder")})}),e.jsxs(ft,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:e.jsx(Ee,{placeholder:n("superior_search"),value:b,onChange:e=>w(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),e.jsxs(Qs,{className:"h-[200px]",children:[e.jsx(gt,{value:"none",children:"[Nenhum]"}),g.filter(e=>{const t=o?e.userId!==a.id_user:!S.includes(e.userId),s=!b||e.userName?.toLowerCase().includes(b.toLowerCase());return t&&s}).sort((e,t)=>{const a=e.userName||e.userEmail||"",s=t.userName||t.userEmail||"";return a.localeCompare(s)}).map(t=>e.jsx(gt,{value:t.userId,children:t.userName},t.userId))]})]})]},`superior-select-${i}`),j.formState.errors.id_leader&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:j.formState.errors.id_leader.message})]}),e.jsxs("div",{children:[e.jsxs(_e,{children:[n("subordinates")," *"]}),e.jsx($c,{value:S,onChange:e=>j.setValue("id_users",e),excludeUserIds:T,error:j.formState.errors.id_users?.message},`users-multiselect-${i}`)]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(Ie,{type:"submit",disabled:C||!o&&0===S.length,children:C&&!f.isPending?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),n(o?"updating":"saving")]}):o?S.length>0?n("update_success",{count:S.length}):n("update"):n("create_success",{count:S.length})}),o&&!k&&0===S.length&&e.jsx(Ie,{type:"button",variant:"destructive",disabled:C,onClick:async()=>{if(a&&window.confirm(n("remove_confirm")))try{await f.mutateAsync(a.id),r?.()}catch(e){}},className:"ml-auto",children:f.isPending?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),n("removing")]}):e.jsxs(e.Fragment,{children:[e.jsx(d.Trash2,{className:"mr-2 h-4 w-4"}),n("remove")]})})]})]})}function Hc({open:t,onOpenChange:a,leader:s,prefilledLeaderId:r,title:n}){return e.jsx(qe,{open:t,onOpenChange:a,children:e.jsxs(Ye,{className:"sm:max-w-[500px]",children:[e.jsx(Qe,{showSeparator:!0,children:e.jsx(Ze,{children:n})}),e.jsx(Xe,{children:e.jsx(qc,{leader:s,prefilledLeaderId:r,onSuccess:()=>a(!1)})})]})})}const Bc="leadership-expanded-nodes",Wc=(e,t)=>{try{localStorage.setItem(`${Bc}-${e}`,JSON.stringify(Array.from(t)))}catch(a){}};function Vc(e){const[a,s]=t.useState(!1),[r,n]=t.useState(0),{t:i}=v.useTranslation(),{uploadFunction:o,deleteFunction:d,defaultOptions:c,onSuccess:u,onError:m}=e||{};return{upload:async(e,t)=>{if(!o){const e=new Error("uploadFunction não fornecida");throw l.toast.error("Erro de configuração",{description:"Função de upload não configurada. Verifique a documentação."}),e}s(!0),n(0);try{const a={...c,...t};if(a.maxSize&&e.size>a.maxSize)throw new Error(`Arquivo muito grande. Tamanho máximo: ${Math.round(a.maxSize/1024/1024)}MB`);if(a.allowedTypes){if(!a.allowedTypes.some(t=>t.endsWith("/*")?e.type.startsWith(t.replace("/*","")):e.type===t))throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${a.allowedTypes.join(", ")}`)}const s=await o(e,a);return n(100),l.toast.success("Sucesso",{description:i("file_upload_success")}),u?.(s),s}catch(a){const e=a instanceof Error?a:new Error("Erro ao fazer upload");throw l.toast.error("Erro",{description:e.message}),m?.(e),e}finally{s(!1)}},deleteMedia:async(e,t)=>{if(!d){const e=new Error("deleteFunction não fornecida");throw l.toast.error("Erro de configuração",{description:"Função de delete não configurada."}),e}try{await d(e,t),l.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(a){throw l.toast.error("Erro",{description:"Erro ao remover o arquivo"}),a}},uploading:a,progress:r}}function Gc(e){const t=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const a of t){const t=e.match(a);if(t)return t[1]}return null}function Yc(e,t){const a=Gc(e);if(!a)return e;return`https://www.youtube.com/embed/${a}${t?"?autoplay=1&mute=1":""}`}function Qc(e){const t=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return t?t[1]:null}function Xc(e,t){const a=Qc(e);if(!a)return e;return`https://player.vimeo.com/video/${a}${t?"?autoplay=1&muted=1":""}`}function Kc(e){if(!e)return;const t=e.match(/src="([^"]+)"/);return t?t[1]:void 0}function Zc(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function Jc(e,t){return e/t}const eu=[{id:"qualiex",label:"Qualiex",modules:[{name:"Análises",description:"Análise de dados",color:"bg-[#002338]"},{name:"Atas e Decisões",description:"Gestão de atas e decisões",color:"bg-[#7DB3B2]"},{name:"Auditorias",description:"Gestão de auditorias",color:"bg-[#912F71]"},{name:"Documentos",description:"Gestão de documentos",color:"bg-[#1D43A6]"},{name:"Fluxos",description:"Gestão de fluxos",color:"bg-[#8BFFE0]"},{name:"Fornecedores",description:"Gestão de fornecedores",color:"bg-[#5C5094]"},{name:"Mapeamentos",description:"Mapeamento de dados pessoais",color:"bg-[#62416B]"},{name:"Metrologia",description:"Gestão de metrologia",color:"bg-[#8CC74F]"},{name:"Ocorrências",description:"Gestão de ocorrências",color:"bg-[#EE7121]"},{name:"OKR",description:"Objetivos e resultados-chave",color:"bg-[#4A90D9]"},{name:"Planos",description:"Planos de ação",color:"bg-[#FBC02D]"},{name:"Portal do Fornecedor",description:"Portal do Fornecedor",color:"bg-[#26A69A]"},{name:"Riscos",description:"Gestão de riscos",color:"bg-[#ED7096]"}]},{id:"saber",label:"Saber Gestão",modules:[{name:"Competências",description:"Gestão de competências",color:"bg-[#9B4F96]"},{name:"Desempenho",description:"Gestão de desempenho",color:"bg-[#4A90D9]"},{name:"Educação",description:"Plataforma de ensino",color:"bg-[#00BCD4]"},{name:"PDI",description:"Plano de desenvolvimento individual",color:"bg-[#7CB342]"},{name:"Pulso",description:"Pesquisas de clima",color:"bg-[#F5A623]"},{name:"Treinamentos",description:"Gestão de treinamentos",color:"bg-[#26A69A]"}]},{id:"classico",label:"Clássicos",modules:[{name:"Action",description:"Planos de ação",color:"bg-[#fbe356]"},{name:"Audit",description:"Gestão de auditorias",color:"bg-[#ca76b5]"},{name:"Configurações v1",description:"Configurações",color:"bg-[#5C6BC0]"},{name:"Dashboards v1",description:"Dashboards",color:"bg-[#EC407A]"},{name:"Docs v1",description:"Gestão de Documentos",color:"bg-[#58b4db]"},{name:"Indicators",description:"Gestão de Indicadores",color:"bg-[#f91b1d]"},{name:"Meeting",description:"Gestão de reuniões",color:"bg-[#96c2c1]"},{name:"Metrology v1",description:"Gestão de Metrologia",color:"bg-[#afd884]"},{name:"Planner",description:"Planejamento estratégico",color:"bg-[#4dc6f4]"},{name:"Relatórios v1",description:"Relatórios",color:"bg-[#FFA726]"},{name:"Risks",description:"Gestão de riscos",color:"bg-[#ef7b9e]"},{name:"Staff",description:"Avaliação de competências",color:"bg-[#0978d6]"},{name:"Supply",description:"Avaliação de fornecedores",color:"bg-[#8276b7]"},{name:"Tracker1",description:"Gestão de ocorrências",color:"bg-[#fe883b]"},{name:"Tracker2",description:"Gestão de ocorrências",color:"bg-[#fe883b]"}]}];function tu({module:t,onClick:a}){return e.jsxs("button",{type:"button",onClick:a,className:"flex items-start gap-3 p-2 rounded-lg hover:bg-muted/50 transition-colors text-left w-full group",children:[e.jsx("div",{className:Te("w-4 h-4 rounded-sm shrink-0 mt-0.5",t.color)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-foreground group-hover:text-primary transition-colors",children:t.name}),t.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate",children:t.description})]})]})}function au({modules:t,onModuleClick:a,columns:s=2}){const r=[...t].sort((e,t)=>e.name.localeCompare(t.name)),n=Math.ceil(r.length/s),i=[];for(let e=0;e<n;e++)for(let t=0;t<s;t++){const a=t*n+e;a<r.length&&i.push(r[a])}return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-1",children:i.map((t,s)=>e.jsx(tu,{module:t,onClick:()=>a?.(t)},`${t.name}-${s}`))})}exports.i18n=o,Object.defineProperty(exports,"sonnerToast",{enumerable:!0,get:function(){return l.toast}}),Object.defineProperty(exports,"toast",{enumerable:!0,get:function(){return l.toast}}),Object.defineProperty(exports,"I18nextProvider",{enumerable:!0,get:function(){return v.I18nextProvider}}),Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:function(){return v.useTranslation}}),exports.AUTH_CONFIG=Fa,exports.Accordion=tn,exports.AccordionContent=rn,exports.AccordionItem=an,exports.AccordionTrigger=sn,exports.ActionButton=Ae,exports.ActionMenu=El,exports.ActionMenuItems=Os,exports.Alert=xr,exports.AlertDescription=br,exports.AlertDialog=nn,exports.AlertDialogAction=fn,exports.AlertDialogCancel=xn,exports.AlertDialogContent=cn,exports.AlertDialogDescription=pn,exports.AlertDialogFooter=mn,exports.AlertDialogHeader=un,exports.AlertDialogOverlay=dn,exports.AlertDialogPortal=ln,exports.AlertDialogTitle=hn,exports.AlertDialogTrigger=on,exports.AlertTitle=gr,exports.AppHeader=$l,exports.AppLayout=sd,exports.AppSidebar=ad,exports.AuthErrorInterceptor=Aa,exports.AuthProvider=os,exports.AuthService=ns,exports.Avatar=gn,exports.AvatarFallback=vn,exports.AvatarImage=bn,exports.Badge=yt,exports.BaseForm=ar,exports.Blockquote=Ri,exports.BodyContent=function({breadcrumbs:t,children:a,className:s}){return e.jsxs("div",{className:Te("bg-neutral-100 dark:bg-neutral-900","h-full overflow-y-auto","p-6",s),children:[t&&t.length>0&&e.jsx(wn,{className:"mb-4",children:e.jsx(Nn,{children:t.map((a,s)=>{const r=s===t.length-1;return e.jsxs(J.Fragment,{children:[s>0&&e.jsx(kn,{}),e.jsx(yn,{children:r||!a.href?e.jsx(Cn,{children:a.label}):a.asChild&&a.children?e.jsx(jn,{asChild:!0,children:a.children}):e.jsx(jn,{asChild:!0,children:e.jsx(y.Link,{to:a.href||"/",children:a.label})})})]},`${a.label}-${s}`)})})}),e.jsx("div",{className:"space-y-6",children:a})]})},exports.Breadcrumb=wn,exports.BreadcrumbEllipsis=Sn,exports.BreadcrumbItem=yn,exports.BreadcrumbLink=jn,exports.BreadcrumbList=Nn,exports.BreadcrumbPage=Cn,exports.BreadcrumbSeparator=kn,exports.BulkActionBar=nr,exports.Button=Ie,exports.ButtonGroup=Pn,exports.CRUD_CONFIG=La,exports.Calendar=ti,exports.CallbackPage=()=>{const{processCallback:a}=ls(),s=y.useNavigate(),[r,n]=t.useState(null),[i,o]=t.useState(!1);t.useEffect(()=>{(async()=>{try{if(await a()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");localStorage.removeItem("auth_return_url"),s(e||"/",{replace:!0})}else n("Falha na autenticação. Tente novamente.")}catch(e){localStorage.removeItem("auth_return_url"),n(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[a,s]);const l=async()=>{o(!0),n(null);try{await a()||n("Falha na autenticação. Tente novamente.")}catch(e){n(e?.message||"Erro ao tentar novamente.")}finally{o(!1)}},c=()=>{window.location.href="/"};return r?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(Re,{className:"w-full max-w-md",children:[e.jsx(ze,{className:"text-center",children:e.jsxs(Fe,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[e.jsx(d.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(xr,{variant:"danger",children:e.jsx(br,{children:r})}),e.jsx("div",{className:"text-sm text-muted-foreground",children:e.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ie,{onClick:l,disabled:i,className:"flex-1",children:i?e.jsxs(e.Fragment,{children:[e.jsx(Ct,{size:"sm",className:"mr-2"}),"Tentando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(d.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),e.jsx(Ie,{onClick:c,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(Re,{className:"w-full max-w-md",children:[e.jsx(ze,{className:"text-center",children:e.jsx(Fe,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),e.jsxs(Oe,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(Ct,{size:"lg"})}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=Re,exports.CardContent=Oe,exports.CardDescription=Le,exports.CardFooter=Ue,exports.CardHeader=ze,exports.CardSkeleton=vs,exports.CardTitle=Fe,exports.ChartContainer=bl,exports.ChartLegend=yl,exports.ChartLegendContent=jl,exports.ChartStyle=vl,exports.ChartTooltip=wl,exports.ChartTooltipContent=Nl,exports.Checkbox=vt,exports.Collapsible=Qr,exports.CollapsibleContent=Kr,exports.CollapsibleTrigger=Xr,exports.ColorPicker=Ys,exports.Combobox=ia,exports.Command=Qt,exports.CommandDialog=({children:t,...a})=>e.jsx("div",{...a,children:e.jsx(Qt,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:t})}),exports.CommandEmpty=Zt,exports.CommandGroup=Jt,exports.CommandInput=Xt,exports.CommandItem=ta,exports.CommandList=Kt,exports.CommandSeparator=ea,exports.CommandShortcut=aa,exports.ContentContainer=function({title:t,subtitle:a,children:s,className:r,hasHeader:n=!0}){const i=t||a;return e.jsxs("div",{className:Te("bg-white dark:bg-card","rounded-lg","shadow-sm","border border-border/40","overflow-hidden",r),children:[n&&i&&e.jsxs("div",{className:"px-6 py-4 border-b border-border/50",children:[t&&e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:t}),a&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:a})]}),s&&e.jsx("div",{className:Te("p-6",!n&&i&&"pt-4"),children:s})]})},exports.ContextMenu=Cs,exports.ContextMenuCheckboxItem=_s,exports.ContextMenuContent=Es,exports.ContextMenuGroup=Ss,exports.ContextMenuItem=Ds,exports.ContextMenuLabel=zs,exports.ContextMenuPortal=Ts,exports.ContextMenuRadioGroup=Ms,exports.ContextMenuRadioItem=Rs,exports.ContextMenuSeparator=Fs,exports.ContextMenuShortcut=Ls,exports.ContextMenuSub=Ps,exports.ContextMenuSubContent=As,exports.ContextMenuSubTrigger=Is,exports.ContextMenuTrigger=ks,exports.CoreProviders=function({children:t,queryClient:a}){const s=a??new N.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}});return e.jsx(en,{children:e.jsx(v.I18nextProvider,{i18n:o,children:e.jsx(N.QueryClientProvider,{client:s,children:e.jsx(os,{children:e.jsx(Vr,{children:e.jsx(Yr,{children:t})})})})})})},exports.CrudGrid=({manager:a,columns:s,onEdit:r,onView:n,onToggleStatus:i,onDelete:o,renderActions:l,customRowActions:c,enableBulkActions:u=!1,onNew:m,newButtonLabel:h,showNewButton:p=!0,customActions:f=[],hideActionBar:x=!1,gridColumns:g=3,renderCard:b,viewMode:w,onViewModeChange:N,listCardRenderer:y,gridCardRenderer:j,showViewToggle:C=!1})=>{const{t:k}=v.useTranslation(),{setSearchVisible:S}=ls();t.useEffect(()=>(S(!0),()=>S(!1)),[S]);const T=!x&&(m||f.length>0||C),P=w||"grid",M="list"===P,I={1:"grid-cols-1",2:"grid-cols-1 md:grid-cols-2",3:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",4:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"}[M?1:g];if(a.isLoading)return e.jsxs("div",{className:"flex flex-col h-full",children:[T&&e.jsx("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:e.jsx("div",{className:"flex items-center gap-2",children:m&&p&&e.jsxs(Ie,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),h||k("new")]})})}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx(vs,{count:6})})]});if(0===a.entities.length)return e.jsxs("div",{className:"flex flex-col h-full",children:[T&&e.jsx("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[m&&p&&e.jsxs(Ie,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),h||k("new")]}),f.map((t,a)=>{const s=t.icon;return e.jsxs(Ie,{onClick:t.action,variant:t.variant||"outline",children:[s&&e.jsx(s,{size:16,className:"mr-2"}),t.label]},a)})]})}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(Ns,{title:k("empty_title"),description:k("empty_description"),variant:"search"})})]});return e.jsxs("div",{className:"flex flex-col h-full",children:[T&&e.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[m&&p&&e.jsxs(Ie,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),h||k("new")]}),f.map((t,a)=>{const s=t.icon;return e.jsxs(Ie,{onClick:t.action,variant:t.variant||"outline",children:[s&&e.jsx(s,{size:16,className:"mr-2"}),t.label]},a)})]}),C&&N&&e.jsxs(Ko,{type:"single",value:P,onValueChange:e=>e&&N(e),size:"sm",children:[e.jsx(Zo,{value:"list","aria-label":"Visualização em lista",children:e.jsx(d.List,{className:"h-4 w-4"})}),e.jsx(Zo,{value:"grid","aria-label":"Visualização em grade",children:e.jsx(d.LayoutGrid,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx("div",{className:Te("grid gap-4",I),children:a.entities.map(t=>{const d=(e=>M&&y?y(e):!M&&j?j(e):b?b(e):null)(t);return e.jsxs(Cs,{children:[e.jsx(ks,{asChild:!0,children:d?e.jsx("div",{className:"cursor-pointer",onClick:e=>{e.stopPropagation(),u?a.selectItem(t.id):r?.(t)},children:d}):e.jsx(Re,{className:Te("overflow-hidden cursor-pointer hover:bg-muted/50 transition-colors",u&&a.selectedIds.includes(t.id)&&"bg-muted ring-2 ring-primary",M&&"flex-row"),onClick:e=>{e.stopPropagation(),u?a.selectItem(t.id):r?.(t)},children:e.jsxs(Oe,{className:Te("p-4",M&&"flex items-center gap-4 w-full"),children:[u&&e.jsx("div",{className:Te(M?"":"pt-0.5"),onClick:e=>e.stopPropagation(),children:e.jsx(Al,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),M?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 flex items-center gap-6 min-w-0",children:s.map(a=>e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[a.header,":"]}),e.jsx("div",{className:"text-sm text-foreground truncate",children:a.render?a.render(t):String(t[a.key]??"")})]},String(a.key)))}),(r||n||l)&&e.jsx("div",{onClick:e=>e.stopPropagation(),children:l?l(t):e.jsx(Us,{onEdit:r?()=>r(t):void 0,onDelete:o?()=>o(t):void 0,onToggleStatus:i?()=>i(t):void 0,isActive:t.is_actived,customActions:c?c(t):[]})})]}):e.jsxs("div",{className:"flex items-start gap-3",children:[u&&e.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e.jsx(Al,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[s.map((a,r)=>e.jsxs("div",{className:Te("flex justify-between items-start gap-2",r!==s.length-1&&"mb-2"),children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[a.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right truncate",children:a.render?a.render(t):String(t[a.key]??"")})]},String(a.key))),(r||n||l)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(t):e.jsx(Us,{onEdit:r?()=>r(t):void 0,onDelete:o?()=>o(t):void 0,onToggleStatus:i?()=>i(t):void 0,isActive:t.is_actived,customActions:c?c(t):[]})})]})]})]})})}),e.jsx(Es,{className:"w-[160px]",children:e.jsx(Os,{onEdit:r?()=>r(t):void 0,onDelete:o?()=>o(t):void 0,onToggleStatus:i?()=>i(t):void 0,isActive:t.is_actived,canDelete:!!o,customActions:c?c(t):[],renderAs:"context"})})]},t.id)})})})]})},exports.CrudPageInternal=ur,exports.CrudPagination=rr,exports.CrudPrimitiveFilterBar=function({searchValue:t="",onSearchChange:a,customFilters:s=[],onClearFilters:r,showClearButton:n=!0,layout:i="horizontal"}){const{t:o}=v.useTranslation(),l=t||s.length>0;return e.jsxs("div",{className:`flex ${"vertical"===i?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[a&&e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ee,{type:"text",placeholder:o("search"),value:t,onChange:e=>a(e.target.value),className:"pl-9 h-9"})]}),s.map((t,a)=>e.jsx("div",{className:"vertical"===i?"w-full":"",children:t},a)),n&&l&&r&&e.jsxs(Ie,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[e.jsx(d.X,{size:14,className:"mr-1"}),o("clear_filters")]})]})},exports.CrudPrimitivePagination=sr,exports.CrudPrimitiveTable=function({data:a,columns:s,sortField:r,sortDirection:n,onSort:i,onRowClick:o,renderActions:l,isLoading:c=!1,emptyMessage:u="Nenhum item encontrado",className:m,enableSelection:h=!1,selectedIds:p=[],onSelectItem:f,onSelectAll:x,isAllSelected:g=!1,enableColumnResize:b=!0,onColumnResize:v,storageKey:w}){const{columnWidths:N,isDragging:y,activeColumn:j,handleMouseDown:C}=qs({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:e.maxWidth??500,defaultWidth:e.width??e.minWidth??150})),storageKey:w?`${w}-columns`:void 0,onResize:v,enabled:b}),{isDragging:k,activeRow:S,handleMouseDown:T,getRowHeight:P}=Hs({rowIds:a.map(e=>e.id),storageKey:w?`${w}-rows`:void 0,enabled:!1}),M=t.useMemo(()=>{if(b)return s.map(e=>`${N[String(e.key)]??e.width??e.minWidth??150}px`);const e=s.reduce((e,t)=>t.width?e:e+(t.weight??1),0);return s.map(t=>{if(t.width)return`${t.width}px`;if(t.minWidth&&!t.weight)return`${t.minWidth}px`;const a=(t.weight??1)/e*100;return t.minWidth?`minmax(${t.minWidth}px, ${a}%)`:`${a}%`})},[s,b,N]);if(c)return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((t,a)=>e.jsx(sa,{className:"h-12 w-full"},a))})});if(0===a.length)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("div",{className:"text-center text-muted-foreground",children:e.jsx("p",{children:u})})});const I=y||k;return e.jsx("div",{className:"flex-1 overflow-auto "+(I?"select-none":""),children:e.jsxs(cs,{className:m,children:[e.jsx(us,{className:"sticky top-0 bg-background z-10",children:e.jsxs(ps,{children:[h&&e.jsx(fs,{className:"w-[40px]",children:e.jsx(vt,{checked:g,onCheckedChange:x,"aria-label":"Selecionar todos"})}),s.map((t,a)=>{const s=b&&!1!==t.resizable,o=j===String(t.key);return e.jsxs(fs,{className:`${t.className||""} relative`,style:{width:M[a]},children:[t.sortable&&i?e.jsxs("button",{onClick:()=>i(String(t.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[t.header,(l=String(t.key),r!==l?e.jsx(d.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===n?e.jsx(d.ArrowUp,{size:14,className:"ml-1"}):e.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}):e.jsx("span",{className:"font-medium",children:t.header}),s&&e.jsx(js,{direction:"horizontal",onMouseDown:e=>C(String(t.key),e),isDragging:o})]},String(t.key));var l}),l&&e.jsx(fs,{className:"w-[80px] text-right",children:"Ações"})]})}),e.jsx(ms,{children:a.map(t=>{const a=P(t.id);return t.id,e.jsxs(ps,{onClick:()=>o?.(t),className:(o?"cursor-pointer":"")+" relative",style:a?{height:`${a}px`}:void 0,children:[h&&e.jsx(xs,{children:e.jsx(vt,{checked:p.includes(t.id),onCheckedChange:()=>f?.(t.id),onClick:e=>e.stopPropagation(),"aria-label":`Selecionar item ${t.id}`})}),s.map(a=>e.jsx(xs,{className:a.className,children:e.jsx(ys,{children:a.render?a.render(t):String(t[a.key]??"-")})},String(a.key))),l&&e.jsx(xs,{className:"text-right",onClick:e=>e.stopPropagation(),children:l(t)})]},t.id)})})]})})},exports.CrudTable=Ws,exports.DATETIME_FORMATS=Er,exports.DEFAULT_DATETIME_FORMAT=Rr,exports.DEFAULT_LOCALE=_r,exports.DEFAULT_TIMEZONE=zr,exports.DataList=ai,exports.DatePicker=function({date:t,onDateChange:a,placeholder:s="Selecione uma data",disabled:r=!1,className:n,disabledDates:o}){return e.jsxs(Vt,{children:[e.jsx(Gt,{asChild:!0,children:e.jsxs(Ie,{variant:"outline",disabled:r,className:Te("w-full justify-start text-left font-normal",!t&&"text-muted-foreground",n),children:[e.jsx(d.Calendar,{className:"mr-2 h-4 w-4"}),t?i.format(t,"d 'de' MMMM 'de' yyyy",{locale:ei}):e.jsx("span",{children:s})]})}),e.jsx(Yt,{className:"w-auto p-0",align:"start",children:e.jsx(ti,{mode:"single",selected:t,onSelect:a,disabled:o,initialFocus:!0,className:"pointer-events-auto"})})]})},exports.Dialog=qe,exports.DialogBody=Xe,exports.DialogClose=We,exports.DialogContent=Ye,exports.DialogDescription=Je,exports.DialogFooter=Ke,exports.DialogHeader=Qe,exports.DialogOverlay=Ve,exports.DialogPortal=Be,exports.DialogTitle=Ze,exports.DialogTrigger=He,exports.DisabledMenuItem=Wt,exports.Drawer=si,exports.DrawerClose=ii,exports.DrawerContent=li,exports.DrawerDescription=mi,exports.DrawerFooter=ci,exports.DrawerHeader=di,exports.DrawerOverlay=oi,exports.DrawerPortal=ni,exports.DrawerTitle=ui,exports.DrawerTrigger=ri,exports.DropdownMenu=St,exports.DropdownMenuCheckboxItem=zt,exports.DropdownMenuContent=_t,exports.DropdownMenuGroup=Pt,exports.DropdownMenuItem=Rt,exports.DropdownMenuLabel=Lt,exports.DropdownMenuPortal=Mt,exports.DropdownMenuRadioGroup=At,exports.DropdownMenuRadioItem=Ft,exports.DropdownMenuSeparator=Ot,exports.DropdownMenuShortcut=Ut,exports.DropdownMenuSub=It,exports.DropdownMenuSubContent=Dt,exports.DropdownMenuSubTrigger=Et,exports.DropdownMenuTrigger=Tt,exports.EmailService=wc,exports.EmptyState=Ns,exports.EntitySelect=ia,exports.ErrorBoundary=en,exports.FilterBar=cr,exports.Form=et,exports.FormControl=it,exports.FormDescription=ot,exports.FormField=({...t})=>e.jsx(tt.Provider,{value:{name:t.name},children:e.jsx(h.Controller,{...t})}),exports.FormItem=rt,exports.FormLabel=nt,exports.FormMessage=lt,exports.FormSkeleton=function({fields:t=4}){return e.jsxs("div",{className:"space-y-4",children:[Array.from({length:t}).map((t,a)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(sa,{className:"h-4 w-24"}),e.jsx(sa,{className:"h-10 w-full"})]},a)),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(sa,{className:"h-10 w-20"}),e.jsx(sa,{className:"h-10 w-20"})]})]})},exports.Grid=function({children:t,cols:a="auto-fit",gap:s="md",className:r}){return e.jsx("div",{className:Te("grid",hi[a],pi[s],r),children:t})},exports.H1=ki,exports.H2=Si,exports.H3=Ti,exports.H4=Pi,exports.HeaderSkeleton=function(){return e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(sa,{className:"h-8 w-8 rounded-full"}),e.jsx(sa,{className:"h-6 w-32"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(sa,{className:"h-8 w-8"}),e.jsx(sa,{className:"h-8 w-24"})]})]})},exports.HoverCard=fi,exports.HoverCardContent=gi,exports.HoverCardTrigger=xi,exports.IconPicker=Zs,exports.ImageEditor=function({value:a,onChange:s,onSubmit:r,onCancel:n,uploadFunction:i,deleteFunction:o,uploadOptions:c}){const{t:u}=v.useTranslation(),[m,h]=t.useState(a||{alignment:"center",allowDownload:!1}),p=t.useRef(null),{upload:f,uploading:x}=Vc({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),g=(e,t)=>{const a={...m,[e]:t};h(a),s(a)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:u("url")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ee,{type:"url",placeholder:u("url_placeholder"),value:m.imageUrl||"",onChange:e=>g("imageUrl",e.target.value),className:"flex-1"}),i&&e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:p,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await f(t),a={...m,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};h(a),s(a)}catch(a){}finally{p.current&&(p.current.value="")}},className:"hidden"}),e.jsx(Ie,{type:"button",variant:"outline",onClick:()=>p.current?.click(),disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),u("uploading")]}):e.jsxs(e.Fragment,{children:[e.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),u("upload")]})})]})]}),m.imageFile&&e.jsx("p",{className:"text-xs text-muted-foreground",children:u("image.fileInfo",{name:m.imageFile,size:Math.round((m.imageSize||0)/1024)})})]}),m.imageUrl&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:u("preview")}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:e.jsx("div",{className:"flex "+("left"===m.alignment?"justify-start":"right"===m.alignment?"justify-end":"justify-center"),children:e.jsx("img",{src:m.imageUrl,alt:m.alt||"Preview",style:{width:m.width?`${m.width}px`:"auto",height:m.height?`${m.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"caption",children:u("caption")}),e.jsx(wt,{id:"caption",placeholder:u("caption"),value:m.caption||"",onChange:e=>g("caption",e.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"alt",children:u("alt")}),e.jsx(Ee,{id:"alt",placeholder:u("alt"),value:m.alt||"",onChange:e=>g("alt",e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:u("alignment")}),e.jsxs(dt,{value:m.alignment||"center",onValueChange:e=>g("alignment",e),children:[e.jsx(mt,{children:e.jsx(ut,{})}),e.jsxs(ft,{children:[e.jsx(gt,{value:"left",children:u("left")}),e.jsx(gt,{value:"center",children:u("center")}),e.jsx(gt,{value:"right",children:u("right")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"width",children:u("width")}),e.jsx(Ee,{id:"width",type:"number",placeholder:"px",value:m.width||"",onChange:e=>g("width",e.target.value?Number(e.target.value):void 0)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"height",children:u("height")}),e.jsx(Ee,{id:"height",type:"number",placeholder:"px",value:m.height||"",onChange:e=>g("height",e.target.value?Number(e.target.value):void 0)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"allowDownload",type:"checkbox",checked:m.allowDownload||!1,onChange:e=>g("allowDownload",e.target.checked),className:"h-4 w-4"}),e.jsx(_e,{htmlFor:"allowDownload",className:"cursor-pointer",children:u("allow_download")})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(Ie,{variant:"outline",onClick:n,children:u("cancel")}),e.jsx(Ie,{onClick:()=>{m.imageUrl?r(m):l.toast.error(u("error"),{description:u("error_no_image")})},disabled:!m.imageUrl,children:u("save")})]})]})},exports.ImageRenderer=function({content:t,className:a="",style:s}){if(!t.imageUrl)return null;const r={left:"justify-start",center:"justify-center",right:"justify-end"}[t.alignment||"center"];return e.jsx("div",{className:`flex ${r} my-4 ${a}`,style:s,children:e.jsxs("div",{className:"space-y-2 max-w-full",children:[e.jsx("img",{src:t.imageUrl,alt:t.alt||"",style:{width:t.width?`${t.width}px`:"auto",height:t.height?`${t.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),t.caption&&e.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:t.caption}),t.allowDownload&&t.imageUrl&&e.jsxs("a",{href:t.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[e.jsx(d.Download,{className:"h-4 w-4"}),"Baixar imagem"]})]})})},exports.InlineCode=_i,exports.Input=Ee,exports.InputGroup=bi,exports.InputGroupAddon=wi,exports.InputGroupButton=yi,exports.InputGroupInput=ji,exports.InputGroupTextarea=Ci,exports.LOGO_CONFIG=Ha,exports.Label=_e,exports.Large=Ai,exports.Lead=Ii,exports.LeaderRow=zc,exports.LeadershipDialog=Hc,exports.LeadershipForm=qc,exports.LeadershipPage=function(){const{alias:a}=ls(),{t:s}=v.useTranslation(),{data:r,isLoading:n,error:i,refetch:o}=Mc(),{data:l=[]}=er({enabled:!0}),[c,u]=t.useState(()=>a?(e=>{try{const t=localStorage.getItem(`${Bc}-${e}`);if(t)return new Set(JSON.parse(t))}catch(i){}return new Set})(a):new Set),[m,h]=t.useState(!1),[p,f]=t.useState(),[x,g]=t.useState(null),b=l.filter(e=>e.userName&&"Nome não disponível"!==e.userName),w=new Set(b.map(e=>e.userId)),N=b.length-(r?Pc(r).filter(e=>w.has(e.id_user)&&"[Não encontrado]"!==e.name).length:0);t.useEffect(()=>{if(r&&r.length>0&&a){if(!localStorage.getItem(`${Bc}-${a}`)){const e=r.map(e=>e.id),t=new Set(e);u(t),Wc(a,t)}}},[r,a]);const y=e=>{u(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),a&&Wc(a,s),s})},j=e=>{f(e),g(null),h(!0)};return n?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(d.RefreshCw,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:s("loading")})]})}):i?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),e.jsx(Ie,{onClick:()=>o(),children:"Tentar novamente"})]})}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex items-center justify-between p-4 border-b",children:e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(Ie,{size:"sm",onClick:()=>{f(void 0),g(null),h(!0)},children:[e.jsx(d.Plus,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),e.jsxs(Ie,{variant:"outline",size:"sm",onClick:()=>{if(!r)return;const e=Pc(r).filter(e=>e.children.length>0).map(e=>e.id),t=new Set(e);u(t),a&&Wc(a,t)},disabled:!r||0===r.length,children:[e.jsx(d.ChevronDown,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),e.jsxs(Ie,{variant:"outline",size:"sm",onClick:()=>{const e=new Set;u(e),a&&Wc(a,e)},disabled:!r||0===r.length,children:[e.jsx(d.ChevronRight,{className:"h-4 w-4 mr-2"}),"Recolher todos"]}),e.jsx("div",{className:"flex items-center gap-2 ml-4",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[e.jsx(d.Users,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm font-medium",children:[N," usuário",1!==N?"s":""," não associado",1!==N?"s":""]})]})})]})}),r&&0!==r.length?e.jsx(Qs,{className:"flex-1",children:e.jsx("div",{children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"py-3 px-4 text-left font-semibold",children:"Nome"}),e.jsx("th",{className:"py-3 px-4 text-center font-semibold",children:"Liderados"})]})}),e.jsx("tbody",{children:r.map(t=>e.jsx(zc,{leader:t,expandedIds:c,onToggleExpand:y,onEdit:j},t.id))})]})})}):e.jsx("div",{className:"flex items-center justify-center flex-1",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Nenhuma hierarquia de liderança encontrada"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Clique em "Definir Líder" para começar'})]})}),e.jsx(Hc,{open:m,onOpenChange:()=>{h(!1),f(void 0),g(null)},leader:p,prefilledLeaderId:x,title:p?s("edit")+" "+s("name"):x?s("add")+" Liderado":s("add")+" Líder Raiz"},`leadership-dialog-${a}`)]})},exports.List=zi,exports.LoadingState=function({isLoading:t,children:a,className:s,type:r="spinner",size:n="md"}){return t?"overlay"===r?e.jsxs("div",{className:Te("relative",s),children:[a,e.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:e.jsx(Ct,{size:n})})]}):"skeleton"===r?e.jsx("div",{className:Te("animate-pulse",s),children:e.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):e.jsx("div",{className:Te("flex items-center justify-center py-8",s),children:e.jsx(Ct,{size:n})}):e.jsx(e.Fragment,{children:a})},exports.LocaleProvider=Vr,exports.LocaleSelector=_l,exports.LoginPage=()=>e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(Re,{className:"w-full max-w-md",children:[e.jsx(ze,{className:"text-center",children:e.jsx(Fe,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),e.jsxs(Oe,{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),e.jsx(Ie,{onClick:async()=>{Ua()?await ns.loginDev():ns.loginProd()},className:"w-full",size:"lg",children:Ua()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),exports.MESSAGES=Ba,exports.MODULES_DATA=eu,exports.ManageAccessModal=yc,exports.Menubar=rl,exports.MenubarCheckboxItem=cl,exports.MenubarContent=ll,exports.MenubarGroup=el,exports.MenubarItem=dl,exports.MenubarLabel=ml,exports.MenubarMenu=Jo,exports.MenubarPortal=tl,exports.MenubarRadioGroup=sl,exports.MenubarRadioItem=ul,exports.MenubarSeparator=hl,exports.MenubarShortcut=pl,exports.MenubarSub=al,exports.MenubarSubContent=ol,exports.MenubarSubTrigger=il,exports.MenubarTrigger=nl,exports.ModalStateProvider=function({children:a}){const[s,r]=t.useState(new Set),[n,i]=t.useState(!1),o=t.useCallback(e=>{r(t=>{const a=new Set(t);return a.add(e),a})},[]),l=t.useCallback(e=>{r(t=>{const a=new Set(t);return a.delete(e),a})},[]),d=t.useCallback(e=>{i(e)},[]),c=t.useMemo(()=>s.size>0||n,[s,n]),u=t.useMemo(()=>({openModals:s,hasOpenModal:c,registerModal:o,unregisterModal:l,setHasOpenModal:d}),[s,c,o,l,d]);return e.jsx(ed.Provider,{value:u,children:a})},exports.ModulesDialog=function({open:a,onOpenChange:s,onModuleClick:r,wikiUrl:n="https://qualiex.forlogic.net/",allModulesUrl:i="https://qualiex.com/",showSettingsLink:o=!0,onSettingsClick:l}){const[c,u]=t.useState("qualiex");return e.jsx(qe,{open:a,onOpenChange:s,children:e.jsxs(Ye,{size:"lg",className:"overflow-hidden flex flex-col",children:[e.jsx(Qe,{children:e.jsx(Ze,{children:"Módulos"})}),e.jsxs("div",{className:"flex-1 min-h-0 flex gap-6 overflow-hidden",children:[e.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:e.jsxs(Bo,{value:c,onValueChange:u,className:"flex-1 flex flex-col min-h-0",children:[e.jsx(Wo,{className:"w-fit shrink-0 mt-4",children:eu.map(t=>e.jsxs(Vo,{value:t.id,children:[t.label,e.jsxs("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",t.modules.length,")"]})]},t.id))}),eu.map(t=>e.jsx(Go,{value:t.id,className:"flex-1 mt-4 overflow-auto pr-2",children:e.jsx(au,{modules:t.modules,onModuleClick:r})},t.id))]})}),e.jsxs("div",{className:"w-72 shrink-0 flex flex-col gap-4",children:[e.jsxs("div",{className:"bg-primary text-primary-foreground rounded-lg p-4 space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"Dúvidas sobre os módulos?"}),e.jsx("p",{className:"text-sm opacity-90",children:"Acesse nossa Wiki e descubra todos os detalhes sobre os módulos e suas funcionalidades"}),e.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm font-medium underline underline-offset-2 hover:opacity-80 transition-opacity",children:["Acessar a Wiki",e.jsx(d.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 space-y-2",children:[e.jsx("p",{className:"text-sm text-foreground",children:"Conheça todas as soluções que o Qualiex pode te oferecer"}),e.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm font-medium text-primary underline underline-offset-2 hover:opacity-80 transition-opacity",children:["Conhecer todos os módulos",e.jsx(d.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx("div",{className:"flex-1"}),o&&e.jsxs("button",{type:"button",onClick:l,className:"flex items-start gap-3 p-2 rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsx(d.Settings,{className:"h-5 w-5 text-muted-foreground shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"Configurações"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Gerenciar módulos ativos"})]})]})]})]})]})})},exports.MultiSelect=ia,exports.Muted=Di,exports.NavigationMenu=Fi,exports.NavigationMenuContent=qi,exports.NavigationMenuIndicator=Wi,exports.NavigationMenuItem=Oi,exports.NavigationMenuLink=Hi,exports.NavigationMenuList=Li,exports.NavigationMenuTrigger=$i,exports.NavigationMenuViewport=Bi,exports.NavigationProvider=Fl,exports.OnboardingDialog=Il,exports.P=Mi,exports.PageBreadcrumb=function({items:t,maxItems:a=3,className:s}){const r=t.length>a?[t[0],...t.slice(-(a-1))]:t,n=t.length>a;return e.jsx(wn,{className:s,children:e.jsx(Nn,{children:r.map((t,a)=>{const s=0===a,r=n&&1===a;return e.jsxs(yn,{children:[!s&&e.jsx(kn,{}),r&&e.jsxs(e.Fragment,{children:[e.jsx(Sn,{}),e.jsx(kn,{})]}),t.isCurrentPage?e.jsx(Cn,{children:t.label}):e.jsx(jn,{asChild:!0,children:e.jsx(y.Link,{to:t.href||"/",children:t.label})})]},t.label)})})})},exports.PageMetadataProvider=wr,exports.Pagination=Vi,exports.PaginationContent=Gi,exports.PaginationEllipsis=Zi,exports.PaginationItem=Yi,exports.PaginationLink=Qi,exports.PaginationNext=Ki,exports.PaginationPrevious=Xi,exports.PlaceCard=jc,exports.PlacesList=function({places:t,isLoading:a,manageAccessConfig:s}){const{t:r}=v.useTranslation();return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r("loading_data")})]})}):t&&0!==t.length?e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),t.map(t=>e.jsx(jc,{place:t,manageAccessConfig:s},t.id))]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[e.jsx(d.Building2,{className:"h-12 w-12 text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})},exports.Popover=Vt,exports.PopoverContent=Yt,exports.PopoverTrigger=Gt,exports.Progress=Ji,exports.ProtectedRoute=({children:a})=>{const{isAuthenticated:s,isLoading:r}=ls();if(t.useEffect(()=>{if(!s)return;const e=()=>{xa.areAllTokensValid()||ns.logout()};e();const t=setInterval(e,3e5);return()=>clearInterval(t)},[s]),t.useEffect(()=>{if(r)return;if(s)return;if(xa.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),t=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,a=new URLSearchParams(t);if(e.has("access_token")||a.has("access_token"))return;const n=Ua(),i=window.location.pathname+window.location.search+window.location.hash;["/","/login","/callback"].includes(window.location.pathname)||localStorage.setItem("auth_return_url",i);(async()=>{n?await ns.loginDev():ns.loginProd()})()},[s,r]),r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(Re,{className:"w-full max-w-md",children:[e.jsx(ze,{className:"text-center",children:e.jsx(Fe,{className:"text-xl font-semibold",children:"Carregando..."})}),e.jsxs(Oe,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!s){return new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token")?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(Re,{className:"w-full max-w-md",children:[e.jsx(ze,{className:"text-center",children:e.jsx(Fe,{className:"text-xl font-semibold",children:"Processando..."})}),e.jsxs(Oe,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(Re,{className:"w-full max-w-md",children:[e.jsx(ze,{className:"text-center",children:e.jsx(Fe,{className:"text-xl font-semibold",children:"Iniciando..."})}),e.jsxs(Oe,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:Ua()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return e.jsx(e.Fragment,{children:a})},exports.QUALIEX_CONFIG=$a,exports.QUERY_KEYS={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]},exports.QualiexEnrichmentService=Xa,exports.QualiexErrorInterceptor=Da,exports.QualiexUserField=tr,exports.RadioGroup=eo,exports.RadioGroupItem=to,exports.ResizableHandle=({withHandle:t,className:a,...s})=>e.jsx(ve.PanelResizeHandle,{className:Te("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",a),...s,children:t&&e.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:e.jsx(d.GripVertical,{className:"h-2.5 w-2.5"})})}),exports.ResizablePanel=ao,exports.ResizablePanelGroup=({className:t,...a})=>e.jsx(ve.PanelGroup,{className:Te("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",t),...a}),exports.RichTextEditor=({value:a,onChange:s,disabled:r,placeholder:n="Escreva o conteúdo aqui...",minHeight:i="300px",showModeToggle:o=!0,showVariableHint:l=!0,className:c})=>{const[u,m]=t.useState("visual"),h=H.useEditor({extensions:[B.configure({heading:{levels:[1,2,3]}}),W,V.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),G.TextStyle,Y.Color,Q.configure({multicolor:!0})],content:a||"",editable:!r,onUpdate:({editor:e})=>{s(e.getHTML())}});J.useEffect(()=>{h&&a!==h.getHTML()&&h.commands.setContent(a||"")},[a,h]);const p=t.useCallback(()=>{if(!h)return;const e=h.getAttributes("link").href,t=window.prompt("URL",e);null!==t&&(""!==t?h.chain().focus().extendMarkRange("link").setLink({href:t}).run():h.chain().focus().extendMarkRange("link").unsetLink().run())},[h]);return h?e.jsxs("div",{className:Te("space-y-2",c),children:[o&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(Ie,{type:"button",size:"sm",variant:"visual"===u?"default":"outline",onClick:()=>m("visual"),disabled:r,children:[e.jsx(d.Edit3,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),e.jsxs(Ie,{type:"button",size:"sm",variant:"code"===u?"default":"outline",onClick:()=>m("code"),disabled:r,children:[e.jsx(d.Code,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),e.jsxs(Ie,{type:"button",size:"sm",variant:"preview"===u?"default":"outline",onClick:()=>m("preview"),disabled:r,children:[e.jsx(d.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),l&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"{{variavel}}"})]})]}),"visual"===u&&e.jsxs("div",{className:"border rounded-md overflow-hidden bg-background",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e.jsx(kl,{onClick:()=>h.chain().focus().toggleHeading({level:1}).run(),isActive:h.isActive("heading",{level:1}),disabled:r,title:"Título 1",children:e.jsx(d.Heading1,{className:"h-4 w-4"})}),e.jsx(kl,{onClick:()=>h.chain().focus().toggleHeading({level:2}).run(),isActive:h.isActive("heading",{level:2}),disabled:r,title:"Título 2",children:e.jsx(d.Heading2,{className:"h-4 w-4"})}),e.jsx(kl,{onClick:()=>h.chain().focus().toggleHeading({level:3}).run(),isActive:h.isActive("heading",{level:3}),disabled:r,title:"Título 3",children:e.jsx(d.Heading3,{className:"h-4 w-4"})}),e.jsx(Sl,{}),e.jsx(kl,{onClick:()=>h.chain().focus().toggleBold().run(),isActive:h.isActive("bold"),disabled:r,title:"Negrito",children:e.jsx(d.Bold,{className:"h-4 w-4"})}),e.jsx(kl,{onClick:()=>h.chain().focus().toggleItalic().run(),isActive:h.isActive("italic"),disabled:r,title:"Itálico",children:e.jsx(d.Italic,{className:"h-4 w-4"})}),e.jsx(kl,{onClick:()=>h.chain().focus().toggleUnderline().run(),isActive:h.isActive("underline"),disabled:r,title:"Sublinhado",children:e.jsx(d.Underline,{className:"h-4 w-4"})}),e.jsx(kl,{onClick:()=>h.chain().focus().toggleStrike().run(),isActive:h.isActive("strike"),disabled:r,title:"Riscado",children:e.jsx(d.Strikethrough,{className:"h-4 w-4"})}),e.jsx(Sl,{}),e.jsx(kl,{onClick:()=>h.chain().focus().toggleBulletList().run(),isActive:h.isActive("bulletList"),disabled:r,title:"Lista",children:e.jsx(d.List,{className:"h-4 w-4"})}),e.jsx(kl,{onClick:()=>h.chain().focus().toggleOrderedList().run(),isActive:h.isActive("orderedList"),disabled:r,title:"Lista Ordenada",children:e.jsx(d.ListOrdered,{className:"h-4 w-4"})}),e.jsx(Sl,{}),e.jsx(kl,{onClick:()=>h.chain().focus().toggleHighlight().run(),isActive:h.isActive("highlight"),disabled:r,title:"Destacar",children:e.jsx(d.Highlighter,{className:"h-4 w-4"})}),e.jsx(kl,{onClick:p,isActive:h.isActive("link"),disabled:r,title:"Link",children:e.jsx(d.Link,{className:"h-4 w-4"})}),e.jsx(Sl,{}),e.jsx(kl,{onClick:()=>h.chain().focus().unsetAllMarks().clearNodes().run(),disabled:r,title:"Limpar Formatação",children:e.jsx(d.RemoveFormatting,{className:"h-4 w-4"})}),e.jsx(Sl,{}),e.jsx(kl,{onClick:()=>h.chain().focus().undo().run(),disabled:r||!h.can().undo(),title:"Desfazer",children:e.jsx(d.Undo,{className:"h-4 w-4"})}),e.jsx(kl,{onClick:()=>h.chain().focus().redo().run(),disabled:r||!h.can().redo(),title:"Refazer",children:e.jsx(d.Redo,{className:"h-4 w-4"})})]}),e.jsx(H.EditorContent,{editor:h,className:Te("prose prose-sm max-w-none p-4 focus:outline-none","[&_.ProseMirror]:outline-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none"),style:{minHeight:i}})]}),"code"===u&&e.jsx("textarea",{value:a||"",onChange:e=>s(e.target.value),disabled:r,className:"w-full p-3 border rounded-md font-mono text-sm resize-none focus:ring-2 focus:ring-primary bg-background",style:{height:i},placeholder:"Cole ou edite o HTML aqui..."}),"preview"===u&&e.jsx("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:i},children:e.jsx("div",{className:"bg-background shadow-sm rounded border p-4",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:a||`<p class="text-muted-foreground">${n}</p>`}})})})]}):null},exports.SEARCH_CONFIG=Oa,exports.SUPPORTED_LOCALES=Ar,exports.ScrollArea=Qs,exports.ScrollBar=Xs,exports.Select=dt,exports.SelectContent=ft,exports.SelectGroup=ct,exports.SelectItem=gt,exports.SelectLabel=xt,exports.SelectScrollDownButton=pt,exports.SelectScrollUpButton=ht,exports.SelectSearch=ia,exports.SelectSeparator=bt,exports.SelectTrigger=mt,exports.SelectValue=ut,exports.Separator=$e,exports.Sheet=so,exports.SheetBody=mo,exports.SheetClose=no,exports.SheetContent=co,exports.SheetDescription=fo,exports.SheetFooter=ho,exports.SheetHeader=uo,exports.SheetOverlay=oo,exports.SheetPortal=io,exports.SheetTitle=po,exports.SheetTrigger=ro,exports.Sidebar=wo,exports.SidebarActionTrigger=Zl,exports.SidebarContent=Po,exports.SidebarFooter=So,exports.SidebarGroup=Mo,exports.SidebarGroupAction=Ao,exports.SidebarGroupContent=Eo,exports.SidebarGroupLabel=Io,exports.SidebarHeader=Kl,exports.SidebarInput=Co,exports.SidebarInset=jo,exports.SidebarMenu=Do,exports.SidebarMenuAction=Fo,exports.SidebarMenuBadge=Lo,exports.SidebarMenuButton=zo,exports.SidebarMenuItem=_o,exports.SidebarMenuSkeleton=Oo,exports.SidebarMenuSub=Uo,exports.SidebarMenuSubButton=qo,exports.SidebarMenuSubItem=$o,exports.SidebarProvider=vo,exports.SidebarRail=yo,exports.SidebarSeparator=To,exports.SidebarSkeleton=function(){return e.jsx("div",{className:"w-64 border-r bg-muted/10",children:e.jsxs("div",{className:"p-4",children:[e.jsx(sa,{className:"h-8 w-32 mb-6"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((t,a)=>e.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[e.jsx(sa,{className:"h-4 w-4"}),e.jsx(sa,{className:"h-4 w-20"})]},a))})]})})},exports.SidebarTrigger=No,exports.Skeleton=sa,exports.Slider=Ho,exports.Small=Ei,exports.SonnerToaster=kt,exports.Spinner=Ct,exports.SplitButton=function({label:t,onClick:a,icon:s,actions:r=[],variant:n="default",size:i="default",disabled:o=!1,loading:l=!1,menuAlign:c="end",className:u}){const m=o||l;return r.length>0?e.jsxs("div",{className:Te("inline-flex rounded-md shadow-sm",u),children:[e.jsxs(Ie,{variant:n,size:i,disabled:m,onClick:a,className:"rounded-r-none border-r-0 focus:z-10",children:[l?e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?e.jsx(s,{className:"mr-2 h-4 w-4"}):null,t]}),e.jsxs(St,{children:[e.jsx(Tt,{asChild:!0,children:e.jsx(Ie,{variant:n,size:i,disabled:m,className:Te("rounded-l-none focus:z-10",{sm:"w-7 min-w-7 px-0",default:"w-8 min-w-8 px-0",lg:"w-9 min-w-9 px-0"}[i]),"aria-label":"Mais opções",children:e.jsx(d.ChevronDown,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[i]})})}),e.jsx(_t,{align:c,className:"min-w-[160px]",children:r.map(t=>{const a=t.icon;return e.jsxs(Rt,{onClick:t.onClick,disabled:t.disabled,className:Te("destructive"===t.variant&&"text-destructive focus:text-destructive"),children:[a&&e.jsx(a,{className:"mr-2 h-4 w-4"}),t.label]},t.id)})})]})]}):e.jsxs(Ie,{variant:n,size:i,disabled:m,onClick:a,className:u,children:[l?e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?e.jsx(s,{className:"mr-2 h-4 w-4"}):null,t]})},exports.Stack=dr,exports.StepSelector=function({currentStep:t,totalSteps:a,onStepChange:s,stepLabels:r,canGoToStep:n,className:i,progressWidth:o="w-32"}){const l=Array.from({length:a},(e,t)=>t+1),c=e=>!(e<=t)&&(!!n&&!n(e));return e.jsxs("div",{className:Te("flex items-center gap-3",i),children:[e.jsxs(St,{children:[e.jsx(Tt,{asChild:!0,children:e.jsxs(Ie,{variant:"ghost",size:"sm",className:"h-auto py-1 px-2 text-sm text-muted-foreground hover:text-foreground",children:["Etapa ",t,"/",a,e.jsx(d.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),e.jsx(_t,{align:"start",children:l.map(a=>e.jsxs(Rt,{onClick:()=>{var e;(e=a)<t?s(e):n&&!n(e)||s(e)},disabled:c(a),className:Te("cursor-pointer",a===t&&"bg-muted font-medium",c(a)&&"opacity-50 cursor-not-allowed"),children:[e.jsxs("span",{className:"mr-2 text-muted-foreground",children:[a,"."]}),r?.[a-1]||`Etapa ${a}`,a===t&&e.jsx(d.Check,{className:"h-4 w-4 ml-auto"})]},a))})]}),e.jsx(Ji,{value:t/a*100,className:Te("h-2",o)})]})},exports.Switch=Js,exports.TIMEZONES=Dr,exports.TabPageContent=function({children:t,className:a}){return e.jsx("div",{className:Te("space-y-6",a),children:t})},exports.TabPageHeader=function({title:t,description:a,actions:s,className:r}){return e.jsxs("div",{className:Te("space-y-4",r),children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:t}),a&&e.jsx("p",{className:"text-muted-foreground text-sm",children:a})]}),s&&e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),e.jsx($e,{})]})},exports.TabPageLayout=function({children:t,className:a}){return e.jsx("div",{className:Te("flex flex-col h-full",a),children:e.jsx(Qs,{className:"flex-1",children:e.jsx("div",{className:"space-y-6 p-6",children:t})})})},exports.Table=cs,exports.TableBody=ms,exports.TableCaption=gs,exports.TableCell=xs,exports.TableFooter=hs,exports.TableHead=fs,exports.TableHeader=us,exports.TableResizeHandle=js,exports.TableRow=ps,exports.TableRowActions=Us,exports.TableSkeleton=bs,exports.Tabs=Bo,exports.TabsContent=Go,exports.TabsList=Wo,exports.TabsTrigger=Vo,exports.Textarea=wt,exports.Toaster=kt,exports.Toggle=Qo,exports.ToggleGroup=Ko,exports.ToggleGroupItem=Zo,exports.TokenManager=xa,exports.TokenService=la,exports.Tooltip=qt,exports.TooltipContent=Bt,exports.TooltipProvider=$t,exports.TooltipTrigger=Ht,exports.TranslationLoader=Yr,exports.TruncatedCell=ys,exports.VideoEditor=function({value:a,onChange:s,onSubmit:r,onCancel:n,uploadFunction:i,deleteFunction:o,uploadOptions:c}){const{t:u}=v.useTranslation(),[m,h]=t.useState(a||{inputType:"url",controls:!0}),p=t.useRef(null),f=t.useRef(null),{upload:x,uploading:g}=Vc({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["video/*"],maxSize:104857600}}),{upload:b,uploading:w}=Vc({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),N=t.useMemo(()=>Zc(m.videoUrl||Kc(m.embedCode)||""),[m.videoUrl,m.embedCode]),y=(e,t)=>{const a={...m,[e]:t};h(a),s(a)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:u("input_type")}),e.jsxs(dt,{value:m.inputType||"url",onValueChange:e=>y("inputType",e),children:[e.jsx(mt,{children:e.jsx(ut,{})}),e.jsxs(ft,{children:[e.jsx(gt,{value:"url",children:u("url")}),e.jsx(gt,{value:"upload",children:u("input_type_upload")}),e.jsx(gt,{value:"embed",children:u("input_type_embed")})]})]})]}),"upload"===m.inputType&&i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:u("file")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:p,type:"file",accept:"video/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await x(t),a={...m,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:m.title||t.name.replace(/\.[^/.]+$/,"")};h(a),s(a)}catch(a){}finally{p.current&&(p.current.value="")}},className:"hidden"}),e.jsx(Ie,{type:"button",variant:"outline",onClick:()=>p.current?.click(),disabled:g,children:g?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),u("uploading")]}):e.jsxs(e.Fragment,{children:[e.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),u("select_video")]})}),m.videoFile&&e.jsx("span",{className:"text-xs text-muted-foreground truncate self-center",children:u("video.fileInfo",{name:m.videoFile,size:Math.round((m.videoSize||0)/1024/1024)})})]})]}),"embed"===m.inputType&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:u("embed")}),e.jsx(wt,{placeholder:u("embed"),value:m.embedCode||"",onChange:e=>y("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:u("thumbnail")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ee,{type:"url",placeholder:u("thumbnail"),value:m.thumbnail||"",onChange:e=>y("thumbnail",e.target.value),className:"flex-1"}),e.jsx("input",{ref:f,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await b(t),a={...m,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};h(a),s(a)}catch(a){}finally{f.current&&(f.current.value="")}},className:"hidden"}),e.jsx(Ie,{type:"button",variant:"outline",onClick:()=>f.current?.click(),disabled:w,children:w?e.jsxs(e.Fragment,{children:[e.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),u("video.uploading")]}):e.jsxs(e.Fragment,{children:[e.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),u("upload")]})})]}),m.thumbnailFile&&e.jsx("p",{className:"text-xs text-muted-foreground",children:u("video.thumbnailFileInfo",{name:m.thumbnailFile})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:u("title")}),e.jsx(Ee,{id:"title",placeholder:u("title"),value:m.title||"",onChange:e=>y("title",e.target.value)})]}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"autoplay",type:"checkbox",checked:m.autoplay||!1,onChange:e=>y("autoplay",e.target.checked),className:"h-4 w-4"}),e.jsx(_e,{htmlFor:"autoplay",className:"cursor-pointer",children:u("video.autoplay")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"controls",type:"checkbox",checked:!1!==m.controls,onChange:e=>y("controls",e.target.checked),className:"h-4 w-4"}),e.jsx(_e,{htmlFor:"controls",className:"cursor-pointer",children:u("video.controls")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:u("preview")}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const t=m.videoUrl||Kc(m.embedCode)||"";if(!t)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:u("no_content_preview")});if("file"===N)return e.jsxs("video",{controls:!1!==m.controls,autoPlay:m.autoplay,poster:m.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[e.jsx("source",{src:t}),u("unsupported")]});const a="youtube"===N?Yc(t,m.autoplay):Xc(t,m.autoplay);return e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:m.title||u("video"),src:a,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(Ie,{variant:"outline",onClick:n,children:u("cancel")}),e.jsx(Ie,{onClick:()=>{m.videoUrl||m.embedCode?r(m):l.toast.error(u("error"),{description:u("error_no_video")})},disabled:!(m.videoUrl||m.embedCode),children:u("save")})]})]})},exports.VideoRenderer=function({content:t,className:a="",style:s}){const r=t.videoUrl||Kc(t.embedCode)||"";if(!r)return null;const n=Zc(r),{t:i}=v.useTranslation();return e.jsx(Re,{className:`overflow-hidden my-4 ${a}`,style:s,children:e.jsxs(Oe,{className:"p-0",children:["file"===n?e.jsxs("video",{controls:!1!==t.controls,autoPlay:t.autoplay,poster:t.thumbnail,className:"w-full h-auto",playsInline:!0,muted:t.autoplay,children:[e.jsx("source",{src:r}),"Seu navegador não suporta vídeos HTML5."]}):e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:t.title||i("video"),src:"youtube"===n?Yc(r,t.autoplay):Xc(r,t.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),t.title&&e.jsx("div",{className:"p-4",children:e.jsx("p",{className:"text-sm font-medium",children:t.title})})]})})},exports.assets=Yl,exports.badgeVariants=Nt,exports.buildHierarchy=Tc,exports.buttonGroupVariants=Tn,exports.buttonVariants=Me,exports.calculateAspectRatio=Jc,exports.cn=Te,exports.createCrudPage=function(t){return({manager:a})=>{const{manager:s,config:r,onSave:n,onEdit:i,onToggleStatus:o}=t,l=a??s,d={entityName:r.entityName,entityNamePlural:r.entityNamePlural,filters:r.filters||[],columns:r.columns,cardFields:r.cardFields||[],enableBulkActions:r.enableBulkActions??!1,bulkActions:r.bulkActions||[],customActions:r.customActions,customRowActions:r.customRowActions,customListView:r.customListView,onEdit:i||r.onEdit,onNew:r.onNew,useCustomRouting:r.useCustomRouting,hideNewButton:r.hideNewButton};return e.jsx(ur,{manager:l,config:d,formSections:r.formSections,onSave:n,onToggleStatus:o,defaultSort:r.defaultSort})}},exports.createCrudRoutingConfig=function(e,t){const a=Dl({basePath:e,newPath:t.newPath,editPath:t.editPath});return{useCustomRouting:!0,onNew:a.onNew,onEdit:a.onEdit}},exports.createRoutingHandlers=Dl,exports.createService=Ja,exports.createSimpleSaveHandler=function(e,t,a){return s=>{if(s.id){const t=a(s);e.updateEntity(s.id,t)}else{const a=t(s);e.createEntity(a)}}},exports.createSimpleService=function(e){const t=Ja({tableName:e.tableName,searchFields:e.searchFields||["title"],selectFields:e.selectFields,schemaName:e.schemaName||"central",entityName:e.entityName,enableQualiexEnrichment:e.enableQualiexEnrichment||!0,userIdFields:e.userIdFields,userFieldsMapping:e.userFieldsMapping});return{service:t,useCrudHook:(a,s)=>ds({queryKey:e.tableName,service:{...t,getAll:async(e={})=>await t.getAll({...e})},entityName:e.entityName,additionalFilters:a,onSuccess:s})}},exports.debounce=(e,t)=>{let a;return(...s)=>{clearTimeout(a),a=setTimeout(()=>e(...s),t)}},exports.deriveEmailField=Va,exports.deriveNameField=Wa,exports.deriveUsernameField=Ga,exports.detectBrowserLocale=Or,exports.detectBrowserPreferences=qr,exports.detectBrowserTimezone=Ur,exports.detectVideoProvider=Zc,exports.emailService=Nc,exports.errorService=va,exports.extractImageFileName=function(e){try{const t=new URL(e),a=t.pathname.split("/");return a[a.length-1]||"image"}catch{const t=e.split("/");return t[t.length-1]||"image"}},exports.extractVimeoId=Qc,exports.extractYouTubeId=Gc,exports.filterAndPromoteOrphans=function(e,t){const a=e.map(e=>({...e})),s=new Set(a.filter(e=>!t.has(e.id_user)).map(e=>e.id_user));return a.forEach(e=>{if(e.id_leader&&s.has(e.id_leader)){let t=e.id_leader;for(;t&&s.has(t);){const e=a.find(e=>e.id_user===t);t=e?.id_leader||null}e.id_leader=t}}),a.filter(e=>t.has(e.id_user))},exports.findDatetimeFormat=e=>Er.find(t=>t.value===e),exports.findLocale=e=>Ar.find(t=>t.value===e),exports.findTimezone=e=>Dr.find(t=>t.value===e),exports.flattenTree=Pc,exports.formatCurrency=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),exports.formatDate=vc,exports.formatDatetime=e=>{if(!e)return"";const t=i.parseISO(e);if(!i.isValid(t))return"Data inválida";return`${t.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",timeZone:"America/Sao_Paulo"})} ${t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit",timeZone:"America/Sao_Paulo"})}`},exports.formatFileSize=function(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`},exports.generateCrudConfig=function(e,t,a={}){const s=[];return Object.keys(t).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const a=t[e],r={key:e,header:hr(e),label:hr(e),...mr(e,a),sortable:!0,searchable:"string"==typeof a};s.push(r)}}),{title:e,columns:s,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...a}},exports.getQualiexConfig=qa,exports.getSupabaseClient=Sa,exports.handleExternalLink=Se,exports.inferDatetimeFormat=$r,exports.inputGroupAddonVariants=vi,exports.inputGroupButtonVariants=Ni,exports.isDevEnvironment=Ua,exports.isImageUrl=function(e){const t=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"].some(e=>t.includes(e))},exports.isValidDatetimeFormat=e=>Er.some(t=>t.value===e),exports.isValidLocale=Fr,exports.isValidTimezone=Lr,exports.logoSrc=Ql,exports.navigationMenuTriggerStyle=Ui,exports.normalizeVideoUrl=function(e,t,a){switch(t||Zc(e)){case"youtube":return Yc(e,a);case"vimeo":return Xc(e,a);default:return e}},exports.normalizeVimeoUrl=Xc,exports.normalizeYouTubeUrl=Yc,exports.parseIframeSrc=Kc,exports.placeService=Sc,exports.qualiexApi=za,exports.resizeKeepingAspect=function(e,t,a,s){const r=Jc(e,t);return a&&!s?{width:a,height:Math.round(a/r)}:s&&!a?{width:Math.round(s*r),height:s}:{width:e,height:t}},exports.resolveFieldMappings=Ya,exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new N.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.slugify=e=>e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-"),exports.smallLogoSrc=Xl,exports.toggleVariants=Yo,exports.translationService=Tr,exports.trimTextFields=Pe,exports.useActiveModules=Hl,exports.useAuth=ls,exports.useBaseForm=Vs,exports.useColumnResize=qs,exports.useCreateLeaderMutation=function(){const e="common",{alias:t}=ls(),a=N.useQueryClient(),s=Sa();return N.useMutation({mutationFn:async a=>{if(!t)throw new Error("Unidade não selecionada");if(a.id_user===a.id_leader)throw new Error("Usuário não pode ser seu próprio líder");if((await s.schema(e).from("leaders").select("id").eq("alias",t).eq("id_user",a.id_user).eq("is_removed",!1).maybeSingle()).data)throw new Error("Este usuário já está cadastrado como líder");a.id_leader&&await Rc(s,t,e,a.id_user,a.id_leader);const{data:r,error:n}=await s.schema(e).from("leaders").insert({alias:t,id_user:a.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return r},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",t]}),l.toast.success("Líder adicionado com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao adicionar líder")}})},exports.useCreateMultipleLeadersMutation=Ac,exports.useCreateSingleLeaderMutation=Ic,exports.useCrud=ds,exports.useDebounce=Ul,exports.useFormField=at,exports.useHasOpenModal=function(){const{hasOpenModal:e}=td();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:t}=Gr(),a=Rr;return{formatDatetime:s=>((e,t=Rr,a=zr,s=_r)=>{if(!e)return"";const r=i.parseISO(e);if(!i.isValid(r))return"Data inválida";const n=bc[s]||ei;try{return gc(r,a,t,{locale:n})}catch(o){return gc(r,zr,t,{locale:n})}})(s,a,t,e),formatDate:a=>vc(a,e,t),locale:e,timezone:t,datetimeFormat:a}},exports.useLeadershipApi=Mc,exports.useLocale=Gr,exports.useMediaUpload=Vc,exports.useModalState=td,exports.useNavigation=Ll,exports.usePageMetadata=function(e){const{setMetadata:a,clearMetadata:s}=Nr();t.useEffect(()=>(a(e),()=>s()),[e.title,e.subtitle,a,s])},exports.usePageMetadataContext=Nr,exports.usePageTitle=Ol,exports.usePermissionQuery=ql,exports.useQualiexUsers=er,exports.useRemoveLeaderMutation=Dc,exports.useRouteBreadcrumbs=function(){const e=y.useLocation();return(()=>{const t=e.pathname.split("/").filter(Boolean),a=[{label:"Exemplos",href:"/"}];let s="";return t.forEach((e,r)=>{s+=`/${e}`;const n=r===t.length-1,i=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");a.push({label:i,href:n?void 0:s,isCurrentPage:n})}),a})()},exports.useRowResize=Hs,exports.useSidebar=bo,exports.useSidebarResize=Jl,exports.useSyncSubordinatesMutation=_c,exports.useUpdateLeaderMutation=Ec,exports.useWizard=function(e){const{steps:a,initialStep:s=0,initialData:r={},onComplete:n,onCancel:i}=e,[o,l]=t.useState(s),[d,c]=t.useState(r),[u,m]=t.useState(!1),[h,p]=t.useState(!1),f=a.length,x=0===o,g=o===f-1,b=a[o],v=f>1?(o+1)/f*100:100,w=t.useCallback(()=>!b?.canProceed||b.canProceed(),[b]),N=t.useMemo(()=>w(),[w,d]),y=t.useMemo(()=>!x&&!b?.disableBack,[x,b]),j=t.useCallback(e=>{c(t=>({...t,...e}))},[]),C=t.useCallback((e,t)=>{c(a=>({...a,[e]:t}))},[]),k=t.useCallback(()=>{l(s),c(r),m(!1),p(!1),i?.()},[s,r,i]),S=t.useCallback(async()=>{if(w()&&!h){p(!0);try{await(n?.(d))}finally{p(!1)}}},[w,h,d,n]),T=t.useCallback(async()=>{w()&&!u&&(g?await S():l(e=>Math.min(e+1,f-1)))},[w,u,g,f,S]),P=t.useCallback(()=>{y&&!u&&l(e=>Math.max(e-1,0))},[y,u]),M=t.useCallback(e=>{e<0||e>=f||u||(e<=o||e===o+1)&&l(e)},[o,f,u]),I=t.useCallback(e=>{m(e)},[]);return{currentStep:o,currentStepConfig:b,data:d,isFirstStep:x,isLastStep:g,isLoading:u,isCompleting:h,next:T,back:P,goTo:M,canProceed:N,canGoBack:y,setData:j,updateField:C,reset:k,complete:S,setLoading:I,progress:v,stepIndex:o,totalSteps:f}};
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react"),a=require("@radix-ui/react-slot"),s=require("class-variance-authority"),r=require("clsx"),n=require("tailwind-merge"),o=require("date-fns"),i=require("sonner"),l=require("lucide-react"),d=require("@radix-ui/react-label"),c=require("@radix-ui/react-dialog"),u=require("@radix-ui/react-separator"),m=require("react-hook-form"),p=require("@radix-ui/react-select"),h=require("@radix-ui/react-checkbox"),f=require("@radix-ui/react-dropdown-menu"),x=require("@radix-ui/react-tooltip"),g=require("@radix-ui/react-popover"),b=require("@supabase/supabase-js"),v=require("@tanstack/react-query"),w=require("react-router-dom"),N=require("@radix-ui/react-context-menu"),y=require("@radix-ui/react-toggle-group"),j=require("@radix-ui/react-toggle"),C=require("@radix-ui/react-scroll-area"),k=require("@radix-ui/react-switch"),S=require("react-i18next"),T=require("i18next"),_=require("@radix-ui/react-collapsible"),A=require("@radix-ui/react-accordion"),E=require("@radix-ui/react-alert-dialog"),P=require("@radix-ui/react-avatar"),M=require("react-day-picker"),I=require("vaul"),D=require("@radix-ui/react-hover-card"),R=require("@radix-ui/react-navigation-menu"),L=require("@radix-ui/react-progress"),z=require("@radix-ui/react-radio-group"),F=require("react-resizable-panels"),U=require("@radix-ui/react-slider"),q=require("@radix-ui/react-tabs"),O=require("@radix-ui/react-menubar"),B=require("recharts"),H=require("@tiptap/react"),$=require("@tiptap/starter-kit"),V=require("@tiptap/extension-underline"),W=require("@tiptap/extension-link"),G=require("@tiptap/extension-text-style"),Y=require("@tiptap/extension-color"),Q=require("@tiptap/extension-highlight"),K=require("zod"),X=require("@hookform/resolvers");function Z(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(a){if("default"!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,Object.freeze(t)}var J=Z(t),ee=Z(d),te=Z(c),ae=Z(u),se=Z(p),re=Z(h),ne=Z(f),oe=Z(x),ie=Z(g),le=Z(N),de=Z(y),ce=Z(j),ue=Z(C),me=Z(k),pe=Z(_),he=Z(A),fe=Z(E),xe=Z(P),ge=Z(D),be=Z(R),ve=Z(L),we=Z(z),Ne=Z(F),ye=Z(U),je=Z(q),Ce=Z(O),ke=Z(B);function Se(e,t){t?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{i.toast.info("Link copiado para a área de transferência")})}function Te(...e){return n.twMerge(r.clsx(e))}const _e=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(_e);if("object"==typeof e&&e.constructor===Object){const t={};for(const[a,s]of Object.entries(e))t[a]=_e(s);return t}return e},Ae=s.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{primary:"bg-primary text-primary-foreground hover:bg-primary-hover shadow-sm hover:shadow-md active:scale-[0.98]",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary-hover border border-input shadow-sm",tertiary:"bg-background text-foreground hover:bg-accent hover:text-accent-foreground border border-border",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",ghost:"hover:bg-accent hover:text-accent-foreground",subtle:"text-muted-foreground hover:text-foreground hover:bg-accent/50",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm hover:shadow-md",danger:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm hover:shadow-md",link:"text-primary underline-offset-4 hover:underline",icon:"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2",loading:"bg-primary/50 text-primary-foreground cursor-wait",default:"bg-primary text-primary-foreground hover:bg-primary/90",action:"bg-primary/10 text-primary hover:bg-primary/20 border border-primary/30","icon-only":"bg-transparent border border-input hover:bg-accent hover:text-accent-foreground p-2","external-link":"bg-transparent text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors","action-primary":"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm","action-secondary":"bg-secondary text-secondary-foreground hover:bg-secondary/80 border border-input"},size:{sm:"h-8 px-3 text-xs rounded",md:"h-10 px-4 py-2 text-sm rounded-md",lg:"h-12 px-8 text-base rounded-lg",xl:"h-14 px-10 text-lg rounded-lg",icon:"h-10 w-10","icon-sm":"h-8 w-8","icon-xs":"h-6 w-6",default:"h-10 px-4 py-2"}},defaultVariants:{variant:"primary",size:"md"}}),Ee=J.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...o},i)=>{const l=n?a.Slot:"button";return e.jsx(l,{className:Te(Ae({variant:s,size:r,className:t})),ref:i,...o})});Ee.displayName="Button";const Pe=t.forwardRef(({className:t,children:a,variant:s="action",...r},n)=>e.jsx(Ee,{ref:n,variant:s,size:"icon",className:Te("h-8 w-8",t),...r,children:a||e.jsx(l.EllipsisVertical,{size:16})}));Pe.displayName="ActionButton";const Me=J.forwardRef(({className:t,type:a,...s},r)=>e.jsx("input",{type:a,className:Te("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:r,...s}));Me.displayName="Input";const Ie=s.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),De=J.forwardRef(({className:t,...a},s)=>e.jsx(ee.Root,{ref:s,className:Te(Ie(),t),...a}));De.displayName=ee.Root.displayName;const Re=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("rounded-lg border bg-card text-card-foreground shadow-sm",t),...a}));Re.displayName="Card";const Le=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("flex flex-col space-y-1.5 p-6",t),...a}));Le.displayName="CardHeader";const ze=J.forwardRef(({className:t,...a},s)=>e.jsx("h3",{ref:s,className:Te("text-2xl font-semibold leading-none tracking-tight",t),...a}));ze.displayName="CardTitle";const Fe=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Te("text-sm text-muted-foreground",t),...a}));Fe.displayName="CardDescription";const Ue=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("p-6 pt-0",t),...a}));Ue.displayName="CardContent";const qe=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("flex items-center p-6 pt-0",t),...a}));qe.displayName="CardFooter";const Oe=J.forwardRef(({className:t,orientation:a="horizontal",decorative:s=!0,...r},n)=>e.jsx(ae.Root,{ref:n,decorative:s,orientation:a,className:Te("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",t),...r}));Oe.displayName=ae.Root.displayName;const Be=te.Root,He=te.Trigger,$e=te.Portal,Ve=te.Close,We=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Overlay,{ref:s,className:Te("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a}));We.displayName=te.Overlay.displayName;const Ge={sm:{width:"30vw",minWidth:"320px",maxWidth:"480px",maxHeight:"320px"},md:{width:"50vw",minWidth:"480px",maxWidth:"720px",maxHeight:"70vh"},lg:{width:"85vw",height:"85vh",minWidth:"720px",maxWidth:"1440px",minHeight:"480px",maxHeight:"900px"}},Ye=J.forwardRef(({className:t,children:a,size:s="md",customWidth:r,customMinWidth:n,customMaxWidth:o,customHeight:i,customMinHeight:d,customMaxHeight:c,style:u,...m},p)=>{const h=Ge[s],f={width:r??h.width,minWidth:n??h.minWidth,maxWidth:o??h.maxWidth,height:i??h.height,minHeight:d??h.minHeight,maxHeight:c??h.maxHeight,...u};return e.jsxs($e,{children:[e.jsx(We,{}),e.jsxs(te.Content,{ref:p,className:Te("fixed left-[50%] top-[50%] z-50 flex flex-col translate-x-[-50%] translate-y-[-50%] border bg-background p-6 shadow-lg duration-200 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 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",t),style:f,...m,children:[a,e.jsxs(te.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-0 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(l.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Ye.displayName=te.Content.displayName;const Qe=({className:t,showSeparator:a=!1,children:s,...r})=>e.jsxs("div",{className:Te("flex flex-col flex-shrink-0",t),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),a&&e.jsx(Oe,{className:"mt-2"})]});Qe.displayName="DialogHeader";const Ke=({className:t,...a})=>e.jsx("div",{className:Te("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",t),...a});Ke.displayName="DialogBody";const Xe=({className:t,children:a,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Oe,{className:"mb-4"}),e.jsx("div",{className:Te("flex flex-row justify-end gap-2",t),...s,children:a})]});Xe.displayName="DialogFooter";const Ze=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Title,{ref:s,className:Te("text-lg font-semibold leading-none tracking-tight",t),...a}));Ze.displayName=te.Title.displayName;const Je=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Description,{ref:s,className:Te("text-sm text-muted-foreground",t),...a}));Je.displayName=te.Description.displayName;const et=m.FormProvider,tt=J.createContext({}),at=()=>{const e=J.useContext(tt),t=J.useContext(st),{getFieldState:a,formState:s}=m.useFormContext(),r=a(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=t;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...r}},st=J.createContext({}),rt=J.forwardRef(({className:t,...a},s)=>{const r=J.useId();return e.jsx(st.Provider,{value:{id:r},children:e.jsx("div",{ref:s,className:Te("space-y-2",t),...a})})});rt.displayName="FormItem";const nt=J.forwardRef(({className:t,...a},s)=>{const{error:r,formItemId:n}=at();return e.jsx(De,{ref:s,className:Te(r&&"text-destructive",t),htmlFor:n,...a})});nt.displayName="FormLabel";const ot=J.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:o,formMessageId:i}=at();return e.jsx(a.Slot,{ref:s,id:n,"aria-describedby":r?`${o} ${i}`:`${o}`,"aria-invalid":!!r,...t})});ot.displayName="FormControl";const it=J.forwardRef(({className:t,...a},s)=>{const{formDescriptionId:r}=at();return e.jsx("p",{ref:s,id:r,className:Te("text-sm text-muted-foreground",t),...a})});it.displayName="FormDescription";const lt=J.forwardRef(({className:t,children:a,...s},r)=>{const{error:n,formMessageId:o}=at(),i=n?String(n?.message):a;return i?e.jsx("p",{ref:r,id:o,className:Te("text-sm font-medium text-destructive",t),...s,children:i}):null});lt.displayName="FormMessage";const dt=se.Root,ct=se.Group,ut=se.Value,mt=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(se.Trigger,{ref:r,className:Te("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...s,children:[a,e.jsx(se.Icon,{asChild:!0,children:e.jsx(l.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));mt.displayName=se.Trigger.displayName;const pt=J.forwardRef(({className:t,...a},s)=>e.jsx(se.ScrollUpButton,{ref:s,className:Te("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(l.ChevronUp,{className:"h-4 w-4"})}));pt.displayName=se.ScrollUpButton.displayName;const ht=J.forwardRef(({className:t,...a},s)=>e.jsx(se.ScrollDownButton,{ref:s,className:Te("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(l.ChevronDown,{className:"h-4 w-4"})}));ht.displayName=se.ScrollDownButton.displayName;const ft=J.forwardRef(({className:t,children:a,position:s="popper",container:r,collisionBoundary:n,...o},i)=>e.jsx(se.Portal,{container:r,children:e.jsxs(se.Content,{ref:i,className:Te("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,collisionBoundary:n,...o,children:[e.jsx(pt,{}),e.jsx(se.Viewport,{className:Te("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),e.jsx(ht,{})]})}));ft.displayName=se.Content.displayName;const xt=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Label,{ref:s,className:Te("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...a}));xt.displayName=se.Label.displayName;const gt=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(se.Item,{ref:r,className:Te("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(se.ItemIndicator,{children:e.jsx(l.Check,{className:"h-4 w-4"})})}),e.jsx(se.ItemText,{children:a})]}));gt.displayName=se.Item.displayName;const bt=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Separator,{ref:s,className:Te("-mx-1 my-1 h-px bg-muted",t),...a}));bt.displayName=se.Separator.displayName;const vt=J.forwardRef(({className:t,...a},s)=>e.jsx(re.Root,{ref:s,className:Te("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...a,children:e.jsx(re.Indicator,{className:Te("flex items-center justify-center text-current"),children:e.jsx(l.Check,{className:"h-4 w-4"})})}));vt.displayName=re.Root.displayName;const wt=J.forwardRef(({className:t,...a},s)=>e.jsx("textarea",{className:Te("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",t),ref:s,...a}));wt.displayName="Textarea";const Nt=s.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",danger:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-success text-success-foreground hover:bg-success/90",warning:"border-transparent bg-warning text-warning-foreground hover:bg-warning/90",info:"border-transparent bg-primary/10 text-primary hover:bg-primary/20",sharp:"border-transparent bg-[hsl(78,70%,46%)] text-foreground hover:bg-[hsl(78,70%,40%)]"}},defaultVariants:{variant:"default"}}),yt=J.forwardRef(({className:t,variant:a,...s},r)=>e.jsx("div",{ref:r,className:Te(Nt({variant:a}),t),...s}));yt.displayName="Badge";const jt={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Ct({size:t="md",className:a}){return e.jsx(l.Loader2,{className:Te("animate-spin text-muted-foreground",jt[t],a)})}const kt=({...t})=>e.jsx(i.Toaster,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:e.jsx(l.CircleCheckIcon,{className:"h-4 w-4"}),info:e.jsx(l.InfoIcon,{className:"h-4 w-4"}),warning:e.jsx(l.TriangleAlertIcon,{className:"h-4 w-4"}),error:e.jsx(l.OctagonXIcon,{className:"h-4 w-4"}),loading:e.jsx(l.Loader2Icon,{className:"h-4 w-4 animate-spin"})},toastOptions:{classNames:{toast:"group toast group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg group-[.toaster]:relative",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",closeButton:"group-[.toast]:absolute group-[.toast]:right-2 group-[.toast]:top-2 group-[.toast]:left-auto group-[.toast]:transform-none group-[.toast]:border-0 group-[.toast]:bg-transparent group-[.toast]:opacity-70 group-[.toast]:hover:opacity-100 group-[.toast]:hover:bg-transparent group-[.toast]:transition-opacity",success:"!bg-success-light !border-success-light",error:"!bg-destructive/10 !border-destructive/10",warning:"!bg-warning-light !border-warning-light",info:"!bg-info-light !border-info-light"}},...t}),St=ne.Root,Tt=ne.Trigger,_t=ne.Group,At=ne.Portal,Et=ne.Sub,Pt=ne.RadioGroup,Mt=J.forwardRef(({className:t,inset:a,children:s,...r},n)=>e.jsxs(ne.SubTrigger,{ref:n,className:Te("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",a&&"pl-8",t),...r,children:[s,e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Mt.displayName=ne.SubTrigger.displayName;const It=J.forwardRef(({className:t,...a},s)=>e.jsx(ne.SubContent,{ref:s,className:Te("z-50 min-w-[8rem] overflow-hidden border bg-popover p-1 text-popover-foreground shadow-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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a}));It.displayName=ne.SubContent.displayName;const Dt=J.forwardRef(({className:t,sideOffset:a=4,...s},r)=>e.jsx(ne.Portal,{children:e.jsx(ne.Content,{ref:r,sideOffset:a,className:Te("z-[100] min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground p-1 shadow-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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s})}));Dt.displayName=ne.Content.displayName;const Rt=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(ne.Item,{ref:r,className:Te("relative flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",t),...s}));Rt.displayName=ne.Item.displayName;const Lt=J.forwardRef(({className:t,children:a,checked:s,...r},n)=>e.jsxs(ne.CheckboxItem,{ref:n,className:Te("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ne.ItemIndicator,{children:e.jsx(l.Check,{className:"h-4 w-4"})})}),a]}));Lt.displayName=ne.CheckboxItem.displayName;const zt=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(ne.RadioItem,{ref:r,className:Te("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ne.ItemIndicator,{children:e.jsx(l.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));zt.displayName=ne.RadioItem.displayName;const Ft=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(ne.Label,{ref:r,className:Te("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",t),...s}));Ft.displayName=ne.Label.displayName;const Ut=J.forwardRef(({className:t,...a},s)=>e.jsx(ne.Separator,{ref:s,className:Te("-mx-1 my-1 h-px bg-muted",t),...a}));Ut.displayName=ne.Separator.displayName;const qt=({className:t,...a})=>e.jsx("span",{className:Te("ml-auto text-xs tracking-widest opacity-60",t),...a});qt.displayName="DropdownMenuShortcut";const Ot=({delayDuration:t=300,...a})=>e.jsx(oe.Provider,{delayDuration:t,...a}),Bt=oe.Root,Ht=oe.Trigger,$t=J.forwardRef(({className:t,sideOffset:a=4,...s},r)=>e.jsx(oe.Content,{ref:r,sideOffset:a,className:Te("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s}));$t.displayName=oe.Content.displayName;const Vt=J.forwardRef(({children:t,disabledReason:a,className:s},r)=>{const n=e.jsx(Rt,{ref:r,className:Te("opacity-50 cursor-not-allowed pointer-events-auto",s),onSelect:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation()},children:t});return a?e.jsx(Ot,{delayDuration:100,children:e.jsxs(Bt,{children:[e.jsx(Ht,{asChild:!0,children:e.jsx("div",{className:"w-full",children:n})}),e.jsx($t,{side:"right",sideOffset:8,className:"max-w-[200px] z-[100]",children:a})]})}):n});Vt.displayName="DisabledMenuItem";const Wt=ie.Root,Gt=ie.Trigger,Yt=J.forwardRef(({className:t,align:a="center",sideOffset:s=4,container:r,...n},o)=>e.jsx(ie.Portal,{container:r,children:e.jsx(ie.Content,{ref:o,align:a,sideOffset:s,className:Te("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));Yt.displayName=ie.Content.displayName;const Qt=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...a}));Qt.displayName="Command";const Kt=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:e.jsx("input",{ref:s,className:Te("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...a})}));Kt.displayName="CommandInput";const Xt=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...a}));Xt.displayName="CommandList";const Zt=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("py-6 text-center text-sm text-muted-foreground",t),...a}));Zt.displayName="CommandEmpty";const Jt=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...a}));Jt.displayName="CommandGroup";const ea=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("-mx-1 h-px bg-border",t),...a}));ea.displayName="CommandSeparator";const ta=J.forwardRef(({className:t,disabled:a,onSelect:s,value:r,...n},o)=>e.jsx("div",{ref:o,className:Te("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",t),"data-disabled":a,onClick:()=>!a&&s?.(r||""),...n}));ta.displayName="CommandItem";const aa=({className:t,...a})=>e.jsx("span",{className:Te("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});function sa({className:t,...a}){return e.jsx("div",{className:Te("animate-pulse rounded-md bg-muted",t),...a})}aa.displayName="CommandShortcut";const ra=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function na({multiple:a,options:s,value:r,onChange:n,getOptionValue:o,getOptionLabel:i,placeholder:d,label:c,icon:u,emptyMessage:m,searchPlaceholder:p,disabled:h,required:f,className:x,sortOptions:g,maxDisplayedBadges:b,popoverContainer:v,onOpen:w,onClose:N}){const[y,j]=t.useState(!1),[C,k]=t.useState(""),S=t.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),T=t.useMemo(()=>{if(!v)return;let e=v,t=0;try{for(;e&&t<3;){const a=window.getComputedStyle(e),s=a.overflowY||a.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,t++}}catch{}return e??void 0},[v]),_=t.useMemo(()=>{const e=s.map(e=>({original:e,value:o(e),label:i(e)}));return g?e.sort((e,t)=>e.label.localeCompare(t.label,"pt-BR",{sensitivity:"base"})):e},[s,o,i,g]),A=t.useMemo(()=>{if(!C)return _;const e=ra(C);return _.filter(t=>ra(t.label).includes(e))},[_,C]),E=t.useMemo(()=>_.filter(e=>S.includes(e.value)),[_,S]),P=e=>{j(e),e?w?.():(k(""),N?.())},M=(e,t)=>{t.preventDefault(),t.stopPropagation(),n&&n(a?S.filter(t=>t!==e):"")},I=b?E.slice(0,b):E,D=b&&E.length>b?E.length-b:0;return e.jsxs("div",{className:Te("space-y-2",x),children:[c&&e.jsxs(De,{children:[c,f&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(Wt,{open:y,onOpenChange:P,modal:!1,children:[e.jsx(Gt,{asChild:!0,children:a?e.jsxs("div",{role:"combobox","aria-expanded":y,"aria-disabled":h,tabIndex:h?-1:0,onKeyDown:e=>{h||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),P(!y))},className:Te("flex w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","min-h-10 h-auto cursor-pointer",h&&"pointer-events-none opacity-50 cursor-not-allowed",0===E.length&&"text-muted-foreground"),children:[0===E.length?e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),d]}):e.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[I.map(t=>e.jsxs(yt,{variant:"secondary",className:"gap-1 pr-1",children:[t.label,e.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:e=>{"Enter"===e.key&&M(t.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>M(t.value,e),children:e.jsx(l.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},t.value)),D>0&&e.jsxs(yt,{variant:"outline",className:"gap-1",children:["+",D]})]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):e.jsxs(Ee,{variant:"outline",role:"combobox","aria-expanded":y,disabled:h,className:Te("w-full justify-between min-h-10 h-auto",0===E.length&&"text-muted-foreground"),children:[0===E.length?e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),d]}):e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),E[0]?.label]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Yt,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:T,collisionBoundary:T,children:e.jsxs(Qt,{children:[e.jsx(Kt,{placeholder:p,value:C,onChange:e=>k(e.target.value)}),e.jsx(Xt,{children:0===s.length?e.jsx(Zt,{children:m}):0===A.length?e.jsx(Zt,{children:"Nenhum resultado encontrado"}):e.jsx(Jt,{children:A.map(t=>e.jsxs(ta,{value:t.value,onSelect:()=>(e=>{if(n)if(a){const t=S.includes(e)?S.filter(t=>t!==e):[...S,e];n(t)}else n(e),j(!1)})(t.value),className:"cursor-pointer",children:[e.jsx(l.Check,{className:Te("mr-2 h-4 w-4",S.includes(t.value)?"opacity-100":"opacity-0")}),t.label]},t.value))})})]})})]})]})}function oa({multiple:t=!1,options:a,items:s,value:r,onChange:n,onValueChange:o,getOptionValue:i=e=>e.value,getOptionLabel:d=e=>e.label,placeholder:c,label:u,icon:m,emptyMessage:p,searchPlaceholder:h,disabled:f=!1,required:x=!1,isLoading:g=!1,error:b,className:v,sortOptions:w=!0,maxDisplayedBadges:N,popoverContainer:y,onOpen:j,onClose:C}){const k=s||a||[],S=o||n,T=c||"Selecione...",_=p||"Nenhum resultado encontrado",A=h||"Pesquisar...";if(g)return e.jsxs("div",{className:Te("space-y-2",v),children:[u&&e.jsxs(De,{children:[u,x&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(sa,{className:"h-10 w-full"})]});const E="string"==typeof b?b:b instanceof Error?b.message:b?"Erro ao carregar dados":void 0;return E?e.jsxs("div",{className:Te("space-y-2",v),children:[u&&e.jsxs(De,{children:[u,x&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[e.jsx(l.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:E})]})]}):e.jsx(na,{multiple:t,options:k,value:r||(t?[]:""),onChange:S,getOptionValue:i,getOptionLabel:d,placeholder:T,label:u,icon:m,emptyMessage:_,searchPlaceholder:A,disabled:f,required:x,className:v,sortOptions:w,maxDisplayedBadges:N,popoverContainer:y,onOpen:j,onClose:C})}var ia=Object.defineProperty;class la{static normalizeBase64Url(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const a=(4-t.length%4)%4;return t+="=".repeat(a),t}static parseJwtPayload(e){try{const r=e.split(".");if(3!==r.length)return null;const n=r[1];n.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(n),t=atob(e),a=new Uint8Array(t.length);for(let r=0;r<t.length;r++)a[r]=t.charCodeAt(r);const s=new TextDecoder("utf-8").decode(a);return JSON.parse(s)}catch(t){try{const e=this.normalizeBase64Url(n),t=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(t)}catch(a){try{const e=this.normalizeBase64Url(n),t=atob(e);return JSON.parse(t)}catch(s){throw s}}}}catch(r){return null}}static validateTokens(e,t){const a=[],s=[];try{t.split(".")[1],e.split(".")[1];const r=this.parseJwtPayload(t),n=this.parseJwtPayload(e);if(!r){const e="ID token decode falhou - possível problema com base64url encoding";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:s}}let o=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";a.push(e),o=!1}const i=Math.floor(Date.now()/1e3);if(n?.exp&&n.exp<i){const e="Access token expirado - pode precisar de refresh";a.push(e),o=!1}if(r.exp&&r.exp<i){const e="ID token expirado - autenticação inválida";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:o,warnings:a,errors:s}}return{isValid:!0,idTokenValid:!0,accessTokenValid:o,warnings:a,errors:s}}catch(r){const e=`Erro na validação de tokens: ${r}`;return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:s}}}static isTokenExpired(e){const t=this.parseJwtPayload(e);return!t||!t.exp||1e3*t.exp<Date.now()}static extractTokenData(e){return this.parseJwtPayload(e)}}((e,t,a)=>{((e,t,a)=>{t in e?ia(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a})(e,t+"",a)})(la,"LARGE_PAYLOAD_THRESHOLD",1e3);const da="qualiex_access_token",ca="qualiex_id_token",ua="supabase_token",ma="oauth_state",pa="oauth_nonce",ha="selected_alias",fa="manual_logout",xa={setAccessToken:e=>localStorage.setItem(da,e),getAccessToken:()=>localStorage.getItem(da),setIdToken:e=>localStorage.setItem(ca,e),getIdToken:()=>localStorage.getItem(ca),getSupabaseToken:()=>localStorage.getItem(ua),setOAuthState:e=>sessionStorage.setItem(ma,e),getOAuthState:()=>sessionStorage.getItem(ma),clearOAuthState:()=>sessionStorage.removeItem(ma),setOAuthNonce:e=>sessionStorage.setItem(pa,e),getOAuthNonce:()=>sessionStorage.getItem(pa),clearOAuthNonce:()=>sessionStorage.removeItem(pa),setSelectedAlias:e=>localStorage.setItem(ha,e),getSelectedAlias:()=>localStorage.getItem(ha),clearSelectedAlias:()=>localStorage.removeItem(ha),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!xa.getAccessToken()||!xa.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(ua,e),xa._clearValidationCache()},areAllTokensValid:()=>{const e=xa.getAccessToken(),t=xa.getIdToken();if(!e||!t)return!1;try{const a=la.validateTokens(e,t);return!!a.idTokenValid&&a.idTokenValid}catch(a){return!1}},clearExpiredTokens:()=>{let e=!1;const t=xa.getAccessToken(),a=xa.getIdToken(),s=xa.getSupabaseToken();return t&&xa.isTokenExpired(t)&&(localStorage.removeItem(da),e=!0),a&&xa.isTokenExpired(a)&&(localStorage.removeItem(ca),e=!0),s&&xa.isTokenExpired(s)&&(localStorage.removeItem(ua),e=!0),e},clearAll:()=>{localStorage.removeItem(da),localStorage.removeItem(ca),localStorage.removeItem(ua),localStorage.removeItem(ha),localStorage.removeItem(fa),sessionStorage.removeItem(ma),sessionStorage.removeItem(pa)},setManualLogout:()=>localStorage.setItem(fa,"true"),isManualLogout:()=>"true"===localStorage.getItem(fa),clearManualLogout:()=>localStorage.removeItem(fa),isTokenExpired:e=>{try{return la.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{xa._validationCache.isValid=!1,xa._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=xa.getSupabaseToken();if(!e)return!1;if(xa.isTokenExpired(e))return xa._clearValidationCache(),xa._handleExpiredToken(),!1;const t=Date.now();return t-xa._validationCache.timestamp<xa._validationCache.cacheValidityMs?xa._validationCache.isValid:(xa._validationCache.isValid=!0,xa._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>xa.isSupabaseTokenValid()?xa.getSupabaseToken():null,_handleExpiredToken:()=>{xa.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!xa.isSupabaseTokenValid())return null;const e=xa.getSupabaseToken();if(!e)return null;try{const t=la.parseJwtPayload(e);if(!t)return null;const a=t.alias||t.default||t.user_alias,s=t.place_id||null,r=t.place_name||null;let n=t.company_id;if(!n&&a)for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=t[e];if(s&&"string"==typeof s){const e=s.split(";");if(e.length>7&&e[0]===a){n=e[7];break}}}return{alias:a,companyId:n,placeId:s,placeName:r,payload:t}}catch(t){return xa._handleExpiredToken(),null}},getCompanyId:e=>{const t=xa.getAccessToken();if(t)try{const a=la.parseJwtPayload(t);if(a)for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const s=a[t];if(s&&"string"==typeof s){const t=s.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(r){}const a=xa.extractTokenData();if(a?.companyId)return a.companyId;const s=xa.getIdToken();if(s)try{const t=la.parseJwtPayload(s);if(t)for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const s=t[a];if(s&&"string"==typeof s){const t=s.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(r){}return null},getCurrentCompanyId:()=>{const e=xa.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=xa.getIdToken();if(!e)return[];try{const t=la.parseJwtPayload(e);if(!t)return[];const a=[];for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=t[e];if(s&&"string"==typeof s){const e=s.split(";");e.length>=4&&a.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:t})}}return a}catch{return[]}}};var ga=Object.defineProperty,ba=(e,t,a)=>((e,t,a)=>t in e?ga(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const va=new class{constructor(){ba(this,"errors",[]),ba(this,"toastCount",0),ba(this,"lastToastTime",0)}handleError(e,t=!0){const a="string"==typeof e?e:e.message;if(this.errors.push({id:Date.now().toString(),message:a,timestamp:Date.now(),count:1}),t&&this.shouldShowToast()){const e=this.getErrorTitle(a);i.toast.error(e,{description:a})}}getErrorTitle(e){const t=e.toLowerCase();return t.includes("401")||t.includes("unauthorized")||t.includes("expirou")?"Sessão Expirada":t.includes("token")||t.includes("autenticação")?"Erro de Autenticação":t.includes("api")||t.includes("network")?"Erro de Conexão":"Erro"}success(e,t){i.toast.success(e,{description:t})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}};var wa=Object.defineProperty,Na=(e,t,a)=>((e,t,a)=>t in e?wa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const ya=(void 0).VITE_SUPABASE_URL,ja=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY,Ca=class e{constructor(){Na(this,"client"),Na(this,"currentToken",null),Na(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:ja};e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`);return b.createClient(ya,ja,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:t,fetch:async(e,t)=>("string"==typeof e?e:e.url).includes("/auth/v1/user")?new Response(JSON.stringify({error:"blocked"}),{status:401,headers:{"Content-Type":"application/json"}}):fetch(e,t)}})}static getInstance(){return e.instance||(e.instance=new e),e.instance}getClient(){const e=xa.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{const t=JSON.parse(atob(e.split(".")[1])),a=Math.floor(Date.now()/1e3);return t.exp>a}catch(t){return va.handleError(t instanceof Error?t:"❌ Supabase - Error validating token",!1),!1}}};Na(Ca,"instance");let ka=Ca;function Sa(){return ka.getInstance().getClient()}class Ta{static async generateToken(e,t,a,s=!1){try{if(!s){const e=xa.getSupabaseToken();if(e&&xa.isSupabaseTokenValid())return e}const r=Sa(),{data:n,error:o}=await r.functions.invoke("validate-token",{body:{access_token:e,alias:t}});return o&&(o.message?.includes("401")||o.message?.includes("Unauthorized"))?(a?.(),null):n?.access_token&&n.access_token?(xa.setSupabaseToken(n.access_token),n.access_token):null}catch(r){return r instanceof Error&&(r.message.includes("401")||r.message.includes("Unauthorized"))&&a?.(),null}}}var _a=Object.defineProperty,Aa=(e,t,a)=>((e,t,a)=>t in e?_a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);class Ea{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=xa.getAccessToken(),t=xa.getSelectedAlias();if(!e||!t)return null;const a=await Ta.generateToken(e,t,this.onLogoutCallback||void 0,!1);return a?(xa.setSupabaseToken(a),a):null}catch(e){return null}finally{this.isRegenerating=!1}}}Aa(Ea,"isRegenerating",!1),Aa(Ea,"onLogoutCallback",null);class Pa{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&(xa.clearAll(),window.location.href="/",!0)}static isAuthenticationError(e,t){if(401===e.status||401===e.statusCode)return!0;const a=t.toLowerCase();return["401","unauthorized","token","expired","invalid","authentication","login","session"].some(e=>a.includes(e))}static async wrapAsync(e){try{return await e}catch(t){if(!this.handleError(t))throw t;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}var Ma=Object.defineProperty;class Ia{static async handleApiError(e){if(!e||this.isRetrying)return!1;const t=e.status||e.statusCode,a=e.message||e.toString();if(401===t||a.includes("401")||a.includes("Unauthorized")){this.isRetrying=!0;try{return await Ea.attemptRegeneration()?(this.isRetrying=!1,!0):(Pa.handleError(e),this.isRetrying=!1,!1)}catch(s){return Pa.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=xa.getAccessToken();return e?xa.isTokenExpired(e)?{valid:!1,message:"Sua sessão expirou. Você será redirecionado para fazer login."}:{valid:!0}:{valid:!1,message:"Token OAuth não encontrado. Faça login novamente."}}}((e,t,a)=>{((e,t,a)=>{t in e?Ma(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a})(e,t+"",a)})(Ia,"isRetrying",!1);var Da=Object.defineProperty,Ra=(e,t,a)=>((e,t,a)=>t in e?Da(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);const La=new class{constructor(){Ra(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,t,a){const s=Ia.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=xa.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!a||""===a.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const n=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{n.searchParams.append(e,t)});const o=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!o.ok){const e=new Error(`API call failed: ${o.status} ${o.statusText}`);throw e.status=o.status,e.statusCode=o.status,e}return await o.json()}mapToQualiexUser(e){return{id:e.id||e.ID||"",userId:e.userId||String(e.ID),userName:e.userName||"Nome não disponível",userEmail:e.userEmail||"Email não disponível",placeId:null,placeName:e.placeName||null,roleId:e.roleId||void 0,roleName:e.roleName||void 0,companyId:e.companyId||void 0,companyName:e.companyName||void 0}}async fetchUsers(e,t){try{const a=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"active"},e);let s=a;if(a.data)s=a.data;else{if(!Array.isArray(a))return va.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];s=a}if(!Array.isArray(s))return va.handleError("[QualiexApi] Resposta não é um array",!1),[];return s.map(this.mapToQualiexUser)}catch(a){if(await Ia.handleApiError(a))try{const a=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"active"},e);let s=a;if(a.data)s=a.data;else{if(!Array.isArray(a))return va.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];s=a}return Array.isArray(s)?s.map(this.mapToQualiexUser):(va.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(s){return va.handleError(s instanceof Error?s:"Erro ao buscar usuários após renovação de token",!0),[]}const r=a instanceof Error?a.message:"Erro ao buscar usuários da API Qualiex";return va.handleError(r,!0),[]}}async fetchUserById(e,t,a){try{return(await this.fetchUsers(t,a)).find(t=>t.userId===e)||null}catch(s){return va.handleError(s instanceof Error?s:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,t){const a=await this.fetchUsers(e,t),s=new Map;return a.forEach(e=>{s.set(e.userId,e)}),s}async getUsers(e){const t=xa.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId):[]}async getAllUsers(e){return this.getUsers(e)}},za={oauth:{authUrl:(void 0).VITE_OAUTH_AUTH_URL,clientId:(void 0).VITE_OAUTH_CLIENT_ID,responseType:"id_token token",scope:"openid profile email"}},Fa={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Ua={debounceDelay:500},qa=()=>{const e=window.location.origin;return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("id-preview")||e.includes("lovable.dev")||(void 0).DEV},Oa={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},Ba=()=>Oa,Ha={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},$a={success:{created:e=>`${e} criado com sucesso`,updated:e=>`${e} atualizado com sucesso`,deleted:e=>`${e} removido com sucesso`},error:{create:e=>`Erro ao criar ${e}`,update:e=>`Erro ao atualizar ${e}`,delete:e=>`Erro ao remover ${e}`,load:e=>`Erro ao carregar ${e}`}};function Va(e,t){const a=Ba(),s=t||a.userNameFieldSuffix||"_name";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function Wa(e,t){const a=Ba(),s=t||a.userEmailFieldSuffix||"_email";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function Ga(e,t){const a=Ba(),s=t||a.userUsernameFieldSuffix||"_username";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function Ya(e,t){return t&&t.length>0?t.map(e=>({idField:e.idField,nameField:e.nameField||Va(e.idField),emailField:e.emailField||Wa(e.idField),usernameField:e.usernameField||Ga(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:Va(e),emailField:Wa(e),usernameField:Ga(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const Qa=new Map;class Ka{static async fetchQualiexUsers(e,t){const a=`${t}_${e}`,s=Qa.get(a);if(s&&Date.now()-s.timestamp<3e5)return s.users;const r=await La.fetchUsers(e,t);return Qa.set(a,{users:r,timestamp:Date.now()}),r}static extractUserIds(e,t){const a=new Set;for(const s of e)for(const e of t){const t=s[e.idField];t&&"string"==typeof t&&""!==t.trim()&&a.add(t)}return a}static indexUsers(e){const t=new Map;for(const a of e)a.id&&t.set(a.id,a),a.userId&&t.set(a.userId,a);return t}static enrichEntity(e,t,a){const s={...e};for(const r of t){const t=e[r.idField];if(!t)continue;const n=a.get(t);if(n){if(r.nameField){s[r.nameField]||(s[r.nameField]=n.userName||n.displayName||null)}if(r.emailField){s[r.emailField]||(s[r.emailField]=n.userEmail||null)}if(r.usernameField){s[r.usernameField]||(s[r.usernameField]=n.userName||null)}}}return s}static async enrichWithUserData(e,t){if(!Array.isArray(e)||0===e.length)return e;try{if(!xa.areAllTokensValid())return e;const a=xa.extractTokenData();if(!a)return e;const{alias:s,companyId:r}=a;if(!s||!r)return e;const n=Ya(t.userIdFields,t.userFieldsMapping);if(0===this.extractUserIds(e,n).size)return e;const o=await this.fetchQualiexUsers(s,r),i=this.indexUsers(o);return e.map(e=>this.enrichEntity(e,n,i))}catch(a){return va.handleError(a instanceof Error?a:new Error(`[QualiexEnrichment.${t.entityName}] Erro crítico`),!1),e}}static async enrichWithResponsibleNames(e,t){return this.enrichWithUserData(e,{entityName:t.entityName,userIdFields:["id_user"],userFieldsMapping:[{idField:"id_user",nameField:"responsible_name"}]})}}const Xa=["responsible_name"],Za=e=>Xa.includes(e);function Ja(e,t,a){const s="string"==typeof e?{tableName:e,searchFields:t||[],schemaName:a||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:r,searchFields:n,selectFields:o,schemaName:i,entityName:l,enableQualiexEnrichment:d=!1}=s,c=()=>{if(!xa.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return Sa().schema(i).from(r)},u=(e,t,a,s)=>{let r=c().select(o||"*",{count:"exact"});r=r.eq("is_removed",!1),Object.entries(s).forEach(([e,t])=>{void 0!==t&&""!==t&&(Array.isArray(t)?r=r.in(e,t):"object"==typeof t&&t&&"operator"in t?"not_null"===t.operator?r=r.not(e,"is",null):"is_null"===t.operator&&(r=r.is(e,null)):null!==t&&(r=r.eq(e,t)))}),r=((e,t)=>{if(t&&n.length>0){const a=n.map(e=>`${e}.ilike.%${t}%`).join(",");return e.or(a)}return e})(r,e);const i=t.includes(".");return i||Za(t)||(r=r.order(t,{ascending:"asc"===a})),{query:r,isForeignKey:i}},m=async(e,t,a,r,n)=>{const o=Ya(s.userIdFields,s.userFieldsMapping).some(e=>e.nameField===t||e.emailField===t||e.usernameField===t),i=t.includes(".");if(Za(t)||i||o){const e={search:"",sortField:void 0,sortDirection:void 0,page:1,limit:500},o=await this.getAll(e);if(!o?.data?.length)return o;const d=await Ka.enrichWithUserData(o.data,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping});let c;c=i?d.sort((e,s)=>{const r=t.split(".").reduce((e,t)=>e?.[t],e)||"",n=t.split(".").reduce((e,t)=>e?.[t],s)||"",o=String(r).localeCompare(String(n),"pt-BR");return"asc"===a?o:-o}):((e,t,a)=>[...e].sort((e,s)=>{const r=e[t]||"",n=s[t]||"",o=r.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===a?o:-o}))(d,t,a);const u=((e,t=1,a=25)=>{const s=(t-1)*a,r=s+a,n=e.slice(s,r);return{data:n,pagination:{currentPage:t,totalPages:Math.ceil(e.length/a),totalItems:n.length,totalCount:e.length,itemsPerPage:a,hasNextPage:r<e.length,hasPreviousPage:t>1}}})(c,r,n);return{data:u.data,currentPage:u.pagination.currentPage,totalPages:u.pagination.totalPages,totalItems:u.pagination.totalCount,itemsPerPage:u.pagination.itemsPerPage,hasNextPage:u.pagination.hasNextPage,hasPreviousPage:u.pagination.hasPreviousPage}}return await Ka.enrichWithUserData(e,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping})};return{async getAll(e={}){const{search:t,sortField:a,sortDirection:n,page:o,limit:i,additionalFilters:c}=(e=>{const{search:t="",sortField:a="updated_at",sortDirection:s="desc",page:r=1,limit:n=25,...o}=e;return{search:t,sortField:a,sortDirection:s,page:r,limit:n,additionalFilters:o}})(e),{query:p}=u(t,a,n,c),h=((e,t,a)=>{const s=(t-1)*a,r=s+a-1;return e.range(s,r)})(p,o,i),{data:f,error:x,count:g}=await h;if(x)throw new Error(`Error fetching ${r}: ${x.message}`);let b=((e,t,a,s)=>{const r=Math.ceil((t||0)/s);return{data:e,currentPage:a,totalPages:r,totalItems:t||0,itemsPerPage:s,hasNextPage:a<r,hasPreviousPage:a>1}})(f||[],g,o,i);if((e=>{if(!d||!l||0===e.length)return!1;const t=Ya(s.userIdFields,s.userFieldsMapping);return e.some(e=>t.some(t=>e[t.idField]))})(b.data)){const e=await m(b.data,a,n,o,i);if(!Array.isArray(e))return e;b={...b,data:e}}return b},async getById(e){const{data:t,error:a}=await c().select(o||"*").eq("id",e).maybeSingle();if(a)throw new Error(`Error fetching ${r}: ${a.message}`);return t},async create(e){const t=_e(e),a=Object.entries(t).reduce((e,[t,a])=>(void 0!==a&&(e[t]=a),e),{}),{data:s,error:n}=await c().insert(a).select().single();if(n)throw new Error(`Error creating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from create ${r} operation`);return s},async update(e,t){const a={..._e(t),updated_at:(new Date).toISOString()},{data:s,error:n}=await c().update(a).eq("id",e).select().single();if(n)throw new Error(`Error updating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from update ${r} operation`);return s},async delete(e){const t={is_removed:!0,updated_at:(new Date).toISOString()},{error:a}=await c().update(t).eq("id",e);if(a)throw new Error(`Error soft deleting ${r}: ${a.message}`)}}}const es=()=>{xa.clearManualLogout()},ts=e=>e?.placeId||null,as=e=>e?.placeName||null,ss=e=>({placeId:ts(e),placeName:as(e)}),rs=class{static async initialize(){try{if(!xa.hasAllTokens()||!xa.areAllTokensValid())return xa.clearExpiredTokens(),{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null};const t=xa.getAccessToken(),a=xa.getIdToken();es();const s=this.extractUserFromIdToken(a),r=this.extractCompaniesFromIdToken(a),n=this.extractAliasFromAccessToken(t),o=xa.extractTokenData(),i=o?.alias;let l=null;if(i&&r.some(e=>e.alias===i))l=i;else{const e=xa.getSelectedAlias(),t=e&&r.some(t=>t.alias===e);l=t?e:n||r[0]?.alias||null}!xa.isSupabaseTokenValid()&&l&&await Ea.attemptRegeneration();let d=null;if(l){const e=xa.getCompanyId(l),t=r.find(e=>e.alias===l);t&&(d={id:e||t.id,name:t.name,alias:t.alias})}let c=null,u=null;if(s?.id&&l){const t=xa.getCompanyId(l);if(t)try{const e=(await La.fetchActiveUsersMap(l,t)).get(s.id);if(e){const t=ss(e);c=t.placeId,u=t.placeName}}catch(e){}}return{isAuthenticated:!0,isLoading:!1,user:s,alias:l,companies:r,selectedUnit:d,userId:s?.id||null,userAlias:s?.id||null,placeId:c,placeName:u,activePlaceId:c,activePlaceName:u}}catch(e){return{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null}}}static async loginDev(){try{const e=Sa(),{data:t,error:a}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(a)return!1;if(!t?.access_token||!t?.id_token)return!1;const s=new URL("/callback",window.location.origin);return s.hash=`access_token=${t.access_token}&id_token=${t.id_token}&token_type=bearer`,window.location.href=s.toString(),!0}catch(e){return!1}}static loginProd(){const e=xa.generateOAuthState();xa.setOAuthState(e);const t=xa.generateOAuthNonce();xa.setOAuthNonce(t);const a=`${window.location.origin}/callback`,s=new URL(za.oauth.authUrl);s.searchParams.set("client_id",za.oauth.clientId),s.searchParams.set("response_type",za.oauth.responseType),s.searchParams.set("scope",za.oauth.scope),s.searchParams.set("redirect_uri",a),s.searchParams.set("state",e),s.searchParams.set("nonce",t),s.searchParams.set("response_mode","fragment"),qa(),window.location.href=s.toString()}static async processCallback(){try{if(xa.hasAllTokens()){if(!xa.getValidSupabaseToken()){xa.getAccessToken();await Ea.attemptRegeneration()}return!0}const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),t=new URLSearchParams(window.location.search),a=a=>e.get(a)||t.get(a),s=a("access_token"),r=a("id_token"),n=a("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(!s||!r)throw new Error("Tokens não encontrados na URL de callback");xa.setAccessToken(s),xa.setIdToken(r),es();const o=this.extractAliasFromAccessToken(s);if(o)xa.setSelectedAlias(o);else{const e=this.extractCompaniesFromIdToken(r);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");xa.setSelectedAlias(e[0].alias)}if(!await Ea.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return xa.clearOAuthState(),xa.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){xa.setManualLogout(),xa.clearAll(),localStorage.removeItem("auth_return_url"),window.location.href="/login"}static decodeToken(e){return la.parseJwtPayload(e)}static extractUserFromIdToken(e){const t=this.decodeToken(e);return t?{id:t.subNewId,email:t.email,name:t.name,identifier:t.identifier}:null}static extractCompaniesFromIdToken(e){const t=this.decodeToken(e);if(!t)return[];const a=[];return Object.keys(t).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof t[e]){const s=t[e].split(";");if(s.length>=4)a.push({id:s.length>7?s[7].trim():"",alias:s[0].trim(),name:s[3].trim()});else{const[s,r]=t[e].split("|");s&&r&&a.push({id:"",alias:s.trim(),name:r.trim()})}}}),a}static extractAliasFromAccessToken(e){const t=this.decodeToken(e);return t?.default||null}};Ea.setLogoutCallback(()=>{rs.logout()});let ns=rs;const os=t.createContext(void 0),is=({children:a})=>{const[s,r]=t.useState({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let n=null;try{n=v.useQueryClient()}catch{}const[o,i]=t.useState(!1),[l,d]=t.useState(0),c=t.useCallback(e=>{r(t=>({...t,...e}))},[]),u=t.useCallback(e=>{r(t=>({...t,isLoading:e}))},[]),m=t.useCallback(()=>{r({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),p=t.useCallback(async e=>{try{u(!0);const a=xa.getAccessToken();if(!a)return;const r=await Ta.generateToken(a,e.alias,void 0,!0);if(!r)return;xa.setSupabaseToken(r),xa.setSelectedAlias(e.alias);const o=xa.extractTokenData(),i=o?.alias||e.alias,l=o?.companyId||xa.getCompanyId(e.alias),d={id:l||e.id,name:e.name,alias:i};let m=null,p=null;if(s.user?.id&&i&&l)try{const e=(await La.fetchActiveUsersMap(i,l)).get(s.user.id);if(e){const t=ss(e);m=t.placeId,p=t.placeName}}catch(t){}c({alias:i,selectedUnit:d,placeId:m,placeName:p,activePlaceId:m,activePlaceName:p}),n&&(await n.clear(),await new Promise(e=>setTimeout(e,100)))}catch(t){}finally{u(!1)}},[c,n,u,s.user]),h=t.useCallback(async()=>await ns.processCallback(),[]),f=t.useCallback(async()=>{ns.logout(),m(),n&&await n.clear()},[m,n]),x=t.useCallback(e=>{i(e)},[]),g=t.useCallback(()=>{d(e=>e+1)},[]),b=t.useCallback(()=>{d(e=>e+1)},[]);t.useEffect(()=>{if(!s.isAuthenticated)return;let e=!0;const t=setInterval(()=>{e&&(xa.areAllTokensValid()||e&&f())},6e5);return()=>{e=!1,clearInterval(t)}},[s.isAuthenticated,f]),t.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const t=await ns.initialize();if(!e)return;t&&t.isAuthenticated?c({user:t.user,companies:t.companies,alias:t.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:t.selectedUnit,userId:t.userId,userAlias:t.userAlias,placeId:t.placeId,placeName:t.placeName,activePlaceId:t.activePlaceId,activePlaceName:t.activePlaceName}):e&&u(!1)}catch(t){e&&(Pa.handleError(t),u(!1))}})(),()=>{e=!1}},[c,u,f]);const w=t.useMemo(()=>({...s,logout:f,processCallback:h,switchUnit:p,availableUnits:s.companies,isSearchVisible:o,setSearchVisible:x,clearSearch:g,refreshData:b}),[s.user,s.companies,s.alias,s.isAuthenticated,s.isLoading,s.selectedUnit,s.userId,s.userAlias,s.placeId,s.placeName,s.activePlaceId,s.activePlaceName,f,h,p,o,x,g,b]);return e.jsx(os.Provider,{value:w,children:a})},ls=()=>{const e=t.useContext(os);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function ds({queryKey:e,service:a,entityName:s,searchFields:r,additionalFilters:n={},onSuccess:o}){const[l,d]=w.useSearchParams(),c=v.useQueryClient(),{alias:u,userId:m,isAuthenticated:p}=ls(),h=t.useCallback(t=>{const a=`${e}_${t}`,s=l.get(a);return s||(l.get(t)||"")},[l,e]),f=h("search"),x=h("sortField")||Fa.sorting.defaultField,g=h("sortDirection")||Fa.sorting.defaultDirection,b=parseInt(h("page")||"1"),N=parseInt(h("limit")||String(Fa.pagination.defaultPageSize)),y=f,j=t.useMemo(()=>({search:y,sortField:x,sortDirection:g,page:b,limit:N,...n}),[y,x,g,b,N,n]),C=t.useCallback(()=>a.getAll(j),[a,j]),k=v.useQuery({queryKey:[e,u,m,j],queryFn:C,enabled:!!u&&p});if(!k)throw new Error(`useCrud: Query initialization failed for "${s}". Ensure QueryClientProvider is configured in your app root.`);const S=v.useMutation({mutationFn:a.create,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),i.toast.success($a.success.created(s)),o?.()},onError:e=>{i.toast.error(`${$a.error.create(s)}: ${e.message}`)}}),T=v.useMutation({mutationFn:({id:e,data:t})=>a.update(e,t),onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),i.toast.success($a.success.updated(s)),o?.()},onError:e=>{i.toast.error(`${$a.error.update(s)}: ${e.message}`)}}),_=v.useMutation({mutationFn:a.delete,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),i.toast.success($a.success.deleted(s))},onError:e=>{i.toast.error(`${$a.error.delete(s)}: ${e.message}`)}}),A=t.useCallback(t=>{const a={...Object.fromEntries(l)};Object.entries(t).forEach(([t,s])=>{const r=`${e}_${t}`;""===s||0===s?delete a[r]:a[r]=String(s)}),delete a.sortField,delete a.sortDirection,d(a)},[l,d,e]),E=t.useCallback(e=>{A({search:e,page:1})},[A]),P=t.useCallback(e=>{A({sortField:e,sortDirection:x===e&&"asc"===g?"desc":"asc",page:1})},[x,g,A]),M=t.useCallback(e=>{A({page:e})},[A]),I=t.useCallback(e=>{A({limit:e,page:1})},[A]),D=t.useCallback(()=>{const t=Object.fromEntries(l),a=`${e}_`,s=Object.fromEntries(Object.entries(t).filter(([e])=>!e.startsWith(a)));d(s)},[d,l,e]),[R,L]=t.useState([]),z=t.useCallback(e=>{L(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),F=t.useCallback(()=>{const e=k?.data?.data.map(e=>e.id)||[];L(t=>t.length===e.length?[]:e)},[k?.data?.data]),U=t.useCallback(()=>{L([])},[]),q=t.useMemo(()=>{const e=k?.data?.data.map(e=>e.id)||[];return e.length>0&&R.length===e.length},[R,k?.data?.data]),O=v.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>a.delete(e)))},onSuccess:(t,a)=>{c.invalidateQueries({queryKey:[e]}),i.toast.success(`${a.length} ${s}(s) deletado(s) com sucesso`),U()},onError:e=>{i.toast.error(`Erro ao deletar itens: ${e.message}`)}}),B=t.useCallback((e,t)=>{const a=t?t(e):e;e.id?T.mutate({id:e.id,data:a}):S.mutate({...a,alias:u})},[u,S,T]);return{entities:k?.data?.data||[],pagination:{data:k?.data?.data||[],currentPage:k?.data?.currentPage||1,totalPages:k?.data?.totalPages||1,totalItems:k?.data?.totalItems||0,itemsPerPage:k?.data?.itemsPerPage||Fa.pagination.defaultPageSize,hasNextPage:k?.data?.hasNextPage||!1,hasPreviousPage:k?.data?.hasPreviousPage||!1},isLoading:k?.isLoading??!0,isCreating:S?.isPending??!1,isUpdating:T?.isPending??!1,isDeleting:_?.isPending??!1,error:k?.error||null,searchTerm:f,sortField:x,sortDirection:g,currentPage:b,itemsPerPage:N,queryKey:e,createEntity:S.mutate,updateEntity:(e,t)=>T.mutate({id:e,data:t}),deleteEntity:_.mutate,save:B,handleSearch:E,handleSort:P,handlePageChange:M,handleItemsPerPageChange:I,clearFilters:D,refetch:k.refetch,selectedIds:R,selectItem:z,selectAll:F,clearSelection:U,isAllSelected:q,bulkDelete:e=>O.mutateAsync(e),isBulkDeleting:O.isPending}}const cs=J.forwardRef(({className:t,...a},s)=>e.jsx("table",{ref:s,className:Te("w-full caption-bottom text-sm table-fixed",t),...a}));cs.displayName="Table";const us=J.forwardRef(({className:t,...a},s)=>e.jsx("thead",{ref:s,className:Te("[&_tr]:border-b sticky top-0 z-[1] bg-background",t),...a}));us.displayName="TableHeader";const ms=J.forwardRef(({className:t,...a},s)=>e.jsx("tbody",{ref:s,className:Te("[&_tr:last-child]:border-0",t),...a}));ms.displayName="TableBody";const ps=J.forwardRef(({className:t,...a},s)=>e.jsx("tfoot",{ref:s,className:Te("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...a}));ps.displayName="TableFooter";const hs=J.forwardRef(({className:t,...a},s)=>e.jsx("tr",{ref:s,className:Te("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",t),...a}));hs.displayName="TableRow";const fs=J.forwardRef(({className:t,...a},s)=>e.jsx("th",{ref:s,className:Te("h-12 px-4 py-3 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",t),...a}));fs.displayName="TableHead";const xs=J.forwardRef(({className:t,...a},s)=>e.jsx("td",{ref:s,className:Te("px-4 py-3 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",t),...a}));xs.displayName="TableCell";const gs=J.forwardRef(({className:t,...a},s)=>e.jsx("caption",{ref:s,className:Te("mt-4 text-sm text-muted-foreground",t),...a}));function bs({rows:t=5,columns:a=4}){return e.jsx("div",{className:"w-full",children:e.jsxs("div",{className:"rounded-md border",children:[e.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:e.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((t,a)=>e.jsx(sa,{className:"h-4 w-24"},a))})}),e.jsx("div",{children:Array.from({length:t}).map((t,s)=>e.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:e.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((t,a)=>e.jsx(sa,{className:"h-4 w-20"},a))})},s))})]})})}function vs({count:t=3}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:t}).map((t,a)=>e.jsxs(Re,{children:[e.jsxs(Le,{children:[e.jsx(sa,{className:"h-4 w-3/4"}),e.jsx(sa,{className:"h-3 w-1/2"})]}),e.jsx(Ue,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(sa,{className:"h-3 w-full"}),e.jsx(sa,{className:"h-3 w-2/3"})]})})]},a))})}gs.displayName="TableCaption";const ws={default:l.FileX,search:l.Search,error:l.AlertCircle};function Ns({icon:t,title:a,description:s,action:r,className:n,variant:o="default"}){const i=t?()=>t:ws[o];return e.jsxs("div",{className:Te("flex flex-col items-center justify-center py-12 px-4 text-center",n),children:[e.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:e.jsx(i,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:a}),s&&e.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),r&&e.jsx(Ee,{onClick:r.onClick,variant:"outline",children:r.label})]})}function ys({children:t,className:a}){const s=J.useRef(null),[r,n]=J.useState(!1);J.useEffect(()=>{const e=()=>{const e=s.current;e&&n(e.scrollWidth>e.clientWidth)};e();const t=new ResizeObserver(e);return s.current&&t.observe(s.current),()=>t.disconnect()},[t]);const o=e.jsx("div",{ref:s,className:`truncate w-full max-w-full ${a||""}`,children:t});return r?e.jsx(Ot,{delayDuration:300,children:e.jsxs(Bt,{children:[e.jsx(Ht,{asChild:!0,children:o}),e.jsx($t,{side:"top",className:"max-w-[400px] break-words",children:t})]})}):o}const js=J.forwardRef(({direction:t,onMouseDown:a,isDragging:s,className:r},n)=>{const o="horizontal"===t;return e.jsx("div",{ref:n,onMouseDown:a,className:Te("absolute z-20 select-none touch-none","transition-colors duration-150",o&&["top-0 right-0 h-full w-2 -mr-1","cursor-col-resize","hover:bg-primary/20","group flex items-center justify-center"],!o&&["bottom-0 left-0 w-full h-2 -mb-1","cursor-row-resize","hover:bg-primary/20","group flex items-center justify-center"],s&&"bg-primary/30",r),children:e.jsx("div",{className:Te("rounded-full bg-border transition-colors group-hover:bg-primary",s&&"bg-primary",o?"h-6 w-0.5":"w-6 h-0.5")})})});js.displayName="TableResizeHandle";const Cs=le.Root,ks=le.Trigger,Ss=le.Group,Ts=le.Portal,_s=le.Sub,As=le.RadioGroup,Es=J.forwardRef(({className:t,inset:a,children:s,...r},n)=>e.jsxs(le.SubTrigger,{ref:n,className:Te("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",a&&"pl-8",t),...r,children:[s,e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Es.displayName=le.SubTrigger.displayName;const Ps=J.forwardRef(({className:t,...a},s)=>e.jsx(le.SubContent,{ref:s,className:Te("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a}));Ps.displayName=le.SubContent.displayName;const Ms=J.forwardRef(({className:t,...a},s)=>e.jsx(le.Portal,{children:e.jsx(le.Content,{ref:s,className:Te("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a})}));Ms.displayName=le.Content.displayName;const Is=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(le.Item,{ref:r,className:Te("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",t),...s}));Is.displayName=le.Item.displayName;const Ds=J.forwardRef(({className:t,children:a,checked:s,...r},n)=>e.jsxs(le.CheckboxItem,{ref:n,className:Te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(le.ItemIndicator,{children:e.jsx(l.Check,{className:"h-4 w-4"})})}),a]}));Ds.displayName=le.CheckboxItem.displayName;const Rs=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(le.RadioItem,{ref:r,className:Te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(le.ItemIndicator,{children:e.jsx(l.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));Rs.displayName=le.RadioItem.displayName;const Ls=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(le.Label,{ref:r,className:Te("px-2 py-1.5 text-sm font-semibold text-foreground",a&&"pl-8",t),...s}));Ls.displayName=le.Label.displayName;const zs=J.forwardRef(({className:t,...a},s)=>e.jsx(le.Separator,{ref:s,className:Te("-mx-1 my-1 h-px bg-border",t),...a}));zs.displayName=le.Separator.displayName;const Fs=({className:t,...a})=>e.jsx("span",{className:Te("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});Fs.displayName="ContextMenuShortcut";const Us=({onEdit:t,onDelete:a,onToggleStatus:s,isActive:r=!0,canDelete:n=!0,customActions:o=[],renderAs:i})=>{const d=[];if(t){const e={icon:l.Edit,label:"Editar",onClick:t};d.push(e)}if(o.forEach(e=>{d.push(e)}),s){const e={icon:r?l.PowerOff:l.Power,label:r?"Inativar":"Ativar",onClick:s};d.push(e)}if(n&&a){const e={icon:l.Trash2,label:"Excluir",onClick:a,destructive:!0};d.push(e)}const c="dropdown"===i?Rt:Is;return e.jsx(e.Fragment,{children:d.map((t,a)=>e.jsxs(c,{onClick:t.onClick,className:Te("whitespace-normal cursor-pointer",t.destructive&&"text-destructive focus:text-destructive"),children:[e.jsx(t.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),t.label]},a))})},qs=({onEdit:t,onDelete:a,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:o=[]})=>e.jsxs(St,{children:[e.jsx(Tt,{asChild:!0,children:e.jsx(Ee,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:e.jsx(l.EllipsisVertical,{size:12})})}),e.jsx(Dt,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:e.jsx(Us,{onEdit:t?e=>{e?.stopPropagation(),t?.()}:void 0,onDelete:a?e=>{e?.stopPropagation(),a?.()}:void 0,onToggleStatus:r?e=>{e?.stopPropagation(),r?.()}:void 0,isActive:n,canDelete:s&&!!a,customActions:o,renderAs:"dropdown"})})]}),Os=150;function Bs({columns:e,storageKey:a,onResize:s,enabled:r=!0}){const[n,o]=t.useState(()=>{if(!r||"undefined"==typeof window)return e.reduce((e,t)=>(e[t.key]=t.defaultWidth??Os,e),{});if(a){const e=localStorage.getItem(a);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,t)=>(e[t.key]=t.defaultWidth??Os,e),{})}),[i,l]=t.useState(!1),[d,c]=t.useState(null),u=t.useRef(0),m=t.useRef(0),p=t.useCallback((e,t)=>{r&&(t.preventDefault(),t.stopPropagation(),l(!0),c(e),u.current=t.clientX,m.current=n[e]??Os)},[r,n]);t.useEffect(()=>{if(!i||!d)return;const t=e.find(e=>e.key===d),r=t?.minWidth??60,n=t?.maxWidth??500,p=e=>{const t=e.clientX-u.current,a=Math.max(r,Math.min(n,m.current+t));o(e=>{const t={...e,[d]:a};return s?.(t),t})},h=()=>{l(!1),c(null),a&&o(e=>(localStorage.setItem(a,JSON.stringify(e)),e))};return document.addEventListener("mousemove",p),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",h)}},[i,d,e,a,s]),t.useEffect(()=>{i?(document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[i]);const h=t.useCallback(()=>{const t=e.reduce((e,t)=>(e[t.key]=t.defaultWidth??Os,e),{});o(t),a&&localStorage.removeItem(a),s?.(t)},[e,a,s]);return{columnWidths:n,isDragging:i,activeColumn:d,handleMouseDown:p,resetWidths:h}}function Hs({rowIds:e,defaultHeight:a=48,minHeight:s=32,maxHeight:r=120,storageKey:n,onResize:o,enabled:i=!0}){const[l,d]=t.useState(()=>{if(!i||"undefined"==typeof window)return{};if(n){const e=localStorage.getItem(n);if(e)try{return JSON.parse(e)}catch{}}return{}}),[c,u]=t.useState(!1),[m,p]=t.useState(null),h=t.useRef(0),f=t.useRef(0),x=t.useCallback(e=>l[e]??a,[l,a]),g=t.useCallback((e,t)=>{i&&(t.preventDefault(),t.stopPropagation(),u(!0),p(e),h.current=t.clientY,f.current=l[e]??a)},[i,l,a]);t.useEffect(()=>{if(!c||!m)return;const e=e=>{const t=e.clientY-h.current,a=Math.max(s,Math.min(r,f.current+t));d(e=>{const t={...e,[m]:a};return o?.(t),t})},t=()=>{u(!1),p(null),n&&d(e=>(localStorage.setItem(n,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[c,m,s,r,n,o]),t.useEffect(()=>{c?(document.body.style.cursor="row-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[c]);const b=t.useCallback(()=>{d({}),n&&localStorage.removeItem(n),o?.({})},[n,o]);return{rowHeights:l,isDragging:c,activeRow:m,handleMouseDown:g,resetHeights:b,getRowHeight:x}}const $s=s.cva("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),Vs=J.forwardRef(({className:t,variant:a,size:s,...r},n)=>e.jsx(ce.Root,{ref:n,className:Te($s({variant:a,size:s,className:t})),...r}));Vs.displayName=ce.Root.displayName;const Ws=J.createContext({size:"default",variant:"default"}),Gs=J.forwardRef(({className:t,variant:a,size:s,children:r,...n},o)=>e.jsx(de.Root,{ref:o,className:Te("flex items-center justify-center gap-1",t),...n,children:e.jsx(Ws.Provider,{value:{variant:a,size:s},children:r})}));Gs.displayName=de.Root.displayName;const Ys=J.forwardRef(({className:t,children:a,variant:s,size:r,...n},o)=>{const i=J.useContext(Ws);return e.jsx(de.Item,{ref:o,className:Te($s({variant:i.variant||s,size:i.size||r}),t),...n,children:a})});Ys.displayName=de.Item.displayName;const Qs=t.memo(function({onNew:t,newButtonLabel:a,showNewButton:s=!0,showSearch:r=!0,searchValue:n="",onSearchChange:o,searchPlaceholder:i,showBulkActions:d=!1,selectedCount:c=0,bulkActions:u=[],onBulkDelete:m,onClearSelection:p,customActions:h=[],filters:f,viewMode:x,onViewModeChange:g,showViewToggle:b=!1,availableViewModes:v=["table","list","grid"],className:w}){const N=t&&s||d||h.length>0,y=f||b,j=r&&o;return N||j||y?e.jsxs("div",{className:Te("flex-shrink-0 flex items-center px-4 py-1.5 bg-muted/50 border-b gap-4",w),children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t&&s&&e.jsxs(Ee,{onClick:t,children:[e.jsx(l.Plus,{size:16,className:"mr-2"}),a||"Novo"]}),d&&e.jsxs(St,{children:[e.jsx(Tt,{asChild:!0,children:e.jsxs(Ee,{variant:"outline",children:["Ações em lote",c>0&&e.jsx(yt,{variant:"secondary",className:"ml-2",children:c}),e.jsx(l.ChevronDown,{size:16,className:"ml-2"})]})}),e.jsxs(Dt,{align:"start",children:[u.length>0?u.map((t,a)=>{const s=t.icon,r=0===c||t.disabled;return e.jsxs(Rt,{onClick:()=>!r&&t.action([]),disabled:r,className:"destructive"===t.variant?"text-destructive":void 0,children:[s&&e.jsx(s,{size:16,className:"mr-2"}),t.label]},a)}):e.jsxs(Rt,{onClick:m,disabled:0===c,className:"text-destructive",children:[e.jsx(l.Trash2,{size:16,className:"mr-2"}),"Excluir"]}),c>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ut,{}),e.jsxs(Rt,{onClick:p,children:[e.jsx(l.X,{size:16,className:"mr-2"}),"Limpar seleção"]})]})]})]}),h.map((t,a)=>{const s=t.icon;return e.jsxs(Ee,{onClick:t.action,variant:t.variant||"outline",disabled:t.disabled,title:t.disabled?t.disabledReason:void 0,children:[s&&e.jsx(s,{size:16,className:"mr-2"}),t.label]},a)})]}),j&&e.jsx("div",{className:"flex-1 flex justify-center max-w-md mx-auto",children:e.jsxs("div",{className:"relative w-full",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Me,{type:"text",placeholder:i||"Pesquisar",value:n,onChange:e=>o?.(e.target.value),className:"pl-9 w-full"})]})}),y&&e.jsxs("div",{className:"flex items-center gap-2 shrink-0 ml-auto",children:[f,b&&x&&g&&e.jsx(Gs,{type:"single",value:x,onValueChange:e=>e&&g(e),size:"sm",children:v.map(t=>{const a=(e=>{switch(e){case"table":return l.Table2;case"list":return l.List;case"grid":return l.LayoutGrid}})(t);return e.jsx(Ys,{value:t,"aria-label":"Visualizar como "+("table"===t?"tabela":"list"===t?"lista":"grade"),children:e.jsx(a,{className:"h-4 w-4"})},t)})})]})]}):null}),Ks=t.memo(({checked:t,onCheckedChange:a})=>e.jsx(vt,{checked:t,onCheckedChange:a}),(e,t)=>e.checked===t.checked),Xs=({manager:a,columns:s,onEdit:r,onView:n,onToggleStatus:o,onDelete:i,renderActions:d,customRowActions:c,enableBulkActions:u=!1,onNew:m,newButtonLabel:p,showNewButton:h=!0,customActions:f=[],hideActionBar:x,showActionBar:g=!0,showSearch:b=!1,searchValue:v,onSearchChange:w,searchPlaceholder:N,bulkActions:y=[],onBulkDelete:j,filters:C,viewMode:k,onViewModeChange:S,showViewToggle:T=!1,enableColumnResize:_=!0,resizeStorageKey:A})=>{const{setSearchVisible:E}=ls(),[P,M]=t.useState(!1),I=void 0!==x?!x:g;t.useEffect(()=>{if(!b)return E(!0),()=>E(!1)},[E,b]),t.useEffect(()=>{const e=()=>M(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const{columnWidths:D,isDragging:R,activeColumn:L,handleMouseDown:z}=Bs({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:A?`${A}-columns`:void 0,enabled:_}),{isDragging:F,activeRow:U,handleMouseDown:q,getRowHeight:O}=Hs({rowIds:a.entities.map(e=>e.id),storageKey:A?`${A}-rows`:void 0,enabled:!1}),B=t.useMemo(()=>(()=>{if(_)return s.map(e=>{const t=D[String(e.key)]??e.width??e.minWidth??150;return{...e,calculatedWidth:t,style:{width:`${t}px`}}});let e=0;const t=s.map(t=>{if(t.width)return e+=t.width,{...t,calculatedWidth:t.width,isFixed:!0};{const a=t.minWidth||120,s=t.weight||1;return e+=a,{...t,calculatedWidth:a,weight:s,isFixed:!1}}});return e+=50,t.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})(),[s,_,D]),H=m||f.length>0||b||u||C||T,$=I&&H,V=j||(()=>{a.bulkDelete?.(a.selectedIds)});return P?a.isLoading?e.jsx(vs,{count:3}):0===a.entities.length?e.jsx(Ns,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"}):e.jsxs("div",{className:"flex flex-col h-full",children:[$&&e.jsx(Qs,{onNew:m,newButtonLabel:p,showNewButton:h,showSearch:b,searchValue:v,onSearchChange:w,searchPlaceholder:N,showBulkActions:u,selectedCount:a.selectedIds.length,bulkActions:y,onBulkDelete:V,onClearSelection:a.clearSelection,customActions:f,filters:C,viewMode:k,onViewModeChange:S,showViewToggle:T}),e.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:a.entities.map(t=>e.jsxs(Cs,{children:[e.jsx(ks,{asChild:!0,children:e.jsx(Re,{className:Te("overflow-hidden cursor-pointer hover:bg-muted/50",u&&a.selectedIds.includes(t.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),u?a.selectItem(t.id):r?.(t)},children:e.jsx(Ue,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[u&&e.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e.jsx(Ks,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),e.jsxs("div",{className:"flex-1",children:[s.map(a=>e.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[a.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:a.render?a.render(t):String(t[a.key]??"")})]},String(a.key))),(r||n||d)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:d?d(t):e.jsx(qs,{onEdit:r?()=>{r(t)}:void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:c?c(t):[]})})]})]})})})}),e.jsx(Ms,{className:"w-[160px]",children:e.jsx(Us,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,canDelete:!!i,customActions:c?c(t):[],renderAs:"context"})})]},t.id))})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[$&&e.jsx(Qs,{onNew:m,newButtonLabel:p,showNewButton:h,showSearch:b,searchValue:v,onSearchChange:w,searchPlaceholder:N,showBulkActions:u,selectedCount:a.selectedIds.length,bulkActions:y,onBulkDelete:V,onClearSelection:a.clearSelection,customActions:f,filters:C,viewMode:k,onViewModeChange:S,showViewToggle:T}),a.isLoading?e.jsx(bs,{rows:5,columns:s.length}):e.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs(cs,{className:"table-auto",children:[e.jsxs("colgroup",{children:[u&&e.jsx("col",{style:{width:"50px"}}),B.map((t,a)=>e.jsx("col",{style:t.style},a)),e.jsx("col",{style:{width:"50px"}})]}),e.jsx(us,{children:e.jsxs(hs,{children:[u&&e.jsx(fs,{className:"w-[50px]",children:e.jsx(Ks,{checked:a.isAllSelected,onCheckedChange:a.selectAll})}),s.map(t=>{const s=_&&!1!==t.resizable,r=L===String(t.key);return e.jsxs(fs,{className:Te(t.className,t.sortable&&"cursor-pointer hover:bg-muted/50","relative"),onClick:t.sortable?()=>a.handleSort(String(t.key)):void 0,children:[e.jsxs("div",{className:"flex items-center "+(t.className?.includes("text-center")?"justify-center":""),children:[t.header,t.sortable&&(n=String(t.key),a.sortField!==n?e.jsx(l.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===a.sortDirection?e.jsx(l.ArrowUp,{size:14,className:"ml-1"}):e.jsx(l.ArrowDown,{size:14,className:"ml-1"}))]}),s&&e.jsx(js,{direction:"horizontal",onMouseDown:e=>z(String(t.key),e),isDragging:r})]},String(t.key));var n}),e.jsx(fs,{className:"w-[50px] text-center",children:"Ações"})]})}),e.jsx(ms,{children:0===a.entities.length?e.jsx(hs,{children:e.jsx(xs,{colSpan:u?s.length+2:s.length+1,className:"h-32",children:e.jsx(Ns,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})}):a.entities.map(t=>{const n=O(t.id);return t.id,e.jsxs(Cs,{children:[e.jsx(ks,{asChild:!0,children:e.jsxs(hs,{className:Te("cursor-pointer hover:bg-muted/50 relative",u&&a.selectedIds.includes(t.id)&&"bg-muted"),style:n?{height:`${n}px`}:void 0,onClick:e=>{e.stopPropagation(),u?a.selectItem(t.id):r?.(t)},children:[u&&e.jsx(xs,{onClick:e=>e.stopPropagation(),children:e.jsx(Ks,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),s.map(a=>e.jsx(xs,{className:a.className,children:e.jsx(ys,{children:a.render?a.render(t):String(t[a.key]??"")})},String(a.key))),e.jsx(xs,{className:"text-center",children:d?d(t):e.jsx(qs,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:c?c(t):[]})})]})}),e.jsx(Ms,{className:"w-[160px]",children:e.jsx(Us,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,canDelete:!!i,customActions:c?c(t):[],renderAs:"context"})})]},t.id)})})]})})})]})};function Zs(e,a,s,r){const[n,o]=t.useState({}),[i,l]=t.useState({}),d=t.useMemo(()=>e,[e]),c=e=>e instanceof Date&&!isNaN(e.getTime()),u=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},m=(e,t)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(t)}catch(a){return u(e)}},p=(e,t,a)=>{if(e.required&&(""===t||null==t||Array.isArray(t)&&0===t.length))return`${e.label} é obrigatório`;if(e.validation){let r;if("function"==typeof e.validation?r=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(r=e.validation.custom),r)try{const e=r(t,a);if(e)return e}catch(s){}}};t.useEffect(()=>{if(!r)return;const e=t=>{const a=[];return t.forEach(t=>{a.push(t),t.fields&&a.push(...e(t.fields))}),a},t=e(d),n={};t.forEach(e=>{let t;if(a&&void 0!==a[e.name]){if(t=a[e.name],null==t&&(t=""),"date"===e.type&&t)if("string"==typeof t){const e=new Date(t);c(e)&&(t=e.toISOString().split("T")[0])}else c(t)&&(t=t.toISOString().split("T")[0])}else t=u(e);n[e.name]=t}),t.forEach(e=>{const t=m(e,n);void 0!==t&&(n[e.name]=t)}),a&&Object.keys(a).forEach(e=>{t.find(t=>t.name===e)||void 0===a[e]||(n[e]=a[e])}),o(n),l({}),s&&s(n)},[d,a,s,r]);const h=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...h(e.fields))}),t},f=()=>{const e=h(d),t={};return e.forEach(e=>{const a=p(e,n[e.name],n);a&&(t[e.name]=a)}),l(t),0===Object.keys(t).length};return{formData:n,errors:i,updateField:(e,t)=>{o(a=>{const r={...a,[e]:t},n=((e,t)=>{let a={...t};const s=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...s(e.fields))}),t};return s(d).filter(t=>t.dependsOn===e).forEach(e=>{const t=m(e,a);void 0!==t&&(a={...a,[e.name]:t})}),a})(e,r);return s&&s(n),n}),i[e]&&l(t=>{const a={...t};return delete a[e],a});const a=h(d).find(t=>t.name===e);if(a){const s=p(a,t,n);s&&l(t=>({...t,[e]:s}))}},validateForm:f,handleSubmit:e=>t=>{t&&(t.preventDefault(),t.stopPropagation()),f()&&e(n)}}}const Js=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],er=({value:t="#3b82f6",onChange:a,label:s})=>e.jsxs("div",{className:"space-y-2",children:[s&&e.jsx(De,{children:s}),e.jsxs(Wt,{children:[e.jsx(Gt,{asChild:!0,children:e.jsxs(Ee,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:t}}),t]})}),e.jsx(Yt,{className:"w-64",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(De,{htmlFor:"color-input",children:"Cor personalizada"}),e.jsx(Me,{id:"color-input",type:"color",value:t,onChange:e=>a?.(e.target.value),className:"h-10 w-full"})]}),e.jsxs("div",{children:[e.jsx(De,{children:"Cores predefinidas"}),e.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:Js.map(t=>e.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:t},onClick:()=>a?.(t),"aria-label":`Selecionar cor ${t}`},t))})]})]})})]})]}),tr=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(ue.Root,{ref:r,className:Te("relative overflow-hidden",t),...s,children:[e.jsx(ue.Viewport,{className:"h-full w-full rounded-[inherit]",children:a}),e.jsx(ar,{}),e.jsx(ue.Corner,{})]}));tr.displayName=ue.Root.displayName;const ar=J.forwardRef(({className:t,orientation:a="vertical",...s},r)=>e.jsx(ue.ScrollAreaScrollbar,{ref:r,orientation:a,className:Te("flex touch-none select-none transition-colors","vertical"===a&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===a&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...s,children:e.jsx(ue.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));ar.displayName=ue.ScrollAreaScrollbar.displayName;const sr={Star:l.Star,Heart:l.Heart,Home:l.Home,User:l.User,Settings:l.Settings,Mail:l.Mail,Phone:l.Phone,Calendar:l.Calendar,MapPin:l.MapPin,Camera:l.Camera,Image:l.Image,Music:l.Music,Video:l.Video,Book:l.Book,Bookmark:l.Bookmark,Search:l.Search,Filter:l.Filter,Edit:l.Edit,Trash2:l.Trash2,Plus:l.Plus,Minus:l.Minus,Check:l.Check,X:l.X,ChevronDown:l.ChevronDown,ChevronUp:l.ChevronUp,ChevronLeft:l.ChevronLeft,ChevronRight:l.ChevronRight,ArrowUp:l.ArrowUp,ArrowDown:l.ArrowDown,ArrowLeft:l.ArrowLeft,ArrowRight:l.ArrowRight,Clock:l.Clock,Bell:l.Bell,AlertCircle:l.AlertCircle,Info:l.Info,HelpCircle:l.HelpCircle,Download:l.Download,Upload:l.Upload,Share:l.Share,Copy:l.Copy,Save:l.Save,FileText:l.FileText,Folder:l.Folder,FolderOpen:l.FolderOpen,Archive:l.Archive,Lock:l.Lock,Unlock:l.Unlock,Eye:l.Eye,EyeOff:l.EyeOff,Shield:l.Shield,Key:l.Key,Zap:l.Zap,Flame:l.Flame,Sparkles:l.Sparkles,Award:l.Award,Trophy:l.Trophy,Target:l.Target},rr=({value:a="Star",onChange:s,label:r})=>{const[n,o]=t.useState(""),i=Object.entries(sr).filter(([e])=>e.toLowerCase().includes(n.toLowerCase())),d=sr[a]||l.Star;return e.jsxs("div",{className:"space-y-2",children:[r&&e.jsx(De,{children:r}),e.jsxs(Wt,{children:[e.jsx(Gt,{asChild:!0,children:e.jsxs(Ee,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx(d,{className:"h-4 w-4 mr-2"}),a]})}),e.jsx(Yt,{className:"w-80",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(De,{htmlFor:"icon-search",children:"Pesquisar"}),e.jsx(Me,{id:"icon-search",placeholder:"Pesquisar",value:n,onChange:e=>o(e.target.value)})]}),e.jsx(tr,{className:"h-48",children:e.jsx("div",{className:"grid grid-cols-6 gap-2",children:i.map(([t,r])=>e.jsx("button",{className:"p-2 rounded border-2 hover:border-primary "+(a===t?"border-primary bg-primary/10":"border-border"),onClick:()=>s?.(t),title:t,children:e.jsx(r,{className:"h-4 w-4"})},t))})})]})})]})]})},nr=J.forwardRef(({className:t,...a},s)=>e.jsx(me.Root,{className:Te("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...a,ref:s,children:e.jsx(me.Thumb,{className:Te("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));nr.displayName=me.Root.displayName;const or=(e={})=>{const{user:t,alias:a}=ls(),{enabled:s=!0}=e;return v.useQuery({queryKey:["qualiex-users",a],queryFn:()=>La.getUsers(a),enabled:s&&!!a&&!!t,retry:2,retryDelay:1e3})},ir=({value:a,onChange:s,multiple:r=!1,label:n,required:o,placeholder:i,icon:l,maxDisplayedBadges:d,className:c,disabled:u,enabled:m,displayFormat:p="name",customDisplayFn:h,filterFn:f,sortOptions:x=!0,popoverContainer:g,onOpen:b,onClose:v})=>{const{data:w=[],isLoading:N,error:y}=or({enabled:m}),j=t.useMemo(()=>f?w.filter(f):w,[w,f]),C=t.useCallback(e=>{if("custom"===p&&h)return h(e);const t=e.userName||e.displayName||"";switch(p){case"name-email":return e.userEmail?`${t} (${e.userEmail})`:t;case"name-role":return e.roleName?`${t} - ${e.roleName}`:t;default:return t}},[p,h]);return e.jsx(oa,{multiple:r,value:a??(r?[]:""),onChange:s,options:j,isLoading:N,error:y,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:C,placeholder:i||"Pesquisar...",searchPlaceholder:"Pesquisar...",emptyMessage:"Nenhum resultado encontrado",label:n,required:o,icon:l,maxDisplayedBadges:d,disabled:u,className:c,sortOptions:x,popoverContainer:g,onOpen:b,onClose:v})};function lr({title:a,sections:s,initialData:r,onSubmit:n,onCancel:o,open:i,submitButtonText:l,isLoading:d=!1,usersData:c}){const[u,m]=t.useState(s?.[0]?.id||""),p=t.useRef(null),[h,f]=t.useState(null),x=t.useCallback(e=>{p.current=e,f(e)},[]),g=t.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:b,errors:v,updateField:w,handleSubmit:N}=Zs(g,r,void 0,i),y=t.useMemo(()=>s&&Array.isArray(s)?s.map(e=>({...e,disabled:e.condition?!e.condition(b):e.disabled||!1})):[],[s,b]),j=t.useMemo(()=>{const e=y.find(e=>e.id===u);if(e&&!e.disabled)return u;const t=y.find(e=>!e.disabled);return t?.id||u},[y,u]);t.useEffect(()=>{j!==u&&m(j)},[j,u]);const C=y.find(e=>e.id===j),k=t=>{const a=(t.computedValue,b[t.name]),s=void 0!==a?a:"",r=v[t.name];switch(t.type){case"group":const a="horizontal"===t.layout,n=a?`flex gap-3 w-full ${t.className||""}`:"space-y-3",o=a?Te("space-y-2 w-full",t.wrapperClassName):Te("space-y-2",t.className,t.wrapperClassName);return e.jsxs("div",{className:o,children:[t.label,e.jsx("div",{className:n,children:t.fields?.map(e=>k(e))})]},t.name);case"user-select":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(De,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ir,{value:s||"",onChange:e=>w(t.name,e),placeholder:t.placeholder,disabled:t.disabled,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"textarea":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(De,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(wt,{id:t.name,value:s||"",onChange:e=>{w(t.name,e.target.value)},placeholder:t.placeholder,disabled:t.disabled,rows:t.rows,maxLength:t.maxLength,className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"select":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(De,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(dt,{value:String(s),onValueChange:e=>{w(t.name,e),t.onValueChange&&t.onValueChange(e)},disabled:t.disabled,children:[e.jsx(mt,{className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,children:e.jsx(ut,{placeholder:t.placeholder})}),e.jsx(ft,{children:t.options?.map(t=>e.jsx(gt,{value:t.value,children:t.label},t.value))})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"multiselect":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(De,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(oa,{options:t.options||[],value:Array.isArray(s)?s:[],onChange:e=>w(t.name,e),placeholder:t.placeholder,disabled:t.disabled,error:r,popoverContainer:h,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"date":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(De,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Me,{id:t.name,type:"date",value:String(s),onChange:e=>w(t.name,e.target.value),placeholder:t.placeholder,disabled:t.disabled,className:Te("w-full",r?"border-destructive":"",t.disabled?"bg-muted cursor-not-allowed":"")}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"color":return e.jsxs("div",{children:[e.jsxs(De,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Me,{id:t.name,type:"color",value:s||t.defaultValue||"#000000",onChange:e=>w(t.name,e.target.value),className:"h-10"}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},t.name);case"color-picker":return e.jsxs("div",{children:[e.jsxs(De,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(er,{value:s||t.defaultValue||"#3b82f6",onChange:e=>w(t.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},t.name);case"icon-picker":return e.jsxs("div",{children:[e.jsxs(De,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(rr,{value:s||t.defaultValue||"Star",onChange:e=>w(t.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},t.name);case"custom":if(!t.component)return null;const i=t.component,l="function"==typeof t.componentProps?t.componentProps(b):t.componentProps||{};return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[t.label&&e.jsxs(De,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(i,{value:s,onChange:e=>{w(t.name,e),t.onValueChange&&t.onValueChange(e)},disabled:t.disabled,error:r,popoverContainer:h,...l}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"number":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(De,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Me,{id:t.name,type:"number",value:null!=s?String(s):"",onChange:e=>{const a=e.target.value,s=""===a?null:Number(a);w(t.name,s)},placeholder:t.placeholder,disabled:t.disabled,className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,min:t.min,step:t.step||"1"}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"checkbox":return e.jsxs("div",{className:`flex items-center space-x-2 ${t.className||""}`,children:[e.jsx(vt,{id:t.name,checked:!!s,onCheckedChange:e=>w(t.name,e),disabled:t.disabled}),e.jsxs(De,{htmlFor:t.name,className:"cursor-pointer",children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"switch":return e.jsxs("div",{className:`flex items-center justify-between space-x-2 ${t.className||""}`,children:[e.jsxs(De,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(nr,{id:t.name,checked:!!s,onCheckedChange:e=>w(t.name,e),disabled:t.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:r})]},t.name);default:return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(De,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Me,{id:t.name,type:"text",value:s||"",onChange:e=>{w(t.name,e.target.value)},placeholder:t.placeholder,disabled:t.disabled,className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:t.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name)}},S=t.useCallback(()=>{if(!C)return null;if(C.disabled)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:e.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),e.jsx("p",{className:"text-muted-foreground max-w-sm",children:'Complete as informações obrigatórias na seção "Informações Gerais" para acessar esta seção.'})]});if(C.component){const t=C.component;return e.jsx(t,{formData:b,updateField:w,errors:v,users:c,disabled:C.disabled})}return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:C.fields.map(k)})},[C,b,w,v,c,k]),T=e.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[y.length>1&&e.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:e.jsx("div",{className:"flex space-x-2",children:y.map(t=>e.jsx(Ee,{variant:j===t.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const t=y.find(t=>t.id===e);t&&!t.disabled&&m(e)})(t.id),disabled:t.disabled,className:t.disabled?"opacity-50 cursor-not-allowed":"",children:t.title},t.id))})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 py-4",children:d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"text-muted-foreground",children:"Carregando..."})}):e.jsxs("form",{onSubmit:N(n),className:"space-y-3 md:space-y-4",children:[S(),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(Ee,{type:"button",variant:"outline",onClick:o,children:"Cancelar"}),e.jsx(Ee,{type:"submit",disabled:d,children:l||"Salvar"})]})]})})]});return e.jsx(Be,{open:i,onOpenChange:e=>{!1===e&&!0===i&&o()},children:e.jsxs(Ye,{ref:x,className:"max-w-4xl max-h-[90vh] overflow-visible",children:[e.jsxs(Qe,{showSeparator:!0,children:[e.jsx(Ze,{children:a}),e.jsx(Je,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),T]})})}function dr({currentPage:t,totalPages:a,totalItems:s,itemsPerPage:r,onPageChange:n,onItemsPerPageChange:o,variant:i="full"}){const d=(t-1)*r+1,c=Math.min(t*r,s);return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:"full"===i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Itens por página"}),e.jsxs(dt,{value:String(r),onValueChange:e=>o(Number(e)),children:[e.jsx(mt,{className:"h-8 w-[70px]",children:e.jsx(ut,{})}),e.jsxs(ft,{children:[e.jsx(gt,{value:"10",children:"10"}),e.jsx(gt,{value:"25",children:"25"}),e.jsx(gt,{value:"50",children:"50"}),e.jsx(gt,{value:"100",children:"100"})]})]})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[d,"-",c," de ",s," itens"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ee,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===t,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronsLeft,{size:16})}),e.jsx(Ee,{variant:"outline",size:"sm",onClick:()=>n(t-1),disabled:1===t,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronLeft,{size:16})}),e.jsxs("div",{className:"flex items-center gap-1 px-2",children:[e.jsx("span",{className:"text-sm font-medium",children:t}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"de"}),e.jsx("span",{className:"text-sm font-medium",children:a})]}),e.jsx(Ee,{variant:"outline",size:"sm",onClick:()=>n(t+1),disabled:t===a,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronRight,{size:16})}),e.jsx(Ee,{variant:"outline",size:"sm",onClick:()=>n(a),disabled:t===a,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronsRight,{size:16})})]})]})}function cr({manager:t}){return e.jsx(dr,{currentPage:t.pagination.currentPage,totalPages:t.pagination.totalPages,totalItems:t.pagination.totalItems,itemsPerPage:t.pagination.itemsPerPage,onPageChange:t.handlePageChange,onItemsPerPageChange:t.handleItemsPerPageChange,variant:"full"})}const ur={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},mr={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},pr={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function hr({children:t,direction:a="column",gap:s="md",align:r="stretch",justify:n="start",wrap:o=!1,className:i}){return e.jsx("div",{className:Te("flex","column"===a?"flex-col":"flex-row",ur[s],mr[r],pr[n],o&&"flex-wrap",i),children:t})}function fr({manager:t,filters:a,inline:s=!1}){const{isSearchVisible:r}=ls(),n=t.searchTerm,o=e.jsxs(e.Fragment,{children:[a.some(e=>"search"===e.type)&&!r&&e.jsxs("div",{className:"relative flex-1",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Me,{placeholder:"Pesquisar",value:t.searchTerm,onChange:e=>t.handleSearch(e.target.value),className:"pl-10"})]}),a.filter(e=>"select"===e.type&&e.options).map((t,a)=>e.jsxs("select",{value:t.value||"",onChange:e=>t.onChange?.(e.target.value),className:"h-10 px-3 rounded-md border border-input bg-background text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[t.placeholder&&e.jsx("option",{value:"",children:t.placeholder}),t.options.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))]},`select-${a}`)),a.filter(e=>"custom"===e.type&&e.component).map((t,a)=>{const r=t.component;return e.jsx("div",{className:s?"":"w-full sm:w-auto",children:e.jsx(r,{...t.props})},`custom-${a}`)}),n&&e.jsxs(Ee,{variant:"outline",onClick:t.clearFilters,className:"whitespace-nowrap",children:[e.jsx(l.X,{className:"h-4 w-4 mr-2"}),"Limpar"]})]});return s?e.jsx("div",{className:"flex items-center gap-2",children:o}):e.jsx(hr,{direction:"column",gap:"md",className:"mb-6",children:e.jsx(hr,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:o})})}function xr({manager:a,config:s,formSections:r,onSave:n,onToggleStatus:o,defaultSort:i}){a&&a.queryKey;const{setSearchVisible:l}=ls(),[d,c]=w.useSearchParams(),[u,m]=t.useState(!1),[p,h]=t.useState(null),[f,x]=t.useState({isOpen:!1,entityId:null,entityName:""}),[g,b]=t.useState({isOpen:!1,count:0});t.useEffect(()=>(l(!0),()=>{l(!1)}),[l]),t.useEffect(()=>{if(i&&a){const e=`${a.queryKey}_sortField`,t=`${a.queryKey}_sortDirection`;if(!d.has(e)&&!d.has(t)){const a=Object.fromEntries(d);a[e]=i.column,a[t]=i.direction,c(a)}}},[]);const v=r.length>0?e=>{s.onEdit?s.onEdit(e):(h(e),m(!0))}:void 0,N="function"==typeof a?.deleteEntity?e=>{x({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})}:void 0,y=()=>{x({isOpen:!1,entityId:null,entityName:""})},j=void 0!==s.hideNewButton?!s.hideNewButton:s.showNewButton??!0,C=(s.customActions||[]).map(e=>({label:e.label,icon:e.icon,action:e.action,variant:"destructive"===e.variant?"default":e.variant,disabled:e.disabled,disabledReason:e.disabledReason}));return e.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[(s.showActionBar??!0)&&e.jsx(Qs,{onNew:()=>{s.onNew?s.onNew():(h(null),m(!0))},newButtonLabel:s.newButtonLabel,showNewButton:j,showSearch:s.showSearch,searchValue:a.searchTerm,onSearchChange:a.handleSearch,searchPlaceholder:s.searchPlaceholder,showBulkActions:s.enableBulkActions,selectedCount:a.selectedIds.length,bulkActions:s.bulkActions,onBulkDelete:()=>{b({isOpen:!0,count:a.selectedIds.length})},onClearSelection:a.clearSelection,customActions:C,filters:s.filters&&s.filters.length>0?e.jsx(fr,{manager:a,filters:s.filters,inline:!0}):void 0}),e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:s.customListView?e.jsx("div",{className:"flex-1 overflow-auto p-4",children:s.customListView(a.entities,a)}):e.jsx(Xs,{manager:a,columns:s.columns,onEdit:v,onDelete:N,onToggleStatus:o,enableBulkActions:s.enableBulkActions,customRowActions:s.customRowActions})}),e.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:e.jsx(cr,{manager:a})}),!s.useCustomRouting&&!s.onNew&&r.length>0&&e.jsx(lr,{open:u,title:p?`Editar ${s.entityName}`:`Novo ${s.entityName}`,sections:r,initialData:p||void 0,onSubmit:e=>{n(e),m(!1),h(null)},onCancel:()=>{m(!1),h(null)},isLoading:a.isLoading,submitButtonText:p?"Atualizar":"Criar"}),e.jsx(Be,{open:f.isOpen,onOpenChange:y,children:e.jsxs(Ye,{size:"sm",children:[e.jsx(Qe,{showSeparator:!0,children:e.jsx(Ze,{children:"Você tem certeza absoluta?"})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e.jsx("strong",{children:f.entityName}),". Esta ação não pode ser desfeita."]})}),e.jsxs(Xe,{children:[e.jsx(Ee,{variant:"outline",onClick:y,children:"Cancelar"}),e.jsx(Ee,{variant:"destructive",onClick:()=>{f.entityId&&"function"==typeof a?.deleteEntity&&(a.deleteEntity(f.entityId),x({isOpen:!1,entityId:null,entityName:""}))},disabled:a.isDeleting,children:a.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),e.jsx(Be,{open:g.isOpen,onOpenChange:()=>b({isOpen:!1,count:0}),children:e.jsxs(Ye,{size:"sm",children:[e.jsx(Qe,{showSeparator:!0,children:e.jsx(Ze,{children:"Você tem certeza absoluta?"})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e.jsx("strong",{children:g.count})," ",1===g.count?s.entityName:s.entityNamePlural,". Esta ação não pode ser desfeita."]})}),e.jsxs(Xe,{children:[e.jsx(Ee,{variant:"outline",onClick:()=>b({isOpen:!1,count:0}),children:"Cancelar"}),e.jsx(Ee,{variant:"destructive",onClick:()=>{a.bulkDelete?.(a.selectedIds),b({isOpen:!1,count:0})},disabled:a.isBulkDeleting,children:a.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function gr(e,t){const a=e.toLowerCase();return a.includes("email")?{type:"email",required:!0}:a.includes("phone")||a.includes("tel")?{type:"tel"}:a.includes("description")||a.includes("content")||a.includes("notes")?{type:"textarea"}:a.includes("status")||a.includes("type")||a.includes("category")?{type:"select",options:[]}:"boolean"==typeof t?{type:"boolean"}:"number"==typeof t?{type:"number"}:t instanceof Date?{type:"date"}:{type:"text"}}function br(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const vr=s.cva("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4",{variants:{variant:{info:"bg-[hsl(var(--alert-info-bg))] border-[hsl(var(--alert-info-border))] text-[hsl(var(--alert-info-foreground))] [&>svg]:text-[hsl(var(--alert-info-foreground))]",warning:"bg-[hsl(var(--alert-warning-bg))] border-[hsl(var(--alert-warning-border))] text-[hsl(var(--alert-warning-foreground))] [&>svg]:text-[hsl(var(--alert-warning-foreground))]",danger:"bg-[hsl(var(--alert-danger-bg))] border-[hsl(var(--alert-danger-border))] text-[hsl(var(--alert-danger-foreground))] [&>svg]:text-[hsl(var(--alert-danger-foreground))]",success:"bg-[hsl(var(--alert-success-bg))] border-[hsl(var(--alert-success-border))] text-[hsl(var(--alert-success-foreground))] [&>svg]:text-[hsl(var(--alert-success-foreground))]"}},defaultVariants:{variant:"info"}}),wr={info:l.Info,warning:l.Info,danger:l.AlertTriangle,success:l.CheckCircle},Nr=J.forwardRef(({className:t,variant:a="info",showIcon:s=!0,children:r,...n},o)=>{const i=wr[a||"info"];return e.jsxs("div",{ref:o,role:"alert",className:Te(vr({variant:a}),t),...n,children:[s&&e.jsx(i,{className:"h-4 w-4"}),r]})});Nr.displayName="Alert";const yr=J.forwardRef(({className:t,...a},s)=>e.jsx("h5",{ref:s,className:Te("mb-1 font-medium leading-none tracking-tight",t),...a}));yr.displayName="AlertTitle";const jr=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("text-sm [&_p]:leading-relaxed",t),...a}));jr.displayName="AlertDescription";const Cr=t.createContext(void 0);function kr({children:a,actions:s}){const[r,n]=t.useState({}),[o,i]=t.useState(s);return t.useEffect(()=>{i(s)},[s]),e.jsx(Cr.Provider,{value:{metadata:r,setMetadata:n,clearMetadata:()=>n({}),headerActions:o,setHeaderActions:i},children:a})}function Sr(){const e=t.useContext(Cr);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}var Tr={access_denied:{pt:"Acesso negado",en:"Access denied",es:""},actions:{pt:"Ações",en:"Actions",es:"Acciones"},activate:{pt:"Ativar",en:"Activate",es:"Activar"},activate_selected:{pt:"Ativar Selecionados",en:"Activate Selected",es:"Activar Seleccionados"},active:{pt:"Ativo",en:"Active",es:"Activo"},active_employees:{pt:"Colaboradores Ativos",en:"Active Employees",es:"Empleados Activos"},active_plural:{pt:"Ativos",en:"Active",es:"Activos"},add:{pt:"Adicionar",en:"Add",es:"Agregar"},additional_fields:{pt:"Campos Adicionais",en:"Additional Fields",es:"Campos Adicionales"},address:{pt:"Endereço",en:"Address",es:"Dirección"},admin:{pt:"Admin",en:"Admin",es:"Admin"},admin_access:{pt:"Acesso Admin",en:"Admin Access",es:"Acceso Admin"},admin_system:{pt:"Administração do Sistema",en:"System Administration",es:"Administración del Sistema"},admission_date:{pt:"Data de Admissão",en:"Admission Date",es:"Fecha de Admisión"},alignment:{pt:"Alinhamento",en:"Alignment",es:"Alineación"},all:{pt:"Todos",en:"All",es:"Todos"},allow_download:{pt:"Permitir Download",en:"Allow Download",es:"Permitir Descarga"},allowed_formats:{pt:"Formatos permitidos",en:"Allowed formats",es:"Formatos permitidos"},alt:{pt:"Texto Alternativo",en:"Alt Text",es:"Texto Alternativo"},api_response:{pt:"Resposta da API:",en:"API Response:",es:"Respuesta de la API:"},apply_filters:{pt:"Aplicar filtros",en:"Apply filters",es:"Aplicar filtros"},auth_required:{pt:"Autenticação necessária",en:"Authentication required",es:"Autenticación requerida"},autoplay:{pt:"Reprodução Automática",en:"Autoplay",es:"Reproducción Automática"},back:{pt:"Voltar",en:"Back",es:"Volver"},background_color:{pt:"Cor do Fundo",en:"Background Color",es:"Color de Fondo"},birth_date:{pt:"Data de Nascimento",en:"Birth Date",es:"Fecha de Nacimiento"},boolean:{pt:"Booleano",en:"Boolean",es:"Booleano"},bulk_actions:{pt:"Ações em lote",en:"Bulk actions",es:"Acciones masivas"},cancel:{pt:"Cancelar",en:"Cancel",es:"Cancelar"},cancelled:{pt:"Cancelado",en:"Cancelled",es:"Cancelado"},caption:{pt:"Legenda",en:"Caption",es:"Leyenda"},center:{pt:"Centro",en:"Center",es:"Centro"},chatbot:{pt:"Chatbot",en:"Chatbot",es:"Chatbot"},checking_access:{pt:"Verificando acesso...",en:"Checking access...",es:"Verificando acceso..."},choose_file:{pt:"Escolher arquivo",en:"Choose file",es:"Elegir archivo"},city:{pt:"Cidade",en:"City",es:"Ciudad"},clear:{pt:"Limpar",en:"Clear",es:"Limpiar"},clear_filters:{pt:"Limpar filtros",en:"Clear filters",es:"Limpiar filtros"},clear_search:{pt:"Limpar busca",en:"Clear search",es:"Limpiar búsqueda"},clear_selection:{pt:"Limpar seleção",en:"Clear selection",es:"Limpiar selección"},click_to_create_post:{pt:"Clique no botão abaixo para criar um novo post",en:"Click the button below to create a new post",es:"Haga clic en el botón de abajo para crear una nueva publicación"},close:{pt:"Fechar",en:"Close",es:"Cerrar"},collaborator:{pt:"Colaborador",en:"Collaborator",es:"Colaborador"},config:{pt:"Configuração",en:"Configuration",es:"Configuración"},config_info:{pt:"Informações da Configuração",en:"Configuration Info",es:"Información de Configuración"},config_info_description:{pt:"Defina a chave e o valor da configuração",en:"Set the configuration key and value",es:"Defina la clave y el valor de la configuración"},config_key:{pt:"Chave da Configuração",en:"Configuration Key",es:"Clave de Configuración"},configs:{pt:"Configurações",en:"Configurations",es:"Configuraciones"},comments:{pt:"Comentários",en:"Comments",es:"Comentarios"},community:{pt:"Comunidade",en:"Community",es:"Comunidad"},community_posts:{pt:"Posts da comunidade",en:"Community posts",es:"Publicaciones de la comunidad"},companies:{pt:"Empresas",en:"Companies",es:"Empresas"},company:{pt:"Empresa",en:"Company",es:"Empresa"},completed:{pt:"Concluído",en:"Completed",es:"Completado"},confirm:{pt:"Confirmar",en:"Confirm",es:"Confirmar"},confirm_delete:{pt:"Tem certeza que deseja excluir?",en:"Are you sure you want to delete?",es:"¿Está seguro de que desea eliminar?"},confirm_delete_message:{pt:"Esta ação não pode ser desfeita.",en:"This action cannot be undone.",es:"Esta acción no se puede deshacer."},confirm_password:{pt:"Confirmar Senha",en:"Confirm Password",es:"Confirmar Contraseña"},content:{pt:"Conteúdo",en:"Content",es:"Contenido"},content_blocks:{pt:"Blocos de Conteúdo",en:"Content Blocks",es:"Bloques de Contenido"},controls:{pt:"Controles",en:"Controls",es:"Controles"},copy:{pt:"Copiar",en:"Copy",es:"Copiar"},country:{pt:"País",en:"Country",es:"País"},courses:{pt:"Cursos",en:"Courses",es:"Cursos"},create:{pt:"Criar",en:"Create",es:"Crear"},create_first_post_hint:{pt:'Crie seu primeiro post na aba "Criar Post"',en:'Create your first post in the "Create Post" tab',es:'Crea tu primera publicación en la pestaña "Crear Publicación"'},create_post:{pt:"Criar Novo Post",en:"Create New Post",es:"Crear Nueva Publicación"},create_success:{pt:"Criado com sucesso",en:"Created successfully",es:"Creado exitosamente"},create_unit:{pt:"Criar Nova Unidade",en:"Create New Unit",es:"Crear Nueva Unidad"},created_at:{pt:"Criado em",en:"Created at",es:"Creado en"},created_by:{pt:"Criado por",en:"Created by",es:"Creado por"},currency:{pt:"Moeda",en:"Currency",es:"Moneda"},dashboard:{pt:"Dashboard",en:"Dashboard",es:"Panel"},date:{pt:"Data",en:"Date",es:"Fecha"},date_and_time:{pt:"Data e Hora",en:"Date and Time",es:"Fecha y Hora"},date_format:{pt:"Formato de Data",en:"Date Format",es:"Formato de Fecha"},date_time_format:{pt:"Formato de Data/Hora",en:"Date/Time Format",es:"Formato de Fecha/Hora"},deactivate:{pt:"Inativar",en:"Deactivate",es:"Desactivar"},deactivate_selected:{pt:"Inativar Selecionados",en:"Deactivate Selected",es:"Desactivar Seleccionados"},default:{pt:"Padrão",en:"Default",es:"Por Defecto"},delete:{pt:"Excluir",en:"Delete",es:"Eliminar"},delete_confirmation:{pt:"Confirmação de Exclusão",en:"Delete Confirmation",es:"Confirmación de Eliminación"},delete_success:{pt:"Excluído com sucesso",en:"Deleted successfully",es:"Eliminado exitosamente"},deleting:{pt:"Excluindo...",en:"Deleting...",es:"Eliminando..."},department:{pt:"Departamento",en:"Department",es:"Departamento"},description:{pt:"Descrição",en:"Description",es:"Descripción"},deselect_all:{pt:"Desselecionar todos",en:"Deselect all",es:"Deseleccionar todo"},design_system:{pt:"Design System",en:"Design System",es:"Sistema de Diseño"},design_tokens_and_docs:{pt:"Design tokens e documentação",en:"Design tokens and documentation",es:"Tokens de diseño y documentación"},details:{pt:"Detalhes",en:"Details",es:"Detalles"},disabled:{pt:"Desabilitado",en:"Disabled",es:"Deshabilitado"},download:{pt:"Baixar",en:"Download",es:"Descargar"},drag_drop:{pt:"Arraste e solte ou clique para selecionar",en:"Drag and drop or click to select",es:"Arrastre y suelte o haga clic para seleccionar"},duplicate:{pt:"Duplicar",en:"Duplicate",es:"Duplicar"},edit:{pt:"Editar",en:"Edit",es:"Editar"},edit_additional_fields:{pt:"Editar Campos Adicionais",en:"Edit Additional Fields",es:"Editar Campos Adicionales"},editor_hint:{pt:"💡 Dica: Use Ctrl+B (negrito), Ctrl+I (itálico), Ctrl+U (sublinhado) ou clique nos botões.",en:"💡 Hint: Use Ctrl+B (bold), Ctrl+I (italic), Ctrl+U (underline) or click the buttons.",es:"💡 Consejo: Use Ctrl+B (negrita), Ctrl+I (cursiva), Ctrl+U (subrayado) o haga clic en los botones."},education:{pt:"Educação",en:"Education",es:"Educación"},email:{pt:"E-mail",en:"Email",es:"Correo electrónico"},email_placeholder:{pt:"email@empresa.com",en:"email@company.com",es:"email@empresa.com"},embed:{pt:"Código Embed",en:"Embed Code",es:"Código Embed"},employee:{pt:"Colaborador",en:"Employee",es:"Empleado"},employee_activated:{pt:"Colaborador ativado com sucesso",en:"Employee activated successfully",es:"Empleado activado exitosamente"},employee_deactivated:{pt:"Colaborador inativado com sucesso",en:"Employee deactivated successfully",es:"Empleado desactivado exitosamente"},employee_information:{pt:"Informações do Colaborador",en:"Employee Information",es:"Información del Empleado"},employees:{pt:"Colaboradores",en:"Employees",es:"Empleados"},employees_removed:{pt:"{{count}} colaborador(es) removido(s)",en:"{{count}} employee(s) removed",es:"{{count}} empleado(s) eliminado(s)"},empty_description:{pt:"Não há dados para exibir no momento.",en:"There is no data to display at this time.",es:"No hay datos para mostrar en este momento."},empty_title:{pt:"Nenhum item encontrado",en:"No items found",es:"No se encontraron elementos"},en:{pt:"EN",en:"EN",es:"EN"},enabled:{pt:"Habilitado",en:"Enabled",es:"Habilitado"},enter_full_name:{pt:"Digite o nome completo",en:"Enter full name",es:"Ingrese el nombre completo"},enter_link_url:{pt:"Digite a URL do link:",en:"Enter link URL:",es:"Ingrese la URL del enlace:"},enter_youtube_url:{pt:"Cole a URL do vídeo do YouTube:",en:"Paste YouTube video URL:",es:"Pegue la URL del video de YouTube:"},error:{pt:"Erro",en:"Error",es:"Error"},error_changing_employee_status:{pt:"Erro ao alterar status do colaborador",en:"Error changing employee status",es:"Error al cambiar el estado del empleado"},error_creating:{pt:"Erro ao criar",en:"Error creating",es:"Error al crear"},error_deleting:{pt:"Erro ao excluir",en:"Error deleting",es:"Error al eliminar"},error_loading:{pt:"Erro ao carregar",en:"Error loading",es:"Error al cargar"},error_no_image:{pt:"Nenhuma imagem selecionada",en:"No image selected",es:"Ninguna imagen seleccionada"},error_no_video:{pt:"Nenhum vídeo selecionado",en:"No video selected",es:"Ningún video seleccionado"},error_saving:{pt:"Erro ao salvar",en:"Error saving",es:"Error al guardar"},error_updating:{pt:"Erro ao atualizar",en:"Error updating",es:"Error al actualizar"},es:{pt:"ES",en:"ES",es:"ES"},export:{pt:"Exportar",en:"Export",es:"Exportar"},failed:{pt:"Falhou",en:"Failed",es:"Fallido"},field_name:{pt:"Nome do Campo",en:"Field Name",es:"Nombre del Campo"},field_type:{pt:"Tipo",en:"Type",es:"Tipo"},file:{pt:"Arquivo de Vídeo",en:"Video File",es:"Archivo de Video"},file_upload_error:{pt:"Erro ao enviar arquivo",en:"Error uploading file",es:"Error al cargar el archivo"},file_upload_success:{pt:"Arquivo enviado com sucesso",en:"File uploaded successfully",es:"Archivo cargado exitosamente"},filter:{pt:"Filtrar",en:"Filter",es:"Filtrar"},first_name:{pt:"Nome",en:"First Name",es:"Nombre"},font:{pt:"Fonte",en:"Font",es:"Fuente"},format_html:{pt:"HTML",en:"HTML",es:"HTML"},format_markdown:{pt:"Markdown",en:"Markdown",es:"Markdown"},format_plain:{pt:"Texto Simples",en:"Plain Text",es:"Texto Simple"},format_rich:{pt:"Rich (WYSIWYG)",en:"Rich (WYSIWYG)",es:"Rich (WYSIWYG)"},full_name:{pt:"Nome Completo",en:"Full Name",es:"Nombre Completo"},general_settings:{pt:"Configurações Gerais",en:"General Settings",es:"Configuración General"},height:{pt:"Altura",en:"Height",es:"Altura"},home:{pt:"Início",en:"Home",es:"Inicio"},html_warning:{pt:"⚠️ HTML será sanitizado para segurança",en:"⚠️ HTML will be sanitized for security",es:"⚠️ HTML será sanitizado por seguridad"},identification:{pt:"Identificação",en:"Identification",es:"Identificación"},identification_invalid:{pt:"Identificação inválida",en:"Invalid identification",es:"Identificación inválida"},image:{pt:"Imagem",en:"Image",es:"Imagen"},import:{pt:"Importar",en:"Import",es:"Importar"},inactive:{pt:"Inativo",en:"Inactive",es:"Inactivo"},inactive_plural:{pt:"Inativos",en:"Inactive",es:"Inactivos"},info:{pt:"Informação",en:"Information",es:"Información"},input_type:{pt:"Tipo de Entrada",en:"Input Type",es:"Tipo de Entrada"},input_type_embed:{pt:"Embed",en:"Embed",es:"Incrustar"},input_type_upload:{pt:"Upload",en:"Upload",es:"Cargar"},integration:{pt:"Integração",en:"Integration",es:"Integración"},invalid_date:{pt:"Data inválida",en:"Invalid date",es:"Fecha inválida"},invalid_email:{pt:"E-mail inválido",en:"Invalid email",es:"Correo electrónico inválido"},invalid_file_type:{pt:"Por favor, selecione um arquivo de vídeo",en:"Please select a video file",es:"Por favor, seleccione un archivo de video"},invalid_phone:{pt:"Telefone inválido",en:"Invalid phone",es:"Teléfono inválido"},invalid_youtube_url:{pt:"URL do YouTube inválida. Use o formato: https://www.youtube.com/watch?v=VIDEO_ID",en:"Invalid YouTube URL. Use format: https://www.youtube.com/watch?v=VIDEO_ID",es:"URL de YouTube inválida. Use el formato: https://www.youtube.com/watch?v=VIDEO_ID"},item_details:{pt:"Detalhes do item",en:"Item details",es:"Detalles del elemento"},key:{pt:"Chave",en:"Key",es:""},language:{pt:"Idioma",en:"Language",es:"Idioma"},last_10_logins:{pt:"Últimos 10 Logins",en:"Last 10 Logins",es:"Últimos 10 Inicios de Sesión"},last_modification:{pt:"Última Modificação",en:"Last Modification",es:"Última Modificación"},last_name:{pt:"Sobrenome",en:"Last Name",es:"Apellido"},leader:{pt:"Líder",en:"Leader",es:"Líder"},leadership:{pt:"Liderança",en:"Leadership",es:"Liderazgo"},leadership_hierarchy:{pt:"Hierarquia de liderança",en:"Leadership hierarchy",es:"Jerarquía de liderazgo"},left:{pt:"Esquerda",en:"Left",es:"Izquierda"},link_copied:{pt:"Link copiado para a área de transferência",en:"Link copied to clipboard",es:"Enlace copiado al portapapeles"},list:{pt:"Lista",en:"List",es:"Lista"},loading:{pt:"Carregando...",en:"Loading...",es:"Cargando..."},loading_data:{pt:"Carregando dados...",en:"Loading data...",es:"Cargando datos..."},logout:{pt:"Sair",en:"Logout",es:"Cerrar Sesión"},manage_reports:{pt:"Gerenciar relatórios",en:"Manage reports",es:"Gestionar informes"},management:{pt:"Gestão",en:"Management",es:"Gestión"},management_access_control:{pt:"Controle de acesso a gestão",en:"Management access control",es:"Control de acceso a gestión"},management_permission:{pt:"Permissão de Gestão",en:"Management Permission",es:"Permiso de Gestión"},management_permissions:{pt:"Permissões de Gestão",en:"Management Permissions",es:"Permisos de Gestión"},markdown_hint:{pt:"💡 Suporte a: **negrito**, *itálico*, [links](url), parágrafos",en:"💡 Supports: **bold**, *italic*, [links](url), paragraphs",es:"💡 Soporta: **negrita**, *cursiva*, [enlaces](url), párrafos"},max_file_size:{pt:"Tamanho máximo",en:"Maximum size",es:"Tamanho máximo"},migration:{pt:"Migração",en:"Migration",es:""},module:{pt:"Módulo",en:"Module",es:"Módulo"},module_title:{pt:"Título do módulo",en:"Module title",es:"Título del módulo"},modules:{pt:"Módulos",en:"Modules",es:"Módulos"},name:{pt:"Nome",en:"Name",es:"Nombre"},new:{pt:"Novo",en:"New",es:"Nuevo"},new_password:{pt:"Nova Senha",en:"New Password",es:"Nueva Contraseña"},new_value:{pt:"Novo valor",en:"New value",es:"Nuevo valor"},next:{pt:"Próximo",en:"Next",es:"Siguiente"},no:{pt:"Não",en:"No",es:"No"},no_additional_fields:{pt:"Nenhum campo adicional configurado.",en:"No additional fields configured.",es:"No hay campos adicionales configurados."},no_content_preview:{pt:"Nenhum conteúdo para visualizar...",en:"No content to preview...",es:"No hay contenido para previsualizar..."},no_data:{pt:"Nenhum dado disponível",en:"No data available",es:"No hay datos disponibles"},no_file_selected:{pt:"Nenhum arquivo selecionado",en:"No file selected",es:"No se seleccionó ningún archivo"},no_items_found:{pt:"Nenhum item encontrado",en:"No items found",es:"No se encontraron elementos"},no_logins_registered:{pt:"Nenhum login registrado ainda.",en:"No logins registered yet.",es:"Aún no se han registrado inicios de sesión."},no_options:{pt:"Nenhuma opção disponível",en:"No options available",es:"No hay opciones disponibles"},no_permission_to_access_reports:{pt:"Sem permissão para acessar relatórios",en:"No permission to access reports",es:""},no_posts_found:{pt:"Nenhum post encontrado",en:"No posts found",es:"No se encontraron publicaciones"},no_results:{pt:"Nenhum resultado encontrado",en:"No results found",es:"No se encontraron resultados"},no_title:{pt:"Sem título",en:"No title",es:"Sin título"},notifications:{pt:"Notificações",en:"Notifications",es:"Notificaciones"},nr1:{pt:"Pulso",en:"Pulse",es:"Pulso"},of:{pt:"de",en:"of",es:"de"},old_password:{pt:"Senha Atual",en:"Current Password",es:"Contraseña Actual"},open_external_link:{pt:"Abrir link externo",en:"Open external link",es:"Abrir enlace externo"},open_wiki:{pt:"Abrir Wiki",en:"Open Wiki",es:"Abrir Wiki"},order:{pt:"Ordem",en:"Order",es:"Orden"},overview:{pt:"Visão geral",en:"Overview",es:"Resumen"},page:{pt:"Página",en:"Page",es:"Página"},password:{pt:"Senha",en:"Password",es:"Contraseña"},paste_html_placeholder:{pt:"Cole ou escreva HTML aqui...",en:"Paste or write HTML here...",es:"Pegue o escriba HTML aquí..."},pdi:{pt:"PDI",en:"PDI",es:"PDI"},pending:{pt:"Pendente",en:"Pending",es:"Pendiente"},performance:{pt:"Desempenho",en:"Performance",es:"Desempeño"},permissions:{pt:"Permissões",en:"Permissions",es:"Permisos"},permissions_roles:{pt:"Permissões e Roles",en:"Permissions and Roles",es:"Permisos y Roles"},phone:{pt:"Telefone",en:"Phone",es:"Teléfono"},place:{pt:"Local",en:"Place",es:"Lugar"},placeholder_select:{pt:"Selecione...",en:"Select...",es:"Seleccionar..."},places:{pt:"Locais",en:"Places",es:"Lugares"},plain_text_placeholder:{pt:"Digite texto simples aqui...",en:"Enter plain text here...",es:"Ingrese texto simple aquí..."},position:{pt:"Cargo",en:"Position",es:"Cargo"},posts:{pt:"Publicações",en:"Posts",es:"Publicaciones"},preferences:{pt:"Preferências de Internacionalização",en:"Internationalization Preferences",es:"Preferencias de Internacionalización"},preview:{pt:"Preview",en:"Preview",es:"Vista Previa"},previous:{pt:"Anterior",en:"Previous",es:"Anterior"},processing:{pt:"Processando...",en:"Processing...",es:"Procesando..."},profile:{pt:"Perfil",en:"Profile",es:"Perfil"},pt:{pt:"PT",en:"PT",es:"PT"},qualiex_places_hierarchy:{pt:"Hierarquia de locais do Qualiex",en:"Qualiex places hierarchy",es:"Jerarquía de lugares de Qualiex"},recipient_email:{pt:"Email Destinatário",en:"Recipient Email",es:"Correo del Destinatario"},redirecting:{pt:"Redirecionando...",en:"Redirecting...",es:"Redirigiendo..."},refresh_data:{pt:"Atualizar dados",en:"Refresh data",es:"Actualizar datos"},reload:{pt:"Recarregar",en:"Reload",es:"Recargar"},remove:{pt:"Remover",en:"Remove",es:"Eliminar"},remove_confirm:{pt:"Tem certeza que deseja remover?",en:"Are you sure you want to remove?",es:"¿Está seguro de que desea eliminar?"},removing:{pt:"Removendo...",en:"Removing...",es:"Eliminando..."},reports:{pt:"Relatórios",en:"Reports",es:"Informes"},required_field:{pt:"Campo obrigatório",en:"Required field",es:"Campo obligatorio"},restricted_access:{pt:"Acesso restrito",en:"Restricted access",es:"Acceso restringido"},results:{pt:"resultados",en:"results",es:"resultados"},right:{pt:"Direita",en:"Right",es:"Derecha"},role:{pt:"Papel",en:"Role",es:"Rol"},roles:{pt:"Perfis",en:"Roles",es:"Roles"},rows_per_page:{pt:"Registros por página",en:"Rows per page",es:"Registros por página"},save:{pt:"Salvar",en:"Save",es:"Guardar"},save_block:{pt:"Salvar Bloco",en:"Save Block",es:"Guardar Bloque"},save_success:{pt:"Salvo com sucesso",en:"Saved successfully",es:"Guardado exitosamente"},saving:{pt:"Salvando...",en:"Saving...",es:"Guardando..."},search:{pt:"Pesquisar",en:"Search",es:"Buscar"},search_placeholder:{pt:"Pesquisar...",en:"Search...",es:"Buscar..."},search_user:{pt:"Buscar usuário...",en:"Search user...",es:"Buscar usuario..."},searchDateFormat:{pt:"Buscar formato...",en:"Search format...",es:"Buscar formato..."},searchTimezone:{pt:"Buscar fuso horário...",en:"Search timezone...",es:"Buscar zona horaria..."},section:{pt:"Seção",en:"Section",es:"Sección"},select_all:{pt:"Selecionar todos",en:"Select all",es:"Seleccionar todo"},select_collaborator:{pt:"Selecionar Colaborador",en:"Select Collaborator",es:"Seleccionar Colaborador"},select_option:{pt:"Selecione uma opção",en:"Select an option",es:"Seleccione una opción"},select_placeholder:{pt:"Selecione...",en:"Select...",es:"Seleccionar..."},selectDateFormat:{pt:"Selecione o formato",en:"Select format",es:"Seleccione el formato"},selectTimezone:{pt:"Selecione o fuso horário",en:"Select timezone",es:"Seleccione la zona horaria"},select_text_for_link:{pt:"Selecione o texto que deseja transformar em link",en:"Select the text you want to turn into a link",es:"Seleccione el texto que desea convertir en enlace"},select_unit_collaborator:{pt:"Selecione um colaborador da unidade",en:"Select a unit collaborator",es:"Seleccione un colaborador de la unidad"},select_user:{pt:"Selecionar Usuário",en:"Select User",es:"Seleccionar Usuario"},select_user_for_admin_access:{pt:"Selecione um usuário para dar acesso admin",en:"Select a user to grant admin access",es:"Seleccione un usuario para dar acceso de administrador"},select_video:{pt:"Selecionar Vídeo",en:"Select Video",es:"Seleccionar Video"},selected:{pt:"selecionado(s)",en:"selected",es:"seleccionado(s)"},selected_count:{pt:"{{count}} selecionado(s)",en:"{{count}} selected",es:"{{count}} seleccionado(s)"},send:{pt:"Enviar",en:"Send",es:"Enviar"},settings:{pt:"Configurações",en:"Settings",es:"Configuración"},settings_summary:{pt:"Resumo das configurações",en:"Settings summary",es:"Resumen de configuración"},showing:{pt:"Mostrando",en:"Showing",es:"Mostrando"},size:{pt:"Tamanho",en:"Size",es:"Tamaño"},skills:{pt:"Habilidades",en:"Skills",es:"Habilidades"},state:{pt:"Estado",en:"State",es:"Estado"},status:{pt:"Status",en:"Status",es:"Estado"},subordinates:{pt:"Subordinados",en:"Subordinates",es:"Subordinados"},success:{pt:"Sucesso",en:"Success",es:"Éxito"},superior:{pt:"Superior Imediato",en:"Immediate Superior",es:"Superior Inmediato"},superior_none:{pt:"Nenhum superior",en:"No superior",es:"Ningún superior"},superior_search:{pt:"Buscar superior...",en:"Search superior...",es:"Buscar superior..."},system_administration:{pt:"Administração do sistema",en:"System administration",es:"Administración del sistema"},system_logs:{pt:"Logs do Sistema",en:"System Logs",es:"Registros del Sistema"},template_variables:{pt:"Variáveis do Template",en:"Template Variables",es:"Variables de Plantilla"},test_email:{pt:"Testar Envio de Email",en:"Test Email Sending",es:"Probar Envío de Correo"},text:{pt:"Texto",en:"Text",es:"Texto"},text_color:{pt:"Cor do Texto",en:"Text Color",es:"Color del Texto"},text_format:{pt:"Formato de Texto",en:"Text Format",es:"Formato de Texto"},thumbnail:{pt:"Thumbnail",en:"Thumbnail",es:"Miniatura"},timezone:{pt:"Fuso Horário",en:"Timezone",es:"Zona Horaria"},title:{pt:"Título",en:"Title",es:"Título"},to:{pt:"até",en:"to",es:"hasta"},total:{pt:"Total",en:"Total",es:"Total"},trainings:{pt:"Treinamentos",en:"Trainings",es:"Capacitaciones"},translation:{pt:"Tradução",en:"Translation",es:"Traducción"},translation_description:{pt:"Informações da tradução",en:"Translation information",es:"Información de la traducción"},translations:{pt:"Traduções",en:"Translations",es:"Traducciones"},type:{pt:"Tipo",en:"Type",es:"Tipo"},type_to_search:{pt:"Digite para pesquisar",en:"Type to search",es:"Escriba para buscar"},unit:{pt:"Unidade",en:"Unit",es:"Unidad"},units:{pt:"Unidades",en:"Units",es:"Unidades"},unsupported:{pt:"Formato não suportado",en:"Unsupported format",es:"Formato no soportado"},update:{pt:"Atualizar",en:"Update",es:"Actualizar"},value:{pt:"Valor",en:"Value",es:"Valor"},update_success:{pt:"Atualizado com sucesso",en:"Updated successfully",es:"Actualizado exitosamente"},updated_at:{pt:"Atualizado em",en:"Updated at",es:"Actualizado en"},updated_by:{pt:"Atualizado por",en:"Updated by",es:"Actualizado por"},updating:{pt:"Atualizando...",en:"Updating...",es:"Actualizando..."},upload:{pt:"Upload",en:"Upload",es:"Cargar"},useSystemDefaults:{pt:"Usar padrão do sistema",en:"Use system defaults",es:"Usar valores del sistema"},uploading:{pt:"Enviando...",en:"Uploading...",es:"Subiendo..."},url:{pt:"URL",en:"URL",es:"URL"},url_placeholder:{pt:"https://exemplo.com/imagem.jpg",en:"https://example.com/image.jpg",es:"https://ejemplo.com/imagen.jpg"},user:{pt:"Usuário",en:"User",es:"Usuario"},user_management:{pt:"Gestão de Usuários",en:"User Management",es:"Gestión de Usuarios"},username:{pt:"Usuário",en:"Username",es:"Usuario"},users:{pt:"Usuários",en:"Users",es:"Usuarios"},video:{pt:"Vídeo",en:"Video",es:"Video"},view:{pt:"Visualizar",en:"View",es:"Visualizar"},view_mode_grid:{pt:"Grade",en:"Grid",es:"Cuadrícula"},view_mode_list:{pt:"Lista",en:"List",es:"Lista"},view_mode_table:{pt:"Tabela",en:"Table",es:"Tabla"},warning:{pt:"Aviso",en:"Warning",es:"Advertencia"},width:{pt:"Largura",en:"Width",es:"Ancho"},yes:{pt:"Sim",en:"Yes",es:"Sí"},zip_code:{pt:"CEP",en:"ZIP Code",es:"Código Postal"}};T.use(S.initReactI18next).init({resources:function(e){const t={},a={},s={};for(const[r,n]of Object.entries(e))t[r]=n.pt||r,a[r]=n.en||n.pt||r,s[r]=n.es||n.pt||r;return{"pt-BR":{translations:t},"en-US":{translations:a},"es-ES":{translations:s}}}(Tr),fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"translations",ns:["translations"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:e=>e});const _r=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],Ar=[{value:"dd/MM/yyyy HH:mm",label:"dd/MM/yyyy HH:mm",example:"28/11/2024 14:30",description:"Padrão Brasileiro"},{value:"MM/dd/yyyy hh:mm a",label:"MM/dd/yyyy hh:mm a",example:"11/28/2024 02:30 PM",description:"Padrão Americano (12h)"},{value:"MM/dd/yyyy HH:mm",label:"MM/dd/yyyy HH:mm",example:"11/28/2024 14:30",description:"Padrão Americano (24h)"},{value:"yyyy-MM-dd HH:mm",label:"yyyy-MM-dd HH:mm",example:"2024-11-28 14:30",description:"ISO 8601"},{value:"dd.MM.yyyy HH:mm",label:"dd.MM.yyyy HH:mm",example:"28.11.2024 14:30",description:"Padrão Europeu"},{value:"d MMM yyyy, HH:mm",label:"d MMM yyyy, HH:mm",example:"28 Nov 2024, 14:30",description:"Formato Longo"}],Er=[{value:"America/Sao_Paulo",label:"Brasília (UTC-3)",offset:"-03:00"},{value:"America/Noronha",label:"Fernando de Noronha (UTC-2)",offset:"-02:00"},{value:"America/Manaus",label:"Manaus (UTC-4)",offset:"-04:00"},{value:"America/Rio_Branco",label:"Rio Branco (UTC-5)",offset:"-05:00"},{value:"America/Buenos_Aires",label:"Buenos Aires (UTC-3)",offset:"-03:00"},{value:"America/Santiago",label:"Santiago (UTC-4)",offset:"-04:00"},{value:"America/Bogota",label:"Bogotá (UTC-5)",offset:"-05:00"},{value:"America/Mexico_City",label:"Cidade do México (UTC-6)",offset:"-06:00"},{value:"America/New_York",label:"New York (UTC-5)",offset:"-05:00"},{value:"America/Chicago",label:"Chicago (UTC-6)",offset:"-06:00"},{value:"America/Denver",label:"Denver (UTC-7)",offset:"-07:00"},{value:"America/Los_Angeles",label:"Los Angeles (UTC-8)",offset:"-08:00"},{value:"America/Toronto",label:"Toronto (UTC-5)",offset:"-05:00"},{value:"America/Vancouver",label:"Vancouver (UTC-8)",offset:"-08:00"},{value:"Europe/London",label:"Londres (UTC+0)",offset:"+00:00"},{value:"Europe/Lisbon",label:"Lisboa (UTC+0)",offset:"+00:00"},{value:"Europe/Paris",label:"Paris (UTC+1)",offset:"+01:00"},{value:"Europe/Berlin",label:"Berlim (UTC+1)",offset:"+01:00"},{value:"Europe/Madrid",label:"Madrid (UTC+1)",offset:"+01:00"},{value:"Europe/Rome",label:"Roma (UTC+1)",offset:"+01:00"},{value:"Europe/Amsterdam",label:"Amsterdã (UTC+1)",offset:"+01:00"},{value:"Europe/Moscow",label:"Moscou (UTC+3)",offset:"+03:00"},{value:"Asia/Dubai",label:"Dubai (UTC+4)",offset:"+04:00"},{value:"Asia/Kolkata",label:"Mumbai (UTC+5:30)",offset:"+05:30"},{value:"Asia/Singapore",label:"Singapura (UTC+8)",offset:"+08:00"},{value:"Asia/Hong_Kong",label:"Hong Kong (UTC+8)",offset:"+08:00"},{value:"Asia/Shanghai",label:"Xangai (UTC+8)",offset:"+08:00"},{value:"Asia/Tokyo",label:"Tóquio (UTC+9)",offset:"+09:00"},{value:"Asia/Seoul",label:"Seul (UTC+9)",offset:"+09:00"},{value:"Australia/Perth",label:"Perth (UTC+8)",offset:"+08:00"},{value:"Australia/Sydney",label:"Sydney (UTC+10)",offset:"+10:00"},{value:"Pacific/Auckland",label:"Auckland (UTC+12)",offset:"+12:00"},{value:"UTC",label:"UTC (UTC+0)",offset:"+00:00"}],Pr="pt-BR",Mr="dd/MM/yyyy HH:mm",Ir="America/Sao_Paulo",Dr=e=>_r.some(t=>t.value===e),Rr=e=>Er.some(t=>t.value===e),Lr=()=>{if("undefined"==typeof navigator)return Pr;const e=navigator.language;if(Dr(e))return e;const t=e.split("-")[0],a=_r.find(e=>e.value.startsWith(t));return a?.value||Pr},zr=()=>{if("undefined"==typeof Intl)return Ir;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;return Rr(e)?e:Ir}catch{return Ir}},Fr=e=>({"pt-BR":"dd/MM/yyyy HH:mm","en-US":"MM/dd/yyyy hh:mm a","es-ES":"dd/MM/yyyy HH:mm"}[e]||Mr),Ur=t.createContext(void 0),qr={locale:"pt-BR",timezone:"America/Sao_Paulo",datetimeFormat:Mr},Or=async()=>{},Br=({children:t})=>e.jsx(Ur.Provider,{value:{...qr,setLocale:Or,setTimezone:Or,setDatetimeFormat:Or,isLoading:!1},children:t}),Hr=()=>{const e=t.useContext(Ur);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e},$r=pe.Root,Vr=pe.CollapsibleTrigger,Wr=pe.CollapsibleContent;var Gr=Object.defineProperty,Yr=(e,t,a)=>((e,t,a)=>t in e?Gr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);class Qr extends t.Component{constructor(e){super(e),Yr(this,"copyErrorDetails",()=>{const e=va.getErrors().slice(0,2),t=`\n=== ERRO ATUAL ===\n${this.state.error?.message||"Erro desconhecido"}\n\nStack Trace:\n${this.state.error?.stack||"Não disponível"}\n\n=== ÚLTIMOS ERROS ===\n${e.map((e,t)=>`${t+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||"Nenhum erro registrado"}\n `.trim();navigator.clipboard.writeText(t),i.toast.success("Detalhes copiados!",{description:"Os detalhes do erro foram copiados para a área de transferência."})}),this.state={hasError:!1,showDetails:!1}}static getDerivedStateFromError(e){if((void 0).DEV)throw e;return{hasError:!0,error:e}}componentDidCatch(e,t){if((void 0).DEV)throw e;va.handleError(e,!1),this.setState({errorInfo:t})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const t=va.getErrors().slice(0,2);return e.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:e.jsxs(Re,{className:"w-full max-w-2xl",children:[e.jsxs(Le,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(l.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),e.jsx(ze,{children:"Algo deu errado"})]}),e.jsxs(Ue,{className:"space-y-4",children:[e.jsx("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),e.jsxs($r,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[e.jsx(Vr,{asChild:!0,children:e.jsxs(Ee,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[e.jsx(l.ChevronDown,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),e.jsxs(Wr,{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),e.jsxs("div",{className:"text-sm space-y-2",children:[e.jsx("p",{className:"font-medium text-destructive",children:this.state.error?.message||"Erro desconhecido"}),this.state.error?.stack&&e.jsx(tr,{className:"h-32 w-full rounded border bg-muted p-2",children:e.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),t.length>0&&e.jsxs("div",{className:"pt-3 border-t",children:[e.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),e.jsx("div",{className:"space-y-2",children:t.map((t,a)=>e.jsx("div",{className:"text-sm p-2 rounded bg-muted/50",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"font-medium text-muted-foreground shrink-0",children:[a+1,"."]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:e.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",new Date(t.timestamp).toLocaleTimeString(),"]"]})}),e.jsx("p",{className:"text-sm break-words",children:t.message})]})]})},t.id))})]})]}),e.jsxs(Ee,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[e.jsx(l.Copy,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),e.jsx(Ee,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const Kr=he.Root,Xr=J.forwardRef(({className:t,...a},s)=>e.jsx(he.Item,{ref:s,className:Te("border-b",t),...a}));Xr.displayName="AccordionItem";const Zr=J.forwardRef(({className:t,children:a,...s},r)=>e.jsx(he.Header,{className:"flex",children:e.jsxs(he.Trigger,{ref:r,className:Te("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",t),...s,children:[a,e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));Zr.displayName=he.Trigger.displayName;const Jr=J.forwardRef(({className:t,children:a,...s},r)=>e.jsx(he.Content,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...s,children:e.jsx("div",{className:Te("pb-4 pt-0",t),children:a})}));Jr.displayName=he.Content.displayName;const en=fe.Root,tn=fe.Trigger,an=fe.Portal,sn=J.forwardRef(({className:t,...a},s)=>e.jsx(fe.Overlay,{className:Te("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a,ref:s}));sn.displayName=fe.Overlay.displayName;const rn=J.forwardRef(({className:t,...a},s)=>e.jsxs(an,{children:[e.jsx(sn,{}),e.jsx(fe.Content,{ref:s,className:Te("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...a})]}));rn.displayName=fe.Content.displayName;const nn=({className:t,...a})=>e.jsx("div",{className:Te("flex flex-col space-y-2 text-center sm:text-left",t),...a});nn.displayName="AlertDialogHeader";const on=({className:t,...a})=>e.jsx("div",{className:Te("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a});on.displayName="AlertDialogFooter";const ln=J.forwardRef(({className:t,...a},s)=>e.jsx(fe.Title,{ref:s,className:Te("text-lg font-semibold",t),...a}));ln.displayName=fe.Title.displayName;const dn=J.forwardRef(({className:t,...a},s)=>e.jsx(fe.Description,{ref:s,className:Te("text-sm text-muted-foreground",t),...a}));dn.displayName=fe.Description.displayName;const cn=J.forwardRef(({className:t,...a},s)=>e.jsx(fe.Action,{ref:s,className:Te(Ae(),t),...a}));cn.displayName=fe.Action.displayName;const un=J.forwardRef(({className:t,...a},s)=>e.jsx(fe.Cancel,{ref:s,className:Te(Ae({variant:"outline"}),"mt-2 sm:mt-0",t),...a}));un.displayName=fe.Cancel.displayName;const mn=J.forwardRef(({className:t,...a},s)=>e.jsx(xe.Root,{ref:s,className:Te("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...a}));mn.displayName=xe.Root.displayName;const pn=J.forwardRef(({className:t,...a},s)=>e.jsx(xe.Image,{ref:s,className:Te("aspect-square h-full w-full",t),...a}));pn.displayName=xe.Image.displayName;const hn=J.forwardRef(({className:t,...a},s)=>e.jsx(xe.Fallback,{ref:s,className:Te("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...a}));hn.displayName=xe.Fallback.displayName;const fn=J.forwardRef(({...t},a)=>e.jsx("nav",{ref:a,"aria-label":"breadcrumb",...t}));fn.displayName="Breadcrumb";const xn=J.forwardRef(({className:t,...a},s)=>e.jsx("ol",{ref:s,className:Te("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...a}));xn.displayName="BreadcrumbList";const gn=J.forwardRef(({className:t,...a},s)=>e.jsx("li",{ref:s,className:Te("inline-flex items-center gap-1.5",t),...a}));gn.displayName="BreadcrumbItem";const bn=J.forwardRef(({asChild:t,className:s,...r},n)=>{const o=t?a.Slot:"a";return e.jsx(o,{ref:n,className:Te("transition-colors hover:text-foreground",s),...r})});bn.displayName="BreadcrumbLink";const vn=J.forwardRef(({className:t,...a},s)=>e.jsx("span",{ref:s,role:"link","aria-disabled":"true","aria-current":"page",className:Te("font-normal text-foreground",t),...a}));vn.displayName="BreadcrumbPage";const wn=({children:t,className:a,...s})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Te("[&>svg]:h-3.5 [&>svg]:w-3.5",a),...s,children:t??e.jsx(l.ChevronRight,{})});wn.displayName="BreadcrumbSeparator";const Nn=({className:t,...a})=>e.jsxs("span",{role:"presentation","aria-hidden":"true",className:Te("flex h-9 w-9 items-center justify-center",t),...a,children:[e.jsx(l.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Mais"})]});Nn.displayName="BreadcrumbEllipsis";const yn=s.cva("flex items-center",{variants:{orientation:{horizontal:"flex-row [&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}}),jn=J.forwardRef(({className:t,orientation:a,...s},r)=>e.jsx("div",{ref:r,className:Te(yn({orientation:a}),t),...s}));function Cn(e){return(t={})=>{const a=t.width?String(t.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}function kn(e){return(t,a)=>{let s;if("formatting"===(a?.context?String(a.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,r=a?.width?String(a.width):t;s=e.formattingValues[r]||e.formattingValues[t]}else{const t=e.defaultWidth,r=a?.width?String(a.width):e.defaultWidth;s=e.values[r]||e.values[t]}return s[e.argumentCallback?e.argumentCallback(t):t]}}function Sn(e){return(t,a={})=>{const s=a.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],n=t.match(r);if(!n)return null;const o=n[0],i=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(i)?function(e,t){for(let a=0;a<e.length;a++)if(t(e[a]))return a;return}(i,e=>e.test(o)):function(e,t){for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&t(e[a]))return a;return}(i,e=>e.test(o));let d;d=e.valueCallback?e.valueCallback(l):l,d=a.valueCallback?a.valueCallback(d):d;return{value:d,rest:t.slice(o.length)}}}function Tn(e){return(t,a={})=>{const s=t.match(e.matchPattern);if(!s)return null;const r=s[0],n=t.match(e.parsePattern);if(!n)return null;let o=e.valueCallback?e.valueCallback(n[0]):n[0];o=a.valueCallback?a.valueCallback(o):o;return{value:o,rest:t.slice(r.length)}}}function _n(e){const t=Object.prototype.toString.call(e);return e instanceof Date||"object"==typeof e&&"[object Date]"===t?new e.constructor(+e):"number"==typeof e||"[object Number]"===t||"string"==typeof e||"[object String]"===t?new Date(e):new Date(NaN)}jn.displayName="ButtonGroup";let An={};function En(){return An}function Pn(e,t){const a=En(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,r=_n(e),n=r.getDay(),o=(n<s?7:0)+n-s;return r.setDate(r.getDate()-o),r.setHours(0,0,0,0),r}const Mn={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},In={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Dn={ordinalNumber:(e,t)=>{const a=Number(e),s=a%100;if(s>20||s<10)switch(s%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},era:kn({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:kn({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:kn({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:kn({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:kn({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},Rn={ordinalNumber:Tn({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Sn({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:Sn({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:Sn({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:Sn({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:Sn({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},Ln={code:"en-US",formatDistance:(e,t,a)=>{let s;const r=Mn[e];return s="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"in "+s:s+" ago":s},formatLong:{date:Cn({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Cn({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:Cn({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},formatRelative:(e,t,a,s)=>In[e],localize:Dn,match:Rn,options:{weekStartsOn:0,firstWeekContainsDate:1}},zn={lessThanXSeconds:{one:"menos de un segundo",other:"menos de {{count}} segundos"},xSeconds:{one:"1 segundo",other:"{{count}} segundos"},halfAMinute:"medio minuto",lessThanXMinutes:{one:"menos de un minuto",other:"menos de {{count}} minutos"},xMinutes:{one:"1 minuto",other:"{{count}} minutos"},aboutXHours:{one:"alrededor de 1 hora",other:"alrededor de {{count}} horas"},xHours:{one:"1 hora",other:"{{count}} horas"},xDays:{one:"1 día",other:"{{count}} días"},aboutXWeeks:{one:"alrededor de 1 semana",other:"alrededor de {{count}} semanas"},xWeeks:{one:"1 semana",other:"{{count}} semanas"},aboutXMonths:{one:"alrededor de 1 mes",other:"alrededor de {{count}} meses"},xMonths:{one:"1 mes",other:"{{count}} meses"},aboutXYears:{one:"alrededor de 1 año",other:"alrededor de {{count}} años"},xYears:{one:"1 año",other:"{{count}} años"},overXYears:{one:"más de 1 año",other:"más de {{count}} años"},almostXYears:{one:"casi 1 año",other:"casi {{count}} años"}},Fn={date:Cn({formats:{full:"EEEE, d 'de' MMMM 'de' y",long:"d 'de' MMMM 'de' y",medium:"d MMM y",short:"dd/MM/y"},defaultWidth:"full"}),time:Cn({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Cn({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Un={lastWeek:"'el' eeee 'pasado a la' p",yesterday:"'ayer a la' p",today:"'hoy a la' p",tomorrow:"'mañana a la' p",nextWeek:"eeee 'a la' p",other:"P"},qn={lastWeek:"'el' eeee 'pasado a las' p",yesterday:"'ayer a las' p",today:"'hoy a las' p",tomorrow:"'mañana a las' p",nextWeek:"eeee 'a las' p",other:"P"},On={ordinalNumber:(e,t)=>Number(e)+"º",era:kn({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:kn({values:{narrow:["1","2","3","4"],abbreviated:["T1","T2","T3","T4"],wide:["1º trimestre","2º trimestre","3º trimestre","4º trimestre"]},defaultWidth:"wide",argumentCallback:e=>Number(e)-1}),month:kn({values:{narrow:["e","f","m","a","m","j","j","a","s","o","n","d"],abbreviated:["ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic"],wide:["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"]},defaultWidth:"wide"}),day:kn({values:{narrow:["d","l","m","m","j","v","s"],short:["do","lu","ma","mi","ju","vi","sá"],abbreviated:["dom","lun","mar","mié","jue","vie","sáb"],wide:["domingo","lunes","martes","miércoles","jueves","viernes","sábado"]},defaultWidth:"wide"}),dayPeriod:kn({values:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"},abbreviated:{am:"AM",pm:"PM",midnight:"medianoche",noon:"mediodia",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"},wide:{am:"a.m.",pm:"p.m.",midnight:"medianoche",noon:"mediodia",morning:"mañana",afternoon:"tarde",evening:"tarde",night:"noche"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"},abbreviated:{am:"AM",pm:"PM",midnight:"medianoche",noon:"mediodia",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"},wide:{am:"a.m.",pm:"p.m.",midnight:"medianoche",noon:"mediodia",morning:"de la mañana",afternoon:"de la tarde",evening:"de la tarde",night:"de la noche"}},defaultFormattingWidth:"wide"})},Bn={ordinalNumber:Tn({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:Sn({matchPatterns:{narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|a\.?\s?e\.?\s?c\.?|d\.?\s?c\.?|e\.?\s?c\.?)/i,wide:/^(antes de cristo|antes de la era com[uú]n|despu[eé]s de cristo|era com[uú]n)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^ac/i,/^dc/i],wide:[/^(antes de cristo|antes de la era com[uú]n)/i,/^(despu[eé]s de cristo|era com[uú]n)/i]},defaultParseWidth:"any"}),quarter:Sn({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:Sn({matchPatterns:{narrow:/^[efmajsond]/i,abbreviated:/^(ene|feb|mar|abr|may|jun|jul|ago|sep|oct|nov|dic)/i,wide:/^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^e/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^en/i,/^feb/i,/^mar/i,/^abr/i,/^may/i,/^jun/i,/^jul/i,/^ago/i,/^sep/i,/^oct/i,/^nov/i,/^dic/i]},defaultParseWidth:"any"}),day:Sn({matchPatterns:{narrow:/^[dlmjvs]/i,short:/^(do|lu|ma|mi|ju|vi|s[áa])/i,abbreviated:/^(dom|lun|mar|mi[ée]|jue|vie|s[áa]b)/i,wide:/^(domingo|lunes|martes|mi[ée]rcoles|jueves|viernes|s[áa]bado)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^d/i,/^l/i,/^m/i,/^m/i,/^j/i,/^v/i,/^s/i],any:[/^do/i,/^lu/i,/^ma/i,/^mi/i,/^ju/i,/^vi/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:Sn({matchPatterns:{narrow:/^(a|p|mn|md|(de la|a las) (mañana|tarde|noche))/i,any:/^([ap]\.?\s?m\.?|medianoche|mediodia|(de la|a las) (mañana|tarde|noche))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mn/i,noon:/^md/i,morning:/mañana/i,afternoon:/tarde/i,evening:/tarde/i,night:/noche/i}},defaultParseWidth:"any"})},Hn={code:"es",formatDistance:(e,t,a)=>{let s;const r=zn[e];return s="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"en "+s:"hace "+s:s},formatLong:Fn,formatRelative:(e,t,a,s)=>1!==t.getHours()?qn[e]:Un[e],localize:On,match:Bn,options:{weekStartsOn:1,firstWeekContainsDate:1}},$n={lessThanXSeconds:{one:"menos de um segundo",other:"menos de {{count}} segundos"},xSeconds:{one:"1 segundo",other:"{{count}} segundos"},halfAMinute:"meio minuto",lessThanXMinutes:{one:"menos de um minuto",other:"menos de {{count}} minutos"},xMinutes:{one:"1 minuto",other:"{{count}} minutos"},aboutXHours:{one:"cerca de 1 hora",other:"cerca de {{count}} horas"},xHours:{one:"1 hora",other:"{{count}} horas"},xDays:{one:"1 dia",other:"{{count}} dias"},aboutXWeeks:{one:"cerca de 1 semana",other:"cerca de {{count}} semanas"},xWeeks:{one:"1 semana",other:"{{count}} semanas"},aboutXMonths:{one:"cerca de 1 mês",other:"cerca de {{count}} meses"},xMonths:{one:"1 mês",other:"{{count}} meses"},aboutXYears:{one:"cerca de 1 ano",other:"cerca de {{count}} anos"},xYears:{one:"1 ano",other:"{{count}} anos"},overXYears:{one:"mais de 1 ano",other:"mais de {{count}} anos"},almostXYears:{one:"quase 1 ano",other:"quase {{count}} anos"}},Vn={date:Cn({formats:{full:"EEEE, d 'de' MMMM 'de' y",long:"d 'de' MMMM 'de' y",medium:"d MMM y",short:"dd/MM/yyyy"},defaultWidth:"full"}),time:Cn({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Cn({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Wn={lastWeek:e=>{const t=e.getDay();return"'"+(0===t||6===t?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},Gn={ordinalNumber:(e,t)=>{const a=Number(e);return"week"===t?.unit?a+"ª":a+"º"},era:kn({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:kn({values:{narrow:["1","2","3","4"],abbreviated:["T1","T2","T3","T4"],wide:["1º trimestre","2º trimestre","3º trimestre","4º trimestre"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:kn({values:{narrow:["j","f","m","a","m","j","j","a","s","o","n","d"],abbreviated:["jan","fev","mar","abr","mai","jun","jul","ago","set","out","nov","dez"],wide:["janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"]},defaultWidth:"wide"}),day:kn({values:{narrow:["D","S","T","Q","Q","S","S"],short:["dom","seg","ter","qua","qui","sex","sab"],abbreviated:["domingo","segunda","terça","quarta","quinta","sexta","sábado"],wide:["domingo","segunda-feira","terça-feira","quarta-feira","quinta-feira","sexta-feira","sábado"]},defaultWidth:"wide"}),dayPeriod:kn({values:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"}},defaultFormattingWidth:"wide"})},Yn={ordinalNumber:Tn({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Sn({matchPatterns:{narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|d\.?\s?c\.?)/i,wide:/^(antes de cristo|depois de cristo)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^ac/i,/^dc/i],wide:[/^antes de cristo/i,/^depois de cristo/i]},defaultParseWidth:"any"}),quarter:Sn({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:Sn({matchPatterns:{narrow:/^[jfmajsond]/i,abbreviated:/^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,wide:/^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^fev/i,/^mar/i,/^abr/i,/^mai/i,/^jun/i,/^jul/i,/^ago/i,/^set/i,/^out/i,/^nov/i,/^dez/i]},defaultParseWidth:"any"}),day:Sn({matchPatterns:{narrow:/^(dom|[23456]ª?|s[aá]b)/i,short:/^(dom|[23456]ª?|s[aá]b)/i,abbreviated:/^(dom|seg|ter|qua|qui|sex|s[aá]b)/i,wide:/^(domingo|(segunda|ter[cç]a|quarta|quinta|sexta)([- ]feira)?|s[aá]bado)/i},defaultMatchWidth:"wide",parsePatterns:{short:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],narrow:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],any:[/^d/i,/^seg/i,/^t/i,/^qua/i,/^qui/i,/^sex/i,/^s[aá]b/i]},defaultParseWidth:"any"}),dayPeriod:Sn({matchPatterns:{narrow:/^(a|p|mn|md|(da) (manhã|tarde|noite))/i,any:/^([ap]\.?\s?m\.?|meia[-\s]noite|meio[-\s]dia|(da) (manhã|tarde|noite))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mn|^meia[-\s]noite/i,noon:/^md|^meio[-\s]dia/i,morning:/manhã/i,afternoon:/tarde/i,evening:/tarde/i,night:/noite/i}},defaultParseWidth:"any"})},Qn={code:"pt-BR",formatDistance:(e,t,a)=>{let s;const r=$n[e];return s="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",String(t)),a?.addSuffix?a.comparison&&a.comparison>0?"em "+s:"há "+s:s},formatLong:Vn,formatRelative:(e,t,a,s)=>{const r=Wn[e];return"function"==typeof r?r(t):r},localize:Gn,match:Yn,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Kn({className:t,classNames:a,showOutsideDays:s=!0,...r}){return e.jsx(M.DayPicker,{showOutsideDays:s,className:Te("p-3 pointer-events-auto",t),locale:Qn,classNames:{months:"relative flex flex-col gap-4 sm:flex-row",month:"flex flex-col gap-4",month_caption:"flex h-9 w-full items-center justify-center px-8",caption_label:"text-sm font-medium",nav:"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1 px-1",button_previous:Te(Ae({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),button_next:Te(Ae({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),month_grid:"w-full border-collapse",weekdays:"flex",weekday:"text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal w-9",week:"mt-2 flex w-full",day:"group/day relative h-9 w-9 select-none p-0 text-center text-sm [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md focus-within:relative focus-within:z-20",day_button:Te(Ae({variant:"ghost"}),"h-9 w-9 p-0 font-normal transition-none aria-selected:opacity-100"),range_start:"bg-accent rounded-l-md",range_end:"bg-accent rounded-r-md",range_middle:"rounded-none aria-selected:bg-accent aria-selected:text-accent-foreground",selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground rounded-md",today:"bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",outside:"text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",disabled:"text-muted-foreground opacity-50",hidden:"invisible",...a},components:{Chevron:({orientation:t})=>"left"===t?e.jsx(l.ChevronLeft,{className:"h-4 w-4"}):e.jsx(l.ChevronRight,{className:"h-4 w-4"})},...r})}Kn.displayName="Calendar";const Xn={Root:function({children:t,className:a}){return e.jsx("div",{className:Te("space-y-4",a),children:t})},Item:function({children:t,onClick:a,className:s}){return e.jsx(Re,{className:Te("transition-colors",a&&"cursor-pointer hover:bg-muted/50",s),onClick:a,children:e.jsx(Ue,{className:"p-4",children:t})})},Field:function({label:t,value:a,className:s}){return e.jsxs("div",{className:Te("flex justify-between items-center text-sm",s),children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[t,":"]}),e.jsx("span",{className:"text-foreground",children:a})]})}};const Zn=({shouldScaleBackground:t=!0,...a})=>e.jsx(I.Drawer.Root,{shouldScaleBackground:t,...a});Zn.displayName="Drawer";const Jn=I.Drawer.Trigger,eo=I.Drawer.Portal,to=I.Drawer.Close,ao=J.forwardRef(({className:t,...a},s)=>e.jsx(I.Drawer.Overlay,{ref:s,className:Te("fixed inset-0 z-50 bg-black/80",t),...a}));ao.displayName=I.Drawer.Overlay.displayName;const so=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(eo,{children:[e.jsx(ao,{}),e.jsxs(I.Drawer.Content,{ref:r,className:Te("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",t),...s,children:[e.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),a]})]}));so.displayName="DrawerContent";const ro=({className:t,...a})=>e.jsx("div",{className:Te("grid gap-1.5 p-4 text-center sm:text-left",t),...a});ro.displayName="DrawerHeader";const no=({className:t,...a})=>e.jsx("div",{className:Te("mt-auto flex flex-col gap-2 p-4",t),...a});no.displayName="DrawerFooter";const oo=J.forwardRef(({className:t,...a},s)=>e.jsx(I.Drawer.Title,{ref:s,className:Te("text-lg font-semibold leading-none tracking-tight",t),...a}));oo.displayName=I.Drawer.Title.displayName;const io=J.forwardRef(({className:t,...a},s)=>e.jsx(I.Drawer.Description,{ref:s,className:Te("text-sm text-muted-foreground",t),...a}));io.displayName=I.Drawer.Description.displayName;const lo={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5",6:"grid-cols-6","auto-fit":"grid-cols-[repeat(auto-fit,minmax(250px,1fr))]","auto-fill":"grid-cols-[repeat(auto-fill,minmax(250px,1fr))]"},co={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};const uo=ge.Root,mo=ge.Trigger,po=J.forwardRef(({className:t,align:a="center",sideOffset:s=4,...r},n)=>e.jsx(ge.Content,{ref:n,align:a,sideOffset:s,className:Te("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r}));po.displayName=ge.Content.displayName;const ho=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-slot":"input-group",className:Te("flex min-w-0 items-center rounded-md border border-input bg-background","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background","has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50","has-[textarea:disabled]:cursor-not-allowed has-[textarea:disabled]:opacity-50",t),...a}));ho.displayName="InputGroup";const fo=s.cva("flex items-center justify-center text-sm text-muted-foreground shrink-0",{variants:{align:{"inline-start":"border-r border-input px-3","inline-end":"border-l border-input px-3","block-start":"border-b border-input px-3 py-2 w-full justify-start","block-end":"border-t border-input px-3 py-2 w-full justify-start"}},defaultVariants:{align:"inline-start"}}),xo=J.forwardRef(({className:t,align:a,...s},r)=>e.jsx("div",{ref:r,"data-slot":"input-group-addon",className:Te(fo({align:a}),t),...s}));xo.displayName="InputGroupAddon";const go=s.cva("",{variants:{size:{xs:"h-6 px-2 text-xs","icon-xs":"h-6 w-6",sm:"h-7 px-3 text-xs","icon-sm":"h-7 w-7"}},defaultVariants:{size:"xs"}}),bo=J.forwardRef(({className:t,size:a,variant:s="ghost",...r},n)=>e.jsx(Ee,{ref:n,"data-slot":"input-group-button",variant:s,className:Te(go({size:a}),"rounded-none first:rounded-l-md last:rounded-r-md",t),...r}));bo.displayName="InputGroupButton";const vo=J.forwardRef(({className:t,...a},s)=>e.jsx(Me,{ref:s,"data-slot":"input-group-control",className:Te("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",t),...a}));vo.displayName="InputGroupInput";const wo=J.forwardRef(({className:t,...a},s)=>e.jsx(wt,{ref:s,"data-slot":"input-group-control",className:Te("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",t),...a}));wo.displayName="InputGroupTextarea";const No=J.forwardRef(({className:t,...a},s)=>e.jsx("h1",{ref:s,className:Te("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",t),...a}));No.displayName="H1";const yo=J.forwardRef(({className:t,...a},s)=>e.jsx("h2",{ref:s,className:Te("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",t),...a}));yo.displayName="H2";const jo=J.forwardRef(({className:t,...a},s)=>e.jsx("h3",{ref:s,className:Te("scroll-m-20 text-2xl font-semibold tracking-tight",t),...a}));jo.displayName="H3";const Co=J.forwardRef(({className:t,...a},s)=>e.jsx("h4",{ref:s,className:Te("scroll-m-20 text-xl font-semibold tracking-tight",t),...a}));Co.displayName="H4";const ko=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Te("leading-7 [&:not(:first-child)]:mt-6",t),...a}));ko.displayName="P";const So=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Te("text-xl text-muted-foreground",t),...a}));So.displayName="Lead";const To=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Te("text-lg font-semibold",t),...a}));To.displayName="Large";const _o=J.forwardRef(({className:t,...a},s)=>e.jsx("small",{ref:s,className:Te("text-sm font-medium leading-none",t),...a}));_o.displayName="Small";const Ao=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Te("text-sm text-muted-foreground",t),...a}));Ao.displayName="Muted";const Eo=J.forwardRef(({className:t,...a},s)=>e.jsx("code",{ref:s,className:Te("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",t),...a}));Eo.displayName="InlineCode";const Po=J.forwardRef(({className:t,...a},s)=>e.jsx("blockquote",{ref:s,className:Te("mt-6 border-l-2 pl-6 italic",t),...a}));Po.displayName="Blockquote";const Mo=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,className:Te("my-6 ml-6 list-disc [&>li]:mt-2",t),...a}));Mo.displayName="List";const Io=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(be.Root,{ref:r,className:Te("relative z-10 flex max-w-max flex-1 items-center justify-center",t),...s,children:[a,e.jsx(qo,{})]}));Io.displayName=be.Root.displayName;const Do=J.forwardRef(({className:t,...a},s)=>e.jsx(be.List,{ref:s,className:Te("group flex flex-1 list-none items-center justify-center space-x-1",t),...a}));Do.displayName=be.List.displayName;const Ro=be.Item,Lo=s.cva("group inline-flex h-10 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50"),zo=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(be.Trigger,{ref:r,className:Te(Lo(),"group",t),...s,children:[a," ",e.jsx(l.ChevronDown,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));zo.displayName=be.Trigger.displayName;const Fo=J.forwardRef(({className:t,...a},s)=>e.jsx(be.Content,{ref:s,className:Te("left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto ",t),...a}));Fo.displayName=be.Content.displayName;const Uo=be.Link,qo=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{className:Te("absolute left-0 top-full flex justify-center"),children:e.jsx(be.Viewport,{className:Te("origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]",t),ref:s,...a})}));qo.displayName=be.Viewport.displayName;const Oo=J.forwardRef(({className:t,...a},s)=>e.jsx(be.Indicator,{ref:s,className:Te("top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in",t),...a,children:e.jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));Oo.displayName=be.Indicator.displayName;const Bo=({className:t,...a})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:Te("mx-auto flex w-full justify-center",t),...a});Bo.displayName="Pagination";const Ho=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,className:Te("flex flex-row items-center gap-1",t),...a}));Ho.displayName="PaginationContent";const $o=J.forwardRef(({className:t,...a},s)=>e.jsx("li",{ref:s,className:Te("",t),...a}));$o.displayName="PaginationItem";const Vo=({className:t,isActive:a,size:s="icon",...r})=>e.jsx("a",{"aria-current":a?"page":void 0,className:Te(Ae({variant:a?"outline":"ghost",size:s}),t),...r});Vo.displayName="PaginationLink";const Wo=({className:t,...a})=>e.jsxs(Vo,{"aria-label":"Go to previous page",size:"default",className:Te("gap-1 pl-2.5",t),...a,children:[e.jsx(l.ChevronLeft,{className:"h-4 w-4"}),e.jsx("span",{children:"Previous"})]});Wo.displayName="PaginationPrevious";const Go=({className:t,...a})=>e.jsxs(Vo,{"aria-label":"Go to next page",size:"default",className:Te("gap-1 pr-2.5",t),...a,children:[e.jsx("span",{children:"Next"}),e.jsx(l.ChevronRight,{className:"h-4 w-4"})]});Go.displayName="PaginationNext";const Yo=({className:t,...a})=>e.jsxs("span",{"aria-hidden":!0,className:Te("flex h-9 w-9 items-center justify-center",t),...a,children:[e.jsx(l.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]});Yo.displayName="PaginationEllipsis";const Qo=J.forwardRef(({className:t,value:a,...s},r)=>e.jsx(ve.Root,{ref:r,className:Te("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",t),...s,children:e.jsx(ve.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(a||0)}%)`}})}));Qo.displayName=ve.Root.displayName;const Ko=J.forwardRef(({className:t,...a},s)=>e.jsx(we.Root,{className:Te("grid gap-2",t),...a,ref:s}));Ko.displayName=we.Root.displayName;const Xo=J.forwardRef(({className:t,...a},s)=>e.jsx(we.Item,{ref:s,className:Te("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...a,children:e.jsx(we.Indicator,{className:"flex items-center justify-center",children:e.jsx(l.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Xo.displayName=we.Item.displayName;const Zo=Ne.Panel,Jo=te.Root,ei=te.Trigger,ti=te.Close,ai=te.Portal,si=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Overlay,{className:Te("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a,ref:s}));si.displayName=te.Overlay.displayName;const ri=s.cva("fixed z-50 flex flex-col bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b max-h-[70vh] data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t max-h-[70vh] data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),ni=J.forwardRef(({side:t="right",className:a,children:s,...r},n)=>e.jsxs(ai,{children:[e.jsx(si,{}),e.jsxs(te.Content,{ref:n,className:Te(ri({side:t}),a),...r,children:[s,e.jsxs(te.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-0 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[e.jsx(l.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ni.displayName=te.Content.displayName;const oi=({className:t,showSeparator:a=!1,children:s,...r})=>e.jsxs("div",{className:Te("flex flex-col flex-shrink-0",t),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),a&&e.jsx(Oe,{className:"mt-2"})]});oi.displayName="SheetHeader";const ii=({className:t,...a})=>e.jsx("div",{className:Te("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",t),...a});ii.displayName="SheetBody";const li=({className:t,children:a,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Oe,{className:"mb-4"}),e.jsx("div",{className:Te("flex flex-row justify-end gap-2",t),...s,children:a})]});li.displayName="SheetFooter";const di=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Title,{ref:s,className:Te("text-lg font-semibold text-foreground",t),...a}));di.displayName=te.Title.displayName;const ci=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Description,{ref:s,className:Te("text-sm text-muted-foreground",t),...a}));ci.displayName=te.Description.displayName;const ui="sidebar:state",mi=J.createContext(null);function pi(){const e=J.useContext(mi);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const hi=J.forwardRef(({defaultOpen:t=!0,open:a,onOpenChange:s,className:r,style:n,children:o,...i},l)=>{const[d,c]=J.useState(!1);J.useEffect(()=>{const e=()=>c(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[u,m]=J.useState(!1),[p,h]=J.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(ui);return null!==e?"true"===e:t}return t}),f=a??p,x=J.useCallback(e=>{const t="function"==typeof e?e(f):e;s?s(t):h(t),"undefined"!=typeof window&&localStorage.setItem(ui,String(t))},[s,f]),g=J.useCallback(()=>d?m(e=>!e):x(e=>!e),[d,x,m]);J.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),g())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[g]);const b=f?"expanded":"collapsed",v=J.useMemo(()=>({state:b,open:f,setOpen:x,isMobile:d,openMobile:u,setOpenMobile:m,toggleSidebar:g}),[b,f,x,d,u,m,g]);return e.jsx(mi.Provider,{value:v,children:e.jsx(Ot,{delayDuration:0,children:e.jsx("div",{className:Te("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",r),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4rem",...n},ref:l,...i,children:o})})})});hi.displayName="SidebarProvider";const fi=J.forwardRef(({side:t="left",variant:a="sidebar",collapsible:s="offcanvas",className:r,children:n,...o},i)=>{const{isMobile:l,state:d,openMobile:c,setOpenMobile:u}=pi();return"none"===s?e.jsx("div",{className:Te("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...o,children:n}):l?e.jsx(Jo,{open:c,onOpenChange:u,...o,children:e.jsxs(ni,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden sidebar-mobile",style:{"--sidebar-width":"18rem"},side:t,children:[e.jsx(di,{className:"sr-only",children:"Menu de Navegação"}),e.jsx("div",{className:"flex h-full w-full flex-col",children:n})]})}):e.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":d,"data-collapsible":"collapsed"===d?s:"","data-variant":a,"data-side":t,children:[e.jsx("div",{className:Te("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===a||"inset"===a?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),e.jsx("div",{className:Te("duration-200 fixed inset-y-0 z-30 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex overflow-visible","left"===t?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===a||"inset"===a?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...o,children:e.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col overflow-visible group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow bg-white",children:n})})]})});fi.displayName="Sidebar";const xi=J.forwardRef(({className:t,onClick:a,...s},r)=>{const{toggleSidebar:n}=pi();return e.jsxs(Ee,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Te("h-7 w-7",t),onClick:e=>{a?.(e),n()},...s,children:[e.jsx(l.PanelLeft,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});xi.displayName="SidebarTrigger";const gi=J.forwardRef(({className:t,...a},s)=>{const{toggleSidebar:r}=pi();return e.jsx("button",{ref:s,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Te("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",t),...a})});gi.displayName="SidebarRail";const bi=J.forwardRef(({className:t,...a},s)=>e.jsx("main",{ref:s,className:Te("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",t),...a}));bi.displayName="SidebarInset";const vi=J.forwardRef(({className:t,...a},s)=>e.jsx(Me,{ref:s,"data-sidebar":"input",className:Te("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",t),...a}));vi.displayName="SidebarInput";const wi=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"header",className:Te("flex flex-col gap-2 p-2",t),...a}));wi.displayName="SidebarHeader";const Ni=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"footer",className:Te("flex flex-col gap-2 p-2",t),...a}));Ni.displayName="SidebarFooter";const yi=J.forwardRef(({className:t,...a},s)=>e.jsx(Oe,{ref:s,"data-sidebar":"separator",className:Te("mx-2 w-auto bg-sidebar-border",t),...a}));yi.displayName="SidebarSeparator";const ji=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"content",className:Te("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),...a}));ji.displayName="SidebarContent";const Ci=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"group",className:Te("relative flex w-full min-w-0 flex-col p-2",t),...a}));Ci.displayName="SidebarGroup";const ki=J.forwardRef(({className:t,asChild:s=!1,...r},n)=>{const o=s?a.Slot:"div";return e.jsx(o,{ref:n,"data-sidebar":"group-label",className:Te("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",t),...r})});ki.displayName="SidebarGroupLabel";const Si=J.forwardRef(({className:t,asChild:s=!1,...r},n)=>{const o=s?a.Slot:"button";return e.jsx(o,{ref:n,"data-sidebar":"group-action",className:Te("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",t),...r})});Si.displayName="SidebarGroupAction";const Ti=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"group-content",className:Te("w-full text-sm",t),...a}));Ti.displayName="SidebarGroupContent";const _i=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu",className:Te("flex w-full min-w-0 flex-col gap-1",t),...a}));_i.displayName="SidebarMenu";const Ai=J.forwardRef(({className:t,...a},s)=>e.jsx("li",{ref:s,"data-sidebar":"menu-item",className:Te("group/menu-item relative",t),...a}));Ai.displayName="SidebarMenuItem";const Ei=s.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-primary/10 data-[active=true]:font-medium data-[active=true]:text-primary data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 group-data-[collapsible=icon]:[&>*]:!mr-0 group-data-[collapsible=icon]:[&>*]:!ml-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-10 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),Pi=J.forwardRef(({asChild:t=!1,isActive:s=!1,variant:r="default",size:n="default",tooltip:o,className:i,...l},d)=>{const c=t?a.Slot:"button",{isMobile:u,state:m}=pi(),p=e.jsx(c,{ref:d,"data-sidebar":"menu-button","data-size":n,"data-active":s,className:Te(Ei({variant:r,size:n}),i),...l});return o?("string"==typeof o&&(o={children:o}),e.jsxs(Bt,{children:[e.jsx(Ht,{asChild:!0,children:p}),e.jsx($t,{side:"right",align:"center",hidden:"collapsed"!==m||u,...o})]})):p});Pi.displayName="SidebarMenuButton";const Mi=J.forwardRef(({className:t,asChild:s=!1,showOnHover:r=!1,...n},o)=>{const i=s?a.Slot:"button";return e.jsx(i,{ref:o,"data-sidebar":"menu-action",className:Te("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",r&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",t),...n})});Mi.displayName="SidebarMenuAction";const Ii=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"menu-badge",className:Te("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",t),...a}));Ii.displayName="SidebarMenuBadge";const Di=J.forwardRef(({className:t,showIcon:a=!1,...s},r)=>{const n=J.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return e.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:Te("rounded-md h-8 flex gap-2 px-2 items-center",t),...s,children:[a&&e.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),e.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});Di.displayName="SidebarMenuSkeleton";const Ri=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu-sub",className:Te("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",t),...a}));Ri.displayName="SidebarMenuSub";const Li=J.forwardRef(({...t},a)=>e.jsx("li",{ref:a,...t}));Li.displayName="SidebarMenuSubItem";const zi=J.forwardRef(({asChild:t=!1,size:s="md",isActive:r,className:n,...o},i)=>{const l=t?a.Slot:"a";return e.jsx(l,{ref:i,"data-sidebar":"menu-sub-button","data-size":s,"data-active":r,className:Te("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground","sm"===s&&"text-xs","md"===s&&"text-sm","group-data-[collapsible=icon]:hidden",n),...o})});zi.displayName="SidebarMenuSubButton";const Fi=J.forwardRef(({className:t,value:a,defaultValue:s,...r},n)=>{const o=a||s||[0];return e.jsxs(ye.Root,{ref:n,value:a,defaultValue:s,className:Te("relative flex w-full touch-none select-none items-center",t),...r,children:[e.jsx(ye.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(ye.Range,{className:"absolute h-full bg-primary"})}),o.map((t,a)=>e.jsx(ye.Thumb,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"},a))]})});Fi.displayName=ye.Root.displayName;const Ui=je.Root,qi=J.forwardRef(({className:t,...a},s)=>e.jsx(je.List,{ref:s,className:Te("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...a}));qi.displayName=je.List.displayName;const Oi=J.forwardRef(({className:t,...a},s)=>e.jsx(je.Trigger,{ref:s,className:Te("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t),...a}));Oi.displayName=je.Trigger.displayName;const Bi=J.forwardRef(({className:t,...a},s)=>e.jsx(je.Content,{ref:s,className:Te("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...a}));Bi.displayName=je.Content.displayName;const Hi=Ce.Menu,$i=Ce.Group,Vi=Ce.Portal,Wi=Ce.Sub,Gi=Ce.RadioGroup,Yi=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.Root,{ref:s,className:Te("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",t),...a}));Yi.displayName=Ce.Root.displayName;const Qi=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.Trigger,{ref:s,className:Te("flex cursor-default select-none items-center rounded-sm px-3 py-1.5 text-sm font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",t),...a}));Qi.displayName=Ce.Trigger.displayName;const Ki=J.forwardRef(({className:t,inset:a,children:s,...r},n)=>e.jsxs(Ce.SubTrigger,{ref:n,className:Te("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",a&&"pl-8",t),...r,children:[s,e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Ki.displayName=Ce.SubTrigger.displayName;const Xi=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.SubContent,{ref:s,className:Te("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a}));Xi.displayName=Ce.SubContent.displayName;const Zi=J.forwardRef(({className:t,align:a="start",alignOffset:s=-4,sideOffset:r=8,...n},o)=>e.jsx(Ce.Portal,{children:e.jsx(Ce.Content,{ref:o,align:a,alignOffset:s,sideOffset:r,className:Te("z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));Zi.displayName=Ce.Content.displayName;const Ji=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(Ce.Item,{ref:r,className:Te("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",t),...s}));Ji.displayName=Ce.Item.displayName;const el=J.forwardRef(({className:t,children:a,checked:s,...r},n)=>e.jsxs(Ce.CheckboxItem,{ref:n,className:Te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Ce.ItemIndicator,{children:e.jsx(l.Check,{className:"h-4 w-4"})})}),a]}));el.displayName=Ce.CheckboxItem.displayName;const tl=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(Ce.RadioItem,{ref:r,className:Te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Ce.ItemIndicator,{children:e.jsx(l.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));tl.displayName=Ce.RadioItem.displayName;const al=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(Ce.Label,{ref:r,className:Te("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",t),...s}));al.displayName=Ce.Label.displayName;const sl=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.Separator,{ref:s,className:Te("-mx-1 my-1 h-px bg-muted",t),...a}));sl.displayName=Ce.Separator.displayName;const rl=({className:t,...a})=>e.jsx("span",{className:Te("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});rl.displayname="MenubarShortcut";const nl={light:"",dark:".dark"},ol=J.createContext(null);function il(){const e=J.useContext(ol);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const ll=J.forwardRef(({id:t,className:a,children:s,config:r,...n},o)=>{const i=J.useId(),l=`chart-${t||i.replace(/:/g,"")}`;return e.jsx(ol.Provider,{value:{config:r},children:e.jsxs("div",{"data-chart":l,ref:o,className:Te("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",a),...n,children:[e.jsx(dl,{id:l,config:r}),e.jsx(ke.ResponsiveContainer,{children:s})]})})});ll.displayName="Chart";const dl=({id:t,config:a})=>{const s=Object.entries(a).filter(([,e])=>e.theme||e.color);return s.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(nl).map(([e,a])=>`\n${a} [data-chart=${t}] {\n${s.map(([t,a])=>{const s=a.theme?.[e]||a.color;return s?` --color-${t}: ${s};`:null}).join("\n")}\n}\n`).join("\n")}}):null},cl=ke.Tooltip,ul=J.forwardRef(({active:t,payload:a,className:s,indicator:r="dot",hideLabel:n=!1,hideIndicator:o=!1,label:i,labelFormatter:l,labelClassName:d,formatter:c,color:u,nameKey:m,labelKey:p},h)=>{const{config:f}=il(),x=J.useMemo(()=>{if(n||!a?.length)return null;const[t]=a,s=hl(f,t,`${p||t?.dataKey||t?.name||"value"}`),r=p||"string"!=typeof i?s?.label:f[i]?.label||i;return l?e.jsx("div",{className:Te("font-medium",d),children:l(r,a)}):r?e.jsx("div",{className:Te("font-medium",d),children:r}):null},[i,l,a,n,d,f,p]);if(!t||!a?.length)return null;const g=1===a.length&&"dot"!==r;return e.jsxs("div",{ref:h,className:Te("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",s),children:[g?null:x,e.jsx("div",{className:"grid gap-1.5",children:a.map((t,a)=>{const s=`${m||t.name||t.dataKey||"value"}`,n=hl(f,t,s),i=u||t.payload?.fill||t.color;return e.jsx("div",{className:Te("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===r&&"items-center"),children:c&&void 0!==t?.value&&t.name?c(t.value,t.name,t,a,t.payload):e.jsxs(e.Fragment,{children:[n?.icon?e.jsx(n.icon,{}):!o&&e.jsx("div",{className:Te("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":"dot"===r,"w-1":"line"===r,"w-0 border-[1.5px] border-dashed bg-transparent":"dashed"===r,"my-0.5":g&&"dashed"===r}),style:{"--color-bg":i,"--color-border":i}}),e.jsxs("div",{className:Te("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[g?x:null,e.jsx("span",{className:"text-muted-foreground",children:n?.label||t.name})]}),void 0!==t.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof t.value?t.value.toLocaleString():t.value})]})]})},t.dataKey||a)})})]})});ul.displayName="ChartTooltip";const ml=ke.Legend,pl=J.forwardRef(({className:t,hideIcon:a=!1,payload:s,verticalAlign:r="bottom",nameKey:n},o)=>{const{config:i}=il();return s?.length?e.jsx("div",{ref:o,className:Te("flex items-center justify-center gap-4","top"===r?"pb-3":"pt-3",t),children:s.map(t=>{const s=`${n||t.dataKey||"value"}`,r=hl(i,t,s);return e.jsxs("div",{className:Te("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[r?.icon&&!a?e.jsx(r.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:t.color}}),r?.label]},t.value)})}):null});function hl(e,t,a){if("object"!=typeof t||null===t)return;const s="payload"in t&&"object"==typeof t.payload&&null!==t.payload?t.payload:void 0;let r=a;return a in t&&"string"==typeof t[a]?r=t[a]:s&&a in s&&"string"==typeof s[a]&&(r=s[a]),r in e?e[r]:e[a]}pl.displayName="ChartLegend";const fl=({onClick:t,isActive:a,disabled:s,children:r,title:n})=>e.jsx("button",{type:"button",onClick:t,disabled:s,title:n,className:Te("p-1.5 rounded hover:bg-muted transition-colors",a?"bg-muted text-primary":"text-muted-foreground",s&&"opacity-50 cursor-not-allowed"),children:r}),xl=()=>e.jsx("div",{className:"w-px h-5 bg-border mx-1"});function gl({image:t,title:a,className:s}){return e.jsx("div",{className:Te("relative w-full aspect-video bg-muted rounded-lg overflow-hidden","max-h-[25vh] sm:max-h-[35vh]",s),children:t?e.jsx("img",{src:t,alt:a,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(l.ImageIcon,{className:"w-16 h-16 text-muted-foreground"})})})}function bl({steps:t,currentStepIndex:a,onStepSelect:s,stepLabel:r,className:n}){const o=t.length,i=(a+1)/o*100;return e.jsxs("div",{className:Te("flex items-center gap-3",n),children:[e.jsxs(St,{children:[e.jsx(Tt,{asChild:!0,children:e.jsxs(Ee,{variant:"ghost",size:"sm",className:"h-8 px-2 text-sm",children:[r," ",a+1,"/",o,e.jsx(l.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),e.jsx(Dt,{align:"start",children:t.map((t,r)=>e.jsxs(Rt,{onClick:()=>s(r),className:Te(r===a&&"bg-accent"),children:[r+1,". ",t.title]},t.id))})]}),e.jsx(Qo,{value:i,className:"w-32 h-2"})]})}function vl({currentStepIndex:t,totalSteps:a,onBack:s,onNext:r,onComplete:n,backButtonText:o,continueButtonText:i,finishButtonText:d,className:c}){const u=0===t,m=t===a-1;return e.jsxs("div",{className:Te("flex items-center gap-2",c),children:[!u&&e.jsxs(Ee,{variant:"outline",onClick:s,size:"sm",children:[e.jsx(l.ArrowLeft,{className:"h-4 w-4 mr-2"}),o]}),e.jsxs(Ee,{onClick:m?n:r,size:"sm",children:[m?d:i,!m&&e.jsx(l.ArrowRight,{className:"h-4 w-4 ml-2"})]})]})}const wl=J.forwardRef(({open:t,onOpenChange:a,steps:s,onComplete:r,onStepChange:n,continueButtonText:o="Continuar",backButtonText:i="Voltar",finishButtonText:d="Concluir",stepLabel:c="Etapa",size:u="md",showProgressIndicator:m=!0,currentStepIndex:p,onCurrentStepChange:h,className:f},x)=>{const[g,b]=J.useState(0),v=void 0!==p,w=v?p:g,N=J.useCallback(e=>{v?h?.(e):b(e),n?.(e)},[v,h,n]);J.useEffect(()=>{t||v||b(0)},[t,v]);const y=s[w],j=s.length;return y?e.jsx(Be,{open:t,onOpenChange:a,children:e.jsxs(Ye,{ref:x,size:u,className:Te("p-0 gap-0 overflow-hidden",f),children:[e.jsxs(Ve,{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 data-[state=open]:bg-accent data-[state=open]:text-muted-foreground z-10",children:[e.jsx(l.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Fechar"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx(gl,{image:y.image,title:y.title}),e.jsx(Ze,{className:"text-xl font-semibold",children:y.title}),e.jsx(Je,{className:"text-muted-foreground",children:y.description})]})}),e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx(Oe,{}),e.jsxs("div",{className:"p-4 flex flex-wrap items-center justify-between gap-2",children:[m&&j>1?e.jsx(bl,{steps:s,currentStepIndex:w,onStepSelect:e=>{N(e)},stepLabel:c}):e.jsx("div",{}),e.jsx(vl,{currentStepIndex:w,totalSteps:j,onBack:()=>{w>0&&N(w-1)},onNext:()=>{w<j-1&&N(w+1)},onComplete:()=>{r?.(),a(!1)},backButtonText:i,continueButtonText:o,finishButtonText:d})]})]})]})}):null});wl.displayName="OnboardingDialog";const Nl=t.memo(({checked:t,onCheckedChange:a})=>e.jsx(vt,{checked:t,onCheckedChange:a}),(e,t)=>e.checked===t.checked);function yl({onEdit:t,onDelete:a,onToggleStatus:s,isActive:r=!0,canEdit:n=!0,canDelete:o=!0,customActions:i=[],renderAs:d="dropdown",variant:c="default"}){const u=[];return t&&n&&u.push({icon:l.Edit,label:"Editar",onClick:t,variant:"default"}),s&&u.push({icon:r?l.PowerOff:l.Power,label:r?"Inativar":"Ativar",onClick:s,variant:"default"}),i.forEach(e=>{!1!==e.show&&u.push({icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default",disabled:e.disabled,disabledReason:e.disabledReason})}),a&&o&&u.push({icon:l.Trash2,label:"Remover",onClick:a,variant:"destructive"}),0===u.length?null:"dropdown"===d?e.jsx(Ot,{delayDuration:200,children:e.jsxs(St,{children:[e.jsx(Tt,{asChild:!0,children:e.jsx(Ee,{variant:"ghost",size:"compact"===c?"sm":"default",className:"compact"===c?"h-7 px-2":"",children:e.jsx(l.EllipsisVertical,{size:"compact"===c?14:16})})}),e.jsx(Dt,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:u.map((t,a)=>t.disabled?e.jsxs(Vt,{disabledReason:t.disabledReason,className:"destructive"===t.variant?"text-destructive":"",children:[t.icon&&e.jsx(t.icon,{className:"mr-2 h-4 w-4"}),t.label]},a):e.jsxs(Rt,{onClick:t.onClick,className:"destructive"===t.variant?"text-destructive":"",children:[t.icon&&e.jsx(t.icon,{className:"mr-2 h-4 w-4"}),t.label]},a))})]})}):e.jsx("div",{className:"flex items-center gap-1",children:u.map((t,a)=>e.jsxs(Ee,{variant:"destructive"===t.variant?"destructive":"ghost",size:"compact"===c?"sm":"default",onClick:t.onClick,className:"compact"===c?"h-7 px-2":"",children:[t.icon&&e.jsx(t.icon,{size:"compact"===c?14:16}),"compact"!==c&&e.jsx("span",{className:"ml-1",children:t.label})]},a))})}function jl(e){const t=w.useNavigate();return{onNew:()=>{const a=e.newPath||`${e.basePath}/new`;t(a)},onEdit:a=>{const s=e.editPath?e.editPath.replace(":id",a.id):`${e.basePath}/${a.id}/edit`;t(s)}}}const Cl=t.memo(({variant:a="card",className:s="",selectedUnit:r,onUnitChange:n})=>{const{user:o,companies:i,alias:d,isAuthenticated:c,logout:u,switchUnit:m}=ls(),p=i?.[0]||null,h=d?i?.find(e=>e.alias===d):p,f=i||[],x=r||h||p||p,g=t.useCallback(e=>{n?n(e):m(e)},[n,m]),b=t.useMemo(()=>{if(!f?.length)return[];const e=new Map;f.forEach(t=>{e.set(t.alias,t)});const t=Array.from(e.values()),a=t.find(e=>e.alias===x?.alias),s=t.filter(e=>e.alias!==x?.alias);return s.sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"})),a?[a,...s]:s},[f,x?.alias]);if(!c||!o)return null;const v=()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:e.jsx(l.User,{className:"h-5 w-5 text-primary-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:o.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",x?.name||"N/A"]})]})]}),x&&e.jsx("div",{className:"mt-3",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:x.name})]})}),b.length>1&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",b.length]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[b.slice(0,3).map(t=>e.jsx(yt,{variant:t.alias===x?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>g(t),children:t.name},t.alias)),b.length>3&&e.jsxs(yt,{variant:"outline",className:"text-xs",children:["+",b.length-3]})]})]})]});return"dropdown"===a?e.jsxs(St,{children:[e.jsx(Tt,{asChild:!0,children:e.jsx(Ee,{variant:"ghost",className:`h-auto p-2 ${s}`,children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("div",{className:"hidden md:block text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:o.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:x?.name||"N/A"})]}),e.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:e.jsx(l.User,{className:"h-4 w-4 text-primary-foreground"})}),e.jsx(l.ChevronDown,{className:"h-4 w-4"})]})})}),e.jsxs(Dt,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[e.jsxs(Et,{children:[e.jsxs(Mt,{children:[e.jsx(l.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),e.jsx(It,{children:b.map(t=>e.jsxs(Rt,{onClick:()=>g(t),className:t.alias===x?.alias?"bg-muted":"",children:[e.jsx(l.Building2,{className:"mr-2 h-4 w-4"}),t.name,t.alias===x?.alias&&e.jsx(yt,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},t.alias))})]}),e.jsx(Ut,{}),e.jsxs(Rt,{onClick:u,children:[e.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}):e.jsxs(Re,{className:s,children:[e.jsx(Le,{children:e.jsx(ze,{className:"text-lg",children:"Informações do Usuário"})}),e.jsxs(Ue,{className:"space-y-4",children:[e.jsx(v,{}),e.jsx(Oe,{}),e.jsxs(Ee,{variant:"outline",onClick:u,size:"sm",className:"w-full",children:[e.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),kl=t.createContext({});function Sl({children:a,config:s}){const r=t.useMemo(()=>({navigation:s?.navigation,appName:s?.appName}),[s?.navigation,s?.appName]);return e.jsx(kl.Provider,{value:r,children:a})}function Tl(){return t.useContext(kl)}function _l(){const e=w.useLocation(),{navigation:t}=Tl();if(!t)return"Página";const a=t.find(t=>t.path===e.pathname);if(a)return a.label;const s=t.find(t=>e.pathname.startsWith(t.path+"/"));return s?.label||"Página"}function Al(e,a){const[s,r]=t.useState(e),n=t.useRef(),o=t.useCallback(()=>{n.current&&(clearTimeout(n.current),n.current=void 0)},[]);return t.useEffect(()=>(o(),n.current=setTimeout(()=>{r(e)},a),o),[e,a,o]),[s,o]}const El=t.memo(function({actions:a}){const s=w.useLocation(),r=_l(),{navigation:n,appName:o}=Tl(),{metadata:i,headerActions:d}=Sr(),{companies:c,alias:u,isSearchVisible:m,clearSearch:p,refreshData:h,switchUnit:f}=ls(),x=u?c?.find(e=>e.alias===u)||c?.[0]||null:c?.[0]||null,[g,b]=w.useSearchParams(),[v,N]=t.useState(()=>g.get("search")||""),[y,j]=Al(v,Ua.debounceDelay);t.useEffect(()=>{if(!m)return;const e=new URLSearchParams(g);y?(e.set("search",y),e.set("page","1")):e.delete("search"),b(e)},[y,b,m]);const C=n?.find(e=>e.path===s.pathname)||n?.find(e=>s.pathname.startsWith(e.path+"/")),k=i.title||r,S=i.subtitle||C?.complementaryText||"Detalhes do item";return e.jsx("header",{className:"bg-background border-b border-border px-2 md:px-4 py-2",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:k})}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:S})]}),m&&e.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Me,{placeholder:"Pesquisar",value:v,onChange:e=>(e=>{N(e)})(e.target.value),className:"w-full pl-10 pr-8"}),v&&e.jsx(Ee,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-muted",onClick:()=>{j(),N("");const e=new URLSearchParams(g);e.delete("search"),e.delete("page"),b(e)},title:"Limpar busca",children:e.jsx(l.X,{size:14})})]}),e.jsx(Ee,{variant:"outline",size:"sm",onClick:h,className:"flex-shrink-0 h-10 w-10 p-0",title:"Atualizar dados",children:e.jsx(l.RefreshCw,{size:14})})]}),e.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(d||a)&&e.jsx("div",{className:"flex items-center gap-2",children:d||a}),(void 0).VITE_WIKI_URL&&e.jsx(Ee,{variant:"secondary",size:"sm",className:"h-8 px-3",onClick:e=>Se((void 0).VITE_WIKI_URL,e),title:"Abrir Wiki",children:"Wiki"}),e.jsx("div",{className:"text-sm",children:e.jsx(Cl,{variant:"dropdown",selectedUnit:x,onUnitChange:f})})]})]})})}),Pl=({key:e,enabled:t,checkFn:a,staleTime:s=3e5,gcTime:r=6e5})=>v.useQuery({queryKey:["permission",e],queryFn:a,enabled:t,staleTime:s,gcTime:r,retry:0,refetchOnWindowFocus:!1});function Ml({className:t}){return e.jsxs("svg",{className:t,width:"32",height:"34",viewBox:"0 0 32 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M0.5 11.7455C0.5 10.2633 2.25695 9.52546 3.36816 10.4399L22.4346 26.1528C23.3588 26.9137 23.229 28.3353 22.1953 28.9301L16.3418 32.2963C15.7961 32.6097 15.1199 32.6098 14.5742 32.2963L1.36133 24.7006C0.832671 24.3966 0.500052 23.8398 0.5 23.2289V11.7455Z",stroke:"currentColor"}),e.jsx("path",{d:"M14.612 0.735352C15.1576 0.421927 15.833 0.421964 16.3786 0.735352L25.3776 5.90723V5.9082C26.5447 6.5808 26.5183 8.24018 25.3298 8.875L25.3307 8.87598L13.9333 14.9697L13.9323 14.9688C13.3016 15.3066 12.5233 15.2301 11.9733 14.7773L4.90302 8.9541C3.97881 8.19317 4.1086 6.77256 5.14227 6.17773L14.612 0.735352Z",stroke:"currentColor"}),e.jsx("path",{d:"M28.1066 9.7966C29.2466 9.18579 30.6895 9.9732 30.6896 11.2937V23.0691C30.6895 23.6825 30.3539 24.2382 29.8264 24.5417L29.8254 24.5427L27.3449 25.9607C26.7486 26.3015 26.0057 26.264 25.4494 25.8747L25.341 25.7917L16.6076 18.5974C15.6649 17.821 15.8224 16.3676 16.8937 15.7937V15.7927L28.1066 9.79758V9.7966Z",stroke:"currentColor"})]})}function Il({className:t}){return e.jsxs("svg",{className:t,width:"18",height:"33",viewBox:"0 0 18 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M0.524143 8.74979C1.44754 8.74979 2.36325 8.74979 3.30973 8.74979C3.30973 8.90069 3.30973 9.05162 3.30973 9.19497C3.30973 9.79101 3.64061 10.1154 4.24082 10.1154C6.8879 10.1154 9.54268 10.1154 12.1898 10.1154C12.7592 10.1154 13.1286 9.77589 13.1132 9.27793C13.0978 8.8856 12.8054 8.5612 12.3745 8.51594C11.2279 8.38767 10.0736 8.26696 8.91938 8.1387C7.72666 8.01043 6.52625 7.88216 5.33352 7.74635C4.71792 7.67845 4.10232 7.61811 3.48672 7.53511C2.00928 7.32386 0.754978 6.06386 0.547213 4.61526C0.331752 3.10631 1.00122 1.73316 2.34015 0.963593C2.89419 0.646712 3.5021 0.503353 4.14848 0.503353C6.84943 0.503353 9.55038 0.495808 12.2513 0.503353C14.0904 0.510898 15.5448 1.71808 15.8603 3.49865C15.8988 3.7099 15.8988 3.92116 15.9065 4.13996C15.9141 4.2984 15.9065 4.44928 15.9065 4.61526C14.9677 4.61526 14.0443 4.61526 13.0978 4.61526C13.0978 4.44928 13.0978 4.28329 13.0978 4.1173C13.0901 3.58162 12.7592 3.25719 12.2206 3.24965C9.53499 3.24965 6.84943 3.24965 4.17157 3.24965C3.69448 3.24965 3.36359 3.52881 3.30203 3.97396C3.24816 4.3512 3.51749 4.73597 3.90224 4.8265C4.10231 4.87177 4.31008 4.88687 4.51784 4.9095C5.8183 5.05285 7.12645 5.19622 8.42691 5.33957C9.71198 5.48292 10.997 5.63382 12.2898 5.75453C13.1824 5.83753 13.9981 6.08649 14.6906 6.68253C16.1604 7.92742 16.3066 10.2588 14.9984 11.6696C14.2443 12.4845 13.3132 12.8844 12.1975 12.8844C9.5273 12.8844 6.84944 12.8844 4.17927 12.8844C2.55562 12.8844 1.21669 11.9563 0.678043 10.4549C0.539533 9.98715 0.470277 9.38356 0.524143 8.74979Z",stroke:"currentColor"}),e.jsx("path",{d:"M8.21913 24.2393C8.21913 24.2317 8.21913 24.2317 8.21913 24.2393ZM8.21913 24.2393C8.98863 24.2393 9.75812 24.2619 10.5199 24.2317C11.7511 24.1789 12.9285 23.1378 13.067 21.9381C13.1439 21.3119 13.1285 20.6706 13.1131 20.0368C13.067 18.6335 11.8743 17.4339 10.443 17.3962C8.96554 17.3584 7.4881 17.366 6.00296 17.3962C4.70251 17.4263 3.54055 18.4373 3.37896 19.6973C3.29431 20.3462 3.3097 21.0101 3.34048 21.6665C3.40204 23.017 4.58708 24.1789 5.96449 24.2317C6.7186 24.2619 7.46502 24.2393 8.21913 24.2393ZM13.1439 15.427C13.7441 14.8385 14.3367 14.2575 14.9138 13.6917C15.5756 14.333 16.2296 14.9818 16.9222 15.6608C16.8914 15.6759 16.8298 15.7061 16.7837 15.7438C16.2604 16.2493 15.7448 16.7624 15.2216 17.2679C15.1446 17.3434 15.1369 17.4037 15.1908 17.4943C15.7064 18.3845 15.9526 19.3427 15.9295 20.3613C15.9141 20.9799 15.9526 21.6062 15.8603 22.2097C15.5371 24.2846 14.352 25.7332 12.3975 26.5782C11.7126 26.8724 10.9816 26.9931 10.2352 26.9931C8.89629 26.9931 7.56504 26.9931 6.22611 26.9931C3.49438 26.9931 1.20897 25.1899 0.631845 22.5719C0.56259 22.2475 0.524115 21.9155 0.51642 21.5835C0.508725 20.9422 0.470242 20.2933 0.547192 19.6596C0.816518 17.3584 2.08619 15.7967 4.27927 14.9516C4.84101 14.7328 5.42584 14.6347 6.02605 14.6347C7.4958 14.6347 8.96554 14.6272 10.4276 14.6423C11.3279 14.6498 12.1667 14.9064 12.9516 15.3289C13.0131 15.3591 13.067 15.3892 13.1439 15.427Z",stroke:"currentColor"}),e.jsx("path",{d:"M0.508791 28.3813C1.43989 28.3813 2.3633 28.3813 3.2944 28.3813C3.31748 28.4945 3.32516 28.6001 3.35594 28.7058C3.50984 29.2943 4.01772 29.7017 4.63332 29.7319C4.76414 29.7394 4.89496 29.7394 5.02578 29.7394C7.22655 29.7394 9.4273 29.7394 11.6281 29.7394C12.3206 29.7394 12.8439 29.3923 13.0363 28.7963C13.0747 28.668 13.0978 28.5323 13.1286 28.3889C14.0443 28.3889 14.9677 28.3889 15.9142 28.3889C15.9219 28.7435 15.868 29.0906 15.7757 29.4301C15.2986 31.1955 13.6519 32.4782 11.7897 32.4857C9.39653 32.5008 7.01108 32.5083 4.61794 32.4857C2.44025 32.4706 0.624216 30.7353 0.508791 28.6077C0.501096 28.5322 0.508791 28.4643 0.508791 28.3813Z",stroke:"currentColor"})]})}const Dl=[{id:"qualiex",label:"Qualiex",modules:[{name:"Análises",description:"Análise de dados",color:"bg-[#002338]",url:"https://apps4.qualiex.com/analysis/{alias}"},{name:"Atas e Decisões",description:"Gestão de atas e decisões",color:"bg-[#7DB3B2]",url:"https://apps4.qualiex.com/decisions/{alias}"},{name:"Auditorias",description:"Gestão de auditorias",color:"bg-[#912F71]",url:"https://apps4.qualiex.com/audit/{alias}"},{name:"Configurações",description:"Configurações gerais",color:"bg-[#5C6BC0]",url:"https://apps4.qualiex.com/common/{alias}"},{name:"Documentos",description:"Gestão de documentos",color:"bg-[#1D43A6]",url:"https://apps4.qualiex.com/docs/{alias}"},{name:"Fluxos",description:"Gestão de fluxos",color:"bg-[#8BFFE0]",url:"https://apps4.qualiex.com/flow/{alias}"},{name:"Fornecedores",description:"Gestão de fornecedores",color:"bg-[#5C5094]",url:"https://apps4.qualiex.com/suppliers/{alias}"},{name:"Mapeamentos",description:"Mapeamento de dados pessoais",color:"bg-[#62416B]",url:"https://apps4.qualiex.com/mapping/{alias}"},{name:"Metrologia",description:"Gestão de metrologia",color:"bg-[#8CC74F]",url:"https://apps4.qualiex.com/metrology/{alias}"},{name:"Ocorrências",description:"Gestão de ocorrências",color:"bg-[#EE7121]",url:"https://apps4.qualiex.com/occurrences/{alias}"},{name:"OKR",description:"Objetivos e resultados-chave",color:"bg-[#4A90D9]",url:"https://okr.qualiex.com"},{name:"Planos",description:"Planos de ação",color:"bg-[#FBC02D]",url:"https://apps4.qualiex.com/plans/{alias}"},{name:"Portal do Fornecedor",description:"Portal do Fornecedor",color:"bg-[#26A69A]",url:"https://portaldofornecedor.qualiex.com/{alias}"},{name:"Riscos",description:"Gestão de riscos",color:"bg-[#ED7096]",url:"https://apps4.qualiex.com/risks/{alias}"},{name:"Competências",description:"Gestão de competências",color:"bg-[#9B4F96]",url:"https://competencias.sabergestao.com.br"},{name:"Desempenho",description:"Gestão de desempenho",color:"bg-[#4A90D9]",url:"https://desempenho.sabergestao.com.br"},{name:"Educação",description:"Plataforma de ensino",color:"bg-[#00BCD4]",url:"https://educacao.sabergestao.com.br"},{name:"PDI",description:"Plano de desenvolvimento individual",color:"bg-[#7CB342]",url:"https://pdi.sabergestao.com.br"},{name:"Pulso",description:"Pesquisas de clima",color:"bg-[#F5A623]",url:"https://nr1pulso.sabergestao.com.br"},{name:"Treinamentos",description:"Gestão de treinamentos",color:"bg-[#26A69A]",url:"https://treinamentos.sabergestao.com.br"}]},{id:"classico",label:"Clássicos",modules:[{name:"Action",description:"Planos de ação",color:"bg-[#fbe356]",url:"https://apps1.qualiex.com/action?unitalias={alias}"},{name:"Audit",description:"Gestão de auditorias",color:"bg-[#ca76b5]",url:"https://apps1.qualiex.com/audit?unitalias={alias}"},{name:"Configurações v3",description:"Configurações",color:"bg-[#5C6BC0]",url:"https://apps3.qualiex.com/{alias}/common"},{name:"Dashboards v1",description:"Dashboards",color:"bg-[#EC407A]",url:"https://apps1.qualiex.com/shared/dashboard?unitalias=forlogic"},{name:"Docs v1",description:"Gestão de Documentos",color:"bg-[#58b4db]",url:"https://apps1.qualiex.com/docs?unitalias={alias}"},{name:"Indicators",description:"Gestão de Indicadores",color:"bg-[#f91b1d]",url:"https://apps1.qualiex.com/indicators?unitalias={alias}"},{name:"Meeting",description:"Gestão de reuniões",color:"bg-[#96c2c1]",url:"https://apps1.qualiex.com/meeting?unitalias={alias}"},{name:"Metrology v3",description:"Gestão de Metrologia",color:"bg-[#afd884]",url:"https://apps3.qualiex.com/{alias}/metrology/"},{name:"Planner",description:"Planejamento estratégico",color:"bg-[#4dc6f4]",url:"https://apps3.qualiex.com/{alias}/planner/m"},{name:"Relatórios v1",description:"Relatórios",color:"bg-[#FFA726]",url:"https://apps1.qualiex.com/common/reports?unitalias=forlogic"},{name:"Risks",description:"Gestão de riscos",color:"bg-[#ef7b9e]",url:"https://apps1.qualiex.com/risks?unitalias={alias}"},{name:"Staff",description:"Avaliação de competências",color:"bg-[#0978d6]",url:"https://apps1.qualiex.com/staff?unitalias={alias}"},{name:"Supply",description:"Avaliação de fornecedores",color:"bg-[#8276b7]",url:"https://apps1.qualiex.com/supply?unitalias={alias}"},{name:"Tracker1",description:"Gestão de ocorrências",color:"bg-[#fe883b]",url:"https://apps1.qualiex.com/tracker1?unitalias={alias}"},{name:"Tracker2",description:"Gestão de ocorrências",color:"bg-[#fe883b]",url:"https://apps1.qualiex.com/tracker2?unitalias={alias}"}]}];function Rl({module:t,onClick:a}){return e.jsxs("button",{type:"button",onClick:a,className:"flex items-start gap-3 p-2 rounded-lg transition-colors text-left w-full group hover:bg-muted/50",children:[e.jsx("div",{className:Te("w-4 h-4 rounded-sm shrink-0 mt-0.5",t.color)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium transition-colors text-foreground group-hover:text-primary",children:t.name}),t.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate",children:t.description})]})]})}function Ll({onClick:t}){return e.jsxs("button",{type:"button",onClick:t,className:"flex items-start gap-3 p-2 rounded-lg transition-colors text-left w-full group hover:bg-muted/50",children:[e.jsx("div",{className:"w-4 h-4 rounded-sm shrink-0 mt-0.5 bg-muted flex items-center justify-center",children:e.jsx(l.Settings,{className:"h-3 w-3 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium transition-colors text-foreground group-hover:text-primary",children:"Configurações"}),e.jsx("div",{className:"text-sm text-muted-foreground truncate",children:"Gerenciar módulos ativos"})]})]})}function zl(e,t){if(0===e.length)return e;const a=Math.ceil(e.length/t),s=[];for(let r=0;r<a;r++)for(let n=0;n<t;n++){const t=n*a+r;t<e.length&&s.push(e[t])}return s}function Fl({modules:a,onModuleClick:s,contractedModules:r,onModuleInterest:n,showSettingsItem:o,onSettingsClick:i}){const l=function(){const[e,a]=t.useState(4);return t.useEffect(()=>{const e=()=>{window.matchMedia("(min-width: 1280px)").matches?a(4):window.matchMedia("(min-width: 768px)").matches?a(3):a(2)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}(),d=[...a].sort((e,t)=>e.name.localeCompare(t.name)),c=void 0!==r,u=c?d.filter(e=>r.includes(e.name)):d,m=c?d.filter(e=>!r.includes(e.name)):[],p=zl(u,l),h=zl(m,l),f=(e,t)=>{t?s?.(e):n?.(e)};return e.jsxs("div",{className:"space-y-6",children:[(p.length>0||o)&&e.jsx("section",{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:[p.map(t=>e.jsx(Rl,{module:t,onClick:()=>f(t,!0)},t.name)),o&&e.jsx(Ll,{onClick:i})]})}),h.length>0&&e.jsxs("section",{className:"bg-neutral-100 dark:bg-neutral-800 rounded-lg p-4 mt-4",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-3",children:"Conheça também"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:h.map(t=>e.jsx(Rl,{module:t,onClick:()=>f(t,!1)},t.name))})]})]})}function Ul({open:a,onOpenChange:s,onModuleClick:r,contractedModules:n,onModuleInterest:o,educaUrl:i="https://educa.forlogic.net/",saberGestaoUrl:d="https://sabergestao.com.br/",wikiUrl:c,showSettingsLink:u=!0,onSettingsClick:m}){const[p,h]=t.useState("qualiex"),[f,x]=t.useState(null),g=e=>{x(e)},b=i||c||"https://educa.forlogic.net/";return e.jsxs(e.Fragment,{children:[e.jsx(Be,{open:a,onOpenChange:s,children:e.jsxs(Ye,{size:"lg",className:"overflow-hidden flex flex-col max-h-[85vh]",children:[e.jsx(Qe,{className:"sr-only",children:e.jsx(Ze,{children:"Módulos"})}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs(Ui,{value:p,onValueChange:h,className:"flex-1 flex flex-col min-h-0",children:[e.jsx(qi,{className:"w-fit shrink-0",children:Dl.map(t=>e.jsxs(Oi,{value:t.id,children:[t.label,e.jsxs("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",t.modules.length,")"]})]},t.id))}),Dl.map(t=>e.jsx(Bi,{value:t.id,className:"flex-1 mt-4 overflow-auto pr-2",children:e.jsx(Fl,{modules:t.modules,onModuleClick:r,contractedModules:n,onModuleInterest:g,showSettingsItem:u,onSettingsClick:m})},t.id))]}),e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Oe,{className:"mb-4"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-primary text-primary-foreground rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-white",children:"Aprenda a usar o Qualiex"}),e.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-white underline underline-offset-2 hover:opacity-80 mt-2",children:["Conheça o Forlogic Educa",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(Ml,{className:"absolute right-2 bottom-2 w-16 h-16 text-[#043481] pointer-events-none"})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Conheça o Saber Gestão"}),e.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Saiba mais",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(Il,{className:"absolute right-2 bottom-2 w-12 h-16 text-[#E0E0E0] pointer-events-none"})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Dúvidas sobre os módulos?"}),e.jsxs("a",{href:c||"https://wiki.qualiex.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Consulte nossa Wiki",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(l.NotebookText,{className:"absolute right-2 top-2 bottom-2 h-[calc(100%-1rem)] w-auto text-[#E0E0E0] pointer-events-none",strokeWidth:1})]})]})]})]})]})}),f&&e.jsx(wl,{open:!!f,onOpenChange:e=>!e&&x(null),steps:(v=f,v.onboardingSteps&&v.onboardingSteps.length>0?v.onboardingSteps.slice(0,3):[{id:"intro",title:`Conheça o ${v.name}`,description:v.description||`O ${v.name} é uma solução completa para otimizar seus processos e aumentar a produtividade da sua equipe.`},{id:"features",title:"Principais Funcionalidades",description:"Automatize processos, gere relatórios detalhados, acompanhe indicadores em tempo real e tenha controle total sobre suas operações."},{id:"cta",title:"Transforme sua Gestão",description:"Fale com um de nossos especialistas e descubra como este módulo pode transformar a gestão da sua empresa."}]),finishButtonText:"Quero conhecer mais",onComplete:()=>{f&&(o?.(f),x(null))}})]});var v}var ql,Ol;function Bl(){return Bl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},Bl.apply(null,arguments)}var Hl;function $l(){return $l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},$l.apply(null,arguments)}const Vl=(void 0).VITE_SUPABASE_PROJECT_ID_STORAGE??(void 0).VITE_SUPABASE_PROJECT_ID,Wl={logo:Ha.isQualiex?`${`https://${Vl}.supabase.co/storage/v1/object/public/library-assets`}/logo-qualiex.svg`:function(e){return J.createElement("svg",Bl({xmlns:"http://www.w3.org/2000/svg",width:90,height:24,fill:"none"},e),ql||(ql=J.createElement("g",{clipPath:"url(#forlogic-full_svg__a)"},J.createElement("path",{fill:"#1D43A6",d:"M73.234 12.99V6.278a.705.705 0 0 1 1.161-.538l10.806 9.183a.705.705 0 0 1-.097 1.143l-3.318 1.967a.7.7 0 0 1-.719 0l-7.488-4.44a.7.7 0 0 1-.345-.607zM75.723 3.28 81.088.098a.7.7 0 0 1 .719 0l5.099 3.024c.469.278.458.96-.02 1.224l-6.458 3.562a.705.705 0 0 1-.797-.08l-4.006-3.403a.706.706 0 0 1 .097-1.145M82.374 8.903l6.354-3.505a.705.705 0 0 1 1.045.618v6.88c0 .25-.132.48-.346.607l-1.407.829a.71.71 0 0 1-.814-.07l-4.95-4.204a.705.705 0 0 1 .117-1.155"}),J.createElement("path",{fill:"#090F11",d:"M40.24 0h2.55c.157 0 .283.127.283.283v15.643a.283.283 0 0 1-.283.283h-2.55a.283.283 0 0 1-.283-.283V.283c0-.156.126-.283.283-.283M44.926 0h2.751c.156 0 .283.127.283.283v2.73a.283.283 0 0 1-.283.283h-2.751a.283.283 0 0 1-.284-.283V.283c0-.156.127-.283.283-.283m.088 4.91h2.551c.157 0 .283.126.283.283v10.733a.283.283 0 0 1-.283.283h-2.55a.283.283 0 0 1-.284-.283V5.193c0-.157.127-.283.283-.283M12.56 15.003c2.128-1.4 3.47-3.81 3.47-6.703 0-4.619-3.408-8.027-8.004-8.027C3.431.273 0 3.681 0 8.3c0 4.125 2.713 7.286 6.592 7.914 1.212.18 2.684.07 2.937-.023.183-.03.36-.073.538-.115l1.02 1.902a.3.3 0 0 0 .263.158h2.394c.225 0 .368-.24.262-.438l-1.443-2.695zm-4.557-1.592c-2.69 0-4.618-2.175-4.618-5.111s1.929-5.135 4.618-5.135 4.642 2.197 4.642 5.135c0 1.618-.595 3.001-1.576 3.92l-.659-1.228a.3.3 0 0 0-.262-.158H7.754a.298.298 0 0 0-.263.438l1.123 2.096c-.2.025-.402.043-.61.043M27.226 16.217h-2.01a.29.29 0 0 1-.268-.185l-.32-.858c-.077-.208-.346-.244-.489-.073-.675.807-1.773 1.293-3.098 1.293-2.496 0-4.13-1.833-4.13-4.373V5.37c0-.157.127-.284.284-.284h2.523c.158 0 .284.128.284.284v5.965c0 1.347.862 2.32 2.142 2.32 1.347 0 2.298-1.061 2.298-2.474v-5.81c0-.158.127-.285.284-.285h2.5c.158 0 .284.128.284.284v10.562a.284.284 0 0 1-.284.284M28.605 13.06c0-2.187 1.634-3.512 4.085-3.512h1.856c.552 0 .839-.354.839-.817 0-.928-.706-1.568-1.965-1.568s-1.93.703-2.056 1.534a.28.28 0 0 1-.278.233h-2.168a.288.288 0 0 1-.284-.327c.264-2.076 2.043-3.693 4.94-3.693s4.882 1.634 4.882 4.152v6.871a.284.284 0 0 1-.284.284H36.16a.29.29 0 0 1-.267-.185l-.29-.776c-.081-.215-.363-.246-.5-.06-.547.738-1.603 1.2-2.853 1.2-2.142 0-3.644-1.436-3.644-3.335zm4.438 1.104c1.48 0 2.34-1.104 2.34-2.517v-.154h-2.23c-.949 0-1.589.574-1.589 1.435 0 .728.619 1.237 1.48 1.237M48.763 10.639c0-2.831 1.726-5.728 5.508-5.728s5.506 2.898 5.506 5.44q-.002.432-.024.737a.277.277 0 0 1-.278.258h-7.411a.28.28 0 0 0-.273.345c.312 1.367 1.27 2.2 2.701 2.2 1.15 0 1.938-.42 2.24-1.241a.29.29 0 0 1 .267-.197h2.453c.185 0 .317.177.27.355-.577 2.206-2.623 3.604-5.229 3.604-3.782 0-5.727-2.963-5.727-5.772zm7.62-1.24c.176 0 .31-.16.277-.333-.208-1.078-1.043-1.9-2.389-1.9s-2.096.581-2.425 1.88a.283.283 0 0 0 .27.355h4.267z"}),J.createElement("path",{fill:"#090F11",d:"m59.283 15.796 3.612-5.219a.28.28 0 0 0 0-.32l-3.317-4.73a.279.279 0 0 1 .228-.44h2.701a.28.28 0 0 1 .23.12l1.72 2.47c.113.16.349.16.46-.002l1.7-2.467a.28.28 0 0 1 .23-.121h2.7c.227 0 .359.254.229.44l-3.318 4.73a.28.28 0 0 0 0 .32l3.612 5.22a.28.28 0 0 1-.23.437h-2.616a.28.28 0 0 1-.23-.12l-2.076-2.982a.28.28 0 0 0-.458 0l-2.099 2.984a.28.28 0 0 1-.228.118h-2.618a.28.28 0 0 1-.23-.438zM54.67 19.87h-.82v3.116h.001l.006.178c0 .02.009.2.113.384.101.18.31.394.73.394h1.613v-.74h-1.641V19.87zM66.109 19.871h-.822v4.07h.822zM68.564 23.258c-.718 0-1.227-.618-1.227-1.35s.509-1.35 1.227-1.35c.394 0 .761.189 1 .472l.554-.488a2.03 2.03 0 0 0-1.554-.728c-1.132 0-2.052.94-2.052 2.093S67.432 24 68.564 24c.62 0 1.176-.282 1.553-.727l-.555-.487c-.238.282-.606.47-.998.47zM43.412 23.942h-.817l.53-3.32a1 1 0 0 1 .141-.366.78.78 0 0 1 .688-.385h1.898v.733h-1.911l-.149.936h1.388v.732h-1.503l-.264 1.669M47.86 23.998a2.094 2.094 0 0 1-2.091-2.092c0-1.153.938-2.091 2.092-2.091s2.092.938 2.092 2.091a2.094 2.094 0 0 1-2.092 2.092m0-3.44c-.732 0-1.267.617-1.267 1.348s.535 1.35 1.268 1.35 1.268-.617 1.268-1.349c0-.731-.535-1.349-1.268-1.349M58.346 23.998a2.094 2.094 0 0 1-2.091-2.092c0-1.153.938-2.091 2.091-2.091s2.092.938 2.092 2.091a2.094 2.094 0 0 1-2.092 2.092m0-3.44c-.731 0-1.266.617-1.266 1.348s.535 1.35 1.266 1.35c.732 0 1.267-.616 1.267-1.349 0-.732-.535-1.349-1.267-1.349M64.887 21.914l-.002-.376h-1.64v.74h.859a1.25 1.25 0 0 1-.275.557c-.239.282-.602.421-.995.421-.718 0-1.227-.617-1.227-1.35 0-.732.509-1.349 1.227-1.349.393 0 .764.185 1.003.468l.559-.481a2.05 2.05 0 0 0-1.562-.73c-1.131 0-2.052.94-2.052 2.093S61.702 24 62.834 24c.62 0 1.176-.282 1.553-.727.25-.296.422-.666.478-1.072 0 0 .02-.15.02-.287zM51.416 19.87a.78.78 0 0 0-.69.388c-.11.176-.14.35-.142.368l-.53 3.316h.819l.264-1.674.117-.735.152-.93h.81c.038 0 .11.01.209.072a.487.487 0 0 1-.001.794.5.5 0 0 1-.182.07l-.06.002h-.621l1.07 2.401h.816l-.747-1.675-.024-.056c.06-.02.127-.048.192-.085.372-.205.577-.584.577-1.067s-.182-.72-.335-.87a1.2 1.2 0 0 0-.803-.319z"}))),Ol||(Ol=J.createElement("defs",null,J.createElement("clipPath",{id:"forlogic-full_svg__a"},J.createElement("path",{fill:"#fff",d:"M0 0h90v24H0z"})))))},smallLogo:function(e){return J.createElement("svg",$l({xmlns:"http://www.w3.org/2000/svg",width:22,height:24,fill:"none"},e),Hl||(Hl=J.createElement("path",{fill:"#1D43A6",d:"M0 16.67V8.06c0-.772.929-1.189 1.534-.69l14.27 11.785a.89.89 0 0 1-.127 1.468l-4.381 2.525a.96.96 0 0 1-.95 0L.456 17.45A.9.9 0 0 1 0 16.672zM3.287 4.208 10.374.126a.96.96 0 0 1 .95 0l6.734 3.88a.892.892 0 0 1-.025 1.57l-8.53 4.57a.95.95 0 0 1-1.052-.102L3.159 5.676a.89.89 0 0 1 .128-1.468M12.072 11.426l8.393-4.497c.62-.334 1.381.103 1.381.792v8.83a.9.9 0 0 1-.458.78l-1.857 1.064a.95.95 0 0 1-1.076-.09l-6.536-5.396a.892.892 0 0 1 .153-1.483"})))}},Gl=Wl.logo,Yl=Wl.smallLogo;function Ql({open:a,appName:s}){const[r,n]=t.useState(!1);return e.jsxs(Ot,{children:[e.jsx(wi,{className:"p-0 gap-0",children:a?e.jsxs("div",{className:"flex flex-col gap-3 pl-2",children:[e.jsx("div",{className:"flex items-center h-10",children:e.jsx("img",{src:Wl.logo,alt:"Logo",className:"h-8 max-w-full object-contain"})}),e.jsxs(Ee,{variant:"secondary",size:"default",className:"h-10 gap-2 px-3 justify-start w-full",onClick:()=>n(!0),children:[e.jsx(l.Grip,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:s||"Módulos"})]})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center w-full gap-3",children:[e.jsx("div",{className:"flex items-center justify-center h-10 w-8",children:e.jsx("img",{src:Wl.smallLogo,alt:"Logo",className:"h-6 w-auto object-contain"})}),e.jsxs(Bt,{children:[e.jsx(Ht,{asChild:!0,children:e.jsx("button",{className:"flex items-center justify-center h-10 w-8 rounded-md hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>n(!0),children:e.jsx(l.Grip,{className:"h-4 w-4"})})}),e.jsx($t,{side:"right",children:e.jsx("p",{children:s||"Módulos"})})]})]})}),e.jsx(Ul,{open:r,onOpenChange:n})]})}function Kl({config:t,isCollapsed:a=!1,isDisabled:s=!1,className:r}){const{actions:n,triggerLabel:o="Criar",triggerIcon:i=l.Plus}=t;if(!n||0===n.length)return null;const d=(t,s,r=!1)=>e.jsxs(e.Fragment,{children:[t,!a&&s&&e.jsx("span",{className:"truncate",children:s}),!a&&r&&e.jsx(l.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(n.length>1)){const t=n[0],o=t.icon||i,l=s||t.disabled,c=e.jsx(Ee,{onClick:t.onClick,disabled:l,className:Te("w-full gap-2 justify-start",a&&"justify-center px-2",r),variant:"outline",size:"default",children:d(e.jsx(o,{className:"h-4 w-4 shrink-0"}),t.label)});return a?e.jsxs(Bt,{children:[e.jsx(Ht,{asChild:!0,children:c}),e.jsx($t,{side:"right",children:e.jsx("p",{children:t.label})})]}):c}const c=e.jsx(Ee,{disabled:s,className:Te("w-full gap-2 justify-start",a&&"justify-center px-2",r),variant:"outline",size:"default",children:d(e.jsx(i,{className:"h-4 w-4 shrink-0"}),o,!0)});return e.jsxs(St,{children:[e.jsx(Tt,{asChild:!0,children:a?e.jsxs(Bt,{children:[e.jsx(Ht,{asChild:!0,children:c}),e.jsx($t,{side:"right",children:e.jsx("p",{children:o})})]}):c}),e.jsx(Dt,{align:"start",side:a?"right":"bottom",className:"w-56 bg-popover",children:n.map(t=>{const a=t.icon;return e.jsxs(Rt,{onClick:t.onClick,disabled:t.disabled,className:"cursor-pointer",children:[a&&e.jsx(a,{className:"mr-2 h-4 w-4"}),t.label]},t.id)})})]})}const Xl="forlogic-sidebar-pinned",Zl=()=>{try{const e=localStorage.getItem(Xl);return!!e&&JSON.parse(e)}catch{return!1}};function Jl({direction:e="right",minWidth:a=224,maxWidth:s=384,defaultWidth:r=240,storageKey:n="sidebar-width",onResize:o,isOpen:i=!0}={}){const[l,d]=t.useState(()=>{if("undefined"==typeof window)return r;const e=localStorage.getItem(n);return e?parseInt(e):r}),[c,u]=t.useState(!1),m=t.useRef(null);t.useEffect(()=>{const e=document.querySelector(".sidebar-container");e&&e instanceof HTMLElement&&(i?e.style.setProperty("--sidebar-width",`${l}px`):e.style.setProperty("--sidebar-width","240px"))},[l,i]);const p=t.useCallback(e=>{e.preventDefault(),u(!0)},[]);return t.useEffect(()=>{if(!c)return;const t=t=>{let r;r="left"===e?window.innerWidth-t.clientX:t.clientX,r=Math.max(a,Math.min(s,r)),d(r),o?.(r)},r=()=>{u(!1),localStorage.setItem(n,l.toString())};return document.addEventListener("mousemove",t),document.addEventListener("mouseup",r),()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r)}},[c,e,a,s,l,n,o]),t.useEffect(()=>{c?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[c,e]),{width:l,isDragging:c,dragRef:m,handleMouseDown:p}}const ed=t.createContext(void 0);function td(){const e=t.useContext(ed);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function ad({config:a,customContent:s,resizable:r=!1,minWidth:n=224,maxWidth:o=384}={}){const{open:i,setOpen:d}=pi(),c=w.useLocation(),{alias:u,user:m}=ls(),{appName:p}=Tl(),{hasOpenModal:h}=td(),[f,x]=t.useState(Zl),g=r?Jl({minWidth:n,maxWidth:o,storageKey:"app-sidebar-width",isOpen:i}):null;t.useEffect(()=>{d(!!f)},[f,d]);const b=e=>c.pathname===e||c.pathname.startsWith(e+"/");return e.jsxs(fi,{collapsible:"icon",className:Te("app-sidebar bg-background border-r border-border py-4",i?"px-3":"px-1.5"),style:g&&i?{width:`${g.width}px`,transition:"none"}:{transition:"all 300ms ease-in-out"},children:[e.jsx(Ql,{open:i,appName:p}),a?.moduleActions&&a.moduleActions.actions.length>0&&e.jsx("div",{className:"py-3",children:e.jsx(Ot,{children:e.jsx(Kl,{config:a.moduleActions,isCollapsed:!i,isDisabled:h})})}),e.jsxs("div",{className:"relative py-5",children:[e.jsx(Oe,{}),e.jsxs(Bt,{children:[e.jsx(Ht,{asChild:!0,children:e.jsx("button",{onClick:()=>{const e=!f;x(e),(e=>{try{localStorage.setItem(Xl,JSON.stringify(e))}catch{}})(e)},className:Te("absolute top-1/2 -translate-y-1/2 z-[100] h-6 w-6 flex items-center justify-center rounded-full bg-primary hover:bg-primary/90 shadow-md transition-colors",i?"-right-6":"-right-[18px]"),children:i?e.jsx(l.ChevronLeft,{className:"h-3.5 w-3.5 text-primary-foreground"}):e.jsx(l.ChevronRight,{className:"h-3.5 w-3.5 text-primary-foreground"})})}),e.jsx($t,{side:"right",children:e.jsx("p",{children:i?"Recolher":"Expandir"})})]})]}),e.jsx(ji,{children:s||e.jsx(Ci,{className:"p-0",children:e.jsx(Ti,{children:e.jsx(_i,{className:"gap-1",children:e.jsx(Ot,{children:a?.navigation?.map((t,a)=>{const s=({item:t,index:a})=>{const r=`${t.path}-${a}-${u??"noalias"}-${m?.id??"nouser"}`,{data:n=!0,isLoading:o}=Pl({key:r,enabled:Boolean(t.permissionCheck&&u&&m?.id),checkFn:t.permissionCheck||(()=>Promise.resolve(!0))}),d=t.permissionCheck&&!n;if(d&&"Admin"===t.label)return null;const c=o?l.Loader2:d?l.Lock:t.icon;d||t.complementaryText;return t.children&&t.children.length>0?i?e.jsx($r,{defaultOpen:!0,className:"group/collapsible",children:e.jsxs(Ai,{children:[e.jsx(Vr,{asChild:!0,children:e.jsx(Pi,{size:"default",children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:e.jsx(c,{className:"h-4 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text",children:t.label}),e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90"})]})})}),e.jsx(Wr,{children:e.jsx(Ri,{children:t.children.map((t,a)=>e.jsx(s,{item:t,index:a},t.path))})})]})},t.path):e.jsx(Ai,{children:e.jsxs(Bt,{children:[e.jsx(Ht,{asChild:!0,children:e.jsx("div",{className:Te("flex items-center justify-center h-8 w-8 mx-auto rounded-md transition-colors cursor-pointer","hover:bg-accent hover:text-accent-foreground"),children:e.jsx(c,{className:"h-4 w-4"})})}),e.jsx($t,{side:"right",children:e.jsx("p",{children:t.label})})]})},t.path):e.jsx(Ai,{children:d||o?e.jsxs(Bt,{children:[e.jsx(Ht,{asChild:!0,children:i?e.jsx(Pi,{size:"default",className:"opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:e.jsx(c,{className:"h-4 w-4 "+(o?"animate-spin":"")})}),e.jsx("span",{className:"font-medium sidebar-text",children:t.label})]})}):e.jsx("div",{className:"flex items-center justify-center h-8 w-8 mx-auto rounded-md opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:e.jsx(c,{className:"h-4 w-4 "+(o?"animate-spin":"")})})}),e.jsx($t,{side:"right",children:e.jsx("p",{children:o?"Verificando acesso...":"Acesso restrito"})})]}):i?e.jsx(Pi,{asChild:!0,isActive:b(t.path),size:"default",children:e.jsxs(w.Link,{to:t.path,className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:e.jsx(c,{className:"h-4 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text",children:t.label})]})}):e.jsxs(Bt,{children:[e.jsx(Ht,{asChild:!0,children:e.jsx(w.Link,{to:t.path,className:Te("flex items-center justify-center h-8 w-8 mx-auto rounded-md transition-colors",b(t.path)?"bg-primary/10 text-primary":"hover:bg-accent hover:text-accent-foreground"),children:e.jsx(c,{className:"h-4 w-4"})})}),e.jsx($t,{side:"right",children:e.jsx("p",{children:t.label})})]})},t.path)};return e.jsx(s,{item:t,index:a},t.path)})})})})})}),r&&g&&i&&e.jsx("div",{ref:g.dragRef,onMouseDown:g.handleMouseDown,className:Te("absolute inset-y-0 right-0 w-1 cursor-ew-resize","hover:bg-primary/20 transition-colors","after:absolute after:inset-y-0 after:-left-1 after:-right-1 after:content-['']",g.isDragging&&"bg-primary/40")})]})}const sd=t.memo(function({children:a,sidebar:s,sidebarConfig:r,showHeader:n=!0}){const o=t.useMemo(()=>s||e.jsx(ad,{config:r}),[s,r]),i=t.useMemo(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return e.jsx(Sl,{config:r,children:e.jsx(kr,{children:e.jsx(hi,{defaultOpen:!1,style:i,children:e.jsxs("div",{className:"sidebar-container min-h-screen flex w-full",children:[o,e.jsxs("main",{className:"relative z-0 flex-1 flex flex-col h-screen overflow-hidden",children:[n&&e.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:e.jsx(El,{})}),e.jsx("div",{className:"flex-1 overflow-hidden bg-muted/30",children:a})]})]})})})})});const rd=6048e5;function nd(e){const t=_n(e);return t.setHours(0,0,0,0),t}function od(e){const t=_n(e),a=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return a.setUTCFullYear(t.getFullYear()),+e-+a}function id(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function ld(e){const t=_n(e),a=function(e,t){const a=nd(e),s=nd(t),r=+a-od(a),n=+s-od(s);return Math.round((r-n)/864e5)}(t,function(e){const t=_n(e),a=id(e,0);return a.setFullYear(t.getFullYear(),0,1),a.setHours(0,0,0,0),a}(t));return a+1}function dd(e){return Pn(e,{weekStartsOn:1})}function cd(e){const t=_n(e),a=t.getFullYear(),s=id(e,0);s.setFullYear(a+1,0,4),s.setHours(0,0,0,0);const r=dd(s),n=id(e,0);n.setFullYear(a,0,4),n.setHours(0,0,0,0);const o=dd(n);return t.getTime()>=r.getTime()?a+1:t.getTime()>=o.getTime()?a:a-1}function ud(e){const t=_n(e),a=+dd(t)-+function(e){const t=cd(e),a=id(e,0);return a.setFullYear(t,0,4),a.setHours(0,0,0,0),dd(a)}(t);return Math.round(a/rd)+1}function md(e,t){const a=_n(e),s=a.getFullYear(),r=En(),n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=id(e,0);o.setFullYear(s+1,0,n),o.setHours(0,0,0,0);const i=Pn(o,t),l=id(e,0);l.setFullYear(s,0,n),l.setHours(0,0,0,0);const d=Pn(l,t);return a.getTime()>=i.getTime()?s+1:a.getTime()>=d.getTime()?s:s-1}function pd(e,t){const a=_n(e),s=+Pn(a,t)-+function(e,t){const a=En(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,r=md(e,t),n=id(e,0);return n.setFullYear(r,0,s),n.setHours(0,0,0,0),Pn(n,t)}(a,t);return Math.round(s/rd)+1}function hd(e,t){return(e<0?"-":"")+Math.abs(e).toString().padStart(t,"0")}const fd={y(e,t){const a=e.getFullYear(),s=a>0?a:1-a;return hd("yy"===t?s%100:s,t.length)},M(e,t){const a=e.getMonth();return"M"===t?String(a+1):hd(a+1,2)},d:(e,t)=>hd(e.getDate(),t.length),a(e,t){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.toUpperCase();case"aaa":return a;case"aaaaa":return a[0];default:return"am"===a?"a.m.":"p.m."}},h:(e,t)=>hd(e.getHours()%12||12,t.length),H:(e,t)=>hd(e.getHours(),t.length),m:(e,t)=>hd(e.getMinutes(),t.length),s:(e,t)=>hd(e.getSeconds(),t.length),S(e,t){const a=t.length,s=e.getMilliseconds();return hd(Math.trunc(s*Math.pow(10,a-3)),t.length)}},xd="midnight",gd="noon",bd="morning",vd="afternoon",wd="evening",Nd="night",yd={G:function(e,t,a){const s=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return a.era(s,{width:"abbreviated"});case"GGGGG":return a.era(s,{width:"narrow"});default:return a.era(s,{width:"wide"})}},y:function(e,t,a){if("yo"===t){const t=e.getFullYear(),s=t>0?t:1-t;return a.ordinalNumber(s,{unit:"year"})}return fd.y(e,t)},Y:function(e,t,a,s){const r=md(e,s),n=r>0?r:1-r;if("YY"===t){return hd(n%100,2)}return"Yo"===t?a.ordinalNumber(n,{unit:"year"}):hd(n,t.length)},R:function(e,t){return hd(cd(e),t.length)},u:function(e,t){return hd(e.getFullYear(),t.length)},Q:function(e,t,a){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(s);case"QQ":return hd(s,2);case"Qo":return a.ordinalNumber(s,{unit:"quarter"});case"QQQ":return a.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return a.quarter(s,{width:"narrow",context:"formatting"});default:return a.quarter(s,{width:"wide",context:"formatting"})}},q:function(e,t,a){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(s);case"qq":return hd(s,2);case"qo":return a.ordinalNumber(s,{unit:"quarter"});case"qqq":return a.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return a.quarter(s,{width:"narrow",context:"standalone"});default:return a.quarter(s,{width:"wide",context:"standalone"})}},M:function(e,t,a){const s=e.getMonth();switch(t){case"M":case"MM":return fd.M(e,t);case"Mo":return a.ordinalNumber(s+1,{unit:"month"});case"MMM":return a.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return a.month(s,{width:"narrow",context:"formatting"});default:return a.month(s,{width:"wide",context:"formatting"})}},L:function(e,t,a){const s=e.getMonth();switch(t){case"L":return String(s+1);case"LL":return hd(s+1,2);case"Lo":return a.ordinalNumber(s+1,{unit:"month"});case"LLL":return a.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return a.month(s,{width:"narrow",context:"standalone"});default:return a.month(s,{width:"wide",context:"standalone"})}},w:function(e,t,a,s){const r=pd(e,s);return"wo"===t?a.ordinalNumber(r,{unit:"week"}):hd(r,t.length)},I:function(e,t,a){const s=ud(e);return"Io"===t?a.ordinalNumber(s,{unit:"week"}):hd(s,t.length)},d:function(e,t,a){return"do"===t?a.ordinalNumber(e.getDate(),{unit:"date"}):fd.d(e,t)},D:function(e,t,a){const s=ld(e);return"Do"===t?a.ordinalNumber(s,{unit:"dayOfYear"}):hd(s,t.length)},E:function(e,t,a){const s=e.getDay();switch(t){case"E":case"EE":case"EEE":return a.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return a.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return a.day(s,{width:"short",context:"formatting"});default:return a.day(s,{width:"wide",context:"formatting"})}},e:function(e,t,a,s){const r=e.getDay(),n=(r-s.weekStartsOn+8)%7||7;switch(t){case"e":return String(n);case"ee":return hd(n,2);case"eo":return a.ordinalNumber(n,{unit:"day"});case"eee":return a.day(r,{width:"abbreviated",context:"formatting"});case"eeeee":return a.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(r,{width:"short",context:"formatting"});default:return a.day(r,{width:"wide",context:"formatting"})}},c:function(e,t,a,s){const r=e.getDay(),n=(r-s.weekStartsOn+8)%7||7;switch(t){case"c":return String(n);case"cc":return hd(n,t.length);case"co":return a.ordinalNumber(n,{unit:"day"});case"ccc":return a.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return a.day(r,{width:"narrow",context:"standalone"});case"cccccc":return a.day(r,{width:"short",context:"standalone"});default:return a.day(r,{width:"wide",context:"standalone"})}},i:function(e,t,a){const s=e.getDay(),r=0===s?7:s;switch(t){case"i":return String(r);case"ii":return hd(r,t.length);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return a.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return a.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return a.day(s,{width:"short",context:"formatting"});default:return a.day(s,{width:"wide",context:"formatting"})}},a:function(e,t,a){const s=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return a.dayPeriod(s,{width:"narrow",context:"formatting"});default:return a.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,t,a){const s=e.getHours();let r;switch(r=12===s?gd:0===s?xd:s/12>=1?"pm":"am",t){case"b":case"bb":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return a.dayPeriod(r,{width:"narrow",context:"formatting"});default:return a.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(e,t,a){const s=e.getHours();let r;switch(r=s>=17?wd:s>=12?vd:s>=4?bd:Nd,t){case"B":case"BB":case"BBB":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return a.dayPeriod(r,{width:"narrow",context:"formatting"});default:return a.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(e,t,a){if("ho"===t){let t=e.getHours()%12;return 0===t&&(t=12),a.ordinalNumber(t,{unit:"hour"})}return fd.h(e,t)},H:function(e,t,a){return"Ho"===t?a.ordinalNumber(e.getHours(),{unit:"hour"}):fd.H(e,t)},K:function(e,t,a){const s=e.getHours()%12;return"Ko"===t?a.ordinalNumber(s,{unit:"hour"}):hd(s,t.length)},k:function(e,t,a){let s=e.getHours();return 0===s&&(s=24),"ko"===t?a.ordinalNumber(s,{unit:"hour"}):hd(s,t.length)},m:function(e,t,a){return"mo"===t?a.ordinalNumber(e.getMinutes(),{unit:"minute"}):fd.m(e,t)},s:function(e,t,a){return"so"===t?a.ordinalNumber(e.getSeconds(),{unit:"second"}):fd.s(e,t)},S:function(e,t){return fd.S(e,t)},X:function(e,t,a){const s=e.getTimezoneOffset();if(0===s)return"Z";switch(t){case"X":return Cd(s);case"XXXX":case"XX":return kd(s);default:return kd(s,":")}},x:function(e,t,a){const s=e.getTimezoneOffset();switch(t){case"x":return Cd(s);case"xxxx":case"xx":return kd(s);default:return kd(s,":")}},O:function(e,t,a){const s=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+jd(s,":");default:return"GMT"+kd(s,":")}},z:function(e,t,a){const s=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+jd(s,":");default:return"GMT"+kd(s,":")}},t:function(e,t,a){return hd(Math.trunc(e.getTime()/1e3),t.length)},T:function(e,t,a){return hd(e.getTime(),t.length)}};function jd(e,t=""){const a=e>0?"-":"+",s=Math.abs(e),r=Math.trunc(s/60),n=s%60;return 0===n?a+String(r):a+String(r)+t+hd(n,2)}function Cd(e,t){if(e%60==0){return(e>0?"-":"+")+hd(Math.abs(e)/60,2)}return kd(e,t)}function kd(e,t=""){const a=e>0?"-":"+",s=Math.abs(e);return a+hd(Math.trunc(s/60),2)+t+hd(s%60,2)}const Sd=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},Td=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},_d={p:Td,P:(e,t)=>{const a=e.match(/(P+)(p+)?/)||[],s=a[1],r=a[2];if(!r)return Sd(e,t);let n;switch(s){case"P":n=t.dateTime({width:"short"});break;case"PP":n=t.dateTime({width:"medium"});break;case"PPP":n=t.dateTime({width:"long"});break;default:n=t.dateTime({width:"full"})}return n.replace("{{date}}",Sd(s,t)).replace("{{time}}",Td(r,t))}},Ad=/^D+$/,Ed=/^Y+$/,Pd=["D","DD","YY","YYYY"];function Md(e){if(!function(e){return e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e)}(e)&&"number"!=typeof e)return!1;const t=_n(e);return!isNaN(Number(t))}const Id=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Dd=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Rd=/^'([^]*?)'?$/,Ld=/''/g,zd=/[a-zA-Z]/;function Fd(e,t,a){const s=En(),r=a?.locale??s.locale??Ln,n=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,o=a?.weekStartsOn??a?.locale?.options?.weekStartsOn??s.weekStartsOn??s.locale?.options?.weekStartsOn??0,i=_n(e);if(!Md(i))throw new RangeError("Invalid time value");let l=t.match(Dd).map(e=>{const t=e[0];if("p"===t||"P"===t){return(0,_d[t])(e,r.formatLong)}return e}).join("").match(Id).map(e=>{if("''"===e)return{isToken:!1,value:"'"};const t=e[0];if("'"===t)return{isToken:!1,value:Ud(e)};if(yd[t])return{isToken:!0,value:e};if(t.match(zd))throw new RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});r.localize.preprocessor&&(l=r.localize.preprocessor(i,l));const d={firstWeekContainsDate:n,weekStartsOn:o,locale:r};return l.map(s=>{if(!s.isToken)return s.value;const n=s.value;(!a?.useAdditionalWeekYearTokens&&function(e){return Ed.test(e)}(n)||!a?.useAdditionalDayOfYearTokens&&function(e){return Ad.test(e)}(n))&&function(e,t,a){const s=function(e,t,a){const s="Y"===e[0]?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${s} to the input \`${a}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(e,t,a);if(Pd.includes(e))throw new RangeError(s)}(n,t,String(e));return(0,yd[n[0]])(i,n,r.localize,d)}).join("")}function Ud(e){const t=e.match(Rd);return t?t[1].replace(Ld,"'"):e}function qd(e,t,a){const s=o.getDefaultOptions(),r=function(e,t,a){return new Intl.DateTimeFormat(a?[a.code,"en-US"]:void 0,{timeZone:t,timeZoneName:e})}(e,a.timeZone,a.locale??s.locale);return"formatToParts"in r?function(e,t){const a=e.formatToParts(t);for(let s=a.length-1;s>=0;--s)if("timeZoneName"===a[s].type)return a[s].value;return}(r,t):function(e,t){const a=e.format(t).replace(/\u200E/g,""),s=/ [\w-+ ]+$/.exec(a);return s?s[0].substr(1):""}(r,t)}function Od(e,t){const a=function(e){Hd[e]||(Hd[e]=Vd?new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}));return Hd[e]}(t);return"formatToParts"in a?function(e,t){try{const a=e.formatToParts(t),s=[];for(let e=0;e<a.length;e++){const t=Bd[a[e].type];void 0!==t&&(s[t]=parseInt(a[e].value,10))}return s}catch(a){if(a instanceof RangeError)return[NaN];throw a}}(a,e):function(e,t){const a=e.format(t),s=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(a);return[parseInt(s[3],10),parseInt(s[1],10),parseInt(s[2],10),parseInt(s[4],10),parseInt(s[5],10),parseInt(s[6],10)]}(a,e)}const Bd={year:0,month:1,day:2,hour:3,minute:4,second:5};const Hd={},$d=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),Vd="06/25/2014, 00:00:00"===$d||"06/25/2014 00:00:00"===$d;function Wd(e,t,a,s,r,n,o){const i=new Date(0);return i.setUTCFullYear(e,t,a),i.setUTCHours(s,r,n,o),i}const Gd=36e5,Yd={timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function Qd(e,t,a){if(!e)return 0;let s,r,n=Yd.timezoneZ.exec(e);if(n)return 0;if(n=Yd.timezoneHH.exec(e),n)return s=parseInt(n[1],10),Xd(s)?-s*Gd:NaN;if(n=Yd.timezoneHHMM.exec(e),n){s=parseInt(n[2],10);const e=parseInt(n[3],10);return Xd(s,e)?(r=Math.abs(s)*Gd+6e4*e,"+"===n[1]?-r:r):NaN}if(function(e){if(Zd[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),Zd[e]=!0,!0}catch(t){return!1}}(e)){t=new Date(t||Date.now());const s=a?t:function(e){return Wd(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t),r=Kd(s,e),n=a?r:function(e,t,a){const s=e.getTime();let r=s-t;const n=Kd(new Date(r),a);if(t===n)return t;r-=n-t;const o=Kd(new Date(r),a);if(n===o)return n;return Math.max(n,o)}(t,r,e);return-n}return NaN}function Kd(e,t){const a=Od(e,t),s=Wd(a[0],a[1]-1,a[2],a[3]%24,a[4],a[5],0).getTime();let r=e.getTime();const n=r%1e3;return r-=n>=0?n:1e3+n,s-r}function Xd(e,t){return-23<=e&&e<=23&&(null==t||0<=t&&t<=59)}const Zd={};const Jd={X:function(e,t,a){const s=ec(a.timeZone,e);if(0===s)return"Z";switch(t){case"X":return sc(s);case"XXXX":case"XX":return ac(s);default:return ac(s,":")}},x:function(e,t,a){const s=ec(a.timeZone,e);switch(t){case"x":return sc(s);case"xxxx":case"xx":return ac(s);default:return ac(s,":")}},O:function(e,t,a){const s=ec(a.timeZone,e);switch(t){case"O":case"OO":case"OOO":return"GMT"+function(e,t=""){const a=e>0?"-":"+",s=Math.abs(e),r=Math.floor(s/60),n=s%60;if(0===n)return a+String(r);return a+String(r)+t+tc(n,2)}(s,":");default:return"GMT"+ac(s,":")}},z:function(e,t,a){switch(t){case"z":case"zz":case"zzz":return qd("short",e,a);default:return qd("long",e,a)}}};function ec(e,t){const a=e?Qd(e,t,!0)/6e4:t?.getTimezoneOffset()??0;if(Number.isNaN(a))throw new RangeError("Invalid time zone specified: "+e);return a}function tc(e,t){const a=e<0?"-":"";let s=Math.abs(e).toString();for(;s.length<t;)s="0"+s;return a+s}function ac(e,t=""){const a=e>0?"-":"+",s=Math.abs(e);return a+tc(Math.floor(s/60),2)+t+tc(Math.floor(s%60),2)}function sc(e,t){if(e%60==0){return(e>0?"-":"+")+tc(Math.abs(e)/60,2)}return ac(e,t)}function rc(e){const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+e-+t}const nc=36e5,oc=6e4,ic={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/};function lc(e,t={}){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(null===e)return new Date(NaN);const a=null==t.additionalDigits?2:Number(t.additionalDigits);if(2!==a&&1!==a&&0!==a)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e))return new Date(e.getTime());if("number"==typeof e||"[object Number]"===Object.prototype.toString.call(e))return new Date(e);if("[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);const s=function(e){const t={};let a,s=ic.dateTimePattern.exec(e);s?(t.date=s[1],a=s[3]):(s=ic.datePattern.exec(e),s?(t.date=s[1],a=s[2]):(t.date=null,a=e));if(a){const e=ic.timeZone.exec(a);e?(t.time=a.replace(e[1],""),t.timeZone=e[1].trim()):t.time=a}return t}(e),{year:r,restDateString:n}=function(e,t){if(e){const a=ic.YYY[t],s=ic.YYYYY[t];let r=ic.YYYY.exec(e)||s.exec(e);if(r){const t=r[1];return{year:parseInt(t,10),restDateString:e.slice(t.length)}}if(r=ic.YY.exec(e)||a.exec(e),r){const t=r[1];return{year:100*parseInt(t,10),restDateString:e.slice(t.length)}}}return{year:null}}(s.date,a),o=function(e,t){if(null===t)return null;let a,s,r;if(!e||!e.length)return a=new Date(0),a.setUTCFullYear(t),a;let n=ic.MM.exec(e);if(n)return a=new Date(0),s=parseInt(n[1],10)-1,pc(t,s)?(a.setUTCFullYear(t,s),a):new Date(NaN);if(n=ic.DDD.exec(e),n){a=new Date(0);const e=parseInt(n[1],10);return function(e,t){if(t<1)return!1;const a=mc(e);if(a&&t>366)return!1;if(!a&&t>365)return!1;return!0}(t,e)?(a.setUTCFullYear(t,0,e),a):new Date(NaN)}if(n=ic.MMDD.exec(e),n){a=new Date(0),s=parseInt(n[1],10)-1;const e=parseInt(n[2],10);return pc(t,s,e)?(a.setUTCFullYear(t,s,e),a):new Date(NaN)}if(n=ic.Www.exec(e),n)return r=parseInt(n[1],10)-1,hc(r)?dc(t,r):new Date(NaN);if(n=ic.WwwD.exec(e),n){r=parseInt(n[1],10)-1;const e=parseInt(n[2],10)-1;return hc(r,e)?dc(t,r,e):new Date(NaN)}return null}(n,r);if(null===o||isNaN(o.getTime()))return new Date(NaN);if(o){const e=o.getTime();let a,r=0;if(s.time&&(r=function(e){let t,a,s=ic.HH.exec(e);if(s)return t=parseFloat(s[1].replace(",",".")),fc(t)?t%24*nc:NaN;if(s=ic.HHMM.exec(e),s)return t=parseInt(s[1],10),a=parseFloat(s[2].replace(",",".")),fc(t,a)?t%24*nc+a*oc:NaN;if(s=ic.HHMMSS.exec(e),s){t=parseInt(s[1],10),a=parseInt(s[2],10);const e=parseFloat(s[3].replace(",","."));return fc(t,a,e)?t%24*nc+a*oc+1e3*e:NaN}return null}(s.time),null===r||isNaN(r)))return new Date(NaN);if(s.timeZone||t.timeZone){if(a=Qd(s.timeZone||t.timeZone,new Date(e+r)),isNaN(a))return new Date(NaN)}else a=rc(new Date(e+r)),a=rc(new Date(e+r+a));return new Date(e+r+a)}return new Date(NaN)}function dc(e,t,a){t=t||0,a=a||0;const s=new Date(0);s.setUTCFullYear(e,0,4);const r=7*t+a+1-(s.getUTCDay()||7);return s.setUTCDate(s.getUTCDate()+r),s}const cc=[31,28,31,30,31,30,31,31,30,31,30,31],uc=[31,29,31,30,31,30,31,31,30,31,30,31];function mc(e){return e%400==0||e%4==0&&e%100!=0}function pc(e,t,a){if(t<0||t>11)return!1;if(null!=a){if(a<1)return!1;const s=mc(e);if(s&&a>uc[t])return!1;if(!s&&a>cc[t])return!1}return!0}function hc(e,t){return!(e<0||e>52)&&(null==t||!(t<0||t>6))}function fc(e,t,a){return!(e<0||e>=25)&&((null==t||!(t<0||t>=60))&&(null==a||!(a<0||a>=60)))}const xc=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function gc(e,t,a,s){return function(e,t,a={}){const s=(t=String(t)).match(xc);if(s){const r=lc(a.originalDate||e,a);t=s.reduce(function(e,t){if("'"===t[0])return e;const s=e.indexOf(t),n="'"===e[s-1],o=e.replace(t,"'"+Jd[t[0]](r,t,a)+"'");return n?o.substring(0,s-1)+o.substring(s+1):o},t)}return Fd(e,t,a)}(function(e,t,a){const s=Qd(t,e=lc(e,a),!0),r=new Date(e.getTime()-s),n=new Date(0);return n.setFullYear(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate()),n.setHours(r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()),n}(e,t,{timeZone:(s={...s,timeZone:t,originalDate:e}).timeZone}),a,s)}const bc={"pt-BR":Qn,"en-US":Ln,"es-ES":Hn},vc=(e,t=Pr,a=Ir)=>{if(!e)return"";const s=o.parseISO(e);if(!o.isValid(s))return"Data inválida";const r=bc[t]||Qn;try{return gc(s,a,"PP",{locale:r})}catch(n){return gc(s,Ir,"PP",{locale:r})}};class wc{static async sendEmail(e){const t=Sa(),{data:a,error:s}=await t.functions.invoke("send-email",{body:{template_code:e.templateCode,to:e.to,variables:e.variables,cc:e.cc,bcc:e.bcc,replyTo:e.replyTo}});if(s)throw s;return a}}const Nc=wc,yc=(void 0).VITE_SUPABASE_URL,jc=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;let Cc=null;var kc=Object.defineProperty,Sc=(e,t,a)=>((e,t,a)=>t in e?kc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const Tc=new class{constructor(){Sc(this,"cache",{}),Sc(this,"cacheTimestamps",new Map),Sc(this,"CACHE_TTL",3e5),Sc(this,"loadingPromises",new Map)}isCacheValid(e){const t=this.cacheTimestamps.get(e);return!!t&&Date.now()-t<this.CACHE_TTL}async loadTranslations(e){if(this.isCacheValid(e))return this.cache[e]||{};const t=this.loadingPromises.get(e);if(t)return t;const a=this.fetchTranslations(e);this.loadingPromises.set(e,a);try{return await a}finally{this.loadingPromises.delete(e)}}async fetchTranslations(e){try{const t=(!Cc&&yc&&jc&&(Cc=b.createClient(yc,jc,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1}})),Cc),{data:a,error:s}=await t.schema("common").from("translations").select("key, pt, en, es").eq("is_removed",!1);if(s)return"42501"===s.code||"PGRST301"===s.code||s.message?.includes("permission denied")||s.message?.includes("No suitable key"),{};const r={};return a?.forEach(t=>{let a;a="pt-BR"===e?t.pt:"en-US"===e?t.en||t.pt:"es-ES"===e&&t.es||t.pt,a&&(r[t.key]=a)}),this.cache[e]=r,this.cacheTimestamps.set(e,Date.now()),r}catch(t){return{}}}async upsertTranslation(e,t,a,s){const r=Sa(),{error:n}=await r.schema("common").from("translations").upsert({key:e,pt:t,en:a,es:s},{onConflict:"key"});if(n)throw n;this.clearCache()}async bulkUpsertTranslations(e){const t=Sa(),{error:a}=await t.schema("common").from("translations").upsert(e.map(e=>({key:e.key,pt:e.pt,en:e.en,es:e.es})),{onConflict:"key"});if(a)throw a;this.clearCache()}clearCache(){this.cache={},this.cacheTimestamps.clear()}clearCacheForLocale(e){delete this.cache[e],this.cacheTimestamps.delete(e)}};function _c({open:a,onOpenChange:s,placeId:r,placeName:n,onMakeManager:o,onMakeMembers:i,currentManagerId:d,currentMemberIds:c=[]}){const[u,m]=t.useState([]),[p,h]=t.useState(!1),[f,x]=t.useState(""),{data:g=[],isLoading:b}=or({enabled:a}),v=t.useMemo(()=>{let e=[...g];if(e.sort((e,t)=>{const a=e.userName?.toLowerCase()||"",s=t.userName?.toLowerCase()||"";return a.localeCompare(s)}),f){const t=f.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(t)||e.userEmail?.toLowerCase().includes(t))}return e},[g,f]),w=e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},N=1===u.length,y=u.length>0;return e.jsx(Be,{open:a,onOpenChange:s,children:e.jsxs(Ye,{className:"max-w-2xl",children:[e.jsx(Qe,{showSeparator:!0,children:e.jsxs(Ze,{className:"flex items-center gap-2",children:[e.jsx(l.Users,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),e.jsxs(Ke,{children:[e.jsxs("div",{className:"relative mb-4",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Me,{placeholder:"Pesquisar...",value:f,onChange:e=>x(e.target.value),className:"pl-9"})]}),e.jsx(tr,{className:"h-[400px] pr-4",children:b?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((t,a)=>e.jsx(sa,{className:"h-16 w-full"},a))}):0===v.length?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(l.Users,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:f?"Nenhum usuário encontrado":"Nenhum usuário disponível"})]}):e.jsx("div",{className:"space-y-2",children:v.map(t=>{const a=t.userId===d,s=c.includes(t.userId||""),r=u.includes(t.userId||"");return e.jsxs("div",{className:Te("flex items-center gap-3 p-3 rounded-lg border transition-colors",r&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>w(t.userId||""),children:[e.jsx(vt,{checked:r,onCheckedChange:()=>w(t.userId||""),onClick:e=>e.stopPropagation()}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:t.userName}),a&&e.jsx(l.Crown,{className:"h-4 w-4 text-yellow-500"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t.userEmail})]}),(a||s)&&e.jsx("div",{className:"text-xs text-muted-foreground",children:a?"Gestor":"Membro"})]},t.userId)})})})]}),e.jsxs(Xe,{className:"flex gap-2 sm:gap-2",children:[e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:u.length>0&&e.jsxs("span",{children:[u.length," selecionado(s)"]})}),N&&o&&e.jsxs(Ee,{onClick:async()=>{if(o&&1===u.length){h(!0);try{await o(u[0],r),m([])}finally{h(!1)}}},disabled:p,variant:"outline",children:[e.jsx(l.Crown,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),y&&i&&e.jsxs(Ee,{onClick:async()=>{if(i&&0!==u.length){h(!0);try{await i(u,r),m([])}finally{h(!1)}}},disabled:p,children:[e.jsx(l.UserPlus,{className:"h-4 w-4 mr-2"}),"Tornar ",u.length>1?"Membros":"Membro"]})]})]})})}function Ac({place:a,level:s=0,manageAccessConfig:r}){const[n,o]=t.useState(!1),[i,d]=t.useState(!1),c=a.subPlaces&&a.subPlaces.length>0,u=a.isActive??!0,m=a.usersCount??0;return e.jsxs("div",{children:[e.jsxs($r,{open:n,onOpenChange:o,children:[e.jsxs("div",{className:"flex items-center gap-2 py-3 px-4 hover:bg-accent/50 transition-colors",style:{paddingLeft:2*s+1+"rem"},children:[c?e.jsxs(Vr,{className:"flex items-center gap-2 flex-1",children:[e.jsx(l.ChevronRight,{className:Te("h-4 w-4 transition-transform shrink-0",n&&"rotate-90")}),e.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:a.name}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",a.subPlaces.length,")"]})]}):e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx("div",{className:"w-4 shrink-0"}),e.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:a.name})]}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(l.Users,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:m})]}),e.jsx(yt,{variant:u?"default":"secondary",className:"text-xs",children:u?"Ativo":"Inativo"}),r&&e.jsx(yl,{customActions:[{label:"Gerenciar Acessos",icon:l.Settings,onClick:()=>d(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),c&&e.jsx(Wr,{children:a.subPlaces.map(t=>e.jsx(Ac,{place:t,level:s+1,manageAccessConfig:r},t.id))})]}),0===s&&e.jsx(Oe,{}),r&&e.jsx(_c,{open:i,onOpenChange:d,placeId:a.id,placeName:a.name,onMakeManager:r.onMakeManager,onMakeMembers:r.onMakeMembers,currentManagerId:r.getCurrentManagerId?.(a.id),currentMemberIds:r.getCurrentMemberIds?.(a.id)})]})}var Ec=Object.defineProperty,Pc=(e,t,a)=>((e,t,a)=>t in e?Ec(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,t+"",a);const Mc=new class{constructor(){Pc(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,t,a){const s=Ia.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=xa.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!a||""===a.trim())throw new Error("Alias da unidade é obrigatório");const n=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{n.searchParams.append(e,t)});const o=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!o.ok){const e=new Error(`API call failed: ${o.status}`);throw e.status=o.status,e}return o.json()}buildHierarchy(e){const t=new Map,a=[];return e.forEach(e=>{t.set(e.id,{...e,subPlaces:[]})}),e.forEach(e=>{const s=t.get(e.id);if(e.parentId){const r=t.get(e.parentId);r?(r.subPlaces=r.subPlaces||[],r.subPlaces.push(s)):a.push(s)}else a.push(s)}),a}async getPlaces(e,t){try{const a=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),s=a.data||a||[];return this.buildHierarchy(s)}catch(a){if(await Ia.handleApiError(a))try{const a=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),s=a.data||a||[];return this.buildHierarchy(s)}catch(s){return va.handleError(s instanceof Error?s:"Erro ao buscar locais após renovação de token",!0),[]}return va.handleError(a instanceof Error?a.message:"Erro ao buscar locais",!0),[]}}};function Ic(e){const t=new Map,a=new Map,s=[];e.forEach(e=>{const s={...e,children:[],level:0};t.set(e.id,s),a.set(e.id_user,s)}),e.forEach(e=>{const r=t.get(e.id);if(e.id_leader){const t=a.get(e.id_leader);if(t)return void t.children.push(r)}s.push(r)});const r=(e,t)=>{e.level=t,e.children.forEach(e=>r(e,t+1))};s.forEach(e=>r(e,0));const n=e=>{e.sort((e,t)=>{const a=e.name||e.id_user||e.email||"",s=t.name||t.id_user||t.email||"";return a.localeCompare(s)}),e.forEach(e=>e.children.length>0&&n(e.children))};return n(s),s}function Dc(e){const t=[],a=e=>{t.push(e),e.children.forEach(a)};return e.forEach(a),t}function Rc(){const{alias:e,isAuthenticated:t}=ls(),a=xa.getAccessToken(),{data:s=[]}=or({enabled:!0});return v.useQuery({queryKey:["leadership",e,s.length],queryFn:async()=>{if(!a||!e)throw new Error("Usuário não autenticado ou unidade não selecionada");const t=Sa(),{data:r,error:n}=await t.schema("common").from("leaders").select("*").eq("is_removed",!1).eq("alias",e);if(n)throw new Error("Erro ao buscar hierarquia de liderança");if(!r||0===r.length)return[];const o={};s.forEach(e=>{o[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const i=r.map(e=>({...e,name:o[e.id_user]?.name||"[Não encontrado]",email:o[e.id_user]?.email||"",subordinatesCount:r.filter(t=>t.id_leader===e.id_user).length})),l=new Set(r.map(e=>e.id_user));return new Set(r.filter(e=>e.id_leader&&!l.has(e.id_leader)).map(e=>e.id_leader)).forEach(e=>{const t=o[e];i.push({id:`virtual-${e}`,alias:r[0]?.alias||"",id_user:e,id_leader:null,is_removed:!1,is_active:!0,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),name:t?.name||"[Não encontrado]",email:t?.email||"",subordinatesCount:r.filter(t=>t.id_leader===e).length})}),Ic(i)},enabled:!!a&&!!e&&t&&s.length>0})}function Lc(){const e="common",{alias:t}=ls(),a=v.useQueryClient(),s=Sa();return v.useMutation({mutationFn:async a=>{if(!t)throw new Error("Unidade não selecionada");if(a.id_user===a.id_leader)throw new Error("Usuário não pode ser seu próprio líder");a.id_leader&&await Oc(s,t,e,a.id_user,a.id_leader);const{data:r,error:n}=await s.schema(e).from("leaders").insert({alias:t,id_user:a.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return r},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",t]}),i.toast.success("Líder virtual promovido com sucesso")},onError:e=>{i.toast.error(e.message||"Erro ao criar líder")}})}function zc(){const e="common",{alias:t}=ls(),a=v.useQueryClient(),s=Sa();return v.useMutation({mutationFn:async a=>{if(!t)throw new Error("Unidade não selecionada");if(!a.users.length)throw new Error("Selecione pelo menos um liderado");const r=a.users.map(e=>e.id_user),{data:n}=await s.schema(e).from("leaders").select("id_user").eq("alias",t).in("id_user",r).eq("is_removed",!1);if(n&&n.length>0){const e=n.map(e=>e.id_user);throw new Error(`Alguns usuários já estão cadastrados como líderes: ${e.join(", ")}`)}for(const d of a.users){if(a.id_leader&&d.id_user===a.id_leader)throw new Error("Usuário não pode ser seu próprio líder");a.id_leader&&await Oc(s,t,e,d.id_user,a.id_leader)}const o=a.users.map(e=>({alias:t,id_user:e.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1})),{data:i,error:l}=await s.schema(e).from("leaders").insert(o).select();if(l)throw l;return i},onSuccess:e=>{a.invalidateQueries({queryKey:["leadership",t]}),i.toast.success(`${e?.length||0} liderado(s) adicionado(s) com sucesso`)},onError:e=>{i.toast.error(e.message||"Erro ao adicionar liderados")}})}function Fc(){const e="common",{alias:t}=ls(),a=v.useQueryClient(),s=Sa();return v.useMutation({mutationFn:async a=>{if(!t)throw new Error("Unidade não selecionada");const{data:r}=await s.schema(e).from("leaders").select("id_user").eq("id",a.id).eq("alias",t).single();if(!r)throw new Error("Líder não encontrado");if(r.id_user===a.id_leader)throw new Error("Usuário não pode ser seu próprio líder");a.id_leader&&await Oc(s,t,e,r.id_user,a.id_leader,a.id);const{data:n,error:o}=await s.schema(e).from("leaders").update({id_leader:a.id_leader}).eq("id",a.id).eq("alias",t).select().single();if(o)throw o;return n},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",t]}),i.toast.success("Líder atualizado com sucesso")},onError:e=>{i.toast.error(e.message||"Erro ao atualizar líder")}})}function Uc(){const{alias:e}=ls(),t=v.useQueryClient(),a=Sa();return v.useMutation({mutationFn:async t=>{if(!e)throw new Error("Unidade não selecionada");const{error:s}=await a.schema("common").from("leaders").update({is_removed:!0}).eq("id",t).eq("alias",e);if(s)throw s},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",e]}),i.toast.success("Líder removido com sucesso")},onError:e=>{i.toast.error(e.message||"Erro ao remover líder")}})}function qc(){const e="common",{alias:t}=ls(),a=v.useQueryClient(),s=Sa();return v.useMutation({mutationFn:async({leaderUserId:a,selectedUsers:r})=>{if(!t)throw new Error("Unidade não selecionada");const n=r.map(e=>e.id_user),o=await Promise.all([s.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1).eq("id_leader",a),s.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1).in("id_user",n.length?n:["__none__"])]),[{data:i,error:l},{data:d,error:c}]=o;if(l)throw l;if(c)throw c;const u=i||[],m=d||[],p=new Set(n),h=u.filter(e=>!p.has(e.id_user)),f=m.filter(e=>e.id_leader!==a),x=new Set(m.map(e=>e.id_user)),g=r.filter(e=>!x.has(e.id_user));for(const w of f)await Oc(s,t,e,w.id_user,a,w.id);for(const w of g){if(w.id_user===a)throw new Error("Usuário não pode ser seu próprio líder");await Oc(s,t,e,w.id_user,a)}const b=[];if(h.length){const a=h.map(e=>e.id);b.push(s.schema(e).from("leaders").update({is_removed:!0}).in("id",a).eq("alias",t))}if(f.length){const r=f.map(e=>e.id);b.push(s.schema(e).from("leaders").update({id_leader:a}).in("id",r).eq("alias",t))}if(g.length){const r=g.map(e=>({alias:t,id_user:e.id_user,id_leader:a,is_active:!0,is_removed:!1}));b.push(s.schema(e).from("leaders").insert(r))}const v=(await Promise.all(b)).find(e=>e?.error);if(v?.error)throw v.error;return{unlinked:h.length,updated:f.length,created:g.length}},onSuccess:e=>{a.invalidateQueries({queryKey:["leadership",t]}),i.toast.success(`Subordinados sincronizados (${e.created} adicionados, ${e.updated} atualizados, ${e.unlinked} removidos)`)},onError:e=>{i.toast.error(e.message||"Erro ao sincronizar subordinados")}})}async function Oc(e,t,a,s,r,n){const{data:o,error:i}=await e.schema(a).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1);if(i)throw i;const l=n?o.filter(e=>e.id!==n):o,d=new Set;let c=r;for(;c;){if(d.has(c))throw new Error("Esta associação criaria um ciclo na hierarquia");if(c===s)throw new Error("Esta associação criaria um ciclo na hierarquia");d.add(c);const e=l.find(e=>e.id_user===c);c=e?.id_leader||null}}function Bc({leader:t,expandedIds:a,onToggleExpand:s,onEdit:r}){const n=a.has(t.id),o=t.children.length>0,i=32*t.level;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[e.jsx("td",{className:"py-3 px-4",children:e.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${i}px`},children:[o?e.jsx("button",{onClick:()=>s(t.id),className:"p-1 hover:bg-accent rounded",children:n?e.jsx(l.ChevronDown,{className:"h-4 w-4"}):e.jsx(l.ChevronRight,{className:"h-4 w-4"})}):e.jsx("div",{className:"w-6"}),e.jsx(l.User,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("button",{onClick:()=>{r(t)},className:"font-medium hover:text-primary hover:underline text-left",children:t.name||t.id_user||t.email})]})}),e.jsx("td",{className:"py-3 px-4 text-center",children:e.jsx("span",{className:"text-sm",children:t.subordinatesCount||0})})]}),o&&n&&t.children.map(t=>e.jsx(Bc,{leader:t,expandedIds:a,onToggleExpand:s,onEdit:r},t.id))]})}var Hc=function(e,t){for(var a={};e.length;){var s=e[0],r=s.code,n=s.message,o=s.path.join(".");if(!a[o])if("unionErrors"in s){var i=s.unionErrors[0].errors[0];a[o]={message:i.message,type:i.code}}else a[o]={message:n,type:r};if("unionErrors"in s&&s.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var l=a[o].types,d=l&&l[s.code];a[o]=m.appendErrors(o,t,a,r,d?[].concat(d,s.message):s.message)}e.shift()}return a},$c=function(e,t,a){return void 0===a&&(a={}),function(s,r,n){try{return Promise.resolve(function(r,o){try{var i=Promise.resolve(e["sync"===a.mode?"parse":"parseAsync"](s,t)).then(function(e){return n.shouldUseNativeValidation&&X.validateFieldsNatively({},n),{errors:{},values:a.raw?s:e}})}catch(l){return o(l)}return i&&i.then?i.then(void 0,o):i}(0,function(e){if(function(e){return Array.isArray(null==e?void 0:e.errors)}(e))return{values:{},errors:X.toNestErrors(Hc(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(o){return Promise.reject(o)}}};const Vc=K.z.object({id_leader:K.z.string().nullable(),id_users:K.z.array(K.z.string()).min(1,"Selecione pelo menos um liderado")}),Wc=K.z.object({id_leader:K.z.string().nullable(),id_users:K.z.array(K.z.string())});function Gc({value:a,onChange:s,excludeUserIds:r=[],error:n}){const{data:o=[],isLoading:i}=or(),[d,c]=t.useState(""),u=t.useRef(null),m=t.useRef(0),p=o.filter(e=>!r.includes(e.userId||"")).filter(e=>{const t=d.toLowerCase(),a=e.userName?.toLowerCase().includes(t);return a}).sort((e,t)=>{const s=a.includes(e.userId),r=a.includes(t.userId);if(s&&!r)return-1;if(!s&&r)return 1;const n=e.userName||e.userEmail||"",o=t.userName||t.userEmail||"";return n.localeCompare(o)});return t.useEffect(()=>{u.current&&m.current>0&&(u.current.scrollTop=m.current)},[p]),i?e.jsxs("div",{className:"flex items-center justify-center p-4",children:[e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin"}),e.jsx("span",{className:"ml-2",children:"Carregando dados..."})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{placeholder:"Buscar usuário...",value:d,onChange:e=>c(e.target.value)}),e.jsx("div",{ref:u,className:"border rounded-md p-4 max-h-[300px] overflow-y-auto",children:0===p.length?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Buscar usuário..."}):e.jsx("div",{className:"space-y-2",children:p.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(vt,{id:t.userId,checked:a.includes(t.userId),onCheckedChange:()=>{return e=t.userId,u.current&&(m.current=u.current.scrollTop),void(a.includes(e)?s(a.filter(t=>t!==e)):s([...a,e]));var e}}),e.jsx(De,{htmlFor:t.userId,className:"flex-1 cursor-pointer",children:t.userName||t.userEmail})]},t.userId))})}),a.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.length," selecionado(s)"]}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function Yc({leader:a,prefilledLeaderId:s,onSuccess:r}){const{alias:n}=ls(),o=!!a,i=a?.id.startsWith("virtual-"),d=zc(),c=Lc(),u=Fc(),p=qc(),h=Uc(),{data:f=[]}=Rc(),{data:x=[]}=or(),[g,b]=t.useState(""),v=Dc(f).map(e=>e.id_user),w=o?Dc(f).filter(e=>e.id_leader===a.id_user).map(e=>e.id_user):[],N=m.useForm({resolver:$c(o?Wc:Vc),defaultValues:{id_leader:s||(o?a?.id_leader:null)||null,id_users:o?w:[]}});t.useEffect(()=>{if(a){const e=Dc(f).filter(e=>e.id_leader===a.id_user).map(e=>e.id_user);N.reset({id_leader:a.id_leader||null,id_users:e})}else s?N.reset({id_leader:s,id_users:[]}):N.reset({id_leader:null,id_users:[]})},[n,a?.id,a?.id_user,a?.id_leader,s,f]);const y=d.isPending||c.isPending||u.isPending||p.isPending||h.isPending,j=N.watch("id_leader"),C=N.watch("id_users"),k=o?[a.id_user,...v.filter(e=>e!==a.id_user&&!C.includes(e)&&!w.includes(e))]:[j,...v.filter(e=>!C.includes(e))].filter(Boolean);return e.jsxs("form",{onSubmit:N.handleSubmit(async e=>{try{if(o)if(i){await c.mutateAsync({id_user:a.id_user,id_leader:e.id_leader});const t=x.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await p.mutateAsync({leaderUserId:a.id_user,selectedUsers:t})}else{await u.mutateAsync({id:a.id,id_leader:e.id_leader});const t=x.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await p.mutateAsync({leaderUserId:a.id_user,selectedUsers:t})}else{const t=x.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await d.mutateAsync({id_leader:e.id_leader,users:t})}r?.()}catch(t){}}),className:"space-y-4",children:[o&&e.jsxs("div",{children:[e.jsx(De,{children:"Líder"}),e.jsx(Me,{value:x.find(e=>e.userId===a.id_user)?.userName||a.name||a.id_user,disabled:!0,className:"bg-muted"})]}),e.jsxs("div",{children:[e.jsx(De,{children:"Superior Imediato"}),e.jsxs(dt,{value:j||"none",onValueChange:e=>N.setValue("id_leader","none"===e?null:e),children:[e.jsx(mt,{children:e.jsx(ut,{placeholder:"Selecione..."})}),e.jsxs(ft,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:e.jsx(Me,{placeholder:"Buscar superior...",value:g,onChange:e=>b(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),e.jsxs(tr,{className:"h-[200px]",children:[e.jsx(gt,{value:"none",children:"[Nenhum]"}),x.filter(e=>{const t=o?e.userId!==a.id_user:!C.includes(e.userId),s=!g||e.userName?.toLowerCase().includes(g.toLowerCase());return t&&s}).sort((e,t)=>{const a=e.userName||e.userEmail||"",s=t.userName||t.userEmail||"";return a.localeCompare(s)}).map(t=>e.jsx(gt,{value:t.userId,children:t.userName},t.userId))]})]})]},`superior-select-${n}`),N.formState.errors.id_leader&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:N.formState.errors.id_leader.message})]}),e.jsxs("div",{children:[e.jsx(De,{children:"Subordinados *"}),e.jsx(Gc,{value:C,onChange:e=>N.setValue("id_users",e),excludeUserIds:k,error:N.formState.errors.id_users?.message},`users-multiselect-${n}`)]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(Ee,{type:"submit",disabled:y||!o&&0===C.length,children:y&&!h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),o?"Atualizando...":"Salvando..."]}):o?(C.length,"Atualizar"):"Criar"}),o&&!j&&0===C.length&&e.jsx(Ee,{type:"button",variant:"destructive",disabled:y,onClick:async()=>{if(a&&window.confirm("Tem certeza que deseja remover?"))try{await h.mutateAsync(a.id),r?.()}catch(e){}},className:"ml-auto",children:h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Removendo..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Trash2,{className:"mr-2 h-4 w-4"}),"Remover"]})})]})]})}function Qc({open:t,onOpenChange:a,leader:s,prefilledLeaderId:r,title:n}){return e.jsx(Be,{open:t,onOpenChange:a,children:e.jsxs(Ye,{className:"sm:max-w-[500px]",children:[e.jsx(Qe,{showSeparator:!0,children:e.jsx(Ze,{children:n})}),e.jsx(Ke,{children:e.jsx(Yc,{leader:s,prefilledLeaderId:r,onSuccess:()=>a(!1)})})]})})}const Kc="leadership-expanded-nodes",Xc=(e,t)=>{try{localStorage.setItem(`${Kc}-${e}`,JSON.stringify(Array.from(t)))}catch(a){}};function Zc(e){const[a,s]=t.useState(!1),[r,n]=t.useState(0),{uploadFunction:o,deleteFunction:l,defaultOptions:d,onSuccess:c,onError:u}=e||{};return{upload:async(e,t)=>{if(!o){const e=new Error("uploadFunction não fornecida");throw i.toast.error("Erro de configuração",{description:"Função de upload não configurada. Verifique a documentação."}),e}s(!0),n(0);try{const a={...d,...t};if(a.maxSize&&e.size>a.maxSize)throw new Error(`Arquivo muito grande. Tamanho máximo: ${Math.round(a.maxSize/1024/1024)}MB`);if(a.allowedTypes){const t=a.allowedTypes.some(t=>t.endsWith("/*")?e.type.startsWith(t.replace("/*","")):e.type===t);if(!t)throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${a.allowedTypes.join(", ")}`)}const s=await o(e,a);return n(100),i.toast.success("Sucesso",{description:"Arquivo enviado com sucesso"}),c?.(s),s}catch(a){const e=a instanceof Error?a:new Error("Erro ao fazer upload");throw i.toast.error("Erro",{description:e.message}),u?.(e),e}finally{s(!1)}},deleteMedia:async(e,t)=>{if(!l){const e=new Error("deleteFunction não fornecida");throw i.toast.error("Erro de configuração",{description:"Função de delete não configurada."}),e}try{await l(e,t),i.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(a){throw i.toast.error("Erro",{description:"Erro ao remover o arquivo"}),a}},uploading:a,progress:r}}function Jc(e){const t=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const a of t){const t=e.match(a);if(t)return t[1]}return null}function eu(e,t){const a=Jc(e);if(!a)return e;return`https://www.youtube.com/embed/${a}${t?"?autoplay=1&mute=1":""}`}function tu(e){const t=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return t?t[1]:null}function au(e,t){const a=tu(e);if(!a)return e;return`https://player.vimeo.com/video/${a}${t?"?autoplay=1&muted=1":""}`}function su(e){if(!e)return;const t=e.match(/src="([^"]+)"/);return t?t[1]:void 0}function ru(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function nu(e,t){return e/t}const ou=(void 0).VITE_SUPABASE_URL,iu=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;async function lu(e,t,a){const s=xa.getSupabaseToken(),r={"Content-Type":"application/json",apikey:iu};s&&(r.Authorization=`Bearer ${s}`);const n=await fetch(`${ou}/functions/v1/${e}`,{method:"POST",headers:r,body:JSON.stringify({action:t,data:a})});if(!n.ok){const e=await n.json().catch(()=>({}));throw new Error(e.error||`Erro na requisição: ${n.status}`)}return n}const du={resolveProvider:async e=>"clicksign",async createEnvelopeWithSigner(e){const t="d4sign"===e.provider?"d4sign":"clicksign",a="d4sign"===e.provider?"create_and_send":"create_envelope_with_signer";return(await lu(t,a,{content_base64:e.contentBase64,filename:e.filename,signer_email:e.signerEmail,signer_name:e.signerName})).json()},async getSignedDocument(e){const t="d4sign"===e.provider?"d4sign":"clicksign";return(await lu(t,"get_signed_document",{envelope_id:e.envelopeId,document_id:e.documentId})).json()}},cu="clicksign-container";function uu({signerId:a,environment:s="sandbox",onSign:r,onError:n,onClose:o}){const i=t.useRef(null),[d,c]=t.useState(!0);return t.useEffect(()=>{if(i.current&&i.current.unmount(),!window.Clicksign)return void n?.(new Error("Script do Clicksign não carregado"));const e=new window.Clicksign(a);return e.endpoint="production"===s?"https://app.clicksign.com":"https://sandbox.clicksign.com",e.origin=window.origin,e.mount(cu),e.on("loaded",function(e){c(!1)}),e.on("signed",function(e){r?.()}),e.on("resized",function(e){const t=e,a=document.getElementById(cu);a&&t?.data?.height&&(a.style.height=t.data.height+"px")}),e.on("error",function(e){c(!1),n?.(e instanceof Error?e:new Error("Erro no widget de assinatura"))}),e.on("closed",function(){o?.()}),i.current=e,()=>{i.current&&(i.current.unmount(),i.current=null)}},[a,s]),e.jsxs("div",{className:"relative h-full",children:[d&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(l.Loader2,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),e.jsx("div",{id:cu,style:{height:"600px"}})]})}function mu({documentKey:a,signerEmail:s,signerName:r,keySigner:n,environment:o,onSign:i,onError:d}){const c=t.useRef(null),[u,m]=t.useState("loading"),[p,h]=t.useState(null),f="production"===o?"https://secure.d4sign.com.br/embed/viewblob":"https://sandbox.d4sign.com.br/embed/viewblob",x=(()=>{const e=new URLSearchParams({email:s,display_name:r||"",disable_preview:"0"});return n&&e.set("key_signer",n),`${f}/${a}?${e.toString()}`})(),g=t.useCallback(e=>"signed"===e.data?(m("ready"),void i?.()):"wrong-data"===e.data?(m("error"),h("O signatário reportou dados incorretos."),void d?.(new Error("O signatário reportou dados incorretos"))):void 0,[i,d]);t.useEffect(()=>(window.addEventListener("message",g,!1),()=>{window.removeEventListener("message",g,!1)}),[g]);const b=t.useCallback(()=>{"loading"===u&&m("ready")},[u,x]);return"error"===u?e.jsxs(Nr,{variant:"danger",className:"my-4",children:[e.jsx(yr,{children:"Erro ao carregar documento"}),e.jsx(jr,{children:p||"Ocorreu um erro inesperado ao carregar o documento para assinatura. Tente novamente."})]}):e.jsxs("div",{className:"relative h-full",children:["loading"===u&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(l.Loader2,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),e.jsx("iframe",{ref:c,id:"d4sign-container",src:x,width:"100%",style:{height:"600px",border:0},allow:"geolocation",onLoad:b})]})}function pu(){const{alias:e}=ls(),[a,s]=t.useState(null),[r,n]=t.useState(!0);t.useEffect(()=>{if(!e)return void n(!1);let t=!1;return(async()=>{n(!0);try{const a=Sa(),{data:r,error:n}=await a.schema("common").from("clicksign_configs").select("*").eq("alias",e).is("deleted_at",null).maybeSingle();t||s(r)}catch(a){t||s(null)}finally{t||n(!1)}})(),()=>{t=!0}},[e]);const o=t.useCallback(async(t,a)=>{if(!e)throw new Error("Alias not available");const r=Sa(),{data:n,error:o}=await r.schema("common").from("clicksign_configs").upsert({alias:e,api_key:t,environment:a,updated_at:(new Date).toISOString()},{onConflict:"alias"}).select().maybeSingle();if(o)throw o;return s(n),n},[e]);return{config:a,isLoading:r,saveConfig:o}}Object.defineProperty(exports,"sonnerToast",{enumerable:!0,get:function(){return i.toast}}),Object.defineProperty(exports,"toast",{enumerable:!0,get:function(){return i.toast}}),Object.defineProperty(exports,"I18nextProvider",{enumerable:!0,get:function(){return S.I18nextProvider}}),Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:function(){return S.useTranslation}}),exports.i18n=T,exports.AUTH_CONFIG=za,exports.Accordion=Kr,exports.AccordionContent=Jr,exports.AccordionItem=Xr,exports.AccordionTrigger=Zr,exports.ActionButton=Pe,exports.ActionMenu=yl,exports.ActionMenuItems=Us,exports.Alert=Nr,exports.AlertDescription=jr,exports.AlertDialog=en,exports.AlertDialogAction=cn,exports.AlertDialogCancel=un,exports.AlertDialogContent=rn,exports.AlertDialogDescription=dn,exports.AlertDialogFooter=on,exports.AlertDialogHeader=nn,exports.AlertDialogOverlay=sn,exports.AlertDialogPortal=an,exports.AlertDialogTitle=ln,exports.AlertDialogTrigger=tn,exports.AlertTitle=yr,exports.AppHeader=El,exports.AppLayout=sd,exports.AppSidebar=ad,exports.AuthErrorInterceptor=Pa,exports.AuthProvider=is,exports.AuthService=ns,exports.Avatar=mn,exports.AvatarFallback=hn,exports.AvatarImage=pn,exports.Badge=yt,exports.BaseForm=lr,exports.Blockquote=Po,exports.BodyContent=function({breadcrumbs:t,children:a,className:s}){return e.jsxs("div",{className:Te("bg-neutral-100 dark:bg-neutral-900","h-full overflow-y-auto","p-6",s),children:[t&&t.length>0&&e.jsx(fn,{className:"mb-4",children:e.jsx(xn,{children:t.map((a,s)=>{const r=s===t.length-1;return e.jsxs(J.Fragment,{children:[s>0&&e.jsx(wn,{}),e.jsx(gn,{children:r||!a.href?e.jsx(vn,{children:a.label}):a.asChild&&a.children?e.jsx(bn,{asChild:!0,children:a.children}):e.jsx(bn,{asChild:!0,children:e.jsx(w.Link,{to:a.href||"/",children:a.label})})})]},`${a.label}-${s}`)})})}),e.jsx("div",{className:"space-y-6",children:a})]})},exports.Breadcrumb=fn,exports.BreadcrumbEllipsis=Nn,exports.BreadcrumbItem=gn,exports.BreadcrumbLink=bn,exports.BreadcrumbList=xn,exports.BreadcrumbPage=vn,exports.BreadcrumbSeparator=wn,exports.Button=Ee,exports.ButtonGroup=jn,exports.CRUD_CONFIG=Fa,exports.Calendar=Kn,exports.CallbackPage=()=>{const{processCallback:a}=ls(),s=w.useNavigate(),[r,n]=t.useState(null),[o,i]=t.useState(!1);t.useEffect(()=>{(async()=>{try{if(await a()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");localStorage.removeItem("auth_return_url"),s(e||"/",{replace:!0})}else n("Falha na autenticação. Tente novamente.")}catch(e){localStorage.removeItem("auth_return_url"),n(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[a,s]);const d=async()=>{i(!0),n(null);try{await a()||n("Falha na autenticação. Tente novamente.")}catch(e){n(e?.message||"Erro ao tentar novamente.")}finally{i(!1)}},c=()=>{window.location.href="/"};return r?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(Re,{className:"w-full max-w-md",children:[e.jsx(Le,{className:"text-center",children:e.jsxs(ze,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[e.jsx(l.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),e.jsxs(Ue,{className:"space-y-4",children:[e.jsx(Nr,{variant:"danger",children:e.jsx(jr,{children:r})}),e.jsx("div",{className:"text-sm text-muted-foreground",children:e.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ee,{onClick:d,disabled:o,className:"flex-1",children:o?e.jsxs(e.Fragment,{children:[e.jsx(Ct,{size:"sm",className:"mr-2"}),"Tentando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),e.jsx(Ee,{onClick:c,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(Re,{className:"w-full max-w-md",children:[e.jsx(Le,{className:"text-center",children:e.jsx(ze,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),e.jsxs(Ue,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(Ct,{size:"lg"})}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=Re,exports.CardContent=Ue,exports.CardDescription=Fe,exports.CardFooter=qe,exports.CardHeader=Le,exports.CardSkeleton=vs,exports.CardTitle=ze,exports.ChartContainer=ll,exports.ChartLegend=ml,exports.ChartLegendContent=pl,exports.ChartStyle=dl,exports.ChartTooltip=cl,exports.ChartTooltipContent=ul,exports.Checkbox=vt,exports.Collapsible=$r,exports.CollapsibleContent=Wr,exports.CollapsibleTrigger=Vr,exports.ColorPicker=er,exports.Combobox=oa,exports.Command=Qt,exports.CommandDialog=({children:t,...a})=>e.jsx("div",{...a,children:e.jsx(Qt,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:t})}),exports.CommandEmpty=Zt,exports.CommandGroup=Jt,exports.CommandInput=Kt,exports.CommandItem=ta,exports.CommandList=Xt,exports.CommandSeparator=ea,exports.CommandShortcut=aa,exports.ContentContainer=function({title:t,subtitle:a,children:s,className:r,hasHeader:n=!0}){const o=t||a;return e.jsxs("div",{className:Te("bg-white dark:bg-card","rounded-lg","shadow-sm","border border-border/40","overflow-hidden",r),children:[n&&o&&e.jsxs("div",{className:"px-6 py-4 border-b border-border/50",children:[t&&e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:t}),a&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:a})]}),s&&e.jsx("div",{className:Te("p-6",!n&&o&&"pt-4"),children:s})]})},exports.ContextMenu=Cs,exports.ContextMenuCheckboxItem=Ds,exports.ContextMenuContent=Ms,exports.ContextMenuGroup=Ss,exports.ContextMenuItem=Is,exports.ContextMenuLabel=Ls,exports.ContextMenuPortal=Ts,exports.ContextMenuRadioGroup=As,exports.ContextMenuRadioItem=Rs,exports.ContextMenuSeparator=zs,exports.ContextMenuShortcut=Fs,exports.ContextMenuSub=_s,exports.ContextMenuSubContent=Ps,exports.ContextMenuSubTrigger=Es,exports.ContextMenuTrigger=ks,exports.CoreProviders=function({children:t,queryClient:a}){const s=a??new v.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}});return e.jsx(Qr,{children:e.jsx(S.I18nextProvider,{i18n:T,children:e.jsx(v.QueryClientProvider,{client:s,children:e.jsx(is,{children:e.jsx(Br,{children:t})})})})})},exports.CrudActionBar=Qs,exports.CrudGrid=({manager:a,columns:s,onEdit:r,onView:n,onToggleStatus:o,onDelete:i,renderActions:l,customRowActions:d,enableBulkActions:c=!1,onNew:u,newButtonLabel:m,showNewButton:p=!0,customActions:h=[],hideActionBar:f,showActionBar:x=!0,showSearch:g=!1,searchValue:b,onSearchChange:v,searchPlaceholder:w,bulkActions:N=[],onBulkDelete:y,filters:j,gridColumns:C=3,renderCard:k,viewMode:S,onViewModeChange:T,listCardRenderer:_,gridCardRenderer:A,showViewToggle:E=!1})=>{const{setSearchVisible:P}=ls(),M=void 0!==f?!f:x;t.useEffect(()=>{if(!g)return P(!0),()=>P(!1)},[P,g]);const I=u||h.length>0||g||c||j||E,D=y||(()=>{a.bulkDelete?.(a.selectedIds)}),R=S||"grid",L="list"===R,z={1:"grid-cols-1",2:"grid-cols-1 md:grid-cols-2",3:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",4:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"}[L?1:C],F=M&&I?e.jsx(Qs,{onNew:u,newButtonLabel:m,showNewButton:p,showSearch:g,searchValue:b,onSearchChange:v,searchPlaceholder:w,showBulkActions:c,selectedCount:a.selectedIds.length,bulkActions:N,onBulkDelete:D,onClearSelection:a.clearSelection,customActions:h,filters:j,viewMode:R,onViewModeChange:T,showViewToggle:E,availableViewModes:["list","grid"]}):null;return a.isLoading?e.jsxs("div",{className:"flex flex-col h-full",children:[F,e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx(vs,{count:6})})]}):0===a.entities.length?e.jsxs("div",{className:"flex flex-col h-full",children:[F,e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(Ns,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[F,e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx("div",{className:Te("grid gap-4",z),children:a.entities.map(t=>{const u=(e=>L&&_?_(e):!L&&A?A(e):k?k(e):null)(t);return e.jsxs(Cs,{children:[e.jsx(ks,{asChild:!0,children:u?e.jsx("div",{className:"cursor-pointer",onClick:e=>{e.stopPropagation(),c?a.selectItem(t.id):r?.(t)},children:u}):e.jsx(Re,{className:Te("overflow-hidden cursor-pointer hover:bg-muted/50 transition-colors",c&&a.selectedIds.includes(t.id)&&"bg-muted ring-2 ring-primary",L&&"flex-row"),onClick:e=>{e.stopPropagation(),c?a.selectItem(t.id):r?.(t)},children:e.jsxs(Ue,{className:Te("p-4",L&&"flex items-center gap-4 w-full"),children:[c&&e.jsx("div",{className:Te(L?"":"pt-0.5"),onClick:e=>e.stopPropagation(),children:e.jsx(Nl,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),L?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 flex items-center gap-6 min-w-0",children:s.map(a=>e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[a.header,":"]}),e.jsx("div",{className:"text-sm text-foreground truncate",children:a.render?a.render(t):String(t[a.key]??"")})]},String(a.key)))}),(r||n||l)&&e.jsx("div",{onClick:e=>e.stopPropagation(),children:l?l(t):e.jsx(qs,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:d?d(t):[]})})]}):e.jsxs("div",{className:"flex items-start gap-3",children:[c&&e.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e.jsx(Nl,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[s.map((a,r)=>e.jsxs("div",{className:Te("flex justify-between items-start gap-2",r!==s.length-1&&"mb-2"),children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[a.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right truncate",children:a.render?a.render(t):String(t[a.key]??"")})]},String(a.key))),(r||n||l)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(t):e.jsx(qs,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:d?d(t):[]})})]})]})]})})}),e.jsx(Ms,{className:"w-[160px]",children:e.jsx(Us,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,canDelete:!!i,customActions:d?d(t):[],renderAs:"context"})})]},t.id)})})})]})},exports.CrudPageInternal=xr,exports.CrudPagination=cr,exports.CrudPrimitiveFilterBar=function({searchValue:t="",onSearchChange:a,customFilters:s=[],onClearFilters:r,showClearButton:n=!0,layout:o="horizontal"}){const i=t||s.length>0;return e.jsxs("div",{className:`flex ${"vertical"===o?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[a&&e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Me,{type:"text",placeholder:"Pesquisar",value:t,onChange:e=>a(e.target.value),className:"pl-9 h-9"})]}),s.map((t,a)=>e.jsx("div",{className:"vertical"===o?"w-full":"",children:t},a)),n&&i&&r&&e.jsxs(Ee,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[e.jsx(l.X,{size:14,className:"mr-1"}),"Limpar filtros"]})]})},exports.CrudPrimitivePagination=dr,exports.CrudPrimitiveTable=function({data:a,columns:s,sortField:r,sortDirection:n,onSort:o,onRowClick:i,renderActions:d,isLoading:c=!1,emptyMessage:u="Nenhum item encontrado",className:m,enableSelection:p=!1,selectedIds:h=[],onSelectItem:f,onSelectAll:x,isAllSelected:g=!1,enableColumnResize:b=!0,onColumnResize:v,storageKey:w}){const{columnWidths:N,isDragging:y,activeColumn:j,handleMouseDown:C}=Bs({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:e.maxWidth??500,defaultWidth:e.width??e.minWidth??150})),storageKey:w?`${w}-columns`:void 0,onResize:v,enabled:b}),{isDragging:k,activeRow:S,handleMouseDown:T,getRowHeight:_}=Hs({rowIds:a.map(e=>e.id),storageKey:w?`${w}-rows`:void 0,enabled:!1}),A=t.useMemo(()=>{if(b)return s.map(e=>`${N[String(e.key)]??e.width??e.minWidth??150}px`);const e=s.reduce((e,t)=>t.width?e:e+(t.weight??1),0);return s.map(t=>{if(t.width)return`${t.width}px`;if(t.minWidth&&!t.weight)return`${t.minWidth}px`;const a=(t.weight??1)/e*100;return t.minWidth?`minmax(${t.minWidth}px, ${a}%)`:`${a}%`})},[s,b,N]);if(c)return e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((t,a)=>e.jsx(sa,{className:"h-12 w-full"},a))})});if(0===a.length)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("div",{className:"text-center text-muted-foreground",children:e.jsx("p",{children:u})})});const E=y||k;return e.jsx("div",{className:"flex-1 overflow-auto "+(E?"select-none":""),children:e.jsxs(cs,{className:m,children:[e.jsx(us,{className:"sticky top-0 bg-background z-10",children:e.jsxs(hs,{children:[p&&e.jsx(fs,{className:"w-[40px]",children:e.jsx(vt,{checked:g,onCheckedChange:x,"aria-label":"Selecionar todos"})}),s.map((t,a)=>{const s=b&&!1!==t.resizable,i=j===String(t.key);return e.jsxs(fs,{className:`${t.className||""} relative`,style:{width:A[a]},children:[t.sortable&&o?e.jsxs("button",{onClick:()=>o(String(t.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[t.header,(d=String(t.key),r!==d?e.jsx(l.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===n?e.jsx(l.ArrowUp,{size:14,className:"ml-1"}):e.jsx(l.ArrowDown,{size:14,className:"ml-1"}))]}):e.jsx("span",{className:"font-medium",children:t.header}),s&&e.jsx(js,{direction:"horizontal",onMouseDown:e=>C(String(t.key),e),isDragging:i})]},String(t.key));var d}),d&&e.jsx(fs,{className:"w-[80px] text-right",children:"Ações"})]})}),e.jsx(ms,{children:a.map(t=>{const a=_(t.id);return t.id,e.jsxs(hs,{onClick:()=>i?.(t),className:(i?"cursor-pointer":"")+" relative",style:a?{height:`${a}px`}:void 0,children:[p&&e.jsx(xs,{children:e.jsx(vt,{checked:h.includes(t.id),onCheckedChange:()=>f?.(t.id),onClick:e=>e.stopPropagation(),"aria-label":`Selecionar item ${t.id}`})}),s.map(a=>e.jsx(xs,{className:a.className,children:e.jsx(ys,{children:a.render?a.render(t):String(t[a.key]??"-")})},String(a.key))),d&&e.jsx(xs,{className:"text-right",onClick:e=>e.stopPropagation(),children:d(t)})]},t.id)})})]})})},exports.CrudTable=Xs,exports.D4SignWidget=mu,exports.DATETIME_FORMATS=Ar,exports.DEFAULT_DATETIME_FORMAT=Mr,exports.DEFAULT_LOCALE=Pr,exports.DEFAULT_TIMEZONE=Ir,exports.DataList=Xn,exports.DatePicker=function({date:t,onDateChange:a,placeholder:s="Selecione uma data",disabled:r=!1,className:n,disabledDates:i}){return e.jsxs(Wt,{children:[e.jsx(Gt,{asChild:!0,children:e.jsxs(Ee,{variant:"outline",disabled:r,className:Te("w-full justify-start text-left font-normal",!t&&"text-muted-foreground",n),children:[e.jsx(l.Calendar,{className:"mr-2 h-4 w-4"}),t?o.format(t,"d 'de' MMMM 'de' yyyy",{locale:Qn}):e.jsx("span",{children:s})]})}),e.jsx(Yt,{className:"w-auto p-0",align:"start",children:e.jsx(Kn,{mode:"single",selected:t,onSelect:a,disabled:i,initialFocus:!0,className:"pointer-events-auto"})})]})},exports.Dialog=Be,exports.DialogBody=Ke,exports.DialogClose=Ve,exports.DialogContent=Ye,exports.DialogDescription=Je,exports.DialogFooter=Xe,exports.DialogHeader=Qe,exports.DialogOverlay=We,exports.DialogPortal=$e,exports.DialogTitle=Ze,exports.DialogTrigger=He,exports.DisabledMenuItem=Vt,exports.DocumentSigner=function({file:a,onDocumentSigned:s,onError:r,showEventLog:n=!1}){const{user:o,alias:d}=ls(),[c,u]=t.useState(null),[m,p]=t.useState(!1),[h,f]=t.useState(null),[x,g]=t.useState("sandbox"),[b,v]=t.useState("clicksign"),[w,N]=t.useState(null),[y,j]=t.useState(null),[C,k]=t.useState(!1),[S,T]=t.useState(0),[_,A]=t.useState(!1),[E,P]=t.useState([]),M=t.useRef(null),I=t.useRef(null),D=t.useCallback(e=>{n&&P(t=>[...t,`[${(new Date).toLocaleTimeString()}] ${e}`])},[n]),R=t.useCallback(async e=>{try{const t=Sa(),{data:a}=await t.schema("common").from("sign_configs").select("provider").eq("alias",e).is("deleted_at",null).maybeSingle();if(a?.provider)return a.provider}catch(t){}return"clicksign"},[]),L=t.useCallback(async e=>{if(u(e),f(null),N(null),j(null),D(`Arquivo selecionado: ${e.name}`),d&&o){p(!0);try{const t=await R(d);v(t),D(`Provedor resolvido: ${t}`);const a=new FileReader,s=await new Promise((t,s)=>{a.onload=()=>{const e=a.result;t(e)},a.onerror=s,a.readAsDataURL(e)});D(`Criando envelope para assinatura via ${t}...`);const n=await du.createEnvelopeWithSigner({alias:d,contentBase64:s,filename:e.name,signerEmail:o.email||"",signerName:o.name||"",provider:t});D(`Envelope criado: ${n.envelope_id}`),N({envelope_id:n.envelope_id,document_id:n.document_id,signer_email:n.signer_email,key_signer:n.signer_id}),g(n.environment),v(n.provider||t),"d4sign"===t?(D("Documento enviado para D4Sign. Abrindo widget de assinatura..."),await new Promise(e=>setTimeout(e,2e3)),f(n.document_id),i.toast.success("Documento enviado! Assine abaixo.")):n.signer_id?(D(`Signer ID obtido: ${n.signer_id}. Aguardando processamento (3s)...`),await new Promise(e=>setTimeout(e,3e3)),f(n.signer_id),i.toast.success("Documento enviado! Assine abaixo.")):(D("AVISO: Nenhum signer ID disponível."),i.toast.error("Não foi possível obter o acesso para assinatura. Tente novamente."),r?.(new Error("Signer ID não disponível")))}catch(t){const e=t instanceof Error?t:new Error("Erro ao processar documento");D(`Erro: ${e.message}`),i.toast.error(e.message),r?.(e)}finally{p(!1)}}},[d,o,D,r,R]);t.useEffect(()=>{a&&d&&o&&a!==I.current&&(I.current=a,L(a))},[a,d,o,L]);const z=t.useCallback(async()=>{if(!w||!d)return;k(!0),T(0),A(!1),D("Buscando documento assinado...");for(let t=1;t<=6;t++){T(t),D(`Tentativa ${t}/6...`);try{const e=await du.getSignedDocument({alias:d,envelopeId:w.envelope_id,documentId:w.document_id,provider:b});if(e.download_url)return D("Documento assinado disponível para download"),j(e.download_url),void k(!1)}catch(e){D(`Erro na tentativa ${t}: ${e instanceof Error?e.message:"Erro desconhecido"}`)}t<6&&(D("Aguardando 10 segundos para próxima tentativa..."),await new Promise(e=>setTimeout(e,1e4)))}D("Não foi possível obter o documento assinado após 6 tentativas."),k(!1),A(!0)},[w,d,D,b]),F=t.useCallback(async()=>{D("Documento assinado com sucesso!"),i.toast.success("Documento assinado com sucesso!"),f(null),w&&d&&(s?.({success:!0,provider:b,envelope_id:w.envelope_id,document_id:w.document_id,signer_id:h||"",environment:x}),await z())},[D,s,w,h,d,x,b,z]);if(!d)return e.jsx(Re,{className:"border-amber-200 bg-amber-50",children:e.jsx(Ue,{className:"flex items-start gap-3 py-6",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-amber-800",children:"Autenticação necessária"}),e.jsx("p",{className:"text-sm text-amber-700 mt-1",children:"Faça login para utilizar a assinatura digital."})]})})});const U="d4sign"===b?"D4Sign":"Clicksign",q=()=>n&&E.length>0?e.jsx("div",{className:"bg-muted p-3 rounded-md text-xs font-mono space-y-1 max-h-40 overflow-auto",children:E.map((t,a)=>e.jsx("div",{children:t},a))}):null;return w&&!h&&(y||C||_)?e.jsxs("div",{className:"space-y-4",children:[e.jsx(Re,{className:"border-green-200 bg-green-50",children:e.jsxs(Ue,{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx(l.CheckCircle2,{className:"h-12 w-12 text-green-600"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-green-800",children:"Documento assinado com sucesso!"}),e.jsx("p",{className:"text-sm text-green-700 mt-1",children:c?.name})]}),C?e.jsxs("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Loader2,{className:"h-4 w-4 animate-spin"}),"Preparando documento assinado... (tentativa ",S,"/6)"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Aguardando processamento pelo ",U,"..."]})]}):y?e.jsx(Ee,{asChild:!0,variant:"default",className:"gap-2",children:e.jsxs("a",{href:y,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(l.Download,{className:"h-4 w-4"}),"Baixar documento assinado"]})}):_?e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Não foi possível obter o documento assinado após 1 minuto."}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"O documento será enviado para o seu e-mail assim que estiver disponível."})]}),e.jsxs(Ee,{variant:"secondary",className:"gap-2",onClick:z,children:[e.jsx(l.RefreshCw,{className:"h-4 w-4"}),"Tentar novamente"]})]}):null]})}),e.jsx(q,{})]}):h?e.jsxs("div",{className:"space-y-4",children:["d4sign"===b?e.jsx(mu,{documentKey:h,signerEmail:w?.signer_email||o?.email||"",signerName:o?.name,keySigner:w?.key_signer,environment:x,onSign:F,onError:r}):e.jsx(uu,{signerId:h,environment:x,onSign:F,onError:r}),e.jsx(q,{})]}):a&&m?e.jsx(Re,{children:e.jsxs(Ue,{className:"flex items-center justify-center gap-3 py-10",children:[e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),e.jsx("p",{className:"font-medium",children:"Enviando documento para assinatura..."})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("input",{ref:M,type:"file",accept:"application/pdf",className:"hidden",onChange:e=>{const t=e.target.files?.[0];t&&"application/pdf"===t.type?L(t):i.toast.error("Selecione um arquivo PDF")}}),m?e.jsx(Re,{children:e.jsxs(Ue,{className:"flex items-center justify-center gap-3 py-10",children:[e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),e.jsx("p",{className:"font-medium",children:"Enviando documento para assinatura..."})]})}):e.jsx(Re,{className:"border-dashed border-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>M.current?.click(),children:e.jsxs(Ue,{className:"flex flex-col items-center justify-center py-10 gap-3",children:[e.jsx(l.Upload,{className:"h-8 w-8 text-muted-foreground"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:"Selecione um arquivo PDF"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Clique para escolher o documento para assinatura"})]})]})}),e.jsx(q,{})]})},exports.Drawer=Zn,exports.DrawerClose=to,exports.DrawerContent=so,exports.DrawerDescription=io,exports.DrawerFooter=no,exports.DrawerHeader=ro,exports.DrawerOverlay=ao,exports.DrawerPortal=eo,exports.DrawerTitle=oo,exports.DrawerTrigger=Jn,exports.DropdownMenu=St,exports.DropdownMenuCheckboxItem=Lt,exports.DropdownMenuContent=Dt,exports.DropdownMenuGroup=_t,exports.DropdownMenuItem=Rt,exports.DropdownMenuLabel=Ft,exports.DropdownMenuPortal=At,exports.DropdownMenuRadioGroup=Pt,exports.DropdownMenuRadioItem=zt,exports.DropdownMenuSeparator=Ut,exports.DropdownMenuShortcut=qt,exports.DropdownMenuSub=Et,exports.DropdownMenuSubContent=It,exports.DropdownMenuSubTrigger=Mt,exports.DropdownMenuTrigger=Tt,exports.EmailService=wc,exports.EmptyState=Ns,exports.EntitySelect=oa,exports.ErrorBoundary=Qr,exports.FilterBar=fr,exports.Form=et,exports.FormControl=ot,exports.FormDescription=it,exports.FormField=({...t})=>e.jsx(tt.Provider,{value:{name:t.name},children:e.jsx(m.Controller,{...t})}),exports.FormItem=rt,exports.FormLabel=nt,exports.FormMessage=lt,exports.FormSkeleton=function({fields:t=4}){return e.jsxs("div",{className:"space-y-4",children:[Array.from({length:t}).map((t,a)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(sa,{className:"h-4 w-24"}),e.jsx(sa,{className:"h-10 w-full"})]},a)),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(sa,{className:"h-10 w-20"}),e.jsx(sa,{className:"h-10 w-20"})]})]})},exports.Grid=function({children:t,cols:a="auto-fit",gap:s="md",className:r}){return e.jsx("div",{className:Te("grid",lo[a],co[s],r),children:t})},exports.H1=No,exports.H2=yo,exports.H3=jo,exports.H4=Co,exports.HeaderSkeleton=function(){return e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(sa,{className:"h-8 w-8 rounded-full"}),e.jsx(sa,{className:"h-6 w-32"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(sa,{className:"h-8 w-8"}),e.jsx(sa,{className:"h-8 w-24"})]})]})},exports.HoverCard=uo,exports.HoverCardContent=po,exports.HoverCardTrigger=mo,exports.IconPicker=rr,exports.ImageEditor=function({value:a,onChange:s,onSubmit:r,onCancel:n,uploadFunction:o,deleteFunction:d,uploadOptions:c}){const[u,m]=t.useState(a||{alignment:"center",allowDownload:!1}),p=t.useRef(null),{upload:h,uploading:f}=Zc({uploadFunction:o,deleteFunction:d,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),x=(e,t)=>{const a={...u,[e]:t};m(a),s(a)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{children:"URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Me,{type:"url",placeholder:"https://exemplo.com/imagem.jpg",value:u.imageUrl||"",onChange:e=>x("imageUrl",e.target.value),className:"flex-1"}),o&&e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:p,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await h(t),a={...u,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};m(a),s(a)}catch(a){}finally{p.current&&(p.current.value="")}},className:"hidden"}),e.jsx(Ee,{type:"button",variant:"outline",onClick:()=>p.current?.click(),disabled:f,children:f?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]})]}),u.imageFile&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Arquivo: ",u.imageFile," (",Math.round((u.imageSize||0)/1024)," KB)"]})]}),u.imageUrl&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{children:"Preview"}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:e.jsx("div",{className:"flex "+("left"===u.alignment?"justify-start":"right"===u.alignment?"justify-end":"justify-center"),children:e.jsx("img",{src:u.imageUrl,alt:u.alt||"Preview",style:{width:u.width?`${u.width}px`:"auto",height:u.height?`${u.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{htmlFor:"caption",children:"Legenda"}),e.jsx(wt,{id:"caption",placeholder:"Legenda",value:u.caption||"",onChange:e=>x("caption",e.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{htmlFor:"alt",children:"Texto Alternativo"}),e.jsx(Me,{id:"alt",placeholder:"Texto Alternativo",value:u.alt||"",onChange:e=>x("alt",e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{children:"Alinhamento"}),e.jsxs(dt,{value:u.alignment||"center",onValueChange:e=>x("alignment",e),children:[e.jsx(mt,{children:e.jsx(ut,{})}),e.jsxs(ft,{children:[e.jsx(gt,{value:"left",children:"Esquerda"}),e.jsx(gt,{value:"center",children:"Centro"}),e.jsx(gt,{value:"right",children:"Direita"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{htmlFor:"width",children:"Largura"}),e.jsx(Me,{id:"width",type:"number",placeholder:"px",value:u.width||"",onChange:e=>x("width",e.target.value?Number(e.target.value):void 0)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{htmlFor:"height",children:"Altura"}),e.jsx(Me,{id:"height",type:"number",placeholder:"px",value:u.height||"",onChange:e=>x("height",e.target.value?Number(e.target.value):void 0)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"allowDownload",type:"checkbox",checked:u.allowDownload||!1,onChange:e=>x("allowDownload",e.target.checked),className:"h-4 w-4"}),e.jsx(De,{htmlFor:"allowDownload",className:"cursor-pointer",children:"Permitir download"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(Ee,{variant:"outline",onClick:n,children:"Cancelar"}),e.jsx(Ee,{onClick:()=>{u.imageUrl?r(u):i.toast.error("Erro",{description:"Nenhuma imagem selecionada"})},disabled:!u.imageUrl,children:"Salvar"})]})]})},exports.ImageRenderer=function({content:t,className:a="",style:s}){if(!t.imageUrl)return null;const r={left:"justify-start",center:"justify-center",right:"justify-end"}[t.alignment||"center"];return e.jsx("div",{className:`flex ${r} my-4 ${a}`,style:s,children:e.jsxs("div",{className:"space-y-2 max-w-full",children:[e.jsx("img",{src:t.imageUrl,alt:t.alt||"",style:{width:t.width?`${t.width}px`:"auto",height:t.height?`${t.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),t.caption&&e.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:t.caption}),t.allowDownload&&t.imageUrl&&e.jsxs("a",{href:t.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[e.jsx(l.Download,{className:"h-4 w-4"}),"Baixar imagem"]})]})})},exports.InlineCode=Eo,exports.Input=Me,exports.InputGroup=ho,exports.InputGroupAddon=xo,exports.InputGroupButton=bo,exports.InputGroupInput=vo,exports.InputGroupTextarea=wo,exports.LOGO_CONFIG=Ha,exports.Label=De,exports.Large=To,exports.Lead=So,exports.LeaderRow=Bc,exports.LeadershipDialog=Qc,exports.LeadershipForm=Yc,exports.LeadershipPage=function(){const{alias:a}=ls(),{data:s,isLoading:r,error:n,refetch:o}=Rc(),{data:i=[]}=or({enabled:!0}),[d,c]=t.useState(()=>a?(e=>{try{const t=localStorage.getItem(`${Kc}-${e}`);if(t)return new Set(JSON.parse(t))}catch(n){}return new Set})(a):new Set),[u,m]=t.useState(!1),[p,h]=t.useState(),[f,x]=t.useState(null),g=i.filter(e=>e.userName&&"Nome não disponível"!==e.userName),b=new Set(g.map(e=>e.userId)),v=g.length-(s?Dc(s).filter(e=>b.has(e.id_user)&&"[Não encontrado]"!==e.name).length:0);t.useEffect(()=>{if(s&&s.length>0&&a){if(!localStorage.getItem(`${Kc}-${a}`)){const e=s.map(e=>e.id),t=new Set(e);c(t),Xc(a,t)}}},[s,a]);const w=e=>{c(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),a&&Xc(a,s),s})},N=e=>{h(e),x(null),m(!0)};return r?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(l.RefreshCw,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"Carregando..."})]})}):n?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),e.jsx(Ee,{onClick:()=>o(),children:"Tentar novamente"})]})}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex items-center justify-between p-4 border-b",children:e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(Ee,{size:"sm",onClick:()=>{h(void 0),x(null),m(!0)},children:[e.jsx(l.Plus,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),e.jsxs(Ee,{variant:"outline",size:"sm",onClick:()=>{if(!s)return;const e=Dc(s).filter(e=>e.children.length>0).map(e=>e.id),t=new Set(e);c(t),a&&Xc(a,t)},disabled:!s||0===s.length,children:[e.jsx(l.ChevronDown,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),e.jsxs(Ee,{variant:"outline",size:"sm",onClick:()=>{const e=new Set;c(e),a&&Xc(a,e)},disabled:!s||0===s.length,children:[e.jsx(l.ChevronRight,{className:"h-4 w-4 mr-2"}),"Recolher todos"]}),e.jsx("div",{className:"flex items-center gap-2 ml-4",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[e.jsx(l.Users,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm font-medium",children:[v," usuário",1!==v?"s":""," não associado",1!==v?"s":""]})]})})]})}),s&&0!==s.length?e.jsx(tr,{className:"flex-1",children:e.jsx("div",{children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"py-3 px-4 text-left font-semibold",children:"Nome"}),e.jsx("th",{className:"py-3 px-4 text-center font-semibold",children:"Liderados"})]})}),e.jsx("tbody",{children:s.map(t=>e.jsx(Bc,{leader:t,expandedIds:d,onToggleExpand:w,onEdit:N},t.id))})]})})}):e.jsx("div",{className:"flex items-center justify-center flex-1",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Nenhuma hierarquia de liderança encontrada"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Clique em "Definir Líder" para começar'})]})}),e.jsx(Qc,{open:u,onOpenChange:()=>{m(!1),h(void 0),x(null)},leader:p,prefilledLeaderId:f,title:p?"Editar Nome":f?"Adicionar Liderado":"Adicionar Líder Raiz"},`leadership-dialog-${a}`)]})},exports.List=Mo,exports.LoadingState=function({isLoading:t,children:a,className:s,type:r="spinner",size:n="md"}){return t?"overlay"===r?e.jsxs("div",{className:Te("relative",s),children:[a,e.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:e.jsx(Ct,{size:n})})]}):"skeleton"===r?e.jsx("div",{className:Te("animate-pulse",s),children:e.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):e.jsx("div",{className:Te("flex items-center justify-center py-8",s),children:e.jsx(Ct,{size:n})}):e.jsx(e.Fragment,{children:a})},exports.LocaleProvider=Br,exports.LoginPage=()=>e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(Re,{className:"w-full max-w-md",children:[e.jsx(Le,{className:"text-center",children:e.jsx(ze,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),e.jsxs(Ue,{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),e.jsx(Ee,{onClick:async()=>{qa()?await ns.loginDev():ns.loginProd()},className:"w-full",size:"lg",children:qa()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),exports.MESSAGES=$a,exports.MODULES_DATA=Dl,exports.ManageAccessModal=_c,exports.Menubar=Yi,exports.MenubarCheckboxItem=el,exports.MenubarContent=Zi,exports.MenubarGroup=$i,exports.MenubarItem=Ji,exports.MenubarLabel=al,exports.MenubarMenu=Hi,exports.MenubarPortal=Vi,exports.MenubarRadioGroup=Gi,exports.MenubarRadioItem=tl,exports.MenubarSeparator=sl,exports.MenubarShortcut=rl,exports.MenubarSub=Wi,exports.MenubarSubContent=Xi,exports.MenubarSubTrigger=Ki,exports.MenubarTrigger=Qi,exports.ModalStateProvider=function({children:a}){const[s,r]=t.useState(new Set),[n,o]=t.useState(!1),i=t.useCallback(e=>{r(t=>{const a=new Set(t);return a.add(e),a})},[]),l=t.useCallback(e=>{r(t=>{const a=new Set(t);return a.delete(e),a})},[]),d=t.useCallback(e=>{o(e)},[]),c=t.useMemo(()=>s.size>0||n,[s,n]),u=t.useMemo(()=>({openModals:s,hasOpenModal:c,registerModal:i,unregisterModal:l,setHasOpenModal:d}),[s,c,i,l,d]);return e.jsx(ed.Provider,{value:u,children:a})},exports.ModulesDialog=Ul,exports.MultiSelect=oa,exports.Muted=Ao,exports.NavigationMenu=Io,exports.NavigationMenuContent=Fo,exports.NavigationMenuIndicator=Oo,exports.NavigationMenuItem=Ro,exports.NavigationMenuLink=Uo,exports.NavigationMenuList=Do,exports.NavigationMenuTrigger=zo,exports.NavigationMenuViewport=qo,exports.NavigationProvider=Sl,exports.OnboardingDialog=wl,exports.P=ko,exports.PageBreadcrumb=function({items:t,maxItems:a=3,className:s}){const r=t.length>a?[t[0],...t.slice(-(a-1))]:t,n=t.length>a;return e.jsx(fn,{className:s,children:e.jsx(xn,{children:r.map((t,a)=>{const s=0===a,r=n&&1===a;return e.jsxs(gn,{children:[!s&&e.jsx(wn,{}),r&&e.jsxs(e.Fragment,{children:[e.jsx(Nn,{}),e.jsx(wn,{})]}),t.isCurrentPage?e.jsx(vn,{children:t.label}):e.jsx(bn,{asChild:!0,children:e.jsx(w.Link,{to:t.href||"/",children:t.label})})]},t.label)})})})},exports.PageMetadataProvider=kr,exports.Pagination=Bo,exports.PaginationContent=Ho,exports.PaginationEllipsis=Yo,exports.PaginationItem=$o,exports.PaginationLink=Vo,exports.PaginationNext=Go,exports.PaginationPrevious=Wo,exports.PlaceCard=Ac,exports.PlacesList=function({places:t,isLoading:a,manageAccessConfig:s}){return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando dados..."})]})}):t&&0!==t.length?e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),t.map(t=>e.jsx(Ac,{place:t,manageAccessConfig:s},t.id))]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[e.jsx(l.Building2,{className:"h-12 w-12 text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})},exports.Popover=Wt,exports.PopoverContent=Yt,exports.PopoverTrigger=Gt,exports.Progress=Qo,exports.ProtectedRoute=({children:a})=>{const{isAuthenticated:s,isLoading:r}=ls();if(t.useEffect(()=>{if(!s)return;const e=()=>{xa.areAllTokensValid()||ns.logout()};e();const t=setInterval(e,3e5);return()=>clearInterval(t)},[s]),t.useEffect(()=>{if(r)return;if(s)return;if(xa.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),t=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,a=new URLSearchParams(t);if(e.has("access_token")||a.has("access_token"))return;const n=qa(),o=window.location.pathname+window.location.search+window.location.hash;["/","/login","/callback"].includes(window.location.pathname)||localStorage.setItem("auth_return_url",o);(async()=>{n?await ns.loginDev():ns.loginProd()})()},[s,r]),r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(Re,{className:"w-full max-w-md",children:[e.jsx(Le,{className:"text-center",children:e.jsx(ze,{className:"text-xl font-semibold",children:"Carregando..."})}),e.jsxs(Ue,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!s){return new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token")?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(Re,{className:"w-full max-w-md",children:[e.jsx(Le,{className:"text-center",children:e.jsx(ze,{className:"text-xl font-semibold",children:"Processando..."})}),e.jsxs(Ue,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(Re,{className:"w-full max-w-md",children:[e.jsx(Le,{className:"text-center",children:e.jsx(ze,{className:"text-xl font-semibold",children:"Iniciando..."})}),e.jsxs(Ue,{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:qa()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return e.jsx(e.Fragment,{children:a})},exports.QUALIEX_CONFIG=Oa,exports.QUERY_KEYS={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]},exports.QualiexEnrichmentService=Ka,exports.QualiexErrorInterceptor=Ia,exports.QualiexUserField=ir,exports.RadioGroup=Ko,exports.RadioGroupItem=Xo,exports.ResizableHandle=({withHandle:t,className:a,...s})=>e.jsx(Ne.PanelResizeHandle,{className:Te("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",a),...s,children:t&&e.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:e.jsx(l.GripVertical,{className:"h-2.5 w-2.5"})})}),exports.ResizablePanel=Zo,exports.ResizablePanelGroup=({className:t,...a})=>e.jsx(Ne.PanelGroup,{className:Te("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",t),...a}),exports.RichTextEditor=({value:a,onChange:s,disabled:r,placeholder:n="Escreva o conteúdo aqui...",minHeight:o="300px",showModeToggle:i=!0,showVariableHint:d=!0,className:c})=>{const[u,m]=t.useState("visual"),p=H.useEditor({extensions:[$.configure({heading:{levels:[1,2,3]}}),V,W.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),G.TextStyle,Y.Color,Q.configure({multicolor:!0})],content:a||"",editable:!r,onUpdate:({editor:e})=>{s(e.getHTML())}});J.useEffect(()=>{p&&a!==p.getHTML()&&p.commands.setContent(a||"")},[a,p]);const h=t.useCallback(()=>{if(!p)return;const e=p.getAttributes("link").href,t=window.prompt("URL",e);null!==t&&(""!==t?p.chain().focus().extendMarkRange("link").setLink({href:t}).run():p.chain().focus().extendMarkRange("link").unsetLink().run())},[p]);return p?e.jsxs("div",{className:Te("space-y-2",c),children:[i&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(Ee,{type:"button",size:"sm",variant:"visual"===u?"default":"outline",onClick:()=>m("visual"),disabled:r,children:[e.jsx(l.Edit3,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),e.jsxs(Ee,{type:"button",size:"sm",variant:"code"===u?"default":"outline",onClick:()=>m("code"),disabled:r,children:[e.jsx(l.Code,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),e.jsxs(Ee,{type:"button",size:"sm",variant:"preview"===u?"default":"outline",onClick:()=>m("preview"),disabled:r,children:[e.jsx(l.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),d&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"{{variavel}}"})]})]}),"visual"===u&&e.jsxs("div",{className:"border rounded-md overflow-hidden bg-background cursor-text",onClick:e=>{e.target.closest(".editor-toolbar")||p?.commands.focus()},children:[e.jsxs("div",{className:"editor-toolbar flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e.jsx(fl,{onClick:()=>p.chain().focus().toggleHeading({level:1}).run(),isActive:p.isActive("heading",{level:1}),disabled:r,title:"Título 1",children:e.jsx(l.Heading1,{className:"h-4 w-4"})}),e.jsx(fl,{onClick:()=>p.chain().focus().toggleHeading({level:2}).run(),isActive:p.isActive("heading",{level:2}),disabled:r,title:"Título 2",children:e.jsx(l.Heading2,{className:"h-4 w-4"})}),e.jsx(fl,{onClick:()=>p.chain().focus().toggleHeading({level:3}).run(),isActive:p.isActive("heading",{level:3}),disabled:r,title:"Título 3",children:e.jsx(l.Heading3,{className:"h-4 w-4"})}),e.jsx(xl,{}),e.jsx(fl,{onClick:()=>p.chain().focus().toggleBold().run(),isActive:p.isActive("bold"),disabled:r,title:"Negrito",children:e.jsx(l.Bold,{className:"h-4 w-4"})}),e.jsx(fl,{onClick:()=>p.chain().focus().toggleItalic().run(),isActive:p.isActive("italic"),disabled:r,title:"Itálico",children:e.jsx(l.Italic,{className:"h-4 w-4"})}),e.jsx(fl,{onClick:()=>p.chain().focus().toggleUnderline().run(),isActive:p.isActive("underline"),disabled:r,title:"Sublinhado",children:e.jsx(l.Underline,{className:"h-4 w-4"})}),e.jsx(fl,{onClick:()=>p.chain().focus().toggleStrike().run(),isActive:p.isActive("strike"),disabled:r,title:"Riscado",children:e.jsx(l.Strikethrough,{className:"h-4 w-4"})}),e.jsx(xl,{}),e.jsx(fl,{onClick:()=>p.chain().focus().toggleBulletList().run(),isActive:p.isActive("bulletList"),disabled:r,title:"Lista",children:e.jsx(l.List,{className:"h-4 w-4"})}),e.jsx(fl,{onClick:()=>p.chain().focus().toggleOrderedList().run(),isActive:p.isActive("orderedList"),disabled:r,title:"Lista Ordenada",children:e.jsx(l.ListOrdered,{className:"h-4 w-4"})}),e.jsx(xl,{}),e.jsx(fl,{onClick:()=>p.chain().focus().toggleHighlight().run(),isActive:p.isActive("highlight"),disabled:r,title:"Destacar",children:e.jsx(l.Highlighter,{className:"h-4 w-4"})}),e.jsx(fl,{onClick:h,isActive:p.isActive("link"),disabled:r,title:"Link",children:e.jsx(l.Link,{className:"h-4 w-4"})}),e.jsx(xl,{}),e.jsx(fl,{onClick:()=>p.chain().focus().unsetAllMarks().clearNodes().run(),disabled:r,title:"Limpar Formatação",children:e.jsx(l.RemoveFormatting,{className:"h-4 w-4"})}),e.jsx(xl,{}),e.jsx(fl,{onClick:()=>p.chain().focus().undo().run(),disabled:r||!p.can().undo(),title:"Desfazer",children:e.jsx(l.Undo,{className:"h-4 w-4"})}),e.jsx(fl,{onClick:()=>p.chain().focus().redo().run(),disabled:r||!p.can().redo(),title:"Refazer",children:e.jsx(l.Redo,{className:"h-4 w-4"})})]}),e.jsx(H.EditorContent,{editor:p,className:Te("prose prose-sm max-w-none focus:outline-none","[&_.ProseMirror]:p-4","[&_.ProseMirror]:min-h-full","[&_.ProseMirror]:cursor-text","[&_.ProseMirror]:outline-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none"),style:{minHeight:o}})]}),"code"===u&&e.jsx("textarea",{value:a||"",onChange:e=>s(e.target.value),disabled:r,className:"w-full p-3 border rounded-md font-mono text-sm resize-none focus:ring-2 focus:ring-primary bg-background",style:{height:o},placeholder:"Cole ou edite o HTML aqui..."}),"preview"===u&&e.jsx("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:o},children:e.jsx("div",{className:"bg-background shadow-sm rounded border p-4",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:a||`<p class="text-muted-foreground">${n}</p>`}})})})]}):null},exports.SEARCH_CONFIG=Ua,exports.SUPPORTED_LOCALES=_r,exports.ScrollArea=tr,exports.ScrollBar=ar,exports.Select=dt,exports.SelectContent=ft,exports.SelectGroup=ct,exports.SelectItem=gt,exports.SelectLabel=xt,exports.SelectScrollDownButton=ht,exports.SelectScrollUpButton=pt,exports.SelectSearch=oa,exports.SelectSeparator=bt,exports.SelectTrigger=mt,exports.SelectValue=ut,exports.Separator=Oe,exports.Sheet=Jo,exports.SheetBody=ii,exports.SheetClose=ti,exports.SheetContent=ni,exports.SheetDescription=ci,exports.SheetFooter=li,exports.SheetHeader=oi,exports.SheetOverlay=si,exports.SheetPortal=ai,exports.SheetTitle=di,exports.SheetTrigger=ei,exports.Sidebar=fi,exports.SidebarActionTrigger=Kl,exports.SidebarContent=ji,exports.SidebarFooter=Ni,exports.SidebarGroup=Ci,exports.SidebarGroupAction=Si,exports.SidebarGroupContent=Ti,exports.SidebarGroupLabel=ki,exports.SidebarHeader=Ql,exports.SidebarInput=vi,exports.SidebarInset=bi,exports.SidebarMenu=_i,exports.SidebarMenuAction=Mi,exports.SidebarMenuBadge=Ii,exports.SidebarMenuButton=Pi,exports.SidebarMenuItem=Ai,exports.SidebarMenuSkeleton=Di,exports.SidebarMenuSub=Ri,exports.SidebarMenuSubButton=zi,exports.SidebarMenuSubItem=Li,exports.SidebarProvider=hi,exports.SidebarRail=gi,exports.SidebarSeparator=yi,exports.SidebarSkeleton=function(){return e.jsx("div",{className:"w-64 border-r bg-muted/10",children:e.jsxs("div",{className:"p-4",children:[e.jsx(sa,{className:"h-8 w-32 mb-6"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((t,a)=>e.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[e.jsx(sa,{className:"h-4 w-4"}),e.jsx(sa,{className:"h-4 w-20"})]},a))})]})})},exports.SidebarTrigger=xi,exports.SignConfigForm=function({onSaved:a}){const{config:s,isLoading:r,saveConfig:n}=pu(),[o,d]=t.useState(""),[c,u]=t.useState("sandbox"),[m,p]=t.useState(!1),[h,f]=t.useState(!1);return h||r||!s?h||r||f(!0):(d(s.api_key),u(s.environment),f(!0)),r?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-4",children:[s?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-600",children:[e.jsx(l.CheckCircle,{className:"h-4 w-4"}),e.jsx("span",{children:"Assinatura digital configurada para esta unidade"})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-600",children:[e.jsx(l.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{children:"Assinatura digital ainda não configurada para esta unidade"})]}),e.jsxs(Re,{children:[e.jsx(Le,{children:e.jsx(ze,{className:"text-base",children:"Configuração de Assinatura Digital"})}),e.jsx(Ue,{children:e.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),o.trim()){p(!0);try{await n(o.trim(),c),i.toast.success("Configuração de assinatura salva com sucesso"),a?.()}catch(t){i.toast.error("Erro ao salvar configuração de assinatura")}finally{p(!1)}}else i.toast.error("Informe a API Key do provedor de assinatura")},className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{htmlFor:"sign-api-key",children:"API Key"}),e.jsx(Me,{id:"sign-api-key",type:"password",placeholder:"Insira a API Key do provedor de assinatura",value:o,onChange:e=>d(e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{htmlFor:"sign-environment",children:"Ambiente"}),e.jsxs("select",{id:"sign-environment",className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",value:c,onChange:e=>u(e.target.value),children:[e.jsx("option",{value:"sandbox",children:"Sandbox (Testes)"}),e.jsx("option",{value:"production",children:"Produção"})]})]}),e.jsxs(Ee,{type:"submit",disabled:m,children:[m&&e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),s?"Atualizar Configuração":"Salvar Configuração"]})]})})]})]})},exports.SignWidget=uu,exports.Skeleton=sa,exports.Slider=Fi,exports.Small=_o,exports.SonnerToaster=kt,exports.Spinner=Ct,exports.SplitButton=function({label:t,onClick:a,icon:s,actions:r=[],variant:n="default",size:o="default",disabled:i=!1,loading:d=!1,menuAlign:c="end",className:u}){const m=i||d;return r.length>0?e.jsxs("div",{className:Te("inline-flex rounded-md shadow-sm",u),children:[e.jsxs(Ee,{variant:n,size:o,disabled:m,onClick:a,className:"rounded-r-none border-r-0 focus:z-10",children:[d?e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?e.jsx(s,{className:"mr-2 h-4 w-4"}):null,t]}),e.jsxs(St,{children:[e.jsx(Tt,{asChild:!0,children:e.jsx(Ee,{variant:n,size:o,disabled:m,className:Te("rounded-l-none focus:z-10",{sm:"w-7 min-w-7 px-0",default:"w-8 min-w-8 px-0",lg:"w-9 min-w-9 px-0"}[o]),"aria-label":"Mais opções",children:e.jsx(l.ChevronDown,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[o]})})}),e.jsx(Dt,{align:c,className:"min-w-[160px]",children:r.map(t=>{const a=t.icon;return e.jsxs(Rt,{onClick:t.onClick,disabled:t.disabled,className:Te("destructive"===t.variant&&"text-destructive focus:text-destructive"),children:[a&&e.jsx(a,{className:"mr-2 h-4 w-4"}),t.label]},t.id)})})]})]}):e.jsxs(Ee,{variant:n,size:o,disabled:m,onClick:a,className:u,children:[d?e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?e.jsx(s,{className:"mr-2 h-4 w-4"}):null,t]})},exports.Stack=hr,exports.StepSelector=function({currentStep:t,totalSteps:a,onStepChange:s,stepLabels:r,canGoToStep:n,className:o,progressWidth:i="w-32"}){const d=Array.from({length:a},(e,t)=>t+1),c=e=>!(e<=t)&&(!!n&&!n(e));return e.jsxs("div",{className:Te("flex items-center gap-3",o),children:[e.jsxs(St,{children:[e.jsx(Tt,{asChild:!0,children:e.jsxs(Ee,{variant:"ghost",size:"sm",className:"h-auto py-1 px-2 text-sm text-muted-foreground hover:text-foreground",children:["Etapa ",t,"/",a,e.jsx(l.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),e.jsx(Dt,{align:"start",children:d.map(a=>e.jsxs(Rt,{onClick:()=>{var e;(e=a)<t?s(e):n&&!n(e)||s(e)},disabled:c(a),className:Te("cursor-pointer",a===t&&"bg-muted font-medium",c(a)&&"opacity-50 cursor-not-allowed"),children:[e.jsxs("span",{className:"mr-2 text-muted-foreground",children:[a,"."]}),r?.[a-1]||`Etapa ${a}`,a===t&&e.jsx(l.Check,{className:"h-4 w-4 ml-auto"})]},a))})]}),e.jsx(Qo,{value:t/a*100,className:Te("h-2",i)})]})},exports.Switch=nr,exports.TIMEZONES=Er,exports.TabPageContent=function({children:t,className:a}){return e.jsx("div",{className:Te("space-y-6",a),children:t})},exports.TabPageHeader=function({title:t,description:a,actions:s,className:r}){return e.jsxs("div",{className:Te("space-y-4",r),children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:t}),a&&e.jsx("p",{className:"text-muted-foreground text-sm",children:a})]}),s&&e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),e.jsx(Oe,{})]})},exports.TabPageLayout=function({children:t,className:a}){return e.jsx("div",{className:Te("flex flex-col h-full",a),children:e.jsx(tr,{className:"flex-1",children:e.jsx("div",{className:"space-y-6 p-6",children:t})})})},exports.Table=cs,exports.TableBody=ms,exports.TableCaption=gs,exports.TableCell=xs,exports.TableFooter=ps,exports.TableHead=fs,exports.TableHeader=us,exports.TableResizeHandle=js,exports.TableRow=hs,exports.TableRowActions=qs,exports.TableSkeleton=bs,exports.Tabs=Ui,exports.TabsContent=Bi,exports.TabsList=qi,exports.TabsTrigger=Oi,exports.Textarea=wt,exports.Toaster=kt,exports.Toggle=Vs,exports.ToggleGroup=Gs,exports.ToggleGroupItem=Ys,exports.TokenManager=xa,exports.TokenService=la,exports.Tooltip=Bt,exports.TooltipContent=$t,exports.TooltipProvider=Ot,exports.TooltipTrigger=Ht,exports.TranslationLoader=function({children:t}){return e.jsx(e.Fragment,{children:t})},exports.TruncatedCell=ys,exports.VideoEditor=function({value:a,onChange:s,onSubmit:r,onCancel:n,uploadFunction:o,deleteFunction:d,uploadOptions:c}){const[u,m]=t.useState(a||{inputType:"url",controls:!0}),p=t.useRef(null),h=t.useRef(null),{upload:f,uploading:x}=Zc({uploadFunction:o,deleteFunction:d,defaultOptions:{...c,allowedTypes:["video/*"],maxSize:104857600}}),{upload:g,uploading:b}=Zc({uploadFunction:o,deleteFunction:d,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),v=t.useMemo(()=>ru(u.videoUrl||su(u.embedCode)||""),[u.videoUrl,u.embedCode]),w=(e,t)=>{const a={...u,[e]:t};m(a),s(a)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{children:"Tipo de entrada"}),e.jsxs(dt,{value:u.inputType||"url",onValueChange:e=>w("inputType",e),children:[e.jsx(mt,{children:e.jsx(ut,{})}),e.jsxs(ft,{children:[e.jsx(gt,{value:"url",children:"URL"}),e.jsx(gt,{value:"upload",children:"Upload de arquivo"}),e.jsx(gt,{value:"embed",children:"Código embed"})]})]})]}),"upload"===u.inputType&&o&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{children:"Arquivo"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:p,type:"file",accept:"video/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await f(t),a={...u,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:u.title||t.name.replace(/\.[^/.]+$/,"")};m(a),s(a)}catch(a){}finally{p.current&&(p.current.value="")}},className:"hidden"}),e.jsx(Ee,{type:"button",variant:"outline",onClick:()=>p.current?.click(),disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),"Selecionar vídeo"]})}),u.videoFile&&e.jsxs("span",{className:"text-xs text-muted-foreground truncate self-center",children:["Arquivo: ",u.videoFile," (",Math.round((u.videoSize||0)/1024/1024)," MB)"]})]})]}),"embed"===u.inputType&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{children:"Código embed"}),e.jsx(wt,{placeholder:"Cole o código embed aqui",value:u.embedCode||"",onChange:e=>w("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),o&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{children:"Thumbnail"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Me,{type:"url",placeholder:"URL da thumbnail",value:u.thumbnail||"",onChange:e=>w("thumbnail",e.target.value),className:"flex-1"}),e.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await g(t),a={...u,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};m(a),s(a)}catch(a){}finally{h.current&&(h.current.value="")}},className:"hidden"}),e.jsx(Ee,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]}),u.thumbnailFile&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Thumbnail: ",u.thumbnailFile]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{htmlFor:"title",children:"Título"}),e.jsx(Me,{id:"title",placeholder:"Título do vídeo",value:u.title||"",onChange:e=>w("title",e.target.value)})]}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"autoplay",type:"checkbox",checked:u.autoplay||!1,onChange:e=>w("autoplay",e.target.checked),className:"h-4 w-4"}),e.jsx(De,{htmlFor:"autoplay",className:"cursor-pointer",children:"Autoplay"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"controls",type:"checkbox",checked:!1!==u.controls,onChange:e=>w("controls",e.target.checked),className:"h-4 w-4"}),e.jsx(De,{htmlFor:"controls",className:"cursor-pointer",children:"Controles"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{children:"Preview"}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const t=u.videoUrl||su(u.embedCode)||"";if(!t)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Nenhum conteúdo para visualizar"});if("file"===v)return e.jsxs("video",{controls:!1!==u.controls,autoPlay:u.autoplay,poster:u.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[e.jsx("source",{src:t}),"Seu navegador não suporta este vídeo."]});const a="youtube"===v?eu(t,u.autoplay):au(t,u.autoplay);return e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:u.title||"Vídeo",src:a,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(Ee,{variant:"outline",onClick:n,children:"Cancelar"}),e.jsx(Ee,{onClick:()=>{u.videoUrl||u.embedCode?r(u):i.toast.error("Erro",{description:"Nenhum vídeo selecionado"})},disabled:!(u.videoUrl||u.embedCode),children:"Salvar"})]})]})},exports.VideoRenderer=function({content:t,className:a="",style:s}){const r=t.videoUrl||su(t.embedCode)||"";if(!r)return null;const n=ru(r);return e.jsx(Re,{className:`overflow-hidden my-4 ${a}`,style:s,children:e.jsxs(Ue,{className:"p-0",children:["file"===n?e.jsxs("video",{controls:!1!==t.controls,autoPlay:t.autoplay,poster:t.thumbnail,className:"w-full h-auto",playsInline:!0,muted:t.autoplay,children:[e.jsx("source",{src:r}),"Seu navegador não suporta vídeos HTML5."]}):e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:t.title||"Vídeo",src:"youtube"===n?eu(r,t.autoplay):au(r,t.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),t.title&&e.jsx("div",{className:"p-4",children:e.jsx("p",{className:"text-sm font-medium",children:t.title})})]})})},exports.assets=Wl,exports.badgeVariants=Nt,exports.buildHierarchy=Ic,exports.buttonGroupVariants=yn,exports.buttonVariants=Ae,exports.calculateAspectRatio=nu,exports.cn=Te,exports.createCrudPage=function(t){return({manager:a})=>{const{manager:s,config:r,onSave:n,onEdit:o,onToggleStatus:i}=t,l=a??s,d={entityName:r.entityName,entityNamePlural:r.entityNamePlural,filters:r.filters||[],columns:r.columns,cardFields:r.cardFields||[],enableBulkActions:r.enableBulkActions??!1,bulkActions:r.bulkActions||[],customActions:r.customActions,customRowActions:r.customRowActions,customListView:r.customListView,onEdit:o||r.onEdit,onNew:r.onNew,useCustomRouting:r.useCustomRouting,hideNewButton:r.hideNewButton};return e.jsx(xr,{manager:l,config:d,formSections:r.formSections,onSave:n,onToggleStatus:i,defaultSort:r.defaultSort})}},exports.createCrudRoutingConfig=function(e,t){const a=jl({basePath:e,newPath:t.newPath,editPath:t.editPath});return{useCustomRouting:!0,onNew:a.onNew,onEdit:a.onEdit}},exports.createRoutingHandlers=jl,exports.createService=Ja,exports.createSimpleSaveHandler=function(e,t,a){return s=>{if(s.id){const t=a(s);e.updateEntity(s.id,t)}else{const a=t(s);e.createEntity(a)}}},exports.createSimpleService=function(e){const t=Ja({tableName:e.tableName,searchFields:e.searchFields||["title"],selectFields:e.selectFields,schemaName:e.schemaName||"central",entityName:e.entityName,enableQualiexEnrichment:e.enableQualiexEnrichment||!0,userIdFields:e.userIdFields,userFieldsMapping:e.userFieldsMapping});return{service:t,useCrudHook:(a,s)=>ds({queryKey:e.tableName,service:{...t,getAll:async(e={})=>await t.getAll({...e})},entityName:e.entityName,additionalFilters:a,onSuccess:s})}},exports.debounce=(e,t)=>{let a;return(...s)=>{clearTimeout(a),a=setTimeout(()=>e(...s),t)}},exports.deriveEmailField=Wa,exports.deriveNameField=Va,exports.deriveUsernameField=Ga,exports.detectBrowserLocale=Lr,exports.detectBrowserPreferences=()=>{const e=Lr();return{locale:e,timezone:zr(),datetimeFormat:Fr(e)}},exports.detectBrowserTimezone=zr,exports.detectVideoProvider=ru,exports.emailService=Nc,exports.errorService=va,exports.extractImageFileName=function(e){try{const t=new URL(e),a=t.pathname.split("/");return a[a.length-1]||"image"}catch{const t=e.split("/");return t[t.length-1]||"image"}},exports.extractVimeoId=tu,exports.extractYouTubeId=Jc,exports.filterAndPromoteOrphans=function(e,t){const a=e.map(e=>({...e})),s=new Set(a.filter(e=>!t.has(e.id_user)).map(e=>e.id_user));return a.forEach(e=>{if(e.id_leader&&s.has(e.id_leader)){let t=e.id_leader;for(;t&&s.has(t);){const e=a.find(e=>e.id_user===t);t=e?.id_leader||null}e.id_leader=t}}),a.filter(e=>t.has(e.id_user))},exports.findDatetimeFormat=e=>Ar.find(t=>t.value===e),exports.findLocale=e=>_r.find(t=>t.value===e),exports.findTimezone=e=>Er.find(t=>t.value===e),exports.flattenTree=Dc,exports.formatCurrency=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),exports.formatDate=vc,exports.formatDatetime=e=>{if(!e)return"";const t=o.parseISO(e);if(!o.isValid(t))return"Data inválida";return`${t.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",timeZone:"America/Sao_Paulo"})} ${t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit",timeZone:"America/Sao_Paulo"})}`},exports.formatFileSize=function(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`},exports.generateCrudConfig=function(e,t,a={}){const s=[];return Object.keys(t).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const a=t[e],r={key:e,header:br(e),label:br(e),...gr(e,a),sortable:!0,searchable:"string"==typeof a};s.push(r)}}),{title:e,columns:s,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...a}},exports.getQualiexConfig=Ba,exports.getSupabaseClient=Sa,exports.handleExternalLink=Se,exports.inferDatetimeFormat=Fr,exports.inputGroupAddonVariants=fo,exports.inputGroupButtonVariants=go,exports.isDevEnvironment=qa,exports.isImageUrl=function(e){const t=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"].some(e=>t.includes(e))},exports.isValidDatetimeFormat=e=>Ar.some(t=>t.value===e),exports.isValidLocale=Dr,exports.isValidTimezone=Rr,exports.logoSrc=Gl,exports.navigationMenuTriggerStyle=Lo,exports.normalizeVideoUrl=function(e,t,a){switch(t||ru(e)){case"youtube":return eu(e,a);case"vimeo":return au(e,a);default:return e}},exports.normalizeVimeoUrl=au,exports.normalizeYouTubeUrl=eu,exports.parseIframeSrc=su,exports.placeService=Mc,exports.qualiexApi=La,exports.resizeKeepingAspect=function(e,t,a,s){const r=nu(e,t);return a&&!s?{width:a,height:Math.round(a/r)}:s&&!a?{width:Math.round(s*r),height:s}:{width:e,height:t}},exports.resolveFieldMappings=Ya,exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new v.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.signService=du,exports.slugify=e=>e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-"),exports.smallLogoSrc=Yl,exports.toggleVariants=$s,exports.translationService=Tc,exports.trimTextFields=_e,exports.useActiveModules=(e={})=>{const{enabled:t=!0}=e,{alias:a}=ls();return v.useQuery({queryKey:["active-modules",a],queryFn:async()=>{if(!a)return[];const e=Sa(),{data:t,error:s}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",a).eq("status","active").order("name");if(s){if(!Pa.handleError(s))throw s;return[]}return t||[]},enabled:t&&!!a})},exports.useAuth=ls,exports.useBaseForm=Zs,exports.useColumnResize=Bs,exports.useCreateLeaderMutation=function(){const e="common",{alias:t}=ls(),a=v.useQueryClient(),s=Sa();return v.useMutation({mutationFn:async a=>{if(!t)throw new Error("Unidade não selecionada");if(a.id_user===a.id_leader)throw new Error("Usuário não pode ser seu próprio líder");if((await s.schema(e).from("leaders").select("id").eq("alias",t).eq("id_user",a.id_user).eq("is_removed",!1).maybeSingle()).data)throw new Error("Este usuário já está cadastrado como líder");a.id_leader&&await Oc(s,t,e,a.id_user,a.id_leader);const{data:r,error:n}=await s.schema(e).from("leaders").insert({alias:t,id_user:a.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return r},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",t]}),i.toast.success("Líder adicionado com sucesso")},onError:e=>{i.toast.error(e.message||"Erro ao adicionar líder")}})},exports.useCreateMultipleLeadersMutation=zc,exports.useCreateSingleLeaderMutation=Lc,exports.useCrud=ds,exports.useDebounce=Al,exports.useFormField=at,exports.useHasOpenModal=function(){const{hasOpenModal:e}=td();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:t}=Hr(),a=Mr;return{formatDatetime:s=>((e,t=Mr,a=Ir,s=Pr)=>{if(!e)return"";const r=o.parseISO(e);if(!o.isValid(r))return"Data inválida";const n=bc[s]||Qn;try{return gc(r,a,t,{locale:n})}catch(i){return gc(r,Ir,t,{locale:n})}})(s,a,t,e),formatDate:a=>vc(a,e,t),locale:e,timezone:t,datetimeFormat:a}},exports.useLeadershipApi=Rc,exports.useLocale=Hr,exports.useMediaUpload=Zc,exports.useModalState=td,exports.useNavigation=Tl,exports.usePageMetadata=function(e){const{setMetadata:a,clearMetadata:s}=Sr();t.useEffect(()=>(a(e),()=>s()),[e.title,e.subtitle,a,s])},exports.usePageMetadataContext=Sr,exports.usePageTitle=_l,exports.usePermissionQuery=Pl,exports.useQualiexUsers=or,exports.useRemoveLeaderMutation=Uc,exports.useRouteBreadcrumbs=function(){const e=w.useLocation();return(()=>{const t=e.pathname.split("/").filter(Boolean),a=[{label:"Exemplos",href:"/"}];let s="";return t.forEach((e,r)=>{s+=`/${e}`;const n=r===t.length-1,o=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");a.push({label:o,href:n?void 0:s,isCurrentPage:n})}),a})()},exports.useRowResize=Hs,exports.useSidebar=pi,exports.useSidebarResize=Jl,exports.useSignConfig=pu,exports.useSyncSubordinatesMutation=qc,exports.useUpdateLeaderMutation=Fc,exports.useWizard=function(e){const{steps:a,initialStep:s=0,initialData:r={},onComplete:n,onCancel:o}=e,[i,l]=t.useState(s),[d,c]=t.useState(r),[u,m]=t.useState(!1),[p,h]=t.useState(!1),f=a.length,x=0===i,g=i===f-1,b=a[i],v=f>1?(i+1)/f*100:100,w=t.useCallback(()=>!b?.canProceed||b.canProceed(),[b]),N=t.useMemo(()=>w(),[w,d]),y=t.useMemo(()=>!x&&!b?.disableBack,[x,b]),j=t.useCallback(e=>{c(t=>({...t,...e}))},[]),C=t.useCallback((e,t)=>{c(a=>({...a,[e]:t}))},[]),k=t.useCallback(()=>{l(s),c(r),m(!1),h(!1),o?.()},[s,r,o]),S=t.useCallback(async()=>{if(w()&&!p){h(!0);try{await(n?.(d))}finally{h(!1)}}},[w,p,d,n]),T=t.useCallback(async()=>{w()&&!u&&(g?await S():l(e=>Math.min(e+1,f-1)))},[w,u,g,f,S]),_=t.useCallback(()=>{y&&!u&&l(e=>Math.max(e-1,0))},[y,u]),A=t.useCallback(e=>{e<0||e>=f||u||(e<=i||e===i+1)&&l(e)},[i,f,u]),E=t.useCallback(e=>{m(e)},[]);return{currentStep:i,currentStepConfig:b,data:d,isFirstStep:x,isLastStep:g,isLoading:u,isCompleting:p,next:T,back:_,goTo:A,canProceed:N,canGoBack:y,setData:j,updateField:C,reset:k,complete:S,setLoading:E,progress:v,stepIndex:i,totalSteps:f}};
|